Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Ha <jackha@gmail.com>2018-03-15 16:33:31 +0300
committerJack Ha <jackha@gmail.com>2018-03-15 16:33:31 +0300
commit50f9548da015f3bb24bfdf37b502294fbb01eed0 (patch)
treee808c28ad0cdabae45c7f7a143e08fc037967c3f /plugins/ModelChecker
parentd0609e97e441573e32367306c0ba3ba0f7f235eb (diff)
CURA-4557 setting up plugin
Diffstat (limited to 'plugins/ModelChecker')
-rw-r--r--plugins/ModelChecker/ModelChecker.py38
-rw-r--r--plugins/ModelChecker/__init__.py23
-rw-r--r--plugins/ModelChecker/plugin.json8
3 files changed, 69 insertions, 0 deletions
diff --git a/plugins/ModelChecker/ModelChecker.py b/plugins/ModelChecker/ModelChecker.py
new file mode 100644
index 0000000000..dedfc86938
--- /dev/null
+++ b/plugins/ModelChecker/ModelChecker.py
@@ -0,0 +1,38 @@
+# Copyright (c) 2018 Ultimaker B.V.
+# Cura is released under the terms of the LGPLv3 or higher.
+
+from PyQt5.QtCore import QTimer
+from cura.Scene.CuraSceneNode import CuraSceneNode
+
+from UM.Application import Application
+from UM.Extension import Extension
+from UM.Logger import Logger
+
+
+class ModelChecker(Extension):
+ def __init__(self):
+ super().__init__()
+
+ self._update_timer = QTimer()
+ self._update_timer.setInterval(2000)
+ self._update_timer.setSingleShot(True)
+ self._update_timer.timeout.connect(self.checkObjects)
+
+ self._nodes_to_check = set()
+
+ ## Reacting to an event. ##
+ Application.getInstance().mainWindowChanged.connect(self.logMessage) #When the main window is created, log a message.
+ Application.getInstance().getController().getScene().sceneChanged.connect(self._onSceneChanged)
+
+ ## Adds a message to the log, as an example of how to listen to events.
+ def logMessage(self):
+ Logger.log("i", "This is an example log message. yeaaa")
+
+ def checkObjects(self):
+ Logger.log("d", "############# checking....")
+
+ def _onSceneChanged(self, source):
+ if isinstance(source, CuraSceneNode) and source.callDecoration("isSliceable"):
+ Logger.log("d", "triggurrrr")
+ self._nodes_to_check.add(source)
+ self._update_timer.start()
diff --git a/plugins/ModelChecker/__init__.py b/plugins/ModelChecker/__init__.py
new file mode 100644
index 0000000000..ae4aa7d0c0
--- /dev/null
+++ b/plugins/ModelChecker/__init__.py
@@ -0,0 +1,23 @@
+# Copyright (c) 2017 Ultimaker B.V.
+# This example is released under the terms of the AGPLv3 or higher.
+
+from . import ModelChecker
+
+## Defines additional metadata for the plug-in.
+#
+# Some types of plug-ins require additional metadata, such as which file types
+# they are able to read or the name of the tool they define. In the case of
+# the "Extension" type plug-in, there is no additional metadata though.
+def getMetaData():
+ return {}
+
+## Lets Uranium know that this plug-in exists.
+#
+# This is called when starting the application to find out which plug-ins
+# exist and what their types are. We need to return a dictionary mapping from
+# strings representing plug-in types (in this case "extension") to objects
+# that inherit from PluginObject.
+#
+# \param app The application that the plug-in needs to register with.
+def register(app):
+ return {"extension": ModelChecker.ModelChecker()}
diff --git a/plugins/ModelChecker/plugin.json b/plugins/ModelChecker/plugin.json
new file mode 100644
index 0000000000..db8819a325
--- /dev/null
+++ b/plugins/ModelChecker/plugin.json
@@ -0,0 +1,8 @@
+{
+ "name": "Model Checker",
+ "author": "Ultimaker",
+ "version": "0.1",
+ "api": 4,
+ "description": "Checks models for possible printing issues and give suggestions.",
+ "catalog": "cura"
+}