2026-02-23 00:21:10 +03:00
|
|
|
#pragma once
|
|
|
|
|
#include <QGraphicsObject>
|
|
|
|
|
#include <QSet>
|
2026-02-25 18:25:51 +03:00
|
|
|
#include <QColor>
|
2026-02-23 00:21:10 +03:00
|
|
|
|
|
|
|
|
class ArrowItem;
|
|
|
|
|
|
|
|
|
|
// Small movable node that lets several arrows meet at a single point.
|
|
|
|
|
class JunctionItem final : public QGraphicsObject {
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
enum { Type = UserType + 2 };
|
|
|
|
|
explicit JunctionItem(QGraphicsItem* parent = nullptr, int id = -1);
|
|
|
|
|
|
|
|
|
|
QRectF boundingRect() const override;
|
|
|
|
|
void paint(QPainter* p, const QStyleOptionGraphicsItem* opt, QWidget* widget) override;
|
|
|
|
|
int type() const override { return Type; }
|
|
|
|
|
|
|
|
|
|
void addArrow(ArrowItem* a);
|
|
|
|
|
void removeArrow(ArrowItem* a);
|
|
|
|
|
|
|
|
|
|
bool hitTest(const QPointF& scenePos, qreal radius) const;
|
|
|
|
|
int id() const { return m_id; }
|
|
|
|
|
void setId(int id) { m_id = id; }
|
2026-02-25 18:25:51 +03:00
|
|
|
static void setVisualTheme(const QColor& normalColor, const QColor& selectedColor);
|
2026-02-23 00:21:10 +03:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
QVariant itemChange(GraphicsItemChange change, const QVariant& value) override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
qreal m_radius = 5.0;
|
|
|
|
|
int m_id;
|
|
|
|
|
QSet<ArrowItem*> m_arrows;
|
2026-02-25 18:25:51 +03:00
|
|
|
static QColor s_normalColor;
|
|
|
|
|
static QColor s_selectedColor;
|
2026-02-23 00:21:10 +03:00
|
|
|
};
|