Commit dbe030cb authored by sumpfralle's avatar sumpfralle

fixed some issues of the support model plugins (not finished)


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@1165 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 28747001
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">5</property> <property name="spacing">5</property>
<child> <child>
<object class="GtkHBox" id="hbox26"> <object class="GtkHButtonBox" id="hbuttonbox1">
<property name="visible">True</property> <property name="visible">True</property>
<child> <child>
<object class="GtkComboBox" id="SupportGridTypesControl"> <object class="GtkComboBox" id="SupportGridTypesControl">
...@@ -39,12 +39,21 @@ ...@@ -39,12 +39,21 @@
</packing> </packing>
</child> </child>
<child> <child>
<placeholder/> <object class="GtkButton" id="CreateSupportModel">
<property name="label" translatable="yes">Create support model</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</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">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
......
...@@ -105,7 +105,7 @@ def draw_complete_model_view(settings): ...@@ -105,7 +105,7 @@ def draw_complete_model_view(settings):
GL.glFinish() GL.glFinish()
obj.to_OpenGL() obj.to_OpenGL()
# draw the support grid # draw the support grid
if settings.get("show_support_grid") and settings.get("current_support_model"): if False and settings.get("show_support_grid") and settings.get("current_support_model"):
GL.glColor4f(*settings.get("color_support_grid")) GL.glColor4f(*settings.get("color_support_grid"))
# we need to wait until the color change is active # we need to wait until the color change is active
GL.glFinish() GL.glFinish()
......
...@@ -86,6 +86,6 @@ class EngraveCutter(object): ...@@ -86,6 +86,6 @@ class EngraveCutter(object):
draw_callback(text="Engrave: processing layer" + \ draw_callback(text="Engrave: processing layer" + \
"%d/%d" % (current_layer + 1, num_of_layers)) "%d/%d" % (current_layer + 1, num_of_layers))
drop_generator.GenerateToolPath(cutter, [model], drop_layers, drop_generator.GenerateToolPath(cutter, [model], drop_layers,
minz=None, maxz=None) minz=minz, maxz=maxz)
return self.pa_push.paths + self.pa_drop.paths return self.pa_push.paths + self.pa_drop.paths
...@@ -99,6 +99,8 @@ class ModelSupport(pycam.Plugins.PluginBase): ...@@ -99,6 +99,8 @@ class ModelSupport(pycam.Plugins.PluginBase):
self.core.set("support_grid_height", 0.5) self.core.set("support_grid_height", 0.5)
self.core.set("support_grid_type", "none") self.core.set("support_grid_type", "none")
# prepare GUI # prepare GUI
self.gui.get_object("CreateSupportModel").connect("clicked",
self._add_support_model)
self._update_widgets() self._update_widgets()
return True return True
...@@ -125,6 +127,11 @@ class ModelSupport(pycam.Plugins.PluginBase): ...@@ -125,6 +127,11 @@ class ModelSupport(pycam.Plugins.PluginBase):
def _support_model_changed(self, widget=None): def _support_model_changed(self, widget=None):
self.core.emit_event("support-model-changed") self.core.emit_event("support-model-changed")
def _add_support_model(self, widget=None):
model = self.core.get("current_support_model")
if model:
self.core.get("models").append(model)
def update_support_model(self, widget=None): def update_support_model(self, widget=None):
grid_type = self.core.get("support_model_type") grid_type = self.core.get("support_model_type")
if grid_type == "none": if grid_type == "none":
......
...@@ -24,6 +24,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>. ...@@ -24,6 +24,7 @@ along with PyCAM. If not, see <http://www.gnu.org/licenses/>.
#import gtk #import gtk
import pycam.Plugins import pycam.Plugins
import pycam.Geometry.Model
class ModelSupportGrid(pycam.Plugins.PluginBase): class ModelSupportGrid(pycam.Plugins.PluginBase):
...@@ -135,6 +136,8 @@ class ModelSupportGrid(pycam.Plugins.PluginBase): ...@@ -135,6 +136,8 @@ class ModelSupportGrid(pycam.Plugins.PluginBase):
grid_type = self.core.get("support_model_type") grid_type = self.core.get("support_model_type")
if grid_type == "grid": if grid_type == "grid":
s = self.core s = self.core
support_grid = None
low, high = self._get_bounds()
if (s.get("support_grid_thickness") > 0) \ if (s.get("support_grid_thickness") > 0) \
and ((s.get("support_grid_distance_x") > 0) \ and ((s.get("support_grid_distance_x") > 0) \
or (s.get("support_grid_distance_y") > 0)) \ or (s.get("support_grid_distance_y") > 0)) \
...@@ -146,8 +149,8 @@ class ModelSupportGrid(pycam.Plugins.PluginBase): ...@@ -146,8 +149,8 @@ class ModelSupportGrid(pycam.Plugins.PluginBase):
> s.get("support_grid_thickness"))) \ > s.get("support_grid_thickness"))) \
and (s.get("support_grid_height") > 0): and (s.get("support_grid_height") > 0):
support_grid = pycam.Toolpath.SupportGrid.get_support_grid( support_grid = pycam.Toolpath.SupportGrid.get_support_grid(
s.get("minx"), s.get("maxx"), s.get("miny"), s.get("maxy"), low[0], high[0], low[1], high[1], low[2],
s.get("minz"), s.get("support_grid_distance_x"), s.get("support_grid_distance_x"),
s.get("support_grid_distance_y"), s.get("support_grid_distance_y"),
s.get("support_grid_thickness"), s.get("support_grid_thickness"),
s.get("support_grid_height"), s.get("support_grid_height"),
...@@ -239,8 +242,9 @@ class ModelSupportGrid(pycam.Plugins.PluginBase): ...@@ -239,8 +242,9 @@ class ModelSupportGrid(pycam.Plugins.PluginBase):
model.clear() model.clear()
s = self.core s = self.core
# get the toolpath without adjustments # get the toolpath without adjustments
low, high = self._get_bounds()
base_x, base_y = pycam.Toolpath.SupportGrid.get_support_grid_locations( base_x, base_y = pycam.Toolpath.SupportGrid.get_support_grid_locations(
s.get("minx"), s.get("maxx"), s.get("miny"), s.get("maxy"), low[0], high[0], low[1], high[1],
s.get("support_grid_distance_x"), s.get("support_grid_distance_x"),
s.get("support_grid_distance_y"), s.get("support_grid_distance_y"),
offset_x=s.get("support_grid_offset_x"), offset_x=s.get("support_grid_offset_x"),
...@@ -270,3 +274,14 @@ class ModelSupportGrid(pycam.Plugins.PluginBase): ...@@ -270,3 +274,14 @@ class ModelSupportGrid(pycam.Plugins.PluginBase):
else: else:
self.grid_adjustment_selector.set_active(-1) self.grid_adjustment_selector.set_active(-1)
def _get_bounds(self):
models = self.core.get("models").get_selected()
low, high = pycam.Geometry.Model.get_combined_bounds(models)
if None in low or None in high:
return [0, 0, 0], [0, 0, 0]
else:
# TODO: the x/y offset should be configurable via a control
for index in range(2):
low[index] -= 5
high[index] += 5
return low, high
...@@ -38,6 +38,10 @@ class OpenGLViewModel(pycam.Plugins.PluginBase): ...@@ -38,6 +38,10 @@ class OpenGLViewModel(pycam.Plugins.PluginBase):
self._gtk = gtk self._gtk = gtk
self._GL = OpenGL.GL self._GL = OpenGL.GL
self.core.register_event("visualize-items", self.draw_model) self.core.register_event("visualize-items", self.draw_model)
self.core.register_event("model-changed",
lambda: self.core.emit_event("visual-item-updated"))
self.core.register_event("model-list-changed",
lambda: self.core.emit_event("visual-item-updated"))
self.core.emit_event("visual-item-updated") self.core.emit_event("visual-item-updated")
self._cache = {} self._cache = {}
return True return True
......
...@@ -271,10 +271,13 @@ def get_lines_grid(models, bounds, layer_distance, line_distance=None, ...@@ -271,10 +271,13 @@ def get_lines_grid(models, bounds, layer_distance, line_distance=None,
low, high = bounds low, high = bounds
# the lower limit is never below the model # the lower limit is never below the model
polygons = _get_sorted_polygons(models, callback=callback) polygons = _get_sorted_polygons(models, callback=callback)
low_limit_lines = min([polygon.minz for polygon in polygons]) if polygons:
low[2] = max(low[2], low_limit_lines) low_limit_lines = min([polygon.minz for polygon in polygons])
low[2] = max(low[2], low_limit_lines)
lines = [] lines = []
for polygon in polygons: for polygon in polygons:
if callback:
callback()
if polygon.is_closed and \ if polygon.is_closed and \
(milling_style == MILLING_STYLE_CONVENTIONAL): (milling_style == MILLING_STYLE_CONVENTIONAL):
polygon = polygon.copy() polygon = polygon.copy()
...@@ -295,10 +298,14 @@ def get_lines_grid(models, bounds, layer_distance, line_distance=None, ...@@ -295,10 +298,14 @@ def get_lines_grid(models, bounds, layer_distance, line_distance=None,
if layers: if layers:
# the upper layers are used for PushCutter operations # the upper layers are used for PushCutter operations
for z in layers[:-1]: for z in layers[:-1]:
if callback:
callback()
yield get_lines_layer(lines, z, last_z=last_z, step_width=None, yield get_lines_layer(lines, z, last_z=last_z, step_width=None,
milling_style=milling_style) milling_style=milling_style)
last_z = z last_z = z
# the last layer is used for a DropCutter operation # the last layer is used for a DropCutter operation
if callback:
callback()
yield get_lines_layer(lines, layers[-1], last_z=last_z, yield get_lines_layer(lines, layers[-1], last_z=last_z,
step_width=step_width, milling_style=milling_style) step_width=step_width, milling_style=milling_style)
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