ModelSnap.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 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 GAZEBO_GUI_MODELSNAP_HH_
18 #define GAZEBO_GUI_MODELSNAP_HH_
19 
20 #include <memory>
21 #include <vector>
22 #include <ignition/math/Quaternion.hh>
23 #include <ignition/math/Triangle3.hh>
24 
27 #include "gazebo/util/system.hh"
28 
30 GZ_SINGLETON_DECLARE(GZ_GUI_VISIBLE, gazebo, gui, ModelSnap)
31 
32 namespace gazebo
33 {
34  namespace common
35  {
36  class MouseEvent;
37  }
38 
39  namespace gui
40  {
41  class ModelSnapPrivate;
42 
45  class GZ_GUI_VISIBLE ModelSnap : public SingletonT<ModelSnap>
46  {
48  private: ModelSnap();
49 
51  private: virtual ~ModelSnap();
52 
54  public: void Init();
55 
58  public: void Clear();
59 
61  public: void Reset();
62 
64  public: void Fini();
65 
73  public: void Snap(
74  const ignition::math::Triangle3d &_triangleSrc,
75  const ignition::math::Triangle3d &_triangleDest,
76  rendering::VisualPtr _visualSrc);
77 
88  public: static void SnapTransform(
89  const ignition::math::Triangle3d &_triangleSrc,
90  const ignition::math::Triangle3d &_triangleDest,
91  const ignition::math::Pose3d &_poseSrc,
92  ignition::math::Vector3d &_trans,
93  ignition::math::Quaterniond &_rot);
94 
97  public: void OnMousePressEvent(const common::MouseEvent &_event);
98 
101  public: void OnMouseMoveEvent(const common::MouseEvent &_event);
102 
105  public: void OnMouseReleaseEvent(const common::MouseEvent &_event);
106 
109  private: void PublishVisualPose(rendering::VisualPtr _vis);
110 
112  private: void Update();
113 
115  private: friend class SingletonT<ModelSnap>;
116 
119  private: std::unique_ptr<ModelSnapPrivate> dataPtr;
120  };
121  }
122 }
123 #endif
Forward declarations for the common classes.
Definition: Animation.hh:27
Singleton template class.
Definition: SingletonT.hh:34
common
Definition: FuelModelDatabase.hh:37
gazebo
Definition: ModelSnap.hh:30
void Snap(const ignition::math::Triangle3d &_triangleSrc, const ignition::math::Triangle3d &_triangleDest, rendering::VisualPtr _visualSrc)
Calculate the translation and rotation needed to snap the centroid of a mesh triangle of a visual to ...
void OnMousePressEvent(const common::MouseEvent &_event)
Process an object translate mouse press event.
void Init()
Initialize the model snapping tool.
void Reset()
Reset the model snapping tool.
void Fini()
Clean up the model snap tool.
static void SnapTransform(const ignition::math::Triangle3d &_triangleSrc, const ignition::math::Triangle3d &_triangleDest, const ignition::math::Pose3d &_poseSrc, ignition::math::Vector3d &_trans, ignition::math::Quaterniond &_rot)
Calculate the translation and rotation needed to snap the centroid of a mesh triangle of a visual to ...
gui
Definition: ModelSnap.hh:30
std::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:114
A gui tool for snapping one model to another.
Definition: ModelSnap.hh:46
void Clear()
Clear the model snapping tool.
#define GZ_SINGLETON_DECLARE(visibility, n1, n2, singletonType)
Helper to declare typed SingletonT.
Definition: SingletonT.hh:61
void OnMouseMoveEvent(const common::MouseEvent &_event)
Process an object translate mouse move event.
void OnMouseReleaseEvent(const common::MouseEvent &_event)
Process an object translate mouse release event.
Generic description of a mouse event.
Definition: MouseEvent.hh:36