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:
model.append(s)
return model
def _reset_cache(self):
def reset_cache(self):
self.minx = None
self.miny = None
self.minz = None
......@@ -101,5 +101,6 @@ class Model:
point.x = x
point.y = y
point.z = z
self._reset_cache()
tr.reset_cache()
self.reset_cache()
......@@ -251,3 +251,4 @@ class Triangle:
self._radiussq = None
self._normal = None
self._plane = None
......@@ -148,6 +148,8 @@ class ProjectGui:
self.gui.get_object("Rotate").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("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):
if widget.get_name() == "Rotate":
......@@ -165,10 +167,23 @@ class ProjectGui:
GuiCommon.transform_model(self.model, value)
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):
# be careful: this depends on equal names of "settings" keys and "model" variables
for limit in ["minx", "miny", "minz", "maxx", "maxy", "maxz"]:
self.settings.set(limit, getattr(self.model, limit))
self.view3d.paint()
def reset_bounds(self, widget, data=None):
xwidth = self.model.maxx - self.model.minx
......@@ -180,6 +195,7 @@ class ProjectGui:
self.settings.set("maxx", self.model.maxx + 0.1 * xwidth)
self.settings.set("maxy", self.model.maxy + 0.1 * ywidth)
self.settings.set("maxz", self.model.maxz + 0.1 * zwidth)
self.view3d.paint()
def destroy(self, widget, data=None):
gtk.main_quit()
......
......@@ -150,4 +150,8 @@ def right_view(scale):
def transform_model(model, direction="normal"):
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