chiark / gitweb /
Added yellow popup to reset scale/mirror/rotate on a new model load. Popup is none...
authordaid <daid303@gmail.com>
Mon, 9 Jul 2012 10:01:18 +0000 (12:01 +0200)
committerdaid <daid303@gmail.com>
Mon, 9 Jul 2012 10:01:18 +0000 (12:01 +0200)
Cura/gui/mainWindow.py
Cura/gui/preview3d.py
Cura/gui/simpleMode.py

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