Commit e1a75c81 authored by sumpfralle's avatar sumpfralle

finished implementation of new task/bounds interface

 * only +/- buttons for bounds interface are still missing


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@404 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 834bc28a
......@@ -381,8 +381,18 @@ class ProjectGui:
if self.gui.get_object(objname).get_active():
return key
self.settings.add_item("boundary_type", get_boundary_type, set_boundary_type)
# connect change handler for boundary settings
self.gui.get_object("BoundsName").connect("changed",
self.handle_bounds_settings_change)
for objname in ("BoundsTypeRelativeMargin", "BoundsTypeFixedMargin",
"BoundsTypeCustom"):
self.gui.get_object(objname).connect("toggled",
self.handle_bounds_settings_change)
for objname in ("boundary_x_low", "boundary_x_high", "boundary_y_low",
"boundary_y_high", "boundary_z_low", "boundary_z_high"):
self.gui.get_object(objname).connect("value-changed",
self.handle_bounds_settings_change)
# the process manager
self.process_table = self.gui.get_object("ProcessListTable")
self.process_editor_table = self.gui.get_object("ProcessEditorTable")
self.process_editor_table.get_selection().connect("changed", self.switch_process_table_selection)
self.gui.get_object("ProcessListMoveUp").connect("clicked", self.handle_process_table_event, "move_up")
......@@ -407,7 +417,6 @@ class ProjectGui:
# store the original content (for adding the number of current toolpaths in "update_toolpath_table")
self._original_toolpath_tab_label = self.gui.get_object("ToolPathTabLabel").get_text()
# tool editor
self.tool_table = self.gui.get_object("ToolListTable")
self.tool_editor_table = self.gui.get_object("ToolEditorTable")
self.tool_editor_table.get_selection().connect("changed", self.switch_tool_editor_table_selection)
self.gui.get_object("ToolListMoveUp").connect("clicked", self._tool_editor_button_event, "move_up")
......@@ -417,8 +426,6 @@ class ProjectGui:
# the task list manager
self.tasklist_table = self.gui.get_object("TaskListTable")
self.tasklist_table.get_selection().connect("changed", self.update_tasklist_controls)
self.tool_table.get_selection().connect("changed", self.update_tasklist_controls)
self.process_table.get_selection().connect("changed", self.update_tasklist_controls)
self.gui.get_object("tasklist_enabled").connect("toggled", self._handle_tasklist_button_event, "toggle_enabled")
self.gui.get_object("TaskListMoveUp").connect("clicked", self._handle_tasklist_button_event, "move_up")
self.gui.get_object("TaskListMoveDown").connect("clicked", self._handle_tasklist_button_event, "move_down")
......@@ -426,6 +433,16 @@ class ProjectGui:
self.gui.get_object("TaskListDelete").connect("clicked", self._handle_tasklist_button_event, "delete")
self.gui.get_object("GenerateToolPathButton").connect("clicked", self._handle_tasklist_button_event, "generate_one_toolpath")
self.gui.get_object("GenerateAllToolPathsButton").connect("clicked", self._handle_tasklist_button_event, "generate_all_toolpaths")
# We need to collect the signal handles to block them during
# programmatical changes.
self._task_property_signals = []
for objname, signal in (("TaskNameControl", "focus-out-event"),
("TaskToolSelector", "changed"),
("TaskProcessSelector", "changed"),
("TaskBoundsSelector", "changed")):
obj = self.gui.get_object(objname)
self._task_property_signals.append((obj,
obj.connect(signal, self._handle_task_setting_change)))
# menu bar
uimanager = gtk.UIManager()
self._accel_group = uimanager.get_accel_group()
......@@ -551,12 +568,6 @@ class ProjectGui:
self.update_view()
def update_tasklist_controls(self, widget=None, data=None):
# check if both the tool and the process table have a selected row
all_are_active = True
for control in (self.tool_table, self.process_table):
if control.get_selection().get_selected()[1] is None:
all_are_active = False
self.gui.get_object("TaskListAdd").set_sensitive(all_are_active)
# en/disable some buttons
index = self._treeview_get_active_index(self.tasklist_table, self.task_list)
selection_active = not index is None
......@@ -564,6 +575,16 @@ class ProjectGui:
self.gui.get_object("TaskListMoveUp").set_sensitive(selection_active and index > 0)
self.gui.get_object("TaskListMoveDown").set_sensitive(selection_active and index < len(self.task_list) - 1)
self.gui.get_object("GenerateToolPathButton").set_sensitive(selection_active)
# "add" is only allowed, if there are any tools, processes and bounds
self.gui.get_object("TaskListAdd").set_sensitive(
(len(self.tool_list) > 0) \
and (len(self.process_list) > 0) \
and (len(self.bounds_list) > 0))
details_box = self.gui.get_object("TaskDetails")
if selection_active:
details_box.show()
else:
details_box.hide()
# check if any of the tasks is marked as "enabled"
enabled_count = len([True for task in self.task_list if task["enabled"]])
self.gui.get_object("GenerateAllToolPathsButton").set_sensitive(enabled_count > 0)
......@@ -572,8 +593,19 @@ class ProjectGui:
task_index = self._treeview_get_active_index(self.tasklist_table, self.task_list)
if (not task_index is None) and (task_index < len(self.task_list)):
task = self.task_list[task_index]
# block all "change" signals for the task controls
for obj, signal_handler in self._task_property_signals:
obj.handler_block(signal_handler)
self.gui.get_object("TaskNameControl").set_text(task["name"])
tool = task["tool"]
self.gui.get_object("TaskToolSelector").set_active(self.tool_list.index(tool))
process = task["process"]
self.gui.get_object("TaskProcessSelector").set_active(self.process_list.index(process))
bounds = task["bounds"]
self.gui.get_object("TaskBoundsSelector").set_active(self.bounds_list.index(bounds))
# unblock the signals again
for obj, signal_handler in self._task_property_signals:
obj.handler_unblock(signal_handler)
unit = self.settings.get("unit")
tool_desc = "Tool: %s " % tool["shape"]
if tool["shape"] != "ToroidalCutter":
......@@ -600,15 +632,37 @@ class ProjectGui:
tasklist_model.clear()
# remove broken tasks from the list (tool or process was deleted)
self.task_list = [task for task in self.task_list
if (task["tool"] in self.tool_list) and (task["process"] in self.process_list)]
if (task["tool"] in self.tool_list) \
and (task["process"] in self.process_list) \
and (task["bounds"] in self.bounds_list)]
counter = 0
for task in self.task_list:
tasklist_model.append((counter, task["tool"]["name"], task["process"]["name"], task["enabled"]))
tasklist_model.append((counter, task["name"], task["enabled"]))
counter += 1
if not new_index is None:
self._treeview_set_active_index(self.tasklist_table, new_index)
self.update_tasklist_controls()
@gui_activity_guard
def _handle_task_setting_change(self, widget, data=None):
# get the index of the currently selected task
try:
current_task_index = self._treeview_get_active_index(self.tasklist_table, self.task_list)
except ValueError:
current_task_index = None
if current_task_index is None:
return
task = self.task_list[current_task_index]
task["name"] = self.gui.get_object("TaskNameControl").get_text()
tool_id = self.gui.get_object("TaskToolSelector").get_active()
task["tool"] = self.tool_list[tool_id]
process_id = self.gui.get_object("TaskProcessSelector").get_active()
task["process"] = self.process_list[process_id]
bounds_id = self.gui.get_object("TaskBoundsSelector").get_active()
task["bounds"] = self.bounds_list[bounds_id]
# update the tasklist table (especially for name changes)
self.update_tasklist_table()
@gui_activity_guard
def _handle_tasklist_button_event(self, widget, data, action=None):
# "toggle" uses two parameters - all other actions have only one
......@@ -621,11 +675,17 @@ class ProjectGui:
current_task_index = None
self._treeview_button_event(self.tasklist_table, self.task_list, action, self.update_tasklist_table)
if action == "add":
tool_index = self._treeview_get_active_index(self.tool_table, self.tool_list)
process_index = self._treeview_get_active_index(self.process_table, self.process_list)
new_task = {}
new_task["tool"] = self.tool_list[tool_index]
new_task["process"] = self.process_list[process_index]
# look for the first unused default name
prefix = "New Task "
index = 1
# loop while the current name is in use
while [True for task in self.task_list if task["name"] == "%s%d" % (prefix, index)]:
index += 1
new_task["name"] = "%s%d" % (prefix, index)
new_task["tool"] = self.tool_list[0]
new_task["process"] = self.process_list[0]
new_task["bounds"] = self.bounds_list[0]
new_task["enabled"] = True
self.task_list.append(new_task)
self.update_tasklist_table(self.task_list.index(new_task))
......@@ -1326,9 +1386,11 @@ class ProjectGui:
settings.load_file(filename)
self.tool_list = settings.get_tools()
self.process_list = settings.get_processes()
self.bounds_list = settings.get_bounds()
self.task_list = settings.get_tasks()
self.update_tool_table()
self.update_process_table()
self.update_bounds_table()
self.update_tasklist_table()
def _put_bounds_settings_to_gui(self, settings):
......@@ -1343,7 +1405,7 @@ class ProjectGui:
def _load_bounds_settings_from_gui(self, settings=None):
if settings is None:
settings = {}
settings["name"] = self.gui.get_object("ToolName").get_text()
settings["name"] = self.gui.get_object("BoundsName").get_text()
settings["type"] = self.settings.get("boundary_type")
for key in ("x_low", "x_high", "y_low", "y_high", "z_low", "z_high"):
settings[key] = self.settings.get("boundary_%s" % key)
......@@ -1617,7 +1679,9 @@ class ProjectGui:
if not filename:
return
settings = pycam.Gui.Settings.ProcessSettings()
if not settings.write_to_file(filename, self.tool_list, self.process_list, self.task_list) and not no_dialog and not self.no_dialog:
if not settings.write_to_file(filename, self.tool_list,
self.process_list, self.bounds_list, self.task_list) \
and not no_dialog and not self.no_dialog:
show_error_dialog(self.window, "Failed to save settings file")
def toggle_progress_bar(self, status):
......
......@@ -63,26 +63,6 @@
<column type="guint"/>
</columns>
</object>
<object class="GtkListStore" id="TaskList">
<columns>
<!-- column-name index -->
<column type="guint"/>
<!-- column-name tool -->
<column type="gchararray"/>
<!-- column-name process -->
<column type="gchararray"/>
<!-- column-name enabled -->
<column type="gboolean"/>
</columns>
<data>
<row>
<col id="0">0</col>
<col id="1" translatable="yes">SphericalCutter (2mm)</col>
<col id="2" translatable="yes">PushCutter Contour</col>
<col id="3">False</col>
</row>
</data>
</object>
<object class="GtkListStore" id="ScaleDimensionAxesList">
<columns>
<!-- column-name value -->
......@@ -182,6 +162,23 @@
</row>
</data>
</object>
<object class="GtkListStore" id="TaskList">
<columns>
<!-- column-name index -->
<column type="guint"/>
<!-- column-name name -->
<column type="gchararray"/>
<!-- column-name enabled -->
<column type="gboolean"/>
</columns>
<data>
<row>
<col id="0">0</col>
<col id="1" translatable="yes">Rough</col>
<col id="2">False</col>
</row>
</data>
</object>
<object class="GtkWindow" id="ProjectWindow">
<property name="title" translatable="yes">PyCAM</property>
<property name="destroy_with_parent">True</property>
......@@ -2948,33 +2945,22 @@ This operation is not available for engraving.</property>
<child>
<object class="GtkCellRendererToggle" id="tasklist_enabled"/>
<attributes>
<attribute name="active">3</attribute>
<attribute name="active">2</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="tasklist_tool">
<property name="title">Tool</property>
<object class="GtkTreeViewColumn" id="tasklist_name">
<property name="title">Name</property>
<child>
<object class="GtkCellRendererText" id="tasklist_tool_name"/>
<object class="GtkCellRendererText" id="tasklist_name_cell"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="tasklist_process">
<property name="title">Process</property>
<child>
<object class="GtkCellRendererText" id="tasklist_process_name"/>
<attributes>
<attribute name="text">2</attribute>
</attributes>
</child>
</object>
</child>
</object>
</child>
</object>
......@@ -3020,8 +3006,8 @@ This operation is not available for engraving.</property>
</packing>
</child>
<child>
<object class="GtkButton" id="TaskListDelete">
<property name="label">gtk-remove</property>
<object class="GtkButton" id="TaskListAdd">
<property name="label">gtk-new</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
......@@ -3032,6 +3018,19 @@ This operation is not available for engraving.</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="TaskListDelete">
<property name="label">gtk-delete</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkButton" id="TaskListMoveUp">
<property name="label">gtk-go-up</property>
......@@ -3042,7 +3041,7 @@ This operation is not available for engraving.</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
<property name="position">4</property>
</packing>
</child>
<child>
......@@ -3055,7 +3054,7 @@ This operation is not available for engraving.</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">4</property>
<property name="position">5</property>
</packing>
</child>
</object>
......@@ -3074,203 +3073,199 @@ This operation is not available for engraving.</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="CurrentTaskSummaryFrame">
<object class="GtkVBox" id="TaskDetails">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkAlignment" id="alignment27">
<object class="GtkHSeparator" id="hseparator13">
<property name="visible">True</property>
<property name="left_padding">12</property>
</object>
<packing>
<property name="expand">False</property>
<property name="padding">3</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkTable" id="table9">
<property name="visible">True</property>
<property name="n_rows">4</property>
<property name="n_columns">2</property>
<property name="column_spacing">5</property>
<property name="row_spacing">3</property>
<child>
<object class="GtkLabel" id="CurrentTaskSummary">
<object class="GtkLabel" id="TaskToolLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="ellipsize">end</property>
<property name="max_width_chars">60</property>
<property name="label" translatable="yes">Tool:</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="CurrentTaskSummaryFrameLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Summary:</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="TaskListFrameLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Task list&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox17">
<property name="visible">True</property>
<property name="spacing">3</property>
<child>
<object class="GtkFrame" id="ToolSelectionFrame">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment16">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">etched-in</property>
<child>
<object class="GtkTreeView" id="ToolListTable">
<property name="width_request">180</property>
<property name="height_request">120</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">ToolList</property>
<property name="headers_clickable">False</property>
<property name="rules_hint">True</property>
<property name="enable_search">False</property>
<property name="search_column">0</property>
<child>
<object class="GtkTreeViewColumn" id="tool_id_column">
<property name="title">ID</property>
<object class="GtkLabel" id="TaskProcessLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Process:</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="TaskBoundsLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Bounds:</property>
</object>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="TaskToolSelector">
<property name="visible">True</property>
<property name="model">ToolList</property>
<child>
<object class="GtkCellRendererText" id="tool_id"/>
<object class="GtkCellRendererText" id="ToolListCell"/>
<attributes>
<attribute name="text">2</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="TaskProcessSelector">
<property name="visible">True</property>
<property name="model">ProcessList</property>
<child>
<object class="GtkCellRendererText" id="ProcessListCell"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkTreeViewColumn" id="Description">
<property name="title">Description</property>
<object class="GtkComboBox" id="TaskBoundsSelector">
<property name="visible">True</property>
<property name="model">BoundsList</property>
<child>
<object class="GtkCellRendererText" id="tool_description"/>
<object class="GtkCellRendererText" id="BoundsListCell"/>
<attributes>
<attribute name="text">2</attribute>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="TaskNameLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Name:</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="TaskNameControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="ToolSelectionFrameLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Tool selection&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment23">
<property name="visible">True</property>
<property name="yscale">0</property>
<child>
<object class="GtkButton" id="TaskListAdd">
<property name="label">gtk-connect</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Connect the currently selected tool (left) with the current process settings (right).
This combination is added to the above task list.</property>
<property name="use_stock">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="ProcessSelectionFrame">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment20">
<property name="visible">True</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow4">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<property name="shadow_type">etched-in</property>
<child>
<object class="GtkTreeView" id="ProcessListTable">
<property name="width_request">180</property>
<property name="height_request">120</property>
<object class="GtkFrame" id="CurrentTaskSummaryFrame">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">ProcessList</property>
<property name="headers_clickable">False</property>
<property name="rules_hint">True</property>
<property name="enable_search">False</property>
<property name="search_column">0</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkTreeViewColumn" id="Description1">
<property name="title">Description</property>
<object class="GtkAlignment" id="alignment27">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkCellRendererText" id="ProcessDescription"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
<object class="GtkLabel" id="CurrentTaskSummary">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="ellipsize">end</property>
<property name="max_width_chars">60</property>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="CurrentTaskSummaryFrameLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Summary:&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="padding">10</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="ProcessSelectionFrameLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Process selection&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
<child type="label">
<object class="GtkLabel" id="TaskListFrameLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Task list&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
......
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