OrbitViewController.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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 
22 #include <ignition/math/Vector3.hh>
23 
26 #include "gazebo/math/Vector3.hh"
27 #include "gazebo/util/system.hh"
28 
29 namespace gazebo
30 {
31  namespace rendering
32  {
35 
39  {
45  public: OrbitViewController(UserCameraPtr _camera,
46  const std::string &_name = "OrbitViewController");
47 
49  public: virtual ~OrbitViewController();
50 
52  public: virtual void Init();
53 
54  // Documentation inherited
55  public: virtual void Init(const math::Vector3 &_focalPoint,
56  const double _yaw = 0, const double _pitch = 0);
57 
59  public: virtual void Update();
60 
63  public: virtual void HandleMouseEvent(const common::MouseEvent &_event);
64 
67  public: static std::string GetTypeString();
68 
71  public: void SetDistance(float _d);
72 
75  public: void SetFocalPoint(const math::Vector3 &_fp);
76 
79  public: math::Vector3 GetFocalPoint() const;
80 
81  // Documentation inherited from parent
82  public: void HandleKeyReleaseEvent(const std::string &_key);
83 
84  // Documentation inherited from parent
85  public: virtual void HandleKeyPressEvent(const std::string &_key);
86 
87  public: double Pitch() const;
88 
89  public: double Yaw() const;
90 
93  protected: void TranslateLocal(const math::Vector3 &_vec);
94 
97  protected: void TranslateGlobal(const math::Vector3 &_vec);
98 
101  protected: void Zoom(float _amount);
102 
106  protected: double NormalizeYaw(double _v);
107 
111  protected: double NormalizePitch(double _v);
112 
114  protected: void UpdateRefVisual();
115 
119  protected: void Orbit(double _dy, double _dp);
120 
122  protected: float yaw;
123 
125  protected: float pitch;
126 
128  protected: float distance;
129 
131  protected: VisualPtr refVisual;
132 
134  protected: std::string key;
135 
138  protected: bool init;
139 
141  protected: ignition::math::Vector3d focalPoint;
142  };
144  }
145 }
146 #endif
float distance
Distance to the focal point.
Definition: OrbitViewController.hh:128
Generic description of a mouse event.
Definition: MouseEvent.hh:35
float pitch
Pitch value.
Definition: OrbitViewController.hh:125
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:39
Orbit view controller.
Definition: OrbitViewController.hh:38
std::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:112
ignition::math::Vector3d focalPoint
The focal point.
Definition: OrbitViewController.hh:141
float yaw
Yaw value.
Definition: OrbitViewController.hh:122
#define GZ_RENDERING_VISIBLE
Definition: system.hh:209
VisualPtr refVisual
A reference visual.
Definition: OrbitViewController.hh:131
bool init
A flag used to inidicate that the view controller has just been initialized.
Definition: OrbitViewController.hh:138
std::string key
Key that is currently pressed.
Definition: OrbitViewController.hh:134
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
boost::shared_ptr< UserCamera > UserCameraPtr
Definition: RenderTypes.hh:92
Base class for view controllers.
Definition: ViewController.hh:34