]> git.mxchange.org Git - flightgear.git/blob - src/Main/viewmgr.hxx
Modified Files:
[flightgear.git] / src / Main / viewmgr.hxx
1 // viewmgr.hxx -- class for managing all the views in the flightgear world.
2 //
3 // Written by Curtis Olson, started October 2000.
4 //
5 // Copyright (C) 2000  Curtis L. Olson  - http://www.flightgear.org/~curt
6 //
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.
11 //
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.
16 //
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.
20 //
21 // $Id$
22
23
24 #ifndef _VIEWMGR_HXX
25 #define _VIEWMGR_HXX
26
27 #include <vector>
28
29 #include <simgear/compiler.h>
30 #include <simgear/structure/subsystem_mgr.hxx>
31
32 #ifdef HAVE_CONFIG_H
33 #  include <config.h>
34 #endif
35
36 #include "fg_props.hxx"
37 #include "viewer.hxx"
38
39 SG_USING_STD(vector);
40
41
42 // Define a structure containing view information
43 class FGViewMgr : public SGSubsystem
44 {
45
46 public:
47
48     // Constructor
49     FGViewMgr( void );
50
51     // Destructor
52     ~FGViewMgr( void );
53
54     virtual void init ();
55     virtual void bind ();
56     virtual void unbind ();
57     virtual void update (double dt);
58     virtual void reinit ();
59
60     // getters
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];
66         } else {
67             return NULL;
68         }
69     }
70     inline const FGViewer *get_current_view() const {
71         if ( current < (int)views.size() ) {
72             return views[current];
73         } else {
74             return NULL;
75         }
76     }
77     inline FGViewer *get_view( int i ) {
78         if ( i < 0 ) { i = 0; }
79         if ( i >= (int)views.size() ) { i = views.size() - 1; }
80         return views[i];
81     }
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; }
85         return views[i];
86     }
87     inline FGViewer *next_view() {
88         setView((current+1 < (int)views.size()) ? (current + 1) : 0);
89         return views[current];
90     }
91     inline FGViewer *prev_view() {
92         setView((0 < current) ? (current - 1) : (views.size() - 1));
93         return views[current];
94     }
95
96     // setters
97     inline void clear() { views.clear(); }
98     inline void set_view( const int v ) { current = v; }
99     inline void add_view( FGViewer * v ) {
100         views.push_back(v);
101         v->init();
102     }
103     // copies current offset settings to current-view path...
104     void copyToCurrent ();
105
106 private:
107
108     double axis_long;
109     double axis_lat;
110
111     void do_axes ();
112
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);
148
149     vector<SGPropertyNode_ptr> config_list;
150     typedef vector<FGViewer *> viewer_list;
151     viewer_list views;
152
153     int current;
154
155 };
156
157
158 #endif // _VIEWMGR_HXX