merge
This commit is contained in:
2
.idea/Trac3r.iml
generated
2
.idea/Trac3r.iml
generated
@@ -2,7 +2,7 @@
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.6 (Trac3r)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="TestRunnerService">
|
||||
|
||||
45
Simulator.py
Normal file
45
Simulator.py
Normal file
@@ -0,0 +1,45 @@
|
||||
import sys, pygame
|
||||
import threading
|
||||
|
||||
|
||||
|
||||
class EventThread(threading.Thread):
|
||||
def __init__(self):
|
||||
super(EventThread, self).__init__()
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
for events in pygame.event.get():
|
||||
if events.type == pygame.QUIT:
|
||||
pygame.display.quit()
|
||||
pygame.quit()
|
||||
|
||||
|
||||
class Simulator:
|
||||
def __init__(self):
|
||||
|
||||
pygame.init()
|
||||
|
||||
self.size = width, height = 320, 240
|
||||
self.black = 0, 0, 0
|
||||
self.red=(255,0,0)
|
||||
|
||||
self.screen = pygame.display.set_mode(self.size)
|
||||
|
||||
def render(self):
|
||||
|
||||
self.screen.fill(self.black)
|
||||
pygame.draw.line(self.screen, self.red, (60, 80), (130, 100))
|
||||
pygame.display.flip()
|
||||
t = EventThread()
|
||||
t.start()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
50
main.py
50
main.py
@@ -1,3 +1,4 @@
|
||||
from math import sqrt
|
||||
from tkinter import *
|
||||
from tkinter import filedialog
|
||||
from tkinter.ttk import Notebook
|
||||
@@ -8,6 +9,26 @@ import os
|
||||
from GCodeRenderer import Renderer
|
||||
from Svg2GcodeConverter import Svg2GcodeConverter
|
||||
from ImageConverter import ImageConverter
|
||||
from Simulator import Simulator
|
||||
|
||||
|
||||
def xy_to_radial(settings, current_xy, dest_xy, pulley_diameter):
|
||||
|
||||
# maybe check for the distance of the move. Split it up into multiple to avoid distortion
|
||||
|
||||
# get the current length of the left pulley wire
|
||||
b = (settings.left_pulley_x_offset - settings.pulley_diameter + current_xy[0])
|
||||
a = settings.pulley_y_droop
|
||||
|
||||
length = sqrt(pow(a, 2) + pow(b, 2))
|
||||
# get the current length of the right pulley wire
|
||||
|
||||
|
||||
# get the desired length of the left pulley wire
|
||||
# get the desired length of the right pulley wire
|
||||
|
||||
return
|
||||
|
||||
|
||||
class Settings:
|
||||
|
||||
@@ -16,12 +37,13 @@ class Settings:
|
||||
# ============ HARDCODED VALUES ===========
|
||||
|
||||
# Canvas size
|
||||
self.canvas_x = 300
|
||||
self.canvas_y = 300
|
||||
self.canvas_x = 700
|
||||
self.canvas_y = 700
|
||||
|
||||
# The position of the pulley centers in relation to the top left and right of the canvas
|
||||
self.left_pulley_xy_offset = (-40, 40)
|
||||
self.right_pulley_xy_offset = (40, 40)
|
||||
self.left_pulley_x_offset = -40
|
||||
self.right_pulley_x_offset = 40
|
||||
self.pulley_y_droop = 60
|
||||
|
||||
# Diameter of the inner portion of the pulley in millimeters
|
||||
self.pulley_diameter = 45
|
||||
@@ -34,9 +56,7 @@ class Settings:
|
||||
self.lift_counter = 0
|
||||
# ============ CALCULATED VALUES ===========
|
||||
|
||||
self.distance_between_centers = abs(self.left_pulley_xy_offset[0]) + self.canvas_x + self.right_pulley_xy_offset[0]
|
||||
|
||||
|
||||
self.distance_between_centers = abs(self.left_pulley_x_offset) + self.canvas_x + self.right_pulley_x_offset
|
||||
|
||||
|
||||
# Main GUI class and program entry point
|
||||
@@ -92,11 +112,14 @@ class Tracer(Tk):
|
||||
self.rightframe = Frame(self)
|
||||
self.rightframe.pack(side=RIGHT)
|
||||
|
||||
self.button = Button(self.rightframe, text="Select Image", command=self.file_select_callback)
|
||||
self.button.pack()
|
||||
self.image_select_button = Button(self.rightframe, text="Select Image", command=self.file_select_callback)
|
||||
self.image_select_button.pack()
|
||||
|
||||
self.button = Button(self.rightframe, text="Re-Render", command=self.render)
|
||||
self.button.pack()
|
||||
self.rerender_button = Button(self.rightframe, text="Re-Render", command=self.render)
|
||||
self.rerender_button.pack()
|
||||
|
||||
self.render_simulation_button = Button(self.rightframe, text="Render Simulation", command=self.render_simulation)
|
||||
self.render_simulation_button.pack()
|
||||
|
||||
self.lift_markers_checkbox = Checkbutton(self.rightframe, text="Lift Markers", command=self.cairo_renderer.toggle_flip_markers)
|
||||
self.lift_markers_checkbox.pack()
|
||||
@@ -157,6 +180,11 @@ class Tracer(Tk):
|
||||
self.n.add(self.f2, text="Original")
|
||||
self.label1.pack(expand=True, fill="both")
|
||||
|
||||
def render_simulation(self):
|
||||
|
||||
simulator = Simulator()
|
||||
simulator.render()
|
||||
|
||||
if __name__ == "__main__":
|
||||
Tracer()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user