Commit a4901170 authored by sumpfralle's avatar sumpfralle

handle "automatically distributed support bridges" gracefully for non-2D models

enable the "toggle model direction" button only for 2D models


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@654 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent d2eff2c0
......@@ -342,8 +342,13 @@ class ProjectGui:
self.gui.get_object("ToggleModelDirectionButton").connect("clicked",
self.reverse_model_direction)
# support grid
self.gui.get_object("SupportGridTypesControl").connect("changed",
support_grid_type_control = self.gui.get_object(
"SupportGridTypesControl")
support_grid_type_control.connect("changed",
self.update_support_grid_controls)
self.settings.add_item("support_grid_type",
support_grid_type_control.get_active,
support_grid_type_control.set_active)
grid_distance_x = self.gui.get_object("SupportGridDistanceX")
grid_distance_x.connect("value-changed",
self.update_support_grid_controls)
......@@ -710,6 +715,13 @@ class ProjectGui:
self.update_support_grid_controls()
self.update_scale_controls()
self.update_gcode_controls()
self.update_model_type_related_controls()
def update_model_type_related_controls(self):
is_reversible = (not self.model is None) \
and hasattr(self.model, "reverse_directions")
self.gui.get_object("ToggleModelDirectionButton").set_sensitive(
is_reversible)
def update_gcode_controls(self, widget=None):
path_mode = self.settings.get("gcode_path_mode")
......@@ -789,7 +801,17 @@ class ProjectGui:
"GridManualShiftExpander": ("grid", ),
"GridAverageDistanceExpander": ("automatic", ),
}
grid_type = self.gui.get_object("SupportGridTypesControl").get_active()
if (self.settings.get("support_grid_type") == GRID_TYPES["automatic"]) \
and (not hasattr(self.model, "get_polygons")):
message = "This feature only works for 2D contour models for now " \
+ "- sorry!"
window = gtk.MessageDialog(self.window, type=gtk.MESSAGE_WARNING,
buttons=gtk.BUTTONS_OK, message_format=message)
window.set_title("Under construction ...")
window.run()
window.destroy()
self.settings.set("support_grid_type", GRID_TYPES["none"])
grid_type = self.settings.get("support_grid_type")
if grid_type == GRID_TYPES["grid"]:
grid_square = self.gui.get_object("SupportGridDistanceSquare")
distance_y = self.gui.get_object("SupportGridDistanceYControl")
......@@ -804,6 +826,9 @@ class ProjectGui:
pass
elif grid_type == GRID_TYPES["none"]:
pass
elif grid_type < 0:
# not initialized
pass
else:
raise ValueError("Invalid grid type: %d" % grid_type)
# show and hide all controls according to the current type
......@@ -817,7 +842,7 @@ class ProjectGui:
self.update_view()
def update_support_grid_model(self, widget=None):
grid_type = self.gui.get_object("SupportGridTypesControl").get_active()
grid_type = self.settings.get("support_grid_type")
s = self.settings
support_grid = None
if grid_type == GRID_TYPES["grid"]:
......@@ -2034,6 +2059,8 @@ class ProjectGui:
self.model = model
# do some initialization
self.append_to_queue(self.update_scale_controls)
self.append_to_queue(self.update_model_type_related_controls)
self.append_to_queue(self.update_support_grid_controls)
self.append_to_queue(self.toggle_3d_view, value=True)
self.append_to_queue(self.update_view)
......@@ -2639,7 +2666,7 @@ class ProjectGui:
tool_settings["speed"], tool_settings["feedrate"])
# get the support grid options
grid_type = self.gui.get_object("SupportGridTypesControl").get_active()
grid_type = self.settings.get("support_grid_type")
if grid_type == GRID_TYPES["grid"]:
toolpath_settings.set_support_grid(
self.settings.get("support_grid_distance_x"),
......
......@@ -157,10 +157,16 @@ def get_support_distributed(model, z_plane, average_distance,
return True
return False
result = Model()
if hasattr(model, "get_polygons"):
polygons = model.get_polygons()
else:
# TODO: Solid models are not supported, yet - we need to get the
# maximum outline of the model.
return result
bridge_positions = []
# minimum required distance between two bridge start points
avoid_distance = 1.5 * (abs(length) + thickness)
for polygon in model.get_polygons():
for polygon in polygons:
# no grid for _small_ inner polygons
# TODO: calculate a reasonable factor (see below)
if not polygon.is_outer() \
......
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