Browse Source

Merge branch 'feature_intent' into feature_intent_container_tree

Diego Prado Gesto 5 years ago
parent
commit
bca68c6db0

+ 0 - 33
cura/CuraActions.py

@@ -75,39 +75,6 @@ class CuraActions(QObject):
             operation.addOperation(center_operation)
         operation.push()
 
-    # Rotate the selection, so that the face that the mouse-pointer is on, faces the build-plate.
-    @pyqtSlot()
-    def bottomFaceSelection(self) -> None:
-        selected_face = Selection.getSelectedFace()
-        if not selected_face:
-            Logger.log("e", "Bottom face operation shouldn't have been called without a selected face.")
-            return
-
-        original_node, face_id = selected_face
-        meshdata = original_node.getMeshDataTransformed()
-        if not meshdata or face_id < 0 or face_id > Selection.getMaxFaceSelectionId():
-            return
-
-        rotation_point, face_normal = meshdata.getFacePlane(face_id)
-        rotation_point_vector = Vector(rotation_point[0], rotation_point[1], rotation_point[2])
-        face_normal_vector = Vector(face_normal[0], face_normal[1], face_normal[2])
-        rotation_quaternion = Quaternion.rotationTo(face_normal_vector.normalized(), Vector(0.0, -1.0, 0.0))
-
-        operation = GroupedOperation()
-        current_node = None  # type: Optional[SceneNode]
-        for node in Selection.getAllSelectedObjects():
-            current_node = node
-            parent_node = current_node.getParent()
-            while parent_node and parent_node.callDecoration("isGroup"):
-                current_node = parent_node
-                parent_node = current_node.getParent()
-        if current_node is None:
-            return
-
-        rotate_operation = RotateOperation(current_node, rotation_quaternion, rotation_point_vector)
-        operation.addOperation(rotate_operation)
-        operation.push()
-
     ##  Multiply all objects in the selection
     #
     #   \param count The number of times to multiply the selection.

+ 1 - 0
cura/PreviewPass.py

@@ -64,6 +64,7 @@ class PreviewPass(RenderPass):
                 self._shader.setUniformValue("u_ambientColor", [0.1, 0.1, 0.1, 1.0])
                 self._shader.setUniformValue("u_specularColor", [0.6, 0.6, 0.6, 1.0])
                 self._shader.setUniformValue("u_shininess", 20.0)
+                self._shader.setUniformValue("u_faceId", -1)  # Don't render any selected faces in the preview.
 
         if not self._non_printing_shader:
             if self._non_printing_shader:

+ 11 - 0
cura/Settings/GlobalStack.py

@@ -303,6 +303,17 @@ class GlobalStack(CuraContainerStack):
             Logger.log("w", "Firmware file %s not found.", hex_file)
             return ""
 
+    def getName(self) -> str:
+        return self._metadata.get("group_name", self._metadata.get("name", ""))
+
+    def setName(self, name: "str") -> None:
+        super().setName(name)
+
+    nameChanged = pyqtSignal()
+    name = pyqtProperty(str, fget=getName, fset=setName, notify=nameChanged)
+
+
+
 ## private:
 global_stack_mime = MimeType(
     name = "application/x-cura-globalstack",

+ 6 - 7
cura/Settings/MachineManager.py

@@ -1317,19 +1317,18 @@ class MachineManager(QObject):
         # Get the definition id corresponding to this machine name
         machine_definition_id = CuraContainerRegistry.getInstance().findDefinitionContainers(name = machine_name)[0].getId()
         # Try to find a machine with the same network key
-        metadata_filter = {"group_id": self._global_container_stack.getMetaDataEntry("group_id"),
-                           "um_network_key": self.activeMachineNetworkKey(),
-                           }
+        metadata_filter = {"group_id": self._global_container_stack.getMetaDataEntry("group_id")}
         new_machine = self.getMachine(machine_definition_id, metadata_filter = metadata_filter)
         # If there is no machine, then create a new one and set it to the non-hidden instance
         if not new_machine:
             new_machine = CuraStackBuilder.createMachine(machine_definition_id + "_sync", machine_definition_id)
             if not new_machine:
                 return
-            new_machine.setMetaDataEntry("group_id", self._global_container_stack.getMetaDataEntry("group_id"))
-            new_machine.setMetaDataEntry("um_network_key", self.activeMachineNetworkKey())
-            new_machine.setMetaDataEntry("group_name", self.activeMachineNetworkGroupName)
-            new_machine.setMetaDataEntry("connection_type", self._global_container_stack.getMetaDataEntry("connection_type"))
+            
+            for metadata_key in self._global_container_stack.getMetaData():
+                if metadata_key in new_machine.getMetaData():
+                    continue  # Don't copy the already preset stuff.
+                new_machine.setMetaDataEntry(metadata_key, self._global_container_stack.getMetaDataEntry(metadata_key))
         else:
             Logger.log("i", "Found a %s with the key %s. Let's use it!", machine_name, self.activeMachineNetworkKey())
 

+ 3 - 3
plugins/SolidView/SolidView.py

@@ -140,9 +140,9 @@ class SolidView(View):
                             1.0
                         ]
 
