mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
CURA-4557 setting up plugin
This commit is contained in:
parent
d0609e97e4
commit
50f9548da0
3 changed files with 69 additions and 0 deletions
38
plugins/ModelChecker/ModelChecker.py
Normal file
38
plugins/ModelChecker/ModelChecker.py
Normal file
|
@ -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()
|
23
plugins/ModelChecker/__init__.py
Normal file
23
plugins/ModelChecker/__init__.py
Normal file
|
@ -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()}
|
8
plugins/ModelChecker/plugin.json
Normal file
8
plugins/ModelChecker/plugin.json
Normal file
|
@ -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"
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue