Gazebo Rendering

API Reference

6.6.3
gz/rendering/TransformController.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 #ifndef GZ_RENDERING_TRANSFORMCONTROLLER_HH_
18 #define GZ_RENDERING_TRANSFORMCONTROLLER_HH_
19 
20 #include <memory>
21 
22 #include <gz/common/SuppressWarning.hh>
23 
24 #include <gz/math/Quaternion.hh>
25 #include <gz/math/Plane.hh>
26 #include <gz/math/Vector3.hh>
27 
28 #include "gz/rendering/config.hh"
29 #include "gz/rendering/Camera.hh"
32 
33 namespace ignition
34 {
35  namespace rendering
36  {
37  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
38  //
39  // forward declarations
40  class TransformControllerPrivate;
41 
42  /* \class TransformController TransformController.hh \
43  * ignition/rendering/TransformController.hh
44  */
46  class IGNITION_RENDERING_VISIBLE TransformController
47  {
49  public: TransformController();
50 
52  public: virtual ~TransformController();
53 
56  public: virtual void Update();
57 
60  public: virtual void SetCamera(const CameraPtr &_camera);
61 
64  public: virtual CameraPtr Camera() const;
65 
69  public: virtual NodePtr Node() const;
70 
73  public: virtual void Attach(NodePtr _node);
74 
77  public: virtual void Detach();
78 
81  public: virtual void SetTransformMode(TransformMode _mode);
82 
85  public: virtual TransformMode Mode() const;
86 
89  public: virtual void SetTransformSpace(TransformSpace _space);
90 
93  public: virtual TransformSpace Space() const;
94 
97  public: virtual void SetActiveAxis(const math::Vector3d &_axis);
98 
101  public: virtual math::Vector3d ActiveAxis() const;
102 
106  public: virtual math::Vector3d AxisById(unsigned int _id) const;
107 
112  public: virtual void Translate(const math::Vector3d &_translation,
113  bool _snap = false);
114 
119  public: virtual void Rotate(const math::Quaterniond &_rotation,
120  bool _snap = false);
121 
126  public: virtual void Scale(const math::Vector3d &_scale,
127  bool _snap = false);
128 
137  public: static gz::math::Vector3d SnapPoint(
138  const gz::math::Vector3d &_point, const double _interval = 1.0,
139  const double _sensitivity = 0.4);
140 
144  public: virtual void Start();
145 
149  public: virtual void Stop();
150 
153  public: virtual bool Active() const;
154 
164  public: math::Vector3d TranslationFrom2d(const math::Vector3d &_axis,
165  const math::Vector2d &_start, const math::Vector2d &_end);
166 
176  public: math::Quaterniond RotationFrom2d(const math::Vector3d &_axis,
177  const math::Vector2d &_start, const math::Vector2d &_end);
178 
188  public: math::Vector3d ScaleFrom2d(const math::Vector3d &_axis,
189  const math::Vector2d &_start, const math::Vector2d &_end);
190 
194  public: static math::Vector3d ToAxis(TransformAxis _axis);
195 
203  protected: math::Planed CreatePlaneForTransform(
204  const math::Vector3d &_axis, const math::Vector2d &_pt2d);
205 
212  protected: bool RayPlaneIntersection(RayQueryPtr _ray,
213  const math::Planed &_plane, math::Vector3d &_result);
214 
219  };
220  }
221  }
222 }
223 #endif
virtual void SetTransformSpace(TransformSpace _space)
Set the transform space.
virtual void Attach(NodePtr _node)
Attach the transform controller to the specified node.
Represents a single posable node in the scene graph.
Definition: gz/rendering/Node.hh:51
STL class.
TransformAxis
Unique identifiers for transformation axes.
Definition: gz/rendering/TransformType.hh:34
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
virtual CameraPtr Camera() const
get the camera that is controlled by this view controller.
virtual void Start()
Start the transform process. To be used with helper functions that computions transforms from 2d move...
math::Quaterniond RotationFrom2d(const math::Vector3d &_axis, const math::Vector2d &_start, const math::Vector2d &_end)
Helper function to compute 3d rotation from 2d translation movement. Useful for converting 2d mouse d...
virtual void SetCamera(const CameraPtr &_camera)
Set the camera.
virtual void SetTransformMode(TransformMode _mode)
Set the transform mode.
math::Planed CreatePlaneForTransform(const math::Vector3d &_axis, const math::Vector2d &_pt2d)
Helper function to create a plane for transfomation. The plane is chosen based on the current transfo...
virtual TransformSpace Space() const
Get the transform space.
math::Vector3d TranslationFrom2d(const math::Vector3d &_axis, const math::Vector2d &_start, const math::Vector2d &_end)
Helper function to compute 3d translation from 2d translation movement. Useful for converting 2d mous...
Posable camera used for rendering the scene graph.
Definition: gz/rendering/Camera.hh:49
virtual math::Vector3d ActiveAxis() const
Get the current highlighted active axis of transform.
virtual void Translate(const math::Vector3d &_translation, bool _snap=false)
Translate the attached node.
virtual TransformMode Mode() const
Get the current transform mode.
virtual void Stop()
Stop the transform process. To be used with helper functions that computions transforms from 2d movem...
An transform tool for translating, rotating, and scaling objects.
Definition: gz/rendering/TransformController.hh:46
virtual void Detach()
Detach the transform controller from the currently attached node.
static math::Vector3d ToAxis(TransformAxis _axis)
Convert a TransformAxis to a vector type.
virtual bool Active() const
Check if the transform process is active.
virtual void SetActiveAxis(const math::Vector3d &_axis)
Set the active transform axis. This highlights the axis visual.
std::unique_ptr< TransformControllerPrivate > dataPtr
Private data pointer.
Definition: gz/rendering/TransformController.hh:217
TransformSpace
Unique identifiers for transformation spaces.
Definition: gz/rendering/TransformType.hh:74
static gz::math::Vector3d SnapPoint(const gz::math::Vector3d &_point, const double _interval=1.0, const double _sensitivity=0.4)
Snap a point at intervals of a fixed distance. Currently used to give a snapping behavior when transf...
virtual NodePtr Node() const
Get the attached node.
TransformMode
Unique identifiers for transformation modes.
Definition: gz/rendering/TransformType.hh:60
math::Vector3d ScaleFrom2d(const math::Vector3d &_axis, const math::Vector2d &_start, const math::Vector2d &_end)
Helper function to compute 3d scale from 2d translation movement. Useful for converting 2d mouse drag...
bool RayPlaneIntersection(RayQueryPtr _ray, const math::Planed &_plane, math::Vector3d &_result)
Helper function to compute ray plane intersection.
virtual void Scale(const math::Vector3d &_scale, bool _snap=false)
Scale the attached node.
virtual void Rotate(const math::Quaterniond &_rotation, bool _snap=false)
Rotate the attached node.
virtual math::Vector3d AxisById(unsigned int _id) const
Get the axis of transform represented by the given node id.
virtual void Update()
Update the transform controller. Its visual is updated based on the current transform mode,...
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING