Commit 22a572a5 authored by sumpfralle's avatar sumpfralle

r572@erker: lars | 2010-02-04 02:36:41 +0100

 implemented shifting of model
 fixed reset of triangle cache


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@95 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 64c908dc
...@@ -78,7 +78,7 @@ class Model: ...@@ -78,7 +78,7 @@ class Model:
model.append(s) model.append(s)
return model return model
def _reset_cache(self): def reset_cache(self):
self.minx = None self.minx = None
self.miny = None self.miny = None
self.minz = None self.minz = None
...@@ -101,5 +101,6 @@ class Model: ...@@ -101,5 +101,6 @@ class Model:
point.x = x point.x = x
point.y = y point.y = y
point.z = z point.z = z
self._reset_cache() tr.reset_cache()
self.reset_cache()
...@@ -251,3 +251,4 @@ class Triangle: ...@@ -251,3 +251,4 @@ class Triangle:
self._radiussq = None self._radiussq = None
self._normal = None self._normal = None
self._plane = None self._plane = None
...@@ -148,6 +148,8 @@ class ProjectGui: ...@@ -148,6 +148,8 @@ class ProjectGui:
self.gui.get_object("Rotate").connect("clicked", self.transform_model) self.gui.get_object("Rotate").connect("clicked", self.transform_model)
self.gui.get_object("Flip").connect("clicked", self.transform_model) self.gui.get_object("Flip").connect("clicked", self.transform_model)
self.gui.get_object("Swap").connect("clicked", self.transform_model) self.gui.get_object("Swap").connect("clicked", self.transform_model)
self.gui.get_object("Shift Model").connect("clicked", self.shift_model, True)
self.gui.get_object("Shift To Origin").connect("clicked", self.shift_model, False)
def transform_model(self, widget): def transform_model(self, widget):
if widget.get_name() == "Rotate": if widget.get_name() == "Rotate":
...@@ -165,10 +167,23 @@ class ProjectGui: ...@@ -165,10 +167,23 @@ class ProjectGui:
GuiCommon.transform_model(self.model, value) GuiCommon.transform_model(self.model, value)
self.view3d.paint() self.view3d.paint()
def shift_model(self, widget, use_form_values=True):
if use_form_values:
shift_x = self.gui.get_object("shift_x").get_value()
shift_y = self.gui.get_object("shift_y").get_value()
shift_z = self.gui.get_object("shift_z").get_value()
else:
shift_x = -self.model.minx
shift_y = -self.model.miny
shift_z = -self.model.minz
GuiCommon.shift_model(self.model, shift_x, shift_y, shift_z)
self.view3d.paint()
def minimize_bounds(self, widget, data=None): def minimize_bounds(self, widget, data=None):
# be careful: this depends on equal names of "settings" keys and "model" variables # be careful: this depends on equal names of "settings" keys and "model" variables
for limit in ["minx", "miny", "minz", "maxx", "maxy", "maxz"]: for limit in ["minx", "miny", "minz", "maxx", "maxy", "maxz"]:
self.settings.set(limit, getattr(self.model, limit)) self.settings.set(limit, getattr(self.model, limit))
self.view3d.paint()
def reset_bounds(self, widget, data=None): def reset_bounds(self, widget, data=None):
xwidth = self.model.maxx - self.model.minx xwidth = self.model.maxx - self.model.minx
...@@ -180,6 +195,7 @@ class ProjectGui: ...@@ -180,6 +195,7 @@ class ProjectGui:
self.settings.set("maxx", self.model.maxx + 0.1 * xwidth) self.settings.set("maxx", self.model.maxx + 0.1 * xwidth)
self.settings.set("maxy", self.model.maxy + 0.1 * ywidth) self.settings.set("maxy", self.model.maxy + 0.1 * ywidth)
self.settings.set("maxz", self.model.maxz + 0.1 * zwidth) self.settings.set("maxz", self.model.maxz + 0.1 * zwidth)
self.view3d.paint()
def destroy(self, widget, data=None): def destroy(self, widget, data=None):
gtk.main_quit() gtk.main_quit()
......
...@@ -150,4 +150,8 @@ def right_view(scale): ...@@ -150,4 +150,8 @@ def right_view(scale):
def transform_model(model, direction="normal"): def transform_model(model, direction="normal"):
model.transform(MODEL_TRANSFORMATIONS[direction]) model.transform(MODEL_TRANSFORMATIONS[direction])
def shift_model(model, shift_x, shift_y, shift_z):
matrix = ((1, 0, 0, shift_x), (0, 1, 0, shift_y), (0, 0, 1, shift_z))
model.transform(matrix)
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