| 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 - [email protected] |
| 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 | |
| 32 | class FGEnvironment; |
| 33 | class FGClimate; |
| 34 | class FGClouds; |
| 35 | class FGPrecipitationMgr; |
| 36 | class SGSky; |
| 37 | struct FGEnvironmentMgrPropertyListener; |
| 38 | |
| 39 | /** |
| 40 | * Manage environment information. |
| 41 | */ |
| 42 | class FGEnvironmentMgr : public SGSubsystemGroup |
| 43 | { |
| 44 | public: |
| 45 | enum { |
| 46 | MAX_CLOUD_LAYERS = 5 |
| 47 | }; |
| 48 | |
| 49 | FGEnvironmentMgr (); |
| 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 | |
| 63 | /** |
| 64 | * Get the environment information for the plane's current position. |
| 65 | */ |
| 66 | virtual FGEnvironment getEnvironment () const; |
| 67 | |
| 68 | const FGEnvironment* getAircraftEnvironment() const; |
| 69 | |
| 70 | virtual FGEnvironment getEnvironmentAtPosition(const SGGeod& aPos) const; |
| 71 | |
| 72 | private: |
| 73 | friend FGEnvironmentMgrPropertyListener; |
| 74 | |
| 75 | void updateClosestAirport(); |
| 76 | void updateDynamicTowerPosition(); |
| 77 | void onTowerAirportIDChanged(); |
| 78 | |
| 79 | double get_cloud_layer_span_m (int index) const; |
| 80 | void set_cloud_layer_span_m (int index, double span_m); |
| 81 | double get_cloud_layer_elevation_ft (int index) const; |
| 82 | void set_cloud_layer_elevation_ft (int index, double elevation_ft); |
| 83 | double get_cloud_layer_thickness_ft (int index) const; |
| 84 | void set_cloud_layer_thickness_ft (int index, double thickness_ft); |
| 85 | double get_cloud_layer_transition_ft (int index) const; |
| 86 | void set_cloud_layer_transition_ft (int index, double transition_ft); |
| 87 | const char * get_cloud_layer_coverage (int index) const; |
| 88 | void set_cloud_layer_coverage (int index, const char * coverage); |
| 89 | int get_cloud_layer_coverage_type (int index) const; |
| 90 | void set_cloud_layer_coverage_type (int index, int type ); |
| 91 | double get_cloud_layer_visibility_m (int index) const; |
| 92 | void set_cloud_layer_visibility_m (int index, double visibility_m); |
| 93 | double get_cloud_layer_maxalpha (int index ) const; |
| 94 | void set_cloud_layer_maxalpha (int index, double maxalpha); |
| 95 | |
| 96 | FGClimate * _climate = nullptr; |
| 97 | FGEnvironment * _environment = nullptr; // always the same, for now |
| 98 | FGClouds *fgClouds = nullptr; |
| 99 | bool _cloudLayersDirty = true; |
| 100 | int max_tower_height_feet; |
| 101 | int min_tower_height_feet; |
| 102 | int default_tower_height_feet; |
| 103 | |
| 104 | simgear::TiedPropertyList _tiedProperties; |
| 105 | SGPropertyChangeListener * _3dCloudsEnableListener; |
| 106 | |
| 107 | std::unique_ptr<FGEnvironmentMgrPropertyListener> _listener; |
| 108 | SGSky* _sky; |
| 109 | |
| 110 | SGPropertyNode_ptr towerViewPositionLatDegNode; |
| 111 | SGPropertyNode_ptr towerViewPositionLonDegNode; |
| 112 | SGPropertyNode_ptr towerViewPositionAltFtNode; |
| 113 | SGPropertyNode_ptr _automaticTowerEnableNode; |
| 114 | |
| 115 | const class FGAICarrier* nearestCarrier; |
| 116 | const class FGAirport* nearestAirport; |
| 117 | }; |
| 118 | |
| 119 | #endif // _ENVIRONMENT_MGR_HXX |