18 #ifndef IGNITION_GAZEBO_GUI_SCENE3D_HH_ 19 #define IGNITION_GAZEBO_GUI_SCENE3D_HH_ 31 #include <sdf/Root.hh> 41 #include <ignition/rendering/Camera.hh> 45 #include "ignition/gui/qt.h" 53 inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
54 class IgnRendererPrivate;
55 class RenderWindowItemPrivate;
85 QString errorPopupText
87 WRITE SetErrorPopupText
88 NOTIFY ErrorPopupTextChanged
95 public: ~Scene3D() override;
98 public:
void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override;
108 public slots:
void OnDropped(const QString &_drop,
109 int _mouseX,
int _mouseY);
114 public slots:
void OnHovered(
int _mouseX,
int _mouseY);
118 public slots:
void OnFocusWindow();
121 protected:
bool eventFilter(QObject *_obj, QEvent *_event) override;
127 private:
bool OnTransformMode(const msgs::StringMsg &_msg,
128 msgs::Boolean &_res);
134 private:
bool OnRecordVideo(const msgs::VideoRecord &_msg,
135 msgs::Boolean &_res);
141 private:
bool OnMoveTo(const msgs::StringMsg &_msg,
142 msgs::Boolean &_res);
148 private:
bool OnFollow(const msgs::StringMsg &_msg,
149 msgs::Boolean &_res);
155 private:
bool OnFollowOffset(const msgs::
Vector3d &_msg,
156 msgs::Boolean &_res);
162 private:
bool OnViewAngle(const msgs::
Vector3d &_msg,
163 msgs::Boolean &_res);
169 private:
bool OnMoveToPose(const msgs::GUICamera &_msg,
170 msgs::Boolean &_res);
177 private:
bool OnViewTransparent(const msgs::StringMsg &_msg,
178 msgs::Boolean &_res);
185 private:
bool OnViewCOM(const msgs::StringMsg &_msg,
186 msgs::Boolean &_res);
192 private:
bool OnViewInertia(const msgs::StringMsg &_msg,
193 msgs::Boolean &_res);
199 private:
bool OnViewJoints(const msgs::StringMsg &_msg,
200 msgs::Boolean &_res);
206 private:
bool OnViewWireframes(const msgs::StringMsg &_msg,
207 msgs::Boolean &_res);
213 private:
bool OnViewCollisions(const msgs::StringMsg &_msg,
214 msgs::Boolean &_res);
218 public: Q_INVOKABLE QString ErrorPopupText() const;
222 public: Q_INVOKABLE
void SetErrorPopupText(const QString &_errorTxt);
225 signals:
void ErrorPopupTextChanged();
230 signals:
void popupError();
236 private:
bool OnViewControl(const msgs::StringMsg &_msg,
237 msgs::Boolean &_res);
241 private:
std::unique_ptr<Scene3DPrivate> dataPtr;
265 public:
void Render(RenderSync *_renderSync);
268 public:
void Initialize();
271 public:
void Destroy();
278 public:
void SetTransformMode(
const std::string &_mode);
286 public:
void SetModelPath(
const std::string &_filePath);
291 public:
void SetDropdownMenuEnabled(
bool _enableDropdownMenu);
297 public:
void SetRecordVideo(
bool _record,
const std::string &_format,
302 public:
void SetRecordVideoUseSimTime(
bool _useSimTime);
306 public:
void SetRecordVideoLockstep(
bool _lockstep);
310 public:
void SetRecordVideoBitrate(
unsigned int _bitrate);
314 public:
void SetMoveTo(
const std::string &_target);
321 public:
void SetFollowTarget(
const std::string &_target,
322 bool _waitForTarget =
false);
336 public:
void SetViewTransparentTarget(
const std::string &_target);
340 public:
void SetViewCOMTarget(
const std::string &_target);
344 public:
void SetViewInertiaTarget(
const std::string &_target);
348 public:
void SetViewJointsTarget(
const std::string &_target);
352 public:
void SetViewWireframesTarget(
const std::string &_target);
356 public:
void SetViewCollisionsTarget(
const std::string &_target);
360 public:
void SetViewController(
const std::string &_viewController);
364 public:
void SetFollowPGain(
double _gain);
369 public:
void SetFollowWorldFrame(
bool _worldFrame);
381 public:
bool FollowWorldFrame()
const;
389 public:
void SetInitCameraPose(
const math::Pose3d &_pose);
403 public:
void HandleKeyPress(QKeyEvent *_e);
407 public:
void HandleKeyRelease(QKeyEvent *_e);
440 public:
void SnapPoint(
449 public:
void RequestSelectionChange(
Entity _selectedEntity,
450 bool _deselectAll,
bool _sendEvent);
460 private:
double SnapValue(
461 double _coord,
double _interval,
double _sensitivity)
const;
468 private:
void HandleMouseEvent();
471 private:
void HandleMouseContextMenu();
474 private:
void HandleMouseViewControl();
477 private:
void HandleMouseTransformControl();
480 private:
void HandleEntitySelection();
483 private:
void HandleModelPlacement();
486 private:
void BroadcastHoverPos();
489 private:
void BroadcastLeftClick();
492 private:
void BroadcastRightClick();
496 private:
Entity UniqueId();
501 public:
bool GeneratePreview(
const sdf::Root &_sdf);
504 public:
void TerminateSpawnPreview();
525 private:
void OnMoveToComplete();
528 private:
void OnViewAngleComplete();
531 private:
void OnMoveToPoseComplete();
537 private:
void UpdateSelectedEntity(
const rendering::NodePtr &_node,
543 private:
void DeselectAllEntities(
bool _sendEvent);
546 signals:
void ContextMenuRequested(QString _entity);
552 signals:
void FollowTargetChanged(
const std::string &_target,
553 bool _waitForTarget);
568 public: uint32_t visibilityMask = 0xFFFFFFFFu;
571 public:
bool initialized =
false;
574 public: QSize textureSize = QSize(1024, 1024);
577 public:
bool textureDirty =
false;
595 public slots:
void RenderNext(RenderSync *renderSync);
598 public slots:
void ShutDown();
601 public slots:
void SizeChanged();
607 signals:
void TextureReady(uint _id,
const QSize &_size);
610 public: QOffscreenSurface *surface =
nullptr;
613 public: QOpenGLContext *context =
nullptr;
645 public:
void SetInitCameraPose(
const math::Pose3d &_pose);
649 public:
void SetVisibilityMask(uint32_t _mask);
653 public:
void SetTransformMode(
const std::string &_mode);
661 public:
void SetModelPath(
const std::string &_filePath);
666 public:
void SetDropdownMenuEnabled(
bool _enableDropdownMenu);
672 public:
void SetRecordVideo(
bool _record,
const std::string &_format,
677 public:
void SetRecordVideoUseSimTime(
bool _useSimTime);
681 public:
void SetRecordVideoLockstep(
bool _lockstep);
685 public:
void SetRecordVideoBitrate(
unsigned int _bitrate);
689 public:
void SetMoveTo(
const std::string &_target);
696 public Q_SLOTS:
void SetFollowTarget(
const std::string &_target,
697 bool _waitForTarget =
false);
711 public:
void SetViewTransparentTarget(
const std::string &_target);
715 public:
void SetViewCOMTarget(
const std::string &_target);
719 public:
void SetViewInertiaTarget(
const std::string &_target);
723 public:
void SetViewJointsTarget(
const std::string &_target);
727 public:
void SetViewWireframesTarget(
const std::string &_target);
731 public:
void SetViewCollisionsTarget(
const std::string &_target);
735 public:
void SetViewController(
const std::string &_viewController);
739 public:
void SetFollowPGain(
double _gain);
744 public:
void SetFollowWorldFrame(
bool _worldFrame);
752 public:
void SetWorldName(
const std::string &_name);
764 public:
void UpdateSelectedEntity(
Entity _entity,
771 public:
void DeselectAllEntities(
bool _sendEvent);
800 public:
bool RendererInitialized()
const;
803 public Q_SLOTS:
void Ready();
807 public:
void HandleKeyPress(QKeyEvent *_e);
811 public:
void HandleKeyRelease(QKeyEvent *_e);
814 protected:
void mousePressEvent(QMouseEvent *_e)
override;
817 protected:
void mouseReleaseEvent(QMouseEvent *_e)
override;
820 protected:
void mouseMoveEvent(QMouseEvent *_e)
override;
823 protected:
void wheelEvent(QWheelEvent *_e)
override;
831 private: QSGNode *updatePaintNode(QSGNode *_oldNode,
832 QQuickItem::UpdatePaintNodeData *_data)
override;
838 signals:
void openContextMenu(QString _entity);
842 public slots:
void OnContextMenuRequested(QString _entity);
858 public:
explicit TextureNode(QQuickWindow *_window,
859 RenderSync &_renderSync);
868 public slots:
void NewTexture(uint _id,
const QSize &_size);
872 public slots:
void PrepareNode();
877 signals:
void TextureInUse(RenderSync *_renderSync);
881 signals:
void PendingNewTexture();
887 public: QSize size = QSize(0, 0);
896 public: QSGTexture *texture =
nullptr;
899 public: QQuickWindow *window =
nullptr;
std::string worldName
Name of the world.
Definition: Scene3D.hh:565
IgnRenderer ignRenderer
Ign-rendering renderer.
Definition: Scene3D.hh:616
Texture node for displaying the render texture from ign-renderer.
Definition: Scene3D.hh:850
A QQUickItem that manages the render window.
Definition: Scene3D.hh:621
Information passed to systems on the update callback.
Definition: Types.hh:38
QMutex mutex
Mutex to protect the texture variables.
Definition: Scene3D.hh:890
The EntityComponentManager constructs, deletes, and returns components and entities. A component can be of any class which inherits from components::BaseComponent.
Definition: EntityComponentManager.hh:66
Creates a new ignition rendering scene or adds a user-camera to an existing scene. It is possible to orbit the camera around the scene with the mouse. Use other plugins to manage objects in the scene.
Definition: Scene3D.hh:79
Ign-rendering renderer. All ign-rendering calls should be performed inside this class as it makes sur...
Definition: Scene3D.hh:252
static const Vector2< T > Zero
Rendering thread.
Definition: Scene3D.hh:585
Vector3< double > Vector3d
RenderSync & renderSync
See RenderSync.
Definition: Scene3D.hh:893
GLuint textureId
Render texture id Values is constantly constantly cycled/swapped/changed from a worker thread Don't r...
Definition: Scene3D.hh:559
This library is part of the Ignition Robotics project.
Base class for a GUI System.
Definition: GuiSystem.hh:44
uint64_t Entity
An Entity identifies a single object in simulation such as a model, link, or light. At its core, an Entity is just an identifier.
Definition: Entity.hh:59
Definition: RenderUtil.hh:44