ModelManipulator.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 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 GAZEBO_GUI_MODELMANIPULATOR_HH_
18 #define GAZEBO_GUI_MODELMANIPULATOR_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <ignition/math/Vector2.hh>
23 #include <ignition/math/Vector3.hh>
24 #include <ignition/math/Pose3.hh>
25 
26 #include "gazebo/math/Vector2i.hh"
27 #include "gazebo/math/Vector3.hh"
28 #include "gazebo/math/Pose.hh"
29 
32 
34 
36 #include "gazebo/util/system.hh"
37 
38 namespace gazebo
39 {
40  namespace gui
41  {
42  class ModelManipulatorPrivate;
43 
47  class GZ_GUI_VISIBLE ModelManipulator : public SingletonT<ModelManipulator>
48  {
50  private: ModelManipulator();
51 
53  private: virtual ~ModelManipulator();
54 
56  public: void Init();
57 
60  public: void Clear();
61 
63  public: void Detach();
64 
67  public: void SetManipulationMode(const std::string &_mode);
68 
70  public: void SetAttachedVisual(rendering::VisualPtr _vis);
71 
74  public: void OnMousePressEvent(const common::MouseEvent &_event);
75 
78  public: void OnMouseMoveEvent(const common::MouseEvent &_event);
79 
82  public: void OnMouseReleaseEvent(const common::MouseEvent &_event);
83 
86  public: void OnKeyPressEvent(const common::KeyEvent &_event);
87 
90  public: void OnKeyReleaseEvent(const common::KeyEvent &_event);
91 
97  public: void RotateEntity(rendering::VisualPtr &_vis,
98  const math::Vector3 &_axis,
99  bool _local = false) GAZEBO_DEPRECATED(8.0);
100 
105  public: void RotateEntity(rendering::VisualPtr &_vis,
106  const ignition::math::Vector3d &_axis,
107  const bool _local = false);
108 
114  public: void TranslateEntity(rendering::VisualPtr &_vis,
115  const math::Vector3 &_axis,
116  bool _local = false) GAZEBO_DEPRECATED(8.0);
117 
122  public: void TranslateEntity(rendering::VisualPtr &_vis,
123  const ignition::math::Vector3d &_axis,
124  const bool _local = false);
125 
131  public: void ScaleEntity(rendering::VisualPtr &_vis,
132  const math::Vector3 &_axis,
133  bool _local = false) GAZEBO_DEPRECATED(8.0);
134 
139  public: void ScaleEntity(rendering::VisualPtr &_vis,
140  const ignition::math::Vector3d &_axis,
141  const bool _local = false);
142 
152  public: static math::Vector3 SnapPoint(const math::Vector3 &_point,
153  double _interval = 1.0, double _sensitivity = 0.4)
154  GAZEBO_DEPRECATED(8.0);
155 
164  public: static ignition::math::Vector3d SnapPoint(
165  const ignition::math::Vector3d &_point,
166  const double _interval = 1.0, const double _sensitivity = 0.4);
167 
174  public: static math::Vector3 GetMousePositionOnPlane(
175  rendering::CameraPtr _camera,
176  const common::MouseEvent &_event) GAZEBO_DEPRECATED(8.0);
177 
183  public: static ignition::math::Vector3d MousePositionOnPlane(
184  rendering::CameraPtr _camera,
185  const common::MouseEvent &_event);
186 
196  public: static math::Vector3 GetMouseMoveDistance(
197  rendering::CameraPtr _camera,
198  const math::Vector2i &_start, const math::Vector2i &_end,
199  const math::Pose &_pose, const math::Vector3 &_axis,
200  bool _local) GAZEBO_DEPRECATED(8.0);
201 
210  public: static ignition::math::Vector3d MouseMoveDistance(
211  rendering::CameraPtr _camera,
212  const ignition::math::Vector2i &_start,
213  const ignition::math::Vector2i &_end,
214  const ignition::math::Pose3d &_pose,
215  const ignition::math::Vector3d &_axis, const bool _local);
216 
222  private: ignition::math::Vector3d MouseMoveDistance(
223  const ignition::math::Pose3d &_pose,
224  const ignition::math::Vector3d &_axis, const bool _local) const;
225 
228  private: void SetMouseMoveVisual(rendering::VisualPtr _vis);
229 
232  private: void PublishVisualPose(rendering::VisualPtr _vis);
233 
236  private: void PublishVisualScale(rendering::VisualPtr _vis);
237 
244  private: ignition::math::Vector3d UpdateScale(
245  const ignition::math::Vector3d &_axis,
246  const ignition::math::Vector3d &_scale, const std::string &_geom);
247 
249  private: friend class SingletonT<ModelManipulator>;
250 
253  private: std::unique_ptr<ModelManipulatorPrivate> dataPtr;
254  };
255  }
256 }
257 #endif
Generic description of a mouse event.
Definition: MouseEvent.hh:35
Forward declarations for the common classes.
Definition: Animation.hh:33
Encapsulates a position and rotation in three space.
Definition: Pose.hh:42
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:44
Generic integer x, y vector.
Definition: Vector2i.hh:36
Generic description of a keyboard event.
Definition: KeyEvent.hh:32
Singleton template class.
Definition: SingletonT.hh:33
Manipulator tool for translating/rotating/scaling models and links.
Definition: ModelManipulator.hh:47
#define GAZEBO_DEPRECATED(version)
Definition: system.hh:302
std::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:113
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
boost::shared_ptr< Camera > CameraPtr
Definition: RenderTypes.hh:89