From: daid303 Date: Fri, 5 Apr 2013 17:02:31 +0000 (+0200) Subject: Some code cleanup and fixing the minecraft import. X-Git-Tag: 13.05~121 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=0566dfbef74e45f169d3aebf145456a1fe13a866;p=cura.git Some code cleanup and fixing the minecraft import. --- diff --git a/Cura/cura.py b/Cura/cura.py index 3c07d642..a65acaa8 100644 --- a/Cura/cura.py +++ b/Cura/cura.py @@ -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. diff --git a/Cura/gui/mainWindow.py b/Cura/gui/mainWindow.py index 9e37de5b..72764e10 100644 --- a/Cura/gui/mainWindow.py +++ b/Cura/gui/mainWindow.py @@ -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() diff --git a/Cura/gui/sceneView.py b/Cura/gui/sceneView.py index 313c3b0c..d1308837 100644 --- a/Cura/gui/sceneView.py +++ b/Cura/gui/sceneView.py @@ -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) diff --git a/Cura/gui/tools/minecraftImport.py b/Cura/gui/tools/minecraftImport.py index 35eda8c1..ea230f10 100644 --- a/Cura/gui/tools/minecraftImport.py +++ b/Cura/gui/tools/minecraftImport.py @@ -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]) diff --git a/Cura/util/profile.py b/Cura/util/profile.py index cf62ee10..78abf27d 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -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 #########################################################