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 
28 
30 
32 #include "gazebo/util/system.hh"
33 
35 GZ_SINGLETON_DECLARE(GZ_GUI_VISIBLE, gazebo, gui, ModelManipulator)
36 
37 namespace gazebo
38 {
39  namespace gui
40  {
41  class ModelManipulatorPrivate;
42 
46  class GZ_GUI_VISIBLE ModelManipulator : public SingletonT<ModelManipulator>
47  {
49  private: ModelManipulator();
50 
52  private: virtual ~ModelManipulator();
53 
55  public: void Init();
56 
59  public: void Clear();
60 
62  public: void Detach();
63 
66  public: void SetManipulationMode(const std::string &_mode);
67 
69  public: void SetAttachedVisual(rendering::VisualPtr _vis);
70 
73  public: void OnMousePressEvent(const common::MouseEvent &_event);
74 
77  public: void OnMouseMoveEvent(const common::MouseEvent &_event);
78 
81  public: void OnMouseReleaseEvent(const common::MouseEvent &_event);
82 
85  public: void OnKeyPressEvent(const common::KeyEvent &_event);
86 
89  public: void OnKeyReleaseEvent(const common::KeyEvent &_event);
90 
95  public: void RotateEntity(rendering::VisualPtr &_vis,
96  const ignition::math::Vector3d &_axis,
97  const bool _local = false);
98 
103  public: void TranslateEntity(rendering::VisualPtr &_vis,
104  const ignition::math::Vector3d &_axis,
105  const bool _local = false);
106 
111  public: void ScaleEntity(rendering::VisualPtr &_vis,
112  const ignition::math::Vector3d &_axis,
113  const bool _local = false);
114 
123  public: static ignition::math::Vector3d SnapPoint(
124  const ignition::math::Vector3d &_point,
125  const double _interval = 1.0, const double _sensitivity = 0.4);
126 
132  public: static ignition::math::Vector3d MousePositionOnPlane(
133  rendering::CameraPtr _camera,
134  const common::MouseEvent &_event);
135 
144  public: static ignition::math::Vector3d MouseMoveDistance(
145  rendering::CameraPtr _camera,
146  const ignition::math::Vector2i &_start,
147  const ignition::math::Vector2i &_end,
148  const ignition::math::Pose3d &_pose,
149  const ignition::math::Vector3d &_axis, const bool _local);
150 
156  private: ignition::math::Vector3d MouseMoveDistance(
157  const ignition::math::Pose3d &_pose,
158  const ignition::math::Vector3d &_axis, const bool _local) const;
159 
162  private: void SetMouseMoveVisual(rendering::VisualPtr _vis);
163 
166  private: void PublishVisualPose(rendering::VisualPtr _vis);
167 
170  private: void PublishVisualScale(rendering::VisualPtr _vis);
171 
178  private: ignition::math::Vector3d UpdateScale(
179  const ignition::math::Vector3d &_axis,
180  const ignition::math::Vector3d &_scale, const std::string &_geom);
181 
183  private: friend class SingletonT<ModelManipulator>;
184 
187  private: std::unique_ptr<ModelManipulatorPrivate> dataPtr;
188  };
189  }
190 }
191 #endif
Generic description of a mouse event.
Definition: MouseEvent.hh:35
Forward declarations for the common classes.
Definition: Animation.hh:26
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:46
std::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:114
gui
Definition: ModelManipulator.hh:35
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
boost::shared_ptr< Camera > CameraPtr
Definition: RenderTypes.hh:90
#define GZ_SINGLETON_DECLARE(visibility, n1, n2, singletonType)
Helper to declare typed SingletonT.
Definition: SingletonT.hh:61