Browse Source

CURA-4400 solved merge conflict

Jack Ha 7 years ago
parent
commit
32ce458516

+ 4 - 1
.github/ISSUE_TEMPLATE.md

@@ -6,7 +6,7 @@ Before filing, PLEASE check if the issue already exists (either open or closed)
 Also, please note the application version in the title of the issue. For example: "[3.2.1] Cannot connect to 3rd-party printer". Please do not write thigns like "Request:" or "[BUG]" in the title; this is what labels are for.
 
 It is also helpful to attach a project (.3mf or .curaproject) file and Cura log file so we can debug issues quicker.
-Information about how to find the log file can be found at https://github.com/Ultimaker/Cura/wiki/Cura-Preferences-and-Settings-Locations. To upload a project, we recommend http://wetransfer.com, but other file hosts like Google Drive or Dropbox work well too.
+Information about how to find the log file can be found at https://github.com/Ultimaker/Cura/wiki/Cura-Preferences-and-Settings-Locations. To upload a project, try changing the extension to e.g. .curaproject.3mf.zip so that github accepts uploading the file. Otherwise we recommend http://wetransfer.com, but other file hosts like Google Drive or Dropbox work well too.
 
 Thank you for using Cura!
 -->
@@ -26,6 +26,9 @@ Thank you for using Cura!
 **Display Driver**
 <!--  Video driver name and version -->
 
+**Printer**
+<!-- Which printer was selected in Cura. Please attach project file as .curaproject.3mf.zip -->
+
 **Steps to Reproduce**
 <!-- Add the steps needed that lead up to the issue (replace this text) -->
 

+ 25 - 1
cura/Machines/Models/BaseMaterialsModel.py

@@ -3,6 +3,7 @@
 
 from PyQt5.QtCore import Qt, pyqtSignal, pyqtProperty
 
+from UM.Application import Application
 from UM.Qt.ListModel import ListModel
 
 
@@ -25,6 +26,8 @@ class BaseMaterialsModel(ListModel):
 
     def __init__(self, parent = None):
         super().__init__(parent)
+        self._application = Application.getInstance()
+        self._machine_manager = self._application.getMachineManager()
 
         self.addRoleName(self.RootMaterialIdRole, "root_material_id")
         self.addRoleName(self.IdRole, "id")
@@ -35,12 +38,33 @@ class BaseMaterialsModel(ListModel):
         self.addRoleName(self.ContainerNodeRole, "container_node")
 
         self._extruder_position = 0
+        self._extruder_stack = None
+
+        self._machine_manager.globalContainerChanged.connect(self._updateExtruderStack)
+
+    def _updateExtruderStack(self):
+        global_stack = self._machine_manager.activeMachine
+        if global_stack is None:
+            return
+
+        if self._extruder_stack is not None:
+            self._extruder_stack.pyqtContainersChanged.disconnect(self._update)
+        self._extruder_stack = global_stack.extruders.get(str(self._extruder_position))
+        if self._extruder_stack is not None:
+            self._extruder_stack.pyqtContainersChanged.connect(self._update)
 
     def setExtruderPosition(self, position: int):
         if self._extruder_position != position:
             self._extruder_position = position
+            self._updateExtruderStack()
             self.extruderPositionChanged.emit()
 
     @pyqtProperty(int, fset = setExtruderPosition, notify = extruderPositionChanged)
     def extruderPosition(self) -> int:
-        return self._extruder_positoin
+        return self._extruder_position
+
+    #
+    # This is an abstract method that needs to be implemented by
+    #
+    def _update(self):
+        pass

+ 7 - 0
cura/Machines/Models/BrandMaterialsModel.py

@@ -120,12 +120,19 @@ class BrandMaterialsModel(ListModel):
                 material_type_item = {"name": material_type,
                                       "colors": BaseMaterialsModel(self)}
                 material_type_item["colors"].clear()
