Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
131 lines (93 loc) · 2.25 KB

File metadata and controls

131 lines (93 loc) · 2.25 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include "ConnectionGeometry.hpp"
#include <cmath>
#include "StyleCollection.hpp"
using QtNodes::ConnectionGeometry;
using QtNodes::PortType;
ConnectionGeometry::
ConnectionGeometry()
: _in(0, 0)
, _out(0, 0)
//, _animationPhase(0)
, _lineWidth(3.0)
, _hovered(false)
{ }
QPointF const&
ConnectionGeometry::
getEndPoint(PortType portType) const
{
Q_ASSERT(portType != PortType::None);
return (portType == PortType::Out ?
_out :
_in);
}
void
ConnectionGeometry::
setEndPoint(PortType portType, QPointF const& point)
{
switch (portType)
{
case PortType::Out:
_out = point;
break;
case PortType::In:
_in = point;
break;
default:
break;
}
}
void
ConnectionGeometry::
moveEndPoint(PortType portType, QPointF const &offset)
{
switch (portType)
{
case PortType::Out:
_out += offset;
break;
case PortType::In:
_in += offset;
break;
default:
break;
}
}
QRectF
ConnectionGeometry::
boundingRect() const
{
auto points = pointsC1C2();
QRectF basicRect = QRectF(_out, _in).normalized();
QRectF c1c2Rect = QRectF(points.first, points.second).normalized();
auto const &connectionStyle =
StyleCollection::connectionStyle();
float const diam = connectionStyle.pointDiameter();
QRectF commonRect = basicRect.united(c1c2Rect);
QPointF const cornerOffset(diam, diam);
commonRect.setTopLeft(commonRect.topLeft() - cornerOffset);
commonRect.setBottomRight(commonRect.bottomRight() + 2 * cornerOffset);
return commonRect;
}
std::pair<QPointF, QPointF>
ConnectionGeometry::
pointsC1C2() const
{
const double defaultOffset = 200;
double xDistance = _in.x() - _out.x();
double horizontalOffset = qMin(defaultOffset, std::abs(xDistance));
double verticalOffset = 0;
double ratioX = 0.5;
if (xDistance <= 0)
{
double yDistance = _in.y() - _out.y() + 20;
double vector = yDistance < 0 ? -1.0 : 1.0;
verticalOffset = qMin(defaultOffset, std::abs(yDistance)) * vector;
ratioX = 1.0;
}
horizontalOffset *= ratioX;
QPointF c1(_out.x() + horizontalOffset,
_out.y() + verticalOffset);
QPointF c2(_in.x() - horizontalOffset,
_in.y() - verticalOffset);
return std::make_pair(c1, c2);
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.