]> git.mxchange.org Git - flightgear.git/blob - src/Main/viewmgr.hxx
new FSF address
[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
28 #ifndef __cplusplus                                                          
29 # error This library requires C++
30 #endif                                   
31
32
33 #include <simgear/compiler.h>
34 #include <simgear/structure/subsystem_mgr.hxx>
35
36 #ifdef HAVE_CONFIG_H
37 #  include <config.h>
38 #endif
39
40 #include <vector>
41
42 #include "viewer.hxx"
43
44 SG_USING_STD(vector);
45
46
47 // Define a structure containing view information
48 class FGViewMgr : public SGSubsystem
49 {
50
51 public:
52
53     // Constructor
54     FGViewMgr( void );
55
56     // Destructor
57     ~FGViewMgr( void );
58
59     virtual void init ();
60     virtual void bind ();
61     virtual void unbind ();
62     virtual void update (double dt);
63     virtual void reinit ();
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         setView((current+1 < (int)views.size()) ? (current + 1) : 0);
94         return views[current];
95     }
96     inline FGViewer *prev_view() {
97         setView((0 < current) ? (current - 1) : (views.size() - 1));
98         return views[current];
99     }
100
101     // setters
102     inline void clear() { views.clear(); }
103     inline void set_view( const int v ) { current = v; }
104     inline void add_view( FGViewer * v ) {
105         views.push_back(v);
106         v->init();
107     }
108     // copies current offset settings to current-view path...
109     void copyToCurrent ();
110
111 private:
112
113     double axis_long;
114     double axis_lat;
115
116     void do_axes ();
117
118     //  callbacks in manager to access viewer methods
119     double getViewHeadingOffset_deg () const;
120     void setViewHeadingOffset_deg (double offset);
121     double getViewGoalHeadingOffset_deg () const;
122     void setViewGoalHeadingOffset_deg (double offset);
123     double getViewPitchOffset_deg () const;
124     void setViewPitchOffset_deg (double tilt);
125     double getGoalViewPitchOffset_deg () const;
126     void setGoalViewRollOffset_deg (double tilt);
127     double getViewRollOffset_deg () const;
128     void setViewRollOffset_deg (double tilt);
129     double getGoalViewRollOffset_deg () const;
130     void setGoalViewPitchOffset_deg (double tilt);
131     double getViewXOffset_m () const;
132     void setViewXOffset_m (double x);
133     double getViewYOffset_m () const;
134     void setViewYOffset_m (double y);
135     double getViewZOffset_m () const;
136     void setViewZOffset_m (double z);
137     double getViewTargetXOffset_m () const;
138     void setViewTargetXOffset_m (double x);
139     double getViewTargetYOffset_m () const;
140     void setViewTargetYOffset_m (double y);
141     double getViewTargetZOffset_m () const;
142     void setViewTargetZOffset_m (double z);
143     double getFOV_deg () const;
144     void setFOV_deg (double fov);
145     double getARM_deg () const; // Aspect Ratio Multiplier
146     void setARM_deg (double fov);
147     double getNear_m () const;
148     void setNear_m (double near_m);
149     void setViewAxisLong (double axis);
150     void setViewAxisLat (double axis);
151     int getView () const;
152     void setView (int newview);
153
154     typedef vector < FGViewer * > viewer_list;
155     viewer_list views;
156
157     int current;
158
159 };
160
161
162 #endif // _VIEWMGR_HXX