Commit 61c43743 authored by sumpfralle's avatar sumpfralle

r573@erker: lars | 2010-02-04 02:58:37 +0100

 implemented model scaling


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@96 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 22a572a5
......@@ -124,6 +124,7 @@ class ProjectGui:
self.settings = pycam.Gui.Settings.Settings()
self.settings.add_item("model", lambda: getattr(self, "model"))
self.settings.add_item("toolpath", lambda: getattr(self, "toolpath"))
self.settings.add_item("scale", lambda: 0.9/getattr(getattr(self, "model"), "maxsize")())
# create the unit field (the default content can't be defined via glade)
scale_box = self.gui.get_object("scale_box")
unit_field = gtk.combo_box_new_text()
......@@ -150,6 +151,10 @@ class ProjectGui:
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)
# scale model
self.gui.get_object("Scale up").connect("clicked", self.scale_model, True)
self.gui.get_object("Scale down").connect("clicked", self.scale_model, False)
self.gui.get_object("Scale factor").set_value(2)
def transform_model(self, widget):
if widget.get_name() == "Rotate":
......@@ -179,6 +184,15 @@ class ProjectGui:
GuiCommon.shift_model(self.model, shift_x, shift_y, shift_z)
self.view3d.paint()
def scale_model(self, widget, scale_up=True):
value = self.gui.get_object("Scale factor").get_value()
if (value == 0) or (value == 1):
return
if not scale_up:
value = 1/value
GuiCommon.scale_model(self.model, value)
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"]:
......@@ -216,7 +230,6 @@ class ProjectGui:
if self.model and self.view3d.enabled:
self.reset_bounds(None)
# why "2.0"?
self.settings.set("scale", 0.9/self.model.maxsize())
self.view3d.reset_view()
def mainloop(self):
......
......@@ -155,3 +155,7 @@ 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)
def scale_model(model, scale):
matrix = ((scale, 0, 0, 0), (0, scale, 0, 0), (0, 0, scale, 0))
model.transform(matrix)
......@@ -350,7 +350,7 @@
</packing>
</child>
<child>
<object class="GtkButton" id="scale down">
<object class="GtkButton" id="Scale down">
<property name="label" translatable="yes">Shrink</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
......@@ -362,7 +362,7 @@
</packing>
</child>
<child>
<object class="GtkButton" id="scale up">
<object class="GtkButton" id="Scale up">
<property name="label" translatable="yes">Enlage</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
......@@ -880,8 +880,7 @@
</child>
</object>
<object class="GtkAdjustment" id="scale factor">
<property name="value">10</property>
<property name="lower">0.001</property>
<property name="value">1</property>
<property name="upper">1000</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
......
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