-                        # Color the currently selected face-id.
-                        face = Selection.getSelectedFace()
-                        uniforms["selected_face"] = (Selection.getMaxFaceSelectionId() + 1) if not face or node != face[0] else face[1]
+                        # Color the currently selected face-id. (Disable for now.)
+                        #face = Selection.getHoverFace()
+                        uniforms["hover_face"] = -1 #if not face or node != face[0] else face[1]
                     except ValueError:
                         pass
 

+ 8 - 8
plugins/UM3NetworkPrinting/resources/qml/MonitorPrintJobProgressBar.qml

@@ -20,7 +20,7 @@ Item
     property var printJob: null
 
     width: childrenRect.width
-    height: 18 * screenScaleFactor // TODO: Theme!
+    height: UM.Theme.getSize("monitor_text_line").height
 
     UM.ProgressBar
     {
@@ -31,7 +31,7 @@ Item
             left: parent.left
         }
         value: printJob ? printJob.progress : 0
-        width: UM.Theme.getSize("monitor_column").width
+        width: UM.Theme.getSize("monitor_progress_bar").width
     }
 
     Label
@@ -40,16 +40,16 @@ Item
         anchors
         {
             left: progressBar.right
-            leftMargin: 18 * screenScaleFactor // TODO: Theme!
+            leftMargin: UM.Theme.getSize("monitor_margin").width
             verticalCenter: parent.verticalCenter
         }
         text: printJob ? Math.round(printJob.progress * 100) + "%" : "0%"
         color: printJob && printJob.isActive ? UM.Theme.getColor("monitor_text_primary") : UM.Theme.getColor("monitor_text_disabled")
         width: contentWidth
-        font: UM.Theme.getFont("medium") // 14pt, regular
+        font: UM.Theme.getFont("default") // 12pt, regular
 
         // FIXED-LINE-HEIGHT:
-        height: 18 * screenScaleFactor // TODO: Theme!
+        height: UM.Theme.getSize("monitor_text_line").height
         verticalAlignment: Text.AlignVCenter
         renderType: Text.NativeRendering
     }
@@ -59,11 +59,11 @@ Item
         anchors
         {
             left: percentLabel.right
-            leftMargin: 18 * screenScaleFactor // TODO: Theme!
+            leftMargin: UM.Theme.getSize("monitor_margin").width
             verticalCenter: parent.verticalCenter
         }
         color: UM.Theme.getColor("monitor_text_primary")
-        font: UM.Theme.getFont("medium") // 14pt, regular
+        font: UM.Theme.getFont("default") // 12pt, regular
         text:
         {
             if (!printJob)
@@ -103,7 +103,7 @@ Item
         width: contentWidth
 
         // FIXED-LINE-HEIGHT:
-        height: 18 * screenScaleFactor // TODO: Theme!
+        height: UM.Theme.getSize("monitor_text_line").height
         verticalAlignment: Text.AlignVCenter
         renderType: Text.NativeRendering
     }

+ 12 - 2
plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDeviceManager.py

@@ -1,10 +1,11 @@
 # Copyright (c) 2019 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
-from typing import Dict, List, Optional
 
+from typing import Dict, List, Optional
 from PyQt5.QtCore import QTimer
 
 from UM import i18nCatalog
+from UM.Logger import Logger  # To log errors talking to the API.
 from UM.Signal import Signal
 from cura.API import Account
 from cura.CuraApplication import CuraApplication
@@ -13,6 +14,7 @@ from cura.Settings.GlobalStack import GlobalStack
 from .CloudApiClient import CloudApiClient
 from .CloudOutputDevice import CloudOutputDevice
 from ..Models.Http.CloudClusterResponse import CloudClusterResponse
+from ..Messages.CloudPrinterDetectedMessage import CloudPrinterDetectedMessage
 
 
 ## The cloud output device manager is responsible for using the Ultimaker Cloud APIs to manage remote clusters.
@@ -36,7 +38,7 @@ class CloudOutputDeviceManager:
         # Persistent dict containing the remote clusters for the authenticated user.
         self._remote_clusters = {}  # type: Dict[str, CloudOutputDevice]
         self._account = CuraApplication.getInstance().getCuraAPI().account  # type: Account
-        self._api = CloudApiClient(self._account, on_error=lambda error: print(error))
+        self._api = CloudApiClient(self._account, on_error = lambda error: Logger.log("e", str(error)))
         self._account.loginStateChanged.connect(self._onLoginStateChanged)
 
         # Create a timer to update the remote cluster list
