SHARE
TWEET

Cura Manual Slice and Redraw

a guest Aug 6th, 2014 197 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Index: Cura/gui/mainWindow.py
  2. ===================================================================
  3. --- Cura/gui/mainWindow.py      (revision 2208)
  4. +++ Cura/gui/mainWindow.py      (working copy)
  5. @@ -115,6 +115,10 @@
  6.                 self.profileFileHistory.UseMenu(profileHistoryMenu)
  7.                 self.profileFileHistory.AddFilesToMenu()
  8.                 self.Bind(wx.EVT_MENU_RANGE, self.OnProfileMRU, id=self.ID_MRU_PROFILE1, id2=self.ID_MRU_PROFILE10)
  9. +              
  10. +               self.fileMenu.AppendSeparator()
  11. +               i = self.fileMenu.Append(-1, _("Start Toolpath Computation\tCTRL+T"))
  12. +               self.Bind(wx.EVT_MENU, self.onToolpathStart, i)
  13.  
  14.                 self.fileMenu.AppendSeparator()
  15.                 i = self.fileMenu.Append(wx.ID_EXIT, _("Quit"))
  16. @@ -336,7 +340,10 @@
  17.                         self.headOffsetWizardMenuItem.Enable(False)
  18.                 self.scene.updateProfileToControls()
  19.                 self.scene._scene.pushFree()
  20. -
  21. +      
  22. +       def onToolpathStart(self, e):
  23. +               self.scene.updateSceneAndRunEngine()
  24. +              
  25.         def onOneAtATimeSwitch(self, e):
  26.                 profile.putPreference('oneAtATime', self.oneAtATime.IsChecked())
  27.                 if self.oneAtATime.IsChecked() and profile.getMachineSettingFloat('extruder_head_size_height') < 1:
  28. Index: Cura/gui/preferencesDialog.py
  29. ===================================================================
  30. --- Cura/gui/preferencesDialog.py       (revision 2208)
  31. +++ Cura/gui/preferencesDialog.py       (working copy)
  32. @@ -51,6 +51,7 @@
  33.                 configBase.SettingRow(right, 'auto_detect_sd')
  34.                 configBase.SettingRow(right, 'check_for_updates')
  35.                 configBase.SettingRow(right, 'submit_slice_information')
  36. +               configBase.SettingRow(right, 'automatic_slicing')
  37.  
  38.                 self.okButton = wx.Button(right, -1, 'Ok')
  39.                 right.GetSizer().Add(self.okButton, (right.GetSizer().GetRows(), 0), flag=wx.BOTTOM, border=5)
  40. Index: Cura/gui/sceneView.py
  41. ===================================================================
  42. --- Cura/gui/sceneView.py       (revision 2211)
  43. +++ Cura/gui/sceneView.py       (working copy)
  44. @@ -35,6 +35,8 @@
  45.  class SceneView(openglGui.glGuiPanel):
  46.         def __init__(self, parent):
  47.                 super(SceneView, self).__init__(parent)
  48. +              
  49. +               self.layersDirty = True
  50.  
  51.                 self._yaw = 30
  52.                 self._pitch = 60
  53. @@ -386,6 +388,11 @@
  54.  
  55.         def OnViewChange(self):
  56.                 if self.viewSelection.getValue() == 4:
  57. +                       if self.layersDirty and profile.getPreference('automatic_slicing') != 'True':
  58. +                               #ensure that we will eventually have some gcode to display in the layer view
  59. +                               self.updateSceneAndRunEngine()
  60. +                               threading.Timer(0.1, self.OnViewChange).start()
  61. +                               return
  62.                         self.viewMode = 'gcode'
  63.                         self.tool = previewTools.toolNone(self)
  64.                 elif self.viewSelection.getValue() == 1:
  65. @@ -542,17 +549,44 @@
  66.                 self.sceneUpdated()
  67.  
  68.         def sceneUpdated(self):
  69. +               if profile.getPreference('automatic_slicing') == 'True':
  70. +                       self._sceneUpdated()
  71. +               else:
  72. +                       self.layersDirty = True
  73. +      
  74. +       def _sceneUpdated(self):
  75.                 self._sceneUpdateTimer.Start(500, True)
  76.                 self._engine.abortEngine()
  77.                 self._scene.updateSizeOffsets()
  78.                 self.QueueRefresh()
  79.  
  80.         def _onRunEngine(self, e):
  81. +               if profile.getPreference('automatic_slicing') == 'True':
  82. +                       self.__onRunEngine(e)
  83. +                      
  84. +       def __onRunEngine(self, e):
  85.                 if self._isSimpleMode:
  86.                         self.GetTopLevelParent().simpleSettingsPanel.setupSlice()
  87.                 self._engine.runEngine(self._scene)
  88.                 if self._isSimpleMode:
  89.                         profile.resetTempOverride()
  90. +                      
  91. +               #clear flag
  92. +               self.layersDirty = False
  93. +              
  94. +       #used when toolpath generation is set to 'Manual' mode
  95. +       def updateSceneAndRunEngine(self):
  96. +               #redraw printables
  97. +               for printable in _scene.objects():
  98. +                       if printable.requiresRedraw:
  99. +                               printable.redraw()
  100. +              
  101. +               #update scene
  102. +               self._sceneUpdated()
  103. +              
  104. +               #run engine
  105. +               self.__onRunEngine(None)
  106. +              
  107.  
  108.         def _updateEngineProgress(self, progressValue):
  109.                 result = self._engine.getResult()
  110. Index: Cura/util/printableObject.py
  111. ===================================================================
  112. --- Cura/util/printableObject.py        (revision 2208)
  113. +++ Cura/util/printableObject.py        (working copy)
  114. @@ -13,6 +13,7 @@
  115.  numpy.seterr(all='ignore')
  116.  
  117.  from Cura.util import polygon
  118. +from Cura.util import profile
  119.  
  120.  class printableObject(object):
  121.         """
  122. @@ -47,6 +48,9 @@
  123.                 self._headAreaMinHull = None
  124.  
  125.                 self._loadAnim = None
  126. +              
  127. +               self.requiresRedraw = True
  128. +               self.hasModel = False
  129.  
  130.         def copy(self):
  131.                 ret = printableObject(self._originFilename)
  132. @@ -90,6 +94,15 @@
  133.                 self.processMatrix()
  134.  
  135.         def processMatrix(self):
  136. +               if profile.getPreference('automatic_slicing') == 'True' or not self.hasModel:
  137. +                       self._processMatrix()
  138. +               else:
  139. +                       self.requiresRedraw = True
  140. +      
  141. +       def redraw(self):
  142. +                       self._processMatrix()
  143. +              
  144. +       def _processMatrix(self):
  145.                 self._transformedMin = numpy.array([999999999999,999999999999,999999999999], numpy.float64)
  146.                 self._transformedMax = numpy.array([-999999999999,-999999999999,-999999999999], numpy.float64)
  147.                 self._boundaryCircleSize = 0
  148. @@ -118,6 +131,9 @@
  149.                 self._boundaryHull = polygon.minkowskiHull((hull.astype(numpy.float32) - self._drawOffset[0:2]), numpy.array([[-1,-1],[-1,1],[1,1],[1,-1]],numpy.float32))
  150.                 self._printAreaHull = polygon.minkowskiHull(self._boundaryHull, self._printAreaExtend)
  151.                 self.setHeadArea(self._headAreaExtend, self._headMinSize)
  152. +              
  153. +               self.requiresRedraw = False
  154. +               self.hasModel = True
  155.  
  156.         def getName(self):
  157.                 return self._name
  158. Index: Cura/util/profile.py
  159. ===================================================================
  160. --- Cura/util/profile.py        (revision 2208)
  161. +++ Cura/util/profile.py        (working copy)
  162. @@ -473,6 +473,7 @@
  163. setting('auto_detect_sd', 'True', bool, 'preference', 'hidden').setLabel(_("Auto detect SD card drive"), _("Auto detect the SD card. You can disable this because on some systems external hard-drives or USB sticks are detected as SD card."))
  164. setting('check_for_updates', 'True', bool, 'preference', 'hidden').setLabel(_("Check for updates"), _("Check for newer versions of Cura on startup"))
  165. setting('submit_slice_information', 'False', bool, 'preference', 'hidden').setLabel(_("Send usage statistics"), _("Submit anonymous usage information to improve future versions of Cura"))
  166. +setting('automatic_slicing', 'True', bool, 'preference', 'hidden').setLabel(_("Automatic slicing"), _("Automatically compute a new toolpath whenever settings are changed; if you disable this option you will need to manually start toolpath computation using 'File -> Start Toolpath Computation' or by pressing 'CTRL+T'."))
  167. setting('youmagine_token', '', str, 'preference', 'hidden')
  168. setting('filament_physical_density', '1240', float, 'preference', 'hidden').setRange(500.0, 3000.0).setLabel(_("Density (kg/m3)"), _("Weight of the filament per m3. Around 1240 for PLA. And around 1040 for ABS. This value is used to estimate the weight if the filament used for the print."))
  169. setting('language', 'English', str, 'preference', 'hidden').setLabel(_('Language'), _('Change the language in which Cura runs. Switching language requires a restart of Cura'))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top