1 // viewmgr.hxx -- class for managing all the views in the flightgear world.
3 // Written by Curtis Olson, started October 2000.
5 // Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29 #include <simgear/compiler.h>
30 #include <simgear/structure/subsystem_mgr.hxx>
31 #include <simgear/math/SGMath.hxx>
35 typedef SGSharedPtr<FGViewer> FGViewerPtr;
37 // Define a structure containing view information
38 class FGViewMgr : public SGSubsystem
51 virtual void unbind ();
52 virtual void update (double dt);
53 virtual void reinit ();
56 inline int size() const { return views.size(); }
57 inline int get_current() const { return current; }
58 inline FGViewer *get_current_view() {
59 if ( current < (int)views.size() ) {
60 return views[current];
65 inline const FGViewer *get_current_view() const {
66 if ( current < (int)views.size() ) {
67 return views[current];
72 inline FGViewer *get_view( int i ) {
73 if ( i < 0 ) { i = 0; }
74 if ( i >= (int)views.size() ) { i = views.size() - 1; }
77 inline const FGViewer *get_view( int i ) const {
78 if ( i < 0 ) { i = 0; }
79 if ( i >= (int)views.size() ) { i = views.size() - 1; }
82 inline FGViewer *next_view() {
83 setView((current+1 < (int)views.size()) ? (current + 1) : 0);
84 view_number->fireValueChanged();
85 return views[current];
87 inline FGViewer *prev_view() {
88 setView((0 < current) ? (current - 1) : (views.size() - 1));
89 view_number->fireValueChanged();
90 return views[current];
94 inline void clear() { views.clear(); }
95 inline void set_view( const int v ) { current = v; }
96 void add_view( FGViewer * v );
98 // copies current offset settings to current-view path...
99 void copyToCurrent ();
108 // callbacks in manager to access viewer methods
109 double getViewHeadingOffset_deg () const;
110 void setViewHeadingOffset_deg (double offset);
111 double getViewGoalHeadingOffset_deg () const;
112 void setViewGoalHeadingOffset_deg (double offset);
113 double getViewPitchOffset_deg () const;
114 void setViewPitchOffset_deg (double tilt);
115 double getGoalViewPitchOffset_deg () const;
116 void setGoalViewRollOffset_deg (double tilt);
117 double getViewRollOffset_deg () const;
118 void setViewRollOffset_deg (double tilt);
119 double getGoalViewRollOffset_deg () const;
120 void setGoalViewPitchOffset_deg (double tilt);
121 double getViewXOffset_m () const;
122 void setViewXOffset_m (double x);
123 double getViewYOffset_m () const;
124 void setViewYOffset_m (double y);
125 double getViewZOffset_m () const;
126 void setViewZOffset_m (double z);
127 double getViewTargetXOffset_m () const;
128 void setViewTargetXOffset_m (double x);
129 double getViewTargetYOffset_m () const;
130 void setViewTargetYOffset_m (double y);
131 double getViewTargetZOffset_m () const;
132 void setViewTargetZOffset_m (double z);
133 double getFOV_deg () const;
134 void setFOV_deg (double fov);
135 double getARM_deg () const; // Aspect Ratio Multiplier
136 void setARM_deg (double fov);
137 double getNear_m () const;
138 void setNear_m (double near_m);
139 void setViewAxisLong (double axis);
140 void setViewAxisLat (double axis);
141 int getView () const;
142 void setView (int newview);
144 SGPropertyNode_ptr view_number;
145 vector<SGPropertyNode_ptr> config_list;
146 typedef std::vector<FGViewerPtr> viewer_list;
148 SGVec3d abs_viewer_position;
155 #endif // _VIEWMGR_HXX