Ilya Ashikhmin b257c1a7cf feat(scene): add interactive graphics scene with grid, ports and styled edges
- SVG node items with snap-to-grid dragging; ports appear on focus/hover
  and highlight compatible targets during a connection drag
- Orthogonally routed edge items with line styles, head/tail decorations
  (arrow, circle, diamond, bar), selection halo and title labels; later
  edges jump crossings with arcs when enabled
- Grid background view with cursor-anchored zoom, middle-button pan,
  rubber-band selection and palette drag-and-drop
- Undoable commands: add/move/delete/connect/property/paste with
  clipboard fragments; light/dark/high-contrast themes
- Flow overlay: animated dashes, direction and density follow flow rate

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 23:25:06 +02:00

45 lines
1.3 KiB
C++

#pragma once
#include "core/Types.h"
#include <QGraphicsObject>
namespace diag {
class DiagramScene;
class NetworkModel;
// An edge (pipe/cable) routed orthogonally between two ports. Supports line
// styles, head/tail decorations (arrow, circle, diamond, bar) and an animated
// flow overlay whose direction and density follow the solver result.
class EdgeItem : public QGraphicsObject {
Q_OBJECT
public:
EdgeItem(DiagramScene* scene, QUuid edgeId);
QUuid edgeId() const { return m_id; }
NetworkModel* model() const;
const QList<QPointF>& polyline() const { return m_poly; }
void setRoute(const QList<QPointF>& poly, const QList<QPointF>& hops);
QRectF boundingRect() const override;
QPainterPath shape() const override;
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
QWidget* widget) override;
private:
QPen basePen() const;
void drawDecoration(QPainter* painter, const QString& kind, QPointF tip, QPointF back,
const QColor& color, double width) const;
void drawFlowOverlay(QPainter* painter, const QPainterPath& path, double width) const;
DiagramScene* m_scene;
QUuid m_id;
QList<QPointF> m_poly;
QList<QPointF> m_hops;
QPainterPath m_path;
};
} // namespace diag