All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ModelManipulator.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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 SetManipulationMode(const std::string &_mode);
53 
55  public: void SetAttachedVisual(rendering::VisualPtr _vis);
56 
59  public: void OnMousePressEvent(const common::MouseEvent &_event);
60 
63  public: void OnMouseMoveEvent(const common::MouseEvent &_event);
64 
67  public: void OnMouseReleaseEvent(const common::MouseEvent &_event);
68 
71  public: void OnKeyPressEvent(const common::KeyEvent &_event);
72 
75  public: void OnKeyReleaseEvent(const common::KeyEvent &_event);
76 
81  public: void RotateEntity(rendering::VisualPtr &_vis,
82  const math::Vector3 &_axis,
83  bool _local = false);
84 
89  public: void TranslateEntity(rendering::VisualPtr &_vis,
90  const math::Vector3 &_axis,
91  bool _local = false);
92 
97  public: void ScaleEntity(rendering::VisualPtr &_vis,
98  const math::Vector3 &_axis,
99  bool _local = false);
100 
109  public: static math::Vector3 SnapPoint(const math::Vector3 &_point,
110  double _interval = 1.0, double _sensitivity = 0.4);
111 
117  public: static math::Vector3 GetMousePositionOnPlane(
118  rendering::CameraPtr _camera,
119  const common::MouseEvent &_event);
120 
127  public: static math::Vector3 GetMouseMoveDistance(
128  rendering::CameraPtr _camera,
129  const math::Vector2i &_start, const math::Vector2i &_end,
130  const math::Pose &_pose, const math::Vector3 &_axis,
131  bool _local);
132 
138  private: math::Vector3 GetMouseMoveDistance(const math::Pose &_pose,
139  const math::Vector3 &_axis, bool _local) const;
140 
143  private: void SetMouseMoveVisual(rendering::VisualPtr _vis);
144 
147  private: void PublishVisualPose(rendering::VisualPtr _vis);
148 
151  private: void PublishVisualScale(rendering::VisualPtr _vis);
152 
154  private: friend class SingletonT<ModelManipulator>;
155 
158  private: ModelManipulatorPrivate *dataPtr;
159  };
160  }
161 }
162 #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:31
Singleton template class.
Definition: SingletonT.hh:33
boost::shared_ptr< Camera > CameraPtr
Definition: RenderTypes.hh:80
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:100
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48