Go to the documentation of this file.
18 #ifndef GZ_GUI_PLUGINS_SCENE3D_HH_
19 #define GZ_GUI_PLUGINS_SCENE3D_HH_
25 #include <gz/math/Color.hh>
26 #include <gz/math/Pose3.hh>
27 #include <gz/math/Vector2.hh>
28 #include <gz/math/Vector3.hh>
30 #include <gz/common/MouseEvent.hh>
41 class IgnRendererPrivate;
42 class RenderWindowItemPrivate;
87 public slots:
void OnHovered(
int _mouseX,
int _mouseY);
116 private:
std::unique_ptr<Scene3DPrivate> dataPtr;
134 public:
void Render();
142 public:
void Destroy();
156 public:
void HandleKeyPress(
QKeyEvent *_e);
160 public:
void HandleKeyRelease(
QKeyEvent *_e);
163 private:
void HandleMouseEvent();
166 private:
void HandleMouseViewControl();
169 private:
void BroadcastHoverPos();
172 private:
void BroadcastLeftClick();
175 private:
void BroadcastRightClick();
178 private:
void BroadcastKeyRelease();
181 private:
void BroadcastKeyPress();
191 public: GLuint textureId = 0u;
209 public:
bool initialized =
false;
212 public:
QSize textureSize =
QSize(1024, 1024);
215 public:
bool textureDirty =
false;
248 public slots:
void RenderNext();
251 public slots:
void ShutDown();
254 public slots:
void SizeChanged();
260 signals:
void TextureReady(
int _id,
const QSize &_size);
270 public: QOffscreenSurface *surface =
nullptr;
273 public: QOpenGLContext *context =
nullptr;
281 class RenderWindowItem :
public QQuickItem
287 public:
explicit RenderWindowItem(QQuickItem *_parent =
nullptr);
290 public:
virtual ~RenderWindowItem();
294 public:
void SetBackgroundColor(
const math::Color &_color);
298 public:
void SetAmbientLight(
const math::Color &_ambient);
302 public:
void SetEngineName(
const std::string &_name);
306 public:
void SetSceneName(
const std::string &_name);
316 public:
void SetSceneService(
const std::string &_service);
322 public:
void SetPoseTopic(
const std::string &_topic);
328 public:
void SetDeletionTopic(
const std::string &_topic);
333 public:
void SetSceneTopic(
const std::string &_topic);
338 public:
void OnHovered(
const gz::math::Vector2i &_hoverPos);
341 public Q_SLOTS:
void Ready();
345 public:
void HandleKeyPress(
QKeyEvent *_e);
349 public:
void HandleKeyRelease(
QKeyEvent *_e);
352 protected:
virtual void mousePressEvent(
QMouseEvent *_e)
override;
355 protected:
virtual void mouseReleaseEvent(
QMouseEvent *_e)
override;
358 protected:
virtual void mouseMoveEvent(
QMouseEvent *_e)
override;
361 protected:
virtual void wheelEvent(
QWheelEvent *_e)
override;
364 protected:
virtual void keyPressEvent(
QKeyEvent *_event)
override;
367 protected:
virtual void keyReleaseEvent(
QKeyEvent *_event)
override;
375 private: QSGNode *updatePaintNode(QSGNode *_oldNode,
376 QQuickItem::UpdatePaintNodeData *_data)
override;
388 class TextureNode :
public QObject,
public QSGSimpleTextureNode
394 public:
explicit TextureNode(QQuickWindow *_window);
397 public: ~TextureNode()
override;
403 public slots:
void NewTexture(
int _id,
const QSize &_size);
407 public slots:
void PrepareNode();
411 signals:
void TextureInUse();
415 signals:
void PendingNewTexture();
427 public: QSGTexture *texture =
nullptr;
430 public: QQuickWindow *window =
nullptr;
QString loadingError
Loading error message.
Definition: Scene3D.hh:76
virtual void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override
Load the plugin with a configuration file. Override this on custom plugins to handle custom configura...
std::string sceneService
Scene service. If not empty, a request will be made to get the scene information using this service a...
Definition: Scene3D.hh:220
void OnFocusWindow()
Callback when the mouse enters the render window to focus the window for mouse/key events.
bool eventFilter(QObject *_obj, QEvent *_event) override
static const Vector2< T > Zero
Base class for Gazebo GUI plugins.
Definition: gz/gui/Plugin.hh:54
void LoadingErrorChanged()
Notify that loading error has changed.
std::string poseTopic
Scene pose topic. If not empty, a node will subcribe to this topic to get pose updates of objects in ...
Definition: Scene3D.hh:224
std::string deletionTopic
Ign-transport deletion topic name.
Definition: Scene3D.hh:227
Creates an ignition rendering scene and user camera. It is possible to orbit the camera around the sc...
Definition: Scene3D.hh:66
Rendering thread.
Definition: MinimalScene.hh:256
Ign-rendering renderer. All ign-rendering calls should be performed inside this class as it makes sur...
Definition: MinimalScene.hh:130
void OnHovered(int _mouseX, int _mouseY)
Callback when the mouse hovers to a new position.
Definition: gz/gui/Application.hh:35
std::string sceneTopic
Ign-transport scene topic name New scene messages will be published to this topic when an entities ar...
Definition: Scene3D.hh:232
Q_INVOKABLE QString LoadingError() const
Get the loading error string.
Q_INVOKABLE void SetLoadingError(const QString &_loadingError)
Set the loading error message.