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