Added yellow popup to reset scale/mirror/rotate on a new model load. Popup is none-intrusive and hides itself after 5 seconds. Fixed #156

master
daid 2012-07-09 12:01:18 +02:00
parent 1684c09cdb
commit 5522a9a588
3 changed files with 56 additions and 7 deletions

View File

@ -336,6 +336,7 @@ class mainWindow(configBase.configWindowBase):
dlg.Destroy()
if not(os.path.exists(filename)):
return False
profile.putPreference('lastFile', filename)
return filename
dlg.Destroy()
return False
@ -352,7 +353,7 @@ class mainWindow(configBase.configWindowBase):
self.filelist = filelist
self.SetTitle(filelist[-1] + ' - Cura - ' + version.getVersion())
profile.putPreference('lastFile', ';'.join(self.filelist))
self.preview3d.loadModelFiles(self.filelist)
self.preview3d.loadModelFiles(self.filelist, True)
self.preview3d.setViewMode("Normal")
def OnDropFiles(self, filenames):

View File

@ -37,7 +37,6 @@ class previewPanel(wx.Panel):
self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DDKSHADOW))
self.SetMinSize((440,320))
self.glCanvas = PreviewGLCanvas(self)
self.objectList = []
self.errorList = []
self.gcode = None
@ -46,6 +45,28 @@ class previewPanel(wx.Panel):
self.loadThread = None
self.machineSize = util3d.Vector3(profile.getPreferenceFloat('machine_width'), profile.getPreferenceFloat('machine_depth'), profile.getPreferenceFloat('machine_height'))
self.machineCenter = util3d.Vector3(float(profile.getProfileSetting('machine_center_x')), float(profile.getProfileSetting('machine_center_y')), 0)
self.glCanvas = PreviewGLCanvas(self)
#Create the popup window
self.warningPopup = wx.PopupWindow(self, flags=wx.BORDER_SIMPLE)
self.warningPopup.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_INFOBK))
self.warningPopup.text = wx.StaticText(self.warningPopup, -1, 'Reset scale, rotation and mirror?')
self.warningPopup.yesButton = wx.Button(self.warningPopup, -1, 'yes', style=wx.BU_EXACTFIT)
self.warningPopup.noButton = wx.Button(self.warningPopup, -1, 'no', style=wx.BU_EXACTFIT)
self.warningPopup.sizer = wx.BoxSizer(wx.HORIZONTAL)
self.warningPopup.SetSizer(self.warningPopup.sizer)
self.warningPopup.sizer.Add(self.warningPopup.text, 1, flag=wx.ALL|wx.ALIGN_CENTER_VERTICAL, border=1)
self.warningPopup.sizer.Add(self.warningPopup.yesButton, 0, flag=wx.EXPAND|wx.ALL, border=1)
self.warningPopup.sizer.Add(self.warningPopup.noButton, 0, flag=wx.EXPAND|wx.ALL, border=1)
self.warningPopup.Fit()
self.warningPopup.Layout()
self.warningPopup.timer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.OnHideWarning, self.warningPopup.timer)
self.Bind(wx.EVT_BUTTON, self.OnResetAll, self.warningPopup.yesButton)
self.Bind(wx.EVT_BUTTON, self.OnHideWarning, self.warningPopup.noButton)
parent.Bind(wx.EVT_MOVE, self.OnMove)
parent.Bind(wx.EVT_SIZE, self.OnMove)
self.toolbar = toolbarUtil.Toolbar(self)
@ -111,6 +132,12 @@ class previewPanel(wx.Panel):
sizer.Add(self.toolbar2, 0, flag=wx.EXPAND|wx.BOTTOM|wx.LEFT|wx.RIGHT, border=1)
self.SetSizer(sizer)
def OnMove(self, e):
e.Skip()
x, y = self.glCanvas.ClientToScreenXY(0, 0)
sx, sy = self.glCanvas.GetClientSizeTuple()
self.warningPopup.SetPosition((x, y+sy-self.warningPopup.GetSize().height))
def OnMulXAddClick(self, e):
profile.putProfileSetting('model_multiply_x', str(max(1, int(profile.getProfileSetting('model_multiply_x'))+1)))
self.glCanvas.Refresh()
@ -194,7 +221,7 @@ class previewPanel(wx.Panel):
self.glCanvas.viewMode = mode
wx.CallAfter(self.glCanvas.Refresh)
def loadModelFiles(self, filelist):
def loadModelFiles(self, filelist, showWarning = False):
while len(filelist) > len(self.objectList):
self.objectList.append(previewObject())
for idx in xrange(len(filelist), len(self.objectList)):
@ -215,6 +242,11 @@ class previewPanel(wx.Panel):
self.loadThread = threading.Thread(target=self.doFileLoadThread)
self.loadThread.daemon = True
self.loadThread.start()
if showWarning:
if profile.getProfileSettingFloat('model_scale') != 1.0 or profile.getProfileSettingFloat('model_rotate_base') != 0 or profile.getProfileSetting('flip_x') != 'False' or profile.getProfileSetting('flip_y') != 'False' or profile.getProfileSetting('flip_z') != 'False' or profile.getProfileSetting('swap_xz') != 'False' or profile.getProfileSetting('swap_yz') != 'False':
self.warningPopup.Show(True)
self.warningPopup.timer.Start(5000)
def loadReModelFiles(self, filelist):
#Only load this again if the filename matches the file we have already loaded (for auto loading GCode after slicing)
@ -262,7 +294,23 @@ class previewPanel(wx.Panel):
def loadProgress(self, progress):
pass
def OnResetAll(self, e):
profile.putProfileSetting('model_scale', '1.0')
profile.putProfileSetting('model_rotate_base', '0')
profile.putProfileSetting('flip_x', 'False')
profile.putProfileSetting('flip_y', 'False')
profile.putProfileSetting('flip_z', 'False')
profile.putProfileSetting('swap_xz', 'False')
profile.putProfileSetting('swap_yz', 'False')
self.updateProfileToControls()
self.warningPopup.Show(False)
self.warningPopup.timer.Stop()
def OnHideWarning(self, e):
self.warningPopup.Show(False)
self.warningPopup.timer.Stop()
def updateToolbar(self):
self.gcodeViewButton.Show(self.gcode != None)
self.mixedViewButton.Show(self.gcode != None)
@ -393,10 +441,10 @@ class PreviewGLCanvas(glcanvas.GLCanvas):
#Workaround for windows background redraw flicker.
pass
def OnSize(self,event):
def OnSize(self,e):
self.Refresh()
def OnPaint(self,event):
def OnPaint(self,e):
dc = wx.PaintDC(self)
if not hasOpenGLlibs:
dc.Clear()

View File

@ -158,7 +158,7 @@ class simpleModeWindow(configBase.configWindowBase):
if dlg.ShowModal() == wx.ID_OK:
self.filelist = [dlg.GetPath()]
profile.putPreference('lastFile', ';'.join(self.filelist))
self.preview3d.loadModelFiles(self.filelist)
self.preview3d.loadModelFiles(self.filelist, True)
self.preview3d.setViewMode("Normal")
dlg.Destroy()