FlightGear next
environment_mgr.hxx
Go to the documentation of this file.
1// environment-mgr.hxx -- manager for natural environment information.
2//
3// Written by David Megginson, started February 2002.
4//
5// Copyright (C) 2002 David Megginson - david@megginson.com
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
22#ifndef _ENVIRONMENT_MGR_HXX
23#define _ENVIRONMENT_MGR_HXX
24
25#include <simgear/compiler.h>
26#include <simgear/structure/subsystem_mgr.hxx>
27#include <simgear/props/tiedpropertylist.hxx>
28#include <simgear/math/SGMath.hxx>
29
30#include <cmath>
31
32class FGEnvironment;
33class FGClimate;
34class FGClouds;
36class SGSky;
38
42class FGEnvironmentMgr : public SGSubsystemGroup
43{
44public:
45 enum {
47 };
48
50 virtual ~FGEnvironmentMgr ();
51
52 // Subsystem API.
53 void bind() override;
54 InitStatus incrementalInit() override;
55 void reinit() override;
56 void shutdown() override;
57 void unbind() override;
58 void update(double dt) override;
59
60 // Subsystem identification.
61 static const char* staticSubsystemClassId() { return "environment"; }
62
66 virtual FGEnvironment getEnvironment () const;
67
69
70 virtual FGEnvironment getEnvironmentAtPosition(const SGGeod& aPos) const;
71
72private:
74 void updateClosestAirport();
75 void updateTowerPosition();
76
77 double get_cloud_layer_span_m (int index) const;
78 void set_cloud_layer_span_m (int index, double span_m);
79 double get_cloud_layer_elevation_ft (int index) const;
80 void set_cloud_layer_elevation_ft (int index, double elevation_ft);
81 double get_cloud_layer_thickness_ft (int index) const;
82 void set_cloud_layer_thickness_ft (int index, double thickness_ft);
83 double get_cloud_layer_transition_ft (int index) const;
84 void set_cloud_layer_transition_ft (int index, double transition_ft);
85 const char * get_cloud_layer_coverage (int index) const;
86 void set_cloud_layer_coverage (int index, const char * coverage);
87 int get_cloud_layer_coverage_type (int index) const;
88 void set_cloud_layer_coverage_type (int index, int type );
89 double get_cloud_layer_visibility_m (int index) const;
90 void set_cloud_layer_visibility_m (int index, double visibility_m);
91 double get_cloud_layer_maxalpha (int index ) const;
92 void set_cloud_layer_maxalpha (int index, double maxalpha);
93
94 FGClimate * _climate = nullptr;
95 FGEnvironment * _environment = nullptr; // always the same, for now
96 FGClouds *fgClouds = nullptr;
97 bool _cloudLayersDirty = true;
98 int max_tower_height_feet;
99 int min_tower_height_feet;
100 int default_tower_height_feet;
101
102 simgear::TiedPropertyList _tiedProperties;
103 SGPropertyChangeListener * _3dCloudsEnableListener;
104 FGEnvironmentMgrMultiplayerListener * _multiplayerListener;
105 SGSky* _sky;
106
107 SGPropertyNode_ptr towerViewPositionLatDegNode;
108 SGPropertyNode_ptr towerViewPositionLonDegNode;
109 SGPropertyNode_ptr towerViewPositionAltFtNode;
110
111 const class FGAICarrier* nearestCarrier;
112 const class FGAirport* nearestAirport;
113};
114
115#endif // _ENVIRONMENT_MGR_HXX
virtual ~FGEnvironmentMgr()
InitStatus incrementalInit() override
void unbind() override
void bind() override
const FGEnvironment * getAircraftEnvironment() const
void update(double dt) override
virtual FGEnvironment getEnvironmentAtPosition(const SGGeod &aPos) const
void reinit() override
void shutdown() override
static const char * staticSubsystemClassId()
virtual FGEnvironment getEnvironment() const
Get the environment information for the plane's current position.
Model the natural environment.