Skip to content

Commit 3253acf

Browse files
committed
fix undesired changes
1 parent be91633 commit 3253acf

21 files changed

+380
-20
lines changed

external/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
if(BUILD_TESTING)
2-
find_package(Catch2 2.13.7 QUIET)
2+
find_package(Catch2 QUIET)
33

44
if(NOT Catch2_FOUND)
55
add_subdirectory(Catch2)

include/QtNodes/internal/ConnectionGraphicsObject.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <utility>
44

5+
#include <QtCore/QUuid>
56
#include <QtWidgets/QGraphicsObject>
67

78
#include "ConnectionState.hpp"

include/QtNodes/internal/ConnectionState.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include <QtCore/QUuid>
4+
35
#include "Export.hpp"
46

57
#include "Definitions.hpp"

include/QtNodes/internal/DefaultNodePainter.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class NODE_EDITOR_PUBLIC DefaultNodePainter : public AbstractNodePainter
3232

3333
void drawResizeRect(QPainter *painter, NodeGraphicsObject &ngo) const;
3434

35+
void drawProcessingIndicator(QPainter *painter, NodeGraphicsObject &ngo) const;
36+
3537
void drawValidationIcon(QPainter *painter, NodeGraphicsObject &ngo) const;
3638

3739
private:

include/QtNodes/internal/Definitions.hpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,18 @@ Q_NAMESPACE_EXPORT(NODE_EDITOR_PUBLIC)
2222
* Constants used for fetching QVariant data from GraphModel.
2323
*/
2424
enum class NodeRole {
25-
Type = 0, ///< Type of the current node, usually a string.
26-
Position = 1, ///< `QPointF` positon of the node on the scene.
27-
Size = 2, ///< `QSize` for resizable nodes.
28-
CaptionVisible = 3, ///< `bool` for caption visibility.
29-
Caption = 4, ///< `QString` for node caption.
30-
Style = 5, ///< Custom NodeStyle as QJsonDocument
31-
InternalData = 6, ///< Node-stecific user data as QJsonObject
32-
InPortCount = 7, ///< `unsigned int`
33-
OutPortCount = 9, ///< `unsigned int`
34-
Widget = 10, ///< Optional `QWidget*` or `nullptr`
35-
ValidationState = 11 ///< Enum NodeValidationState of the node
25+
Type = 0, ///< Type of the current node, usually a string.
26+
Position = 1, ///< `QPointF` positon of the node on the scene.
27+
Size = 2, ///< `QSize` for resizable nodes.
28+
CaptionVisible = 3, ///< `bool` for caption visibility.
29+
Caption = 4, ///< `QString` for node caption.
30+
Style = 5, ///< Custom NodeStyle as QJsonDocument
31+
InternalData = 6, ///< Node-stecific user data as QJsonObject
32+
InPortCount = 7, ///< `unsigned int`
33+
OutPortCount = 9, ///< `unsigned int`
34+
Widget = 10, ///< Optional `QWidget*` or `nullptr`
35+
ValidationState = 11, ///< Enum NodeValidationState of the node
36+
ProcessingStatus = 12 ///< Enum NodeProcessingStatus of the node
3637
};
3738
Q_ENUM_NS(NodeRole)
3839

include/QtNodes/internal/NodeDelegateModel.hpp

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
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+
3449
class 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

7797
public:
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

154196
Q_DECLARE_METATYPE(QtNodes::NodeValidationState)
197+
Q_DECLARE_METATYPE(QtNodes::NodeProcessingStatus)

include/QtNodes/internal/NodeGraphicsObject.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <QtCore/QUuid>
99
#include <QtWidgets/QGraphicsObject>
1010

11+
#include "NodeState.hpp"
12+
1113
class QGraphicsProxyWidget;
1214

1315
namespace QtNodes {

include/QtNodes/internal/NodeState.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <QtCore/QPointF>
77
#include <QtCore/QPointer>
8+
#include <QtCore/QUuid>
89

910
#include "Definitions.hpp"
1011
#include "Export.hpp"

include/QtNodes/internal/NodeStyle.hpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
11
#pragma once
22

3+
#include <QIcon>
34
#include <QtGui/QColor>
45

56
#include "Export.hpp"
67
#include "Style.hpp"
78

89
namespace QtNodes {
910

11+
/**
12+
* Describes the position of the processing icon on the node ui
13+
*/
14+
enum class ProcessingIconPos {
15+
BottomLeft = 0, /// icon on the bottom left position
16+
BottomRight = 1, /// icon on the bottom right position
17+
};
18+
19+
/**
20+
* Defines the processing icon style;
21+
*/
22+
struct ProcessingIconStyle
23+
{
24+
ProcessingIconPos _pos{ProcessingIconPos::BottomRight};
25+
double _size{20.0};
26+
double _margin{8.0};
27+
int _resolution{64};
28+
};
29+
1030
class NODE_EDITOR_PUBLIC NodeStyle : public Style
1131
{
1232
public:
@@ -26,6 +46,12 @@ class NODE_EDITOR_PUBLIC NodeStyle : public Style
2646

2747
QJsonObject toJson() const override;
2848

49+
/// Set uniform background color for the node.
50+
void setBackgroundColor(QColor const &color);
51+
52+
/// Current uniform background color.
53+
QColor backgroundColor() const;
54+
2955
public:
3056
QColor NormalBoundaryColor;
3157
QColor SelectedBoundaryColor;
@@ -51,5 +77,14 @@ class NODE_EDITOR_PUBLIC NodeStyle : public Style
5177
float ConnectionPointDiameter;
5278

5379
float Opacity;
80+
81+
QIcon statusUpdated{QStringLiteral("://status_icons/updated.svg")};
82+
QIcon statusProcessing{QStringLiteral("://status_icons/processing.svg")};
83+
QIcon statusPending{QStringLiteral("://status_icons/pending.svg")};
84+
QIcon statusInvalid{QStringLiteral("://status_icons/failed.svg")};
85+
QIcon statusEmpty{QStringLiteral("://status_icons/empty.svg")};
86+
QIcon statusPartial{QStringLiteral("://status_icons/partial.svg")};
87+
88+
ProcessingIconStyle processingIconStyle{};
5489
};
5590
} // namespace QtNodes

resources/resources.qrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
<qresource prefix="/">
33
<file>DefaultStyle.json</file>
44
<file>info-tooltip.svg</file>
5+
<file>status_icons/empty.svg</file>
6+
<file>status_icons/failed.svg</file>
7+
<file>status_icons/partial.svg</file>
8+
<file>status_icons/pending.svg</file>
9+
<file>status_icons/processing.svg</file>
10+
<file>status_icons/updated.svg</file>
511
<file>padlock-lock.png</file>
612
<file>padlock-unlock.png</file>
713
</qresource>

0 commit comments

Comments
 (0)