mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-07-07 21:41:48 +08:00
Create functions that get & set platform activity
The platform activity is determined by whether there is a mesh in the build platform or not Contributes to #128
This commit is contained in:
parent
ae89ef37c0
commit
a5f00f30ca
@ -74,6 +74,7 @@ class CuraApplication(QtApplication):
|
|||||||
self._print_information = None
|
self._print_information = None
|
||||||
self._i18n_catalog = None
|
self._i18n_catalog = None
|
||||||
self._previous_active_tool = None
|
self._previous_active_tool = None
|
||||||
|
self._platform_activity = False
|
||||||
|
|
||||||
self.activeMachineChanged.connect(self._onActiveMachineChanged)
|
self.activeMachineChanged.connect(self._onActiveMachineChanged)
|
||||||
|
|
||||||
@ -215,6 +216,31 @@ class CuraApplication(QtApplication):
|
|||||||
self._previous_active_tool = None
|
self._previous_active_tool = None
|
||||||
|
|
||||||
requestAddPrinter = pyqtSignal()
|
requestAddPrinter = pyqtSignal()
|
||||||
|
activityChanged = pyqtSignal()
|
||||||
|
|
||||||
|
@pyqtProperty(bool, notify = activityChanged)
|
||||||
|
def getPlatformActivity(self):
|
||||||
|
return self._platform_activity
|
||||||
|
|
||||||
|
@pyqtSlot(bool)
|
||||||
|
def setPlatformActivity(self, activity):
|
||||||
|
##Sets the _platform_activity variable on true or false depending on whether there is a mesh on the platform
|
||||||
|
if activity == True:
|
||||||
|
self._platform_activity = activity
|
||||||
|
elif activity == False:
|
||||||
|
nodes = []
|
||||||
|
for node in DepthFirstIterator(self.getController().getScene().getRoot()):
|
||||||
|
if type(node) is not SceneNode or not node.getMeshData():
|
||||||
|
continue
|
||||||
|
nodes.append(node)
|
||||||
|
i = 0
|
||||||
|
for node in nodes:
|
||||||
|
if not node.getMeshData():
|
||||||
|
continue
|
||||||
|
i += 1
|
||||||
|
if i <= 1: ## i == 0 when the meshes are removed using the deleteAll function; i == 1 when the last remaining mesh is removed using the deleteObject function
|
||||||
|
self._platform_activity = activity
|
||||||
|
self.activityChanged.emit()
|
||||||
|
|
||||||
## Remove an object from the scene
|
## Remove an object from the scene
|
||||||
@pyqtSlot("quint64")
|
@pyqtSlot("quint64")
|
||||||
@ -227,6 +253,7 @@ class CuraApplication(QtApplication):
|
|||||||
if object:
|
if object:
|
||||||
op = RemoveSceneNodeOperation(object)
|
op = RemoveSceneNodeOperation(object)
|
||||||
op.push()
|
op.push()
|
||||||
|
self.setPlatformActivity(False)
|
||||||
|
|
||||||
## Create a number of copies of existing object.
|
## Create a number of copies of existing object.
|
||||||
@pyqtSlot("quint64", int)
|
@pyqtSlot("quint64", int)
|
||||||
@ -267,7 +294,6 @@ class CuraApplication(QtApplication):
|
|||||||
if type(node) is not SceneNode or not node.getMeshData():
|
if type(node) is not SceneNode or not node.getMeshData():
|
||||||
continue
|
continue
|
||||||
nodes.append(node)
|
nodes.append(node)
|
||||||
|
|
||||||
if nodes:
|
if nodes:
|
||||||
op = GroupedOperation()
|
op = GroupedOperation()
|
||||||
|
|
||||||
@ -275,6 +301,7 @@ class CuraApplication(QtApplication):
|
|||||||
op.addOperation(RemoveSceneNodeOperation(node))
|
op.addOperation(RemoveSceneNodeOperation(node))
|
||||||
|
|
||||||
op.push()
|
op.push()
|
||||||
|
self.setPlatformActivity(False)
|
||||||
|
|
||||||
## Reset all translation on nodes with mesh data.
|
## Reset all translation on nodes with mesh data.
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user