mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -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()
|
Loading…
Add table
Add a link
Reference in a new issue