5#include <QGraphicsEllipseItem>
6#include <QGraphicsItem>
10#include "control_widget.h"
13#include "transition.h"
15#include "widgets/controls/canvas_control_widget.h"
19class QGraphicsSceneMouseEvent;
20class QGraphicsSceneHoverEvent;
42 NodeItem(
const QString&
id, std::shared_ptr<NodeSaveInfo> info,
const QPointF& initialPosition, std::shared_ptr<NodeConfig> nodeConfig,
43 QGraphicsItem* parent =
nullptr);
55 int type()
const override;
62 VoidResult
start()
override;
70 QRectF sceneNodeRect()
const;
77 return mControlActive && mControlWidget && qobject_cast<T*>(mControlWidget->controlWidget()) !=
nullptr;
80 void highlight(
const QColor& color,
const QString& message,
int durationMs = 1000);
81 void dismissHighlight();
83 void showSimulationControls(maki::ControlWidget*
controls,
const QColor& highlightColor);
85 void dismissControl();
93 QPainterPath
shape()
const override;
102 void paint(QPainter* painter,
const QStyleOptionGraphicsItem* style, QWidget* widget)
override;
137 QVector<ControlsConfig>
controls()
const;
144 QVector<std::shared_ptr<IParameter>>
properties()
const;
158 Types::LibraryTypes
function()
const;
174 void setProperty(
const QString& key,
const maki::Value& value);
195 QVector<NodeItem*>
children()
const;
210 QVector<std::shared_ptr<IParameter>>
fields()
const;
227 VoidResult
setField(
const QString& key,
const QJsonObject& property);
236 VoidResult
setField(
const QString& key, std::shared_ptr<PropertyInfo> property);
258 QVector<std::shared_ptr<IFlow>>
flowConfigs()
const;
260 QVector<std::shared_ptr<IFlow>> eventConfigs()
const;
262 QVector<std::shared_ptr<IFlow>> allEventFlowConfigs()
const;
291 QVector<Flow*>
flows()
const;
300 Flow*
createFlow(
const QString& flowName, std::shared_ptr<FlowSaveInfo> info);
351 std::function<void(
NodeItem* item)> nodeModified;
352 std::function<void(
Flow* flow,
NodeItem* item)> flowAdded;
353 std::function<void(
NodeItem* item)> nodeMoved;
354 std::function<void(
NodeItem* item,
bool enter)> nodeHovered;
407 void hoverEnterEvent(QGraphicsSceneHoverEvent* event)
override;
408 void hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
override;
417 QVariant
itemChange(GraphicsItemChange change,
const QVariant& value)
override;
420 std::shared_ptr<NodeSaveInfo> mStorage;
427 bool mControlActive =
false;
450 QSizeF
clampSize(qreal width, qreal height)
const;
459 QPointF
clampPosInside(
const QRectF& inner,
const QRectF& childSceneRect)
const;
476 void ensureMainFlowExists();
Definition canvas_message.h:8
Configuration for a flow or process.
Definition config.h:70
Represents a flow in the system.
Definition flow.h:17
Configuration for help information.
Definition config.h:147
virtual std::shared_ptr< NodeConfig > config() const
Retrieves the configuration settings for the node.
Definition node_base.cpp:57
NodeBase(const QString &id, const QString &nodeId, std::shared_ptr< NodeConfig > config, QGraphicsItem *parent)
Constructs a new NodeBase instance.
Definition node_base.cpp:19
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
Handles mouse release events for this item.
Definition node.cpp:624
Types::LibraryTypes function() const
Returns the library type associated with this node's function.
Definition node.cpp:90
int type() const override
Returns the type of this item.
Definition node.cpp:85
Flow * getFlow(const QString &flowId) const
Gets a flow by its ID.
Definition node.cpp:789
friend QDataStream & operator<<(QDataStream &out, const NodeItem &config)
Saves the state of this NodeItem to a QDataStream.
void updateExtrasPosition()
Size of the node when resizing started.
Definition node.cpp:710
void setProperty(const QString &key, const maki::Value &value)
Sets a property with a given key and value.
Definition node.cpp:372
friend QDataStream & operator>>(QDataStream &in, NodeItem &config)
Loads the state of a NodeItem from a QDataStream.
QSizeF mSize
Base scale for the node.
Definition node.h:430
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override
Handles changes to the item's properties.
Definition node.cpp:659
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
Handles mouse press events for this item.
Definition node.cpp:607
QVector< std::shared_ptr< IParameter > > fields() const
Returns a list of fields associated with this node.
Definition node.cpp:339
bool mIsResizing
Last known position of the node.
Definition node.h:434
CanvasMessage * mHighlightMessage
List of child nodes.
Definition node.h:425
VoidResult start() override
Starts the node.
Definition node.cpp:114
QPointF edgePointToward(const QPointF &targetScenePos) const
Calculates an edge point toward a target scene position.
Definition node.cpp:727
QPointF mDragStartPos
Current size of the node.
Definition node.h:431
QPointF mResizeStartMousePos
Flag indicating if the node is being resized.
Definition node.h:435
void addParent(NodeItem *node)
Adds a parent node to this item.
Definition node.cpp:441
const PropertyInfo * getProperty(const QString &key) const
Gets a property by key.
Definition node.cpp:364
QString nodeName() const
Returns the name of the node.
Definition node.cpp:95
QVector< TransitionConfig > configTransitions() const
Returns a list of configured transitions.
Definition node.cpp:741
QPointF mLastPosition
Position where dragging started.
Definition node.h:432
void applySize(const QSizeF &size)
Applies a new size to the node.
Definition node.cpp:493
void deleteFlow(const QString &flowId)
Deletes a flow by its ID.
Definition node.cpp:798
QPointF clampPosInside(const QRectF &inner, const QRectF &childSceneRect) const
Clamps a position inside an inner rectangle.
Definition node.cpp:514
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
Handles mouse move events for this item.
Definition node.cpp:581
NodeItem * parentNode() const
Returns the parent node of this item.
Definition node.cpp:468
QSizeF clampSize(qreal width, qreal height) const
Clamps a size within valid limits.
Definition node.cpp:532
HelpConfig help() const
Returns help configuration for this node.
Definition node.cpp:478
QVector< std::shared_ptr< IFlow > > flowConfigs() const
Returns a list of events associated with this node.
Definition node.cpp:349
QVector< NodeItem * > mChildrenNodes
Parent node of this item, if any.
Definition node.h:424
NodeItem * mParentNode
List of flows associated with this node.
Definition node.h:423
void childRemoved(NodeItem *child)
Handles when a child is removed from this item.
Definition node.cpp:462
QString behaviour() const
Returns the behavior of the node.
Definition node.cpp:473
void renameNode(const QString &name)
Renames the node to a new name.
VoidResult setField(const QString &key, const QJsonObject &property)
Sets a field with a given key and JSON object.
Definition node.cpp:400
void addChild(NodeItem *node, std::shared_ptr< NodeSaveInfo > info)
Adds a child node with the given save information.
Definition node.cpp:453
void removeField(const QString &key)
Removes a field by key.
Definition node.cpp:428
NodeItem(const QString &id, std::shared_ptr< NodeSaveInfo > info, const QPointF &initialPosition, std::shared_ptr< NodeConfig > nodeConfig, QGraphicsItem *parent=nullptr)
Constructs a new NodeItem with the given parameters.
Definition node.cpp:26
qreal baseScale() const
Returns the base scale for this node.
Definition node.cpp:109
QVector< ControlsConfig > controls() const
Returns the controls configuration for this node.
Definition node.cpp:359
QSizeF mResizeStartSize
Mouse position when resizing started.
Definition node.h:436
QVector< NodeItem * > children() const
Returns a list of child nodes.
Definition node.cpp:436
QString nodeType() const
Returns the type of the node.
Definition node.cpp:103
void setEvent(int index, const FlowConfig &event)
Sets an event at the given index with the provided FlowConfig.
Definition node.cpp:389
QVector< PropertyConfig > configurationProperties() const
Returns the configuration properties of the node.
Definition node.cpp:329
NodeSaveInfo saveInfo() const
Returns the savable information for this node.
Definition node.cpp:722
void fitInsideParent(qreal padding)
Fits this node inside its parent with optional padding.
Definition node.cpp:555
QRectF nodeRect() const override
Returns the bounding rectangle for this item.
Definition node.cpp:122
QVector< Flow * > mFlows
Save information for the node.
Definition node.h:422
QRectF parentInnerSceneRect(qreal padding) const
Returns the inner scene rectangle of the parent, optionally padded.
Definition node.cpp:483
QVector< std::shared_ptr< IParameter > > properties() const
Returns the properties of the node.
Definition node.cpp:334
QPainterPath shape() const override
Returns the shape of this item.
Definition node.cpp:324
void updateFlow()
Updates all flows associated with this node.
Definition node.cpp:804
QVector< Flow * > flows() const
Returns a list of flows associated with this node.
Definition node.cpp:746
PropertyInfo getField(const QString &key) const
Gets a property info by key.
Definition node.cpp:420
void paint(QPainter *painter, const QStyleOptionGraphicsItem *style, QWidget *widget) override
Paints the item using the given painter.
Definition node.cpp:315
void updatePosition(const QPointF &position)
Updates the position of the node.
Definition node.cpp:694
Flow * createFlow(const QString &flowName, std::shared_ptr< FlowSaveInfo > info)
Creates a new flow with the given name and save information.
Definition node.cpp:751
Represents a node that can be saved and loaded.
Definition node_info.h:17
Represents a property with configuration and options.
Definition property_info.h:16
Definition canvas_control_widget.h:25