4#include <QGraphicsItem>
5#include <QGraphicsSvgItem>
8#include "app_configs.h"
12#include "widgets/settings_manager.h"
22 Type = Types::BASE_NODE
33 explicit NodeBase(
const QString&
id,
const QString&
nodeId, std::shared_ptr<NodeConfig>
config, QGraphicsItem* parent);
52 virtual int type()
const override;
59 virtual QString
nodeId()
const;
66 std::shared_ptr<NodeConfig>
config()
const;
82 virtual QRectF nodeRect()
const;
83 virtual QRectF extraBoundingRect()
const;
98 virtual QRectF
drawingRect(
const QRectF& input)
const;
106 virtual QPainterPath
nodeShape(
const QRectF& bounds)
const;
108 QPainterPath geometricBodyOutlinePath(
const QRectF& drawingBounds)
const;
118 void paintNode(
const QRectF& bounds,
const QColor& background,
const QPen& text, QPainter* painter);
119 void paintNodeBody(
const QRectF& bounds, QPainter* painter);
146 std::shared_ptr<NodeConfig> mConfig;
151 mutable QPainterPath mSvgOutlineCachePath{};
152 mutable QString mSvgOutlineCacheKey{};
153 mutable QRectF mSvgOutlineCacheTarget{};
155 QRectF shapeSvgTargetRect(
const QSvgRenderer* renderer,
const QRectF& drawingBounds)
const;
156 QPainterPath svgSilhouetteOutlinePath(QSvgRenderer* renderer,
const QRectF& drawingBounds)
const;
158 void paintSelectionOutline(QPainter* painter,
const QPen& text,
const QRectF& bounds)
const;
160 QFont labelFont()
const;
161 bool isLabelVisible()
const;
169 virtual void setIcon(
const QString& path,
const QColor& iconColor);
177 virtual void setLabel(
const QString& name, qreal fontSize);
192 virtual void setLabelSize(qreal fontSize,
const QSizeF& boundingSize);
200 virtual void paintLabel(QPainter* painter,
const QRectF& area,
const QPen& pen,
bool elide =
false)
const;
213 bool mPaintLabel =
true;
214 QRectF mScaledBounds;
static const QFont Main
Font constants for the application.
Definition app_configs.h:78
virtual void setLabelSize(qreal fontSize, const QSizeF &boundingSize)
Sets the font size and bounding size for the label.
Definition node_base.cpp:385
virtual void setIcon(const QString &path, const QColor &iconColor)
Sets the icon for the node.
Definition node_base.cpp:401
virtual QString nodeId() const
Retrieves the identifier of the node within its type.
Definition node_base.cpp:49
qreal computeScaleFactor() const
Scaled bounding rectangle of the node.
Definition node_base.cpp:437
virtual QPainterPath nodeShape(const QRectF &bounds) const
Returns the node shape as a QPainterPath.
Definition node_base.cpp:324
QString mLabelText
Bounding rectangle of the node.
Definition node_base.h:211
virtual QRectF drawingRect(const QRectF &input) const
Returns the drawing rectangle based on the input rectangle.
Definition node_base.cpp:93
virtual void setLabel(const QString &name, qreal fontSize)
Sets the label text and font size.
Definition node_base.cpp:371
virtual void settingsChanged(const AppearanceSettings &appearance)
Update the node on setting change.
Definition node_base.cpp:397
virtual QRectF labelBoundingRect() const
Returns the bounding rectangle of the label.
Definition node_base.cpp:79
virtual QString nodeIcon() const
Retrieves the icon path of the node.
Definition node_base.cpp:460
QGraphicsSvgItem * mIconItem
Path to the icon image.
Definition node_base.h:149
QSvgRenderer * mRenderer
Pointer to the SVG icon item.
Definition node_base.h:150
std::shared_ptr< NodeConfig > config() const
Retrieves the configuration settings for the node.
Definition node_base.cpp:54
NodeBase(const QString &id, const QString &nodeId, std::shared_ptr< NodeConfig > config, QGraphicsItem *parent)
Constructs a new NodeBase instance.
Definition node_base.cpp:16
QString id() const
Retrieves the unique identifier of the node.
Definition node_base.cpp:39
virtual QRectF scaledRect() const
Returns the scaled rectangle of the node.
Definition node_base.cpp:88
const QRectF mBounds
Unique identifier of the node.
Definition node_base.h:209
virtual QRectF boundingRect() const override
Returns the bounding rectangle of the node.
Definition node_base.cpp:59
virtual void toggleLabelVisibility(bool forceVisible=false)
Toggles the visibility of the label.
Definition node_base.cpp:391
virtual void setLabelName(const QString &name)
Sets the label text.
Definition node_base.cpp:379
virtual QPixmap nodePixmap() const
Retrieves the pixmap of the node.
Definition node_base.cpp:446
virtual int type() const override
Returns the type of the node.
Definition node_base.cpp:44
virtual void initializeNodeSize()
Called by children after setup to fix size.
Definition node_base.cpp:357
void paintNode(const QRectF &bounds, const QColor &background, const QPen &text, QPainter *painter)
Paints the node using the provided painter.
Definition node_base.cpp:129
virtual void paintLabel(QPainter *painter, const QRectF &area, const QPen &pen, bool elide=false) const
Paints the label using the provided painter.
Definition node_base.cpp:332
QString mIconPath
Configuration settings for the node.
Definition node_base.h:148
Holds appearance settings.
Definition settings_manager.h:50