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 view_number->fireValueChanged();
90 return views[current];
92 inline FGViewer *prev_view() {
93 setView((0 < current) ? (current - 1) : (views.size() - 1));
94 view_number->fireValueChanged();
95 return views[current];
99 inline void clear() { views.clear(); }
100 inline void set_view( const int v ) { current = v; }
101 inline void add_view( FGViewer * v ) {
105 // copies current offset settings to current-view path...
106 void copyToCurrent ();
115 // callbacks in manager to access viewer methods
116 double getViewHeadingOffset_deg () const;
117 void setViewHeadingOffset_deg (double offset);
118 double getViewGoalHeadingOffset_deg () const;
119 void setViewGoalHeadingOffset_deg (double offset);
120 double getViewPitchOffset_deg () const;
121 void setViewPitchOffset_deg (double tilt);
122 double getGoalViewPitchOffset_deg () const;
123 void setGoalViewRollOffset_deg (double tilt);
124 double getViewRollOffset_deg () const;
125 void setViewRollOffset_deg (double tilt);
126 double getGoalViewRollOffset_deg () const;
127 void setGoalViewPitchOffset_deg (double tilt);
128 double getViewXOffset_m () const;
129 void setViewXOffset_m (double x);
130 double getViewYOffset_m () const;
131 void setViewYOffset_m (double y);
132 double getViewZOffset_m () const;
133 void setViewZOffset_m (double z);
134 double getViewTargetXOffset_m () const;
135 void setViewTargetXOffset_m (double x);
136 double getViewTargetYOffset_m () const;
137 void setViewTargetYOffset_m (double y);
138 double getViewTargetZOffset_m () const;
139 void setViewTargetZOffset_m (double z);
140 double getFOV_deg () const;
141 void setFOV_deg (double fov);
142 double getARM_deg () const; // Aspect Ratio Multiplier
143 void setARM_deg (double fov);
144 double getNear_m () const;
145 void setNear_m (double near_m);
146 void setViewAxisLong (double axis);
147 void setViewAxisLat (double axis);
148 int getView () const;
149 void setView (int newview);
151 SGPropertyNode_ptr view_number;
152 vector<SGPropertyNode_ptr> config_list;
153 typedef vector<SGSharedPtr<FGViewer> > viewer_list;
155 SGVec3d abs_viewer_position;
162 #endif // _VIEWMGR_HXX