-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathGrid3D.qml
232 lines (209 loc) · 5.03 KB
/
Grid3D.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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/*
* Copyright (C) 2018 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import QtQuick 2.9
import QtQuick.Controls 2.1
import QtQuick.Controls.Material 2.1
import QtQuick.Dialogs 1.0
import QtQuick.Layouts 1.3
import "qrc:/qml"
GridLayout {
columns: 4
columnSpacing: 10
Layout.minimumWidth: 300
Layout.minimumHeight: 625
anchors.fill: parent
anchors.leftMargin: 10
anchors.rightMargin: 10
// Get number of decimal digits based on a widget's width
// TODO(chapulina) Move this to a common place so all widgets can use it
function getDecimals(_width) {
if (_width <= 80)
return 2;
else if (_width <= 100)
return 4;
return 6;
}
Connections {
target: Grid3D
onNewParams: {
horizontalCellCount.value = _hCellCount;
verticalCellCount.value = _vCellCount;
cellLength.value = _cellLength;
gzPoseInstance.xValue = _pos.x;
gzPoseInstance.yValue = _pos.y;
gzPoseInstance.zValue = _pos.z;
gzPoseInstance.rollValue = _rot.x;
gzPoseInstance.pitchValue = _rot.y;
gzPoseInstance.yawValue = _rot.z;
gzColorGrid.r = _color.r;
gzColorGrid.g = _color.g;
gzColorGrid.b = _color.b;
gzColorGrid.a = _color.a;
}
}
ComboBox {
id: combo
Layout.columnSpan: 2
Layout.fillWidth: true
model: Grid3D.nameList
onCurrentIndexChanged: {
if (currentIndex < 0)
return;
Grid3D.OnName(textAt(currentIndex));
}
popup.width: parent.width
ToolTip.visible: hovered
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
ToolTip.text: qsTr("Grids in the scene")
}
RoundButton {
text: "\u21bb"
Layout.columnSpan: 1
Material.background: Material.primary
onClicked: {
Grid3D.OnRefresh();
}
ToolTip.visible: hovered
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
ToolTip.text: qsTr("Refresh list of grids")
}
CheckBox {
Layout.alignment: Qt.AlignHCenter
id: showgrid
Layout.columnSpan: 1
text: qsTr("Show")
checked: true
onClicked: {
Grid3D.OnShow(checked)
}
}
Text {
Layout.columnSpan: 4
text: "Cell Count"
color: "dimgrey"
font.bold: true
}
Text {
Layout.columnSpan: 2
id: vercelltext
color: "dimgrey"
text: "Vertical"
}
IgnSpinBox {
Layout.columnSpan: 2
Layout.fillWidth: true
id: verticalCellCount
maximumValue: Number.MAX_VALUE
minimumValue: 0
value: 0
onEditingFinished: Grid3D.UpdateVCellCount(verticalCellCount.value)
}
Text {
Layout.columnSpan: 2
id: honcelltext
color: "dimgrey"
text: "Horizontal"
}
IgnSpinBox {
Layout.columnSpan: 2
Layout.fillWidth: true
id: horizontalCellCount
maximumValue: Number.MAX_VALUE
minimumValue: 1
value: 20
onEditingFinished: Grid3D.UpdateHCellCount(horizontalCellCount.value)
}
Text {
Layout.columnSpan: 4
id: celllengthtext
text: "Cell Length"
color: "dimgrey"
font.bold: true
}
Text {
Layout.columnSpan: 2
id: length
color: "dimgrey"
text: "Length (m)"
}
IgnSpinBox {
Layout.columnSpan: 2
Layout.fillWidth: true
id: cellLength
maximumValue: Number.MAX_VALUE
minimumValue: 0.0000001
value: 1.00
decimals: getDecimals(cellLength.width)
stepSize: 0.01
onEditingFinished: Grid3D.UpdateCellLength(cellLength.value)
}
Text {
Layout.columnSpan: 2
id: cartesian
color: "dimgrey"
font.bold: true
text: "Position (m)"
}
Text {
Layout.columnSpan: 1
id: principal
text: "Rotation (rad)"
color: "dimgrey"
font.bold: true
}
// dummy item for formatting
Item {
Layout.columnSpan: 1
}
GzPose {
id: gzPoseInstance
Layout.columnSpan: 4
Layout.fillWidth: true
readOnly: false
xValue: 0.00
yValue: 0.00
zValue: 0.00
rollValue: 0.00
pitchValue: 0.00
yawValue: 0.00
onGzPoseSet: {
// _x, _y, _z, _roll, _pitch, _yaw are parameters of signal gzPoseSet
// from gz-gui GzPose.qml
Grid3D.SetPose(_x, _y, _z, _roll, _pitch, _yaw)
}
expand: true
}
Text {
Layout.columnSpan: 4
text: "Color"
color: "dimgrey"
font.bold: true
}
Text {
Layout.columnSpan: 2
color: "dimgrey"
text: "Grid Color"
}
GzColor {
id: gzColorGrid
Layout.columnSpan: 2
Layout.alignment: Qt.AlignRight
Layout.bottomMargin: 5
Layout.rightMargin: 20
onGzColorSet: Grid3D.SetColor(gzColorGrid.r, gzColorGrid.g, gzColorGrid.b, gzColorGrid.a)
}
}