Browse Source

Merge remote-tracking branch 'origin/master' into CURA-3710_setting_visibility_preset

Lipu Fei 7 years ago
parent
commit
0e5c67a38f

+ 2 - 2
Jenkinsfile

@@ -1,5 +1,5 @@
-timeout(time: 2, unit: "HOURS") {
-    parallel_nodes(['linux && cura', 'windows && cura']) {
+parallel_nodes(['linux && cura', 'windows && cura']) {
+    timeout(time: 2, unit: "HOURS") {
         // Prepare building
         stage('Prepare') {
             // Ensure we start with a clean build directory.

+ 1 - 19
README.md

@@ -41,25 +41,7 @@ Please check out [Wiki page](https://github.com/Ultimaker/Cura/wiki/Cura-Setting
 
 Translating Cura
 ----------------
-If you'd like to contribute a translation of Cura, please first look for [any existing translation](https://github.com/Ultimaker/Cura/tree/master/resources/i18n). If your language is already there in the source code but not in Cura's interface, it may be partially translated.
-
-There are four files that need to be translated for Cura:
-1. https://github.com/Ultimaker/Cura/blob/master/resources/i18n/cura.pot
-2. https://github.com/Ultimaker/Cura/blob/master/resources/i18n/fdmextruder.def.json.pot
-3. https://github.com/Ultimaker/Cura/blob/master/resources/i18n/fdmprinter.def.json.pot (This one is the most work.)
-4. https://github.com/Ultimaker/Uranium/blob/master/resources/i18n/uranium.pot
-
-Copy these files and rename them to `*.po` (remove the `t`). Then create the actual translations by filling in the empty `msgstr` entries. These are gettext files, which are plain text so you can open them with any text editor such as Notepad or GEdit, but it is probably easier with a specialised tool such as [POEdit](https://poedit.net/) or [Virtaal](http://virtaal.translatehouse.org/).
-
-Do not hestiate to ask us about a translation or the meaning of some text via Github Issues.
-
-Once the translation is complete, it's probably best to test them in Cura. Use your favourite software to convert the .po file to a .mo file (such as [GetText](https://www.gnu.org/software/gettext/)). Then put the .mo files in the `.../resources/i18n/<language code>/LC_MESSAGES` folder in your Cura installation. Then find your Cura configuration file (next to the log as described above, except on Linux where it is located in `~/.config/cura`) and change the language preference to the name of the folder you just created. Then start Cura. If working correctly, your Cura should now be translated.
-
-To submit your translation, ideally you would make two pull requests where all `*.po` files are located in that same `<language code>` folder in the resources of both the Cura and Uranium repositories. Put `cura.po`, `fdmprinter.def.json.po` and `fdmextruder.def.json.po` in the Cura repository, and put `uranium.po` in the Uranium repository. Then submit the pull requests to Github. For people with less experience with Git, you can also e-mail the translations to the e-mail address listed at the top of the [cura.pot](https://github.com/Ultimaker/Cura/blob/master/resources/i18n/cura.pot) file as the `Report-Msgid-Bugs-To` entry and we'll make sure it gets checked and included.
-
-After the translation is submitted, the Cura maintainers will check for its completeness and check whether it is consistent. We will take special care to look for common mistakes, such as translating mark-up `<message>` code and such. We are often not fluent in every language, so we expect the translator and the international users to make corrections where necessary. Of course, there will always be some mistakes in every translation.
-
-When the next Cura release comes around, some of the texts will have changed and some new texts will have been added. Around the time when the beta is released we will invoke a string freeze, meaning that no developer is allowed to make changes to the texts. Then we will update the translation template `.pot` files and ask all our translators to update their translations. If you are unable to update the translation in time for the actual release, we will remove the language from the drop-down menu in the Preferences window. The translation stays in Cura however, so that someone might pick it up again later and update it with the newest texts. Also, users who had previously selected the language can still continue Cura in their language but English text will appear among the original text.
+Please check out [Wiki page](https://github.com/Ultimaker/Cura/wiki/Translating-Cura) about how to translate Cura into other languages.
 
 License
 ----------------

+ 25 - 2
cura/BuildVolume.py

@@ -195,7 +195,8 @@ class BuildVolume(SceneNode):
 
         return True
 
-    ##  For every sliceable node, update outsideBuildArea
+    ##  For every sliceable node, update node._outside_buildarea
+    #
     def updateNodeBoundaryCheck(self):
         root = Application.getInstance().getController().getScene().getRoot()
         nodes = list(BreadthFirstIterator(root))
@@ -212,7 +213,29 @@ class BuildVolume(SceneNode):
 
         for node in nodes:
             # Need to check group nodes later
-            self.checkBoundsAndUpdate(node, bounds = build_volume_bounding_box)
+            if node.callDecoration("isGroup"):
+                group_nodes.append(node)  # Keep list of affected group_nodes
+
+            if node.callDecoration("isSliceable") or node.callDecoration("isGroup"):
+                node._outside_buildarea = False
+                bbox = node.getBoundingBox()
+
+                # Mark the node as outside the build volume if the bounding box test fails.
+                if build_volume_bounding_box.intersectsBox(bbox) != AxisAlignedBox.IntersectionResult.FullIntersection:
+                    node._outside_buildarea = True
+                    continue
+
+                convex_hull = node.callDecoration("getConvexHull")
+                if convex_hull:
+                    if not convex_hull.isValid():
+                        return
+                    # Check for collisions between disallowed areas and the object
+                    for area in self.getDisallowedAreas():
+                        overlap = convex_hull.intersectsPolygon(area)
+                        if overlap is None:
+                            continue
+                        node._outside_buildarea = True
+                        continue
 
         # Group nodes should override the _outside_buildarea property of their children.
         for group_node in group_nodes:

+ 3 - 3
cura/CrashHandler.py

@@ -189,7 +189,7 @@ class CrashHandler:
 
             json_metadata_file = os.path.join(directory, "plugin.json")
             try:
-                with open(json_metadata_file, "r") as f:
+                with open(json_metadata_file, "r", encoding = "utf-8") as f:
                     try:
                         metadata = json.loads(f.read())
                         module_version = metadata["version"]
@@ -217,9 +217,9 @@ class CrashHandler:
         text_area = QTextEdit()
         tmp_file_fd, tmp_file_path = tempfile.mkstemp(prefix = "cura-crash", text = True)
         os.close(tmp_file_fd)
-        with open(tmp_file_path, "w") as f:
+        with open(tmp_file_path, "w", encoding = "utf-8") as f:
             faulthandler.dump_traceback(f, all_threads=True)
-        with open(tmp_file_path, "r") as f:
+        with open(tmp_file_path, "r", encoding = "utf-8") as f:
             logdata = f.read()
 
         text_area.setText(logdata)

+ 4 - 0
cura/CuraActions.py

@@ -94,6 +94,10 @@ class CuraActions(QObject):
                     removed_group_nodes.append(group_node)
                     op.addOperation(SetParentOperation(remaining_nodes_in_group[0], group_node.getParent()))
                     op.addOperation(RemoveSceneNodeOperation(group_node))
+
+            # Reset the print information
+            Application.getInstance().getController().getScene().sceneChanged.emit(node)
+
         op.push()
 
     ##  Set the extruder that should be used to print the selection.

+ 9 - 10
cura/CuraApplication.py

@@ -1115,8 +1115,9 @@ class CuraApplication(QtApplication):
             Selection.add(node)
 
     ##  Delete all nodes containing mesh data in the scene.
+    #   \param only_selectable. Set this to False to delete objects from all build plates
     @pyqtSlot()
-    def deleteAll(self):
+    def deleteAll(self, only_selectable = True):
         Logger.log("i", "Clearing scene")
         if not self.getController().getToolsEnabled():
             return
@@ -1127,7 +1128,9 @@ class CuraApplication(QtApplication):
                 continue
             if (not node.getMeshData() and not node.callDecoration("getLayerData")) and not node.callDecoration("isGroup"):
                 continue  # Node that doesnt have a mesh and is not a group.
-            if not node.isSelectable():
+            if only_selectable and not node.isSelectable():
+                continue
+            if not node.callDecoration("isSliceable") and not node.callDecoration("getLayerData") and not node.callDecoration("isGroup"):
                 continue  # Only remove nodes that are selectable.
             if node.getParent() and node.getParent().callDecoration("isGroup"):
                 continue  # Grouped nodes don't need resetting as their parent (the group) is resetted)
@@ -1138,16 +1141,12 @@ class CuraApplication(QtApplication):
             for node in nodes:
                 op.addOperation(RemoveSceneNodeOperation(node))
 
+                # Reset the print information
+                self.getController().getScene().sceneChanged.emit(node)
+
             op.push()
             Selection.clear()
 
-        # Reset the print information:
-        self.getController().getScene().sceneChanged.emit(node)
-        # self._print_information.setToZeroPrintInformation(self.getBuildPlateModel().activeBuildPlate)
-
-        # stay on the same build plate
-        #self.getCuraSceneController().setActiveBuildPlate(0)  # Select first build plate
-
     ## Reset all translation on nodes with mesh data.
     @pyqtSlot()
     def resetAllTranslation(self):
@@ -1507,7 +1506,7 @@ class CuraApplication(QtApplication):
 
         self._currently_loading_files.append(f)
         if extension in self._non_sliceable_extensions:
-            self.deleteAll()
+            self.deleteAll(only_selectable = False)
 
         job = ReadMeshJob(f)
         job.finished.connect(self._readMeshFinished)

+ 2 - 1
cura/OneAtATimeIterator.py

@@ -18,12 +18,13 @@ class OneAtATimeIterator(Iterator.Iterator):
     def _fillStack(self):
         node_list = []
         for node in self._scene_node.getChildren():
-            if not isinstance(node, SceneNode):
+            if not issubclass(type(node), SceneNode):
                 continue
 
             if node.callDecoration("getConvexHull"):
                 node_list.append(node)
 
+
         if len(node_list) < 2:
             self._node_stack = node_list[:]
             return 

+ 22 - 7
cura/PrintInformation.py

@@ -8,7 +8,9 @@ from UM.Application import Application
 from UM.Logger import Logger
 from UM.Qt.Duration import Duration
 from UM.Preferences import Preferences
+from UM.Scene.SceneNode import SceneNode
 from UM.Settings.ContainerRegistry import ContainerRegistry
+from cura.Scene.CuraSceneNode import CuraSceneNode
 
 from cura.Settings.ExtruderManager import ExtruderManager
 from typing import Dict
@@ -65,7 +67,7 @@ class PrintInformation(QObject):
         self._backend = Application.getInstance().getBackend()
         if self._backend:
             self._backend.printDurationMessage.connect(self._onPrintDurationMessage)
-        Application.getInstance().getController().getScene().sceneChanged.connect(self.setToZeroPrintInformation)
+        Application.getInstance().getController().getScene().sceneChanged.connect(self._onSceneChanged)
 
         self._base_name = ""
         self._abbr_machine = ""
@@ -395,12 +397,25 @@ class PrintInformation(QObject):
         return result
 
     # Simulate message with zero time duration
-    def setToZeroPrintInformation(self, build_plate_number):
+    def setToZeroPrintInformation(self, build_plate):
+
+        # Construct the 0-time message
         temp_message = {}
-        if build_plate_number not in self._print_time_message_values:
-            self._print_time_message_values[build_plate_number] = {}
-        for key in self._print_time_message_values[build_plate_number].keys():
+        if build_plate not in self._print_time_message_values:
+            self._print_time_message_values[build_plate] = {}
+        for key in self._print_time_message_values[build_plate].keys():
             temp_message[key] = 0
-
         temp_material_amounts = [0]
-        self._onPrintDurationMessage(build_plate_number, temp_message, temp_material_amounts)
+
+        self._onPrintDurationMessage(build_plate, temp_message, temp_material_amounts)
+
+    ##  Listen to scene changes to check if we need to reset the print information
+    def _onSceneChanged(self, scene_node):
+
+        # Ignore any changes that are not related to sliceable objects
+        if not isinstance(scene_node, SceneNode)\
+                or not scene_node.callDecoration("isSliceable")\
+                or not scene_node.callDecoration("getBuildPlateNumber") == self._active_build_plate:
+            return
+
+        self.setToZeroPrintInformation(self._active_build_plate)

+ 1 - 1
cura/PrinterOutput/NetworkedPrinterOutputDevice.py

@@ -100,7 +100,7 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
             if batched_lines_count >= max_chars_per_line:
                 file_data_bytes_list.append(self._compressDataAndNotifyQt("".join(batched_lines)))
                 batched_lines = []
-                batched_lines_count
+                batched_lines_count = 0
 
         # Don't miss the last batch (If any)
         if len(batched_lines) != 0:

+ 0 - 1
cura/Scene/CuraSceneNode.py

@@ -1,6 +1,5 @@
 from UM.Application import Application
 from UM.Logger import Logger
-from UM.Math.AxisAlignedBox import AxisAlignedBox
 from UM.Scene.SceneNode import SceneNode
 from copy import deepcopy
 

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