]> git.mxchange.org Git - flightgear.git/blob - src/Main/viewmgr.hxx
6e9b76298a9e02bee181dfaabec203af0951bc43
[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  - curt@flightgear.org
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., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #ifndef _VIEWMGR_HXX
25 #define _VIEWMGR_HXX
26
27
28 #ifndef __cplusplus                                                          
29 # error This library requires C++
30 #endif                                   
31
32
33 #include <simgear/compiler.h>
34
35 #ifdef HAVE_CONFIG_H
36 #  include <config.h>
37 #endif
38
39 #include <vector>
40
41 #include "fgfs.hxx"
42 #include "viewer_lookat.hxx"
43 #include "viewer_rph.hxx"
44
45 SG_USING_STD(vector);
46
47
48 // Define a structure containing view information
49 class FGViewMgr : public FGSubsystem
50 {
51
52 public:
53
54     // Constructor
55     FGViewMgr( void );
56
57     // Destructor
58     ~FGViewMgr( void );
59
60     virtual void init ();
61     virtual void bind ();
62     virtual void unbind ();
63     virtual void update (int dt);
64
65     // getters
66     inline int size() const { return views.size(); }
67     inline int get_current() const { return current; }
68     inline FGViewer *get_current_view() {
69         if ( current < (int)views.size() ) {
70             return views[current];
71         } else {
72             return NULL;
73         }
74     }
75     inline const FGViewer *get_current_view() const {
76         if ( current < (int)views.size() ) {
77             return views[current];
78         } else {
79             return NULL;
80         }
81     }
82     inline FGViewer *get_view( int i ) {
83         if ( i < 0 ) { i = 0; }
84         if ( i >= (int)views.size() ) { i = views.size() - 1; }
85         return views[i];
86     }
87     inline const FGViewer *get_view( int i ) const {
88         if ( i < 0 ) { i = 0; }
89         if ( i >= (int)views.size() ) { i = views.size() - 1; }
90         return views[i];
91     }
92     inline FGViewer *next_view() {
93         ++current;
94         if ( current >= (int)views.size() ) {
95             current = 0;
96         }
97         return views[current];
98     }
99     inline FGViewer *prev_view() {
100         --current;
101         if ( current < 0 ) {
102             current = views.size() - 1;
103         }
104         return views[current];
105     }
106
107     // setters
108     inline void clear() { views.clear(); }
109     inline void set_view( const int v ) { current = v; }
110     inline void add_view( FGViewer * v ) {
111         views.push_back(v);
112     }
113
114 private:
115
116     double axis_long;
117     double axis_lat;
118
119     void do_axes ();
120
121     double getViewOffset_deg () const;
122     void setViewOffset_deg (double offset);
123     double getGoalViewOffset_deg () const;
124     void setGoalViewOffset_deg (double offset);
125     double getViewTilt_deg () const;
126     void setViewTilt_deg (double tilt);
127     double getGoalViewTilt_deg () const;
128     void setGoalViewTilt_deg (double tilt);
129     double getPilotXOffset_m () const;
130     void setPilotXOffset_m (double x);
131     double getPilotYOffset_m () const;
132     void setPilotYOffset_m (double y);
133     double getPilotZOffset_m () const;
134     void setPilotZOffset_m (double z);
135     double getFOV_deg () const;
136     void setFOV_deg (double fov);
137     void setViewAxisLong (double axis);
138     void setViewAxisLat (double axis);
139
140     typedef vector < FGViewer * > viewer_list;
141     viewer_list views;
142
143     int current;
144
145 };
146
147
148 #endif // _VIEWMGR_HXX