Commit fdb7758b authored by sumpfralle's avatar sumpfralle

added a button for reversing the order of a 2D contour model


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@623 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 0385eb03
Version 0.3.1 - UNRELEASED Version 0.3.1 - UNRELEASED
* added automatic support grid positioning for contour models * added automatic support grid positioning for contour models
* allow to reverse the direction of a 2D contour model
Version 0.3.0 - 2010-08-16 Version 0.3.0 - 2010-08-16
* added support for importing contour paths from SVG files (requires Inkscape and pstoedit) * added support for importing contour paths from SVG files (requires Inkscape and pstoedit)
......
...@@ -877,6 +877,62 @@ ...@@ -877,6 +877,62 @@
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkVSeparator" id="vseparator12">
<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="GtkFrame" id="MiscellaneousModelFrame">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment42">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<object class="GtkVBox" id="vbox29">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">3</property>
<child>
<object class="GtkButton" id="ToggleModelDirectionButton">
<property name="label" translatable="yes">Toggle direction</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Toggle the direction of a 2D contour model.
This can be useful if the imported model is technically broken (sometimes this happens with Inkscape).</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">2</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="MiscellaneousModelFrameLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Miscellaneous&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="position">4</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -1449,7 +1505,7 @@ ...@@ -1449,7 +1505,7 @@
<child> <child>
<object class="GtkTable" id="table12"> <object class="GtkTable" id="table12">
<property name="visible">True</property> <property name="visible">True</property>
<property name="n_rows">2</property> <property name="n_rows">3</property>
<property name="n_columns">3</property> <property name="n_columns">3</property>
<property name="column_spacing">3</property> <property name="column_spacing">3</property>
<property name="row_spacing">2</property> <property name="row_spacing">2</property>
...@@ -1540,6 +1596,49 @@ ...@@ -1540,6 +1596,49 @@
<property name="y_options">GTK_FILL</property> <property name="y_options">GTK_FILL</property>
</packing> </packing>
</child> </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> </object>
</child> </child>
<child type="label"> <child type="label">
...@@ -6222,4 +6321,9 @@ Any selected group of dimensions will be scaled accordingly.</property> ...@@ -6222,4 +6321,9 @@ Any selected group of dimensions will be scaled accordingly.</property>
<property name="upper">20</property> <property name="upper">20</property>
<property name="step_increment">1</property> <property name="step_increment">1</property>
</object> </object>
<object class="GtkAdjustment" id="SupportGridLength">
<property name="lower">0.01</property>
<property name="upper">100</property>
<property name="step_increment">1</property>
</object>
</interface> </interface>
...@@ -245,9 +245,11 @@ class ContourModel(BaseModel): ...@@ -245,9 +245,11 @@ class ContourModel(BaseModel):
def get_polygons(self): def get_polygons(self):
return self._line_groups return self._line_groups
def reverse_directions(self): def reverse_directions(self, callback=None):
for polygon in self._line_groups: for polygon in self._line_groups:
polygon.reverse_direction() polygon.reverse_direction()
if callback and callback():
return None
self.reset_cache() self.reset_cache()
def get_cropped_model(self, minx, maxx, miny, maxy, minz, maxz): def get_cropped_model(self, minx, maxx, miny, maxy, minz, maxz):
......
...@@ -325,6 +325,8 @@ class ProjectGui: ...@@ -325,6 +325,8 @@ class ProjectGui:
lambda widget, data: scale_dimension_button.grab_default()) lambda widget, data: scale_dimension_button.grab_default())
scale_dimension_control.connect("focus-out-event", scale_dimension_control.connect("focus-out-event",
lambda widget, data: self.window.set_default(None)) lambda widget, data: self.window.set_default(None))
self.gui.get_object("ToggleModelDirectionButton").connect("clicked",
self.reverse_model_direction)
# support grid # support grid
self.gui.get_object("SupportGridTypesControl").connect("changed", self.gui.get_object("SupportGridTypesControl").connect("changed",
self.update_support_grid_controls) self.update_support_grid_controls)
...@@ -347,13 +349,17 @@ class ProjectGui: ...@@ -347,13 +349,17 @@ class ProjectGui:
self.settings.add_item("support_grid_distance_y", self.settings.add_item("support_grid_distance_y",
get_support_grid_distance_y, grid_distance_y.set_value) get_support_grid_distance_y, grid_distance_y.set_value)
grid_thickness = self.gui.get_object("SupportGridThickness") grid_thickness = self.gui.get_object("SupportGridThickness")
grid_thickness.connect("value-changed", self.update_support_grid_controls) grid_thickness.connect("value-changed", self.update_support_grid_model)
self.settings.add_item("support_grid_thickness", self.settings.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_grid_controls) grid_height.connect("value-changed", self.update_support_grid_model)
self.settings.add_item("support_grid_height", self.settings.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_grid_model)
self.settings.add_item("support_grid_length",
grid_length.get_value, grid_length.set_value)
grid_offset_x = self.gui.get_object("SupportGridOffsetX") grid_offset_x = self.gui.get_object("SupportGridOffsetX")
grid_offset_x.connect("value-changed", grid_offset_x.connect("value-changed",
self.update_support_grid_model) self.update_support_grid_model)
...@@ -423,6 +429,7 @@ class ProjectGui: ...@@ -423,6 +429,7 @@ class ProjectGui:
self.settings.set("support_grid_height", 0.5) self.settings.set("support_grid_height", 0.5)
self.settings.set("support_grid_average_distance", 30) self.settings.set("support_grid_average_distance", 30)
self.settings.set("support_grid_minimum_bridges", 2) self.settings.set("support_grid_minimum_bridges", 2)
self.settings.set("support_grid_length", 5)
self.grid_adjustment_axis_x_last = True self.grid_adjustment_axis_x_last = True
# visual and general settings # visual and general settings
for name, objname in (("show_model", "ShowModelCheckBox"), for name, objname in (("show_model", "ShowModelCheckBox"),
...@@ -797,13 +804,15 @@ class ProjectGui: ...@@ -797,13 +804,15 @@ class ProjectGui:
if (s.get("support_grid_thickness") > 0) \ if (s.get("support_grid_thickness") > 0) \
and (s.get("support_grid_height") > 0) \ and (s.get("support_grid_height") > 0) \
and (s.get("support_grid_average_distance") > 0) \ and (s.get("support_grid_average_distance") > 0) \
and (s.get("support_grid_minimum_bridges") > 0): and (s.get("support_grid_minimum_bridges") > 0) \
and (s.get("support_grid_length") > 0):
support_grid = pycam.Toolpath.SupportGrid.get_distributed_support_bridges( support_grid = pycam.Toolpath.SupportGrid.get_distributed_support_bridges(
s.get("model"), s.get("minz"), s.get("model"), s.get("minz"),
s.get("support_grid_average_distance"), s.get("support_grid_average_distance"),
s.get("support_grid_minimum_bridges"), s.get("support_grid_minimum_bridges"),
s.get("support_grid_thickness"), s.get("support_grid_thickness"),
s.get("support_grid_height")) s.get("support_grid_height"),
s.get("support_grid_length"))
elif grid_type == GRID_TYPES["none"]: elif grid_type == GRID_TYPES["none"]:
pass pass
s.set("support_grid", support_grid) s.set("support_grid", support_grid)
...@@ -1831,7 +1840,19 @@ class ProjectGui: ...@@ -1831,7 +1840,19 @@ class ProjectGui:
@progress_activity_guard @progress_activity_guard
@gui_activity_guard @gui_activity_guard
def scale_model_axis_fit(self, widget): def reverse_model_direction(self, widget=None):
if (self.model is None) \
or not hasattr(self.model, "reverse_directions"):
return
self.update_progress_bar(text="Reversing directions of contour model")
progress_callback = pycam.Utils.ProgressCounter(
len(self.model.get_polygons()),
self.update_progress_bar).increment
self.model.reverse_directions(callback=progress_callback)
@progress_activity_guard
@gui_activity_guard
def scale_model_axis_fit(self, widget=None):
proportionally = self.gui.get_object("ScaleDimensionsProportionally").get_active() proportionally = self.gui.get_object("ScaleDimensionsProportionally").get_active()
value = self.gui.get_object("ScaleDimensionValue").get_value() value = self.gui.get_object("ScaleDimensionValue").get_value()
index = self.gui.get_object("ScaleDimensionAxis").get_active() index = self.gui.get_object("ScaleDimensionAxis").get_active()
...@@ -2587,7 +2608,8 @@ class ProjectGui: ...@@ -2587,7 +2608,8 @@ class ProjectGui:
self.settings.get("support_grid_average_distance"), self.settings.get("support_grid_average_distance"),
self.settings.get("support_grid_minimum_bridges"), self.settings.get("support_grid_minimum_bridges"),
self.settings.get("support_grid_thickness"), self.settings.get("support_grid_thickness"),
self.settings.get("support_grid_height")) self.settings.get("support_grid_height"),
self.settings.get("support_grid_length"))
elif grid_type == GRID_TYPES["none"]: elif grid_type == GRID_TYPES["none"]:
pass pass
else: else:
......
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