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>
36 #include "fg_props.hxx"
42 // Define a structure containing view information
43 class FGViewMgr : public SGSubsystem
56 virtual void unbind ();
57 virtual void update (double dt);
58 virtual void reinit ();
61 inline int size() const { return views.size(); }
62 inline int get_current() const { return current; }
63 inline FGViewer *get_current_view() {
64 if ( current < (int)views.size() ) {
65 return views[current];
70 inline const FGViewer *get_current_view() const {
71 if ( current < (int)views.size() ) {
72 return views[current];
77 inline FGViewer *get_view( int i ) {
78 if ( i < 0 ) { i = 0; }
79 if ( i >= (int)views.size() ) { i = views.size() - 1; }
82 inline const FGViewer *get_view( int i ) const {
83 if ( i < 0 ) { i = 0; }
84 if ( i >= (int)views.size() ) { i = views.size() - 1; }
87 inline FGViewer *next_view() {
88 setView((current+1 < (int)views.size()) ? (current + 1) : 0);
89 return views[current];
91 inline FGViewer *prev_view() {
92 setView((0 < current) ? (current - 1) : (views.size() - 1));
93 return views[current];
97 inline void clear() { views.clear(); }
98 inline void set_view( const int v ) { current = v; }
99 inline void add_view( FGViewer * v ) {
103 // copies current offset settings to current-view path...
104 void copyToCurrent ();
113 // callbacks in manager to access viewer methods
114 double getViewHeadingOffset_deg () const;
115 void setViewHeadingOffset_deg (double offset);
116 double getViewGoalHeadingOffset_deg () const;
117 void setViewGoalHeadingOffset_deg (double offset);
118 double getViewPitchOffset_deg () const;
119 void setViewPitchOffset_deg (double tilt);
120 double getGoalViewPitchOffset_deg () const;
121 void setGoalViewRollOffset_deg (double tilt);
122 double getViewRollOffset_deg () const;
123 void setViewRollOffset_deg (double tilt);
124 double getGoalViewRollOffset_deg () const;
125 void setGoalViewPitchOffset_deg (double tilt);
126 double getViewXOffset_m () const;
127 void setViewXOffset_m (double x);
128 double getViewYOffset_m () const;
129 void setViewYOffset_m (double y);
130 double getViewZOffset_m () const;
131 void setViewZOffset_m (double z);
132 double getViewTargetXOffset_m () const;
133 void setViewTargetXOffset_m (double x);
134 double getViewTargetYOffset_m () const;
135 void setViewTargetYOffset_m (double y);
136 double getViewTargetZOffset_m () const;
137 void setViewTargetZOffset_m (double z);
138 double getFOV_deg () const;
139 void setFOV_deg (double fov);
140 double getARM_deg () const; // Aspect Ratio Multiplier
141 void setARM_deg (double fov);
142 double getNear_m () const;
143 void setNear_m (double near_m);
144 void setViewAxisLong (double axis);
145 void setViewAxisLat (double axis);
146 int getView () const;
147 void setView (int newview);
149 vector<SGPropertyNode_ptr> config_list;
150 typedef vector<FGViewer *> viewer_list;
158 #endif // _VIEWMGR_HXX