+
+                # Sort materials by name
+                material_list = sorted(material_list, key = lambda x: x["name"])
                 material_type_item["colors"].setItems(material_list)
 
                 material_type_item_list.append(material_type_item)
 
+            # Sort material type by name
+            material_type_item_list = sorted(material_type_item_list, key = lambda x: x["name"])
             brand_item["materials"].setItems(material_type_item_list)
 
             brand_item_list.append(brand_item)
 
+        # Sort brand by name
+        brand_item_list = sorted(brand_item_list, key = lambda x: x["name"])
         self.setItems(brand_item_list)

+ 0 - 10
cura/ObjectsModel.py

@@ -19,8 +19,6 @@ class ObjectsModel(ListModel):
 
         self._build_plate_number = -1
 
-        self._stacks_have_errors = None  # type:Optional[bool]
-
     def setActiveBuildPlate(self, nr):
         self._build_plate_number = nr
         self._update()
@@ -69,11 +67,3 @@ class ObjectsModel(ListModel):
     @staticmethod
     def createObjectsModel():
         return ObjectsModel()
-
-    ##  Check if none of the model's stacks contain error states
-    #   The setting applied for the settings per model
-    def stacksHaveErrors(self) -> bool:
-        return bool(self._stacks_have_errors)
-
-    def setStacksHaveErrors(self, value):
-        self._stacks_have_errors = value

+ 3 - 0
cura/PrinterOutput/NetworkedPrinterOutputDevice.py

@@ -219,6 +219,9 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
             reply.uploadProgress.connect(onProgress)
         self._registerOnFinishedCallback(reply, onFinished)
 
+
+        return reply
+
     def postForm(self, target: str, header_data: str, body_data: bytes, onFinished: Optional[Callable[[Any, QNetworkReply], None]], onProgress: Callable = None) -> None:
         post_part = QHttpPart()
         post_part.setHeader(QNetworkRequest.ContentDispositionHeader, header_data)

+ 10 - 10
cura/PrinterOutput/PrinterOutputModel.py

@@ -103,32 +103,32 @@ class PrinterOutputModel(QObject):
             self._head_position = Vector(x, y, z)
             self.headPositionChanged.emit()
 
-    @pyqtProperty("long", "long", "long")
-    @pyqtProperty("long", "long", "long", "long")
+    @pyqtProperty(float, float, float)
+    @pyqtProperty(float, float, float, float)
     def setHeadPosition(self, x, y, z, speed = 3000):
         self.updateHeadPosition(x, y, z)
         self._controller.setHeadPosition(self, x, y, z, speed)
 
-    @pyqtProperty("long")
-    @pyqtProperty("long", "long")
+    @pyqtProperty(float)
+    @pyqtProperty(float, float)
     def setHeadX(self, x, speed = 3000):
         self.updateHeadPosition(x, self._head_position.y, self._head_position.z)
         self._controller.setHeadPosition(self, x, self._head_position.y, self._head_position.z, speed)
 
-    @pyqtProperty("long")
-    @pyqtProperty("long", "long")
+    @pyqtProperty(float)
+    @pyqtProperty(float, float)
     def setHeadY(self, y, speed = 3000):
         self.updateHeadPosition(self._head_position.x, y, self._head_position.z)
         self._controller.setHeadPosition(self, self._head_position.x, y, self._head_position.z, speed)
 
-    @pyqtProperty("long")
-    @pyqtProperty("long", "long")
+    @pyqtProperty(float)
+    @pyqtProperty(float, float)
     def setHeadZ(self, z, speed = 3000):
         self.updateHeadPosition(self._head_position.x, self._head_position.y, z)
         self._controller.setHeadPosition(self, self._head_position.x, self._head_position.y, z, speed)
 
-    @pyqtSlot("long", "long", "long")
-    @pyqtSlot("long", "long", "long", "long")
+    @pyqtSlot(float, float, float)
+    @pyqtSlot(float, float, float, float)
     def moveHead(self, x = 0, y = 0, z = 0, speed = 3000):
         self._controller.moveHead(self, x, y, z, speed)
 

