-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTriPoint.qml
211 lines (200 loc) · 5.46 KB
/
TriPoint.qml
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
import QtQuick 2.12
import QtQuick.Controls 1.4
import QtQuick.Shapes 1.15
Item{
id: triPoint
anchors.fill: parent
property var midPoint: Qt.point(0,0)
property var radius: 0
property bool selected: true
property var angle: 0
property var color: objColor
property var centerText: ""
onRadiusChanged: {
mid.center = Qt.point(midPoint.x,midPoint.y)
updatePos()
}
Item{
id: left
x: mid.x-radius
y: mid.y
Rectangle{
id: targetLeft
x:-width/2
y:-height/2
width: 20*k
height: width
radius: width/2
color: "black"
border.color: "white"
border.width:width/8
}
Text{
anchors.verticalCenter: targetLeft.verticalCenter
anchors.horizontalCenter: targetLeft.horizontalCenter
text:"L"
font.family: "Helvetica"
font.pixelSize: 10*k
font.bold: true
color: "white"
}
MouseArea {
anchors.fill: targetLeft
drag.target: parent
drag.axis: Drag.XAndYAxis
onPressed: {
rect.selected(true)
}
onReleased: {
updateAction()
}
onPositionChanged: {
angle=Math.atan2(mid.y-left.y,mid.x-left.x)
if (angle > Math.PI/2)
angle = Math.PI/2
if (angle < -Math.PI/2)
angle = -Math.PI/2
updatePos()
}
}
}
Item{
id: right
x: mid.x+radius
y: mid.y
Rectangle{
id: targetRight
x:-width/2
y:-height/2
width: 20*k
height: width
radius: width/2
color: "white"
border.color: "black"
border.width:width/8
}
Text{
anchors.verticalCenter: targetRight.verticalCenter
anchors.horizontalCenter: targetRight.horizontalCenter
text:"R"
font.family: "Helvetica"
font.pixelSize: 10*k
font.bold: true
color: "black"
}
MouseArea {
anchors.fill: targetRight
drag.target: parent
drag.axis: Drag.XAndYAxis
onPressed: {
rect.selected(true)
}
onReleased: {
updateAction()
}
onPositionChanged: {
angle=Math.atan2(right.y-mid.y,right.x-mid.x)
if (angle > Math.PI/2)
angle = Math.PI/2
if (angle < -Math.PI/2)
angle = -Math.PI/2
updatePos()
}
}
}
DragAnchor{
id: mid
center: Qt.point(0,0)
onUpdated: {
updatePos()
updateAction()
}
borderColor: color
}
Text{
z:200
anchors.verticalCenter: mid.verticalCenter
anchors.horizontalCenter: mid.horizontalCenter
text:centerText
font.family: "Helvetica"
font.pixelSize: 10*k
font.bold: true
color: "black"
}
Shape {
anchors.fill: parent
z: -10
ShapePath {
strokeWidth: 5
strokeColor: "#FF696969"
strokeStyle: ShapePath.DashLine
dashPattern: [ 1, 3 ]
startX: left.x; startY: left.y
PathLine { x: right.x; y: right.y}
}
}
function updatePos(){
midPoint = Qt.point(mid.x,mid.y)
right.x=mid.x+radius*Math.cos(angle)
right.y=mid.y+radius*Math.sin(angle)
left.x=mid.x-radius*Math.cos(angle)
left.y=mid.y-radius*Math.sin(angle)
}
function getCoord(){
return parseInt(midPoint.x/pixScale)+'/'+parseInt(midPoint.y/pixScale+map.offset)+'/'+parseInt(-angle*180/(Math.PI))
}
/*
Item{
id: startPoint
x:(left.x+right.x)/2
y:(left.y+right.y)/2
}
Rectangle{
id: startRect
color: "black"
width: 10
height: width
radius: width/2
x:startPoint.x-width/2
y:startPoint.y-height/2
z:-1
opacity: 1
visible: true
}
Rectangle{
id: dragPoint
x:startPoint.x-width/2
y:startPoint.y-height/2
width: 40
height: width
radius: width/2
color: "red"
border.color: objColor
border.width:width/3
}
MouseArea {
id:mouseArea
anchors.fill: dragPoint
drag.target: dragPoint
drag.axis: Drag.XAndYAxis
acceptedButtons: Qt.LeftButton
onPressed: {
rect.selected(true)
dragPoint.x = dragPoint.x
dragPoint.y = dragPoint.y
}
}
/* MouseArea {
id:mouseArea
anchors.fill: dial
drag.target: dial
drag.axis: Drag.XAndYAxis
onMouseXChanged: {
var theta=Math.atan2(dialCenter.y-rotationSlider.width/2,dialCenter.x-rotationSlider.width/2)
displayView.rotation = theta/Math.PI*180+90
dial.x=rotationSlider.width/2*(1+Math.cos(theta))-dial.width/2
dial.y=rotationSlider.height/2*(1+Math.sin(theta))-dial.height/2
rotationSlider.theta_h=displayView.rotation - rotationSlider.theta_r
}
*/
}