-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.qml
178 lines (161 loc) · 4.55 KB
/
main.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
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Dialogs 1.2
import QtQuick.Window 2.3
import QtQuick.Controls.Material 2.2
// import the VTK module
import VTKPLUS 9.1
ApplicationWindow {
id: root
// minimumWidth: 1024
// minimumHeight: 700
minimumWidth: 600
minimumHeight: 600
visible: true
title: "QtVTK"
Material.primary: Material.Indigo
Material.accent: Material.LightBlue
property bool isModelSelected: qtVTKItem.isModelSelected
VTKRenderWindow {
objectName: "RenderWindowQt"
id: vtkwindow
anchors.fill: parent
}
VTKRenderItem {
id: coneViewItem
objectName: "ConeView"
// x: 0
// y: 0
// width: 200
// height: 200
anchors.fill: parent
renderWindow: vtkwindow
focus: true
}
Button {
id: openFileButton
text: "Open file"
highlighted: isModelSelected
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.margins: 50
onClicked: qtVTKItem.showFileDialog = true;
ToolTip.visible: hovered
ToolTip.delay: 1000
ToolTip.text: "Open a 3D model into the canvas"
background: Rectangle {
color: parent.down ? "#bbbbbb" :
(parent.hovered ? "#d6d6d6" : "#f6f6f6")
}
}
ComboBox {
id: representationCombobox
visible: isModelSelected
width: 200
model: ["Points", "Wireframe", "Surface"]
currentIndex: 2
anchors.left: parent.left
anchors.top: parent.top
anchors.leftMargin: 40
anchors.topMargin: 30
onActivated: qtVTKItem.setModelsRepresentation(currentIndex);
}
Slider {
id: opacitySlider
visible: isModelSelected
width: 200
value: 1
from: 0.1
to: 1
stepSize: 0.01
anchors.left: parent.left
anchors.top: representationCombobox.bottom
anchors.leftMargin: 40
anchors.topMargin: 30
onValueChanged: qtVTKItem.setModelsOpacity(value);
}
Switch {
id: gouraudInterpolationSwitch
visible: isModelSelected
text: "Gouraud interpolation"
anchors.left: parent.left
anchors.top: opacitySlider.bottom
anchors.leftMargin: 40
anchors.topMargin: 30
onCheckedChanged: qtVTKItem.setGouraudInterpolation(checked);
}
SpinBox {
id: modelColorR
visible: isModelSelected
value: 3
editable: true
from: 0
to: 255
// onValueChanged: canvasHandler.setModelColorR(value);
anchors.left: parent.left
anchors.top: gouraudInterpolationSwitch.bottom
anchors.leftMargin: 40
anchors.topMargin: 30
}
SpinBox {
id: modelColorG
visible: isModelSelected
value: 169
from: 0
to: 255
// onValueChanged: canvasHandler.setModelColorG(value);
anchors.left: parent.left
anchors.top: modelColorR.bottom
anchors.leftMargin: 40
anchors.topMargin: 25
}
SpinBox {
id: modelColorB
visible: isModelSelected
value: 244
from: 0
to: 255
// onValueChanged: canvasHandler.setModelColorB(value);
anchors.left: parent.left
anchors.top: modelColorG.bottom
anchors.leftMargin: 40
anchors.topMargin: 25
}
Label {
id: positionLabelX
visible: isModelSelected
text: "X: " /*+ canvasHandler.modelPositionX*/
font.pixelSize: 12
anchors.bottom: positionLabelY.top
anchors.left: parent.left
anchors.margins: 40
}
Label {
id: positionLabelY
visible: isModelSelected
text: "Y: " /*+ canvasHandler.modelPositionY*/
font.pixelSize: 12
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.margins: 40
}
FileDialog {
id: openModelsFileDialog
visible: qtVTKItem.showFileDialog
title: "Import model"
folder: shortcuts.documents
nameFilters: ["Model files" + "(*.stl *.STL *.obj *.OBJ)", "All files" + "(*)"]
onAccepted: {
qtVTKItem.showFileDialog = false;
qtVTKItem.openModel(fileUrl);
}
onRejected: {
qtVTKItem.showFileDialog = false;
}
}
onFocusObjectChanged: {
if(activeFocusItem == null){
coneViewItem.focus = true
}
}
}