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 (C) 2012-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 _ORBITVIEWCONTROLLER_HH_
18 #define _ORBITVIEWCONTROLLER_HH_
19 
20 #include <string>
21 
24 #include "gazebo/math/Vector3.hh"
25 #include "gazebo/util/system.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 
53  public: virtual void Update();
54 
57  public: virtual void HandleMouseEvent(const common::MouseEvent &_event);
58 
61  public: static std::string GetTypeString();
62 
65  public: void SetDistance(float _d);
66 
69  public: void SetFocalPoint(const math::Vector3 &_fp);
70 
73  public: math::Vector3 GetFocalPoint() const;
74 
75  // Documentation inherited from parent
76  public: void HandleKeyReleaseEvent(const std::string &_key);
77 
78  // Documentation inherited from parent
79  public: virtual void HandleKeyPressEvent(const std::string &_key);
80 
83  private: void TranslateLocal(const math::Vector3 &_vec);
84 
87  private: void TranslateGlobal(const math::Vector3 &_vec);
88 
91  private: void Zoom(float _amount);
92 
96  private: double NormalizeYaw(double _v);
97 
101  private: double NormalizePitch(double _v);
102 
104  private: void UpdateRefVisual();
105 
109  private: void Orbit(double _dy, double _dp);
110 
112  private: float yaw;
113 
115  private: float pitch;
116 
118  private: float distance;
119 
121  private: math::Vector3 focalPoint;
122 
124  private: VisualPtr refVisual;
125 
127  private: std::string key;
128 
131  private: bool init;
132  };
134  }
135 }
136 #endif