Added "scale up to max size" button, we really need those icons...

This commit is contained in:
daid 2012-04-17 12:08:19 +02:00
parent 0f5e864714
commit ddaca56c89
2 changed files with 22 additions and 1 deletions

View file

@ -118,7 +118,11 @@ class previewPanel(wx.Panel):
self.rotate.SetRange(0, 360)
self.toolbar2.AddControl(self.rotate)
self.Bind(wx.EVT_SPINCTRL, self.OnRotate, self.rotate)
self.scaleMax = wx.Button(self.toolbar, -1, 'Max size', size=(21*3.5,21))
self.toolbar.AddControl(self.scaleMax)
self.Bind(wx.EVT_BUTTON, self.OnScaleMax, self.scaleMax)
self.toolbar2.Realize()
self.updateToolbar()
@ -168,6 +172,22 @@ class previewPanel(wx.Panel):
profile.putProfileSetting('model_scale', self.scale.GetValue())
self.updateModelTransform()
def OnScaleMax(self, e):
if self.triangleMesh == None:
return
scale = float(self.scale.GetValue())
vMin = self.triangleMesh.getMinimum() / scale
vMax = self.triangleMesh.getMaximum() / scale
scaleX1 = (self.machineSize.x - self.machineCenter.x) / ((vMax.x - vMin.x) / 2)
scaleY1 = (self.machineSize.y - self.machineCenter.y) / ((vMax.y - vMin.y) / 2)
scaleX2 = (self.machineCenter.x) / ((vMax.x - vMin.x) / 2)
scaleY2 = (self.machineCenter.y) / ((vMax.y - vMin.y) / 2)
scaleZ = self.machineSize.z / (vMax.z - vMin.z)
scale = min(scaleX1, scaleY1, scaleX2, scaleY2, scaleZ)
self.scale.SetValue(str(scale))
profile.putProfileSetting('model_scale', self.scale.GetValue())
self.updateModelTransform()
def OnRotate(self, e):
profile.putProfileSetting('model_rotate_base', self.rotate.GetValue())
self.updateModelTransform()

View file

@ -27,6 +27,7 @@ class Vector3():
def __div__(self, v):
return Vector3( self.x / v, self.y / v, self.z / v )
__truediv__ = __div__
def __neg__(self):
return Vector3( - self.x, - self.y, - self.z )