T553: Fixed job name

This commit is contained in:
Victor Larchenko 2016-10-21 15:26:34 +06:00 committed by Youness Alaoui
parent 4ba8033c2a
commit 9da00563e5
2 changed files with 32 additions and 28 deletions

View file

@ -49,6 +49,8 @@ class PrintInformation(QObject):
self._material_lengths = [] self._material_lengths = []
self._material_weights = [] self._material_weights = []
self._pre_sliced = False
self._backend = Application.getInstance().getBackend() self._backend = Application.getInstance().getBackend()
if self._backend: if self._backend:
self._backend.printDurationMessage.connect(self._onPrintDurationMessage) self._backend.printDurationMessage.connect(self._onPrintDurationMessage)
@ -122,7 +124,9 @@ class PrintInformation(QObject):
def createJobName(self, base_name): def createJobName(self, base_name):
base_name = self._stripAccents(base_name) base_name = self._stripAccents(base_name)
self._setAbbreviatedMachineName() self._setAbbreviatedMachineName()
if Preferences.getInstance().getValue("cura/jobname_prefix"): if self._pre_sliced:
return "Pre-sliced_" + base_name
elif Preferences.getInstance().getValue("cura/jobname_prefix"):
return self._abbr_machine + "_" + base_name return self._abbr_machine + "_" + base_name
else: else:
return base_name return base_name

View file

@ -58,35 +58,33 @@ class GCODEReader(MeshReader):
except: except:
return None return None
def onSceneChanged(self, obj): def parent_changed(self, node):
if node.getParent() is None:
scene = Application.getInstance().getController().getScene() scene = Application.getInstance().getController().getScene()
def findAny(): def findAny():
for node in DepthFirstIterator(scene.getRoot()): for node1 in DepthFirstIterator(scene.getRoot()):
if hasattr(node, "gcode"): if hasattr(node1, "gcode") and getattr(node1, "gcode") is True:
return True return True
return False return False
if not findAny():
# Preferences.getInstance().setValue("cura/jobname_prefix", True)
backend = Application.getInstance().getBackend() backend = Application.getInstance().getBackend()
if not findAny():
backend._pauseSlicing = False backend._pauseSlicing = False
Application.getInstance().setHideSettings(False) Application.getInstance().setHideSettings(False)
#Application.getInstance().getPrintInformation()._setAbbreviatedMachineName() Application.getInstance().getPrintInformation()._pre_sliced = False
else: else:
backend = Application.getInstance().getBackend()
backend._pauseSlicing = True backend._pauseSlicing = True
backend.backendStateChange.emit(3) backend.backendStateChange.emit(3)
Application.getInstance().getPrintInformation()._abbr_machine = "Pre-sliced" Application.getInstance().getPrintInformation()._pre_sliced = True
Application.getInstance().setHideSettings(True) Application.getInstance().setHideSettings(True)
def read(self, file_name): def read(self, file_name):
scene_node = None scene_node = None
extension = os.path.splitext(file_name)[1] extension = os.path.splitext(file_name)[1]
if extension.lower() in self._supported_extensions: if extension.lower() in self._supported_extensions:
scene = Application.getInstance().getController().getScene()
scene.sceneChanged.connect(self.onSceneChanged)
# for node in DepthFirstIterator(scene.getRoot()): # for node in DepthFirstIterator(scene.getRoot()):
# if node.callDecoration("getLayerData"): # if node.callDecoration("getLayerData"):
# node.getParent().removeChild(node) # node.getParent().removeChild(node)
@ -245,7 +243,12 @@ class GCODEReader(MeshReader):
decorator.setLayerData(layer_mesh) decorator.setLayerData(layer_mesh)
scene_node.addDecorator(decorator) scene_node.addDecorator(decorator)
Application.getInstance().getPrintInformation()._abbr_machine = "Pre-sliced" Application.getInstance().getPrintInformation()._pre_sliced = True
scene_node.parentChanged.connect(self.parent_changed)
scene_node_parent = Application.getInstance().getBuildVolume() scene_node_parent = Application.getInstance().getBuildVolume()
scene_node.setParent(scene_node_parent) scene_node.setParent(scene_node_parent)
@ -256,6 +259,8 @@ class GCODEReader(MeshReader):
scene_node.setPosition(Vector(-machine_width / 2, 0, machine_depth / 2)) scene_node.setPosition(Vector(-machine_width / 2, 0, machine_depth / 2))
# mesh_builder = MeshBuilder() # mesh_builder = MeshBuilder()
# mesh_builder.setFileName(file_name) # mesh_builder.setFileName(file_name)
# #
@ -264,11 +269,6 @@ class GCODEReader(MeshReader):
# scene_node.setMeshData(mesh_builder.build()) # scene_node.setMeshData(mesh_builder.build())
# scene_node.setMeshData(MeshData(file_name=file_name)) # scene_node.setMeshData(MeshData(file_name=file_name))
Preferences.getInstance().setValue("cura/jobname_prefix", True)
view = Application.getInstance().getController().getActiveView() view = Application.getInstance().getController().getActiveView()
if view.getPluginId() == "LayerView": if view.getPluginId() == "LayerView":
view.resetLayerData() view.resetLayerData()