Commit 9b3fab54 authored by sumpfralle's avatar sumpfralle

implemented the increase/decrease/reset buttons for x/y/z bounds


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@409 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 9f55599e
...@@ -381,6 +381,15 @@ class ProjectGui: ...@@ -381,6 +381,15 @@ class ProjectGui:
self.gui.get_object("BoundsListMoveDown").connect("clicked", self.handle_bounds_table_event, "move_down") self.gui.get_object("BoundsListMoveDown").connect("clicked", self.handle_bounds_table_event, "move_down")
self.gui.get_object("BoundsListAdd").connect("clicked", self.handle_bounds_table_event, "add") self.gui.get_object("BoundsListAdd").connect("clicked", self.handle_bounds_table_event, "add")
self.gui.get_object("BoundsListDelete").connect("clicked", self.handle_bounds_table_event, "delete") self.gui.get_object("BoundsListDelete").connect("clicked", self.handle_bounds_table_event, "delete")
self.gui.get_object("BoundsMarginIncreaseX").connect("clicked", self.adjust_bounds, "x", "+")
self.gui.get_object("BoundsMarginIncreaseY").connect("clicked", self.adjust_bounds, "y", "+")
self.gui.get_object("BoundsMarginIncreaseZ").connect("clicked", self.adjust_bounds, "z", "+")
self.gui.get_object("BoundsMarginDecreaseX").connect("clicked", self.adjust_bounds, "x", "-")
self.gui.get_object("BoundsMarginDecreaseY").connect("clicked", self.adjust_bounds, "y", "-")
self.gui.get_object("BoundsMarginDecreaseZ").connect("clicked", self.adjust_bounds, "z", "-")
self.gui.get_object("BoundsMarginResetX").connect("clicked", self.adjust_bounds, "x", "0")
self.gui.get_object("BoundsMarginResetY").connect("clicked", self.adjust_bounds, "y", "0")
self.gui.get_object("BoundsMarginResetZ").connect("clicked", self.adjust_bounds, "z", "0")
# connect change handler for boundary settings # connect change handler for boundary settings
self.gui.get_object("BoundsName").connect("changed", self.gui.get_object("BoundsName").connect("changed",
self.handle_bounds_settings_change) self.handle_bounds_settings_change)
...@@ -567,6 +576,42 @@ class ProjectGui: ...@@ -567,6 +576,42 @@ class ProjectGui:
else: else:
self.settings.set("support_grid", None) self.settings.set("support_grid", None)
@gui_activity_guard
def adjust_bounds(self, widget, axis, change):
bounds = self.settings.get("current_bounds")
abs_bounds = self._get_bounds_limits_absolute(bounds)
# calculate the "change" for +/- (10% of this axis' model dimension)
if bounds is None:
return
if axis == "x":
change_value = (self.model.maxx - self.model.minx) * 0.1
elif axis == "y":
change_value = (self.model.maxy - self.model.miny) * 0.1
elif axis == "z":
change_value = (self.model.maxz - self.model.minz) * 0.1
else:
# not allowed
return
# calculate the new bounds
if change == "0":
abs_bounds["%s_low" % axis] = getattr(self.model, "min%s" % axis)
abs_bounds["%s_high" % axis] = getattr(self.model, "max%s" % axis)
elif change == "+":
abs_bounds["%s_low" % axis] -= change_value
abs_bounds["%s_high" % axis] += change_value
elif change == "-":
abs_bounds["%s_low" % axis] += change_value
abs_bounds["%s_high" % axis] -= change_value
else:
# not allowed
return
# transfer the new bounds values to the old settings
self._change_bounds_by_absolute_values(bounds, abs_bounds)
# update the controls
self._put_bounds_settings_to_gui(bounds)
# update the visualization
self.append_to_queue(self.update_boundary_limits)
def _get_bounds_limits_absolute(self, bounds): def _get_bounds_limits_absolute(self, bounds):
minx, maxx, miny, maxy, minz, maxz = self.model.minx, self.model.maxx, \ minx, maxx, miny, maxy, minz, maxz = self.model.minx, self.model.maxx, \
self.model.miny, self.model.maxy, self.model.minz, \ self.model.miny, self.model.maxy, self.model.minz, \
...@@ -609,27 +654,33 @@ class ProjectGui: ...@@ -609,27 +654,33 @@ class ProjectGui:
if new_type == bounds["type"]: if new_type == bounds["type"]:
# no change # no change
return return
# calculate the absolute bounds of the previous configuration
abs_bounds = self._get_bounds_limits_absolute(bounds)
bounds["type"] = new_type
self._change_bounds_by_absolute_values(bounds, abs_bounds)
self._put_bounds_settings_to_gui(bounds)
self.append_to_queue(self.update_boundary_limits)
def _change_bounds_by_absolute_values(self, bounds, abs_bounds):
minx, maxx, miny, maxy, minz, maxz = self.model.minx, self.model.maxx, \ minx, maxx, miny, maxy, minz, maxz = self.model.minx, self.model.maxx, \
self.model.miny, self.model.maxy, self.model.minz, \ self.model.miny, self.model.maxy, self.model.minz, \
self.model.maxz self.model.maxz
# calculate the absolute bounds of the previous configuration
abs_bounds = self._get_bounds_limits_absolute(bounds)
# calculate the new settings # calculate the new settings
if new_type == "relative_margin": if bounds["type"] == "relative_margin":
bounds["x_low"] = (minx - abs_bounds["x_low"]) / (maxx - minx) * 100.0 bounds["x_low"] = (minx - abs_bounds["x_low"]) / (maxx - minx) * 100.0
bounds["x_high"] = (abs_bounds["x_high"] - maxx) / (maxx - minx) * 100.0 bounds["x_high"] = (abs_bounds["x_high"] - maxx) / (maxx - minx) * 100.0
bounds["y_low"] = (miny - abs_bounds["y_low"]) / (maxy - miny) * 100.0 bounds["y_low"] = (miny - abs_bounds["y_low"]) / (maxy - miny) * 100.0
bounds["y_high"] = (abs_bounds["y_high"] - maxy) / (maxy - miny) * 100.0 bounds["y_high"] = (abs_bounds["y_high"] - maxy) / (maxy - miny) * 100.0
bounds["z_low"] = (minz - abs_bounds["z_low"]) / (maxz - minz) * 100.0 bounds["z_low"] = (minz - abs_bounds["z_low"]) / (maxz - minz) * 100.0
bounds["z_high"] = (abs_bounds["z_high"] - maxz) / (maxz - minz) * 100.0 bounds["z_high"] = (abs_bounds["z_high"] - maxz) / (maxz - minz) * 100.0
elif new_type == "fixed_margin": elif bounds["type"] == "fixed_margin":
bounds["x_low"] = minx - abs_bounds["x_low"] bounds["x_low"] = minx - abs_bounds["x_low"]
bounds["x_high"] = abs_bounds["x_high"] - maxx bounds["x_high"] = abs_bounds["x_high"] - maxx
bounds["y_low"] = miny - abs_bounds["y_low"] bounds["y_low"] = miny - abs_bounds["y_low"]
bounds["y_high"] = abs_bounds["y_high"] - maxy bounds["y_high"] = abs_bounds["y_high"] - maxy
bounds["z_low"] = minz - abs_bounds["z_low"] bounds["z_low"] = minz - abs_bounds["z_low"]
bounds["z_high"] = abs_bounds["z_high"] - maxz bounds["z_high"] = abs_bounds["z_high"] - maxz
elif new_type == "custom": elif bounds["type"] == "custom":
bounds["x_low"] = abs_bounds["x_low"] bounds["x_low"] = abs_bounds["x_low"]
bounds["x_high"] = abs_bounds["x_high"] bounds["x_high"] = abs_bounds["x_high"]
bounds["y_low"] = abs_bounds["y_low"] bounds["y_low"] = abs_bounds["y_low"]
...@@ -639,9 +690,6 @@ class ProjectGui: ...@@ -639,9 +690,6 @@ class ProjectGui:
else: else:
# this should not happen # this should not happen
return return
bounds["type"] = new_type
self._put_bounds_settings_to_gui(bounds)
self.append_to_queue(self.update_boundary_limits)
@gui_activity_guard @gui_activity_guard
def update_boundary_limits(self, widget=None): def update_boundary_limits(self, widget=None):
......
...@@ -2530,7 +2530,7 @@ This operation is not available for engraving.</property> ...@@ -2530,7 +2530,7 @@ This operation is not available for engraving.</property>
<object class="GtkTable" id="table2"> <object class="GtkTable" id="table2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="n_rows">4</property> <property name="n_rows">4</property>
<property name="n_columns">5</property> <property name="n_columns">6</property>
<property name="column_spacing">3</property> <property name="column_spacing">3</property>
<property name="row_spacing">3</property> <property name="row_spacing">3</property>
<child> <child>
...@@ -2538,7 +2538,7 @@ This operation is not available for engraving.</property> ...@@ -2538,7 +2538,7 @@ This operation is not available for engraving.</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="invisible_char">&#x25CF;</property> <property name="invisible_char">&#x25CF;</property>
<property name="width_chars">5</property> <property name="width_chars">6</property>
<property name="adjustment">min-x</property> <property name="adjustment">min-x</property>
<property name="digits">2</property> <property name="digits">2</property>
<property name="numeric">True</property> <property name="numeric">True</property>
...@@ -2557,7 +2557,7 @@ This operation is not available for engraving.</property> ...@@ -2557,7 +2557,7 @@ This operation is not available for engraving.</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="invisible_char">&#x25CF;</property> <property name="invisible_char">&#x25CF;</property>
<property name="width_chars">5</property> <property name="width_chars">6</property>
<property name="adjustment">max-y</property> <property name="adjustment">max-y</property>
<property name="digits">2</property> <property name="digits">2</property>
<property name="numeric">True</property> <property name="numeric">True</property>
...@@ -2576,7 +2576,7 @@ This operation is not available for engraving.</property> ...@@ -2576,7 +2576,7 @@ This operation is not available for engraving.</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="invisible_char">&#x25CF;</property> <property name="invisible_char">&#x25CF;</property>
<property name="width_chars">5</property> <property name="width_chars">6</property>
<property name="adjustment">min-z</property> <property name="adjustment">min-z</property>
<property name="digits">2</property> <property name="digits">2</property>
<property name="numeric">True</property> <property name="numeric">True</property>
...@@ -2595,7 +2595,7 @@ This operation is not available for engraving.</property> ...@@ -2595,7 +2595,7 @@ This operation is not available for engraving.</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="invisible_char">&#x25CF;</property> <property name="invisible_char">&#x25CF;</property>
<property name="width_chars">5</property> <property name="width_chars">6</property>
<property name="adjustment">max-z</property> <property name="adjustment">max-z</property>
<property name="digits">2</property> <property name="digits">2</property>
<property name="numeric">True</property> <property name="numeric">True</property>
...@@ -2614,7 +2614,7 @@ This operation is not available for engraving.</property> ...@@ -2614,7 +2614,7 @@ This operation is not available for engraving.</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="invisible_char">&#x25CF;</property> <property name="invisible_char">&#x25CF;</property>
<property name="width_chars">5</property> <property name="width_chars">6</property>
<property name="adjustment">min-y</property> <property name="adjustment">min-y</property>
<property name="digits">2</property> <property name="digits">2</property>
<property name="numeric">True</property> <property name="numeric">True</property>
...@@ -2633,7 +2633,7 @@ This operation is not available for engraving.</property> ...@@ -2633,7 +2633,7 @@ This operation is not available for engraving.</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="invisible_char">&#x25CF;</property> <property name="invisible_char">&#x25CF;</property>
<property name="width_chars">5</property> <property name="width_chars">6</property>
<property name="adjustment">max-x</property> <property name="adjustment">max-x</property>
<property name="digits">2</property> <property name="digits">2</property>
<property name="numeric">True</property> <property name="numeric">True</property>
...@@ -2739,7 +2739,7 @@ This operation is not available for engraving.</property> ...@@ -2739,7 +2739,7 @@ This operation is not available for engraving.</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="BoundsMarginIncreaseX1"> <object class="GtkButton" id="BoundsMarginIncreaseY">
<property name="label" translatable="yes">+</property> <property name="label" translatable="yes">+</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
...@@ -2755,7 +2755,7 @@ This operation is not available for engraving.</property> ...@@ -2755,7 +2755,7 @@ This operation is not available for engraving.</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="BoundsMarginIncreaseX2"> <object class="GtkButton" id="BoundsMarginIncreaseZ">
<property name="label" translatable="yes">+</property> <property name="label" translatable="yes">+</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
...@@ -2772,7 +2772,7 @@ This operation is not available for engraving.</property> ...@@ -2772,7 +2772,7 @@ This operation is not available for engraving.</property>
</child> </child>
<child> <child>
<object class="GtkAlignment" id="alignment35"> <object class="GtkAlignment" id="alignment35">
<property name="width_request">40</property> <property name="width_request">30</property>
<property name="visible">True</property> <property name="visible">True</property>
<child> <child>
<placeholder/> <placeholder/>
...@@ -2787,15 +2787,15 @@ This operation is not available for engraving.</property> ...@@ -2787,15 +2787,15 @@ This operation is not available for engraving.</property>
</child> </child>
<child> <child>
<object class="GtkAlignment" id="alignment36"> <object class="GtkAlignment" id="alignment36">
<property name="width_request">40</property> <property name="width_request">30</property>
<property name="visible">True</property> <property name="visible">True</property>
<child> <child>
<placeholder/> <placeholder/>
</child> </child>
</object> </object>
<packing> <packing>
<property name="left_attach">4</property> <property name="left_attach">5</property>
<property name="right_attach">5</property> <property name="right_attach">6</property>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property>
</packing> </packing>
...@@ -2807,6 +2807,54 @@ This operation is not available for engraving.</property> ...@@ -2807,6 +2807,54 @@ This operation is not available for engraving.</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">True</property> <property name="receives_default">True</property>
</object> </object>
<packing>
<property name="left_attach">5</property>
<property name="right_attach">6</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="GtkButton" id="BoundsMarginDecreaseY">
<property name="label" translatable="yes">-</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="left_attach">5</property>
<property name="right_attach">6</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="GtkButton" id="BoundsMarginDecreaseZ">
<property name="label" translatable="yes">-</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="left_attach">5</property>
<property name="right_attach">6</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="GtkButton" id="BoundsMarginResetX">
<property name="label" translatable="yes">0</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing> <packing>
<property name="left_attach">4</property> <property name="left_attach">4</property>
<property name="right_attach">5</property> <property name="right_attach">5</property>
...@@ -2817,8 +2865,8 @@ This operation is not available for engraving.</property> ...@@ -2817,8 +2865,8 @@ This operation is not available for engraving.</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="BoundsMarginDecreaseX1"> <object class="GtkButton" id="BoundsMarginResetY">
<property name="label" translatable="yes">-</property> <property name="label" translatable="yes">0</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">True</property> <property name="receives_default">True</property>
...@@ -2833,8 +2881,8 @@ This operation is not available for engraving.</property> ...@@ -2833,8 +2881,8 @@ This operation is not available for engraving.</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButton" id="BoundsMarginDecreaseX2"> <object class="GtkButton" id="BoundsMarginResetZ">
<property name="label" translatable="yes">-</property> <property name="label" translatable="yes">0</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">True</property> <property name="receives_default">True</property>
...@@ -2848,6 +2896,21 @@ This operation is not available for engraving.</property> ...@@ -2848,6 +2896,21 @@ This operation is not available for engraving.</property>
<property name="y_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkAlignment" id="alignment16">
<property name="width_request">30</property>
<property name="visible">True</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="left_attach">4</property>
<property name="right_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment