FlightGear next
viewmgr.hxx
Go to the documentation of this file.
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/props/props.hxx>
32#include <simgear/props/tiedpropertylist.hxx>
33#include <simgear/math/SGMath.hxx>
34#include <simgear/screen/video-encoder.hxx>
35
36
37// forward decls
38namespace flightgear
39{
40 class View;
41 typedef SGSharedPtr<flightgear::View> ViewPtr;
42}
43
44// Define a structure containing view information
45class FGViewMgr : public SGSubsystem
46{
47public:
48 // Constructor
49 FGViewMgr( void );
50
51 // Destructor
52 ~FGViewMgr( void );
53
54 // Subsystem API.
55 void bind() override;
56 void init() override;
57 void postinit() override;
58 void reinit() override;
59 void shutdown() override;
60 void unbind() override;
61 void update(double dt) override;
62
63 // Subsystem identification.
64 static const char* staticSubsystemClassId() { return "view-manager"; }
65
66 // getters
67 inline int size() const { return views.size(); }
68
69 int getCurrentViewIndex() const;
70
73
75 const flightgear::View* get_view( int i ) const;
76
79
80 // Support for extra view windows. This only works if --compositer-viewer=1 was specified.
81 //
82
83 // Calls SviewPush().
84 void view_push();
85
86 // These all end up calling SviewCreate().
87 void clone_current_view(const SGPropertyNode* config);
88 void clone_last_pair(const SGPropertyNode* config);
89 void clone_last_pair_double(const SGPropertyNode* config);
90 void view_new(const SGPropertyNode* config);
91
92 // setters
93 void clear();
94
95 void add_view( flightgear::View * v );
96
97 // Start video encoding of main window.
98 //
99 // name
100 // If "", we generate a name containing aircraft name, date and
101 // time and with suffix /sim/video/container, and we also create a
102 // softlink with the same name excluding date and time. Both names are
103 // converted into paths by prepending with /sim/video/directory.
104 //
105 // Otherwise we prepend with /sim/video/directory, and do not create
106 // a softlink. In this case, <name> should end with a name that is a
107 // recognised video container, such as '.mp4'.
108 //
109 // List of supported containers can be found with 'ffmpeg -formats'.
110 // codec_name
111 // Name of codec or "" to use /sim/video/codec. Passed to
112 // avcodec_find_encoder_by_name(). List of supported codecs can be
113 // found with 'ffmpeg -codecs'.
114 // quality
115 // Encoding quality in range 0..1 or -1 to use /sim/video/quality.
116 // speed:
117 // Encoding speed in range 0..1 or -1 to use /sim/video/speed.
118 // bitrate
119 // Target bitratae in bits/sec or -1 to use /sim/video/bitrate.
120 //
121 // We show popup warning if values are out of range - quality and speed
122 // must be -1 or 0-1, bitrate must be >= 0.
123 //
124 // Returns false if we fail to start video encoding.
125 //
126 bool video_start(
127 const std::string& name="",
128 const std::string& codec="",
129 double quality=-1,
130 double speed=-1,
131 int bitrate=0
132 );
133
134 // Stop video encoding of main window.
135 //
136 void video_stop();
137
138private:
139 simgear::TiedPropertyList _tiedProperties;
140
141 void setCurrentViewIndex(int newview);
142
143 bool _inited = false;
144 std::vector<SGPropertyNode_ptr> config_list;
145 SGPropertyNode_ptr _viewNumberProp;
146 typedef std::vector<flightgear::ViewPtr> viewer_list;
147 viewer_list views;
148
149 int _current = 0;
150
151 std::unique_ptr<simgear::VideoEncoder> _video_encoder;
152};
153
154#endif // _VIEWMGR_HXX
#define i(x)
int size() const
Definition viewmgr.hxx:67
void view_new(const SGPropertyNode *config)
Definition viewmgr.cxx:350
void reinit() override
Definition viewmgr.cxx:114
static const char * staticSubsystemClassId()
Definition viewmgr.hxx:64
void clear()
Definition viewmgr.cxx:258
void view_push()
Definition viewmgr.cxx:322
FGViewMgr(void)
Definition viewmgr.cxx:32
void bind() override
Definition viewmgr.cxx:123
void postinit() override
Definition viewmgr.cxx:95
void unbind() override
Definition viewmgr.cxx:140
void shutdown() override
Definition viewmgr.cxx:103
void video_stop()
Definition viewmgr.cxx:481
void update(double dt) override
Definition viewmgr.cxx:180
flightgear::View * next_view()
Definition viewmgr.cxx:302
flightgear::View * prev_view()
Definition viewmgr.cxx:311
void init() override
Definition viewmgr.cxx:42
~FGViewMgr(void)
Definition viewmgr.cxx:37
int getCurrentViewIndex() const
Definition viewmgr.cxx:495
void clone_current_view(const SGPropertyNode *config)
Definition viewmgr.cxx:335
void clone_last_pair_double(const SGPropertyNode *config)
Definition viewmgr.cxx:345
flightgear::View * get_view(int i)
Definition viewmgr.cxx:286
bool video_start(const std::string &name="", const std::string &codec="", double quality=-1, double speed=-1, int bitrate=0)
Definition viewmgr.cxx:364
flightgear::View * get_current_view()
Definition viewmgr.cxx:264
void clone_last_pair(const SGPropertyNode *config)
Definition viewmgr.cxx:340
void add_view(flightgear::View *v)
Definition viewmgr.cxx:358
const char * name
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...
Definition Addon.cxx:53
SGSharedPtr< flightgear::View > ViewPtr
Definition viewmgr.hxx:41