]> git.mxchange.org Git - flightgear.git/blob - src/Main/viewmgr.hxx
Merge branch 'jt/runway' into next
[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 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         view_number->fireValueChanged();
90         return views[current];
91     }
92     inline FGViewer *prev_view() {
93         setView((0 < current) ? (current - 1) : (views.size() - 1));
94         view_number->fireValueChanged();
95         return views[current];
96     }
97
98     // setters
99     inline void clear() { views.clear(); }
100     inline void set_view( const int v ) { current = v; }
101     inline void add_view( FGViewer * v ) {
102         views.push_back(v);
103         v->init();
104     }
105     // copies current offset settings to current-view path...
106     void copyToCurrent ();
107
108 private:
109
110     double axis_long;
111     double axis_lat;
112
113     void do_axes ();
114
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);
150
151     SGPropertyNode_ptr view_number;
152     vector<SGPropertyNode_ptr> config_list;
153     typedef vector<SGSharedPtr<FGViewer> > viewer_list;
154     viewer_list views;
155     SGVec3d abs_viewer_position;
156
157     int current;
158
159 };
160
161
162 #endif // _VIEWMGR_HXX