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 
51  public: void Detach();
52 
55  public: void SetManipulationMode(const std::string &_mode);
56 
58  public: void SetAttachedVisual(rendering::VisualPtr _vis);
59 
62  public: void OnMousePressEvent(const common::MouseEvent &_event);
63 
66  public: void OnMouseMoveEvent(const common::MouseEvent &_event);
67 
70  public: void OnMouseReleaseEvent(const common::MouseEvent &_event);
71 
74  public: void OnKeyPressEvent(const common::KeyEvent &_event);
75 
78  public: void OnKeyReleaseEvent(const common::KeyEvent &_event);
79 
84  public: void RotateEntity(rendering::VisualPtr &_vis,
85  const math::Vector3 &_axis,
86  bool _local = false);
87 
92  public: void TranslateEntity(rendering::VisualPtr &_vis,
93  const math::Vector3 &_axis,
94  bool _local = false);
95 
100  public: void ScaleEntity(rendering::VisualPtr &_vis,
101  const math::Vector3 &_axis,
102  bool _local = false);
103 
112  public: static math::Vector3 SnapPoint(const math::Vector3 &_point,
113  double _interval = 1.0, double _sensitivity = 0.4);
114 
120  public: static math::Vector3 GetMousePositionOnPlane(
121  rendering::CameraPtr _camera,
122  const common::MouseEvent &_event);
123 
130  public: static math::Vector3 GetMouseMoveDistance(
131  rendering::CameraPtr _camera,
132  const math::Vector2i &_start, const math::Vector2i &_end,
133  const math::Pose &_pose, const math::Vector3 &_axis,
134  bool _local);
135 
141  private: math::Vector3 GetMouseMoveDistance(const math::Pose &_pose,
142  const math::Vector3 &_axis, bool _local) const;
143 
146  private: void SetMouseMoveVisual(rendering::VisualPtr _vis);
147 
150  private: void PublishVisualPose(rendering::VisualPtr _vis);
151 
154  private: void PublishVisualScale(rendering::VisualPtr _vis);
155 
157  private: friend class SingletonT<ModelManipulator>;
158 
161  private: ModelManipulatorPrivate *dataPtr;
162  };
163  }
164 }
165 #endif
Generic description of a mouse event.
Definition: MouseEvent.hh:32
Encapsulates a position and rotation in three space.
Definition: Pose.hh:40
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:43
Generic integer x, y vector.
Definition: Vector2i.hh:39
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:82
Private data for the ModelManipulator class.
Definition: ModelManipulatorPrivate.hh:34
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:102
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48