Isolation toolpath creation from GUI
This commit is contained in:
parent
0b16365ba2
commit
1e85c54266
75
cirkuix.py
75
cirkuix.py
|
@ -231,6 +231,17 @@ class App:
|
|||
|
||||
self.canvas.queue_draw()
|
||||
|
||||
def plot_geometry(self, geometry):
|
||||
for geo in geometry.solid_geometry:
|
||||
x, y = geo.exterior.coords.xy
|
||||
self.axes.plot(x, y, 'r-')
|
||||
for ints in geo.interiors:
|
||||
x, y = ints.coords.xy
|
||||
self.axes.plot(x, y, 'r-')
|
||||
|
||||
self.canvas.queue_draw()
|
||||
|
||||
|
||||
def setup_component_viewer(self):
|
||||
'''
|
||||
List or Tree where whatever has been loaded or created is
|
||||
|
@ -290,11 +301,23 @@ class App:
|
|||
entry_name.connect("activate", self.on_activate_name)
|
||||
box1.show()
|
||||
|
||||
def build_geometry_ui(self):
|
||||
print "build_geometry_ui()"
|
||||
osw = self.builder.get_object("offscrwindow_geometry")
|
||||
box1 = self.builder.get_object("box_geometry")
|
||||
osw.remove(box1)
|
||||
self.notebook.append_page(box1, Gtk.Label("Selection"))
|
||||
entry_name = self.builder.get_object("entry_geometryname")
|
||||
entry_name.set_text(self.selected_item_name)
|
||||
entry_name.connect("activate", self.on_activate_name)
|
||||
box1.show()
|
||||
|
||||
def plot_all(self):
|
||||
self.clear_plots()
|
||||
plotter = {"gerber":self.plot_gerber,
|
||||
"excellon":self.plot_excellon,
|
||||
"cncjob":self.plot_cncjob}
|
||||
"cncjob":self.plot_cncjob,
|
||||
"geometry":self.plot_geometry}
|
||||
|
||||
for i in self.stuff:
|
||||
kind = self.stuff[i].kind
|
||||
|
@ -311,6 +334,30 @@ class App:
|
|||
########################################
|
||||
## EVENT HANDLERS ##
|
||||
########################################
|
||||
def on_eval_update(self, widget):
|
||||
# TODO: error handling here
|
||||
widget.set_text(str(eval(widget.get_text())))
|
||||
|
||||
def on_generate_isolation(self, widget):
|
||||
print "Generating Isolation Geometry:"
|
||||
# Get required info
|
||||
tooldia = self.builder.get_object("entry_gerberisotooldia").get_text()
|
||||
tooldia = eval(tooldia)
|
||||
print "tooldia:", tooldia
|
||||
|
||||
# Generate
|
||||
iso = self.stuff[self.selected_item_name].isolation_geometry(tooldia/2.0)
|
||||
# TODO: This will break if there is something with this name already
|
||||
iso_name = self.selected_item_name + "_iso"
|
||||
geo = CirkuixGeometry(iso_name)
|
||||
geo.solid_geometry = iso
|
||||
|
||||
# Add to App and update.
|
||||
self.stuff[iso_name] = geo
|
||||
self.build_list()
|
||||
|
||||
|
||||
|
||||
def on_delete(self, widget):
|
||||
self.stuff.pop(self.selected_item_name)
|
||||
|
||||
|
@ -363,7 +410,8 @@ class App:
|
|||
# Build the UI
|
||||
builder = {"gerber": self.build_gerber_ui,
|
||||
"excellon": self.build_excellon_ui,
|
||||
"cncjob": self.build_cncjob_ui}
|
||||
"cncjob": self.build_cncjob_ui,
|
||||
"geometry": self.build_geometry_ui}
|
||||
builder[kind]()
|
||||
|
||||
def on_filequit(self, param):
|
||||
|
@ -460,8 +508,27 @@ class App:
|
|||
xmin, ymin, xmax, ymax = get_bounds(self.stuff)
|
||||
width = xmax-xmin
|
||||
height = ymax-ymin
|
||||
self.axes.set_xlim((xmin-0.05*width, xmax+0.05*width))
|
||||
self.axes.set_ylim((ymin-0.05*height, ymax+0.05*height))
|
||||
r = width/height
|
||||
|
||||
Fw, Fh = self.canvas.get_width_height()
|
||||
Fr = float(Fw)/Fh
|
||||
print "Window aspect ratio:", Fr
|
||||
print "Data aspect ratio:", r
|
||||
|
||||
#self.axes.set_xlim((xmin-0.05*width, xmax+0.05*width))
|
||||
#self.axes.set_ylim((ymin-0.05*height, ymax+0.05*height))
|
||||
|
||||
if r > Fr:
|
||||
self.axes.set_xlim((xmin-0.05*width, xmax+0.05*width))
|
||||
ycenter = (ymin+ymax)/2.0
|
||||
newheight = height*r/Fr
|
||||
self.axes.set_ylim((ycenter-newheight/2.0, ycenter+newheight/2.0))
|
||||
else:
|
||||
self.axes.set_ylim((ymin-0.05*height, ymax+0.05*height))
|
||||
xcenter = (xmax+ymin)/2.0
|
||||
newwidth = width*Fr/r
|
||||
self.axes.set_xlim((xcenter-newwidth/2.0, xcenter+newwidth/2.0))
|
||||
|
||||
self.canvas.queue_draw()
|
||||
return
|
||||
|
||||
|
|
235
cirkuix.ui
235
cirkuix.ui
|
@ -144,17 +144,7 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button4">
|
||||
<property name="label" translatable="yes">Refresh Plot</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">6</property>
|
||||
</packing>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
|
@ -296,18 +286,151 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button3">
|
||||
<property name="label" translatable="yes">Refresh Plot</property>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkOffscreenWindow" id="offscrwindow_geometry">
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="box_geometry">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">5</property>
|
||||
<property name="margin_right">5</property>
|
||||
<property name="margin_top">5</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label15">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="ypad">3</property>
|
||||
<property name="label" translatable="yes">Geometry Object</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="semibold"/>
|
||||
</attributes>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">6</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box8">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label16">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xpad">3</property>
|
||||
<property name="label" translatable="yes">Name: </property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="entry_geometryname">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="invisible_char">●</property>
|
||||
<property name="invisible_char_set">True</property>
|
||||
<signal name="activate" handler="on_activate_name" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label20">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="ypad">3</property>
|
||||
<property name="label" translatable="yes">Plot Options:</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="semibold"/>
|
||||
</attributes>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="cb_geometryplot">
|
||||
<property name="label" translatable="yes">Plot</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="cb_geometrysolid">
|
||||
<property name="label" translatable="yes">Solid</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="cb_multicolored4">
|
||||
<property name="label" translatable="yes">Multi-colored</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
|
@ -463,17 +586,7 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button2">
|
||||
<property name="label" translatable="yes">Refresh Plot</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">7</property>
|
||||
</packing>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label13">
|
||||
|
@ -496,7 +609,7 @@
|
|||
<object class="GtkGrid" id="grid2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="row_spacing">2</property>
|
||||
<property name="row_spacing">3</property>
|
||||
<property name="column_spacing">2</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label14">
|
||||
|
@ -514,11 +627,14 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="entry4">
|
||||
<object class="GtkEntry" id="entry_gerberisotooldia">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="margin_top">2</property>
|
||||
<property name="margin_bottom">2</property>
|
||||
<property name="invisible_char">●</property>
|
||||
<property name="invisible_char_set">True</property>
|
||||
<signal name="activate" handler="on_eval_update" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
@ -527,64 +643,6 @@
|
|||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label15">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="xpad">3</property>
|
||||
<property name="label" translatable="yes">Cut X:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="entry5">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="invisible_char">●</property>
|
||||
<property name="invisible_char_set">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label16">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="xpad">3</property>
|
||||
<property name="label" translatable="yes">Travel X:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="entry6">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="invisible_char">●</property>
|
||||
<property name="invisible_char_set">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -598,6 +656,8 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<signal name="activate" handler="on_generate_isolation" swapped="no"/>
|
||||
<signal name="clicked" handler="on_generate_isolation" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -1008,6 +1068,7 @@
|
|||
<property name="can_focus">True</property>
|
||||
<property name="invisible_char">●</property>
|
||||
<property name="text" translatable="yes">0.0</property>
|
||||
<signal name="activate" handler="on_eval_update" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
|
Loading…
Reference in New Issue