]> git.mxchange.org Git - flightgear.git/blob - src/Main/viewmgr.hxx
c6476a15bf5db9dd32651826b21e1a468a4cd8da
[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 #include <simgear/math/SGMath.hxx>
32
33 // forward decls
34 class FGViewer;
35 typedef SGSharedPtr<FGViewer> FGViewerPtr;
36
37 // Define a structure containing view information
38 class FGViewMgr : public SGSubsystem
39 {
40
41 public:
42
43     // Constructor
44     FGViewMgr( void );
45
46     // Destructor
47     ~FGViewMgr( void );
48
49     virtual void init ();
50     virtual void bind ();
51     virtual void unbind ();
52     virtual void update (double dt);
53     virtual void reinit ();
54
55     // getters
56     inline int size() const { return views.size(); }
57     inline int get_current() const { return current; }
58     inline FGViewer *get_current_view() {
59         if ( current < (int)views.size() ) {
60             return views[current];
61         } else {
62             return NULL;
63         }
64     }
65     inline const FGViewer *get_current_view() const {
66         if ( current < (int)views.size() ) {
67             return views[current];
68         } else {
69             return NULL;
70         }
71     }
72     inline FGViewer *get_view( int i ) {
73         if ( i < 0 ) { i = 0; }
74         if ( i >= (int)views.size() ) { i = views.size() - 1; }
75         return views[i];
76     }
77     inline const FGViewer *get_view( int i ) const {
78         if ( i < 0 ) { i = 0; }
79         if ( i >= (int)views.size() ) { i = views.size() - 1; }
80         return views[i];
81     }
82     inline FGViewer *next_view() {
83         setView((current+1 < (int)views.size()) ? (current + 1) : 0);
84         view_number->fireValueChanged();
85         return views[current];
86     }
87     inline FGViewer *prev_view() {
88         setView((0 < current) ? (current - 1) : (views.size() - 1));
89         view_number->fireValueChanged();
90         return views[current];
91     }
92
93     // setters
94     inline void clear() { views.clear(); }
95     inline void set_view( const int v ) { current = v; }
96     void add_view( FGViewer * v );
97     
98     // copies current offset settings to current-view path...
99     void copyToCurrent ();
100
101 private:
102
103     double axis_long;
104     double axis_lat;
105
106     void do_axes ();
107
108     //  callbacks in manager to access viewer methods
109     double getViewHeadingOffset_deg () const;
110     void setViewHeadingOffset_deg (double offset);
111     double getViewGoalHeadingOffset_deg () const;
112     void setViewGoalHeadingOffset_deg (double offset);
113     double getViewPitchOffset_deg () const;
114     void setViewPitchOffset_deg (double tilt);
115     double getGoalViewPitchOffset_deg () const;
116     void setGoalViewRollOffset_deg (double tilt);
117     double getViewRollOffset_deg () const;
118     void setViewRollOffset_deg (double tilt);
119     double getGoalViewRollOffset_deg () const;
120     void setGoalViewPitchOffset_deg (double tilt);
121     double getViewXOffset_m () const;
122     void setViewXOffset_m (double x);
123     double getViewYOffset_m () const;
124     void setViewYOffset_m (double y);
125     double getViewZOffset_m () const;
126     void setViewZOffset_m (double z);
127     double getViewTargetXOffset_m () const;
128     void setViewTargetXOffset_m (double x);
129     double getViewTargetYOffset_m () const;
130     void setViewTargetYOffset_m (double y);
131     double getViewTargetZOffset_m () const;
132     void setViewTargetZOffset_m (double z);
133     double getFOV_deg () const;
134     void setFOV_deg (double fov);
135     double getARM_deg () const; // Aspect Ratio Multiplier
136     void setARM_deg (double fov);
137     double getNear_m () const;
138     void setNear_m (double near_m);
139     void setViewAxisLong (double axis);
140     void setViewAxisLat (double axis);
141     int getView () const;
142     void setView (int newview);
143
144     SGPropertyNode_ptr view_number;
145     vector<SGPropertyNode_ptr> config_list;
146     typedef std::vector<FGViewerPtr> viewer_list;
147     viewer_list views;
148     SGVec3d abs_viewer_position;
149
150     int current;
151
152 };
153
154
155 #endif // _VIEWMGR_HXX