Commit b5e69ecc authored by sumpfralle's avatar sumpfralle

moved process handling to a separate plugin


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1117 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 989d52e8
<?xml version="1.0"?>
<interface>
<!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy project-wide -->
<object class="GtkAdjustment" id="EngraveOffsetValue">
<property name="lower">-1000</property>
<property name="upper">1000</property>
<property name="step_increment">0.5</property>
</object>
<object class="GtkAdjustment" id="OverlapPercentValue">
<property name="upper">99</property>
<property name="step_increment">5</property>
</object>
<object class="GtkAdjustment" id="MaxStepDownValue">
<property name="lower">0.01</property>
<property name="upper">100</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="MaterialAllowanceValue">
<property name="upper">100</property>
<property name="step_increment">0.10000000000000001</property>
</object>
<object class="GtkListStore" id="PocketingOptions">
<columns>
<!-- column-name name -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">none</col>
</row>
<row>
<col id="0" translatable="yes">holes</col>
</row>
<row>
<col id="0" translatable="yes">enclosed</col>
</row>
</data>
</object>
<object class="GtkWindow" id="window1">
<child>
<object class="GtkVPaned" id="ProcessBox">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkHBox" id="hbox11">
<property name="visible">True</property>
<property name="spacing">3</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow5">
<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="ProcessEditorTable">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="model">ProcessList</property>
<property name="headers_clickable">False</property>
<property name="enable_search">False</property>
<property name="search_column">0</property>
<child>
<object class="GtkTreeViewColumn" id="NameColumn">
<property name="title">Name</property>
<property name="expand">True</property>
<child>
<object class="GtkCellRendererText" id="NameCell"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="DescriptionColumn">
<property name="title">Description</property>
<child>
<object class="GtkCellRendererText" id="DescriptionCell"/>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox20">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkVButtonBox" id="vbuttonbox2">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="layout_style">center</property>
<child>
<object class="GtkButton" id="ProcessNew">
<property name="label">gtk-new</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="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="ProcessDelete">
<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="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="ProcessMoveUp">
<property name="label">gtk-go-up</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="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="ProcessMoveDown">
<property name="label">gtk-go-down</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="fill">False</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLinkButton" id="ProcessHelp">
<property name="label">gtk-help</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief">none</property>
<property name="use_stock">True</property>
<property name="uri">http://sourceforge.net/apps/mediawiki/pycam/index.php?title=ProcessSettings</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">False</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="ProcessSettingsControlsBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">4</property>
<child>
<object class="GtkHSeparator" id="hseparator7">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox29">
<property name="visible">True</property>
<child>
<object class="GtkFrame" id="frame8">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment7">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkVBox" id="vbox21">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">1</property>
<child>
<object class="GtkRadioButton" id="PushRemoveStrategy">
<property name="label" translatable="yes">Slice removal</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="ContourPolygonStrategy">
<property name="label" translatable="yes">Contour (polygon)</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">PushRemoveStrategy</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="ContourFollowStrategy">
<property name="label" translatable="yes">Contour (follow)</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">PushRemoveStrategy</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="SurfaceStrategy">
<property name="label" translatable="yes">Surface</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">PushRemoveStrategy</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="EngraveStrategy">
<property name="label" translatable="yes">Engraving</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">PushRemoveStrategy</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">4</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="ToolpathStrategy">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Path Strategy&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="GtkVSeparator" id="vseparator9">
<property name="visible">True</property>
<property name="orientation">vertical</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="PathSettingsFrame">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment9">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkTable" id="table7">
<property name="visible">True</property>
<property name="n_rows">5</property>
<property name="n_columns">2</property>
<property name="column_spacing">2</property>
<property name="row_spacing">2</property>
<child>
<object class="GtkLabel" id="OverlapLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Overlap [%]:</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="OverlapPercentControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">OverlapPercentValue</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="MaterialAllowanceLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Material Allowance:</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="MaterialAllowanceControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">MaterialAllowanceValue</property>
<property name="digits">2</property>
</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>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="MaxStepDownControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">MaxStepDownValue</property>
<property name="digits">2</property>
</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>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="StepDownLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Max. Step Down:</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="EngraveOffsetLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Engrave Offset:</property>
</object>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="EngraveOffsetControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">EngraveOffsetValue</property>
<property name="digits">2</property>
</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>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="PocketingLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Pocketing:</property>
</object>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="PocketingControl">
<property name="visible">True</property>
<property name="model">PocketingOptions</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext7"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="PathSettingsFrameLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Path Control&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkHSeparator" id="hseparator4">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame11">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment17">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkHBox" id="hbox13">
<property name="visible">True</property>
<child>
<object class="GtkHBox" id="hbox31">
<property name="visible">True</property>
<property name="spacing">4</property>
<child>
<object class="GtkLabel" id="GridDirectionLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="label" translatable="yes">Grid direction:</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox15">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkRadioButton" id="GridDirectionX">
<property name="label" translatable="yes">x</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="GridDirectionY">
<property name="label" translatable="yes">y</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">GridDirectionX</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="GridDirectionXY">
<property name="label" translatable="yes">both </property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">GridDirectionX</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkVSeparator" id="vseparator8">
<property name="visible">True</property>
<property name="orientation">vertical</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="MillingStyleLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="label" translatable="yes">Milling Style:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox33">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkRadioButton" id="MillingStyleConventional">
<property name="label" translatable="yes">conventional / up</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="MillingStyleClimb">
<property name="label" translatable="yes">climb / down</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">MillingStyleConventional</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="MillingStyleIgnore">
<property name="label" translatable="yes">ignore</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="group">MillingStyleConventional</property>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">4</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="PathDirectionFrameLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Path Direction&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="resize">False</property>
<property name="shrink">False</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkListStore" id="ProcessList">
<columns>
<!-- column-name ref -->
<column type="gulong"/>
<!-- column-name name -->
<column type="gchararray"/>
</columns>
</object>
</interface>
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -140,7 +140,6 @@ PREFERENCES_DEFAULTS = {
""" the listed items will be loaded/saved via the preferences file in the
user's home directory on startup/shutdown"""
POCKETING_TYPES = ["none", "holes", "enclosed"]
MAX_UNDO_STATES = 10
FILENAME_DRAG_TARGETS = ("text/uri-list", "text-plain")
......@@ -488,7 +487,7 @@ class ProjectGui(object):
def add_main_tab_item(item, name):
main_tab.append_page(item, gtk.Label(name))
# TODO: move these to plugins, as well
tab_names = ("Processes", "Bounds", "Tasks", "Toolpaths")
tab_names = ("Bounds", "Tasks", "Toolpaths")
for name in tab_names:
item = self.gui.get_object(name + "Tab")
item.unparent()
......@@ -671,27 +670,6 @@ class ProjectGui(object):
self.settings.add_item("drill_progress_max_fps", skip_obj.get_value, skip_obj.set_value)
sim_detail_obj = self.gui.get_object("SimulationDetailsValue")
self.settings.add_item("simulation_details_level", sim_detail_obj.get_value, sim_detail_obj.set_value)
# connect the "consistency check" and the update-handler with all toolpath settings
for objname in ("PushRemoveStrategy", "ContourPolygonStrategy",
"ContourFollowStrategy", "SurfaceStrategy",
"EngraveStrategy", "GridDirectionX", "GridDirectionY",
"GridDirectionXY", "MillingStyleConventional",
"MillingStyleClimb", "MillingStyleIgnore"):
self.gui.get_object(objname).connect("toggled",
self.update_process_controls)
self.gui.get_object(objname).connect("toggled",
self.handle_process_settings_change)
for objname in ("OverlapPercentControl", "MaterialAllowanceControl",
"MaxStepDownControl", "EngraveOffsetControl"):
self.gui.get_object(objname).connect("value-changed",
self.handle_process_settings_change)
self.gui.get_object("ProcessSettingName").connect("changed",
self.handle_process_settings_change)
pocketing_selector = self.gui.get_object("PocketingControl")
self.settings.add_item("pocketing_type", pocketing_selector.get_active,
pocketing_selector.set_active)
pocketing_selector.connect("changed",
self.handle_process_settings_change)
# get/set functions for the current tool/process/bounds/task
def get_current_item(table, item_list):
index = self._treeview_get_active_index(table, item_list)
......@@ -710,9 +688,7 @@ class ProjectGui(object):
else:
self._treeview_set_active_index(table, new_index)
# update all controls related the (possibly changed) item
if item_list is self.process_list:
self.append_to_queue(self.switch_process_table_selection)
elif item_list is self.task_list:
if item_list is self.task_list:
self.append_to_queue(self.switch_tasklist_table_selection)
# the boundary manager
self.settings.add_item("current_bounds",
......@@ -744,12 +720,6 @@ class ProjectGui(object):
self.settings.add_item("current_process",
lambda: get_current_item(self.process_editor_table, self.process_list),
lambda process: set_current_item(self.process_editor_table, self.process_list, process))
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")
self.gui.get_object("ProcessListMoveDown").connect("clicked", self.handle_process_table_event, "move_down")
self.gui.get_object("ProcessListAdd").connect("clicked", self.handle_process_table_event, "add")
self.gui.get_object("ProcessListDelete").connect("clicked", self.handle_process_table_event, "delete")
# make sure that the toolpath settings are consistent
self.toolpath_table = self.gui.get_object("ToolPathTable")
self.toolpath_table.get_selection().connect("changed", self.toolpath_table_event, "update_buttons")
......@@ -1017,8 +987,6 @@ class ProjectGui(object):
def update_all_controls(self):
self.update_toolpath_table()
self.update_process_controls()
self.update_process_table()
self.update_bounds_table()
self.update_tasklist_table()
self.update_save_actions()
......@@ -1452,8 +1420,7 @@ class ProjectGui(object):
current_task = self.settings.get("current_task")
if not current_task is None:
self.settings.get("tools").select(current_task["tool"])
self.settings.set("current_process", current_task["process"])
self.update_process_table(skip_model_update=True)
self.settings.get("processes").select(current_task["process"])
self.settings.set("current_bounds", current_task["bounds"])
self.update_bounds_table(skip_model_update=True)
self.update_tasklist_controls()
......@@ -1553,55 +1520,6 @@ class ProjectGui(object):
progress.update_multiple()
progress.finish()
def update_process_controls(self, widget=None, data=None):
# possible dependencies of the DropCutter
get_obj = self.gui.get_object
strategy = None
for one_strategy in ("PushRemoveStrategy", "ContourPolygonStrategy",
"ContourFollowStrategy", "SurfaceStrategy", "EngraveStrategy"):
if get_obj(one_strategy).get_active():
strategy = one_strategy
break
else:
raise ValueError("Invalid path strategy selected")
if strategy == "ContourPolygonStrategy" \
and not get_obj("MillingStyleIgnore").get_active():
get_obj("MillingStyleIgnore").set_active(True)
if strategy == "ContourPolygonStrategy" \
and not get_obj("GridDirectionX").get_active():
# only "x" direction for ContourPolygon
get_obj("GridDirectionX").set_active(True)
if strategy in ("ContourFollowStrategy", "EngraveStrategy") \
and get_obj("MillingStyleIgnore").get_active():
get_obj("MillingStyleConventional").set_active(True)
all_controls = ("GridDirectionX", "GridDirectionY", "GridDirectionXY",
"MillingStyleConventional", "MillingStyleClimb",
"MillingStyleIgnore", "MaxStepDownControl",
"MaterialAllowanceControl", "OverlapPercentControl",
"EngraveOffsetControl", "PocketingControl")
active_controls = {
"PushRemoveStrategy": ("GridDirectionX", "GridDirectionY",
"GridDirectionXY", "MillingStyleConventional",
"MillingStyleClimb", "MillingStyleIgnore",
"MaxStepDownControl", "MaterialAllowanceControl",
"OverlapPercentControl"),
# TODO: direction y and xy currently don't work for ContourPolygonStrategy
"ContourPolygonStrategy": ("GridDirectionX",
"MillingStyleIgnore", "MaxStepDownControl",
"MaterialAllowanceControl", "OverlapPercentControl"),
"ContourFollowStrategy": ("MillingStyleConventional",
"MillingStyleClimb", "MaxStepDownControl"),
"SurfaceStrategy": ("GridDirectionX", "GridDirectionY",
"GridDirectionXY", "MillingStyleConventional",
"MillingStyleClimb", "MillingStyleIgnore",
"MaterialAllowanceControl", "OverlapPercentControl"),
"EngraveStrategy": ("MaxStepDownControl", "EngraveOffsetControl",
"MillingStyleConventional", "MillingStyleClimb",
"PocketingControl"),
}
for one_control in all_controls:
get_obj(one_control).set_sensitive(one_control in active_controls[strategy])
@gui_activity_guard
def toggle_about_window(self, widget=None, event=None, state=None):
# only "delete-event" uses four arguments
......@@ -1890,9 +1808,10 @@ class ProjectGui(object):
progress.finish()
if self.gui.get_object("UnitChangeProcesses").get_active():
# scale the process settings
for process in self.process_list:
for key in ("material_allowance", "step_down",
"engrave_offset"):
for process in self.processes:
for key in ("MaterialAllowanceControl",
"MaxStepDownControl",
"EngraveOffsetControl"):
process[key] *= factor
if self.gui.get_object("UnitChangeBounds").get_active():
# scale the boundaries and keep their center
......@@ -2265,14 +2184,12 @@ class ProjectGui(object):
if not filename is None:
settings.load_file(filename)
# flush all tables (without re-assigning new objects)
for one_list in (self.settings.get("tools"), self.process_list, self.bounds_list, self.task_list):
for one_list in (self.settings.get("tools"), self.settings.get("processes"), self.bounds_list, self.task_list):
while len(one_list) > 0:
one_list.pop()
#self.settings.get("tools").extend(settings.get_tools())
self.process_list.extend(settings.get_processes())
self.bounds_list.extend(settings.get_bounds())
self.task_list.extend(settings.get_tasks())
self.update_process_table()
self.update_bounds_table()
self.update_tasklist_table()
......@@ -2441,6 +2358,7 @@ class ProjectGui(object):
elif action == "delete":
self.append_to_queue(self.switch_bounds_table_selection)
# TODO: PROCESS-PLUGIN
def _load_process_settings_from_gui(self, settings=None):
if settings is None:
settings = {}
......@@ -2477,6 +2395,7 @@ class ProjectGui(object):
self.gui.get_object("PocketingControl").get_active()]
return settings
# TODO: PROCESS-PLUGIN
def _put_process_settings_to_gui(self, settings):
self.gui.get_object("ProcessSettingName").set_text(settings["name"])
# path direction
......@@ -2506,73 +2425,6 @@ class ProjectGui(object):
self.gui.get_object("PocketingControl").set_active(
POCKETING_TYPES.index(settings["pocketing_type"]))
@gui_activity_guard
def handle_process_settings_change(self, widget=None, data=None):
current_process = self.settings.get("current_process")
if not current_process is None:
self._load_process_settings_from_gui(current_process)
self.update_process_table()
def update_process_table(self, new_index=None, skip_model_update=False):
# 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._treeview_get_active_index(self.process_editor_table, self.process_list)
if not skip_model_update:
# update the TreeModel data
model = self.gui.get_object("ProcessList")
model.clear()
# columns: index, description
for index in range(len(self.process_list)):
process = self.process_list[index]
items = (index, process["name"])
model.append(items)
if not new_index is None:
self._treeview_set_active_index(self.process_editor_table, new_index)
# enable/disable the modification buttons
self.gui.get_object("ProcessListMoveUp").set_sensitive((not new_index is None) and (new_index > 0))
self.gui.get_object("ProcessListDelete").set_sensitive(not new_index is None)
self.gui.get_object("ProcessListMoveDown").set_sensitive((not new_index is None) and (new_index + 1 < len(self.process_list)))
# hide all controls if no process is defined
if new_index is None:
self.gui.get_object("ProcessSettingsControlsBox").hide()
else:
self.gui.get_object("ProcessSettingsControlsBox").show()
# remove any broken tasks and update changed names
self.update_task_description()
@gui_activity_guard
def switch_process_table_selection(self, widget=None, data=None):
current_process = self.settings.get("current_process")
if not current_process is None:
self.gui.get_object("ProcessSettingsControlsBox").show()
self._put_process_settings_to_gui(current_process)
self.update_process_table()
else:
self.gui.get_object("ProcessSettingsControlsBox").hide()
@gui_activity_guard
def handle_process_table_event(self, widget, data, action=None):
# "toggle" uses two parameters - all other actions have only one
if action is None:
action = data
self._treeview_button_event(self.process_editor_table, self.process_list, action, self.update_process_table)
# do some post-processing ...
if action == "add":
# look for the first unused default name
prefix = "New Process "
index = 1
# loop while the current name is in use
while [True for process in self.process_list if process["name"] == "%s%d" % (prefix, index)]:
index += 1
new_settings = self._load_process_settings_from_gui()
new_settings["name"] = "%s%d" % (prefix, index)
self.process_list.append(new_settings)
self.update_process_table(self.process_list.index(new_settings))
self._put_process_settings_to_gui(new_settings)
elif action == "delete":
self.append_to_queue(self.switch_process_table_selection)
@gui_activity_guard
def toolpath_table_event(self, widget, data, action=None):
# "toggle" uses two parameters - all other actions have only one
......
# -*- coding: utf-8 -*-
"""
$Id$
Copyright 2011 Lars Kruse <devel@sumpfralle.de>
This file is part of PyCAM.
PyCAM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
PyCAM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
"""
import pycam.Plugins
from pycam.PathGenerators.PushCutter import PushCutter
from pycam.PathGenerators.ContourFollow import ContourFollow
from pycam.PathGenerators.DropCutter import DropCutter
from pycam.PathGenerators.EngraveCutter import EngraveCutter
class Processes(pycam.Plugins.ListPluginBase):
UI_FILE = "processes.ui"
COLUMN_REF, COLUMN_NAME = range(2)
LIST_ATTRIBUTE_MAP = {"ref": COLUMN_REF, "name": COLUMN_NAME}
CONTROL_BUTTONS = ("PushRemoveStrategy", "ContourPolygonStrategy",
"ContourFollowStrategy", "SurfaceStrategy", "EngraveStrategy",
"OverlapPercentControl", "MaterialAllowanceControl",
"MaxStepDownControl", "EngraveOffsetControl",
"PocketingControl", "GridDirectionX", "GridDirectionY",
"GridDirectionXY", "MillingStyleConventional", "MillingStyleClimb",
"MillingStyleIgnore")
POCKETING_TYPES = ["none", "holes", "enclosed"]
CONTROL_SIGNALS = ("toggled", "value-changed", "changed")
CONTROL_GET = ("get_active", "get_value")
CONTROL_SET = ("set_active", "set_value")
def setup(self):
if self.gui:
import gtk
self._gtk = gtk
process_frame = self.gui.get_object("ProcessBox")
process_frame.unparent()
self.core.register_ui("main", "Processs", process_frame, weight=20)
self._modelview = self.gui.get_object("ProcessEditorTable")
for action, obj_name in ((self.ACTION_UP, "ProcessMoveUp"),
(self.ACTION_DOWN, "ProcessMoveDown"),
(self.ACTION_DELETE, "ProcessDelete")):
self.register_list_action_button(action, self._modelview,
self.gui.get_object(obj_name))
self.gui.get_object("ProcessNew").connect("clicked",
self._process_new)
selection = self._modelview.get_selection()
selection.connect("changed",
lambda widget, event: self.core.emit_event(event),
"process-selection-changed")
self.gui.get_object("NameCell").connect("edited",
self._edit_process_name)
cell = self.gui.get_object("DescriptionCell")
self.gui.get_object("DescriptionColumn").set_cell_data_func(
cell, self._render_process_description)
self._treemodel = self.gui.get_object("ProcessList")
self._treemodel.clear()
def update_model():
if not hasattr(self, "_model_cache"):
self._model_cache = {}
cache = self._model_cache
for row in self._treemodel:
cache[row[self.COLUMN_REF]] = list(row)
self._treemodel.clear()
for index, item in enumerate(self):
if not id(item) in cache:
cache[id(item)] = [id(item), "Process #%d" % index]
self._treemodel.append(cache[id(item)])
self.register_model_update(update_model)
# process settings
self._detail_handlers = []
for objname in self.CONTROL_BUTTONS:
obj = self.gui.get_object(objname)
for signal in self.CONTROL_SIGNALS:
try:
handler = obj.connect(signal,
lambda *args: self.core.emit_event(args[-1]),
"process-changed")
self._detail_handlers.append((obj, handler))
break
except TypeError:
continue
else:
self.log.info("Failed to connect to widget '%s'" % str(objname))
self.core.register_event("process-selection-changed",
self._process_change)
self.core.register_event("process-changed",
self._update_process_controls)
self._update_process_controls()
self.core.set("processes", self)
return True
def teardown(self):
if self.gui:
self.core.unregister_ui("main", self.gui.get_object("ProcessBox"))
self.core.set("processes", None)
return True
def get_selected(self, index=False):
return self._get_selected(self._modelview, index=index)
def select(self, process):
if process in self:
selection = self._modelview.get_selection()
index = [id(p) for p in self].index(id(p))
selection.unselect_all()
selection.select_path((index,))
def _render_process_description(self, column, cell, model, m_iter):
path = model.get_path(m_iter)
data = self[path[0]]
# find the current strategy
for key in ("PushRemoveStrategy", "ContourPolygonStrategy",
"ContourFollowStrategy", "SurfaceStrategy", "EngraveStrategy"):
if data[key]:
strategy = key
break
if strategy == "PushRemoveStrategy":
text = "Slice %g%s %d%%" % (data["MaxStepDownControl"],
self.core.get("unit"), data["OverlapPercentControl"])
elif strategy == "ContourPolygonStrategy":
text = "Contour (polygon) %g%s" % (data["MaxStepDownControl"],
self.core.get("unit"))
elif strategy == "ContourFollowStrategy":
text = "Contour (follow) %g%s" % (data["MaxStepDownControl"],
self.core.get("unit"))
elif strategy == "SurfaceStrategy":
text = "Surface %d%%" % data["OverlapPercentControl"]
else:
# EngraveStrategy
text = "Engrave %g%s" % (data["EngraveOffsetControl"],
self.core.get("unit"))
cell.set_property("text", text)
def _edit_process_name(self, cell, path, new_text):
path = int(path)
if (new_text != self._treemodel[path][self.COLUMN_NAME]) and \
new_text:
self._treemodel[path][self.COLUMN_NAME] = new_text
def _update_process_controls(self):
data = self.get_selected()
if data is None:
self.gui.get_object("ProcessSettingsControlsBox").hide()
return
else:
for obj_name in self.CONTROL_BUTTONS:
obj = self.gui.get_object(obj_name)
for get_func in self.CONTROL_GET:
if hasattr(obj, get_func):
value = getattr(obj, get_func)()
data[obj_name] = value
break
else:
log.info("Failed to update value of control %s" % objname)
self.gui.get_object("ProcessSettingsControlsBox").show()
while not self._validate_process_consistency():
pass
# trigger a table update - this is clumsy!
cell = self.gui.get_object("DescriptionColumn")
renderer = self.gui.get_object("DescriptionCell")
cell.set_cell_data_func(renderer, self._render_process_description)
def _process_change(self, widget=None, data=None):
process = self.get_selected()
control_box = self.gui.get_object("ProcessSettingsControlsBox")
if not process:
control_box.hide()
else:
for obj, handler in self._detail_handlers:
obj.handler_block(handler)
for obj_name, value in process.iteritems():
obj = self.gui.get_object(obj_name)
for set_func in self.CONTROL_SET:
if hasattr(obj, set_func):
if (value is False) and hasattr(obj, "get_group"):
# no "False" for radio buttons
pass
else:
getattr(obj, set_func)(value)
break
else:
log.info("Failed to set value of control %s" % objname)
for obj, handler in self._detail_handlers:
obj.handler_unblock(handler)
control_box.show()
def _process_new(self, *args):
current_process_index = self.get_selected(index=True)
if current_process_index is None:
current_process_index = 0
new_process = {"PushRemoveStrategy": True,
"ContourPolygonStrategy": False,
"ContourFollowStrategy": False,
"SurfaceStrategy": False,
"EngraveStrategy": False,
"OverlapPercentControl": 10,
"MaterialAllowanceControl": 0,
"MaxStepDownControl": 1,
"EngraveOffsetControl": 0,
"PocketingControl": self.POCKETING_TYPES.index("none"),
"GridDirectionX": True,
"GridDirectionY": False,
"GridDirectionXY": False,
"MillingStyleConventional": False,
"MillingStyleClimb": False,
"MillingStyleIgnore": True,
}
self.append(new_process)
self.select(new_process)
# loop until the process is valid
while not self._validate_process_consistency():
pass
def _validate_process_consistency(self):
data = self.get_selected()
if not data:
return True
if data["ContourPolygonStrategy"] and not data["MillingStyleIgnore"]:
data["MillingStyleConventional"] = False
data["MillingStyleIgnore"] = True
data["MillingStyleClimb"] = False
self.gui.get_object("MillingStyleIgnore").set_active(True)
return False
if data["ContourPolygonStrategy"] and not data["GridDirectionX"]:
# only "x" direction for ContourPolygon
data["GridDirectionX"] = True
data["GridDirectionY"] = False
data["GridDirectionXY"] = False
self.gui.get_object("GridDirectionX").set_active(True)
return False
if (data["ContourFollowStrategy"] or data["EngraveStrategy"]) \
and data["MillingStyleIgnore"]:
data["MillingStyleConventional"] = True
data["MillingStyleIgnore"] = False
data["MillingStyleClimb"] = False
self.gui.get_object("MillingStyleConventional").set_active(True)
return False
all_controls = ("GridDirectionX", "GridDirectionY", "GridDirectionXY",
"MillingStyleConventional", "MillingStyleClimb",
"MillingStyleIgnore", "MaxStepDownControl",
"MaterialAllowanceControl", "OverlapPercentControl",
"EngraveOffsetControl", "PocketingControl")
active_controls = {
"PushRemoveStrategy": ("GridDirectionX", "GridDirectionY",
"GridDirectionXY", "MillingStyleConventional",
"MillingStyleClimb", "MillingStyleIgnore",
"MaxStepDownControl", "MaterialAllowanceControl",
"OverlapPercentControl"),
# TODO: direction y and xy currently don't work for ContourPolygonStrategy
"ContourPolygonStrategy": ("GridDirectionX",
"MillingStyleIgnore", "MaxStepDownControl",
"MaterialAllowanceControl", "OverlapPercentControl"),
"ContourFollowStrategy": ("MillingStyleConventional",
"MillingStyleClimb", "MaxStepDownControl"),
"SurfaceStrategy": ("GridDirectionX", "GridDirectionY",
"GridDirectionXY", "MillingStyleConventional",
"MillingStyleClimb", "MillingStyleIgnore",
"MaterialAllowanceControl", "OverlapPercentControl"),
"EngraveStrategy": ("MaxStepDownControl", "EngraveOffsetControl",
"MillingStyleConventional", "MillingStyleClimb",
"PocketingControl"),
}
# find the current strategy
for key in active_controls:
if data[key]:
strategy = key
break
# disable all invalid controls
for one_control in all_controls:
self.gui.get_object(one_control).set_sensitive(one_control in active_controls[strategy])
return True
......@@ -68,11 +68,10 @@ class Tools(pycam.Plugins.ListPluginBase):
cache[row[self.COLUMN_ID]] = list(row)
self._treemodel.clear()
for index, item in enumerate(self):
if id(item) in cache:
if not id(item) in cache:
cache[id(item)] = [id(item), index + 1,
"Tool #%d" % index]
self._treemodel.append(cache[id(item)])
else:
self._treemodel.append((id(item), index + 1,
"Tool #%d" % index))
self.register_model_update(update_model)
# drill settings
self._detail_handlers = []
......@@ -109,7 +108,8 @@ class Tools(pycam.Plugins.ListPluginBase):
def select(self, tool):
if tool in self:
selection = self._modelview.get_selection()
index = self.index(tool)
# check for identity instead of equality
index = [id(t) for t in self].index(id(tool))
selection.unselect_all()
selection.select_path((index,))
......@@ -165,8 +165,13 @@ class Tools(pycam.Plugins.ListPluginBase):
else:
args = []
new_tool = cutter_class(radius, *args)
self.pop(tool_index)
old_tool = self.pop(tool_index)
self.insert(tool_index, new_tool)
if hasattr(self, "_model_cache"):
# move the cache item
cache = self._model_cache
cache[id(new_tool)] = cache[id(old_tool)]
del cache[id(old_tool)]
self.select(new_tool)
def _tool_change(self, widget=None, data=None):
......@@ -202,6 +207,6 @@ class Tools(pycam.Plugins.ListPluginBase):
if current_tool_index is None:
current_tool_index = 0
new_tool = CylindricalCutter(1.0)
self.insert(current_tool_index, new_tool)
self.append(new_tool)
self.select(new_tool)
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