All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OrbitViewController.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2012 Nate Koenig
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 _ORBITVIEWCONTROLLER_HH_
18 #define _ORBITVIEWCONTROLLER_HH_
19 
20 #include <string>
21 
24 #include "gazebo/math/Vector3.hh"
25 #include "gazebo/math/Vector2i.hh"
26 
27 namespace gazebo
28 {
29  namespace rendering
30  {
33 
37  {
40  public: OrbitViewController(UserCameraPtr _camera);
41 
43  public: virtual ~OrbitViewController();
44 
46  public: virtual void Init();
47 
50  public: virtual void Init(const math::Vector3 &_focalPoint);
51 
55  public: void SetDistanceRange(double _minDist, double _maxDist);
56 
58  public: virtual void Update();
59 
62  public: virtual void HandleMouseEvent(const common::MouseEvent &_event);
63 
66  public: static std::string GetTypeString();
67 
70  public: void SetDistance(float _d);
71 
74  public: void SetFocalPoint(const math::Vector3 &_fp);
75 
78  public: math::Vector3 GetFocalPoint() const;
79 
82  public: void SetYaw(double _yaw);
83 
86  public: void SetPitch(double _pitch);
87 
88  // Documentation inherited from parent
89  public: void HandleKeyReleaseEvent(const std::string &_key);
90 
91  // Documentation inherited from parent
92  public: virtual void HandleKeyPressEvent(const std::string &_key);
93 
96  private: void TranslateLocal(math::Vector3 _vec);
97 
100  private: void TranslateGlobal(math::Vector3 _vec);
101 
104  private: void Zoom(float _amount);
105 
108  private: void NormalizeYaw(float &_v);
109 
112  private: void NormalizePitch(float &_v);
113 
115  private: void UpdatePose();
116 
117  private: float yaw, pitch;
118  private: float distance;
119  private: float minDist, maxDist;
120  private: math::Vector3 focalPoint;
121 
122  private: VisualPtr refVisual;
123  private: math::Vector2i posCache;
124  private: math::Vector3 worldFocal;
125 
126  private: std::string key;
127  };
129  }
130 }
131 #endif