Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e1d7023
improves NodeValidationState struct
tatatupi Jun 23, 2025
2e91091
qt6 for linux-gcc
tatatupi Jun 23, 2025
39518ac
Adds node nickname functionality
Gabrielnmds Jul 12, 2025
76447d7
Adjust label layout
tatatupi Jul 22, 2025
fe633d0
improve caption and nickname dynamic
g-abilio Jul 23, 2025
67c7184
Merge pull request #8 from fabns-nano/codex/improve-nickname-position…
g-abilio Jul 23, 2025
6402dd8
Add editable nickname label
tatatupi Jul 25, 2025
a10c9a9
add correct caption dynamic, as well as labelEdit max size
g-abilio Jul 25, 2025
ef789fd
fix alignment issues between nickname and node caption
g-abilio Aug 4, 2025
cba54f9
solves conflict
tatatupi Sep 11, 2025
7d62954
revert workflows change
tatatupi Sep 11, 2025
da5cc88
fix segfault detected in dataflowgraphmodel tests
g-abilio Sep 12, 2025
436efe0
produces optional nickname structure and adds example
g-abilio Sep 18, 2025
7f338be
fix typo in spacing method and attribute
g-abilio Sep 18, 2025
67a191d
uniformizes icon files attributes
tatatupi Nov 11, 2025
a41ce83
removes commented code
tatatupi Nov 11, 2025
97c0c94
improves processing status icon resolution
tatatupi Nov 13, 2025
0156e5f
solves situations where icons should not appear
g-abilio Nov 13, 2025
8832922
adds docstring to each nodeprocessingstatus
g-abilio Nov 13, 2025
582cc45
adds possibility to change the node processing status icon style
tatatupi Nov 13, 2025
e73aaf4
moves all status logic to NodeStyle
tatatupi Nov 13, 2025
89eb02f
removes unnecessary code
tatatupi Nov 13, 2025
90ccd88
adds declaration of QPixmap
tatatupi Nov 13, 2025
5d30a5d
solve conflicts
g-abilio Dec 10, 2025
a973ef0
pull new node_processing_status and solve conflicts
g-abilio Dec 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/calculator/LongProcessingRandomNumber.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class RandomNumberModel : public MathOperationDataModel
RandomNumberModel() {
this->setNodeProcessingStatus(QtNodes::NodeProcessingStatus::Empty);


QObject::connect(this, &NodeDelegateModel::computingStarted, this, [this]() {
if (_number1.lock() && _number2.lock()) {
this->setNodeProcessingStatus(
Expand Down
4 changes: 1 addition & 3 deletions examples/calculator/NumberDisplayDataModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

NumberDisplayDataModel::NumberDisplayDataModel()
: _label{nullptr}
{
this->setNodeProcessingStatus(QtNodes::NodeProcessingStatus::NoStatus);
}
{}

unsigned int NumberDisplayDataModel::nPorts(PortType portType) const
{
Expand Down
4 changes: 1 addition & 3 deletions examples/calculator/NumberSourceDataModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
NumberSourceDataModel::NumberSourceDataModel()
: _lineEdit{nullptr}
, _number(std::make_shared<DecimalData>(0.0))
{
this->setNodeProcessingStatus(QtNodes::NodeProcessingStatus::NoStatus);
}
{}

QJsonObject NumberSourceDataModel::save() const
{
Expand Down
2 changes: 2 additions & 0 deletions examples/styles/models.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class MyDataModel : public NodeDelegateModel

QString name() const override { return QString("MyDataModel"); }

bool labelEditable() const override { return true; }

public:
QJsonObject save() const override
{
Expand Down
17 changes: 13 additions & 4 deletions include/QtNodes/internal/AbstractNodeGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ class NODE_EDITOR_PUBLIC AbstractNodeGeometry
/// Port position in node's coordinate system.
virtual QPointF portPosition(NodeId const nodeId,
PortType const portType,
PortIndex const index) const
= 0;
PortIndex const index) const = 0;

/// A convenience function using the `portPosition` and a given transformation.
virtual QPointF portScenePosition(NodeId const nodeId,
Expand All @@ -48,8 +47,7 @@ class NODE_EDITOR_PUBLIC AbstractNodeGeometry
/// Defines where to draw port label. The point corresponds to a font baseline.
virtual QPointF portTextPosition(NodeId const nodeId,
PortType const portType,
PortIndex const portIndex) const
= 0;
PortIndex const portIndex) const = 0;

/**
* Defines where to start drawing the caption. The point corresponds to a font
Expand All @@ -60,6 +58,15 @@ class NODE_EDITOR_PUBLIC AbstractNodeGeometry
/// Caption rect is needed for estimating the total node size.
virtual QRectF captionRect(NodeId const nodeId) const = 0;

/**
* Defines where to start drawing the label. The point corresponds to a font
* baseline.
*/
virtual QPointF labelPosition(NodeId const nodeId) const = 0;

/// Caption rect is needed for estimating the total node size.
virtual QRectF labelRect(NodeId const nodeId) const = 0;

/// Position for an embedded widget. Return any value if you don't embed.
virtual QPointF widgetPosition(NodeId const nodeId) const = 0;

Expand All @@ -69,6 +76,8 @@ class NODE_EDITOR_PUBLIC AbstractNodeGeometry

virtual QRect resizeHandleRect(NodeId const nodeId) const = 0;

virtual int getPortSpacing() = 0;

protected:
AbstractGraphModel &_graphModel;
};
Expand Down
5 changes: 5 additions & 0 deletions include/QtNodes/internal/DataFlowGraphModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <QJsonObject>

#include <memory>
#include <unordered_map>
#include <QString>

namespace QtNodes {

Expand Down Expand Up @@ -137,6 +139,9 @@ private Q_SLOTS:
std::unordered_set<ConnectionId> _connectivity;

mutable std::unordered_map<NodeId, NodeGeometryData> _nodeGeometryData;

std::unordered_map<NodeId, QString> _labels;
std::unordered_map<NodeId, bool> _labelsVisible;
};

} // namespace QtNodes
9 changes: 8 additions & 1 deletion include/QtNodes/internal/DefaultHorizontalNodeGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,21 @@ class NODE_EDITOR_PUBLIC DefaultHorizontalNodeGeometry : public AbstractNodeGeom
QPointF portTextPosition(NodeId const nodeId,
PortType const portType,
PortIndex const PortIndex) const override;

QPointF captionPosition(NodeId const nodeId) const override;

QRectF captionRect(NodeId const nodeId) const override;

QPointF labelPosition(const NodeId nodeId) const override;

QRectF labelRect(NodeId const nodeId) const override;

QPointF widgetPosition(NodeId const nodeId) const override;

QRect resizeHandleRect(NodeId const nodeId) const override;

int getPortSpacing() override { return _portSpacing; }

private:
QRectF portTextRect(NodeId const nodeId,
PortType const portType,
Expand All @@ -52,7 +59,7 @@ class NODE_EDITOR_PUBLIC DefaultHorizontalNodeGeometry : public AbstractNodeGeom
// constness of the Node.

mutable unsigned int _portSize;
unsigned int _portSpasing;
unsigned int _portSpacing;
mutable QFontMetrics _fontMetrics;
mutable QFontMetrics _boldFontMetrics;
};
Expand Down
2 changes: 2 additions & 0 deletions include/QtNodes/internal/DefaultNodePainter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class NODE_EDITOR_PUBLIC DefaultNodePainter : public AbstractNodePainter

void drawNodeCaption(QPainter *painter, NodeGraphicsObject &ngo) const;

void drawNodeLabel(QPainter *painter, NodeGraphicsObject &ngo) const;

void drawEntryLabels(QPainter *painter, NodeGraphicsObject &ngo) const;

void drawResizeRect(QPainter *painter, NodeGraphicsObject &ngo) const;
Expand Down
8 changes: 7 additions & 1 deletion include/QtNodes/internal/DefaultVerticalNodeGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@ class NODE_EDITOR_PUBLIC DefaultVerticalNodeGeometry : public AbstractNodeGeomet

QRectF captionRect(NodeId const nodeId) const override;

QPointF labelPosition(const NodeId nodeId) const override;

QRectF labelRect(NodeId const nodeId) const override;

QPointF widgetPosition(NodeId const nodeId) const override;

QRect resizeHandleRect(NodeId const nodeId) const override;

int getPortSpacing() override { return _portSpacing; }

private:
QRectF portTextRect(NodeId const nodeId,
PortType const portType,
Expand All @@ -54,7 +60,7 @@ class NODE_EDITOR_PUBLIC DefaultVerticalNodeGeometry : public AbstractNodeGeomet
// constness of the Node.

mutable unsigned int _portSize;
unsigned int _portSpasing;
unsigned int _portSpacing;
mutable QFontMetrics _fontMetrics;
mutable QFontMetrics _boldFontMetrics;
};
Expand Down
34 changes: 19 additions & 15 deletions include/QtNodes/internal/Definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,27 @@ NODE_EDITOR_PUBLIC Q_NAMESPACE
Q_NAMESPACE_EXPORT(NODE_EDITOR_PUBLIC)
#endif

/**
/**
* Constants used for fetching QVariant data from GraphModel.
*/
enum class NodeRole {
Type = 0, ///< Type of the current node, usually a string.
Position = 1, ///< `QPointF` positon of the node on the scene.
Size = 2, ///< `QSize` for resizable nodes.
CaptionVisible = 3, ///< `bool` for caption visibility.
Caption = 4, ///< `QString` for node caption.
Style = 5, ///< Custom NodeStyle as QJsonDocument
InternalData = 6, ///< Node-stecific user data as QJsonObject
InPortCount = 7, ///< `unsigned int`
OutPortCount = 9, ///< `unsigned int`
Widget = 10, ///< Optional `QWidget*` or `nullptr`
ValidationState = 11, ///< Enum NodeValidationState of the node
ProcessingStatus = 12 ///< Enum NodeProcessingStatus of the node
};
enum class NodeRole {
Type = 0, ///< Type of the current node, usually a string.
Position = 1, ///< `QPointF` positon of the node on the scene.
Size = 2, ///< `QSize` for resizable nodes.
CaptionVisible = 3, ///< `bool` for caption visibility.
Caption = 4, ///< `QString` for node caption.
Style = 5, ///< Custom NodeStyle as QJsonDocument
InternalData = 6, ///< Node-stecific user data as QJsonObject
InPortCount = 7, ///< `unsigned int`
OutPortCount = 9, ///< `unsigned int`
Widget = 10, ///< Optional `QWidget*` or `nullptr`
ValidationState = 11, ///< Enum NodeValidationState of the node
LabelVisible = 12, ///< `bool` for label visibility.
ProcessingStatus = 13, ///< Enum NodeProcessingStatus of the node
Label = 14, ///< `QString` for node label.
LabelEditable = 15, ///< `bool` to indicate label editing support.
};

Q_ENUM_NS(NodeRole)

/**
Expand Down
6 changes: 6 additions & 0 deletions include/QtNodes/internal/GraphicsView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

#include <QtWidgets/QGraphicsView>

#include "Definitions.hpp"
#include "Export.hpp"

class QLineEdit;

namespace QtNodes {

class BasicGraphicsScene;
Expand Down Expand Up @@ -93,5 +96,8 @@ public Q_SLOTS:

QPointF _clickPos;
ScaleRange _scaleRange;

QLineEdit *_labelEdit = nullptr;
NodeId _editingNodeId = InvalidNodeId;
};
} // namespace QtNodes
38 changes: 27 additions & 11 deletions include/QtNodes/internal/NodeDelegateModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
#include <memory>

#include <QMetaType>
#include <QPixmap>
#include <QtWidgets/QWidget>

#include "Definitions.hpp"
#include "Export.hpp"
#include "NodeData.hpp"
#include "NodeStyle.hpp"
#include <QtGui/QColor>
#include "Serializable.hpp"
#include <QtGui/QColor>

namespace QtNodes {

Expand All @@ -33,16 +34,16 @@ struct NodeValidationState
};

/**
* Describes the node status, depending on its current situation
*/
* Describes the node status, depending on its current situation
*/
enum class NodeProcessingStatus : int {
NoStatus = 0, ///
Updated = 1, ///
Processing = 2, ///
Pending = 3, ///
Empty = 4, ///
Failed = 5, ///
Partial = 6, ///
NoStatus = 0, ///< No processing status is shown in the Node UI.
Updated = 1, ///< Node is up to date; its outputs reflect the current inputs and parameters.
Processing = 2, ///< Node is currently running a computation.
Pending = 3, ///< Node is out of date and waiting to be recomputed (e.g. manual/queued run).
Empty = 4, ///< Node has no valid input data; nothing to compute.
Failed = 5, ///< The last computation ended with an error.
Partial = 6, ///< Computation finished incompletely; only partial results are available.
};

class StyleCollection;
Expand Down Expand Up @@ -82,6 +83,15 @@ class NODE_EDITOR_PUBLIC NodeDelegateModel
/// Validation State will default to Valid, but you can manipulate it by overriding in an inherited class
virtual NodeValidationState validationState() const { return _nodeValidationState; }

/// Nicknames can be assigned to nodes and shown in GUI
virtual QString label() const { return QString(); }

/// It is possible to hide the nickname in GUI
virtual bool labelVisible() const { return true; }

/// Controls whether the label can be edited or not
virtual bool labelEditable() const { return false; }

/// Returns the curent processing status
virtual NodeProcessingStatus processingStatus() const { return _processingStatus; }

Expand All @@ -106,6 +116,12 @@ class NODE_EDITOR_PUBLIC NodeDelegateModel
/// Convenience helper to change the node background color.
void setBackgroundColor(QColor const &color);

QPixmap processingStatusIcon() const;

void setStatusIcon(NodeProcessingStatus status, const QPixmap &pixmap);

void setStatusIconStyle(ProcessingIconStyle const &style);

public:
virtual void setInData(std::shared_ptr<NodeData> nodeData, PortIndex const portIndex) = 0;

Expand Down Expand Up @@ -180,7 +196,7 @@ public Q_SLOTS:

NodeValidationState _nodeValidationState;

NodeProcessingStatus _processingStatus;
NodeProcessingStatus _processingStatus{NodeProcessingStatus::NoStatus};
};

} // namespace QtNodes
Expand Down
19 changes: 0 additions & 19 deletions include/QtNodes/internal/NodeGraphicsObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ class NodeGraphicsObject : public QGraphicsObject

void updateQWidgetEmbedPos();

void updateStatusIconSize() const;

const QIcon processingStatusIcon() const;

QRect statusIconRect() const;

QSize statusIconSize() const;

protected:
void paint(QPainter *painter,
QStyleOptionGraphicsItem const *option,
Expand Down Expand Up @@ -90,16 +82,5 @@ class NodeGraphicsObject : public QGraphicsObject

// either nullptr or owned by parent QGraphicsItem
QGraphicsProxyWidget *_proxyWidget;

mutable bool _statusIconActive;

mutable QSize _statusIconSize;

const QIcon _statusUpdated{"://status_icons/updated.svg"};
const QIcon _statusProcessing{"://status_icons/processing.svg"};
const QIcon _statusPending{"://status_icons/pending.svg"};
const QIcon _statusInvalid{"://status_icons/failed.svg"};
const QIcon _statusEmpty{"://status_icons/empty.svg"};
const QIcon _statusPartial{"://status_icons/partial.svg"};
};
} // namespace QtNodes
29 changes: 29 additions & 0 deletions include/QtNodes/internal/NodeStyle.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,32 @@
#pragma once

#include <QIcon>
#include <QtGui/QColor>

#include "Export.hpp"
#include "Style.hpp"

namespace QtNodes {

/**
* Describes the position of the processing icon on the node ui
*/
enum class ProcessingIconPos {
BottomLeft = 0, /// icon on the bottom left position
BottomRight = 1, /// icon on the bottom right position
};

/**
* Defines the processing icon style;
*/
struct ProcessingIconStyle
{
ProcessingIconPos _pos{ProcessingIconPos::BottomRight};
double _size{20.0};
double _margin{8.0};
int _resolution{64};
};

class NODE_EDITOR_PUBLIC NodeStyle : public Style
{
public:
Expand Down Expand Up @@ -57,5 +77,14 @@ class NODE_EDITOR_PUBLIC NodeStyle : public Style
float ConnectionPointDiameter;

float Opacity;

QIcon statusUpdated{QStringLiteral("://status_icons/updated.svg")};
QIcon statusProcessing{QStringLiteral("://status_icons/processing.svg")};
QIcon statusPending{QStringLiteral("://status_icons/pending.svg")};
QIcon statusInvalid{QStringLiteral("://status_icons/failed.svg")};
QIcon statusEmpty{QStringLiteral("://status_icons/empty.svg")};
QIcon statusPartial{QStringLiteral("://status_icons/partial.svg")};

ProcessingIconStyle processingIconStyle{};
};
} // namespace QtNodes
Loading
Loading