chiark / gitweb /
Merge pull request #564 from hg42/allow-dropping-profile
authordaid <daid303@gmail.com>
Tue, 24 Sep 2013 13:58:51 +0000 (06:58 -0700)
committerdaid <daid303@gmail.com>
Tue, 24 Sep 2013 13:58:51 +0000 (06:58 -0700)
allow dropping profile (*.ini) onto window

1  2 
Cura/gui/mainWindow.py
Cura/gui/sceneView.py

diff --combined Cura/gui/mainWindow.py
index cc53be01089ca074ee622b53ea2ebc92bcd24469,419f07878cb52239cc3072384e0e1d281cf69541..e1bf8934a1d4c7dc401a8515b943420bde79e450
@@@ -30,7 -30,7 +30,7 @@@ class mainWindow(wx.Frame)
  
                wx.EVT_CLOSE(self, self.OnClose)
  
-               self.SetDropTarget(dropTarget.FileDropTarget(self.OnDropFiles, meshLoader.loadSupportedExtensions() + ['.g', '.gcode']))
+               self.SetDropTarget(dropTarget.FileDropTarget(self.OnDropFiles, meshLoader.loadSupportedExtensions() + ['.g', '.gcode', '.ini']))
  
                self.normalModeOnlyItems = []
  
                if self.extruderCount > 1:
                        i = expertMenu.Append(-1, _("Run head offset wizard..."))
                        self.Bind(wx.EVT_MENU, self.OnHeadOffsetWizard, i)
 +
 +              i = expertMenu.Append(-1, _("Add new machine..."))
 +              self.Bind(wx.EVT_MENU, self.OnAddNewMachine, i)
 +
                self.menubar.Append(expertMenu, _("Expert"))
  
                helpMenu = wx.Menu()
                        # Save normal mode sash
                        self.normalSashPos = self.splitter.GetSashPosition()
  
-                       # Change location of sash to width of quick mode pane 
+                       # Change location of sash to width of quick mode pane
                        (width, height) = self.simpleSettingsPanel.GetSizer().GetSize()
                        self.splitter.SetSashPosition(width, True)
  
                self.config.SetPath("/ProfileMRU")
                self.profileFileHistory.Save(self.config)
                self.config.Flush()
-               # Load Profile  
+               # Load Profile
                profile.loadProfile(path)
                self.updateProfileToAllControls()
  
                self.profileFileHistory.AddFileToHistory(file)
                self.config.SetPath("/ProfileMRU")
                self.profileFileHistory.Save(self.config)