@@ -108,6 +110,7 @@ class CloudOutputDeviceManager:
         )
         self._remote_clusters[device.getId()] = device
         self.discoveredDevicesChanged.emit()
+        self._checkIfNewClusterWasAdded(device.clusterData.cluster_id)
         self._connectToActiveMachine()
 
     def _onDiscoveredDeviceUpdated(self, cluster_data: CloudClusterResponse) -> None:
@@ -179,3 +182,10 @@ class CloudOutputDeviceManager:
         output_device_manager = CuraApplication.getInstance().getOutputDeviceManager()
         if device.key not in output_device_manager.getOutputDeviceIds():
             output_device_manager.addOutputDevice(device)
+
+    ## Checks if Cura has a machine stack (printer) for the given cluster ID and shows a message if it hasn't.
+    def _checkIfNewClusterWasAdded(self, cluster_id: str) -> None:
+        container_registry = CuraApplication.getInstance().getContainerRegistry()
+        cloud_machines = container_registry.findContainersMetadata(**{self.META_CLUSTER_ID: "*"})  # all cloud machines
+        if not any(machine[self.META_CLUSTER_ID] == cluster_id for machine in cloud_machines):
+            CloudPrinterDetectedMessage().show()

+ 33 - 0
plugins/UM3NetworkPrinting/src/Messages/CloudPrinterDetectedMessage.py

@@ -0,0 +1,33 @@
+# Copyright (c) 2019 Ultimaker B.V.
+# Cura is released under the terms of the LGPLv3 or higher.
+from UM import i18nCatalog
+from UM.Message import Message
+
+
+I18N_CATALOG = i18nCatalog("cura")
+
+
+## Message shown when a new printer was added to your account but not yet in Cura.
+class CloudPrinterDetectedMessage(Message):
+
+    # Singleton used to prevent duplicate messages of this type at the same time.
+    __is_visible = False
+
+    def __init__(self) -> None:
+        super().__init__(
+            title=I18N_CATALOG.i18nc("@info:title", "New cloud printers found"),
+            text=I18N_CATALOG.i18nc("@info:message", "New printers have been found connected to your account, "
+                                                     "you can find them in your list of discovered printers."),
+            lifetime=10,
+            dismissable=True
+        )
+
+    def show(self) -> None:
+        if CloudPrinterDetectedMessage.__is_visible:
+            return
+        super().show()
+        CloudPrinterDetectedMessage.__is_visible = True
+
+    def hide(self, send_signal = True) -> None:
+        super().hide(send_signal)
+        CloudPrinterDetectedMessage.__is_visible = False

+ 3 - 1
plugins/UM3NetworkPrinting/src/Network/LocalClusterOutputDevice.py

@@ -1,5 +1,6 @@
 # Copyright (c) 2019 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
+
 from typing import Optional, Dict, List, Callable, Any
 
 from PyQt5.QtGui import QDesktopServices
@@ -8,6 +9,7 @@ from PyQt5.QtNetwork import QNetworkReply
 
 from UM.FileHandler.FileHandler import FileHandler
 from UM.i18n import i18nCatalog
+from UM.Logger import Logger
 from UM.Scene.SceneNode import SceneNode
 from cura.PrinterOutput.NetworkedPrinterOutputDevice import AuthState
 from cura.PrinterOutput.PrinterOutputDevice import ConnectionType
@@ -167,5 +169,5 @@ class LocalClusterOutputDevice(UltimakerNetworkedPrinterOutputDevice):
     ## Get the API client instance.
     def _getApiClient(self) -> ClusterApiClient:
         if not self._cluster_api:
-            self._cluster_api = ClusterApiClient(self.address, on_error=lambda error: print(error))
+            self._cluster_api = ClusterApiClient(self.address, on_error = lambda error: Logger.log("e", str(error)))
         return self._cluster_api

+ 2 - 1
plugins/UM3NetworkPrinting/src/Network/LocalClusterOutputDeviceManager.py

@@ -1,5 +1,6 @@
 # Copyright (c) 2019 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
+
 from typing import Dict, Optional, Callable, List
 
 from UM import i18nCatalog
@@ -66,7 +67,7 @@ class LocalClusterOutputDeviceManager:
 
     ## Add a networked printer manually by address.
     def addManualDevice(self, address: str, callback: Optional[Callable[[bool, str], None]] = None) -> None:
-        api_client = ClusterApiClient(address, lambda error: print(error))
+        api_client = ClusterApiClient(address, lambda error: Logger.log("e", str(error)))
         api_client.getSystem(lambda status: self._onCheckManualDeviceResponse(address, status, callback))
 
     ## Remove a manually added networked printer.

Some files were not shown because too many files changed in this diff