chiark / gitweb /
Some code cleanup and fixing the minecraft import.
authordaid303 <daid303@gmail.com>
Fri, 5 Apr 2013 17:02:31 +0000 (19:02 +0200)
committerdaid303 <daid303@gmail.com>
Fri, 5 Apr 2013 17:02:31 +0000 (19:02 +0200)
Cura/cura.py
Cura/gui/mainWindow.py
Cura/gui/sceneView.py
Cura/gui/tools/minecraftImport.py
Cura/util/profile.py

index 3c07d642c44815fbbce9c5106e88ae208a5750ad..a65acaa87a40a6761bb8669879b06d35bfe6264b 100644 (file)
@@ -72,7 +72,6 @@ def main():
                #Place any unused arguments as last file, so Cura starts with opening those files.
                if len(args) > 0:
                        profile.putPreference('lastFile', ';'.join(args))
-                       profile.putProfileSetting('model_matrix', '1,0,0,0,1,0,0,0,1')
                        profile.setPluginConfig([])
 
                #Do not import anything from Cura.gui before this spot, as the above code also needs to run in pypy.
index 9e37de5b2e4111d088e9de7fd3f56e1dec7661f1..72764e107295b280dddd97030b1cb1379552f468 100644 (file)
@@ -11,16 +11,13 @@ from Cura.gui import pluginPanel
 from Cura.gui import preferencesDialog
 from Cura.gui import configWizard
 from Cura.gui import firmwareInstall
-from Cura.gui import printWindow
 from Cura.gui import simpleMode
-from Cura.gui import projectPlanner
 from Cura.gui import sceneView
 from Cura.gui.tools import batchRun
 from Cura.gui.util import dropTarget
 from Cura.gui.tools import minecraftImport
 from Cura.util import profile
 from Cura.util import version
-from Cura.util import sliceRun
 from Cura.util import meshLoader
 
 class mainWindow(wx.Frame):
@@ -104,9 +101,6 @@ class mainWindow(wx.Frame):
                self.switchToNormalMenuItem = i
                self.Bind(wx.EVT_MENU, self.OnNormalSwitch, i)
                toolsMenu.AppendSeparator()
-               i = toolsMenu.Append(-1, 'Project planner...')
-               self.Bind(wx.EVT_MENU, self.OnProjectPlanner, i)
-               self.normalModeOnlyItems.append(i)
                i = toolsMenu.Append(-1, 'Batch run...')
                self.Bind(wx.EVT_MENU, self.OnBatchRun, i)
                self.normalModeOnlyItems.append(i)
@@ -264,20 +258,10 @@ class mainWindow(wx.Frame):
                prefDialog.Show(True)
 
        def OnDropFiles(self, files):
-               profile.putProfileSetting('model_matrix', '1,0,0,0,1,0,0,0,1')
                profile.setPluginConfig([])
                self.updateProfileToControls()
                self.scene.loadScene(files)
 
-       def OnPrint(self, e):
-               if len(self.filelist) < 1:
-                       wx.MessageBox('You need to load a file and prepare it before you can print.', 'Print error', wx.OK | wx.ICON_INFORMATION)
-                       return
-               if not os.path.exists(sliceRun.getExportFilename(self.filelist[0])):
-                       wx.MessageBox('You need to prepare a print before you can run the actual print.', 'Print error', wx.OK | wx.ICON_INFORMATION)
-                       return
-               printWindow.printFile(sliceRun.getExportFilename(self.filelist[0]))
-
        def OnModelMRU(self, e):
                fileNum = e.GetId() - self.ID_MRU_MODEL1
                path = self.modelFileHistory.GetHistoryFile(fileNum)
@@ -404,11 +388,6 @@ class mainWindow(wx.Frame):
                ecw.Centre()
                ecw.Show(True)
 
-       def OnProjectPlanner(self, e):
-               pp = projectPlanner.projectPlanner()
-               pp.Centre()
-               pp.Show(True)
-
        def OnMinecraftImport(self, e):
                mi = minecraftImport.minecraftImportWindow(self)
                mi.Centre()
index 313c3b0c0c231c06b92fb6bcd1934ac167874bdb..d130883787f9a27b8d6c6a5d0d5d90e17bfdd644 100644 (file)
@@ -594,11 +594,14 @@ void main(void)
                        glEnable(GL_CULL_FACE)
                        glEnable(GL_STENCIL_TEST)
                        glStencilFunc(GL_EQUAL, 0, 255)
+
                        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
                        glLineWidth(2)
                        glColor4f(1,1,1,0.5)
                        self._renderObject(self._selectedObj)
                        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
+
+                       glViewport(0, 0, self.GetSize().GetWidth(), self.GetSize().GetHeight())
                        glDisable(GL_STENCIL_TEST)
                        glDisable(GL_CULL_FACE)
                        glEnable(GL_DEPTH_TEST)
index 35eda8c1c6533145d5d585a876c551be4f47f064..ea230f10ab29f3956dce7fc81d252f59c4dc2612 100644 (file)
@@ -212,65 +212,41 @@ class minecraftImportWindow(wx.Frame):
                                                if y == sy - 1 or not self.isSolid[blocks[x, y + 1, z]]:
                                                        faceCount += 1
                m = mesh.mesh()
-               m._prepareVertexCount(faceCount * 2 * 3)
+               m._prepareFaceCount(faceCount * 2)
                for x in xrange(0, sx):
                        for y in xrange(0, sy):
                                for z in xrange(minZ, maxZ + 1):
                                        if self.isSolid[blocks[x, y, z]]:
                                                if z == maxZ or not self.isSolid[blocks[x, y, z + 1]]:
