OsgTrackballZoomManipulator.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
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 #ifndef SURGSIM_GRAPHICS_OSGTRACKBALLZOOMMANIPULATOR_H
17 #define SURGSIM_GRAPHICS_OSGTRACKBALLZOOMMANIPULATOR_H
18 
19 #include <osgGA/TrackballManipulator>
20 
21 
22 
23 namespace SurgSim
24 {
25 namespace Graphics
26 {
27 
32 class OsgTrackballZoomManipulator : public osgGA::TrackballManipulator
33 {
34 public:
37 
40  virtual void setMinZoomFactor(double factor);
41 
44  double getMinZoomFactor() const;
45 
48  virtual void setMaxZoomFactor(double factor);
49 
52  double getMaxZoomFactor() const;
53 
56  virtual void setMinZoomAmount(double amount);
57 
60  double getMinZoomAmount() const;//
61 
64  virtual void setMaxZoomAmount(double amount);
65 
68  double getMaxZoomAmount() const;
69 
72  virtual void setZoomFactor(double factor);
73 
76  double getZoomFactor() const;
77 
80  virtual void setZoomFactorScale(double factor);
81 
84  double getZoomFactorScale() const;
85 
88  virtual void zoom(double zoomPercent);
89 
91  virtual void makeUpright();
92 
93 protected:
94 
99 
103 
106 
109  double m_zoomFactor;
110 
113 
118  virtual bool handle(const osgGA::GUIEventAdapter& eventAdapter, osgGA::GUIActionAdapter& actionAdapter); //NOLINT
119 
124  virtual bool handleMouseWheel(const osgGA::GUIEventAdapter& eventAdapter,
125  osgGA::GUIActionAdapter& actionAdapter); //NOLINT
126 
127  void updateCamera(osg::Camera& camera) override;
128 
129 };
130 
131 }; // namespace Graphics
132 }; // namespace SurgSim
133 
134 
135 #endif
virtual bool handle(const osgGA::GUIEventAdapter &eventAdapter, osgGA::GUIActionAdapter &actionAdapter)
Handle keyboard CTRL-U events to make the view upright.
Definition: OsgTrackballZoomManipulator.cpp:149
Definition: CompoundShapeToGraphics.cpp:29
double m_zoomFactor
Current zoom factor Larger values are zoomed out, smaller values are zoomed in.
Definition: OsgTrackballZoomManipulator.h:109
virtual void setZoomFactor(double factor)
Sets the current zoom factor.
Definition: OsgTrackballZoomManipulator.cpp:78
double getZoomFactor() const
Gets the current zoom factor.
Definition: OsgTrackballZoomManipulator.cpp:82
double m_minZoomAmount
Minimum amount to change the zoom factor in one step This minimum prevents zooming by infinitely smal...
Definition: OsgTrackballZoomManipulator.h:102
double m_maxZoomAmount
Maximum amount to change the zoom factor in one step.
Definition: OsgTrackballZoomManipulator.h:105
double getZoomFactorScale() const
Gets the current zoom factor.
Definition: OsgTrackballZoomManipulator.cpp:91
virtual void setMaxZoomFactor(double factor)
Sets the maximum zoom factor (zoomed out)
Definition: OsgTrackballZoomManipulator.cpp:51
virtual void makeUpright()
Removes roll of the camera, so that the top of the view is towards the Y direction.
Definition: OsgTrackballZoomManipulator.cpp:121
double m_zoomFactorScale
Scaling factor applied to the zoom factor before it is applied to the FOV.
Definition: OsgTrackballZoomManipulator.h:112
virtual bool handleMouseWheel(const osgGA::GUIEventAdapter &eventAdapter, osgGA::GUIActionAdapter &actionAdapter)
Handle mouse wheel scrolling to zoom in or out.
Definition: OsgTrackballZoomManipulator.cpp:184
virtual void zoom(double zoomPercent)
Zoom by a percent of the difference between the current zoom amount and minimum zoom factor...
Definition: OsgTrackballZoomManipulator.cpp:96
virtual void setMaxZoomAmount(double amount)
Sets the maximum amount to change the zoom factor in one step.
Definition: OsgTrackballZoomManipulator.cpp:69
void updateCamera(osg::Camera &camera) override
Definition: OsgTrackballZoomManipulator.cpp:213
double getMinZoomFactor() const
Gets the minimum zoom factor.
Definition: OsgTrackballZoomManipulator.cpp:46
OsgTrackballZoomManipulator()
Initializes the zoom parameters to default values.
Definition: OsgTrackballZoomManipulator.cpp:31
virtual void setZoomFactorScale(double factor)
Sets the scale applied to the zoom factor before it is applied to the FOV.
Definition: OsgTrackballZoomManipulator.cpp:87
double getMaxZoomAmount() const
Gets the maximum amount to change the zoom factor in one step.
Definition: OsgTrackballZoomManipulator.cpp:73
virtual void setMinZoomAmount(double amount)
Sets the minimum amount to change the zoom factor in one step.
Definition: OsgTrackballZoomManipulator.cpp:60
Trackball manipulator that uses the mouse wheel to control zoom amount.
Definition: OsgTrackballZoomManipulator.h:32
double getMinZoomAmount() const
Gets the minimum amount to change the zoom factor in one step.
Definition: OsgTrackballZoomManipulator.cpp:64
double getMaxZoomFactor() const
Gets the maximum zoom factor.
Definition: OsgTrackballZoomManipulator.cpp:55
double m_maxZoomFactor
Maximum zoom factor value (zoomed out)
Definition: OsgTrackballZoomManipulator.h:98
double m_minZoomFactor
Minimum zoom factor value (zoomed in)
Definition: OsgTrackballZoomManipulator.h:96
virtual void setMinZoomFactor(double factor)
Sets the minimum zoom factor (zoomed out)
Definition: OsgTrackballZoomManipulator.cpp:42