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 
23 #include "math/Vector3.hh"
24 #include "math/Vector2i.hh"
25 
26 namespace gazebo
27 {
28  namespace rendering
29  {
32 
36  {
39  public: OrbitViewController(UserCameraPtr _camera);
40 
42  public: virtual ~OrbitViewController();
43 
45  public: virtual void Init();
46 
49  public: virtual void Init(const math::Vector3 &_focalPoint);
50 
54  public: void SetDistanceRange(double _minDist, double _maxDist);
55 
57  public: virtual void Update();
58 
61  public: virtual void HandleMouseEvent(const common::MouseEvent &_event);
62 
65  public: static std::string GetTypeString();
66 
69  public: void SetDistance(float _d);
70 
73  public: void SetFocalPoint(const math::Vector3 &_fp);
74 
77  public: math::Vector3 GetFocalPoint() const;
78 
81  public: void SetYaw(double _yaw);
82 
85  public: void SetPitch(double _pitch);
86 
87  // Documentation inherited from parent
88  public: void HandleKeyReleaseEvent(const std::string &_key);
89 
90  // Documentation inherited from parent
91  public: virtual void HandleKeyPressEvent(const std::string &_key);
92 
95  private: void TranslateLocal(math::Vector3 _vec);
96 
99  private: void TranslateGlobal(math::Vector3 _vec);
100 
103  private: void Zoom(float _amount);
104 
107  private: void NormalizeYaw(float &_v);
108 
111  private: void NormalizePitch(float &_v);
112 
114  private: void UpdatePose();
115 
116  private: float yaw, pitch;
117  private: float distance;
118  private: float minDist, maxDist;
119  private: math::Vector3 focalPoint;
120 
121  private: VisualPtr refVisual;
122  private: math::Vector2i posCache;
123  private: math::Vector3 worldFocal;
124 
125  private: std::string key;
126  };
128  }
129 }
130 #endif