|
@@ -104,7 +104,8 @@ from cura.Settings.SettingInheritanceManager import SettingInheritanceManager
|
|
|
from cura.Settings.SidebarCustomMenuItemsModel import SidebarCustomMenuItemsModel
|
|
|
from cura.Settings.SimpleModeSettingsManager import SimpleModeSettingsManager
|
|
|
from cura.TaskManagement.OnExitCallbackManager import OnExitCallbackManager
|
|
|
-from cura.UI import CuraSplashScreen, MachineActionManager, PrintInformation
|
|
|
+from cura.UI import CuraSplashScreen, PrintInformation
|
|
|
+from cura.UI.MachineActionManager import MachineActionManager
|
|
|
from cura.UI.AddPrinterPagesModel import AddPrinterPagesModel
|
|
|
from cura.UI.MachineSettingsManager import MachineSettingsManager
|
|
|
from cura.UI.ObjectsModel import ObjectsModel
|
|
@@ -125,6 +126,7 @@ from .Machines.Models.CompatibleMachineModel import CompatibleMachineModel
|
|
|
from .Machines.Models.MachineListModel import MachineListModel
|
|
|
from .Machines.Models.ActiveIntentQualitiesModel import ActiveIntentQualitiesModel
|
|
|
from .Machines.Models.IntentSelectionModel import IntentSelectionModel
|
|
|
+from .PrintOrderManager import PrintOrderManager
|
|
|
from .SingleInstance import SingleInstance
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
@@ -179,6 +181,7 @@ class CuraApplication(QtApplication):
|
|
|
|
|
|
# Variables set from CLI
|
|
|
self._files_to_open = []
|
|
|
+ self._urls_to_open = []
|
|
|
self._use_single_instance = False
|
|
|
|
|
|
self._single_instance = None
|
|
@@ -186,7 +189,7 @@ class CuraApplication(QtApplication):
|
|
|
|
|
|
self._cura_formula_functions = None # type: Optional[CuraFormulaFunctions]
|
|
|
|
|
|
- self._machine_action_manager = None # type: Optional[MachineActionManager.MachineActionManager]
|
|
|
+ self._machine_action_manager: Optional[MachineActionManager] = None
|
|
|
|
|
|
self.empty_container = None # type: EmptyInstanceContainer
|
|
|
self.empty_definition_changes_container = None # type: EmptyInstanceContainer
|
|
@@ -202,6 +205,7 @@ class CuraApplication(QtApplication):
|
|
|
self._container_manager = None
|
|
|
|
|
|
self._object_manager = None
|
|
|
+ self._print_order_manager = None
|
|
|
self._extruders_model = None
|
|
|
self._extruders_model_with_optional = None
|
|
|
self._build_plate_model = None
|
|
@@ -333,7 +337,7 @@ class CuraApplication(QtApplication):
|
|
|
for filename in self._cli_args.file:
|
|
|
url = QUrl(filename)
|
|
|
if url.scheme() in self._supported_url_schemes:
|
|
|
- self._open_url_queue.append(url)
|
|
|
+ self._urls_to_open.append(url)
|
|
|
else:
|
|
|
self._files_to_open.append(os.path.abspath(filename))
|
|
|
|
|
@@ -352,11 +356,11 @@ class CuraApplication(QtApplication):
|
|
|
self.__addAllEmptyContainers()
|
|
|
self.__setLatestResouceVersionsForVersionUpgrade()
|
|
|
|
|
|
- self._machine_action_manager = MachineActionManager.MachineActionManager(self)
|
|
|
+ self._machine_action_manager = MachineActionManager(self)
|
|
|
self._machine_action_manager.initialize()
|
|
|
|
|
|
def __sendCommandToSingleInstance(self):
|
|
|
- self._single_instance = SingleInstance(self, self._files_to_open)
|
|
|
+ self._single_instance = SingleInstance(self, self._files_to_open, self._urls_to_open)
|
|
|
|
|
|
# If we use single instance, try to connect to the single instance server, send commands, and then exit.
|
|
|
# If we cannot find an existing single instance server, this is the only instance, so just keep going.
|
|
@@ -373,9 +377,15 @@ class CuraApplication(QtApplication):
|
|
|
Resources.addExpectedDirNameInData(dir_name)
|
|
|
|
|
|
app_root = os.path.abspath(os.path.join(os.path.dirname(sys.executable)))
|
|
|
- Resources.addSecureSearchPath(os.path.join(app_root, "share", "cura", "resources"))
|
|
|
|
|
|
- Resources.addSecureSearchPath(os.path.join(self._app_install_dir, "share", "cura", "resources"))
|
|
|
+ if platform.system() == "Darwin":
|
|
|
+ Resources.addSecureSearchPath(os.path.join(app_root, "Resources", "share", "cura", "resources"))
|
|
|
+ Resources.addSecureSearchPath(
|
|
|
+ os.path.join(self._app_install_dir, "Resources", "share", "cura", "resources"))
|
|
|
+ else:
|
|
|
+ Resources.addSecureSearchPath(os.path.join(app_root, "share", "cura", "resources"))
|
|
|
+ Resources.addSecureSearchPath(os.path.join(self._app_install_dir, "share", "cura", "resources"))
|
|
|
+
|
|
|
if not hasattr(sys, "frozen"):
|
|
|
cura_data_root = os.environ.get('CURA_DATA_ROOT', None)
|
|
|
if cura_data_root:
|
|
@@ -899,6 +909,7 @@ class CuraApplication(QtApplication):
|
|
|
# initialize info objects
|
|
|
self._print_information = PrintInformation.PrintInformation(self)
|
|
|
self._cura_actions = CuraActions.CuraActions(self)
|
|
|
+ self._print_order_manager = PrintOrderManager(self.getObjectsModel().getNodes)
|
|
|
self.processEvents()
|
|
|
# Initialize setting visibility presets model.
|
|
|
self._setting_visibility_presets_model = SettingVisibilityPresetsModel(self.getPreferences(), parent = self)
|
|
@@ -956,6 +967,8 @@ class CuraApplication(QtApplication):
|
|
|
self.callLater(self._openFile, file_name)
|
|
|
for file_name in self._open_file_queue: # Open all the files that were queued up while plug-ins were loading.
|
|
|
self.callLater(self._openFile, file_name)
|
|
|
+ for url in self._urls_to_open:
|
|
|
+ self.callLater(self._openUrl, url)
|
|
|
for url in self._open_url_queue:
|
|
|
self.callLater(self._openUrl, url)
|
|
|
|
|
@@ -979,6 +992,7 @@ class CuraApplication(QtApplication):
|
|
|
t.setEnabledAxis([ToolHandle.XAxis, ToolHandle.YAxis, ToolHandle.ZAxis])
|
|
|
|
|
|
Selection.selectionChanged.connect(self.onSelectionChanged)
|
|
|
+ self._print_order_manager.printOrderChanged.connect(self._onPrintOrderChanged)
|
|
|
|
|
|
# Set default background color for scene
|
|
|
self.getRenderer().setBackgroundColor(QColor(245, 245, 245))
|
|
@@ -1068,6 +1082,10 @@ class CuraApplication(QtApplication):
|
|
|
def getTextManager(self, *args) -> "TextManager":
|
|
|
return self._text_manager
|
|
|
|
|
|
+ @pyqtSlot(bool)
|
|
|
+ def getWorkplaceDropToBuildplate(self, drop_to_build_plate: bool) ->None:
|
|
|
+ return self._physics.setAppPerModelDropDown(drop_to_build_plate)
|
|
|
+
|
|
|
def getCuraFormulaFunctions(self, *args) -> "CuraFormulaFunctions":
|
|
|
if self._cura_formula_functions is None:
|
|
|
self._cura_formula_functions = CuraFormulaFunctions(self)
|
|
@@ -1094,6 +1112,10 @@ class CuraApplication(QtApplication):
|
|
|
self._object_manager = ObjectsModel(self)
|
|
|
return self._object_manager
|
|
|
|
|
|
+ @pyqtSlot(str, result = "QVariantList")
|
|
|
+ def getSupportedActionMachineList(self, definition_id: str) -> List["MachineAction"]:
|
|
|
+ return self._machine_action_manager.getSupportedActions(self._machine_manager.getDefinitionByMachineId(definition_id))
|
|
|
+
|
|
|
@pyqtSlot(result = QObject)
|
|
|
def getExtrudersModel(self, *args) -> "ExtrudersModel":
|
|
|
if self._extruders_model is None:
|
|
@@ -1129,18 +1151,16 @@ class CuraApplication(QtApplication):
|
|
|
self._setting_inheritance_manager = SettingInheritanceManager.createSettingInheritanceManager()
|
|
|
return self._setting_inheritance_manager
|
|
|
|
|
|
- def getMachineActionManager(self, *args: Any) -> MachineActionManager.MachineActionManager:
|
|
|
+ @pyqtSlot(result = QObject)
|
|
|
+ def getMachineActionManager(self, *args: Any) -> MachineActionManager:
|
|
|
"""Get the machine action manager
|
|
|
|
|
|
We ignore any *args given to this, as we also register the machine manager as qml singleton.
|
|
|
It wants to give this function an engine and script engine, but we don't care about that.
|
|
|
"""
|
|
|
|
|
|
- return cast(MachineActionManager.MachineActionManager, self._machine_action_manager)
|
|
|
+ return self._machine_action_manager
|
|
|
|
|
|
- @pyqtSlot(result = QObject)
|
|
|
- def getMachineActionManagerQml(self)-> MachineActionManager.MachineActionManager:
|
|
|
- return cast(QObject, self._machine_action_manager)
|
|
|
|
|
|
@pyqtSlot(result = QObject)
|
|
|
def getMaterialManagementModel(self) -> MaterialManagementModel:
|
|
@@ -1250,6 +1270,7 @@ class CuraApplication(QtApplication):
|
|
|
self.processEvents()
|
|
|
engine.rootContext().setContextProperty("Printer", self)
|
|
|
engine.rootContext().setContextProperty("CuraApplication", self)
|
|
|
+ engine.rootContext().setContextProperty("PrintOrderManager", self._print_order_manager)
|
|
|
engine.rootContext().setContextProperty("PrintInformation", self._print_information)
|
|
|
engine.rootContext().setContextProperty("CuraActions", self._cura_actions)
|
|
|
engine.rootContext().setContextProperty("CuraSDKVersion", ApplicationMetadata.CuraSDKVersion)
|
|
@@ -1264,7 +1285,7 @@ class CuraApplication(QtApplication):
|
|
|
qmlRegisterSingletonType(IntentManager, "Cura", 1, 6, self.getIntentManager, "IntentManager")
|
|
|
qmlRegisterSingletonType(SettingInheritanceManager, "Cura", 1, 0, self.getSettingInheritanceManager, "SettingInheritanceManager")
|
|
|
qmlRegisterSingletonType(SimpleModeSettingsManager, "Cura", 1, 0, self.getSimpleModeSettingsManagerWrapper, "SimpleModeSettingsManager")
|
|
|
- qmlRegisterSingletonType(MachineActionManager.MachineActionManager, "Cura", 1, 0, self.getMachineActionManagerWrapper, "MachineActionManager")
|
|
|
+ qmlRegisterSingletonType(MachineActionManager, "Cura", 1, 0, self.getMachineActionManagerWrapper, "MachineActionManager")
|
|
|
|
|
|
self.processEvents()
|
|
|
qmlRegisterType(NetworkingUtil, "Cura", 1, 5, "NetworkingUtil")
|
|
@@ -1745,8 +1766,12 @@ class CuraApplication(QtApplication):
|
|
|
Selection.remove(node)
|
|
|
Selection.add(group_node)
|
|
|
|
|
|
+ all_nodes = self.getObjectsModel().getNodes()
|
|
|
+ PrintOrderManager.updatePrintOrdersAfterGroupOperation(all_nodes, group_node, selected_nodes)
|
|
|
+
|
|
|
@pyqtSlot()
|
|
|
def ungroupSelected(self) -> None:
|
|
|
+ all_nodes = self.getObjectsModel().getNodes()
|
|
|
selected_objects = Selection.getAllSelectedObjects().copy()
|
|
|
for node in selected_objects:
|
|
|
if node.callDecoration("isGroup"):
|
|
@@ -1754,21 +1779,30 @@ class CuraApplication(QtApplication):
|
|
|
|
|
|
group_parent = node.getParent()
|
|
|
children = node.getChildren().copy()
|
|
|
- for child in children:
|
|
|
- # Ungroup only 1 level deep
|
|
|
- if child.getParent() != node:
|
|
|
- continue
|
|
|
|
|
|
+ # Ungroup only 1 level deep
|
|
|
+ children_to_ungroup = list(filter(lambda child: child.getParent() == node, children))
|
|
|
+ for child in children_to_ungroup:
|
|
|
# Set the parent of the children to the parent of the group-node
|
|
|
op.addOperation(SetParentOperation(child, group_parent))
|
|
|
|
|
|
# Add all individual nodes to the selection
|
|
|
Selection.add(child)
|
|
|
|
|
|
+ PrintOrderManager.updatePrintOrdersAfterUngroupOperation(all_nodes, node, children_to_ungroup)
|
|
|
op.push()
|
|
|
# Note: The group removes itself from the scene once all its children have left it,
|
|
|
# see GroupDecorator._onChildrenChanged
|
|
|
|
|
|
+ def _onPrintOrderChanged(self) -> None:
|
|
|
+ # update object list
|
|
|
+ scene = self.getController().getScene()
|
|
|
+ scene.sceneChanged.emit(scene.getRoot())
|
|
|
+
|
|
|
+ # reset if already was sliced
|
|
|
+ Application.getInstance().getBackend().needsSlicing()
|
|
|
+ Application.getInstance().getBackend().tickle()
|
|
|
+
|
|
|
def _createSplashScreen(self) -> Optional[CuraSplashScreen.CuraSplashScreen]:
|
|
|
if self._is_headless:
|
|
|
return None
|