Changeset View
Changeset View
Standalone View
Standalone View
src/part/canvasedge.h
Show All 18 Lines | |||||
19 | /* This file was callgraphview.h, part of KCachegrind. | 19 | /* This file was callgraphview.h, part of KCachegrind. | ||
20 | Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer@gmx.de> | 20 | Copyright (C) 2003 Josef Weidendorfer <Josef.Weidendorfer@gmx.de> | ||
21 | 21 | | |||
22 | KCachegrind is free software; you can redistribute it and/or | 22 | KCachegrind is free software; you can redistribute it and/or | ||
23 | modify it under the terms of the GNU General Public | 23 | modify it under the terms of the GNU General Public | ||
24 | License as published by the Free Software Foundation, version 2. | 24 | License as published by the Free Software Foundation, version 2. | ||
25 | */ | 25 | */ | ||
26 | 26 | | |||
27 | | ||||
28 | #ifndef CANVAS_EDGE_H | 27 | #ifndef CANVAS_EDGE_H | ||
29 | #define CANVAS_EDGE_H | 28 | #define CANVAS_EDGE_H | ||
30 | 29 | | |||
31 | #include <QGraphicsScene> | | |||
32 | #include <QGraphicsPathItem> | | |||
33 | #include <QAbstractGraphicsShapeItem> | 30 | #include <QAbstractGraphicsShapeItem> | ||
34 | #include <QWidget> | | |||
35 | #include <QMap> | | |||
36 | #include <QFont> | 31 | #include <QFont> | ||
32 | #include <QGraphicsPathItem> | ||||
33 | #include <QGraphicsScene> | ||||
34 | #include <QMap> | ||||
35 | #include <QWidget> | ||||
37 | 36 | | |||
38 | #include "graphexporter.h" | 37 | #include "graphexporter.h" | ||
39 | 38 | | |||
40 | | ||||
41 | class QMenu; | 39 | class QMenu; | ||
42 | 40 | | |||
43 | struct DotRenderOp; | 41 | struct DotRenderOp; | ||
44 | 42 | | |||
45 | /* | 43 | /* | ||
46 | * Canvas Items: | 44 | * Canvas Items: | ||
47 | * - CanvasNode (Rectangular Area) | 45 | * - CanvasNode (Rectangular Area) | ||
48 | * - CanvasEdge (Spline curve) | 46 | * - CanvasEdge (Spline curve) | ||
49 | * - CanvasEdgeLabel (Label for edges) | 47 | * - CanvasEdgeLabel (Label for edges) | ||
50 | * - CanvasEdgeArrow (Arrows at the end of the edge spline) | 48 | * - CanvasEdgeArrow (Arrows at the end of the edge spline) | ||
51 | */ | 49 | */ | ||
52 | namespace KGraphViewer | 50 | namespace KGraphViewer | ||
53 | { | 51 | { | ||
54 | | ||||
55 | class CanvasNode; | 52 | class CanvasNode; | ||
56 | class CanvasEdge; | 53 | class CanvasEdge; | ||
57 | class GraphEdge; | 54 | class GraphEdge; | ||
58 | class DotGraphView; | 55 | class DotGraphView; | ||
59 | 56 | | |||
60 | class CanvasEdge : public QObject, public QAbstractGraphicsShapeItem | 57 | class CanvasEdge : public QObject, public QAbstractGraphicsShapeItem | ||
61 | { | 58 | { | ||
62 | Q_OBJECT | 59 | Q_OBJECT | ||
63 | public: | 60 | public: | ||
64 | explicit CanvasEdge(DotGraphView* v, GraphEdge*, | 61 | explicit CanvasEdge(DotGraphView *v, GraphEdge *, qreal scaleX, qreal scaleY, qreal xMargin, qreal yMargin, qreal gh, qreal wdhcf, qreal hdvcf, QGraphicsItem *parent = nullptr); | ||
65 | qreal scaleX, qreal scaleY, | | |||
66 | qreal xMargin, qreal yMargin, qreal gh, | | |||
67 | qreal wdhcf, qreal hdvcf, QGraphicsItem* parent = nullptr); | | |||
68 | 62 | | |||
69 | ~CanvasEdge() override; | 63 | ~CanvasEdge() override; | ||
70 | 64 | | |||
71 | QRectF boundingRect() const override; | 65 | QRectF boundingRect() const override; | ||
72 | 66 | | |||
73 | QPainterPath shape () const override; | 67 | QPainterPath shape() const override; | ||
74 | 68 | | |||
75 | void paint(QPainter* p, const QStyleOptionGraphicsItem *option, QWidget *widget) override; | 69 | void paint(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *widget) override; | ||
76 | 70 | | |||
77 | inline GraphEdge* edge() { return m_edge; } | 71 | inline GraphEdge *edge() | ||
78 | inline const GraphEdge* edge() const { return m_edge; } | 72 | { | ||
73 | return m_edge; | ||||
74 | } | ||||
75 | inline const GraphEdge *edge() const | ||||
76 | { | ||||
77 | return m_edge; | ||||
78 | } | ||||
79 | 79 | | |||
80 | inline void setGh(qreal gh) {m_gh = gh;} | 80 | inline void setGh(qreal gh) | ||
81 | { | ||||
82 | m_gh = gh; | ||||
83 | } | ||||
81 | 84 | | |||
82 | void computeBoundingRect(); | 85 | void computeBoundingRect(); | ||
83 | 86 | | |||
84 | Q_SIGNALS: | 87 | Q_SIGNALS: | ||
85 | void selected(CanvasEdge*, Qt::KeyboardModifiers); | 88 | void selected(CanvasEdge *, Qt::KeyboardModifiers); | ||
86 | void edgeContextMenuEvent(const QString&, const QPoint&); | 89 | void edgeContextMenuEvent(const QString &, const QPoint &); | ||
87 | void hoverEnter(CanvasEdge*); | 90 | void hoverEnter(CanvasEdge *); | ||
88 | void hoverLeave(CanvasEdge*); | 91 | void hoverLeave(CanvasEdge *); | ||
89 | 92 | | |||
90 | public Q_SLOTS: | 93 | public Q_SLOTS: | ||
91 | void modelChanged(); | 94 | void modelChanged(); | ||
92 | void slotRemoveEdge(); | 95 | void slotRemoveEdge(); | ||
93 | 96 | | |||
94 | protected: | 97 | protected: | ||
95 | void mousePressEvent(QGraphicsSceneMouseEvent* event) override; | 98 | void mousePressEvent(QGraphicsSceneMouseEvent *event) override; | ||
96 | void hoverEnterEvent(QGraphicsSceneHoverEvent* event) override; | 99 | void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; | ||
97 | void hoverLeaveEvent(QGraphicsSceneHoverEvent* event) override; | 100 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; | ||
98 | 101 | | |||
99 | private: | 102 | private: | ||
100 | QPainterPath pathForSpline(int splineNum, const DotRenderOp& dro) const; | 103 | QPainterPath pathForSpline(int splineNum, const DotRenderOp &dro) const; | ||
101 | qreal distance(const QPointF& point1, const QPointF& point2); | 104 | qreal distance(const QPointF &point1, const QPointF &point2); | ||
102 | 105 | | |||
103 | qreal m_scaleX, m_scaleY; | 106 | qreal m_scaleX, m_scaleY; | ||
104 | qreal m_xMargin, m_yMargin, m_gh, m_wdhcf, m_hdvcf; | 107 | qreal m_xMargin, m_yMargin, m_gh, m_wdhcf, m_hdvcf; | ||
105 | GraphEdge* m_edge; | 108 | GraphEdge *m_edge; | ||
106 | QRectF m_boundingRect; | 109 | QRectF m_boundingRect; | ||
107 | QFont* m_font; | 110 | QFont *m_font; | ||
108 | DotGraphView* m_view; | 111 | DotGraphView *m_view; | ||
109 | QMenu* m_popup; | 112 | QMenu *m_popup; | ||
110 | mutable QPainterPath m_shape; | 113 | mutable QPainterPath m_shape; | ||
111 | }; | 114 | }; | ||
112 | 115 | | |||
113 | } | 116 | } | ||
114 | 117 | | |||
115 | #endif | 118 | #endif | ||
116 | | ||||
117 | | ||||
118 | |