Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
2edfb0b
Updates fork from upstream
tatatupi Jun 20, 2025
988ce45
wip: adds NodeValidationState info to NodeDelegateModel
tatatupi Jun 22, 2025
1c84750
makes the nodeObject red in case of invalid state and adds a tooltip …
tatatupi Jun 22, 2025
3007c23
adds warning state and adapts calculator example
tatatupi Jun 22, 2025
129d414
adds validation icon and adapts calculation example
tatatupi Jun 22, 2025
e0b0c4a
core improvements to develop node processing status
g-abilio Jul 14, 2025
e002f5b
first commit on the creation of a processing status example
g-abilio Jul 15, 2025
985b638
fixes nodeprocessingstatus cast
tatatupi Jul 15, 2025
3f55e35
creation of random gen example, and fix of icon color
g-abilio Jul 16, 2025
50c6bec
Connect delegate UI update signal
tatatupi Jul 17, 2025
1c09ecf
fix random number node dynamic
g-abilio Jul 17, 2025
50ce760
Merge pull request #5 from fabns-nano/codex/add-signal-for-ui-updates…
g-abilio Jul 17, 2025
f2c120f
clean up test code in multiplication node
g-abilio Jul 17, 2025
965eb15
Add per-node background color API
hudsonmiranda291 Jul 22, 2025
545c018
Updates fork from upstream
Gabrielnmds Aug 5, 2025
c34e6e3
adds version to Catch2 due to compatibility issues
tatatupi Aug 6, 2025
97d48d5
Merge branch 'paceholder:master' into master
tatatupi Sep 2, 2025
89ac7f2
Merge branch 'master' of https://github.com/paceholder/nodeeditor
tatatupi Sep 5, 2025
37c3bf8
solves conflict
tatatupi Sep 10, 2025
b23ecc3
revert unnecessary changes in multiplication model
tatatupi Sep 10, 2025
0a35f76
revert unnecessary changes
tatatupi Sep 10, 2025
a9be092
solve icon size and refactor NodeProcessingStatus code
g-abilio Sep 11, 2025
5530b72
update and merge new code
g-abilio Sep 11, 2025
03e311a
remove duplicate code
g-abilio Sep 11, 2025
a87ceb2
add space to better organize processing status in node display
g-abilio Sep 15, 2025
ae3715b
remove processing value default value
g-abilio Sep 19, 2025
eedc666
fix bugs in node processing status
g-abilio Sep 19, 2025
1298605
add Q_DECLARE_METATYPE to solve linux build problems
g-abilio Sep 24, 2025
47d948f
declaring metatype in the correct place
g-abilio Sep 24, 2025
21b55ac
Merge pull request #6 from fabns-nano/node_processing_status
g-abilio Oct 20, 2025
4f1b23c
fix undocommands module inclusion
g-abilio Dec 3, 2025
87e219b
solve conflicts
g-abilio Dec 3, 2025
dea439b
Merge pull request #7 from fabns-nano/codex/expose-setbackgroundcolor…
g-abilio Dec 3, 2025
cc81264
Adds node nickname functionality (#11)
g-abilio Dec 11, 2025
83426c7
Merge branch 'master' of https://github.com/paceholder/nodeeditor int…
Gabrielnmds Dec 17, 2025
422cdd5
adds zoomFitAll and zoomFitSelected methods
Gabrielnmds Aug 5, 2025
9fdc3e8
refactor(zoom fit): minor code fixes
Gabrielnmds Dec 15, 2025
f2473e7
refactor(zoom fit): fixes code conflicts
Gabrielnmds Dec 17, 2025
bc1b6cb
Refactor(node editor): solve conflicts
Gabrielnmds Dec 17, 2025
2b3ac01
fix uninitialized variable and remove return
g-abilio Jan 7, 2026
891b702
remove bad coupling
g-abilio Jan 7, 2026
8d6c26b
refactoring to simpler code
g-abilio Jan 12, 2026
e828567
solve conflicts
g-abilio Jan 14, 2026
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
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
14 changes: 8 additions & 6 deletions include/QtNodes/internal/AbstractGraphModel.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#pragma once

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

#include <QtCore/QJsonObject>
#include <QtCore/QObject>
#include <QtCore/QVariant>

#include <unordered_set>


namespace QtNodes {

/**
Expand Down Expand Up @@ -51,8 +50,7 @@ class NODE_EDITOR_PUBLIC AbstractGraphModel : public QObject
*/
virtual std::unordered_set<ConnectionId> connections(NodeId nodeId,
PortType portType,
PortIndex index) const
= 0;
PortIndex index) const = 0;

/// Checks if two nodes with the given `connectionId` are connected.
virtual bool connectionExists(ConnectionId const connectionId) const = 0;
Expand Down Expand Up @@ -132,8 +130,10 @@ class NODE_EDITOR_PUBLIC AbstractGraphModel : public QObject
* @returns Port Data Type, Port Data, Connection Policy, Port
* Caption.
*/
virtual QVariant portData(NodeId nodeId, PortType portType, PortIndex index, PortRole role) const
= 0;
virtual QVariant portData(NodeId nodeId,
PortType portType,
PortIndex index,
PortRole role) const = 0;

/**
* A utility function that unwraps the `QVariant` value returned from the
Expand Down Expand Up @@ -188,6 +188,8 @@ class NODE_EDITOR_PUBLIC AbstractGraphModel : public QObject

virtual bool loopsEnabled() const { return true; }

virtual bool nodeZoomFitMenu(NodeId) { return false; }

public:
/**
* Function clears connections attached to the ports that are scheduled to be
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
6 changes: 5 additions & 1 deletion include/QtNodes/internal/BasicGraphicsScene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <tuple>
#include <unordered_map>


class QUndoStack;

namespace QtNodes {
Expand Down Expand Up @@ -112,6 +111,8 @@ class NODE_EDITOR_PUBLIC BasicGraphicsScene : public QGraphicsScene
*/
virtual QMenu *createSceneMenu(QPointF const scenePos);

QMenu *createZoomMenu(QPointF const scenePos);

Q_SIGNALS:
void modified(BasicGraphicsScene *);
void nodeMoved(NodeId const nodeId, QPointF const &newLocation);
Expand All @@ -125,6 +126,9 @@ class NODE_EDITOR_PUBLIC BasicGraphicsScene : public QGraphicsScene

/// Signal allows showing custom context menu upon clicking a node.
void nodeContextMenu(NodeId const nodeId, QPointF const pos);
/// Signals to call Graphics View's zoomFit methods
void zoomFitAllClicked();
void zoomFitSelectedClicked();

private:
/**
Expand Down
13 changes: 10 additions & 3 deletions include/QtNodes/internal/DataFlowGraphModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@
#include <QJsonObject>

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

namespace QtNodes {

class NODE_EDITOR_PUBLIC DataFlowGraphModel : public AbstractGraphModel, public Serializable
class NODE_EDITOR_PUBLIC DataFlowGraphModel
: public AbstractGraphModel
, public Serializable
{
Q_OBJECT

Expand Down Expand Up @@ -43,7 +47,6 @@ class NODE_EDITOR_PUBLIC DataFlowGraphModel : public AbstractGraphModel, public

NodeId addNode(QString const nodeType) override;


bool connectionPossible(ConnectionId const connectionId) const override;

void addConnection(ConnectionId const connectionId) override;
Expand Down Expand Up @@ -75,7 +78,6 @@ class NODE_EDITOR_PUBLIC DataFlowGraphModel : public AbstractGraphModel, public

void loadNode(QJsonObject const &nodeJson) override;


// From Serializable
QJsonObject save() const override;

Expand All @@ -101,6 +103,8 @@ class NODE_EDITOR_PUBLIC DataFlowGraphModel : public AbstractGraphModel, public
/// Loops do not make any sense in uni-direction data propagation
bool loopsEnabled() const override { return false; }

bool nodeZoomFitMenu(NodeId) override;

Q_SIGNALS:
void inPortDataWasSet(NodeId const, PortType const, PortIndex const);

Expand Down Expand Up @@ -137,6 +141,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
10 changes: 10 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 @@ -58,6 +61,10 @@ public Q_SLOTS:

virtual void onPasteObjects();

void zoomFitAll();

void zoomFitSelected();

Q_SIGNALS:
void scaleChanged(double scale);

Expand Down Expand Up @@ -93,5 +100,8 @@ public Q_SLOTS:

QPointF _clickPos;
ScaleRange _scaleRange;

QLineEdit *_labelEdit = nullptr;
NodeId _editingNodeId = InvalidNodeId;
};
} // namespace QtNodes
17 changes: 16 additions & 1 deletion include/QtNodes/internal/NodeDelegateModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

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

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

namespace QtNodes {

Expand Down Expand Up @@ -83,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 Down Expand Up @@ -132,6 +141,10 @@ class NODE_EDITOR_PUBLIC NodeDelegateModel

virtual bool resizable() const { return false; }

bool zoomFitMenu() const { return _zoomFitMenu; }

void setZoomFitMenu(bool state) { _zoomFitMenu = state; }

public Q_SLOTS:
virtual void inputConnectionCreated(ConnectionId const &) {}
virtual void inputConnectionDeleted(ConnectionId const &) {}
Expand Down Expand Up @@ -188,6 +201,8 @@ public Q_SLOTS:
NodeValidationState _nodeValidationState;

NodeProcessingStatus _processingStatus{NodeProcessingStatus::NoStatus};

bool _zoomFitMenu{false};
};

} // namespace QtNodes
Expand Down
2 changes: 1 addition & 1 deletion include/QtNodes/internal/UndoCommands.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include "Definitions.hpp"
#include "Export.hpp"

#include <QUndoCommand>
#include <QtCore/QJsonObject>
#include <QtCore/QPointF>
#include <QUndoCommand>

#include <unordered_set>

Expand Down
Loading