-                                                       m.addVertex(x, y, z+1)
-                                                       m.addVertex(x+1, y, z+1)
-                                                       m.addVertex(x, y+1, z+1)
+                                                       m._addFace(x, y, z+1, x+1, y, z+1, x, y+1, z+1)
 
-                                                       m.addVertex(x+1, y+1, z+1)
-                                                       m.addVertex(x, y+1, z+1)
-                                                       m.addVertex(x+1, y, z+1)
+                                                       m._addFace(x+1, y+1, z+1, x, y+1, z+1, x+1, y, z+1)
 
                                                if z == minZ or not self.isSolid[blocks[x, y, z - 1]]:
-                                                       m.addVertex(x, y, z)
-                                                       m.addVertex(x, y+1, z)
-                                                       m.addVertex(x+1, y, z)
+                                                       m._addFace(x, y, z, x, y+1, z, x+1, y, z)
 
-                                                       m.addVertex(x+1, y+1, z)
-                                                       m.addVertex(x+1, y, z)
-                                                       m.addVertex(x, y+1, z)
+                                                       m._addFace(x+1, y+1, z, x+1, y, z, x, y+1, z)
 
                                                if x == 0 or not self.isSolid[blocks[x - 1, y, z]]:
-                                                       m.addVertex(x, y, z)
-                                                       m.addVertex(x, y, z+1)
-                                                       m.addVertex(x, y+1, z)
+                                                       m._addFace(x, y, z, x, y, z+1, x, y+1, z)
 
-                                                       m.addVertex(x, y+1, z+1)
-                                                       m.addVertex(x, y+1, z)
-                                                       m.addVertex(x, y, z+1)
+                                                       m._addFace(x, y+1, z+1, x, y+1, z, x, y, z+1)
 
                                                if x == sx - 1 or not self.isSolid[blocks[x + 1, y, z]]:
-                                                       m.addVertex(x+1, y, z)
-                                                       m.addVertex(x+1, y+1, z)
-                                                       m.addVertex(x+1, y, z+1)
+                                                       m._addFace(x+1, y, z, x+1, y+1, z, x+1, y, z+1)
 
-                                                       m.addVertex(x+1, y+1, z+1)
-                                                       m.addVertex(x+1, y, z+1)
-                                                       m.addVertex(x+1, y+1, z)
+                                                       m._addFace(x+1, y+1, z+1, x+1, y, z+1, x+1, y+1, z)
 
                                                if y == 0 or not self.isSolid[blocks[x, y - 1, z]]:
-                                                       m.addVertex(x, y, z)
-                                                       m.addVertex(x+1, y, z)
-                                                       m.addVertex(x, y, z+1)
+                                                       m._addFace(x, y, z, x+1, y, z, x, y, z+1)
 
-                                                       m.addVertex(x+1, y, z+1)
-                                                       m.addVertex(x, y, z+1)
-                                                       m.addVertex(x+1, y, z)
+                                                       m._addFace(x+1, y, z+1, x, y, z+1, x+1, y, z)
 
                                                if y == sy - 1 or not self.isSolid[blocks[x, y + 1, z]]:
-                                                       m.addVertex(x, y+1, z)
-                                                       m.addVertex(x, y+1, z+1)
-                                                       m.addVertex(x+1, y+1, z)
+                                                       m._addFace(x, y+1, z, x, y+1, z+1, x+1, y+1, z)
 
-                                                       m.addVertex(x+1, y+1, z+1)
-                                                       m.addVertex(x+1, y+1, z)
-                                                       m.addVertex(x, y+1, z+1)
+                                                       m._addFace(x+1, y+1, z+1, x+1, y+1, z, x, y+1, z+1)
 
                stlFilename = os.path.join(os.path.dirname(self.level.filename), 'export.stl')
                stl.saveAsSTL(m, stlFilename)
-               self.GetParent()._loadModels([stlFilename])
+               self.GetParent().scene.loadScene([stlFilename])
index cf62ee1026ef1852aa1b9b0bcde6805d548d7b2b..78abf27d11fa1e91b450119ca080b5f39553cd1b 100644 (file)
@@ -164,7 +164,6 @@ setting('fan_layer',                   1, int,   'expert',   'Cool').setRange(0)
 #setting('raft_interface_material_amount', 100, int, 'expert', 'Raft').setRange(0,100).setLabel('Interface material amount (%)', 'The interface layer is a weak thin layer between the base layer and the printed object. It is designed to has little material to make it easy to break the base off the printed object. This setting adjusts the amount of material used for the interface layer.')
 #setting('hop_on_move', False, bool, 'expert', 'Hop').setLabel('Enable hop on move', 'When moving from print position to print position, raise the printer head 0.2mm so it does not knock off the print (experimental).')
 
-setting('model_matrix', '1,0,0,0,1,0,0,0,1', str, 'hidden', 'hidden')
 setting('plugin_config', '', str, 'hidden', 'hidden')
 setting('object_center_x', -1, float, 'hidden', 'hidden')
 setting('object_center_y', -1, float, 'hidden', 'hidden')
@@ -590,12 +589,6 @@ def getMachineCenterCoords():
                return [0, 0]
        return [getPreferenceFloat('machine_width') / 2, getPreferenceFloat('machine_depth') / 2]
 
-def getObjectMatrix():
-       try:
-               return map(float, getProfileSetting('model_matrix').split(','))
-       except ValueError:
-               return [1,0,0, 0,1,0, 0,0,1]
-
 #########################################################
 ## Alteration file functions
 #########################################################