-               self.config.Flush()                     
+               self.config.Flush()
  
        def updateProfileToAllControls(self):
                self.scene.updateProfileToControls()
                firmwareInstall.InstallFirmware()
  
        def OnCustomFirmware(self, e):
 -              if profile.getPreference('machine_type').startswith('ultimaker'):
 +              if profile.getMachineSetting('machine_type').startswith('ultimaker'):
                        wx.MessageBox(_("Warning: Installing a custom firmware does not guarantee that you machine will function correctly, and could damage your machine."), _("Firmware update"), wx.OK | wx.ICON_EXCLAMATION)
                dlg=wx.FileDialog(self, _("Open firmware to upload"), os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
                dlg.SetWildcard("HEX file (*.hex)|*.hex;*.HEX")
                        firmwareInstall.InstallFirmware(filename)
  
        def OnFirstRunWizard(self, e):
 +              self.Hide()
                configWizard.configWizard()
 +              self.Show()
 +              self.updateProfileToAllControls()
 +
 +      def OnAddNewMachine(self, e):
 +              self.Hide()
 +              n = 0
 +              while profile.getMachineSetting('machine_name', n) != '':
 +                      n += 1
 +              profile.setActiveMachine(n)
 +              configWizard.configWizard(True)
 +              self.Show()
                self.updateProfileToAllControls()
  
        def OnBedLevelWizard(self, e):
@@@ -593,17 -577,17 +593,17 @@@ class normalSettingsPanel(configBase.co
        def OnSize(self, e):
                # Make the size of the Notebook control the same size as this control
                self.nb.SetSize(self.GetSize())
-               
                # Propegate the OnSize() event (just in case)
                e.Skip()
-               
                # Perform out resize magic
                self.UpdateSize(self.printPanel)
                self.UpdateSize(self.advancedPanel)
-       
        def UpdateSize(self, configPanel):
                sizer = configPanel.GetSizer()
-               
                # Pseudocde
                # if horizontal:
                #     if width(col1) < best_width(col1) || width(col2) < best_width(col2):
                #     if width(col1) > (best_width(col1) + best_width(col1)):
                #         switch to horizontal
                #
-                               
                col1 = configPanel.leftPanel
                colSize1 = col1.GetSize()
                colBestSize1 = col1.GetBestSize()
                colBestSize2 = col2.GetBestSize()
  
                orientation = sizer.GetOrientation()
-               
                if orientation == wx.HORIZONTAL:
                        if (colSize1[0] <= colBestSize1[0]) or (colSize2[0] <= colBestSize2[0]):
                                configPanel.Freeze()
diff --combined Cura/gui/sceneView.py
index 5380bb9f937b64f1446bbd8a285d7ea4ebf8e689,bd22863e19e356119be9241e5f76821efacc0d70..b65ff526e25562a265c7d8061588a44ac98c56ba
@@@ -145,14 -145,23 +145,23 @@@ class SceneView(openglGui.glGuiPanel)
        def loadFiles(self, filenames):
                gcodeFilename = None
                for filename in filenames:
-                       self.GetParent().GetParent().GetParent().addToModelMRU(filename)
+                       self.GetParent().GetParent().GetParent().addToModelMRU(filename)        #??? only Model files?
                        ext = filename[filename.rfind('.')+1:].upper()
                        if ext == 'G' or ext == 'GCODE':
                                gcodeFilename = filename
                if gcodeFilename is not None:
                        self.loadGCodeFile(gcodeFilename)
                else:
-                       self.loadSceneFiles(filenames)
+                       profileFilename = None
+                       for filename in filenames:
+                               ext = filename[filename.rfind('.')+1:].upper()
+                               if ext == 'INI':
+                                       profileFilename = filename
+                       if profileFilename is not None:
+                               profile.loadProfile(profileFilename)
+                               self.GetParent().GetParent().GetParent().updateProfileToAllControls()
+                       else:
+                               self.loadSceneFiles(filenames)
  
        def showLoadModel(self, button = 1):
                if button == 1:
@@@ -1170,7 -1179,7 +1179,7 @@@ void main(void
                                        self._platformMesh[machine] = meshes[0]
                                else:
                                        self._platformMesh[machine] = None
 -                              if profile.getMachineSetting('machine_type') == 'ultimaker2':
 +                              if machine == 'ultimaker2':
                                        self._platformMesh[machine]._drawOffset = numpy.array([0,-37,145], numpy.float32)
                                else:
                                        self._platformMesh[machine]._drawOffset = numpy.array([0,0,2.5], numpy.float32)
                        self._objectShader.bind()
                        self._renderObject(self._platformMesh[machine], False, False)
                        self._objectShader.unbind()
 +
 +                      #For the Ultimaker 2 render the texture on the back plate to show the Ultimaker2 text.
 +                      if machine == 'ultimaker2':
 +                              if not hasattr(self._platformMesh[machine], 'texture'):
 +                                      self._platformMesh[machine].texture = opengl.loadGLTexture('Ultimaker2backplate.png')
 +                              glBindTexture(GL_TEXTURE_2D, self._platformMesh[machine].texture)
 +                              glEnable(GL_TEXTURE_2D)
 +                              glPushMatrix()
 +                              glColor4f(1,1,1,1)
 +
 +                              glTranslate(0,150,-5)
 +                              h = 50
 +                              d = 8
 +                              w = 100
 +                              glEnable(GL_BLEND)
 +                              glBlendFunc(GL_DST_COLOR, GL_ZERO)
 +                              glBegin(GL_QUADS)
 +                              glTexCoord2f(1, 0)
 +                              glVertex3f( w, 0, h)
 +                              glTexCoord2f(0, 0)
 +                              glVertex3f(-w, 0, h)
 +                              glTexCoord2f(0, 1)
 +                              glVertex3f(-w, 0, 0)
 +                              glTexCoord2f(1, 1)
 +                              glVertex3f( w, 0, 0)
 +
 +                              glTexCoord2f(1, 0)
 +                              glVertex3f(-w, d, h)
 +                              glTexCoord2f(0, 0)
 +                              glVertex3f( w, d, h)
 +                              glTexCoord2f(0, 1)
 +                              glVertex3f( w, d, 0)
 +                              glTexCoord2f(1, 1)
 +                              glVertex3f(-w, d, 0)
 +                              glEnd()
 +                              glDisable(GL_TEXTURE_2D)
 +                              glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
 +                              glPopMatrix()
                else:
                        glColor4f(0,0,0,1)
                        glLineWidth(3)