+ 17 - 10
cura/Settings/MachineManager.py

@@ -982,30 +982,38 @@ class MachineManager(QObject):
 
     ## Update current quality type and machine after setting material
     def _updateQualityWithMaterial(self):
-        current_quality = None
+        Logger.log("i", "Updating quality/quality_changes due to material change")
+        current_quality_type = None
         if self._current_quality_group:
-            current_quality = self._current_quality_group.quality_type
-        quality_manager = Application.getInstance()._quality_manager
-        candidate_quality_groups = quality_manager.getQualityGroups(self._global_container_stack)
+            current_quality_type = self._current_quality_group.quality_type
+        candidate_quality_groups = self._quality_manager.getQualityGroups(self._global_container_stack)
         available_quality_types = {qt for qt, g in candidate_quality_groups.items() if g.is_available}
 
+        Logger.log("d", "Current quality type = [%s]", current_quality_type)
         if not self.activeMaterialsCompatible():
+            Logger.log("i", "Active materials are not compatible, setting all qualities to empty (Not Supported).")
             self._setEmptyQuality()
             return
 
         if not available_quality_types:
+            Logger.log("i", "No available quality types found, setting all qualities to empty (Not Supported).")
             self._setEmptyQuality()
             return
 
-        if current_quality in available_quality_types:
-            self._setQualityGroup(candidate_quality_groups[current_quality], empty_quality_changes = False)
+        if current_quality_type in available_quality_types:
+            Logger.log("i", "Current available quality type [%s] is available, applying changes.", current_quality_type)
+            self._setQualityGroup(candidate_quality_groups[current_quality_type], empty_quality_changes = False)
             return
 
+        # The current quality type is not available so we use the preferred quality type if it's available,
+        # otherwise use one of the available quality types.
         quality_type = sorted(list(available_quality_types))[0]
         preferred_quality_type = self._global_container_stack.getMetaDataEntry("preferred_quality_type")
         if preferred_quality_type in available_quality_types:
             quality_type = preferred_quality_type
 
+        Logger.log("i", "The current quality type [%s] is not available, switching to [%s] instead",
+                   current_quality_type, quality_type)
         self._setQualityGroup(candidate_quality_groups[quality_type], empty_quality_changes = True)
 
     def _updateMaterialWithVariant(self, position: Optional[str]):
@@ -1020,9 +1028,8 @@ class MachineManager(QObject):
             current_material_base_name = extruder.material.getMetaDataEntry("base_file")
             current_variant_name = extruder.variant.getMetaDataEntry("name")
 
-            material_manager = Application.getInstance()._material_manager
             material_diameter = self._global_container_stack.getProperty("material_diameter", "value")
