-
Notifications
You must be signed in to change notification settings - Fork 304
/
Copy pathComponentInspector.qml
241 lines (216 loc) · 6.71 KB
/
ComponentInspector.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
232
233
234
235
236
237
238
239
240
241
/*
* Copyright (C) 2019 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 1.4
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.1
import QtQuick.Layouts 1.3
import QtQuick.Controls.Styles 1.4
import IgnGazebo 1.0 as IgnGazebo
Rectangle {
id: componentInspector
color: lightGrey
Layout.minimumWidth: 400
Layout.minimumHeight: 375
anchors.fill: parent
/**
* Time delay for tooltip to show, in ms
*/
property int tooltipDelay: 500
/**
* Height of each item in pixels
*/
property int itemHeight: 30
/**
* Entity type
*/
property string entityType: ComponentInspector.type
/**
* Get if entity is nested model or not
*/
property bool nestedModel : ComponentInspector.nestedModel
/**
* Light grey according to theme
*/
property color lightGrey: (Material.theme == Material.Light) ?
Material.color(Material.Grey, Material.Shade100) :
Material.color(Material.Grey, Material.Shade800)
/**
* Dark grey according to theme
*/
property color darkGrey: (Material.theme == Material.Light) ?
Material.color(Material.Grey, Material.Shade200) :
Material.color(Material.Grey, Material.Shade900)
/**
* Highlight color
*/
property color highlightColor: Qt.rgba(
Material.accent.r,
Material.accent.g,
Material.accent.b, 0.3)
function delegateQml(_model) {
if (_model === null || _model.dataType == undefined)
return 'NoData.qml'
return _model.dataType + '.qml'
}
// Get number of decimal digits based on a widget's width
function getDecimals(_width) {
if (_width <= 80)
return 2;
else if (_width <= 100)
return 4;
return 6;
}
/**
* Forward pose changes to C++
*/
function onPose(_x, _y, _z, _roll, _pitch, _yaw) {
ComponentInspector.OnPose(_x, _y, _z, _roll, _pitch, _yaw)
}
/**
* Forward light changes to C++
*/
function onLight(_rSpecular, _gSpecular, _bSpecular, _aSpecular,
_rDiffuse, _gDiffuse, _bDiffuse, _aDiffuse,
_attRange, _attLinear, _attConstant, _attQuadratic,
_castShadows, _directionX, _directionY, _directionZ,
_innerAngle, _outerAngle, _falloff, _type) {
ComponentInspector.OnLight(_rSpecular, _gSpecular, _bSpecular, _aSpecular,
_rDiffuse, _gDiffuse, _bDiffuse, _aDiffuse,
_attRange, _attLinear, _attConstant, _attQuadratic,
_castShadows, _directionX, _directionY, _directionZ,
_innerAngle, _outerAngle, _falloff, _type)
}
/*
* Forward physics changes to C++
*/
function onPhysics(_stepSize, _realTimeFactor) {
ComponentInspector.OnPhysics(_stepSize, _realTimeFactor)
}
/**
* Forward material color changes to C++
*/
function onMaterialColor(_rAmbient, _gAmbient, _bAmbient, _aAmbient,
_rDiffuse, _gDiffuse, _bDiffuse, _aDiffuse,
_rSpecular, _gSpecular, _bSpecular, _aSpecular,
_rEmissive, _gEmissive, _bEmissive, _aEmissive,
_type, _currColor) {
ComponentInspector.OnMaterialColor(
_rAmbient, _gAmbient, _bAmbient, _aAmbient,
_rDiffuse, _gDiffuse, _bDiffuse, _aDiffuse,
_rSpecular, _gSpecular, _bSpecular, _aSpecular,
_rEmissive, _gEmissive, _bEmissive, _aEmissive,
_type, _currColor)
}
Rectangle {
id: header
height: lockButton.height
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
width: parent.width
color: darkGrey
RowLayout {
anchors.fill: parent
spacing: 0
IgnGazebo.TypeIcon {
id: icon
height: lockButton.height * 0.8
width: lockButton.height * 0.8
entityType: ComponentInspector.type
}
Label {
text: ComponentInspector.type
font.capitalization: Font.Capitalize
color: Material.theme == Material.Light ? "#444444" : "#cccccc"
font.pointSize: 12
padding: 3
}
Item {
height: entityLabel.height
Layout.fillWidth: true
}
ToolButton {
id: lockButton
checkable: true
checked: false
text: "Lock entity"
contentItem: Image {
fillMode: Image.Pad
horizontalAlignment: Image.AlignHCenter
verticalAlignment: Image.AlignVCenter
source: lockButton.checked ? "qrc:/Gazebo/images/lock.svg" :
"qrc:/Gazebo/images/unlock.svg"
sourceSize.width: 18;
sourceSize.height: 18;
}
ToolTip.text: lockButton.checked ? "Unlock entity" : "Lock entity"
ToolTip.visible: hovered
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
onToggled: {
ComponentInspector.locked = lockButton.checked
}
}
ToolButton {
id: pauseButton
checkable: true
checked: false
text: pauseButton.checked ? "\u25B6" : "\u275A\u275A"
contentItem: Text {
text: pauseButton.text
color: "#b5b5b5"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
ToolTip.text: pauseButton.checked ? "Resume updates" : "Pause updates"
ToolTip.visible: hovered
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval
onToggled: {
ComponentInspector.paused = pauseButton.checked
}
}
Label {
id: entityLabel
text: 'Entity ' + ComponentInspector.entity
Layout.minimumWidth: 80
color: Material.theme == Material.Light ? "#444444" : "#cccccc"
font.pointSize: 12
padding: 5
}
}
}
ListView {
anchors.top: header.bottom
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
model: {
try {
return ComponentsModel;
}
catch (e) {
// The QML is loaded before we set the context property
return null
}
}
spacing: 5
delegate: Loader {
id: loader
source: delegateQml(model)
}
}
}