Commit c8c0eb7d authored by sumpfralle's avatar sumpfralle

implemented handling of multiple toolpaths via the GUI:

 * export multiple toolpaths to a single gcode file
 * sort toolpaths arbitrarily
 * deleted a toolpath from the list


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@177 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 728514ac
...@@ -7,6 +7,7 @@ Version 0.2 - UNRELEASED ...@@ -7,6 +7,7 @@ Version 0.2 - UNRELEASED
* handling of multiple processing templates (e.g. "Rough", "Semi-finish" and "Finish") * handling of multiple processing templates (e.g. "Rough", "Semi-finish" and "Finish")
* configure "material allowance" for a minimum distance between drill and model * configure "material allowance" for a minimum distance between drill and model
* configure the "safety height" for the machine * configure the "safety height" for the machine
* allow to manage and export (gcode) multiple toolpaths
* based on GtkGlExt (for OpenGL) * based on GtkGlExt (for OpenGL)
* visualize conflicting processing settings * visualize conflicting processing settings
* configure "overlap" instead of "lines" and "samples" * configure "overlap" instead of "lines" and "samples"
......
...@@ -455,8 +455,14 @@ class ProjectGui: ...@@ -455,8 +455,14 @@ class ProjectGui:
self.task_pane = self.gui.get_object("Tasks") self.task_pane = self.gui.get_object("Tasks")
self.gui.get_object("ProgressCancelButton").connect("clicked", self.cancel_progress) self.gui.get_object("ProgressCancelButton").connect("clicked", self.cancel_progress)
# make sure that the toolpath settings are consistent # make sure that the toolpath settings are consistent
self.toolpath_table = self.gui.get_object("ToolPathTable")
self.toolpath_model = self.gui.get_object("ToolPathListModel")
self.disable_invalid_toolpath_settings() self.disable_invalid_toolpath_settings()
self.gui.get_object("toolpath_visible").connect("toggled", self.toolpath_table_event) self.toolpath_table.get_selection().connect("changed", self.toolpath_table_event, "update_buttons")
self.gui.get_object("toolpath_visible").connect("toggled", self.toolpath_table_event, "toggle_visibility")
self.gui.get_object("toolpath_up").connect("clicked", self.toolpath_table_event, "move_up")
self.gui.get_object("toolpath_delete").connect("clicked", self.toolpath_table_event, "delete")
self.gui.get_object("toolpath_down").connect("clicked", self.toolpath_table_event, "move_down")
# speed and feedrate controls # speed and feedrate controls
speed_control = self.gui.get_object("SpeedControl") speed_control = self.gui.get_object("SpeedControl")
self.settings.add_item("speed", speed_control.get_value, speed_control.set_value) self.settings.add_item("speed", speed_control.get_value, speed_control.set_value)
...@@ -525,9 +531,6 @@ class ProjectGui: ...@@ -525,9 +531,6 @@ class ProjectGui:
self.gui.get_object("MaxStepDownControl").set_sensitive(self.settings.get("path_generator") == "PushCutter") self.gui.get_object("MaxStepDownControl").set_sensitive(self.settings.get("path_generator") == "PushCutter")
# "material allowance" requires ODE support # "material allowance" requires ODE support
self.gui.get_object("MaterialAllowanceControl").set_sensitive(self.settings.get("enable_ode")) self.gui.get_object("MaterialAllowanceControl").set_sensitive(self.settings.get("enable_ode"))
# toolpath table
self.toolpath_table = self.gui.get_object("ToolPathTable")
self.toolpath_model = self.gui.get_object("ToolPathListModel")
@gui_activity_guard @gui_activity_guard
def toggle_3d_view(self, widget=None, value=None): def toggle_3d_view(self, widget=None, value=None):
...@@ -742,33 +745,100 @@ class ProjectGui: ...@@ -742,33 +745,100 @@ class ProjectGui:
if section in config_list: if section in config_list:
self.processing_config_selection.set_active(config_list.index(section)) self.processing_config_selection.set_active(config_list.index(section))
def _toolpath_table_get_active_index(self):
if len(self.toolpath) == 0:
result = None
else:
treeselection = self.toolpath_table.get_selection()
(model, iteration) = treeselection.get_selected()
# the first item in the model is the index within the toolpath list
try:
result = model[iteration][0]
except TypeError:
result = None
return result
def _toolpath_table_set_active_index(self, index):
treeselection = self.toolpath_table.get_selection()
treeselection.select_path((index,))
@gui_activity_guard @gui_activity_guard
def toolpath_table_event(self, widget, path): def toolpath_table_event(self, widget, data, action=None):
if isinstance(widget, gtk.CellRendererToggle): # "toggle" uses two parameters - all other actions have only one
if action is None:
action = data
future_selection_index = None
skip_model_update = False
if action == "toggle_visibility":
try: try:
path = int(path) path = int(data)
except ValueError: except ValueError:
path = None path = None
if (not path is None) and (path < len(self.toolpath)): if (not path is None) and (path < len(self.toolpath)):
self.toolpath[path].visible = not self.toolpath[path].visible self.toolpath[path].visible = not self.toolpath[path].visible
# hide/show toolpaths according to the new setting # hide/show toolpaths according to the new setting
self.update_view() self.update_view()
self.update_toolpath_table() elif action == "update_buttons":
skip_model_update = True
elif action in ("move_up", "move_down", "delete"):
index = self._toolpath_table_get_active_index()
if action == "move_up":
if index > 0:
# move a toolpath one position up the list
selected = self.toolpath[index]
above = self.toolpath[index-1]
self.toolpath[index] = above
self.toolpath[index-1] = selected
future_selection_index = index - 1
elif action == "move_down":
if index + 1 < len(self.toolpath):
# move a toolpath one position down the list
selected = self.toolpath[index]
below = self.toolpath[index+1]
self.toolpath[index] = below
self.toolpath[index+1] = selected
future_selection_index = index + 1
else:
# delete one toolpath from the list
self.toolpath.remove(self.toolpath[index])
# don't set a new index, if the list emptied
if len(self.toolpath) > 0:
if index < len(self.toolpath):
future_selection_index = index
else:
# the last item was removed
future_selection_index = len(self.toolpath) - 1
# hide the deleted toolpath immediately
self.update_view()
self.update_toolpath_table(new_index=future_selection_index, skip_model_update=skip_model_update)
def update_toolpath_table(self): def update_toolpath_table(self, new_index=None, skip_model_update=False):
# show or hide the "toolpath" tab # show or hide the "toolpath" tab
toolpath_tab = self.gui.get_object("ToolPathTab") toolpath_tab = self.gui.get_object("ToolPathTab")
if self.toolpath is None: if self.toolpath is None:
toolpath_tab.hide() toolpath_tab.hide()
else: else:
toolpath_tab.show() toolpath_tab.show()
# reset the model data and the selection
if new_index is None:
# keep the old selection - this may return "None" if nothing is selected
new_index = self._toolpath_table_get_active_index()
if not skip_model_update:
# update the TreeModel data # update the TreeModel data
self.toolpath_model.clear() model = self.toolpath_model
model.clear()
# columns: name, visible, drill_size, drill_id, allowance, speed, feedrate # columns: name, visible, drill_size, drill_id, allowance, speed, feedrate
for tp in self.toolpath: for index in range(len(self.toolpath)):
items = (tp.name, tp.visible, tp.drill_size, tp = self.toolpath[index]
items = (index, tp.name, tp.visible, tp.drill_size,
tp.drill_id, tp.material_allowance, tp.speed, tp.feedrate) tp.drill_id, tp.material_allowance, tp.speed, tp.feedrate)
self.toolpath_model.append(items) model.append(items)
if not new_index is None:
self._toolpath_table_set_active_index(new_index)
# enable/disable the modification buttons
self.gui.get_object("toolpath_up").set_sensitive((not new_index is None) and (new_index > 0))
self.gui.get_object("toolpath_delete").set_sensitive(not new_index is None)
self.gui.get_object("toolpath_down").set_sensitive((not new_index is None) and (new_index + 1 < len(self.toolpath)))
@gui_activity_guard @gui_activity_guard
def save_processing_settings_file(self, widget=None, section=None): def save_processing_settings_file(self, widget=None, section=None):
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
</object> </object>
<object class="GtkListStore" id="ToolPathListModel"> <object class="GtkListStore" id="ToolPathListModel">
<columns> <columns>
<!-- column-name index -->
<column type="guint"/>
<!-- column-name name --> <!-- column-name name -->
<column type="gchararray"/> <column type="gchararray"/>
<!-- column-name visible --> <!-- column-name visible -->
...@@ -27,22 +29,24 @@ ...@@ -27,22 +29,24 @@
</columns> </columns>
<data> <data>
<row> <row>
<col id="0" translatable="yes">Rough</col> <col id="0">0</col>
<col id="1">True</col> <col id="1" translatable="yes">Rough</col>
<col id="2">12</col> <col id="2">True</col>
<col id="3">0</col> <col id="3">12</col>
<col id="4">0</col> <col id="4">0</col>
<col id="5">0</col> <col id="5">0</col>
<col id="6">0</col> <col id="6">0</col>
<col id="7">0</col>
</row> </row>
<row> <row>
<col id="0" translatable="yes">test</col> <col id="0">0</col>
<col id="1">False</col> <col id="1" translatable="yes">test</col>
<col id="2">0</col> <col id="2">False</col>
<col id="3">0</col> <col id="3">0</col>
<col id="4">0</col> <col id="4">0</col>
<col id="5">0</col> <col id="5">0</col>
<col id="6">0</col> <col id="6">0</col>
<col id="7">0</col>
</row> </row>
</data> </data>
</object> </object>
...@@ -2214,7 +2218,7 @@ ...@@ -2214,7 +2218,7 @@
<child> <child>
<object class="GtkCellRendererToggle" id="toolpath_visible"/> <object class="GtkCellRendererToggle" id="toolpath_visible"/>
<attributes> <attributes>
<attribute name="active">1</attribute> <attribute name="active">2</attribute>
</attributes> </attributes>
</child> </child>
</object> </object>
...@@ -2225,7 +2229,7 @@ ...@@ -2225,7 +2229,7 @@
<child> <child>
<object class="GtkCellRendererText" id="name"/> <object class="GtkCellRendererText" id="name"/>
<attributes> <attributes>
<attribute name="text">0</attribute> <attribute name="text">1</attribute>
</attributes> </attributes>
</child> </child>
</object> </object>
...@@ -2236,13 +2240,13 @@ ...@@ -2236,13 +2240,13 @@
<child> <child>
<object class="GtkCellRendererText" id="drill_id"/> <object class="GtkCellRendererText" id="drill_id"/>
<attributes> <attributes>
<attribute name="text">3</attribute> <attribute name="text">4</attribute>
</attributes> </attributes>
</child> </child>
<child> <child>
<object class="GtkCellRendererText" id="drill_size"/> <object class="GtkCellRendererText" id="drill_size"/>
<attributes> <attributes>
<attribute name="text">2</attribute> <attribute name="text">3</attribute>
</attributes> </attributes>
</child> </child>
</object> </object>
...@@ -2253,13 +2257,13 @@ ...@@ -2253,13 +2257,13 @@
<child> <child>
<object class="GtkCellRendererText" id="speed-speed"/> <object class="GtkCellRendererText" id="speed-speed"/>
<attributes> <attributes>
<attribute name="text">5</attribute> <attribute name="text">6</attribute>
</attributes> </attributes>
</child> </child>
<child> <child>
<object class="GtkCellRendererText" id="speed-feedrate"/> <object class="GtkCellRendererText" id="speed-feedrate"/>
<attributes> <attributes>
<attribute name="text">6</attribute> <attribute name="text">7</attribute>
</attributes> </attributes>
</child> </child>
</object> </object>
...@@ -2270,7 +2274,7 @@ ...@@ -2270,7 +2274,7 @@
<child> <child>
<object class="GtkCellRendererText" id="allowance"/> <object class="GtkCellRendererText" id="allowance"/>
<attributes> <attributes>
<attribute name="text">6</attribute> <attribute name="text">5</attribute>
</attributes> </attributes>
</child> </child>
</object> </object>
...@@ -2297,7 +2301,6 @@ ...@@ -2297,7 +2301,6 @@
<object class="GtkButton" id="toolpath_up"> <object class="GtkButton" id="toolpath_up">
<property name="label">gtk-go-up</property> <property name="label">gtk-go-up</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="receives_default">True</property>
<property name="use_stock">True</property> <property name="use_stock">True</property>
...@@ -2312,7 +2315,6 @@ ...@@ -2312,7 +2315,6 @@
<object class="GtkButton" id="toolpath_delete"> <object class="GtkButton" id="toolpath_delete">
<property name="label">gtk-delete</property> <property name="label">gtk-delete</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="receives_default">True</property>
<property name="use_stock">True</property> <property name="use_stock">True</property>
...@@ -2327,7 +2329,6 @@ ...@@ -2327,7 +2329,6 @@
<object class="GtkButton" id="toolpath_down"> <object class="GtkButton" id="toolpath_down">
<property name="label">gtk-go-down</property> <property name="label">gtk-go-down</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="receives_default">True</property>
<property name="use_stock">True</property> <property name="use_stock">True</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment