-
Notifications
You must be signed in to change notification settings - Fork 0
/
TouchJoint.qml
55 lines (46 loc) · 1.39 KB
/
TouchJoint.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
import QtQuick 2.0
import Ros 1.0
TouchPoint {
id: touch
property string name: "touch"
property bool drawing: false
// when used to draw on the background:
property var currentStroke: []
property color color: "black"
onXChanged: {
// (only add stroke point in one dimension (Y) to avoid double drawing)
}
onYChanged: {
if (drawing) {
currentStroke.push(Qt.point(x,y));
drawingarea.update();
}
}
onPressedChanged: {
if (pressed) {
var obj = figures.childAt(x, y);
if (drawingarea.drawEnabled) {
for(var i = 0;i<figures.children.length;i++){
if(figures.children[i].name === "rect" && figures.children[i].inHull(Qt.point(x,y)))
return
}
currentStroke = [];
color = drawingarea.fgColor;
drawing = true;
drawingarea.newStroke()
currentStroke.push(Qt.point(x,y));
recognizer.addPoint(x, y)
drawingarea.update();
}
}
else {
if(drawing) {
drawing = false;
if (drawingarea.drawEnabled) {
drawingarea.finishStroke(currentStroke);
}
currentStroke = [];
}
}
}
}