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;
88 QString errorPopupText
90 WRITE SetErrorPopupText
91 NOTIFY ErrorPopupTextChanged
99 NOTIFY LoadingErrorChanged
106 public: ~Scene3D() override;
109 public:
void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override;
119 public slots:
void OnDropped(const QString &_drop,
120 int _mouseX,
int _mouseY);
125 public slots:
void OnHovered(
int _mouseX,
int _mouseY);
129 public slots:
void OnFocusWindow();
132 protected:
bool eventFilter(QObject *_obj, QEvent *_event) override;
138 private:
bool OnTransformMode(const msgs::StringMsg &_msg,
139 msgs::Boolean &_res);
145 private:
bool OnRecordVideo(const msgs::VideoRecord &_msg,
146 msgs::Boolean &_res);
152 private:
bool OnMoveTo(const msgs::StringMsg &_msg,
153 msgs::Boolean &_res);
159 private:
bool OnFollow(const msgs::StringMsg &_msg,
160 msgs::Boolean &_res);
166 private:
bool OnViewAngle(const msgs::
Vector3d &_msg,
167 msgs::Boolean &_res);
173 private:
bool OnMoveToPose(const msgs::GUICamera &_msg,
174 msgs::Boolean &_res);
180 private:
bool OnViewCollisions(const msgs::StringMsg &_msg,
181 msgs::Boolean &_res);
185 public: Q_INVOKABLE QString ErrorPopupText() const;
189 public: Q_INVOKABLE
void SetErrorPopupText(const QString &_errorTxt);
192 signals:
void ErrorPopupTextChanged();
197 signals:
void popupError();
201 public: Q_INVOKABLE QString LoadingError() const;
205 public: Q_INVOKABLE
void SetLoadingError(const QString &_loadingError);
208 signals:
void LoadingErrorChanged();
211 public: QString loadingError;
215 private:
std::unique_ptr<Scene3DPrivate> dataPtr;
235 public:
void Render();
243 public:
void Destroy();
250 public:
void SetTransformMode(
const std::string &_mode);
258 public:
void SetModelPath(
const std::string &_filePath);
263 public:
void SetDropdownMenuEnabled(
bool _enableDropdownMenu);
269 public:
void SetRecordVideo(
bool _record,
const std::string &_format,
274 public:
void SetRecordVideoUseSimTime(
bool _useSimTime);
278 public:
void SetRecordVideoLockstep(
bool _lockstep);
282 public:
void SetRecordVideoBitrate(
unsigned int _bitrate);
286 public:
void SetMoveTo(
const std::string &_target);
293 public:
void SetFollowTarget(
const std::string &_target,
294 bool _waitForTarget =
false);
308 public:
void SetViewCollisionsTarget(
const std::string &_target);
312 public:
void SetFollowPGain(
double _gain);
317 public:
void SetFollowWorldFrame(
bool _worldFrame);
329 public:
bool FollowWorldFrame()
const;
337 public:
void SetInitCameraPose(
const math::Pose3d &_pose);
351 public:
void HandleKeyPress(QKeyEvent *_e);
355 public:
void HandleKeyRelease(QKeyEvent *_e);
388 public:
void SnapPoint(
397 public:
void RequestSelectionChange(
Entity _selectedEntity,
398 bool _deselectAll,
bool _sendEvent);
408 private:
double SnapValue(
409 double _coord,
double _interval,
double _sensitivity)
const;
416 private:
void HandleMouseEvent();
419 private:
void HandleMouseContextMenu();
422 private:
void HandleMouseViewControl();
425 private:
void HandleMouseTransformControl();
428 private:
void HandleEntitySelection();
431 private:
void HandleModelPlacement();
434 private:
void BroadcastHoverPos();
437 private:
void BroadcastLeftClick();
440 private:
void BroadcastRightClick();
444 private:
Entity UniqueId();
449 public:
bool GeneratePreview(
const sdf::Root &_sdf);
452 public:
void TerminateSpawnPreview();
473 private:
void OnMoveToComplete();
476 private:
void OnViewAngleComplete();
479 private:
void OnMoveToPoseComplete();
485 private:
void UpdateSelectedEntity(
const rendering::NodePtr &_node,
491 private:
void DeselectAllEntities(
bool _sendEvent);
494 signals:
void ContextMenuRequested(QString _entity);
500 signals:
void FollowTargetChanged(
const std::string &_target,
501 bool _waitForTarget);
504 public: GLuint textureId = 0u;
513 public:
bool initialized =
false;
516 public: QSize textureSize = QSize(1024, 1024);
519 public:
bool textureDirty =
false;
535 public slots:
void RenderNext();
538 public slots:
void ShutDown();
541 public slots:
void SizeChanged();
547 signals:
void TextureReady(
int _id,
const QSize &_size);
551 public:
void SetErrorCb(
std::function<
void(
const QString &)> _cb);
557 public: QOffscreenSurface *surface =
nullptr;
560 public: QOpenGLContext *context =
nullptr;
592 public:
void SetInitCameraPose(
const math::Pose3d &_pose);
596 public:
void SetTransformMode(
const std::string &_mode);
604 public:
void SetModelPath(
const std::string &_filePath);
609 public:
void SetDropdownMenuEnabled(
bool _enableDropdownMenu);
615 public:
void SetRecordVideo(
bool _record,
const std::string &_format,
620 public:
void SetRecordVideoUseSimTime(
bool _useSimTime);
624 public:
void SetRecordVideoLockstep(
bool _lockstep);
628 public:
void SetRecordVideoBitrate(
unsigned int _bitrate);
632 public:
void SetMoveTo(
const std::string &_target);
639 public Q_SLOTS:
void SetFollowTarget(
const std::string &_target,
640 bool _waitForTarget =
false);
654 public:
void SetViewCollisionsTarget(
const std::string &_target);
658 public:
void SetFollowPGain(
double _gain);
663 public:
void SetFollowWorldFrame(
bool _worldFrame);
671 public:
void SetWorldName(
const std::string &_name);
683 public:
void UpdateSelectedEntity(
Entity _entity,
690 public:
void DeselectAllEntities(
bool _sendEvent);
719 public:
bool RendererInitialized()
const;
722 public Q_SLOTS:
void Ready();
726 public:
void HandleKeyPress(QKeyEvent *_e);
730 public:
void HandleKeyRelease(QKeyEvent *_e);
733 protected:
void mousePressEvent(QMouseEvent *_e)
override;
736 protected:
void mouseReleaseEvent(QMouseEvent *_e)
override;
739 protected:
void mouseMoveEvent(QMouseEvent *_e)
override;
742 protected:
void wheelEvent(QWheelEvent *_e)
override;
750 private: QSGNode *updatePaintNode(QSGNode *_oldNode,
751 QQuickItem::UpdatePaintNodeData *_data)
override;
757 signals:
void openContextMenu(QString _entity);
761 public slots:
void OnContextMenuRequested(QString _entity);
765 public:
void SetErrorCb(
std::function<
void(
const QString &)> _cb);
779 public:
explicit TextureNode(QQuickWindow *_window);
788 public slots:
void NewTexture(
int _id,
const QSize &_size);
792 public slots:
void PrepareNode();
796 signals:
void TextureInUse();
800 signals:
void PendingNewTexture();
806 public: QSize size = QSize(0, 0);
812 public: QSGTexture *texture =
nullptr;
815 public: QQuickWindow *window =
nullptr;
std::string worldName
Name of the world.
Definition: Scene3D.hh:510
IgnRenderer ignRenderer
Ign-rendering renderer.
Definition: Scene3D.hh:563
Texture node for displaying the render texture from ign-renderer.
Definition: Scene3D.hh:773
A QQUickItem that manages the render window.
Definition: Scene3D.hh:568
Information passed to systems on the update callback.
Definition: include/ignition/gazebo/Types.hh:37
QMutex mutex
Mutex to protect the texture variables.
Definition: Scene3D.hh:809
The EntityComponentManager constructs, deletes, and returns components and entities. A component can be of any class which inherits from components::BaseComponent.
Definition: EntityComponentManager.hh:64
Creates an ignition rendering scene and user camera. It is possible to orbit the camera around the sc...
Definition: Scene3D.hh:82
Ign-rendering renderer. All ign-rendering calls should be performed inside this class as it makes sur...
Definition: Scene3D.hh:224
static const Vector2< T > Zero
std::function< void(const QString &)> errorCb
Function to be called if there are errors.
Definition: Scene3D.hh:554
Rendering thread.
Definition: Scene3D.hh:527
Vector3< double > Vector3d
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