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 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 _ORBITVIEWCONTROLLER_HH_
18 #define _ORBITVIEWCONTROLLER_HH_
19 
20 #include <string>
21 
24 #include "gazebo/math/Vector3.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 
52  public: virtual void Update();
53 
56  public: virtual void HandleMouseEvent(const common::MouseEvent &_event);
57 
60  public: static std::string GetTypeString();
61 
64  public: void SetDistance(float _d);
65 
68  public: void SetFocalPoint(const math::Vector3 &_fp);
69 
72  public: math::Vector3 GetFocalPoint() const;
73 
74  // Documentation inherited from parent
75  public: void HandleKeyReleaseEvent(const std::string &_key);
76 
77  // Documentation inherited from parent
78  public: virtual void HandleKeyPressEvent(const std::string &_key);
79 
82  private: void TranslateLocal(const math::Vector3 &_vec);
83 
86  private: void TranslateGlobal(const math::Vector3 &_vec);
87 
90  private: void Zoom(float _amount);
91 
95  private: double NormalizeYaw(double _v);
96 
100  private: double NormalizePitch(double _v);
101 
103  private: void UpdateRefVisual();
104 
108  private: void Orbit(double _dy, double _dp);
109 
111  private: float yaw, initYaw;
112 
114  private: float pitch, initPitch;
115 
117  private: float distance;
118 
120  private: math::Vector3 focalPoint;
121 
123  private: VisualPtr refVisual;
124 
126  private: std::string key;
127 
130  private: bool init;
131  };
133  }
134 }
135 #endif