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 
34 namespace gazebo
35 {
36  namespace gui
37  {
38  class ModelManipulatorPrivate;
39 
43  class GZ_GUI_VISIBLE ModelManipulator : public SingletonT<ModelManipulator>
44  {
46  private: ModelManipulator();
47 
49  private: virtual ~ModelManipulator();
50 
52  public: void Init();
53 
56  public: void Clear();
57 
59  public: void Detach();
60 
63  public: void SetManipulationMode(const std::string &_mode);
64 
66  public: void SetAttachedVisual(rendering::VisualPtr _vis);
67 
70  public: void OnMousePressEvent(const common::MouseEvent &_event);
71 
74  public: void OnMouseMoveEvent(const common::MouseEvent &_event);
75 
78  public: void OnMouseReleaseEvent(const common::MouseEvent &_event);
79 
82  public: void OnKeyPressEvent(const common::KeyEvent &_event);
83 
86  public: void OnKeyReleaseEvent(const common::KeyEvent &_event);
87 
92  public: void RotateEntity(rendering::VisualPtr &_vis,
93  const ignition::math::Vector3d &_axis,
94  const bool _local = false);
95 
100  public: void TranslateEntity(rendering::VisualPtr &_vis,
101  const ignition::math::Vector3d &_axis,
102  const bool _local = false);
103 
108  public: void ScaleEntity(rendering::VisualPtr &_vis,
109  const ignition::math::Vector3d &_axis,
110  const bool _local = false);
111 
120  public: static ignition::math::Vector3d SnapPoint(
121  const ignition::math::Vector3d &_point,
122  const double _interval = 1.0, const double _sensitivity = 0.4);
123 
129  public: static ignition::math::Vector3d MousePositionOnPlane(
130  rendering::CameraPtr _camera,
131  const common::MouseEvent &_event);
132 
141  public: static ignition::math::Vector3d MouseMoveDistance(
142  rendering::CameraPtr _camera,
143  const ignition::math::Vector2i &_start,
144  const ignition::math::Vector2i &_end,
145  const ignition::math::Pose3d &_pose,
146  const ignition::math::Vector3d &_axis, const bool _local);
147 
153  private: ignition::math::Vector3d MouseMoveDistance(
154  const ignition::math::Pose3d &_pose,
155  const ignition::math::Vector3d &_axis, const bool _local) const;
156 
159  private: void SetMouseMoveVisual(rendering::VisualPtr _vis);
160 
163  private: void PublishVisualPose(rendering::VisualPtr _vis);
164 
167  private: void PublishVisualScale(rendering::VisualPtr _vis);
168 
175  private: ignition::math::Vector3d UpdateScale(
176  const ignition::math::Vector3d &_axis,
177  const ignition::math::Vector3d &_scale, const std::string &_geom);
178 
180  private: friend class SingletonT<ModelManipulator>;
181 
184  private: std::unique_ptr<ModelManipulatorPrivate> dataPtr;
185  };
186  }
187 }
188 #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:43
std::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:114
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
boost::shared_ptr< Camera > CameraPtr
Definition: RenderTypes.hh:90