Commit e9ff489d authored by sumpfralle's avatar sumpfralle

fixed simulation mode

fixed unit change for bounds


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@596 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent a6a399cf
...@@ -1457,7 +1457,7 @@ ...@@ -1457,7 +1457,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkVBox" id="dialog-vbox3"> <object class="GtkVBox" id="ToolTab">
<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>
...@@ -1992,7 +1992,7 @@ ...@@ -1992,7 +1992,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkVBox" id="dialog-vbox4"> <object class="GtkVBox" id="ProcessTab">
<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>
...@@ -2703,7 +2703,7 @@ This operation is not available for engraving.</property> ...@@ -2703,7 +2703,7 @@ This operation is not available for engraving.</property>
</packing> </packing>
</child> </child>
<child type="tab"> <child type="tab">
<object class="GtkLabel" id="ProcessesTabLabel"> <object class="GtkLabel" id="ProcessTabLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">Processes</property> <property name="label" translatable="yes">Processes</property>
</object> </object>
...@@ -2713,7 +2713,7 @@ This operation is not available for engraving.</property> ...@@ -2713,7 +2713,7 @@ This operation is not available for engraving.</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkFrame" id="BoundsFrame"> <object class="GtkFrame" id="BoundsTab">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label_xalign">0</property> <property name="label_xalign">0</property>
<property name="shadow_type">none</property> <property name="shadow_type">none</property>
......
...@@ -1549,30 +1549,30 @@ class ProjectGui: ...@@ -1549,30 +1549,30 @@ class ProjectGui:
if self.gui.get_object("UnitChangeBounds").get_active(): if self.gui.get_object("UnitChangeBounds").get_active():
# scale the boundaries and keep their center # scale the boundaries and keep their center
for bounds in self.bounds_list: for bounds in self.bounds_list:
if bounds["type"] == "fixed_margin": low, high = bounds.get_bounds()
bounds["x_low"] *= factor if bounds.get_type() == Bounds.TYPE_FIXED_MARGIN:
bounds["x_high"] *= factor low[0] *= factor
bounds["y_low"] *= factor high[0] *= factor
bounds["y_high"] *= factor low[1] *= factor
bounds["z_low"] *= factor high[1] *= factor
bounds["z_high"] *= factor low[2] *= factor
elif bounds["type"] == "custom": high[2] *= factor
center_x = (bounds["x_high"] + bounds["x_low"]) / 2.0 bounds.set_bounds(low, high)
center_y = (bounds["y_high"] + bounds["y_low"]) / 2.0 elif bounds.get_type() == Bounds.TYPE_CUSTOM:
center_z = (bounds["z_high"] + bounds["z_low"]) / 2.0 center = [0, 0, 0]
bounds["x_low"] = center_x + (bounds["x_low"] - center_x) * factor for i in range(3):
bounds["x_high"] = center_x + (bounds["x_high"] - center_x) * factor center[i] = (high[i] + low[i]) / 2
bounds["y_low"] = center_y + (bounds["y_low"] - center_y) * factor for i in range(3):
bounds["y_high"] = center_y + (bounds["y_high"] - center_y) * factor low[i] = center[i] + (low[i] - center[i]) * factor
bounds["z_low"] = center_z + (bounds["z_low"] - center_z) * factor high[i] = center[i] + (high[i] - center[i]) * factor
bounds["z_high"] = center_z + (bounds["z_high"] - center_z) * factor bounds.set_bounds(low, high)
elif bounds["type"] == "relative_margin": elif bounds.get_type() == Bounds.TYPE_RELATIVE_MARGIN:
# no need to change relative margins # no need to change relative margins
pass pass
if self.gui.get_object("UnitChangeTools").get_active(): if self.gui.get_object("UnitChangeTools").get_active():
# scale all tool dimensions # scale all tool dimensions
for tool in self.tool_list: for tool in self.tool_list:
for key in ("tool_radius", "torus_radius", "feedrate"): for key in ("tool_radius", "torus_radius"):
tool[key] *= factor tool[key] *= factor
self.unit_change_window.hide() self.unit_change_window.hide()
# store the current unit (for the next run of this function) # store the current unit (for the next run of this function)
...@@ -2314,8 +2314,7 @@ class ProjectGui: ...@@ -2314,8 +2314,7 @@ class ProjectGui:
# hide the simulation tab # hide the simulation tab
self.gui.get_object("SimulationTab").hide() self.gui.get_object("SimulationTab").hide()
# enable all other tabs again # enable all other tabs again
for objname in ("ModelTab", "ModelTabLabel", "TasksTab", "TasksTabLabel", "ToolPathTab", "ToolPathTabLabel"): self.toggle_tabs_for_simulation(True)
self.gui.get_object(objname).set_sensitive(True)
self.settings.set("simulate_object", None) self.settings.set("simulate_object", None)
self.settings.set("show_simulation", False) self.settings.set("show_simulation", False)
self.update_view() self.update_view()
...@@ -2338,9 +2337,9 @@ class ProjectGui: ...@@ -2338,9 +2337,9 @@ class ProjectGui:
detail_level = self.gui.get_object("SimulationDetailsValue").get_value() detail_level = self.gui.get_object("SimulationDetailsValue").get_value()
grid_size = 100 * pow(2, detail_level - 1) grid_size = 100 * pow(2, detail_level - 1)
bounding_box = toolpath.get_toolpath_settings().get_bounds() bounding_box = toolpath.get_toolpath_settings().get_bounds()
(minx, miny, minz), (maxx, maxy, maxz) = bounding_box.get_bounds()
# proportion = dimension_x / dimension_y # proportion = dimension_x / dimension_y
proportion = (bounding_box["maxx"] - bounding_box["minx"]) \ proportion = (maxx - minx) / (maxy - miny)
/ (bounding_box["maxy"] - bounding_box["miny"])
x_steps = int(sqrt(grid_size) * proportion) x_steps = int(sqrt(grid_size) * proportion)
y_steps = int(sqrt(grid_size) / proportion) y_steps = int(sqrt(grid_size) / proportion)
simulation_backend = ODEBlocks.ODEBlocks(toolpath.get_tool_settings(), simulation_backend = ODEBlocks.ODEBlocks(toolpath.get_tool_settings(),
...@@ -2373,10 +2372,16 @@ class ProjectGui: ...@@ -2373,10 +2372,16 @@ class ProjectGui:
if not widget is None: if not widget is None:
self.gui.get_object("SimulationTab").set_sensitive(True) self.gui.get_object("SimulationTab").set_sensitive(True)
def toggle_tabs_for_simulation(self, new_state):
for objname in ("ModelTab", "ModelTabLabel", "TasksTab",
"TasksTabLabel", "ToolPathTab", "ToolPathTabLabel", "ToolTab",
"ToolTabLabel", "ProcessTab", "ProcessTabLabel", "BoundsTab",
"BoundsTabLabel"):
self.gui.get_object(objname).set_sensitive(new_state)
def show_toolpath_simulation(self, toolpath): def show_toolpath_simulation(self, toolpath):
# disable the main controls # disable the main controls
for objname in ("ModelTab", "ModelTabLabel", "TasksTab", "TasksTabLabel", "ToolPathTab", "ToolPathTabLabel"): self.toggle_tabs_for_simulation(False)
self.gui.get_object(objname).set_sensitive(False)
# show the simulation controls # show the simulation controls
self.gui.get_object("SimulationTab").show() self.gui.get_object("SimulationTab").show()
# switch to the simulation tab # switch to the simulation tab
......
...@@ -80,8 +80,8 @@ class ToolPath: ...@@ -80,8 +80,8 @@ class ToolPath:
def get_bounding_box(self): def get_bounding_box(self):
box = self.toolpath_settings.get_bounds() box = self.toolpath_settings.get_bounds()
return (box["minx"], box["maxx"], box["miny"], box["maxy"], box["minz"], (minx, miny, minz), (maxx, maxy, maxz) = box.get_bounds()
box["maxz"]) return (minx, maxx, miny, maxy, minz, maxz)
def get_tool_settings(self): def get_tool_settings(self):
return self.toolpath_settings.get_tool_settings() return self.toolpath_settings.get_tool_settings()
......
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