ModelManipulator.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2015 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 _MODEL_MANIPULATOR_HH_
18 #define _MODEL_MANIPULATOR_HH_
19 
20 #include <string>
21 
24 
26 
28 #include "gazebo/util/system.hh"
29 
30 namespace gazebo
31 {
32  namespace gui
33  {
34  class ModelManipulatorPrivate;
35 
39  class GAZEBO_VISIBLE ModelManipulator : public SingletonT<ModelManipulator>
40  {
42  private: ModelManipulator();
43 
45  private: virtual ~ModelManipulator();
46 
48  public: void Init();
49 
52  public: void Clear();
53 
55  public: void Detach();
56 
59  public: void SetManipulationMode(const std::string &_mode);
60 
62  public: void SetAttachedVisual(rendering::VisualPtr _vis);
63 
66  public: void OnMousePressEvent(const common::MouseEvent &_event);
67 
70  public: void OnMouseMoveEvent(const common::MouseEvent &_event);
71 
74  public: void OnMouseReleaseEvent(const common::MouseEvent &_event);
75 
78  public: void OnKeyPressEvent(const common::KeyEvent &_event);
79 
82  public: void OnKeyReleaseEvent(const common::KeyEvent &_event);
83 
88  public: void RotateEntity(rendering::VisualPtr &_vis,
89  const math::Vector3 &_axis,
90  bool _local = false);
91 
96  public: void TranslateEntity(rendering::VisualPtr &_vis,
97  const math::Vector3 &_axis,
98  bool _local = false);
99 
104  public: void ScaleEntity(rendering::VisualPtr &_vis,
105  const math::Vector3 &_axis,
106  bool _local = false);
107 
116  public: static math::Vector3 SnapPoint(const math::Vector3 &_point,
117  double _interval = 1.0, double _sensitivity = 0.4);
118 
124  public: static math::Vector3 GetMousePositionOnPlane(
125  rendering::CameraPtr _camera,
126  const common::MouseEvent &_event);
127 
136  public: static math::Vector3 GetMouseMoveDistance(
137  rendering::CameraPtr _camera,
138  const math::Vector2i &_start, const math::Vector2i &_end,
139  const math::Pose &_pose, const math::Vector3 &_axis,
140  bool _local);
141 
147  private: math::Vector3 GetMouseMoveDistance(const math::Pose &_pose,
148  const math::Vector3 &_axis, bool _local) const;
149 
152  private: void SetMouseMoveVisual(rendering::VisualPtr _vis);
153 
156  private: void PublishVisualPose(rendering::VisualPtr _vis);
157 
160  private: void PublishVisualScale(rendering::VisualPtr _vis);
161 
168  private: math::Vector3 UpdateScale(const math::Vector3 &_axis,
169  const math::Vector3 &_scale, const std::string &_geom);
170 
172  private: friend class SingletonT<ModelManipulator>;
173 
176  private: ModelManipulatorPrivate *dataPtr;
177  };
178  }
179 }
180 #endif
Generic description of a mouse event.
Definition: MouseEvent.hh:35
Encapsulates a position and rotation in three space.
Definition: Pose.hh:37
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:39
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
boost::shared_ptr< Camera > CameraPtr
Definition: RenderTypes.hh:87
Private data for the ModelManipulator class.
Definition: ModelManipulatorPrivate.hh:35
Manipulator tool for translating/rotating/scaling models and links.
Definition: ModelManipulator.hh:39
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
boost::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:107
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:66