-            candidate_materials = material_manager.getAvailableMaterials(
+            candidate_materials = self._material_manager.getAvailableMaterials(
                 self._global_container_stack.definition.getId(),
                 current_variant_name,
                 material_diameter)
@@ -1069,7 +1076,7 @@ class MachineManager(QObject):
 
         # See if we need to show the Discard or Keep changes screen
         if self.hasUserSettings and Preferences.getInstance().getValue("cura/active_mode") == 1:
-            Application.getInstance().discardOrKeepProfileChanges()
+            self._application.discardOrKeepProfileChanges()
 
     @pyqtProperty(QObject, fset = setQualityGroup, notify = activeQualityGroupChanged)
     def activeQualityGroup(self):
@@ -1083,7 +1090,7 @@ class MachineManager(QObject):
 
         # See if we need to show the Discard or Keep changes screen
         if self.hasUserSettings and Preferences.getInstance().getValue("cura/active_mode") == 1:
-            Application.getInstance().discardOrKeepProfileChanges()
+            self._application.discardOrKeepProfileChanges()
 
     @pyqtProperty(QObject, fset = setQualityChangesGroup, notify = activeQualityChangesGroupChanged)
     def activeQualityChangesGroup(self):

+ 3 - 21
cura/Settings/SettingOverrideDecorator.py

@@ -9,8 +9,7 @@ from UM.Signal import Signal, signalemitter
 from UM.Settings.InstanceContainer import InstanceContainer
 from UM.Settings.ContainerRegistry import ContainerRegistry
 from UM.Logger import Logger
-from UM.Settings.Validator import ValidatorState
-from PyQt5.QtCore import QTimer
+
 from UM.Application import Application
 
 from cura.Settings.PerObjectContainerStack import PerObjectContainerStack
@@ -40,10 +39,6 @@ class SettingOverrideDecorator(SceneNodeDecorator):
         self._extruder_stack = ExtruderManager.getInstance().getExtruderStack(0).getId()
 
         self._is_non_printing_mesh = False
-        self._error_check_timer = QTimer()
-        self._error_check_timer.setInterval(250)
-        self._error_check_timer.setSingleShot(True)
-        self._error_check_timer.timeout.connect(self._checkStackForErrors)
 
         self._stack.propertyChanged.connect(self._onSettingChanged)
 
@@ -103,21 +98,8 @@ class SettingOverrideDecorator(SceneNodeDecorator):
         if property_name == "value":
             self._is_non_printing_mesh = self.evaluateIsNonPrintingMesh()
 
-            if not self._is_non_printing_mesh:
-                # self._error_check_timer.start()
-                self._checkStackForErrors()
-        Application.getInstance().getBackend().needsSlicing()
-        Application.getInstance().getBackend().tickle()
-
-    def _checkStackForErrors(self):
-        hasErrors = False;
-        for key in self._stack.getAllKeys():
-            validation_state = self._stack.getProperty(key, "validationState")
-            if validation_state in (ValidatorState.Exception, ValidatorState.MaximumError, ValidatorState.MinimumError):
-                Logger.log("w", "Setting Per Object %s is not valid.", key)
-                hasErrors = True
-                break
-        Application.getInstance().getObjectsModel().setStacksHaveErrors(hasErrors)
+            Application.getInstance().getBackend().needsSlicing()
+            Application.getInstance().getBackend().tickle()
 
     ##  Makes sure that the stack upon which the container stack is placed is
     #   kept up to date.

+ 1 - 5
plugins/CuraEngineBackend/StartSliceJob.py

@@ -136,14 +136,10 @@ class StartSliceJob(Job):
                     self.setResult(StartJobResult.MaterialIncompatible)
                     return
 
-        # Validate settings per selectable model
-        if Application.getInstance().getObjectsModel().stacksHaveErrors():
-            self.setResult(StartJobResult.ObjectSettingError)
-            return
 
         # Don't slice if there is a per object setting with an error value.
         for node in DepthFirstIterator(self._scene.getRoot()):
-            if node.isSelectable():
+            if type(node) is not CuraSceneNode or not node.isSelectable():
                 continue
 
             if self._checkStackForErrors(node.callDecoration("getStack")):

+ 1 - 14
plugins/PerObjectSettingsTool/PerObjectItem.qml

@@ -25,20 +25,7 @@ UM.TooltipArea
 
         onClicked:
         {
-            // Important first set visible and then subscribe
-            // otherwise the setting is not yet in list
-            // For unsubscribe is important first remove the subscription and then
-            // set as invisible
-            if(checked)
-            {
-                addedSettingsModel.setVisible(model.key, checked);
-                UM.ActiveTool.triggerActionWithData("subscribeForSettingValidation", model.key)
-            }
-            else
-            {
-                UM.ActiveTool.triggerActionWithData("unsubscribeForSettingValidation", model.key)
-                addedSettingsModel.setVisible(model.key, checked);
-            }
+            addedSettingsModel.setVisible(model.key, checked);
             UM.ActiveTool.forceUpdate();
         }
     }

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