18 #ifndef GZ_GUI_PLUGINS_MINIMALSCENE_HH_
19 #define GZ_GUI_PLUGINS_MINIMALSCENE_HH_
24 #include <gz/common/KeyEvent.hh>
25 #include <gz/common/MouseEvent.hh>
26 #include <gz/math/Color.hh>
27 #include <gz/math/Pose3.hh>
28 #include <gz/math/Vector2.hh>
29 #include <gz/utils/ImplPtr.hh>
30 #include <gz/rendering/GraphicsAPI.hh>
36 namespace gz::gui::plugins
78 NOTIFY LoadingErrorChanged
87 public slots:
void OnHovered(
int _mouseX,
int _mouseY);
91 public slots:
void OnFocusWindow();
97 public slots:
void OnDropped(const
QString &_drop,
98 int _mouseX,
int _mouseY);
101 public: virtual
void LoadConfig(const
tinyxml2::XMLElement *_pluginElem)
106 public: Q_INVOKABLE
QString LoadingError() const;
110 public: Q_INVOKABLE
void SetLoadingError(const
QString &_loadingError);
113 signals:
void LoadingErrorChanged();
120 GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
138 public:
void Render(RenderSync *_renderSync);
151 public:
void Destroy();
155 public:
void NewMouseEvent(
const common::MouseEvent &_e);
164 public:
void NewDropEvent(
const std::string &_dropText,
169 public:
void HandleKeyPress(
const common::KeyEvent &_e);
173 public:
void HandleKeyRelease(
const common::KeyEvent &_e);
176 private:
void HandleMouseEvent();
179 private:
void BroadcastHoverPos();
182 private:
void BroadcastDrag();
185 private:
void BroadcastLeftClick();
188 private:
void BroadcastRightClick();
191 private:
void BroadcastMousePress();
194 private:
void BroadcastScroll();
197 private:
void BroadcastKeyRelease();
200 private:
void BroadcastDrop();
203 private:
void BroadcastKeyPress();
209 public:
void TextureId(
void* _texturePtr);
221 public:
double cameraNearClip = 0.01;
224 public:
double cameraFarClip = 1000.0;
230 public: math::Color ambientLight = math::Color(0.3f, 0.3f, 0.3f, 1.0f);
233 public:
bool initialized =
false;
239 public:
bool textureDirty =
true;
242 public:
bool skyEnable =
false;
245 public: math::Angle cameraHFOV = math::Angle(M_PI * 0.5);
252 GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
266 public slots:
void RenderNext(RenderSync *_renderSync);
269 public slots:
void ShutDown();
272 public slots:
void SizeChanged();
278 signals:
void TextureReady(
void* _texturePtr,
const QSize &_size);
288 public: QOffscreenSurface *Surface()
const;
292 public:
void SetSurface(QOffscreenSurface *_surface);
295 public: QOpenGLContext *Context()
const;
299 public:
void SetContext(QOpenGLContext *_context);
329 public:
void SetBackgroundColor(
const math::Color &_color);
333 public:
void SetAmbientLight(
const math::Color &_ambient);
337 public:
void SetEngineName(
const std::string &_name);
341 public:
void SetSceneName(
const std::string &_name);
349 public:
void SetCameraNearClip(
double _near);
353 public:
void SetCameraFarClip(
double _far);
363 public:
void OnDropped(
const QString &_drop,
368 public:
void SetSkyEnabled(
const bool &_sky);
372 public:
void SetCameraHFOV(
const math::Angle &_fov);
380 public:
void SetCameraViewController(
const std::string &_view_controller);
383 public Q_SLOTS:
void Ready();
387 public:
void HandleKeyPress(
const common::KeyEvent &_e);
391 public:
void HandleKeyRelease(
const common::KeyEvent &_e);
398 public:
void StopRendering();
401 protected:
virtual void mousePressEvent(
QMouseEvent *_e)
override;
404 protected:
virtual void mouseReleaseEvent(
QMouseEvent *_e)
override;
407 protected:
virtual void mouseMoveEvent(
QMouseEvent *_e)
override;
410 protected:
virtual void keyPressEvent(
QKeyEvent *_e)
override;
413 protected:
virtual void keyReleaseEvent(
QKeyEvent *_e)
override;
416 protected:
virtual void wheelEvent(
QWheelEvent *_e)
override;
424 private: QSGNode *updatePaintNode(QSGNode *_oldNode,
425 QQuickItem::UpdatePaintNodeData *_data)
override;
429 GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
442 public:
explicit TextureNode(QQuickWindow *_window,
443 RenderSync &_renderSync,
454 public slots:
void NewTexture(
void* _texturePtr,
const QSize &_size);
458 public slots:
void PrepareNode();
461 signals:
void TextureInUse(RenderSync *_renderSync);
465 signals:
void PendingNewTexture();
477 public: QQuickWindow *window =
nullptr;
484 #endif // GZ_GUI_PLUGINS_MINIMALSCENE_HH_