33#include < memory>
44
55#include < QMetaType>
6+ #include < QPixmap>
7+ #include < QtGui/QColor>
68#include < QtWidgets/QWidget>
79
810#include " Definitions.hpp"
@@ -31,6 +33,19 @@ struct NodeValidationState
3133 QString _stateMessage{" " };
3234};
3335
36+ /* *
37+ * Describes the node status, depending on its current situation
38+ */
39+ enum class NodeProcessingStatus : int {
40+ NoStatus = 0 , // /< No processing status is shown in the Node UI.
41+ Updated = 1 , // /< Node is up to date; its outputs reflect the current inputs and parameters.
42+ Processing = 2 , // /< Node is currently running a computation.
43+ Pending = 3 , // /< Node is out of date and waiting to be recomputed (e.g. manual/queued run).
44+ Empty = 4 , // /< Node has no valid input data; nothing to compute.
45+ Failed = 5 , // /< The last computation ended with an error.
46+ Partial = 6 , // /< Computation finished incompletely; only partial results are available.
47+ };
48+
3449class StyleCollection ;
3550
3651/* *
@@ -68,11 +83,16 @@ class NODE_EDITOR_PUBLIC NodeDelegateModel
6883 // / Validation State will default to Valid, but you can manipulate it by overriding in an inherited class
6984 virtual NodeValidationState validationState () const { return _nodeValidationState; }
7085
86+ // / Returns the curent processing status
87+ virtual NodeProcessingStatus processingStatus () const { return _processingStatus; }
88+
7189 QJsonObject save () const override ;
7290
7391 void load (QJsonObject const &) override ;
7492
75- void setValidatonState (const NodeValidationState &validationState);
93+ void setNodeProcessingStatus (NodeProcessingStatus status);
94+
95+ void setValidationState (const NodeValidationState &validationState);
7696
7797public:
7898 virtual unsigned int nPorts (PortType portType) const = 0;
@@ -85,6 +105,16 @@ class NODE_EDITOR_PUBLIC NodeDelegateModel
85105
86106 void setNodeStyle (NodeStyle const &style);
87107
108+ // / Convenience helper to change the node background color.
109+ void setBackgroundColor (QColor const &color);
110+
111+ QPixmap processingStatusIcon () const ;
112+
113+ void setStatusIcon (NodeProcessingStatus status, const QPixmap &pixmap);
114+
115+ void setStatusIconStyle (ProcessingIconStyle const &style);
116+
117+ public:
88118 virtual void setInData (std::shared_ptr<NodeData> nodeData, PortIndex const portIndex) = 0;
89119
90120 virtual std::shared_ptr<NodeData> outData (PortIndex const port) = 0;
@@ -121,6 +151,16 @@ public Q_SLOTS:
121151
122152 void embeddedWidgetSizeUpdated ();
123153
154+ // / Request an update of the node's UI.
155+ /* *
156+ * Emit this signal whenever some internal state change requires
157+ * the node to be repainted. The containing graph model will
158+ * propagate the update to the scene.
159+ */
160+ void requestNodeUpdate ();
161+
162+ // / Call this function before deleting the data associated with ports.
163+
124164 /* *
125165 * @brief Call this function before deleting the data associated with ports.
126166 * The function notifies the Graph Model and makes it remove and recompute the
@@ -147,8 +187,11 @@ public Q_SLOTS:
147187 NodeStyle _nodeStyle;
148188
149189 NodeValidationState _nodeValidationState;
190+
191+ NodeProcessingStatus _processingStatus{NodeProcessingStatus::NoStatus};
150192};
151193
152194} // namespace QtNodes
153195
154196Q_DECLARE_METATYPE (QtNodes::NodeValidationState)
197+ Q_DECLARE_METATYPE(QtNodes::NodeProcessingStatus)
0 commit comments