This repository has been archived by the owner on Aug 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainScreen.qml
executable file
·201 lines (167 loc) · 5.6 KB
/
MainScreen.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
import QtQuick 2.3
import "StyleSheet.js" as Style
import "qrc:/Controls"
import "qrc:/Keyboard"
import "qrc:/Bottom"
import FBORenderer 1.0
Rectangle {
id: rootRect
visible: true
width: 480
height: 800
color: Style.bgMain
function addStl() {
qmlFileBrowser.open()
}
TopDrawer {
id: topDrawer
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
z: 100;
}
FileBrowser {
id: qmlFileBrowser
height: parent.height - topDrawer.iClosedHeight
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
z: 90
}
Item {
anchors.fill: parent
visible: !qmlFileBrowser.visible
Keyboard {
objectName: "keyboard"
anchors.left: parent.left
anchors.bottom: parent.bottom
}
BottomDrawer {
id: bottomDrawer
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.bottomMargin: keyboard.uiOffset
Behavior on anchors.bottomMargin {
PropertyAnimation { }
}
}
Renderer {
id: renderer
width: parent.width
height: parent.height - bottomDrawer.iClosedHeight
anchors.bottom: parent.bottom
anchors.bottomMargin: bottomDrawer.isExpanded ? 0 : bottomDrawer.iClosedHeight
Behavior on anchors.bottomMargin {
PropertyAnimation {}
}
// Move the view down a bit after creation
Component.onCompleted: {
//renderer.panView(0, renderer.height / 3);
}
meshOpacity: (bottomDrawer.activeTabNum == 0) ? 1 : ((bottomDrawer.activeTabNum == 1) ? 0.5 : 0)
tpOpacity: (bottomDrawer.activeTabNum == 2) ? 1 : ((bottomDrawer.activeTabNum == 1) ? 0.5 : 0)
Behavior on meshOpacity {
PropertyAnimation {}
}
Behavior on tpOpacity {
PropertyAnimation {}
}
Behavior on curMeshPos {
PropertyAnimation {
id: curMeshPosAnimation
}
}
Behavior on curMeshScale {
PropertyAnimation {
id: curMeshScaleAnimation
}
}
Behavior on curMeshRot {
PropertyAnimation {
id: curMeshRotAnimation
}
}
Toggle {
id: toggler
anchors.top: parent.top
anchors.topMargin: 7 + topDrawer.iClosedHeight
anchors.left: parent.left
anchors.leftMargin: 7
width: 150
isDimmable: true
opacity: bottomDrawer.isExpanded ? 0.0 : 0.6
nameA: 'Pan'
nameB: 'Rotate'
visible: !bottomDrawer.isExpanded
z: 200
}
Button {
anchors.top: toggler.top
anchors.right: parent.right
anchors.rightMargin: 7
opacity: bottomDrawer.isExpanded ? 0.0 : 0.6
isDimmable: true
text: "Reset view"
width: 150
z: 200
onClicked: {
renderer.resetView(true)
}
}
PinchArea {
anchors.fill: parent
property real lastScale: 1
onPinchStarted: {
lastScale = pinch.scale
}
onPinchUpdated: {
var scale = pinch.scale / lastScale
lastScale = pinch.scale
renderer.zoomView(scale)
}
MouseArea {
id: mouser
anchors.fill: parent
//scrollGestureEnabled: true // Qt 5.5
property real lastX: 0
property real lastY: 0
property bool started: false
property bool click: true
onPressed: {
lastX = mouseX
lastY = mouseY
started = true
click = true
}
onReleased: {
started = false
// Normal onclicked includes drags
if (click)
renderer.testMouseIntersection(lastX, lastY)
}
onPositionChanged: {
var deltaX = mouseX - lastX
var deltaY = mouseY - lastY
if ((deltaX != 0) || (deltaY != 0))
{
if (toggler.toggled)
renderer.panView(deltaX, deltaY);
else
renderer.rotateView(deltaX, deltaY);
}
lastX = mouseX
lastY = mouseY
click = false
}
onWheel: {
if (wheel.angleDelta.y > 0)
renderer.zoomView(1.1)
else if (wheel.angleDelta.y < 0)
renderer.zoomView(0.9)
}
}
}
}
}
}