-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathGuiEvents.hh
262 lines (226 loc) · 8.55 KB
/
GuiEvents.hh
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
/*
* Copyright (C) 2020 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.
*
*/
#ifndef IGNITION_GUI_GUIEVENTS_HH_
#define IGNITION_GUI_GUIEVENTS_HH_
#include <QEvent>
#include <string>
#include <utility>
#include <vector>
#include <ignition/math/Vector3.hh>
namespace ignition
{
namespace gui
{
/// \brief Namespace for all events.
namespace events
{
/// User defined events should start from QEvent::MaxUser and
/// count down to avoid collision with ign-gazebo events
/// \brief Event called in the render thread of a 3D scene.
/// It's safe to make rendering calls in this event's callback.
class Render : public QEvent
{
public: Render()
: QEvent(kType)
{
}
/// \brief Unique type for this event.
static const QEvent::Type kType = QEvent::Type(QEvent::MaxUser);
};
/// \brief The class for sending and receiving custom snap value events.
/// This event is used in the Transform Control plugin tool when the
/// user manually alters their snapping values.
class SnapIntervals : public QEvent
{
/// \brief Constructor
/// \param[in] _xyz XYZ snapping values.
/// \param[in] _rpy RPY snapping values.
/// \param[in] _scale Scale snapping values.
public: SnapIntervals(
const math::Vector3d &_xyz,
const math::Vector3d &_rpy,
const math::Vector3d &_scale)
: QEvent(kType), xyz(_xyz), rpy(_rpy), scale(_scale)
{
}
/// \brief Get the XYZ snapping values.
/// \return The XYZ snapping values.
public: math::Vector3d Position() const
{
return this->xyz;
}
/// \brief Get the RPY snapping values.
/// \return The RPY snapping values.
public: math::Vector3d Rotation() const
{
return this->rpy;
}
/// \brief Get the scale snapping values.
/// \return The scale snapping values.
public: math::Vector3d Scale() const
{
return this->scale;
}
/// \brief The QEvent representing a snap event occurrence.
static const QEvent::Type kType = QEvent::Type(QEvent::MaxUser - 1);
/// \brief XYZ snapping values in meters, these values must be positive.
private: math::Vector3d xyz;
/// \brief RPY snapping values in degrees, these values must be
/// positive.
private: math::Vector3d rpy;
/// \brief Scale snapping values - a multiplier of the current size,
/// these values must be positive.
private: math::Vector3d scale;
};
/// \brief Event called to spawn a resource, given its description as a
/// string.
class SpawnFromDescription : public QEvent
{
/// \brief Constructor
/// \param[in] _string The resource's description as a string, such
/// as an SDF file.
public: explicit SpawnFromDescription(const std::string &_description)
: QEvent(kType), description(_description)
{
}
/// \brief Unique type for this event.
static const QEvent::Type kType = QEvent::Type(QEvent::MaxUser - 2);
/// \brief Get the string description of the resource.
/// \return The resource string
public: const std::string &Description() const
{
return this->description;
}
/// \brief The string of the resource to be spawned.
std::string description;
};
/// \brief Event called to spawn a resource, which takes the path
/// to its file.
class SpawnFromPath : public QEvent
{
/// \brief Constructor
/// \param[in] _filePath The path to a file.
public: explicit SpawnFromPath(const std::string &_filePath)
: QEvent(kType), filePath(_filePath)
{
}
/// \brief Unique type for this event.
static const QEvent::Type kType = QEvent::Type(QEvent::MaxUser - 3);
/// \brief Get the path of the file.
/// \return The file path.
public: const std::string &FilePath() const
{
return this->filePath;
}
/// \brief The path of file to be previewed.
std::string filePath;
};
/// \brief Event which is called to broadcast the 3D coordinates of a
/// user's mouse hover within the scene.
class HoverToScene : public QEvent
{
/// \brief Constructor
/// \param[in] _point The point at which the mouse is hovering within
/// the scene
public: explicit HoverToScene(const math::Vector3d &_point)
: QEvent(kType), point(_point)
{
}
/// \brief Unique type for this event.
static const QEvent::Type kType = QEvent::Type(QEvent::MaxUser - 4);
/// \brief Get the point within the scene over which the user is
/// hovering.
/// \return The 3D point
public: math::Vector3d Point() const
{
return this->point;
}
/// \brief The 3D point over which the user is hovering.
private: math::Vector3d point;
};
/// \brief Event which is called to broadcast the 3D coordinates of a
/// user's left click within the scene.
class LeftClickToScene : public QEvent
{
/// \brief Constructor
/// \param[in] _point The point which the user has left clicked within
/// the scene
public: explicit LeftClickToScene(const math::Vector3d &_point)
: QEvent(kType), point(_point)
{
}
/// \brief Unique type for this event.
static const QEvent::Type kType = QEvent::Type(QEvent::MaxUser - 5);
/// \brief Get the point within the scene that the user clicked.
/// \return The 3D point.
public: math::Vector3d Point() const
{
return this->point;
}
/// \brief The 3D point that the user clicked within the scene.
private: math::Vector3d point;
};
/// \brief Event which is called to broadcast the 3D coordinates of a
/// user's right click within the scene.
class RightClickToScene : public QEvent
{
/// \brief Constructor
/// \param[in] _point The point which the user has right clicked
/// within the scene
public: explicit RightClickToScene(const math::Vector3d &_point)
: QEvent(kType), point(_point)
{
}
/// \brief Unique type for this event.
static const QEvent::Type kType = QEvent::Type(QEvent::MaxUser - 6);
/// \brief Get the point within the scene that the user clicked.
/// \return The 3D point.
public: math::Vector3d Point() const
{
return this->point;
}
/// \brief The 3D point that the user clicked within the scene.
private: math::Vector3d point;
};
/// \brief Event which is called to enable or disable the dropdown menu.
/// This is primarily used by plugins which also use the right click
/// mouse event to cancel any actions currently in progress.
class DropdownMenuEnabled : public QEvent
{
/// \brief Constructor
/// \param[in] _menuEnabled The boolean indicating whether the dropdown
/// menu should be enabled or disabled.
public: explicit DropdownMenuEnabled(bool _menuEnabled)
: QEvent(kType), menuEnabled(_menuEnabled)
{
}
/// \brief Unique type for this event.
static const QEvent::Type kType = QEvent::Type(QEvent::MaxUser - 7);
/// \brief Gets whether the menu is enabled or not for this event.
/// \return True if enabling the menu, false if disabling the menu
public: bool MenuEnabled() const
{
return this->menuEnabled;
}
/// \brief The boolean indicating whether the menu is disabled or not
/// for this event.
private: bool menuEnabled;
};
}
}
}
#endif // IGNITION_GUI_GUIEVENTS_HH_