Commit 21de7ac0 authored by sumpfralle's avatar sumpfralle

coloring of models fixed

toolpath-grid plugin improved
units plugin separated


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1127 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 0b069aaf
...@@ -2,20 +2,6 @@ ...@@ -2,20 +2,6 @@
<interface> <interface>
<!-- interface-requires gtk+ 2.12 --> <!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy project-wide --> <!-- interface-naming-policy project-wide -->
<object class="GtkListStore" id="unit_model">
<columns>
<!-- column-name name -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">mm</col>
</row>
<row>
<col id="0" translatable="yes">inch</col>
</row>
</data>
</object>
<object class="GtkListStore" id="ProcessingConfigs"> <object class="GtkListStore" id="ProcessingConfigs">
<columns> <columns>
<!-- column-name Name --> <!-- column-name Name -->
...@@ -178,7 +164,7 @@ ...@@ -178,7 +164,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="left_padding">12</property> <property name="left_padding">12</property>
<child> <child>
<object class="GtkVBox" id="vbox14"> <object class="GtkVBox" id="GeneralPreferencesBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">2</property> <property name="spacing">2</property>
...@@ -196,77 +182,44 @@ ...@@ -196,77 +182,44 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkTable" id="table8"> <object class="GtkVBox" id="TaskSettingsDefaultFileBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="n_columns">2</property> <property name="orientation">vertical</property>
<property name="column_spacing">5</property>
<property name="row_spacing">3</property>
<child> <child>
<object class="GtkLabel" id="UnitLabel"> <object class="GtkCheckButton" id="AutoLoadTaskFile">
<property name="label" translatable="yes">Load custom task settings on startup</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0</property> <property name="can_focus">True</property>
<property name="label" translatable="yes">Unit (for all dimensions):</property> <property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object> </object>
<packing> <packing>
<property name="x_options">GTK_FILL</property> <property name="expand">False</property>
<property name="y_options">GTK_FILL</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkComboBox" id="unit_control"> <object class="GtkAlignment" id="StartupTaskFileBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="model">unit_model</property> <property name="left_padding">20</property>
<property name="active">0</property>
<child> <child>
<object class="GtkCellRendererText" id="unit_name"/> <object class="GtkFileChooserButton" id="StartupTaskFile">
<attributes> <property name="visible">True</property>
<attribute name="text">0</attribute> <property name="title" translatable="yes">Choose custom task settings file loading on startup</property>
</attributes> </object>
</child> </child>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="expand">False</property>
<property name="right_attach">2</property> <property name="position">1</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing> </packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkCheckButton" id="AutoLoadTaskFile">
<property name="label" translatable="yes">Load custom task settings on startup</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="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="StartupTaskFileBox">
<property name="visible">True</property>
<property name="left_padding">20</property>
<child>
<object class="GtkFileChooserButton" id="StartupTaskFile">
<property name="visible">True</property>
<property name="title" translatable="yes">Choose custom task settings file loading on startup</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
</object> </object>
</child> </child>
</object> </object>
...@@ -1601,7 +1554,7 @@ Hotkey: &lt;m&gt;</property> ...@@ -1601,7 +1554,7 @@ Hotkey: &lt;m&gt;</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Toggle the OpenGL lighting. <property name="tooltip_text" translatable="yes">Toggle the OpenGL lighting.
Hotkey: &lt;l&gt;</property> Hotkey: &lt;i&gt;</property>
<property name="draw_indicator">True</property> <property name="draw_indicator">True</property>
</object> </object>
<packing> <packing>
...@@ -1983,184 +1936,6 @@ You should have received a copy of the GNU General Public License along with thi ...@@ -1983,184 +1936,6 @@ You should have received a copy of the GNU General Public License along with thi
<object class="GtkAction" id="ExportEMCToolDefinition"> <object class="GtkAction" id="ExportEMCToolDefinition">
<property name="label">_Export EMC tools ...</property> <property name="label">_Export EMC tools ...</property>
</object> </object>
<object class="GtkDialog" id="UnitChangeDialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">Unit change compensation</property>
<property name="role">pycam-units</property>
<property name="modal">True</property>
<property name="icon_name">accessories-calculator</property>
<property name="type_hint">normal</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox7">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkFrame" id="UnitChangeFrame">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment28">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkVBox" id="vbox24">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="UnitChangeHelpLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Switching the unit size causes a change of the real world size of the various dimensions within PyCAM.
This change can be compensated by applying the unit conversion factor to the current dimensions.
Any selected group of dimensions will be scaled accordingly.</property>
<property name="wrap">True</property>
<property name="width_chars">40</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="UnitChangeModel">
<property name="label" translatable="yes">Model</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="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="UnitChangeTools">
<property name="label" translatable="yes">Tools</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="position">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="UnitChangeProcesses">
<property name="label" translatable="yes">Processes</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="expand">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="UnitChangeBounds">
<property name="label" translatable="yes">Bounds</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="expand">False</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkHButtonBox" id="hbuttonbox2">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="UnitChangeSelectAll">
<property name="label">gtk-select-all</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="UnitChangeSelectNone">
<property name="label">gtk-clear</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="padding">4</property>
<property name="position">5</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="UnitChangeFrameLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Change of unit size&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area5">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkButton" id="UnitChangeApply">
<property name="label">gtk-apply</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">UnitChangeApply</action-widget>
</action-widgets>
</object>
<object class="GtkAction" id="HelpMenu"> <object class="GtkAction" id="HelpMenu">
<property name="label">_Help</property> <property name="label">_Help</property>
</object> </object>
...@@ -2264,262 +2039,6 @@ Any selected group of dimensions will be scaled accordingly.</property> ...@@ -2264,262 +2039,6 @@ Any selected group of dimensions will be scaled accordingly.</property>
<property name="upper">100</property> <property name="upper">100</property>
<property name="step_increment">5.0000000000000002e-05</property> <property name="step_increment">5.0000000000000002e-05</property>
</object> </object>
<object class="GtkDialog" id="ToolpathGridDialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">Toolpath Grid</property>
<property name="role">pycam-toolpath-grid</property>
<property name="destroy_with_parent">True</property>
<property name="icon_name">document-page-setup</property>
<property name="type_hint">normal</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox10">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkTable" id="table16">
<property name="visible">True</property>
<property name="n_rows">4</property>
<property name="n_columns">3</property>
<property name="column_spacing">3</property>
<property name="row_spacing">3</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkLabel" id="LabelGridRows">
<property name="visible">True</property>
<property name="label" translatable="yes">Rows</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="LabelGridColumns">
<property name="visible">True</property>
<property name="label" translatable="yes">Columns</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="LabelGridCount">
<property name="visible">True</property>
<property name="label" translatable="yes">Count:</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="GtkLabel" id="LabelGridDistance">
<property name="visible">True</property>
<property name="label" translatable="yes">Distance:</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="GridYCount">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">GridYCountValue</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="GridXCount">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">GridXCountValue</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="GtkSpinButton" id="GridYDistance">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">GridYDistanceValue</property>
<property name="digits">3</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="GridXDistance">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">GridXDistanceValue</property>
<property name="digits">3</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>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment47">
<property name="visible">True</property>
<child>
<placeholder/>
</child>
</object>
</child>
<child>
<object class="GtkLabel" id="LabelWidth">
<property name="visible">True</property>
<property name="label" translatable="yes">Width:</property>
</object>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="LabelGridYWidth">
<property name="visible">True</property>
<property name="label" translatable="yes">?</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="LabelGridXWidth">
<property name="visible">True</property>
<property name="label" translatable="yes">?</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area9">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="ToolpathGridClose">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="ToolpathGridOK">
<property name="label">gtk-ok</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">ToolpathGridClose</action-widget>
<action-widget response="1">ToolpathGridOK</action-widget>
</action-widgets>
</object>
<object class="GtkAdjustment" id="GridYCountValue">
<property name="value">1</property>
<property name="lower">1</property>
<property name="upper">1000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="GridXCountValue">
<property name="value">1</property>
<property name="lower">1</property>
<property name="upper">1000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="GridYDistanceValue">
<property name="lower">-1000</property>
<property name="upper">1000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="GridXDistanceValue">
<property name="lower">-1000</property>
<property name="upper">1000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="ToolChangeRapidMoveDownValue"> <object class="GtkAdjustment" id="ToolChangeRapidMoveDownValue">
<property name="upper">10000</property> <property name="upper">10000</property>
<property name="step_increment">1</property> <property name="step_increment">1</property>
......
...@@ -2,10 +2,258 @@ ...@@ -2,10 +2,258 @@
<interface> <interface>
<!-- interface-requires gtk+ 2.12 --> <!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy project-wide --> <!-- interface-naming-policy project-wide -->
<object class="GtkButton" id="ToolpathGrid"> <object class="GtkDialog" id="ToolpathGridDialog">
<property name="label">Clone grid</property> <property name="border_width">5</property>
<property name="visible">True</property> <property name="title" translatable="yes">Toolpath Grid</property>
<property name="can_focus">True</property> <property name="role">pycam-toolpath-grid</property>
<property name="receives_default">True</property> <property name="destroy_with_parent">True</property>
<property name="icon_name">document-page-setup</property>
<property name="type_hint">normal</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox10">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkTable" id="table16">
<property name="visible">True</property>
<property name="n_rows">4</property>
<property name="n_columns">3</property>
<property name="column_spacing">3</property>
<property name="row_spacing">3</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkLabel" id="LabelGridRows">
<property name="visible">True</property>
<property name="label" translatable="yes">Rows</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="LabelGridColumns">
<property name="visible">True</property>
<property name="label" translatable="yes">Columns</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="LabelGridCount">
<property name="visible">True</property>
<property name="label" translatable="yes">Count:</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="GtkLabel" id="LabelGridDistance">
<property name="visible">True</property>
<property name="label" translatable="yes">Distance:</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="GridYCount">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">GridYCountValue</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="GridXCount">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">GridXCountValue</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="GtkSpinButton" id="GridYDistance">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">GridYDistanceValue</property>
<property name="digits">3</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="GridXDistance">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">GridXDistanceValue</property>
<property name="digits">3</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>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment47">
<property name="visible">True</property>
<child>
<placeholder/>
</child>
</object>
</child>
<child>
<object class="GtkLabel" id="LabelWidth">
<property name="visible">True</property>
<property name="label" translatable="yes">Width:</property>
</object>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="LabelGridYWidth">
<property name="visible">True</property>
<property name="label" translatable="yes">?</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="LabelGridXWidth">
<property name="visible">True</property>
<property name="label" translatable="yes">?</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area9">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="ToolpathGridClose">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="ToolpathGridOK">
<property name="label">gtk-ok</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">ToolpathGridClose</action-widget>
<action-widget response="1">ToolpathGridOK</action-widget>
</action-widgets>
</object>
<object class="GtkAdjustment" id="GridXDistanceValue">
<property name="lower">-1000</property>
<property name="upper">1000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="GridYDistanceValue">
<property name="lower">-1000</property>
<property name="upper">1000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="GridXCountValue">
<property name="lower">1</property>
<property name="upper">1000</property>
<property name="step_increment">1</property>
</object>
<object class="GtkAdjustment" id="GridYCountValue">
<property name="lower">1</property>
<property name="upper">1000</property>
<property name="step_increment">1</property>
</object> </object>
</interface> </interface>
<?xml version="1.0"?>
<interface>
<!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy project-wide -->
<object class="GtkDialog" id="UnitChangeDialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">Unit change compensation</property>
<property name="role">pycam-units</property>
<property name="modal">True</property>
<property name="icon_name">accessories-calculator</property>
<property name="type_hint">normal</property>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox7">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child>
<object class="GtkFrame" id="UnitChangeFrame">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment28">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkVBox" id="vbox24">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="UnitChangeHelpLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Switching the unit size causes a change of the real world size of the various dimensions within PyCAM.
This change can be compensated by applying the unit conversion factor to the current dimensions.
Any selected group of dimensions will be scaled accordingly.</property>
<property name="wrap">True</property>
<property name="width_chars">40</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="UnitChangeModel">
<property name="label" translatable="yes">Model</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="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="UnitChangeTools">
<property name="label" translatable="yes">Tools</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="position">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="UnitChangeProcesses">
<property name="label" translatable="yes">Processes</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="expand">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="UnitChangeBounds">
<property name="label" translatable="yes">Bounds</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="expand">False</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkHButtonBox" id="hbuttonbox2">
<property name="visible">True</property>
<child>
<object class="GtkButton" id="UnitChangeSelectAll">
<property name="label">gtk-select-all</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="UnitChangeSelectNone">
<property name="label">gtk-clear</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="padding">4</property>
<property name="position">5</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="UnitChangeFrameLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Change of unit size&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area5">
<property name="visible">True</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkButton" id="UnitChangeApply">
<property name="label">gtk-apply</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="0">UnitChangeApply</action-widget>
</action-widgets>
</object>
<object class="GtkListStore" id="UnitModel">
<columns>
<!-- column-name name -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes">mm</col>
</row>
<row>
<col id="0" translatable="yes">inch</col>
</row>
</data>
</object>
<object class="GtkHBox" id="UnitPrefBox">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="UnitLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Unit (for all dimensions):</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="unit_control">
<property name="visible">True</property>
<property name="model">UnitModel</property>
<property name="active">0</property>
<child>
<object class="GtkCellRendererText" id="unit_name"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
</interface>
...@@ -21,6 +21,10 @@ You should have received a copy of the GNU General Public License ...@@ -21,6 +21,10 @@ You should have received a copy of the GNU General Public License
along with PyCAM. If not, see <http://www.gnu.org/licenses/>. along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
""" """
import uuid
import math
import pycam.Exporters.STLExporter import pycam.Exporters.STLExporter
import pycam.Exporters.SVGExporter import pycam.Exporters.SVGExporter
from pycam.Geometry.Triangle import Triangle from pycam.Geometry.Triangle import Triangle
...@@ -35,10 +39,6 @@ from pycam.Geometry.utils import INFINITE, epsilon ...@@ -35,10 +39,6 @@ from pycam.Geometry.utils import INFINITE, epsilon
from pycam.Geometry import TransformableContainer from pycam.Geometry import TransformableContainer
from pycam.Utils import ProgressCounter from pycam.Utils import ProgressCounter
import pycam.Utils.log import pycam.Utils.log
import uuid
import math
# OpenGLTools will be imported later, if necessary
#import pycam.Gui.OpenGLTools
try: try:
...@@ -169,7 +169,6 @@ class BaseModel(TransformableContainer): ...@@ -169,7 +169,6 @@ class BaseModel(TransformableContainer):
if not coords in vertices: if not coords in vertices:
vertices[coords] = [] vertices[coords] = []
vertices[coords].append((t.normal.normalized(), t.get_area())) vertices[coords].append((t.normal.normalized(), t.get_area()))
print "Triangles: %d / Vertices: %d" % (len(self.triangles()), len(vertices))
GL.glBegin(GL.GL_TRIANGLES) GL.glBegin(GL.GL_TRIANGLES)
for t in self.triangles(): for t in self.triangles():
# The triangle's points are in clockwise order, but GL expects # The triangle's points are in clockwise order, but GL expects
......
...@@ -415,10 +415,6 @@ class ProjectGui(object): ...@@ -415,10 +415,6 @@ class ProjectGui(object):
self.about_window = self.gui.get_object("AboutWindow") self.about_window = self.gui.get_object("AboutWindow")
self.about_window.set_version(VERSION) self.about_window.set_version(VERSION)
self.gui.get_object("About").connect("activate", self.toggle_about_window, True) self.gui.get_object("About").connect("activate", self.toggle_about_window, True)
# "unit change" window
self.unit_change_window = self.gui.get_object("UnitChangeDialog")
self.gui.get_object("UnitChangeApply").connect("clicked", self.change_unit_apply)
self.unit_change_window.connect("delete_event", self.change_unit_apply, False)
# we assume, that the last child of the window is the "close" button # we assume, that the last child of the window is the "close" button
# TODO: fix this ugly hack! # TODO: fix this ugly hack!
self.gui.get_object("AboutWindowButtons").get_children()[-1].connect("clicked", self.toggle_about_window, False) self.gui.get_object("AboutWindowButtons").get_children()[-1].connect("clicked", self.toggle_about_window, False)
...@@ -430,6 +426,7 @@ class ProjectGui(object): ...@@ -430,6 +426,7 @@ class ProjectGui(object):
self.settings.add_item("gtk-accel-group", lambda: self._accel_group) self.settings.add_item("gtk-accel-group", lambda: self._accel_group)
for window in (self.window, self.about_window, self.preferences_window): for window in (self.window, self.about_window, self.preferences_window):
window.add_accel_group(self._accel_group) window.add_accel_group(self._accel_group)
# preferences tab
preferences_book = self.gui.get_object("PreferencesNotebook") preferences_book = self.gui.get_object("PreferencesNotebook")
def clear_preferences(): def clear_preferences():
for index in range(preferences_book.get_n_pages()): for index in range(preferences_book.get_n_pages()):
...@@ -448,9 +445,23 @@ class ProjectGui(object): ...@@ -448,9 +445,23 @@ class ProjectGui(object):
obj = self.gui.get_object(obj_name) obj = self.gui.get_object(obj_name)
obj.unparent() obj.unparent()
self.settings.register_ui("preferences", label, obj, priority) self.settings.register_ui("preferences", label, obj, priority)
# general preferences
general_prefs = self.gui.get_object("GeneralPreferencesBox")
def clear_general_prefs():
for item in general_prefs.get_children():
general_prefs.remove(item)
def add_general_prefs_item(item, name):
general_prefs.pack_start(item, expand=False, padding=3)
self.settings.register_ui_section("preferences_general",
add_general_prefs_item, clear_general_prefs)
for obj_name, priority in (("SettingEnableODE", 10),
("TaskSettingsDefaultFileBox", 30)):
obj = self.gui.get_object(obj_name)
obj.unparent()
self.settings.register_ui("preferences_general", None,
obj, priority)
# set defaults # set defaults
self.cutter = None self.cutter = None
self._last_unit = None
# add some dummies - to be implemented later ... # add some dummies - to be implemented later ...
self.settings.add_item("cutter", lambda: self.cutter) self.settings.add_item("cutter", lambda: self.cutter)
main_tab = self.gui.get_object("MainTabs") main_tab = self.gui.get_object("MainTabs")
...@@ -475,17 +486,6 @@ class ProjectGui(object): ...@@ -475,17 +486,6 @@ class ProjectGui(object):
clear_main_window) clear_main_window)
self.settings.register_ui("main_window", "Tabs", main_tab, -20, self.settings.register_ui("main_window", "Tabs", main_tab, -20,
args_dict={"expand": True, "fill": True}) args_dict={"expand": True, "fill": True})
# unit control (mm/inch)
unit_field = self.gui.get_object("unit_control")
unit_field.connect("changed", self.change_unit_init)
def set_unit(text):
unit_field.set_active(0 if text == "mm" else 1)
self._last_unit = text
self.settings.add_item("unit", unit_field.get_active_text, set_unit)
self.gui.get_object("UnitChangeSelectAll").connect("clicked",
self.change_unit_set_selection, True)
self.gui.get_object("UnitChangeSelectNone").connect("clicked",
self.change_unit_set_selection, False)
# autoload task settings file on startup # autoload task settings file on startup
autoload_enable = self.gui.get_object("AutoLoadTaskFile") autoload_enable = self.gui.get_object("AutoLoadTaskFile")
autoload_box = self.gui.get_object("StartupTaskFileBox") autoload_box = self.gui.get_object("StartupTaskFileBox")
...@@ -746,7 +746,6 @@ class ProjectGui(object): ...@@ -746,7 +746,6 @@ class ProjectGui(object):
def update_all_controls(self): def update_all_controls(self):
self.update_save_actions() self.update_save_actions()
self.update_unit_labels()
self.update_gcode_controls() self.update_gcode_controls()
self.update_ode_settings() self.update_ode_settings()
...@@ -930,113 +929,6 @@ class ProjectGui(object): ...@@ -930,113 +929,6 @@ class ProjectGui(object):
# don't close the window - just hide it (for "delete-event") # don't close the window - just hide it (for "delete-event")
return True return True
def change_unit_init(self, widget=None):
new_unit = self.gui.get_object("unit_control").get_active_text()
if self._last_unit is None:
# first initialization
self._last_unit = new_unit
return
if self._last_unit == new_unit:
# don't show the dialog if the conversion would make no sense
return
if self.no_dialog:
# without the dialog we don't scale anything
return
# show a dialog asking for a possible model scaling due to the unit change
self.unit_change_window.show()
def change_unit_set_selection(self, widget, state):
for key in ("UnitChangeModel", "UnitChangeProcesses", "UnitChangeTools",
"UnitChangeBounds"):
self.gui.get_object(key).set_active(state)
def change_unit_apply(self, widget=None, data=None, apply_scale=True):
if self.no_dialog:
# without the dialog we don't scale anything
return
new_unit = self.gui.get_object("unit_control").get_active_text()
factors = {
("mm", "inch"): 1 / 25.4,
("inch", "mm"): 25.4,
}
conversion = (self._last_unit, new_unit)
if conversion in factors.keys():
factor = factors[conversion]
if apply_scale:
if self.gui.get_object("UnitChangeModel").get_active():
# transform the model if it is selected
# keep the original center of the model
self.settings.emit_event("model-change-before")
models = self.settings.get("models")
progress = self.settings.get("progress")
progress.disable_cancel()
progress.set_multiple(len(models), "Scaling model")
for model in models:
new_x, new_y, new_z = ((model.maxx + model.minx) / 2,
(model.maxy + model.miny) / 2,
(model.maxz + model.minz) / 2)
model.scale(factor, callback=progress.update)
cur_x, cur_y, cur_z = self._get_model_center()
model.shift(new_x - cur_x, new_y - cur_y,
new_z - cur_z,
callback=progress.update)
progress.update_multiple()
progress.finish()
if self.gui.get_object("UnitChangeProcesses").get_active():
# scale the process settings
for process in self.settings.get("processes"):
for key in ("MaterialAllowanceControl",
"MaxStepDownControl",
"EngraveOffsetControl"):
process[key] *= factor
if self.gui.get_object("UnitChangeBounds").get_active():
# scale the boundaries and keep their center
for bounds in self.settings.get("bounds"):
low, high = bounds.get_bounds()
if bounds.get_type() == Bounds.TYPE_FIXED_MARGIN:
low[0] *= factor
high[0] *= factor
low[1] *= factor
high[1] *= factor
low[2] *= factor
high[2] *= factor
bounds.set_bounds(low, high)
elif bounds.get_type() == Bounds.TYPE_CUSTOM:
center = [0, 0, 0]
for i in range(3):
center[i] = (high[i] + low[i]) / 2
for i in range(3):
low[i] = center[i] + (low[i] - center[i]) * factor
high[i] = center[i] + (high[i] - center[i]) * factor
bounds.set_bounds(low, high)
elif bounds.get_type() == Bounds.TYPE_RELATIVE_MARGIN:
# no need to change relative margins
pass
if self.gui.get_object("UnitChangeTools").get_active():
# scale all tool dimensions
for tool in self.settings.get("tools"):
for key in ("tool_radius", "torus_radius"):
# TODO: fix this invalid access
tool[key] *= factor
self.unit_change_window.hide()
# store the current unit (for the next run of this function)
self._last_unit = new_unit
# update all labels containing the unit size
self.update_unit_labels()
# redraw the model
self.settings.emit_event("model-change-after")
def update_unit_labels(self, widget=None, data=None):
# don't use the "unit" setting, since we need the plural of "inch"
if self.settings.get("unit") == "mm":
base_unit = "mm"
else:
base_unit = "inches"
for key in ("SpeedUnit2", ):
self.gui.get_object(key).set_text("%s/minute" % base_unit)
for key in ("LengthUnit1", "LengthUnit2", "LengthUnitTouchOffHeight"):
self.gui.get_object(key).set_text(base_unit)
def get_filename_with_suffix(self, filename, type_filter): def get_filename_with_suffix(self, filename, type_filter):
# use the first extension provided by the filter as the default # use the first extension provided by the filter as the default
if isinstance(type_filter[0], (tuple, list)): if isinstance(type_filter[0], (tuple, list)):
......
...@@ -43,6 +43,7 @@ class OpenGLViewModel(pycam.Plugins.PluginBase): ...@@ -43,6 +43,7 @@ class OpenGLViewModel(pycam.Plugins.PluginBase):
return True return True
def draw_model(self): def draw_model(self):
GL = self._GL
if self.core.get("show_model") \ if self.core.get("show_model") \
and not (self.core.get("show_simulation") \ and not (self.core.get("show_simulation") \
and self.core.get("simulation_toolpath_moves")): and self.core.get("simulation_toolpath_moves")):
...@@ -50,9 +51,13 @@ class OpenGLViewModel(pycam.Plugins.PluginBase): ...@@ -50,9 +51,13 @@ class OpenGLViewModel(pycam.Plugins.PluginBase):
color_str = self.core.get("models").get_attr(model, "color") color_str = self.core.get("models").get_attr(model, "color")
alpha = self.core.get("models").get_attr(model, "alpha") alpha = self.core.get("models").get_attr(model, "alpha")
col = self._gtk.gdk.color_parse(color_str) col = self._gtk.gdk.color_parse(color_str)
self._GL.glColor4f(col.red / GTK_COLOR_MAX, col.green / GTK_COLOR_MAX, color = (col.red / GTK_COLOR_MAX, col.green / GTK_COLOR_MAX,
col.blue / GTK_COLOR_MAX, alpha / GTK_COLOR_MAX) col.blue / GTK_COLOR_MAX, alpha / GTK_COLOR_MAX)
GL.glColor4f(*color)
# reset the material color
GL.glMaterial(GL.GL_FRONT_AND_BACK,
GL.GL_AMBIENT_AND_DIFFUSE, color)
# we need to wait until the color change is active # we need to wait until the color change is active
self._GL.glFinish() GL.glFinish()
model.to_OpenGL(show_directions=self.core.get("show_directions")) model.to_OpenGL(show_directions=self.core.get("show_directions"))
...@@ -239,7 +239,7 @@ class OpenGLWindow(pycam.Plugins.PluginBase): ...@@ -239,7 +239,7 @@ class OpenGLWindow(pycam.Plugins.PluginBase):
self.reset_view() self.reset_view()
else: else:
# the window is just hidden # the window is just hidden
self.view3d.show() self.show()
else: else:
self.hide() self.hide()
......
...@@ -28,8 +28,16 @@ class ToolpathGrid(pycam.Plugins.PluginBase): ...@@ -28,8 +28,16 @@ class ToolpathGrid(pycam.Plugins.PluginBase):
UI_FILE = "toolpath_grid.ui" UI_FILE = "toolpath_grid.ui"
def setup(self):
if self.gui:
for objname in ("GridYCount", "GridXCount", "GridYDistance",
"GridXDistance"):
self.gui.get_object(objname).connect("value-changed",
self.update_toolpath_grid_window)
# TODO: add a button to the toolpath action UI
return True
def update_toolpath_grid_window(self, widget=None): def update_toolpath_grid_window(self, widget=None):
return False
data = self._toolpath_for_grid_data data = self._toolpath_for_grid_data
x_dim = data["maxx"] - data["minx"] x_dim = data["maxx"] - data["minx"]
y_dim = data["maxy"] - data["miny"] y_dim = data["maxy"] - data["miny"]
...@@ -43,10 +51,6 @@ class ToolpathGrid(pycam.Plugins.PluginBase): ...@@ -43,10 +51,6 @@ class ToolpathGrid(pycam.Plugins.PluginBase):
(x_width, self.settings.get("unit"))) (x_width, self.settings.get("unit")))
self.gui.get_object("LabelGridYWidth").set_label("%g%s" % \ self.gui.get_object("LabelGridYWidth").set_label("%g%s" % \
(y_width, self.settings.get("unit"))) (y_width, self.settings.get("unit")))
for objname in ("GridYCount", "GridXCount", "GridYDistance",
"GridXDistance"):
self.gui.get_object(objname).connect("value-changed",
self.update_toolpath_grid_window)
def create_toolpath_grid(self, toolpath): def create_toolpath_grid(self, toolpath):
dialog = self.gui.get_object("ToolpathGridDialog") dialog = self.gui.get_object("ToolpathGridDialog")
...@@ -80,6 +84,7 @@ class ToolpathGrid(pycam.Plugins.PluginBase): ...@@ -80,6 +84,7 @@ class ToolpathGrid(pycam.Plugins.PluginBase):
toolpath.toolpath_settings) toolpath.toolpath_settings)
toolpath.visible = False toolpath.visible = False
new_toolpath.visible = True new_toolpath.visible = True
# TODO: emit "toolpath-list-changed"
self.toolpath.append(new_toolpath) self.toolpath.append(new_toolpath)
self.update_toolpath_table() self.update_toolpath_table()
dialog.hide() dialog.hide()
......
...@@ -152,33 +152,6 @@ class Toolpaths(pycam.Plugins.ListPluginBase): ...@@ -152,33 +152,6 @@ class Toolpaths(pycam.Plugins.ListPluginBase):
self.core.get("gcode_safety_height"))) self.core.get("gcode_safety_height")))
cell.set_property("text", text) cell.set_property("text", text)
def _update_toolpath_table(self, new_index=None, skip_model_update=False):
self._update_widgets()
# reset the model data and the selection
if new_index is None:
# keep the old selection - this may return "None" if nothing is selected
new_index = self._treeview_get_active_index(self.toolpath_table, self.toolpath)
if not skip_model_update:
# update the TreeModel data
self._treemodel.clear()
# columns: name, visible, drill_size, drill_id, allowance, speed, feedrate
for index in range(len(self.toolpath)):
tp = self.toolpath[index]
toolpath_settings = tp.get_toolpath_settings()
tool = toolpath_settings.get_tool_settings()
process = toolpath_settings.get_process_settings()
items = (index, tp.name, tp.visible, tool["tool_radius"],
tool["id"], process["material_allowance"],
tool["speed"], tool["feedrate"],
get_time_string(tp.get_machine_time(
self.core.get("gcode_safety_height"))))
self._treemodel.append(items)
if not new_index is None:
self._treeview_set_active_index(self.toolpath_table, new_index)
# enable/disable the modification buttons
self.gui.get_object("toolpath_simulate").set_sensitive(not new_index is None)
self.gui.get_object("ToolpathGrid").set_sensitive(not new_index is None)
def save_toolpath(self, widget=None, only_visible=False): def save_toolpath(self, widget=None, only_visible=False):
if only_visible: if only_visible:
toolpaths = self.get_selected() toolpaths = self.get_selected()
......
# -*- 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 Toolpaths(pycam.Plugins.PluginBase):
UI_FILE = "units.ui"
def setup(self):
if self.gui:
unit_pref_box = self.gui.get_object("UnitPrefBox")
unit_pref_box.unparent()
self.core.register_ui("preferences_general", "Units",
unit_pref_box, 20)
# unit control (mm/inch)
unit_field = self.gui.get_object("unit_control")
unit_field.connect("changed", self.change_unit_init)
def set_unit(text):
unit_field.set_active(0 if text == "mm" else 1)
self._last_unit = text
self.core.add_item("unit", unit_field.get_active_text, set_unit)
self.gui.get_object("UnitChangeSelectAll").connect("clicked",
self.change_unit_set_selection, True)
self.gui.get_object("UnitChangeSelectNone").connect("clicked",
self.change_unit_set_selection, False)
# "unit change" window
self.unit_change_window = self.gui.get_object("UnitChangeDialog")
self.gui.get_object("UnitChangeApply").connect("clicked", self.change_unit_apply)
self.unit_change_window.connect("delete_event", self.change_unit_apply, False)
return True
def teardown(self):
self.core.unregister_ui("preferences_general",
self.gui.get_object("UnitPrefBox"))
def change_unit_init(self, widget=None):
new_unit = self.gui.get_object("unit_control").get_active_text()
if self._last_unit is None:
# first initialization
self._last_unit = new_unit
return
if self._last_unit == new_unit:
# don't show the dialog if the conversion would make no sense
return
# show a dialog asking for a possible model scaling due to the unit change
self.unit_change_window.show()
def change_unit_set_selection(self, widget, state):
for key in ("UnitChangeModel", "UnitChangeProcesses", "UnitChangeTools",
"UnitChangeBounds"):
self.gui.get_object(key).set_active(state)
def change_unit_apply(self, widget=None, data=None, apply_scale=True):
# TODO: move tool/process/task related code to these plugins
new_unit = self.gui.get_object("unit_control").get_active_text()
factors = {
("mm", "inch"): 1 / 25.4,
("inch", "mm"): 25.4,
}
conversion = (self._last_unit, new_unit)
if conversion in factors.keys():
factor = factors[conversion]
if apply_scale:
if self.gui.get_object("UnitChangeModel").get_active():
# transform the model if it is selected
# keep the original center of the model
self.core.emit_event("model-change-before")
models = self.core.get("models")
progress = self.core.get("progress")
progress.disable_cancel()
progress.set_multiple(len(models), "Scaling model")
for model in models:
new_x, new_y, new_z = ((model.maxx + model.minx) / 2,
(model.maxy + model.miny) / 2,
(model.maxz + model.minz) / 2)
model.scale(factor, callback=progress.update)
cur_x, cur_y, cur_z = self._get_model_center()
model.shift(new_x - cur_x, new_y - cur_y,
new_z - cur_z,
callback=progress.update)
progress.update_multiple()
progress.finish()
if self.gui.get_object("UnitChangeProcesses").get_active():
# scale the process settings
for process in self.core.get("processes"):
for key in ("MaterialAllowanceControl",
"MaxStepDownControl",
"EngraveOffsetControl"):
process[key] *= factor
if self.gui.get_object("UnitChangeBounds").get_active():
# scale the boundaries and keep their center
for bounds in self.core.get("bounds"):
low, high = bounds.get_bounds()
if bounds.get_type() == Bounds.TYPE_FIXED_MARGIN:
low[0] *= factor
high[0] *= factor
low[1] *= factor
high[1] *= factor
low[2] *= factor
high[2] *= factor
bounds.set_bounds(low, high)
elif bounds.get_type() == Bounds.TYPE_CUSTOM:
center = [0, 0, 0]
for i in range(3):
center[i] = (high[i] + low[i]) / 2
for i in range(3):
low[i] = center[i] + (low[i] - center[i]) * factor
high[i] = center[i] + (high[i] - center[i]) * factor
bounds.set_bounds(low, high)
elif bounds.get_type() == Bounds.TYPE_RELATIVE_MARGIN:
# no need to change relative margins
pass
if self.gui.get_object("UnitChangeTools").get_active():
# scale all tool dimensions
for tool in self.core.get("tools"):
for key in ("tool_radius", "torus_radius"):
# TODO: fix this invalid access
tool[key] *= factor
self.unit_change_window.hide()
# store the current unit (for the next run of this function)
self._last_unit = new_unit
# update all labels containing the unit size
self.update_unit_labels()
# redraw the model
self.core.emit_event("model-change-after")
def update_unit_labels(self, widget=None, data=None):
# don't use the "unit" setting, since we need the plural of "inch"
if self.core.get("unit") == "mm":
base_unit = "mm"
else:
base_unit = "inches"
for key in ("SpeedUnit2", ):
self.gui.get_object(key).set_text("%s/minute" % base_unit)
for key in ("LengthUnit1", "LengthUnit2", "LengthUnitTouchOffHeight"):
self.gui.get_object(key).set_text(base_unit)
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