Commit 0e0466b3 authored by sumpfralle's avatar sumpfralle

more separation for the support grid plugins

some minor refactoring regarding support models
fixed minor issue with "register_ui" being called after "register_ui_section"


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1066 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 8a7037e6
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
<object class="GtkVBox" id="vbox17"> <object class="GtkVBox" id="vbox17">
<property name="visible">True</property> <property name="visible">True</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">5</property>
<child> <child>
<object class="GtkHBox" id="hbox26"> <object class="GtkHBox" id="hbox26">
<property name="visible">True</property> <property name="visible">True</property>
...@@ -27,7 +28,7 @@ ...@@ -27,7 +28,7 @@
<child> <child>
<object class="GtkCellRendererText" id="SupportGridTypesCell"/> <object class="GtkCellRendererText" id="SupportGridTypesCell"/>
<attributes> <attributes>
<attribute name="text">0</attribute> <attribute name="text">1</attribute>
</attributes> </attributes>
</child> </child>
</object> </object>
...@@ -43,6 +44,7 @@ ...@@ -43,6 +44,7 @@
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
...@@ -55,376 +57,52 @@ ...@@ -55,376 +57,52 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<child> <child>
<object class="GtkHBox" id="hbox1"> <object class="GtkAlignment" id="alignment1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="spacing">3</property> <property name="left_padding">30</property>
<child> <child>
<object class="GtkAlignment" id="alignment20"> <object class="GtkHBox" id="hbox1">
<property name="width_request">40</property>
<property name="visible">True</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="SupportGridThicknessLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">thickness:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="SupportGridThicknessControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridThickness</property>
<property name="digits">2</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkVSeparator" id="vseparator10">
<property name="visible">True</property>
<property name="orientation">vertical</property>
</object>
<packing>
<property name="expand">False</property>
<property name="padding">3</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="SupportGridHeightLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">height:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="SupportGridHeightControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridHeight</property>
<property name="digits">2</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">5</property>
</packing>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="GridProfileExpanderLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Profile</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkExpander" id="GridPatternExpander">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="expanded">True</property>
<child>
<object class="GtkTable" id="table10">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">4</property>
<property name="column_spacing">4</property>
<property name="row_spacing">1</property>
<child>
<object class="GtkLabel" id="SupportGridDistanceXLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">distance x:</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="SupportGridDistanceYLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">distance y:</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="SupportGridDistanceXControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridDistanceX</property>
<property name="digits">2</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="SupportGridDistanceYControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridDistanceY</property>
<property name="digits">2</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</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="GtkCheckButton" id="SupportGridDistanceSquare">
<property name="label" translatable="yes">square grid</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment23">
<property name="width_request">40</property>
<property name="visible">True</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment33">
<property name="width_request">40</property>
<property name="visible">True</property>
<child>
<placeholder/>
</child>
</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>
<placeholder/>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="GridPatternExpanderLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Pattern</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkExpander" id="GridPositionExpander">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkHBox" id="hbox17">
<property name="visible">True</property>
<property name="spacing">4</property>
<child>
<object class="GtkAlignment" id="alignment37">
<property name="width_request">40</property>
<property name="visible">True</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="GridOffsetXLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">offset x:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="SupportGridOffsetXControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridOffsetX</property>
<property name="digits">2</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkVSeparator" id="vseparator2">
<property name="visible">True</property>
<property name="orientation">vertical</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="GridOffsetYLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">offset y:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="SupportGridOffsetYControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridOffsetY</property>
<property name="digits">2</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">5</property>
</packing>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="GridPositionExpanderLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Position offset</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkExpander" id="GridManualShiftExpander">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkVBox" id="vbox12">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkHBox" id="hbox24">
<property name="visible">True</property> <property name="visible">True</property>
<property name="spacing">3</property> <property name="spacing">3</property>
<child> <child>
<object class="GtkRadioButton" id="SupportGridPositionManualAxisX"> <object class="GtkLabel" id="SupportGridThicknessLabel">
<property name="label" translatable="yes">x</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="xalign">0</property>
<property name="receives_default">False</property> <property name="label" translatable="yes">thickness:</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="padding">10</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkRadioButton" id="SupportGridPositionManualAxisY"> <object class="GtkSpinButton" id="SupportGridThicknessControl">
<property name="label" translatable="yes">y</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">False</property> <property name="invisible_char">&#x25CF;</property>
<property name="draw_indicator">True</property> <property name="adjustment">SupportGridThickness</property>
<property name="group">SupportGridPositionManualAxisX</property> <property name="digits">2</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="padding">10</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkVSeparator" id="vseparator7"> <object class="GtkVSeparator" id="vseparator10">
<property name="visible">True</property> <property name="visible">True</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="padding">3</property>
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="GridPositionManualSelectionLabel"> <object class="GtkLabel" id="SupportGridHeightLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0</property> <property name="label" translatable="yes">height:</property>
<property name="label" translatable="yes">Grid item:</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -432,21 +110,12 @@ ...@@ -432,21 +110,12 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkComboBox" id="SupportGridPositionManualSelector"> <object class="GtkSpinButton" id="SupportGridHeightControl">
<property name="visible">True</property> <property name="visible">True</property>
<property name="model">SupportGridPositionManualList</property> <property name="can_focus">True</property>
<child> <property name="invisible_char">&#x25CF;</property>
<object class="GtkCellRendererText" id="SupportGridManualSelectorBase"/> <property name="adjustment">SupportGridHeight</property>
<attributes> <property name="digits">2</property>
<attribute name="text">0</attribute>
</attributes>
</child>
<child>
<object class="GtkCellRendererText" id="SupportGridManualSelectorChange"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -454,255 +123,32 @@ ...@@ -454,255 +123,32 @@
</packing> </packing>
</child> </child>
</object> </object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox28">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkHBox" id="SupportGridPositionManualShiftBox">
<property name="visible">True</property>
<child>
<object class="GtkHScale" id="SupportGridPositionManualShiftControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">SupportGridPositionManualAdjustment</property>
<property name="digits">2</property>
<property name="draw_value">False</property>
<property name="value_pos">right</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="SupportGridPositionManualShiftControl2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridPositionManualAdjustment</property>
<property name="digits">1</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox25">
<property name="visible">True</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkButton" id="SupportGridPositionManualResetAll">
<property name="label" translatable="yes">Reset all items</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="SupportGridPositionManualResetOne">
<property name="label" translatable="yes">Reset this item</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child> </child>
</object> </object>
</child> </child>
<child type="label"> <child type="label">
<object class="GtkLabel" id="GridManualShiftExpanderLabel"> <object class="GtkLabel" id="GridProfileExpanderLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">Manual position adjustment</property> <property name="label" translatable="yes">Profile</property>
</object> </object>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="position">3</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkExpander" id="GridAverageDistanceExpander"> <object class="GtkVBox" id="SupportAddOnContainer">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="orientation">vertical</property>
<property name="spacing">5</property>
<child> <child>
<object class="GtkTable" id="table12"> <placeholder/>
<property name="visible">True</property>
<property name="n_rows">3</property>
<property name="n_columns">3</property>
<property name="column_spacing">3</property>
<property name="row_spacing">2</property>
<child>
<object class="GtkSpinButton" id="GridMinBridgesPerPolygon">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridMinBridgesPerPolygon</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</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="GtkLabel" id="GridMinBridgesPerPolygonLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Minimum bridges per polygon:</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="GridAverageDistance">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridAverageDistance</property>
<property name="digits">2</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="GridAverageDistanceLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Average distance between bridges:</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="GtkAlignment" id="alignment39">
<property name="width_request">40</property>
<property name="visible">True</property>
<child>
<placeholder/>
</child>
</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="GtkAlignment" id="alignment40">
<property name="width_request">40</property>
<property name="visible">True</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment41">
<property name="width_request">40</property>
<property name="visible">True</property>
<child>
<placeholder/>
</child>
</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="GridLengthLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Length of each bridge:</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>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="GridLengthControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridLength</property>
<property name="digits">2</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="GridAverageDistanceExpanderLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Distribution</property>
</object>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="position">1</property>
<property name="position">4</property>
</packing> </packing>
</child> </child>
</object> </object>
...@@ -724,38 +170,6 @@ ...@@ -724,38 +170,6 @@
</object> </object>
</child> </child>
</object> </object>
<object class="GtkAdjustment" id="SupportGridLength">
<property name="lower">-100</property>
<property name="upper">100</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="SupportGridMinBridgesPerPolygon">
<property name="lower">1</property>
<property name="upper">20</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="SupportGridAverageDistance">
<property name="lower">0.01</property>
<property name="upper">500</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="SupportGridPositionManualAdjustment">
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="SupportGridOffsetY">
<property name="lower">-1000</property>
<property name="upper">1000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="SupportGridOffsetX">
<property name="lower">-1000</property>
<property name="upper">1000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="SupportGridDistanceY">
<property name="upper">1000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="SupportGridHeight"> <object class="GtkAdjustment" id="SupportGridHeight">
<property name="lower">0.01</property> <property name="lower">0.01</property>
<property name="upper">100</property> <property name="upper">100</property>
...@@ -766,42 +180,12 @@ ...@@ -766,42 +180,12 @@
<property name="upper">100</property> <property name="upper">100</property>
<property name="step_increment">0.10000000000000001</property> <property name="step_increment">0.10000000000000001</property>
</object> </object>
<object class="GtkAdjustment" id="SupportGridDistanceX">
<property name="upper">1000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkListStore" id="SupportGridTypesList"> <object class="GtkListStore" id="SupportGridTypesList">
<columns> <columns>
<!-- column-name name --> <!-- column-name name -->
<column type="gchararray"/> <column type="gchararray"/>
</columns> <!-- column-name label -->
<data>
<row>
<col id="0" translatable="yes">none</col>
</row>
<row>
<col id="0" translatable="yes">grid pattern</col>
</row>
<row>
<col id="0" translatable="yes">automatic distribution (edges)</col>
</row>
<row>
<col id="0" translatable="yes">automatic distribution (corners)</col>
</row>
</data>
</object>
<object class="GtkListStore" id="SupportGridPositionManualList">
<columns>
<!-- column-name base -->
<column type="gchararray"/>
<!-- column-name change -->
<column type="gchararray"/> <column type="gchararray"/>
</columns> </columns>
<data>
<row>
<col id="0" translatable="yes">17.3mm (-2.0)</col>
<col id="1" translatable="yes">-2.0</col>
</row>
</data>
</object> </object>
</interface> </interface>
<?xml version="1.0"?>
<interface>
<!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy project-wide -->
<object class="GtkWindow" id="window1">
<child>
<object class="GtkExpander" id="DistributedSupportExpander">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="left_padding">30</property>
<child>
<object class="GtkTable" id="table12">
<property name="visible">True</property>
<property name="n_rows">3</property>
<property name="n_columns">2</property>
<property name="column_spacing">3</property>
<property name="row_spacing">2</property>
<child>
<object class="GtkSpinButton" id="GridMinBridgesPerPolygon">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridMinBridgesPerPolygon</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="GtkLabel" id="GridMinBridgesPerPolygonLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Minimum bridges per polygon:</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="GridAverageDistance">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridAverageDistance</property>
<property name="digits">2</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="GridAverageDistanceLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Average distance between bridges:</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="GridLengthLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Length of each bridge:</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="GtkSpinButton" id="GridLengthControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridLength</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>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="GridAverageDistanceExpanderLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Distribution</property>
</object>
</child>
</object>
</child>
</object>
<object class="GtkAdjustment" id="SupportGridAverageDistance">
<property name="lower">0.01</property>
<property name="upper">500</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="SupportGridMinBridgesPerPolygon">
<property name="lower">1</property>
<property name="upper">20</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="SupportGridLength">
<property name="lower">-100</property>
<property name="upper">100</property>
<property name="step_increment">1</property>
</object>
</interface>
<?xml version="1.0"?>
<interface>
<!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy project-wide -->
<object class="GtkWindow" id="window1">
<child>
<object class="GtkVBox" id="SupportModelGridBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkExpander" id="GridPatternExpander">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="expanded">True</property>
<child>
<object class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="left_padding">30</property>
<child>
<object class="GtkTable" id="table10">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">3</property>
<property name="column_spacing">4</property>
<property name="row_spacing">1</property>
<child>
<object class="GtkLabel" id="SupportGridDistanceXLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">distance x:</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="SupportGridDistanceYLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">distance y:</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="SupportGridDistanceXControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridDistanceX</property>
<property name="digits">2</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="GtkSpinButton" id="SupportGridDistanceYControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridDistanceY</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="GtkCheckButton" id="SupportGridDistanceSquare">
<property name="label" translatable="yes">square grid</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="GridPatternExpanderLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Pattern</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkExpander" id="GridPositionExpander">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="left_padding">30</property>
<child>
<object class="GtkHBox" id="hbox17">
<property name="visible">True</property>
<property name="spacing">4</property>
<child>
<object class="GtkLabel" id="GridOffsetXLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">offset x:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="SupportGridOffsetXControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridOffsetX</property>
<property name="digits">2</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkVSeparator" id="vseparator2">
<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="GridOffsetYLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">offset y:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="SupportGridOffsetYControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridOffsetY</property>
<property name="digits">2</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="GridPositionExpanderLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Position offset</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkExpander" id="GridManualShiftExpander">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="left_padding">30</property>
<child>
<object class="GtkVBox" id="vbox12">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkHBox" id="hbox24">
<property name="visible">True</property>
<property name="spacing">3</property>
<child>
<object class="GtkRadioButton" id="SupportGridPositionManualAxisX">
<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="padding">10</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="SupportGridPositionManualAxisY">
<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">SupportGridPositionManualAxisX</property>
</object>
<packing>
<property name="expand">False</property>
<property name="padding">10</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkVSeparator" id="vseparator7">
<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="GridPositionManualSelectionLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Grid item:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="SupportGridPositionManualSelector">
<property name="visible">True</property>
<property name="model">SupportGridPositionManualList</property>
<child>
<object class="GtkCellRendererText" id="SupportGridManualSelectorBase"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
<child>
<object class="GtkCellRendererText" id="SupportGridManualSelectorChange"/>
<attributes>
<attribute name="text">1</attribute>
</attributes>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">4</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox28">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkHBox" id="SupportGridPositionManualShiftBox">
<property name="visible">True</property>
<child>
<object class="GtkHScale" id="SupportGridPositionManualShiftControl">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">SupportGridPositionManualAdjustment</property>
<property name="digits">2</property>
<property name="draw_value">False</property>
<property name="value_pos">right</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="SupportGridPositionManualShiftControl2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">SupportGridPositionManualAdjustment</property>
<property name="digits">1</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkHButtonBox" id="hbuttonbox1">
<property name="visible">True</property>
<property name="layout_style">spread</property>
<child>
<object class="GtkButton" id="SupportGridPositionManualResetAll">
<property name="label" translatable="yes">Reset all items</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="SupportGridPositionManualResetOne">
<property name="label" translatable="yes">Reset this item</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="GridManualShiftExpanderLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">Manual position adjustment</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkListStore" id="SupportGridPositionManualList">
<columns>
<!-- column-name base -->
<column type="gchararray"/>
<!-- column-name change -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">17.3mm (-2.0)</col>
<col id="1" translatable="yes">-2.0</col>
</row>
</data>
</object>
<object class="GtkAdjustment" id="SupportGridDistanceX">
<property name="upper">1000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="SupportGridDistanceY">
<property name="upper">1000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="SupportGridOffsetX">
<property name="lower">-1000</property>
<property name="upper">1000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="SupportGridOffsetY">
<property name="lower">-1000</property>
<property name="upper">1000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="SupportGridPositionManualAdjustment">
<property name="step_increment">1</property>
</object>
</interface>
...@@ -926,9 +926,9 @@ def draw_complete_model_view(settings): ...@@ -926,9 +926,9 @@ def draw_complete_model_view(settings):
""" """
model.to_OpenGL(show_directions=settings.get("show_directions")) model.to_OpenGL(show_directions=settings.get("show_directions"))
# draw the support grid # draw the support grid
if settings.get("show_support_grid") and settings.get("support_grid"): if settings.get("show_support_grid") and settings.get("current_support_model"):
GL.glColor4f(*settings.get("color_support_grid")) GL.glColor4f(*settings.get("color_support_grid"))
settings.get("support_grid").to_OpenGL() settings.get("current_support_model").to_OpenGL()
# draw the toolpath simulation # draw the toolpath simulation
if settings.get("show_simulation"): if settings.get("show_simulation"):
moves = settings.get("simulation_toolpath_moves") moves = settings.get("simulation_toolpath_moves")
......
...@@ -232,6 +232,7 @@ class EventCore(pycam.Gui.Settings.Settings): ...@@ -232,6 +232,7 @@ class EventCore(pycam.Gui.Settings.Settings):
log.debug("Trying to unregister an unknown event: %s" % event) log.debug("Trying to unregister an unknown event: %s" % event)
def emit_event(self, event): def emit_event(self, event):
log.debug("Event emitted: %s" % str(event))
if event in self.event_handlers: if event in self.event_handlers:
if self.event_handlers[event][EVENT_BLOCKER_INDEX] != 0: if self.event_handlers[event][EVENT_BLOCKER_INDEX] != 0:
return return
...@@ -256,13 +257,14 @@ class EventCore(pycam.Gui.Settings.Settings): ...@@ -256,13 +257,14 @@ class EventCore(pycam.Gui.Settings.Settings):
if self.event_handlers[event][EVENT_BLOCKER_INDEX] > 0: if self.event_handlers[event][EVENT_BLOCKER_INDEX] > 0:
self.event_handlers[event][EVENT_BLOCKER_INDEX] -= 1 self.event_handlers[event][EVENT_BLOCKER_INDEX] -= 1
else: else:
log.debug("Trying to unblock non-blocked event '%s'" % str(event)) log.debug("Trying to unblock non-blocked event '%s'" % \
str(event))
else: else:
log.debug("Trying to unblock an unknown event: %s" % str(event)) log.debug("Trying to unblock an unknown event: %s" % str(event))
def register_ui_section(self, section, add_action, clear_action): def register_ui_section(self, section, add_action, clear_action):
if not section in self.ui_sections: if not section in self.ui_sections:
self.ui_sections[section] = [None, None, None] self.ui_sections[section] = [None, None]
self.ui_sections[section][UI_WIDGET_INDEX] = [] self.ui_sections[section][UI_WIDGET_INDEX] = []
self.ui_sections[section][UI_FUNC_INDEX] = (add_action, clear_action) self.ui_sections[section][UI_FUNC_INDEX] = (add_action, clear_action)
self._rebuild_ui_section(section) self._rebuild_ui_section(section)
...@@ -272,7 +274,8 @@ class EventCore(pycam.Gui.Settings.Settings): ...@@ -272,7 +274,8 @@ class EventCore(pycam.Gui.Settings.Settings):
ui_section = self.ui_sections[section] ui_section = self.ui_sections[section]
if ui_section[UI_FUNC_INDEX]: if ui_section[UI_FUNC_INDEX]:
add_func, clear_func = ui_section[UI_FUNC_INDEX] add_func, clear_func = ui_section[UI_FUNC_INDEX]
ui_section[UI_WIDGET_INDEX].sort(key=lambda x: x[WIDGET_WEIGHT_INDEX]) ui_section[UI_WIDGET_INDEX].sort(
key=lambda x: x[WIDGET_WEIGHT_INDEX])
clear_func() clear_func()
for item in ui_section[UI_WIDGET_INDEX]: for item in ui_section[UI_WIDGET_INDEX]:
add_func(item[WIDGET_OBJ_INDEX], item[WIDGET_NAME_INDEX]) add_func(item[WIDGET_OBJ_INDEX], item[WIDGET_NAME_INDEX])
...@@ -281,12 +284,14 @@ class EventCore(pycam.Gui.Settings.Settings): ...@@ -281,12 +284,14 @@ class EventCore(pycam.Gui.Settings.Settings):
def register_ui(self, section, name, widget, weight=0): def register_ui(self, section, name, widget, weight=0):
if not section in self.ui_sections: if not section in self.ui_sections:
self.ui_sections[section] = [None, []] self.ui_sections[section] = [None, None]
ui_section = self.ui_sections[section] self.ui_sections[section][UI_WIDGET_INDEX] = []
assert WIDGET_NAME_INDEX == 0 assert WIDGET_NAME_INDEX == 0
assert WIDGET_OBJ_INDEX == 1 assert WIDGET_OBJ_INDEX == 1
assert WIDGET_WEIGHT_INDEX == 2 assert WIDGET_WEIGHT_INDEX == 2
ui_section[UI_WIDGET_INDEX].append((name, widget, weight)) self.ui_sections[section][UI_WIDGET_INDEX].append((name, widget,
weight))
self._rebuild_ui_section(section)
def unregister_ui(self, section, widget): def unregister_ui(self, section, widget):
if (section in self.ui_sections) or (None in self.ui_sections): if (section in self.ui_sections) or (None in self.ui_sections):
...@@ -301,7 +306,8 @@ class EventCore(pycam.Gui.Settings.Settings): ...@@ -301,7 +306,8 @@ class EventCore(pycam.Gui.Settings.Settings):
for index in removal_list: for index in removal_list:
ui_section[UI_WIDGET_INDEX].pop(index) ui_section[UI_WIDGET_INDEX].pop(index)
else: else:
log.debug("Trying to unregister unknown ui section: %s" % str(section)) log.debug("Trying to unregister unknown ui section: %s" % \
str(section))
class ProjectGui(object): class ProjectGui(object):
...@@ -425,6 +431,7 @@ class ProjectGui(object): ...@@ -425,6 +431,7 @@ class ProjectGui(object):
self.settings.register_event("model-change-after", self.update_save_actions) self.settings.register_event("model-change-after", self.update_save_actions)
self.settings.register_event("model-change-after", self.update_model_type_related_controls) self.settings.register_event("model-change-after", self.update_model_type_related_controls)
self.settings.register_event("model-change-after", self.update_view) self.settings.register_event("model-change-after", self.update_view)
self.settings.register_event("visual-item-updated", self.update_view)
self.settings.set("update_progress", self.update_progress_bar) self.settings.set("update_progress", self.update_progress_bar)
self.settings.set("disable_progress_cancel_button", self.disable_progress_cancel_button) self.settings.set("disable_progress_cancel_button", self.disable_progress_cancel_button)
self.settings.set("load_model", self.load_model) self.settings.set("load_model", self.load_model)
...@@ -2717,7 +2724,7 @@ class ProjectGui(object): ...@@ -2717,7 +2724,7 @@ class ProjectGui(object):
def load_model(self, model): def load_model(self, model):
# load the new model only if the import worked # load the new model only if the import worked
if not model is None: if model:
self.settings.emit_event("model-change-before") self.settings.emit_event("model-change-before")
self.model = model self.model = model
self.last_model_uri = None self.last_model_uri = None
...@@ -3131,6 +3138,15 @@ class ProjectGui(object): ...@@ -3131,6 +3138,15 @@ class ProjectGui(object):
self.update_toolpath_table() self.update_toolpath_table()
dialog.hide() dialog.hide()
def _get_projection_plane(self):
# determine projection plane
if (self.model.maxz < 0) or (self.model.minz > 0):
# completely above or below zero
plane_z = self.model.minz
else:
plane_z = 0
return Plane(Point(0, 0, plane_z), Vector(0, 0, 1))
@progress_activity_guard @progress_activity_guard
def crop_toolpath(self, toolpath): def crop_toolpath(self, toolpath):
if hasattr(self.model, "get_polygons"): if hasattr(self.model, "get_polygons"):
...@@ -3571,10 +3587,9 @@ class ProjectGui(object): ...@@ -3571,10 +3587,9 @@ class ProjectGui(object):
tool_settings["tool_radius"], tool_settings["torus_radius"], tool_settings["tool_radius"], tool_settings["torus_radius"],
tool_settings["speed"], tool_settings["feedrate"]) tool_settings["speed"], tool_settings["feedrate"])
support_factory = self.settings.get("get_support_model") support_model = self.settings.get("current_support_model")
if support_factory: if support_model:
# TODO: this is not a good approach - "toolpath_settings" should just have a "set_support" method toolpath_settings.set_support_model(support_model)
support_factory(toolpath_settings)
# calculation backend: ODE / None # calculation backend: ODE / None
if self.settings.get("enable_ode"): if self.settings.get("enable_ode"):
......
...@@ -574,20 +574,6 @@ class ToolpathSettings(object): ...@@ -574,20 +574,6 @@ class ToolpathSettings(object):
"speed": float, "speed": float,
"feedrate": float, "feedrate": float,
}, },
"SupportGrid": {
"type": str,
"distance_x": float,
"distance_y": float,
"thickness": float,
"height": float,
"offset_x": float,
"offset_y": float,
"adjustments_x": "list_of_float",
"adjustments_y": "list_of_float",
"average_distance": float,
"minimum_bridges": int,
"length": float,
},
"Program": { "Program": {
"unit": str, "unit": str,
"enable_ode": bool, "enable_ode": bool,
...@@ -612,7 +598,6 @@ class ToolpathSettings(object): ...@@ -612,7 +598,6 @@ class ToolpathSettings(object):
self.program = {} self.program = {}
self.bounds = {} self.bounds = {}
self.tool_settings = {} self.tool_settings = {}
self.support_grid = {}
self.process_settings = {} self.process_settings = {}
def set_bounds(self, bounds): def set_bounds(self, bounds):
...@@ -647,48 +632,11 @@ class ToolpathSettings(object): ...@@ -647,48 +632,11 @@ class ToolpathSettings(object):
def get_tool_settings(self): def get_tool_settings(self):
return self.tool_settings return self.tool_settings
def set_support_grid(self, distance_x, distance_y, thickness, height, def set_support_model(self, model):
offset_x=0.0, offset_y=0.0, adjustments_x=None, self.support_model = model
adjustments_y=None):
if adjustments_x is None: def get_support_model(self):
adjustments_x = [] return self.support_model
if adjustments_y is None:
adjustments_y = []
self.support_grid["type"] = "grid"
self.support_grid["distance_x"] = distance_x
self.support_grid["distance_y"] = distance_y
self.support_grid["offset_x"] = offset_x
self.support_grid["offset_y"] = offset_y
self.support_grid["thickness"] = thickness
self.support_grid["height"] = height
self.support_grid["adjustments_x"] = adjustments_x
self.support_grid["adjustments_y"] = adjustments_y
def set_support_distributed(self, average_distance, minimum_bridges,
thickness, height, length, start_at_corners=False):
if start_at_corners:
self.support_grid["type"] = "distributed_corners"
else:
self.support_grid["type"] = "distributed_edges"
self.support_grid["average_distance"] = average_distance
self.support_grid["minimum_bridges"] = minimum_bridges
self.support_grid["thickness"] = thickness
self.support_grid["height"] = height
self.support_grid["length"] = length
def get_support_grid(self):
result = {}
if self.support_grid:
options = self.support_grid
else:
options = {}
# add all keys from the default list
for key in self.SECTIONS["SupportGrid"].keys():
if options.has_key(key):
result[key] = options[key]
else:
result[key] = None
return result
def set_calculation_backend(self, backend=None): def set_calculation_backend(self, backend=None):
self.program["enable_ode"] = (backend.upper() == "ODE") self.program["enable_ode"] = (backend.upper() == "ODE")
...@@ -738,7 +686,6 @@ class ToolpathSettings(object): ...@@ -738,7 +686,6 @@ class ToolpathSettings(object):
config.readfp(text_stream) config.readfp(text_stream)
for config_dict, section in ((self.bounds, "Bounds"), for config_dict, section in ((self.bounds, "Bounds"),
(self.tool_settings, "Tool"), (self.tool_settings, "Tool"),
(self.support_grid, "SupportGrid"),
(self.process_settings, "Process")): (self.process_settings, "Process")):
for key, value_type in self.SECTIONS[section].items(): for key, value_type in self.SECTIONS[section].items():
value_raw = config.get(section, key, None) value_raw = config.get(section, key, None)
...@@ -775,7 +722,6 @@ class ToolpathSettings(object): ...@@ -775,7 +722,6 @@ class ToolpathSettings(object):
result = [] result = []
for config_dict, section in ((self.bounds, "Bounds"), for config_dict, section in ((self.bounds, "Bounds"),
(self.tool_settings, "Tool"), (self.tool_settings, "Tool"),
(self.support_grid, "SupportGrid"),
(self.process_settings, "Process")): (self.process_settings, "Process")):
# skip empty sections # skip empty sections
if not config_dict: if not config_dict:
......
...@@ -24,10 +24,6 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>. ...@@ -24,10 +24,6 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
import pycam.Plugins import pycam.Plugins
GRID_TYPES = {"none": 0, "grid": 1, "automatic_edge": 2, "automatic_corner": 3}
# TODO: manual_adjust_slider is stuck; automatic distribution does now show up
class ModelSupport(pycam.Plugins.PluginBase): class ModelSupport(pycam.Plugins.PluginBase):
UI_FILE = "model_support.ui" UI_FILE = "model_support.ui"
...@@ -37,326 +33,79 @@ class ModelSupport(pycam.Plugins.PluginBase): ...@@ -37,326 +33,79 @@ class ModelSupport(pycam.Plugins.PluginBase):
support_frame = self.gui.get_object("ModelExtensionsFrame") support_frame = self.gui.get_object("ModelExtensionsFrame")
support_frame.unparent() support_frame.unparent()
self.core.register_ui("model_handling", "Support", support_frame, 0) self.core.register_ui("model_handling", "Support", support_frame, 0)
self.core.set("get_support_model", self.support_model_factory) support_model_changed = lambda widget=None: self.core.emit_event(
self.core.register_event("model-change-after", self.update_support_model) "support-model-changed")
self.core.register_event("model-change-after", self.update_support_controls) self.core.register_event("model-change-after",
support_model_changed)
self.core.register_event("boundary-updated", self.core.register_event("boundary-updated",
self.update_support_grid_manual_adjust) support_model_changed)
# support grid self.core.register_event("support-model-changed",
self.grid_adjustments_x = [] self.update_support_model)
self.grid_adjustments_y = [] support_model_type_selector = self.gui.get_object(
support_grid_type_control = self.gui.get_object(
"SupportGridTypesControl") "SupportGridTypesControl")
support_grid_type_control.connect("changed", support_model_type_selector.connect("changed",
self.update_support_controls) support_model_changed)
self.core.add_item("support_grid_type", def add_support_type(obj, name):
support_grid_type_control.get_active, types_model = support_model_type_selector.get_model()
support_grid_type_control.set_active) types_model.append((obj, name))
self.core.set("support_grid_type", GRID_TYPES["none"]) # enable the first item by default
grid_distance_x = self.gui.get_object("SupportGridDistanceX") if len(types_model) == 1:
grid_distance_x.connect("value-changed", self.update_support_controls) support_model_type_selector.set_active(0)
self.core.add_item("support_grid_distance_x", self.core.register_ui_section("support_model_type_selector",
grid_distance_x.get_value, grid_distance_x.set_value) add_support_type,
grid_distance_square = self.gui.get_object("SupportGridDistanceSquare") lambda: support_model_type_selector.get_model().clear())
grid_distance_square.connect("clicked", self.update_support_controls) self.core.register_ui("support_model_type_selector", "none",
grid_distance_y = self.gui.get_object("SupportGridDistanceY") "none", weight=-100)
grid_distance_y.connect("value-changed", self.update_support_controls) container = self.gui.get_object("SupportAddOnContainer")
def get_support_grid_distance_y(): def clear_support_model_settings():
if grid_distance_square.get_active(): children = container.get_children()
return self.core.get("support_grid_distance_x") for child in children:
container.remove(child)
self.core.register_ui_section("support_model_settings",
lambda obj, name: container.pack_start(obj, expand=False),
clear_support_model_settings)
def get_support_model_type():
index = support_model_type_selector.get_active()
if index < 0:
return None
else: else:
return grid_distance_y.get_value() selector_model = support_model_type_selector.get_model()
self.core.add_item("support_grid_distance_y", return selector_model[index][0]
get_support_grid_distance_y, grid_distance_y.set_value) def set_support_model_type(model_type):
selector_model = support_model_type_selector.get_model()
for index, row in enumerate(selector_model):
if row[0] == model_type:
support_model_type_selector.set_active(index)
break
else:
support_model_type_selector.set_active(-1)
self.core.add_item("support_model_type",
get_support_model_type,
set_support_model_type)
grid_thickness = self.gui.get_object("SupportGridThickness") grid_thickness = self.gui.get_object("SupportGridThickness")
grid_thickness.connect("value-changed", self.update_support_model) grid_thickness.connect("value-changed", support_model_changed)
self.core.add_item("support_grid_thickness", self.core.add_item("support_grid_thickness",
grid_thickness.get_value, grid_thickness.set_value) grid_thickness.get_value, grid_thickness.set_value)
grid_height = self.gui.get_object("SupportGridHeight") grid_height = self.gui.get_object("SupportGridHeight")
grid_height.connect("value-changed", self.update_support_model) grid_height.connect("value-changed", support_model_changed)
self.core.add_item("support_grid_height", self.core.add_item("support_grid_height",
grid_height.get_value, grid_height.set_value) grid_height.get_value, grid_height.set_value)
grid_length = self.gui.get_object("SupportGridLength")
grid_length.connect("value-changed", self.update_support_model)
self.core.add_item("support_grid_length",
grid_length.get_value, grid_length.set_value)
grid_offset_x = self.gui.get_object("SupportGridOffsetX")
grid_offset_x.connect("value-changed", self.update_support_model)
self.core.add_item("support_grid_offset_x",
grid_offset_x.get_value, grid_offset_x.set_value)
grid_offset_y = self.gui.get_object("SupportGridOffsetY")
grid_offset_y.connect("value-changed", self.update_support_model)
self.core.add_item("support_grid_offset_y",
grid_offset_y.get_value, grid_offset_y.set_value)
grid_average_distance = self.gui.get_object("GridAverageDistance")
grid_average_distance.connect("value-changed",
self.update_support_model)
self.core.add_item("support_grid_average_distance",
grid_average_distance.get_value,
grid_average_distance.set_value)
grid_minimum_bridges = self.gui.get_object("GridMinBridgesPerPolygon")
grid_minimum_bridges.connect("value-changed", self.update_support_model)
self.core.add_item("support_grid_minimum_bridges",
grid_minimum_bridges.get_value, grid_minimum_bridges.set_value)
# manual grid adjustments
self.grid_adjustment_axis_x = self.gui.get_object("SupportGridPositionManualAxisX")
self.grid_adjustment_axis_x.connect("toggled",
self.switch_support_grid_manual_selector)
self.gui.get_object("SupportGridPositionManualResetOne").connect(
"clicked", self.reset_support_grid_manual, False)
self.gui.get_object("SupportGridPositionManualResetAll").connect(
"clicked", self.reset_support_grid_manual, True)
self.grid_adjustment_model = self.gui.get_object(
"SupportGridPositionManualList")
self.grid_adjustment_selector = self.gui.get_object(
"SupportGridPositionManualSelector")
self.grid_adjustment_selector.connect("changed",
self.switch_support_grid_manual_selector)
self.grid_adjustment_value = self.gui.get_object(
"SupportGridPositionManualAdjustment")
self.grid_adjustment_value_control = self.gui.get_object(
"SupportGridPositionManualShiftControl")
self.grid_adjustment_value_control.connect("move-slider",
self.update_support_grid_manual_adjust)
self.grid_adjustment_value_control.connect("value-changed",
self.update_support_grid_manual_adjust)
self.gui.get_object("SupportGridPositionManualShiftControl2").connect(
"value-changed", self.update_support_grid_manual_adjust)
def get_set_grid_adjustment_value(value=None):
if self.grid_adjustment_axis_x.get_active():
adjustments = self.grid_adjustments_x
else:
adjustments = self.grid_adjustments_y
index = self.grid_adjustment_selector.get_active()
if value is None:
if 0 <= index < len(adjustments):
return adjustments[index]
else:
return 0
else:
while len(adjustments) <= index:
adjustments.append(0)
adjustments[index] = value
self.core.add_item("support_grid_adjustment_value",
get_set_grid_adjustment_value, get_set_grid_adjustment_value)
# support grid defaults # support grid defaults
grid_distance_square.set_active(True)
self.core.set("support_grid_distance_x", 10.0)
self.core.set("support_grid_thickness", 0.5) self.core.set("support_grid_thickness", 0.5)
self.core.set("support_grid_height", 0.5) self.core.set("support_grid_height", 0.5)
self.core.set("support_grid_average_distance", 30) self.core.set("support_grid_type", "none")
self.core.set("support_grid_minimum_bridges", 2)
self.core.set("support_grid_length", 5)
self.grid_adjustment_axis_x_last = True
# refresh everything
self.update_support_controls()
return True return True
def teardown(self): def teardown(self):
if self.gui: if self.gui:
self.core.unregister_ui("model_handling", self.core.unregister_ui("model_handling",
self.gui.get_object("ModelExtensionsFrame")) self.gui.get_object("ModelExtensionsFrame"))
self.core.unregister_event("support-model-changed",
def update_support_controls(self, widget=None): self.update_support_model)
controls = {"GridProfileExpander": ("grid", "automatic_edge",
"automatic_corner"),
"GridPatternExpander": ("grid", ),
"GridPositionExpander": ("grid", ),
"GridManualShiftExpander": ("grid", ),
"GridAverageDistanceExpander": ("automatic_edge",
"automatic_corner"),
}
grid_type = self.core.get("support_grid_type")
if grid_type == GRID_TYPES["grid"]:
grid_square = self.gui.get_object("SupportGridDistanceSquare")
distance_y = self.gui.get_object("SupportGridDistanceYControl")
distance_y.set_sensitive(not grid_square.get_active())
if grid_square.get_active():
# We let "distance_y" track the value of "distance_x".
self.core.set("support_grid_distance_y",
self.core.get("support_grid_distance_x"))
self.update_support_grid_manual_model()
self.switch_support_grid_manual_selector()
elif grid_type in (GRID_TYPES["automatic_edge"],
GRID_TYPES["automatic_corner"], GRID_TYPES["none"]):
pass
elif grid_type < 0:
# not initialized
pass
else:
log.error("Invalid grid type: %d" % grid_type)
# show and hide all controls according to the current type
for key, grid_types in controls.iteritems():
obj = self.gui.get_object(key)
if grid_type in [GRID_TYPES[allowed] for allowed in grid_types]:
obj.show()
else:
obj.hide()
self.core.emit_event("model-change-after")
def update_support_model(self, widget=None): def update_support_model(self, widget=None):
model = self.core.get("model") grid_type = self.core.get("support_model_type")
if not model: if grid_type == "none":
return self.core.set("current_support_model", None)
grid_type = self.core.get("support_grid_type") self.core.emit_event("visual-item-updated")
s = self.core
support_grid = None
if grid_type == GRID_TYPES["grid"]:
if (s.get("support_grid_thickness") > 0) \
and ((s.get("support_grid_distance_x") > 0) \
or (s.get("support_grid_distance_y") > 0)) \
and ((s.get("support_grid_distance_x") == 0) \
or (s.get("support_grid_distance_x") \
> s.get("support_grid_thickness"))) \
and ((s.get("support_grid_distance_y") == 0) \
or (s.get("support_grid_distance_y") \
> s.get("support_grid_thickness"))) \
and (s.get("support_grid_height") > 0):
support_grid = pycam.Toolpath.SupportGrid.get_support_grid(
s.get("minx"), s.get("maxx"), s.get("miny"), s.get("maxy"),
s.get("minz"), s.get("support_grid_distance_x"),
s.get("support_grid_distance_y"),
s.get("support_grid_thickness"),
s.get("support_grid_height"),
offset_x=s.get("support_grid_offset_x"),
offset_y=s.get("support_grid_offset_y"),
adjustments_x=self.grid_adjustments_x,
adjustments_y=self.grid_adjustments_y)
elif grid_type in (GRID_TYPES["automatic_edge"],
GRID_TYPES["automatic_corner"]):
if (s.get("support_grid_thickness") > 0) \
and (s.get("support_grid_height") > 0) \
and (s.get("support_grid_average_distance") > 0) \
and (s.get("support_grid_minimum_bridges") > 0):
# get the minimum z value of the bounding box
bounds = self.core.get("current_bounds")
if not bounds is None:
minz = bounds.get_absolute_limits(
reference=model.get_bounds())[0][2]
corner_start = (grid_type == GRID_TYPES["automatic_corner"])
support_grid = pycam.Toolpath.SupportGrid.get_support_distributed(
s.get("model"), minz,
s.get("support_grid_average_distance"),
s.get("support_grid_minimum_bridges"),
s.get("support_grid_thickness"),
s.get("support_grid_height"),
s.get("support_grid_length"),
bounds.get_referenced_bounds(s.get("model").get_bounds()),
start_at_corners=corner_start)
elif grid_type == GRID_TYPES["none"]:
pass
s.set("support_grid", support_grid)
self.core.emit_event("model-change-after")
def switch_support_grid_manual_selector(self, widget=None):
old_axis_was_x = self.grid_adjustment_axis_x_last
self.grid_adjustment_axis_x_last = \
self.grid_adjustment_axis_x.get_active()
if self.grid_adjustment_axis_x.get_active():
# x axis is selected
if not old_axis_was_x:
self.update_support_grid_manual_model()
max_distance = self.core.get("support_grid_distance_x")
else:
# y axis
if old_axis_was_x:
self.update_support_grid_manual_model()
max_distance = self.core.get("support_grid_distance_y")
# we allow an individual adjustment of 66% of the distance
max_distance /= 1.5
if hasattr(self.grid_adjustment_value, "set_lower"):
# gtk 2.14 is required for "set_lower" and "set_upper"
self.grid_adjustment_value.set_lower(-max_distance)
self.grid_adjustment_value.set_upper(max_distance)
if self.grid_adjustment_value.get_value() \
!= self.core.get("support_grid_adjustment_value"):
self.grid_adjustment_value.set_value(self.core.get(
"support_grid_adjustment_value"))
self.gui.get_object("SupportGridPositionManualShiftBox").set_sensitive(
self.grid_adjustment_selector.get_active() >= 0)
def update_support_grid_manual_adjust(self, widget=None, data1=None,
data2=None):
new_value = self.grid_adjustment_value.get_value()
self.core.set("support_grid_adjustment_value", new_value)
tree_iter = self.grid_adjustment_selector.get_active_iter()
if not tree_iter is None:
value_string = "(%+.1f)" % new_value
self.grid_adjustment_model.set(tree_iter, 1, value_string)
self.core.emit_event("model-change-after")
def reset_support_grid_manual(self, widget=None, reset_all=False):
if reset_all:
self.grid_adjustments_x = []
self.grid_adjustments_y = []
else:
self.core.set("support_grid_adjustment_value", 0)
self.update_support_grid_manual_model()
self.switch_support_grid_manual_selector()
self.core.emit_event("model-change-after")
def update_support_grid_manual_model(self):
old_index = self.grid_adjustment_selector.get_active()
model = self.grid_adjustment_model
model.clear()
s = self.core
# get the toolpath without adjustments
base_x, base_y = pycam.Toolpath.SupportGrid.get_support_grid_locations(
s.get("minx"), s.get("maxx"), s.get("miny"), s.get("maxy"),
s.get("support_grid_distance_x"),
s.get("support_grid_distance_y"),
offset_x=s.get("support_grid_offset_x"),
offset_y=s.get("support_grid_offset_y"))
# fill the adjustment lists
while len(self.grid_adjustments_x) < len(base_x):
self.grid_adjustments_x.append(0)
while len(self.grid_adjustments_y) < len(base_y):
self.grid_adjustments_y.append(0)
# select the currently active list
if self.grid_adjustment_axis_x.get_active():
base = base_x
adjustments = self.grid_adjustments_x
else:
base = base_y
adjustments = self.grid_adjustments_y
# generate the model content
for index, base_value in enumerate(base):
position = "%.2f%s" % (base_value, s.get("unit"))
if (0 <= index < len(adjustments)) and (adjustments[index] != 0):
diff = "(%+.1f)" % adjustments[index]
else:
diff = ""
model.append((position, diff))
if old_index < len(base):
self.grid_adjustment_selector.set_active(old_index)
else:
self.grid_adjustment_selector.set_active(-1)
def support_model_factory(self, tp_settings):
# get the support grid options
grid_type = self.core.get("support_grid_type")
if grid_type == GRID_TYPES["grid"]:
tp_settings.set_support_grid(
self.core.get("support_grid_distance_x"),
self.core.get("support_grid_distance_y"),
self.core.get("support_grid_thickness"),
self.core.get("support_grid_height"),
offset_x=self.core.get("support_grid_offset_x"),
offset_y=self.core.get("support_grid_offset_y"),
adjustments_x=self.grid_adjustments_x,
adjustments_y=self.grid_adjustments_y)
elif grid_type in (GRID_TYPES["automatic_edge"],
GRID_TYPES["automatic_corner"]):
corner_start = (grid_type == GRID_TYPES["automatic_corner"])
tp_settings.set_support_distributed(
self.core.get("support_grid_average_distance"),
self.core.get("support_grid_minimum_bridges"),
self.core.get("support_grid_thickness"),
self.core.get("support_grid_height"),
self.core.get("support_grid_length"),
start_at_corners=corner_start)
elif grid_type == GRID_TYPES["none"]:
pass
else:
log.error("Invalid support grid type: %d" % grid_type)
# -*- 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
class ModelSupportDistributed(pycam.Plugins.PluginBase):
UI_FILE = "model_support_distributed.ui"
def setup(self):
if self.gui:
support_expander = self.gui.get_object("DistributedSupportExpander")
support_expander.unparent()
self.core.register_ui("support_model_type_selector",
"Distributed (edges)", "distributed_edges", weight=0)
self.core.register_ui("support_model_type_selector",
"Distributed (corners)", "distributed_corners", weight=10)
self.core.register_ui("support_model_settings", "Grid settings",
support_expander)
self.core.register_event("support-model-changed",
self.update_support_controls)
self.core.register_event("support-model-changed",
self.update_support_model)
grid_length = self.gui.get_object("SupportGridLength")
grid_length.connect("value-changed", self.update_support_model)
self.core.add_item("support_grid_length",
grid_length.get_value, grid_length.set_value)
average_distance = self.gui.get_object("GridAverageDistance")
average_distance.connect("value-changed", self.update_support_model)
self.core.add_item("support_grid_average_distance",
average_distance.get_value, average_distance.set_value)
minimum_bridges = self.gui.get_object("GridMinBridgesPerPolygon")
minimum_bridges.connect("value-changed", self.update_support_model)
self.core.add_item("support_grid_minimum_bridges",
minimum_bridges.get_value, minimum_bridges.set_value)
self.core.set("support_grid_average_distance", 30)
self.core.set("support_grid_minimum_bridges", 2)
self.core.set("support_grid_length", 5)
return True
def update_support_controls(self):
grid_type = self.core.get("support_model_type")
if grid_type in ("distributed_edges", "distributed_corners"):
self.gui.get_object("DistributedSupportExpander").show()
else:
self.gui.get_object("DistributedSupportExpander").hide()
def update_support_model(self, widget=None):
model = self.core.get("model")
if not model:
return
grid_type = self.core.get("support_model_type")
support_model = None
if grid_type in ("distributed_edges", "distributed_corners"):
s = self.core
if (s.get("support_grid_thickness") > 0) \
and (s.get("support_grid_height") > 0) \
and (s.get("support_grid_average_distance") > 0) \
and (s.get("support_grid_minimum_bridges") > 0):
# get the minimum z value of the bounding box
bounds = s.get("current_bounds")
if bounds:
minz = bounds.get_absolute_limits(
reference=model.get_bounds())[0][2]
corner_start = (grid_type == "distributed_corners")
support_model = pycam.Toolpath.SupportGrid.get_support_distributed(
s.get("model"), minz,
s.get("support_grid_average_distance"),
s.get("support_grid_minimum_bridges"),
s.get("support_grid_thickness"),
s.get("support_grid_height"),
s.get("support_grid_length"),
bounds.get_referenced_bounds(s.get("model").get_bounds()),
start_at_corners=corner_start)
if support_model != self.core.get("current_support_model"):
self.core.set("current_support_model", support_model)
self.core.emit_event("visual-item-updated")
# -*- 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
# gtk is imported later
#import gtk
class ModelSupportGrid(pycam.Plugins.PluginBase):
UI_FILE = "model_support_grid.ui"
def setup(self):
if self.gui:
import gtk
grid_box = self.gui.get_object("SupportModelGridBox")
grid_box.unparent()
self.core.register_ui("support_model_type_selector", "Grid",
"grid", weight=-10)
self.core.register_ui("support_model_settings", "Grid settings",
grid_box)
self.core.register_event("support-model-changed",
self.update_support_model)
support_model_changed = lambda widget=None: self.core.emit_event(
"support-model-changed")
# support grid
self.grid_adjustments_x = []
self.grid_adjustments_y = []
self.grid_adjustment_axis_x_last = True
self._block_manual_adjust_update = False
grid_distance_x = self.gui.get_object("SupportGridDistanceX")
grid_distance_x.connect("value-changed", support_model_changed)
self.core.add_item("support_grid_distance_x",
grid_distance_x.get_value, grid_distance_x.set_value)
grid_distance_square = self.gui.get_object("SupportGridDistanceSquare")
grid_distance_square.connect("clicked", self.update_support_controls)
grid_distance_y = self.gui.get_object("SupportGridDistanceY")
grid_distance_y.connect("value-changed", support_model_changed)
def get_support_grid_distance_y():
if grid_distance_square.get_active():
return self.core.get("support_grid_distance_x")
else:
return grid_distance_y.get_value()
self.core.add_item("support_grid_distance_y",
get_support_grid_distance_y, grid_distance_y.set_value)
grid_offset_x = self.gui.get_object("SupportGridOffsetX")
grid_offset_x.connect("value-changed", support_model_changed)
self.core.add_item("support_grid_offset_x",
grid_offset_x.get_value, grid_offset_x.set_value)
grid_offset_y = self.gui.get_object("SupportGridOffsetY")
grid_offset_y.connect("value-changed", support_model_changed)
self.core.add_item("support_grid_offset_y",
grid_offset_y.get_value, grid_offset_y.set_value)
# manual grid adjustments
self.grid_adjustment_axis_x = self.gui.get_object("SupportGridPositionManualAxisX")
self.grid_adjustment_axis_x.connect("toggled",
self.switch_support_grid_manual_selector)
self.gui.get_object("SupportGridPositionManualResetOne").connect(
"clicked", self.reset_support_grid_manual, False)
self.gui.get_object("SupportGridPositionManualResetAll").connect(
"clicked", self.reset_support_grid_manual, True)
self.grid_adjustment_model = self.gui.get_object(
"SupportGridPositionManualList")
self.grid_adjustment_selector = self.gui.get_object(
"SupportGridPositionManualSelector")
self.grid_adjustment_selector.connect("changed",
self.switch_support_grid_manual_selector)
self.grid_adjustment_value = self.gui.get_object(
"SupportGridPositionManualAdjustment")
self.grid_adjustment_value_control = self.gui.get_object(
"SupportGridPositionManualShiftControl")
self.grid_adjustment_value_control.set_update_policy(
gtk.UPDATE_DISCONTINUOUS)
self.grid_adjustment_value_control.connect("move-slider",
self.update_support_grid_manual_adjust)
self.grid_adjustment_value_control.connect("value-changed",
self.update_support_grid_manual_adjust)
self.gui.get_object("SupportGridPositionManualShiftControl2").connect(
"value-changed", self.update_support_grid_manual_adjust)
def get_set_grid_adjustment_value(value=None):
if self.grid_adjustment_axis_x.get_active():
adjustments = self.grid_adjustments_x
else:
adjustments = self.grid_adjustments_y
index = self.grid_adjustment_selector.get_active()
if value is None:
if 0 <= index < len(adjustments):
return adjustments[index]
else:
return 0
else:
while len(adjustments) <= index:
adjustments.append(0)
adjustments[index] = value
self.core.add_item("support_grid_adjustment_value",
get_set_grid_adjustment_value, get_set_grid_adjustment_value)
self.core.register_event("support-model-changed",
self.update_support_controls)
grid_distance_square.set_active(True)
self.core.set("support_grid_distance_x", 10.0)
return True
def update_support_model(self, widget=None):
grid_type = self.core.get("support_model_type")
if grid_type == "grid":
s = self.core
if (s.get("support_grid_thickness") > 0) \
and ((s.get("support_grid_distance_x") > 0) \
or (s.get("support_grid_distance_y") > 0)) \
and ((s.get("support_grid_distance_x") == 0) \
or (s.get("support_grid_distance_x") \
> s.get("support_grid_thickness"))) \
and ((s.get("support_grid_distance_y") == 0) \
or (s.get("support_grid_distance_y") \
> s.get("support_grid_thickness"))) \
and (s.get("support_grid_height") > 0):
support_grid = pycam.Toolpath.SupportGrid.get_support_grid(
s.get("minx"), s.get("maxx"), s.get("miny"), s.get("maxy"),
s.get("minz"), s.get("support_grid_distance_x"),
s.get("support_grid_distance_y"),
s.get("support_grid_thickness"),
s.get("support_grid_height"),
offset_x=s.get("support_grid_offset_x"),
offset_y=s.get("support_grid_offset_y"),
adjustments_x=self.grid_adjustments_x,
adjustments_y=self.grid_adjustments_y)
self.core.set("current_support_model", support_grid)
self.core.emit_event("visual-item-updated")
def update_support_controls(self, widget=None):
grid_type = self.core.get("support_model_type")
if grid_type == "grid":
grid_square = self.gui.get_object("SupportGridDistanceSquare")
distance_y = self.gui.get_object("SupportGridDistanceYControl")
distance_y.set_sensitive(not grid_square.get_active())
if grid_square.get_active():
# We let "distance_y" track the value of "distance_x".
self.core.set("support_grid_distance_y",
self.core.get("support_grid_distance_x"))
self.update_support_grid_manual_model()
self.switch_support_grid_manual_selector()
self.gui.get_object("SupportModelGridBox").show()
else:
self.gui.get_object("SupportModelGridBox").hide()
def switch_support_grid_manual_selector(self, widget=None):
""" Event handler for a switch between the x and y axis selector for
manual adjustment. Final goal: update the adjustment combobox with the
current values for that axis.
"""
old_axis_was_x = self.grid_adjustment_axis_x_last
self.grid_adjustment_axis_x_last = \
self.grid_adjustment_axis_x.get_active()
if self.grid_adjustment_axis_x.get_active():
# x axis is selected
if not old_axis_was_x:
self.update_support_grid_manual_model()
max_distance = self.core.get("support_grid_distance_x")
else:
# y axis
if old_axis_was_x:
self.update_support_grid_manual_model()
max_distance = self.core.get("support_grid_distance_y")
# we allow an individual adjustment of 66% of the distance
max_distance /= 1.5
if hasattr(self.grid_adjustment_value, "set_lower"):
# gtk 2.14 is required for "set_lower" and "set_upper"
self.grid_adjustment_value.set_lower(-max_distance)
self.grid_adjustment_value.set_upper(max_distance)
if self.grid_adjustment_value.get_value() \
!= self.core.get("support_grid_adjustment_value"):
self.grid_adjustment_value.set_value(self.core.get(
"support_grid_adjustment_value"))
self.gui.get_object("SupportGridPositionManualShiftBox").set_sensitive(
self.grid_adjustment_selector.get_active() >= 0)
def update_support_grid_manual_adjust(self, widget=None, data1=None,
data2=None):
""" Update the current entry in the manual adjustment combobox after
a manual change. Additionally the slider and the numeric control are
synched.
"""
if self._block_manual_adjust_update:
return
self._block_manual_adjust_update = True
new_value = self.grid_adjustment_value.get_value()
self.core.set("support_grid_adjustment_value", new_value)
tree_iter = self.grid_adjustment_selector.get_active_iter()
if not tree_iter is None:
value_string = "(%+.1f)" % new_value
self.grid_adjustment_model.set(tree_iter, 1, value_string)
self.core.emit_event("support-model-changed")
self._block_manual_adjust_update = False
def reset_support_grid_manual(self, widget=None, reset_all=False):
if reset_all:
self.grid_adjustments_x = []
self.grid_adjustments_y = []
else:
self.core.set("support_grid_adjustment_value", 0)
self.update_support_grid_manual_model()
self.switch_support_grid_manual_selector()
self.core.emit_event("support-model-changed")
def update_support_grid_manual_model(self):
old_index = self.grid_adjustment_selector.get_active()
model = self.grid_adjustment_model
model.clear()
s = self.core
# get the toolpath without adjustments
base_x, base_y = pycam.Toolpath.SupportGrid.get_support_grid_locations(
s.get("minx"), s.get("maxx"), s.get("miny"), s.get("maxy"),
s.get("support_grid_distance_x"),
s.get("support_grid_distance_y"),
offset_x=s.get("support_grid_offset_x"),
offset_y=s.get("support_grid_offset_y"))
# fill the adjustment lists
while len(self.grid_adjustments_x) < len(base_x):
self.grid_adjustments_x.append(0)
while len(self.grid_adjustments_y) < len(base_y):
self.grid_adjustments_y.append(0)
# select the currently active list
if self.grid_adjustment_axis_x.get_active():
base = base_x
adjustments = self.grid_adjustments_x
else:
base = base_y
adjustments = self.grid_adjustments_y
# generate the model content
for index, base_value in enumerate(base):
position = "%.2f%s" % (base_value, s.get("unit"))
if (0 <= index < len(adjustments)) and (adjustments[index] != 0):
diff = "(%+.1f)" % adjustments[index]
else:
diff = ""
model.append((position, diff))
if old_index < len(base):
self.grid_adjustment_selector.set_active(old_index)
else:
self.grid_adjustment_selector.set_active(-1)
...@@ -47,7 +47,7 @@ CALCULATION_BACKENDS = frozenset((None, "ODE")) ...@@ -47,7 +47,7 @@ CALCULATION_BACKENDS = frozenset((None, "ODE"))
def generate_toolpath_from_settings(model, tp_settings, callback=None): def generate_toolpath_from_settings(model, tp_settings, callback=None):
process = tp_settings.get_process_settings() process = tp_settings.get_process_settings()
grid = tp_settings.get_support_grid() support_model = tp_settings.get_support_model()
backend = tp_settings.get_calculation_backend() backend = tp_settings.get_calculation_backend()
return generate_toolpath(model, tp_settings.get_tool_settings(), return generate_toolpath(model, tp_settings.get_tool_settings(),
tp_settings.get_bounds(), process["path_direction"], tp_settings.get_bounds(), process["path_direction"],
...@@ -55,24 +55,14 @@ def generate_toolpath_from_settings(model, tp_settings, callback=None): ...@@ -55,24 +55,14 @@ def generate_toolpath_from_settings(model, tp_settings, callback=None):
process["material_allowance"], process["overlap_percent"], process["material_allowance"], process["overlap_percent"],
process["step_down"], process["engrave_offset"], process["step_down"], process["engrave_offset"],
process["milling_style"], process["pocketing_type"], process["milling_style"], process["pocketing_type"],
grid["type"], grid["distance_x"], grid["distance_y"], support_model, backend, callback)
grid["thickness"], grid["height"], grid["offset_x"],
grid["offset_y"], grid["adjustments_x"], grid["adjustments_y"],
grid["average_distance"], grid["minimum_bridges"], grid["length"],
backend, callback)
def generate_toolpath(model, tool_settings=None, def generate_toolpath(model, tool_settings=None,
bounds=None, direction="x", bounds=None, direction="x",
path_generator="DropCutter", path_postprocessor="ZigZagCutter", path_generator="DropCutter", path_postprocessor="ZigZagCutter",
material_allowance=0, overlap_percent=0, step_down=0, engrave_offset=0, material_allowance=0, overlap_percent=0, step_down=0, engrave_offset=0,
milling_style="ignore", pocketing_type="none", milling_style="ignore", pocketing_type="none",
support_grid_type=None, support_grid_distance_x=None, support_model=None, calculation_backend=None, callback=None):
support_grid_distance_y=None, support_grid_thickness=None,
support_grid_height=None, support_grid_offset_x=None,
support_grid_offset_y=None, support_grid_adjustments_x=None,
support_grid_adjustments_y=None, support_grid_average_distance=None,
support_grid_minimum_bridges=None, support_grid_length=None,
calculation_backend=None, callback=None):
""" abstract interface for generating a toolpath """ abstract interface for generating a toolpath
@type model: pycam.Geometry.Model.Model @type model: pycam.Geometry.Model.Model
...@@ -103,22 +93,6 @@ def generate_toolpath(model, tool_settings=None, ...@@ -103,22 +93,6 @@ def generate_toolpath(model, tool_settings=None,
@value step_down: maximum height of each layer (for PushCutter) @value step_down: maximum height of each layer (for PushCutter)
@type engrave_offset: float @type engrave_offset: float
@value engrave_offset: toolpath distance to the contour model @value engrave_offset: toolpath distance to the contour model
@type support_grid_distance_x: float
@value support_grid_distance_x: distance between support grid lines along x
@type support_grid_distance_y: float
@value support_grid_distance_y: distance between support grid lines along y
@type support_grid_thickness: float
@value support_grid_thickness: thickness of the support grid
@type support_grid_height: float
@value support_grid_height: height of the support grid
@type support_grid_offset_x: float
@value support_grid_offset_x: shift the support grid by this value along x
@type support_grid_offset_y: float
@value support_grid_offset_y: shift the support grid by this value along y
@type support_grid_adjustments_x: list(float)
@value support_grid_adjustments_x: manual adjustment of each x-grid bar
@type support_grid_adjustments_y: list(float)
@value support_grid_adjustments_y: manual adjustment of each y-grid bar
@type calculation_backend: str | None @type calculation_backend: str | None
@value calculation_backend: any member of the CALCULATION_BACKENDS set @value calculation_backend: any member of the CALCULATION_BACKENDS set
The default is the triangular collision detection. The default is the triangular collision detection.
...@@ -156,67 +130,8 @@ def generate_toolpath(model, tool_settings=None, ...@@ -156,67 +130,8 @@ def generate_toolpath(model, tool_settings=None,
# material allowance is not available for these two strategies # material allowance is not available for these two strategies
cutter.set_required_distance(material_allowance) cutter.set_required_distance(material_allowance)
# create the grid model if requested # create the grid model if requested
if (support_grid_type == "grid") \ if support_model:
and (((not support_grid_distance_x is None) \ trimesh_models.append(support_model)
or (not support_grid_distance_y is None)) \
and (not support_grid_thickness is None)):
# grid height defaults to the thickness
if support_grid_height is None:
support_grid_height = support_grid_thickness
if (support_grid_distance_x < 0) or (support_grid_distance_y < 0):
return "The distance of the support grid must be a positive value"
if not ((support_grid_distance_x > 0) or (support_grid_distance_y > 0)):
return "Both distance values for the support grid may not be " \
+ "zero at the same time"
if support_grid_thickness <= 0:
return "The thickness of the support grid must be a positive value"
if support_grid_height <= 0:
return "The height of the support grid must be a positive value"
if not callback is None:
callback(text="Preparing support grid model ...")
support_grid_model = pycam.Toolpath.SupportGrid.get_support_grid(
minx, maxx, miny, maxy, minz, support_grid_distance_x,
support_grid_distance_y, support_grid_thickness,
support_grid_height, offset_x=support_grid_offset_x,
offset_y=support_grid_offset_y,
adjustments_x=support_grid_adjustments_x,
adjustments_y=support_grid_adjustments_y)
trimesh_models.append(support_grid_model)
elif (support_grid_type in ("distributed_edges", "distributed_corners")) \
and (not support_grid_average_distance is None) \
and (not support_grid_thickness is None) \
and (not support_grid_length is None):
if support_grid_height is None:
support_grid_height = support_grid_thickness
if support_grid_minimum_bridges is None:
support_grid_minimum_bridges = 2
if support_grid_average_distance <= 0:
return "The average support grid distance must be a positive value"
if support_grid_minimum_bridges <= 0:
return "The minimum number of bridged per polygon must be a " \
+ "positive value"
if support_grid_thickness <= 0:
return "The thickness of the support grid must be a positive value"
if support_grid_height <= 0:
return "The height of the support grid must be a positive value"
if not callback is None:
callback(text="Preparing support grid model ...")
# check which model to choose
if not contour_model is None:
model = contour_model
else:
model = trimesh_models[0]
start_at_corners = (support_grid_type == "distributed_corners")
support_grid_model = pycam.Toolpath.SupportGrid.get_support_distributed(
model, minz, support_grid_average_distance,
support_grid_minimum_bridges, support_grid_thickness,
support_grid_height, support_grid_length,
bounds, start_at_corners=start_at_corners)
trimesh_models.append(support_grid_model)
elif (not support_grid_type) or (support_grid_type == "none"):
pass
else:
return "Invalid support grid type selected: %s" % support_grid_type
# Adapt the contour_model to the engraving offset. This offset is # Adapt the contour_model to the engraving offset. This offset is
# considered to be part of the material_allowance. # considered to be part of the material_allowance.
if (not contour_model is None) and (engrave_offset != 0): if (not contour_model is None) and (engrave_offset != 0):
......
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