Merge pull request #59 from PyroMani/master
Added Icons for Mirror and Swap
|
@ -8,6 +8,7 @@ import time
|
|||
import os
|
||||
|
||||
from wx import glcanvas
|
||||
from wx.lib import buttons
|
||||
import wx
|
||||
try:
|
||||
import OpenGL
|
||||
|
@ -26,6 +27,61 @@ from util import gcodeInterpreter
|
|||
from util import stl
|
||||
from util import util3d
|
||||
|
||||
class ToggleButton(buttons.GenBitmapToggleButton):
|
||||
def __init__(self, parent, popupParent, profileSetting, bitmapOn, bitmapOff,
|
||||
helpText='', id=-1, size=(20,20)):
|
||||
buttons.GenBitmapToggleButton.__init__(self, parent, id, bitmapOff, size=size)
|
||||
|
||||
self.popupParent = popupParent
|
||||
self.profileSetting = profileSetting
|
||||
self.bitmapOn = bitmapOn
|
||||
self.bitmapOff = bitmapOff
|
||||
self.helpText = helpText
|
||||
|
||||
self.bezelWidth = 1
|
||||
self.useFocusInd = False
|
||||
|
||||
if self.profileSetting != '':
|
||||
self.SetValue(profile.getProfileSetting(self.profileSetting) == 'True')
|
||||
self.Bind(wx.EVT_BUTTON, self.OnButtonProfile)
|
||||
else:
|
||||
self.Bind(wx.EVT_BUTTON, self.OnButton)
|
||||
|
||||
self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter)
|
||||
self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave)
|
||||
|
||||
def SetBitmap(self, bool):
|
||||
if bool:
|
||||
buttons.GenBitmapToggleButton.SetBitmapLabel(self, self.bitmapOn, False)
|
||||
else:
|
||||
buttons.GenBitmapToggleButton.SetBitmapLabel(self, self.bitmapOff, False)
|
||||
|
||||
def SetValue(self, bool):
|
||||
self.SetBitmap(bool)
|
||||
buttons.GenBitmapToggleButton.SetValue(self, bool)
|
||||
|
||||
def OnButton(self, event):
|
||||
self.SetBitmap(buttons.GenBitmapToggleButton.GetValue(self))
|
||||
event.Skip()
|
||||
|
||||
def OnButtonProfile(self, event):
|
||||
if buttons.GenBitmapToggleButton.GetValue(self):
|
||||
self.SetBitmap(True)
|
||||
profile.putProfileSetting(self.profileSetting, 'True')
|
||||
else:
|
||||
self.SetBitmap(False)
|
||||
profile.putProfileSetting(self.profileSetting, 'False')
|
||||
self.popupParent.updateModelTransform()
|
||||
event.Skip()
|
||||
|
||||
def OnMouseEnter(self, event):
|
||||
self.popupParent.OnPopupDisplay(event)
|
||||
event.Skip()
|
||||
|
||||
def OnMouseLeave(self, event):
|
||||
self.popupParent.OnPopupHide(event)
|
||||
event.Skip()
|
||||
|
||||
class previewPanel(wx.Panel):
|
||||
def __init__(self, parent):
|
||||
wx.Panel.__init__(self, parent,-1)
|
||||
|
@ -33,6 +89,15 @@ class previewPanel(wx.Panel):
|
|||
self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DDKSHADOW))
|
||||
self.SetMinSize((440,320))
|
||||
|
||||
# Create popup window
|
||||
self.popup = wx.PopupWindow(self, flags=wx.BORDER_SIMPLE)
|
||||
self.popup.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_INFOBK))
|
||||
self.popup.text = wx.StaticText(self.popup, -1, '')
|
||||
self.popup.sizer = wx.BoxSizer()
|
||||
self.popup.sizer.Add(self.popup.text, flag=wx.EXPAND|wx.ALL, border=1)
|
||||
self.popup.SetSizer(self.popup.sizer)
|
||||
self.popupOwner = None
|
||||
|
||||
self.glCanvas = PreviewGLCanvas(self)
|
||||
self.init = 0
|
||||
self.triangleMesh = None
|
||||
|
@ -63,32 +128,25 @@ class previewPanel(wx.Panel):
|
|||
self.toolbar.AddControl(self.layerSpin)
|
||||
self.Bind(wx.EVT_SPINCTRL, self.OnLayerNrChange, self.layerSpin)
|
||||
|
||||
self.toolbar2 = wx.ToolBar( self, -1 )
|
||||
self.toolbar2 = wx.ToolBar( self, -1, style = wx.TB_HORIZONTAL | wx.NO_BORDER )
|
||||
self.toolbar2.SetToolBitmapSize( ( 21, 21 ) )
|
||||
self.toolbar2.AddControl(wx.StaticText(self.toolbar2, -1, 'Flip'))
|
||||
|
||||
self.flipX = wx.CheckBox(self.toolbar2, -1, "X")
|
||||
self.flipX.SetValue(profile.getProfileSetting('flip_x') == 'True')
|
||||
self.toolbar2.AddControl(self.flipX)
|
||||
self.Bind(wx.EVT_CHECKBOX, self.OnFlipXClick, self.flipX)
|
||||
self.flipY = wx.CheckBox(self.toolbar2, -1, "Y")
|
||||
self.flipY.SetValue(profile.getProfileSetting('flip_y') == 'True')
|
||||
self.toolbar2.AddControl(self.flipY)
|
||||
self.Bind(wx.EVT_CHECKBOX, self.OnFlipYClick, self.flipY)
|
||||
self.flipZ = wx.CheckBox(self.toolbar2, -1, "Z")
|
||||
self.flipZ.SetValue(profile.getProfileSetting('flip_z') == 'True')
|
||||
self.toolbar2.AddControl(self.flipZ)
|
||||
self.Bind(wx.EVT_CHECKBOX, self.OnFlipZClick, self.flipZ)
|
||||
self.mirrorX = ToggleButton(self.toolbar2, self, 'flip_x', wx.Bitmap('Cura/images/object-mirror-x-on.png'), wx.Bitmap('Cura/images/object-mirror-x-off.png'), 'Mirror X')
|
||||
self.toolbar2.AddControl(self.mirrorX)
|
||||
|
||||
self.swapXZ = wx.CheckBox(self.toolbar2, -1, "XZ")
|
||||
self.swapXZ.SetValue(profile.getProfileSetting('swap_xz') == 'True')
|
||||
self.mirrorY = ToggleButton(self.toolbar2, self, 'flip_y', wx.Bitmap('Cura/images/object-mirror-y-on.png'), wx.Bitmap('Cura/images/object-mirror-y-off.png'), 'Mirror Y')
|
||||
self.toolbar2.AddControl(self.mirrorY)
|
||||
|
||||
self.mirrorZ = ToggleButton(self.toolbar2, self, 'flip_z', wx.Bitmap('Cura/images/object-mirror-z-on.png'), wx.Bitmap('Cura/images/object-mirror-z-off.png'), 'Mirror Z')
|
||||
self.toolbar2.AddControl(self.mirrorZ)
|
||||
|
||||
self.toolbar2.AddSeparator()
|
||||
|
||||
self.swapXZ = ToggleButton(self.toolbar2, self, 'swap_xz', wx.Bitmap('Cura/images/object-swap-xz-on.png'), wx.Bitmap('Cura/images/object-swap-xz-off.png'), 'Swap XZ')
|
||||
self.toolbar2.AddControl(self.swapXZ)
|
||||
self.Bind(wx.EVT_CHECKBOX, self.OnSwapXZClick, self.swapXZ)
|
||||
|
||||
self.swapYZ = wx.CheckBox(self.toolbar2, -1, "YZ")
|
||||
self.swapYZ.SetValue(profile.getProfileSetting('swap_yz') == 'True')
|
||||
self.swapYZ = ToggleButton(self.toolbar2, self, 'swap_yz', wx.Bitmap('Cura/images/object-swap-yz-on.png'), wx.Bitmap('Cura/images/object-swap-yz-off.png'), 'Swap YZ')
|
||||
self.toolbar2.AddControl(self.swapYZ)
|
||||
self.Bind(wx.EVT_CHECKBOX, self.OnSwapYZClick, self.swapYZ)
|
||||
|
||||
self.toolbar2.InsertSeparator(self.toolbar2.GetToolsCount())
|
||||
self.toolbar2.AddControl(wx.StaticText(self.toolbar2, -1, 'Scale'))
|
||||
|
@ -132,25 +190,26 @@ class previewPanel(wx.Panel):
|
|||
sizer.Add(self.toolbar2, 0, flag=wx.EXPAND|wx.BOTTOM|wx.LEFT|wx.RIGHT, border=1)
|
||||
self.SetSizer(sizer)
|
||||
|
||||
def OnFlipXClick(self, e):
|
||||
profile.putProfileSetting('flip_x', str(self.flipX.GetValue()))
|
||||
self.updateModelTransform()
|
||||
|
||||
def OnFlipYClick(self, e):
|
||||
profile.putProfileSetting('flip_y', str(self.flipY.GetValue()))
|
||||
self.updateModelTransform()
|
||||
|
||||
def OnFlipZClick(self, e):
|
||||
profile.putProfileSetting('flip_z', str(self.flipZ.GetValue()))
|
||||
self.updateModelTransform()
|
||||
|
||||
def OnSwapXZClick(self, e):
|
||||
profile.putProfileSetting('swap_xz', str(self.swapXZ.GetValue()))
|
||||
self.updateModelTransform()
|
||||
|
||||
def OnSwapYZClick(self, e):
|
||||
profile.putProfileSetting('swap_yz', str(self.swapYZ.GetValue()))
|
||||
self.updateModelTransform()
|
||||
def OnPopupDisplay(self, e):
|
||||
self.UpdatePopup(e.GetEventObject())
|
||||
self.popup.Show(True)
|
||||
|
||||
def OnPopupHide(self, e):
|
||||
if self.popupOwner == e.GetEventObject():
|
||||
self.popup.Show(False)
|
||||
|
||||
def UpdatePopup(self, control):
|
||||
self.popupOwner = control
|
||||
self.popup.text.SetLabel(control.helpText)
|
||||
self.popup.text.Wrap(350)
|
||||
self.popup.Fit();
|
||||
if os.name == 'darwin':
|
||||
x, y = self.ClientToScreenXY(0, 0)
|
||||
sx, sy = self.GetClientSizeTuple()
|
||||
else:
|
||||
x, y = control.ClientToScreenXY(0, 0)
|
||||
sx, sy = control.GetSizeTuple()
|
||||
self.popup.SetPosition((x, y+sy))
|
||||
|
||||
def OnMulXAddClick(self, e):
|
||||
profile.putProfileSetting('model_multiply_x', str(max(1, int(profile.getProfileSetting('model_multiply_x'))+1)))
|
||||
|
|
BIN
Cura/images/object-mirror-x-off.png
Normal file
After Width: | Height: | Size: 49 KiB |
BIN
Cura/images/object-mirror-x-on.png
Normal file
After Width: | Height: | Size: 49 KiB |
BIN
Cura/images/object-mirror-y-off.png
Normal file
After Width: | Height: | Size: 49 KiB |
BIN
Cura/images/object-mirror-y-on.png
Normal file
After Width: | Height: | Size: 49 KiB |
BIN
Cura/images/object-mirror-z-off.png
Normal file
After Width: | Height: | Size: 49 KiB |
BIN
Cura/images/object-mirror-z-on.png
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
Cura/images/object-swap-xz-off.png
Normal file
After Width: | Height: | Size: 49 KiB |
BIN
Cura/images/object-swap-xz-on.png
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
Cura/images/object-swap-yz-off.png
Normal file
After Width: | Height: | Size: 49 KiB |
BIN
Cura/images/object-swap-yz-on.png
Normal file
After Width: | Height: | Size: 49 KiB |