-
Notifications
You must be signed in to change notification settings - Fork 948
Expand file tree
/
Copy pathAbstractNodeGeometry.hpp
More file actions
85 lines (64 loc) · 2.81 KB
/
AbstractNodeGeometry.hpp
File metadata and controls
85 lines (64 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#pragma once
#include "Definitions.hpp"
#include "Export.hpp"
#include <QRectF>
#include <QSize>
#include <QTransform>
namespace QtNodes {
class AbstractGraphModel;
class NODE_EDITOR_PUBLIC AbstractNodeGeometry
{
public:
AbstractNodeGeometry(AbstractGraphModel &);
virtual ~AbstractNodeGeometry() {}
/**
* The node's size plus some additional margin around it to account for drawing
* effects (for example shadows) or node's parts outside the size rectangle
* (for example port points).
*/
virtual QRectF boundingRect(NodeId const nodeId) const = 0;
/// A direct rectangle defining the borders of the node's rectangle.
virtual QSize size(NodeId const nodeId) const = 0;
/**
* The function is triggeren when a nuber of ports is changed or when an
* embedded widget needs an update.
*/
virtual void recomputeSize(NodeId const nodeId) const = 0;
/// Port position in node's coordinate system.
virtual QPointF portPosition(NodeId const nodeId,
PortType const portType,
PortIndex const index) const = 0;
/// A convenience function using the `portPosition` and a given transformation.
virtual QPointF portScenePosition(NodeId const nodeId,
PortType const portType,
PortIndex const index,
QTransform const &t) const;
/// Defines where to draw port label. The point corresponds to a font baseline.
virtual QPointF portTextPosition(NodeId const nodeId,
PortType const portType,
PortIndex const portIndex) const = 0;
/**
* Defines where to start drawing the caption. The point corresponds to a font
* baseline.
*/
virtual QPointF captionPosition(NodeId const nodeId) const = 0;
/// Caption rect is needed for estimating the total node size.
virtual QRectF captionRect(NodeId const nodeId) const = 0;
/**
* Defines where to start drawing the label. The point corresponds to a font
* baseline.
*/
virtual QPointF labelPosition(NodeId const nodeId) const = 0;
/// Caption rect is needed for estimating the total node size.
virtual QRectF labelRect(NodeId const nodeId) const = 0;
/// Position for an embedded widget. Return any value if you don't embed.
virtual QPointF widgetPosition(NodeId const nodeId) const = 0;
virtual PortIndex checkPortHit(NodeId const nodeId,
PortType const portType,
QPointF const nodePoint) const;
virtual QRect resizeHandleRect(NodeId const nodeId) const = 0;
virtual int getPortSpacing() = 0;
protected:
AbstractGraphModel &_graphModel;
};
} // namespace QtNodes