-
Notifications
You must be signed in to change notification settings - Fork 283
/
Copy pathEntityContextMenu.qml
195 lines (186 loc) · 4.87 KB
/
EntityContextMenu.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
/*
* 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.0
import QtQuick.Controls 2.0
import IgnGazebo 1.0 as IgnGazebo
Item {
Menu {
id: menu
transformOrigin: Menu.TopRight
MenuItem {
id: moveToMenu
text: "Move To"
onTriggered: context.OnRequest("move_to", context.entity)
}
MenuItem {
id: followMenu
text: "Follow"
onTriggered: context.OnRequest("follow", context.entity)
}
MenuItem {
id: removeMenu
text: "Remove"
onTriggered: context.OnRemove(context.entity, context.type)
}
MenuItem {
id: copyMenu
text: "Copy"
onTriggered: context.OnRequest("copy", context.entity)
}
MenuItem {
id: pasteMenu
text: "Paste"
// no data needs to be passed along to the paste request, so an empty
// string is sent
onTriggered: context.OnRequest("paste", "")
}
// // cascading submenu only works in Qt 5.10+ on focal
// Menu {
// id: viewSubmenu
// title: "View"
// MenuItem {
// id: viewCollisionsMenu
// text: "Collisions"
// onTriggered: context.OnRequest("view_collisions", context.entity)
// }
// }
// workaround for getting submenu's to work on bionic (< Qt 5.10)
MenuItem {
id: viewSubmenu
text: "View >"
MouseArea {
id: viewSubMouseArea
anchors.fill: parent
hoverEnabled: true
onEntered: secondMenu.open()
}
}
}
Menu {
id: secondMenu
x: menu.x + menu.width
y: menu.y + viewSubmenu.y
MenuItem {
id: viewCOMMenu
text: "Center of Mass"
onTriggered: {
menu.close()
context.OnRequest("view_com", context.entity)
}
}
MenuItem {
id: viewCollisionsMenu
text: "Collisions"
onTriggered: {
menu.close()
context.OnRequest("view_collisions", context.entity)
}
}
MenuItem {
id: viewInertiaMenu
text: "Inertia"
onTriggered: {
menu.close()
context.OnRequest("view_inertia", context.entity)
}
}
MenuItem {
id: viewJointsMenu
text: "Joints"
onTriggered: {
menu.close()
context.OnRequest("view_joints", context.entity)
}
}
MenuItem {
id: viewFramesMenu
text: "Frames"
onTriggered: {
menu.close()
context.OnRequest("view_frames", context.entity)
}
}
MenuItem {
id: viewTransparentMenu
text: "Transparent"
onTriggered: {
menu.close()
context.OnRequest("view_transparent", context.entity)
}
}
MenuItem {
id: viewWireframesMenu
text: "Wireframe"
onTriggered: {
menu.close()
context.OnRequest("view_wireframes", context.entity)
}
}
}
function open(_entity, _type, _x, _y) {
menu.x = _x
menu.y = _y
context.entity = _entity
context.type = _type
moveToMenu.enabled = false
followMenu.enabled = false
removeMenu.enabled = false
viewTransparentMenu.enabled = false;
viewCOMMenu.enabled = false;
viewInertiaMenu.enabled = false;
viewJointsMenu.enabled = false;
viewWireframesMenu.enabled = false;
viewCollisionsMenu.enabled = false;
viewFramesMenu.enabled = false;
// enable / disable menu items
if (context.type == "model" || context.type == "link" ||
context.type == "visual" || context.type == "light" ||
context.type == "performer")
{
moveToMenu.enabled = true
followMenu.enabled = true
}
if (context.type == "model" || context.type == "light")
{
removeMenu.enabled = true
}
if (context.type == "model" || context.type == "link")
{
viewTransparentMenu.enabled = true;
viewCOMMenu.enabled = true;
viewInertiaMenu.enabled = true;
viewWireframesMenu.enabled = true;
viewCollisionsMenu.enabled = true;
}
if (context.type == "model")
{
viewJointsMenu.enabled = true;
}
// TODO(chapulina) Support collision, sensor, etc.
if (context.type == "model" || context.type == "link" ||
context.type == "visual")
{
viewFramesMenu.enabled = true
}
menu.open()
}
IgnGazebo.EntityContextMenuItem {
id: context
property string entity
property string type
}
}