From 60a2444766580826522e1d5ddae6c99a0d8bec2e Mon Sep 17 00:00:00 2001 From: Edward d'Auvergne Date: Tue, 3 Apr 2018 12:21:33 +0200 Subject: [PATCH] SGSubsystem classes: Whitespace standardisation of the declarations. This is a clean up commit prior to the subsystem API standardisation to simplify the diffs. It includes all SGSubsystem and SGSubsystemGroup derived classes. --- docs-mini/README.introduction | 17 +- src/AIModel/AIManager.hxx | 8 +- src/AIModel/performancedb.hxx | 13 +- src/AIModel/submodel.hxx | 9 +- src/ATC/atc_mgr.hxx | 30 +- src/Aircraft/FlightHistory.hxx | 41 +- src/Aircraft/controls.hxx | 75 +- src/Aircraft/replay.hxx | 2 +- src/Airports/airportdynamicsmanager.hxx | 1 + src/Autopilot/analogcomponent.hxx | 26 +- src/Autopilot/autopilot.cxx | 31 +- src/Autopilot/autopilotgroup.cxx | 12 +- src/Autopilot/autopilotgroup.hxx | 6 +- src/Autopilot/component.hxx | 21 +- src/Autopilot/digitalcomponent.hxx | 8 +- src/Autopilot/digitalfilter.hxx | 11 +- src/Autopilot/flipflop.hxx | 17 +- src/Autopilot/logic.hxx | 4 +- src/Autopilot/pidcontroller.hxx | 5 +- src/Autopilot/pisimplecontroller.hxx | 5 +- src/Autopilot/predictor.hxx | 10 +- src/Autopilot/route_mgr.hxx | 182 ++--- src/Canvas/canvas_mgr.hxx | 8 +- src/Canvas/gui_mgr.hxx | 8 +- src/Cockpit/NavDisplay.hxx | 52 +- src/Cockpit/agradar.hxx | 6 +- src/Cockpit/cockpitDisplayManager.hxx | 7 +- src/Cockpit/groundradar.hxx | 9 +- src/Cockpit/wxradar.hxx | 10 +- src/Environment/environment_ctrl.hxx | 11 +- src/Environment/environment_mgr.hxx | 92 ++- src/Environment/ephemeris.hxx | 21 +- src/Environment/magvarmanager.hxx | 12 +- src/Environment/realwx_ctrl.cxx | 6 +- src/Environment/realwx_ctrl.hxx | 6 +- src/Environment/ridge_lift.hxx | 62 +- src/Environment/terrainsampler.cxx | 41 +- src/Environment/terrainsampler.hxx | 7 +- src/FDM/ExternalNet/ExternalNet.hxx | 8 +- src/FDM/ExternalPipe/ExternalPipe.hxx | 9 +- src/FDM/JSBSim/JSBSim.hxx | 9 +- src/FDM/LaRCsim/LaRCsim.hxx | 33 +- src/FDM/NullFDM.hxx | 7 +- src/FDM/SP/ACMS.hxx | 6 +- src/FDM/SP/ADA.hxx | 10 +- src/FDM/SP/AISim.hpp | 84 +-- src/FDM/SP/Balloon.h | 26 +- src/FDM/SP/MagicCarpet.hxx | 8 +- src/FDM/UFO.hxx | 10 +- src/FDM/YASim/YASim.hxx | 6 +- src/FDM/fdm_shell.hxx | 50 +- src/FDM/flight.hxx | 225 +++--- src/GUI/new_gui.hxx | 13 +- src/Input/FGEventInput.hxx | 303 ++++---- src/Input/FGHIDEventInput.hxx | 25 +- src/Input/FGJoystickInput.hxx | 117 +-- src/Input/FGKeyboardInput.hxx | 52 +- src/Input/FGLinuxEventInput.hxx | 57 +- src/Input/FGMacOSXEventInput.hxx | 20 +- src/Input/FGMouseInput.hxx | 16 +- src/Input/input.hxx | 19 +- src/Instrumentation/HUD/HUD.hxx | 22 +- src/Instrumentation/KLN89/kln89.hxx | 572 +++++++-------- src/Instrumentation/adf.hxx | 4 - src/Instrumentation/airspeed_indicator.hxx | 6 +- src/Instrumentation/altimeter.hxx | 4 +- src/Instrumentation/attitude_indicator.hxx | 3 - src/Instrumentation/clock.hxx | 3 +- src/Instrumentation/commradio.cxx | 54 +- src/Instrumentation/commradio.hxx | 9 +- src/Instrumentation/dclgps.hxx | 669 +++++++++--------- src/Instrumentation/dme.hxx | 3 - src/Instrumentation/gps.hxx | 170 ++--- src/Instrumentation/gsdi.hxx | 32 +- src/Instrumentation/heading_indicator.hxx | 4 - src/Instrumentation/heading_indicator_dg.hxx | 3 - src/Instrumentation/heading_indicator_fg.hxx | 14 +- .../inst_vertical_speed_indicator.hxx | 3 - src/Instrumentation/instrument_mgr.hxx | 7 +- src/Instrumentation/kr_87.hxx | 13 +- src/Instrumentation/mag_compass.hxx | 4 - src/Instrumentation/marker_beacon.hxx | 2 - src/Instrumentation/mk_viii.hxx | 2 +- src/Instrumentation/mrg.hxx | 3 - src/Instrumentation/navradio.hxx | 27 +- src/Instrumentation/newnavradio.cxx | 73 +- src/Instrumentation/newnavradio.hxx | 3 +- src/Instrumentation/rad_alt.hxx | 16 +- src/Instrumentation/slip_skid_ball.hxx | 3 - src/Instrumentation/tacan.hxx | 11 +- src/Instrumentation/tcas.hxx | 47 +- src/Instrumentation/transponder.hxx | 29 +- src/Instrumentation/turn_indicator.hxx | 6 +- .../vertical_speed_indicator.hxx | 4 - src/Main/FGInterpolator.hxx | 6 +- src/Main/fg_io.hxx | 7 +- src/Main/fg_props.hxx | 56 +- src/Main/logger.hxx | 38 +- src/Model/acmodel.hxx | 40 +- src/Model/modelmgr.hxx | 137 ++-- src/MultiPlayer/multiplaymgr.hxx | 118 +-- src/Network/DNSClient.hxx | 7 +- src/Network/HTTPClient.hxx | 9 +- src/Network/fgcom.hxx | 11 +- src/Network/http/httpd.cxx | 105 ++- src/Network/http/httpd.hxx | 4 +- src/Scenery/scenery.hxx | 17 +- src/Scripting/NasalSys.hxx | 41 +- src/Sound/voice.hxx | 59 +- src/Systems/electrical.hxx | 56 +- src/Systems/pitot.hxx | 3 - src/Systems/static.hxx | 4 - src/Systems/system_mgr.hxx | 2 - src/Systems/vacuum.hxx | 4 - src/Time/TimeManager.hxx | 147 ++-- src/Time/light.hxx | 9 +- src/Traffic/TrafficMgr.hxx | 96 ++- src/Viewer/view.hxx | 66 +- src/Viewer/viewmgr.hxx | 16 +- utils/fgpanel/FGPanel.hxx | 80 +-- utils/fgpanel/FGPanelProtocol.hxx | 19 +- utils/fgpanel/panel_io.hxx | 5 +- 122 files changed, 2449 insertions(+), 2543 deletions(-) diff --git a/docs-mini/README.introduction b/docs-mini/README.introduction index 8d4d8aab3..e3ba7f9f9 100644 --- a/docs-mini/README.introduction +++ b/docs-mini/README.introduction @@ -54,16 +54,15 @@ SGSubsystem and define at least a small set of functions: class FGFX : public SGSubsystem { public: + FGFX(); + virtual ~FGFX(); - FGFX (); - virtual ~FGFX (); - - virtual void init (); - virtual void reinit (); - virtual void bind (); - virtual void unbind (); - virtual void update (double dt); - } + virtual void init(); + virtual void reinit(); + virtual void bind(); + virtual void unbind(); + virtual void update(double dt); + }; The init() functions should make sure everything is set and ready so the update() function can be run by the main loop. The reinit() function handles diff --git a/src/AIModel/AIManager.hxx b/src/AIModel/AIManager.hxx index 783249b31..96cff2bf9 100644 --- a/src/AIModel/AIManager.hxx +++ b/src/AIModel/AIManager.hxx @@ -37,7 +37,6 @@ typedef SGSharedPtr FGAIBasePtr; class FGAIManager : public SGSubsystem { - public: FGAIManager(); virtual ~FGAIManager(); @@ -99,15 +98,16 @@ public: * avoid correctly. */ FGAIAircraft* getUserAircraft() const; - + bool isRadarEnabled() const { return _radarEnabled; } - + bool enableRadarDebug() const { return _radarDebugMode; } - + double radarRangeM() const { return _radarRangeM; } + private: // FGSubmodelMgr is a friend for access to the AI_list friend class FGSubmodelMgr; diff --git a/src/AIModel/performancedb.hxx b/src/AIModel/performancedb.hxx index 0e80b28fd..e5bbcdf9a 100644 --- a/src/AIModel/performancedb.hxx +++ b/src/AIModel/performancedb.hxx @@ -15,7 +15,7 @@ class SGPath; * * Allows to store performance data for later reuse/retrieval. Just * a simple map for now. - * + * * @author Thomas F�rster */ //TODO provide std::map interface? @@ -41,6 +41,7 @@ public: PerformanceData* getDefaultPerformance() const; static const char* subsystemName() { return "aircraft-performance-db"; } + private: void load(const SGPath& path); @@ -49,13 +50,13 @@ private: typedef std::map PerformanceDataDict; PerformanceDataDict _db; - + const std::string& findAlias(const std::string& acType) const; - + typedef std::pair StringPair; - /// alias list, to allow type/class names to share data. This is used to merge - /// related types together. Note it's ordered, and not a map since we permit - /// partial matches when merging - the first matching alias is used. + /// alias list, to allow type/class names to share data. This is used to merge + /// related types together. Note it's ordered, and not a map since we permit + /// partial matches when merging - the first matching alias is used. std::vector _aliases; }; diff --git a/src/AIModel/submodel.hxx b/src/AIModel/submodel.hxx index edd378e77..0ce027c40 100644 --- a/src/AIModel/submodel.hxx +++ b/src/AIModel/submodel.hxx @@ -19,11 +19,10 @@ class FGAIBase; class FGAIManager; -class FGSubmodelMgr : public SGSubsystem, public SGPropertyChangeListener +class FGSubmodelMgr : public SGSubsystem, + public SGPropertyChangeListener { - public: - typedef struct { SGPropertyNode_ptr trigger_node; SGPropertyNode_ptr prop; @@ -107,7 +106,6 @@ public: void shutdown() override; private: - typedef std::vector submodel_vector_type; typedef submodel_vector_type::iterator submodel_vector_iterator; @@ -183,10 +181,9 @@ private: SGGeod userpos; SGGeod offsetpos; - + SGVec3d getCartOffsetPos(submodel* sm) const; void setOffsetPos(submodel* sm); - }; #endif // __SYSTEMS_SUBMODEL_HXX diff --git a/src/ATC/atc_mgr.hxx b/src/ATC/atc_mgr.hxx index 4f378d895..9fa77ee63 100644 --- a/src/ATC/atc_mgr.hxx +++ b/src/ATC/atc_mgr.hxx @@ -23,8 +23,8 @@ /************************************************************************** * The ATC Manager interfaces the users aircraft with the AI traffic system * and also monitors the ongoing AI traffic patterns for potential conflicts - * and interferes where necessary. - *************************************************************************/ + * and interferes where necessary. + *************************************************************************/ #ifndef _ATC_MGR_HXX_ #define _ATC_MGR_HXX_ @@ -42,21 +42,21 @@ typedef std::vector::iterator AtcVecIterator; class FGATCManager : public SGSubsystem { private: - AtcVec activeStations; - FGATCController *controller, *prevController; // The ATC controller that is responsible for the user's aircraft. - bool networkVisible; - bool initSucceeded; - SGPropertyNode_ptr trans_num; + AtcVec activeStations; + FGATCController *controller, *prevController; // The ATC controller that is responsible for the user's aircraft. + bool networkVisible; + bool initSucceeded; + SGPropertyNode_ptr trans_num; public: - FGATCManager(); - ~FGATCManager(); - void postinit() override; - void shutdown() override; + FGATCManager(); + ~FGATCManager(); + void postinit() override; + void shutdown() override; - void addController(FGATCController *controller); - void removeController(FGATCController* controller); - void update(double time); + void addController(FGATCController *controller); + void removeController(FGATCController* controller); + void update(double time); }; - + #endif // _ATC_MRG_HXX_ diff --git a/src/Aircraft/FlightHistory.hxx b/src/Aircraft/FlightHistory.hxx index 9e36d583e..5d6950b14 100644 --- a/src/Aircraft/FlightHistory.hxx +++ b/src/Aircraft/FlightHistory.hxx @@ -31,13 +31,15 @@ typedef std::vector SGGeodVec; -class PagedPathForHistory : public SGReferenced { +class PagedPathForHistory : public SGReferenced +{ public: - PagedPathForHistory() : last_seen(0) {} - virtual ~PagedPathForHistory() {} - SGGeodVec path; - time_t last_seen; + PagedPathForHistory() : last_seen(0) {} + virtual ~PagedPathForHistory() {} + SGGeodVec path; + time_t last_seen; }; + typedef SGSharedPtr PagedPathForHistory_ptr; const unsigned int SAMPLE_BUCKET_WIDTH = 1024; @@ -54,12 +56,12 @@ class FGFlightHistory : public SGSubsystem public: FGFlightHistory(); virtual ~FGFlightHistory(); - + virtual void init(); virtual void shutdown(); virtual void reinit(); virtual void update(double dt); - + PagedPathForHistory_ptr pagedPathForHistory(size_t max_entries, size_t newerThan = 0) const; /** * retrieve the path, collapsing segments shorter than @@ -86,9 +88,8 @@ private: float heading, pitch, roll; size_t simTimeMSec; }; - - - + + /** * Bucket is a fixed-size container of samples. This is a crude slab * allocation of samples, in chunks defined by the width constant above. @@ -101,26 +102,26 @@ private: public: Sample samples[SAMPLE_BUCKET_WIDTH]; }; - + double m_lastCaptureTime; double m_sampleInterval; ///< sample interval in seconds -/// our store of samples (in buckets). The last bucket is partially full, -/// with the number of valid samples indicated by m_validSampleCount + /// our store of samples (in buckets). The last bucket is partially full, + /// with the number of valid samples indicated by m_validSampleCount std::vector m_buckets; - -/// number of valid samples in the final bucket + + /// number of valid samples in the final bucket unsigned int m_validSampleCount; - + SGPropertyNode_ptr m_weightOnWheels; SGPropertyNode_ptr m_enabled; - + bool m_lastWoW; size_t m_maxMemoryUseBytes; - + void allocateNewBucket(); - + void capture(); - + size_t currentMemoryUseBytes() const; }; diff --git a/src/Aircraft/controls.hxx b/src/Aircraft/controls.hxx index aefe94b8d..970cc8c11 100644 --- a/src/Aircraft/controls.hxx +++ b/src/Aircraft/controls.hxx @@ -31,9 +31,7 @@ class FGControls : public SGSubsystem { - public: - enum { ALL_ENGINES = -1, MAX_ENGINES = 12 @@ -83,19 +81,19 @@ public: ALL_EJECTION_SEATS = -1, MAX_EJECTION_SEATS = 10 }; - + enum { SEAT_SAFED = -1, SEAT_ARMED = 0, SEAT_FAIL = 1 }; - - enum { + + enum { CMD_SEL_NORM = -1, CMD_SEL_AFT = 0, CMD_SEL_SOLO = 1 }; - + private: // controls/flight/ double aileron; @@ -143,7 +141,7 @@ private: bool fuel_selector[MAX_TANKS]; int to_engine[MAX_TANKS]; int to_tank[MAX_TANKS]; - + // controls/fuel/tank[n]/pump[p]/ bool boost_pump[MAX_TANKS * MAX_BOOSTPUMPS]; @@ -174,7 +172,7 @@ private: // controls/anti-ice/engine[n]/ bool carb_heat[MAX_ENGINES]; bool inlet_heat[MAX_ENGINES]; - + // controls/hydraulic/system[n]/ bool engine_pump[MAX_HYD_SYSTEMS]; bool electric_pump[MAX_HYD_SYSTEMS]; @@ -193,7 +191,7 @@ private: // controls/pneumatic/engine[n]/ bool engine_bleed[MAX_ENGINES]; - + // controls/pressurization/ int mode; bool dump; @@ -247,16 +245,15 @@ private: double bank_angle_select; double vertical_speed_select; double speed_select; - double mach_select; + double mach_select; int vertical_mode; int lateral_mode; - SGPropertyNode_ptr auto_coordination; SGPropertyNode_ptr auto_coordination_factor; simgear::TiedPropertyList _tiedProperties; -public: +public: FGControls(); ~FGControls(); @@ -266,10 +263,10 @@ public: void unbind (); void update (double dt); virtual void reinit(); - + // Reset function void reset_all(void); - + // Query functions // controls/flight/ inline double get_aileron() const { return aileron; } @@ -280,7 +277,7 @@ public: inline double get_rudder_trim() const { return rudder_trim; } inline double get_flaps() const { return flaps; } inline double get_slats() const { return slats; } - inline bool get_BLC() const { return BLC; } + inline bool get_BLC() const { return BLC; } inline double get_spoilers() const { return spoilers; } inline double get_speedbrake() const { return speedbrake; } inline double get_wing_sweep() const { return wing_sweep; } @@ -305,7 +302,7 @@ public: } inline int get_magnetos(int engine) const { return magnetos[engine]; } inline int get_feed_tank(int engine) const { return feed_tank[engine]; } - inline bool get_nitrous_injection(int engine) const { + inline bool get_nitrous_injection(int engine) const { return nitrous_injection[engine]; } inline double get_cowl_flaps_norm(int engine) const { @@ -315,8 +312,8 @@ public: inline int get_ignition(int engine) const { return ignition[engine]; } inline bool get_augmentation(int engine) const { return augmentation[engine]; } inline bool get_reverser(int engine) const { return reverser[engine]; } - inline bool get_water_injection(int engine) const { - return water_injection[engine]; + inline bool get_water_injection(int engine) const { + return water_injection[engine]; } inline double get_condition(int engine) const { return condition[engine]; } @@ -375,7 +372,7 @@ public: inline bool get_APU_generator() const { return APU_generator; } // controls/electric/engine[n]/ - inline bool get_generator_breaker(int engine) const { + inline bool get_generator_breaker(int engine) const { return generator_breaker[engine]; } inline bool get_bus_tie(int engine) const { return bus_tie[engine]; } @@ -385,7 +382,7 @@ public: // controls/pneumatic/engine[n]/ inline bool get_engine_bleed(int engine) const { return engine_bleed[engine]; } - + // controls/pressurization/ inline int get_mode() const { return mode; } inline double get_outflow_valve() const { return outflow_valve; } @@ -427,7 +424,7 @@ public: return eseat_status[which_seat]; } inline int get_cmd_selector_valve() const { return cmd_selector_valve; } - + // controls/APU/ inline int get_off_start_run() const { return off_start_run; } @@ -439,19 +436,19 @@ public: inline double get_heading_select() const { return heading_select; } inline double get_altitude_select() const { return altitude_select; } inline double get_bank_angle_select() const { return bank_angle_select; } - inline double get_vertical_speed_select() const { - return vertical_speed_select; + inline double get_vertical_speed_select() const { + return vertical_speed_select; } inline double get_speed_select() const { return speed_select; } - inline double get_mach_select() const { return mach_select; } + inline double get_mach_select() const { return mach_select; } inline int get_vertical_mode() const { return vertical_mode; } inline int get_lateral_mode() const { return lateral_mode; } // controls/autoflight/autopilot[n]/ - inline bool get_autopilot_engage(int ap) const { + inline bool get_autopilot_engage(int ap) const { return autopilot_engage[ap]; } - + // Update functions // controls/flight/ @@ -471,14 +468,14 @@ public: void move_flaps( double amt ); void set_slats( double pos ); void move_slats( double amt ); - void set_BLC( bool val ); + void set_BLC( bool val ); void set_spoilers( double pos ); void move_spoilers( double amt ); void set_speedbrake( double pos ); void move_speedbrake( double amt ); void set_wing_sweep( double pos ); void move_wing_sweep( double amt ); - void set_wing_fold( bool val ); + void set_wing_fold( bool val ); void set_drag_chute( bool val ); // controls/engines/ @@ -507,7 +504,7 @@ public: void set_augmentation( int engine, bool val ); void set_reverser( int engine, bool val ); void set_water_injection( int engine, bool val ); - void set_condition( int engine, double val ); + void set_condition( int engine, double val ); // controls/fuel void set_dump_valve( bool val ); @@ -569,7 +566,7 @@ public: // controls/pneumatic/engine[n]/ void set_engine_bleed( int engine, bool val ); - + // controls/pressurization/ void set_mode( int mode ); void set_outflow_valve( double pos ); @@ -631,8 +628,8 @@ public: void move_vertical_speed_select( double amt ); void set_speed_select( double speed ); void move_speed_select( double amt ); - void set_mach_select( double mach ); - void move_mach_select( double amt ); + void set_mach_select( double mach ); + void move_mach_select( double amt ); void set_vertical_mode( int mode ); void set_lateral_mode( int mode ); @@ -640,17 +637,17 @@ public: void set_autopilot_engage( int ap, bool val ); static const char* subsystemName() { return "controls"; } + private: inline void do_autocoordination() { - // check for autocoordination - if ( auto_coordination->getBoolValue() ) { - double factor = auto_coordination_factor->getDoubleValue(); - if( factor > 0.0 ) set_rudder( aileron * factor ); - } - } + // check for autocoordination + if ( auto_coordination->getBoolValue() ) { + double factor = auto_coordination_factor->getDoubleValue(); + if( factor > 0.0 ) set_rudder( aileron * factor ); + } + } }; - #endif // _CONTROLS_HXX diff --git a/src/Aircraft/replay.hxx b/src/Aircraft/replay.hxx index 3ee25a08c..de8f7be0c 100644 --- a/src/Aircraft/replay.hxx +++ b/src/Aircraft/replay.hxx @@ -56,7 +56,7 @@ typedef std::vector < FGReplayMessages > replay_messages_type; /** * A recording/replay module for FlightGear flights - * + * */ class FGReplay : public SGSubsystem diff --git a/src/Airports/airportdynamicsmanager.hxx b/src/Airports/airportdynamicsmanager.hxx index 8eb2fa6e4..691325444 100644 --- a/src/Airports/airportdynamicsmanager.hxx +++ b/src/Airports/airportdynamicsmanager.hxx @@ -50,6 +50,7 @@ public: FGAirportDynamicsRef dynamicsForICAO(const std::string& icao); static const char* subsystemName() { return "airport-dynamics"; } + private: typedef std::map ICAODynamicsDict; ICAODynamicsDict m_dynamics; diff --git a/src/Autopilot/analogcomponent.hxx b/src/Autopilot/analogcomponent.hxx index 852f7432a..f7e6b76fa 100644 --- a/src/Autopilot/analogcomponent.hxx +++ b/src/Autopilot/analogcomponent.hxx @@ -40,8 +40,8 @@ namespace FGXMLAutopilot { *
  • an optional periodical definition
  • * */ -class AnalogComponent : public Component { - +class AnalogComponent : public Component +{ private: /** * @brief a flag signalling that the output property value shall be fed back @@ -77,7 +77,7 @@ protected: PeriodicalValue_ptr _periodical; /** - * @brief A constructor for an analog component. Call configure() to + * @brief A constructor for an analog component. Call configure() to * configure this component from a property node */ AnalogComponent(); @@ -104,8 +104,8 @@ protected: /** * @brief overideable method being called from the update() method if this component - * is disabled. Analog components feed back it's output value to the active - input value if disabled and feedback-if-disabled is true + * is disabled. Analog components feed back it's output value to the active + input value if disabled and feedback-if-disabled is true */ virtual void disabled( double dt ); @@ -115,10 +115,10 @@ protected: * If no output property is configured, a value of zero will be returned. * If more than one output property is configured, the value of the first output property * is returned. The current value of the output property will be clamped to the configured - * values of <min> and/or <max>. + * values of <min> and/or <max>. */ inline double get_output_value() const { - return _output_list.empty() ? 0.0 : clamp(_output_list[0]->getDoubleValue()); + return _output_list.empty() ? 0.0 : clamp(_output_list[0]->getDoubleValue()); } simgear::PropertyList _output_list; @@ -134,7 +134,7 @@ protected: value = clamp( value ); for( simgear::PropertyList::iterator it = _output_list.begin(); it != _output_list.end(); ++it) - (*it)->setDoubleValue( value ); + (*it)->setDoubleValue( value ); } public: @@ -143,11 +143,11 @@ public: inline void AnalogComponent::disabled( double dt ) { - if( _feedback_if_disabled && ! _output_list.empty() ) { - InputValue * input; - if( (input = _valueInput.get_active() ) != NULL ) - input->set_value( _output_list[0]->getDoubleValue() ); - } + if( _feedback_if_disabled && ! _output_list.empty() ) { + InputValue * input; + if( (input = _valueInput.get_active() ) != NULL ) + input->set_value( _output_list[0]->getDoubleValue() ); + } } } diff --git a/src/Autopilot/autopilot.cxx b/src/Autopilot/autopilot.cxx index f1067eeae..6b653a0ab 100644 --- a/src/Autopilot/autopilot.cxx +++ b/src/Autopilot/autopilot.cxx @@ -49,25 +49,22 @@ using namespace FGXMLAutopilot; class StateMachineComponent : public Component { public: - StateMachineComponent( SGPropertyNode& props_root, - SGPropertyNode& cfg ) - { - inner = simgear::StateMachine::createFromPlist(&cfg, &props_root); - } - - virtual bool configure( const std::string & nodeName, SGPropertyNode_ptr config) - { - return false; - } - - virtual void update( bool firstTime, double dt ) - { - SG_UNUSED(firstTime); - inner->update(dt); - } + StateMachineComponent( SGPropertyNode& props_root, + SGPropertyNode& cfg ) { + inner = simgear::StateMachine::createFromPlist(&cfg, &props_root); + } + + virtual bool configure( const std::string & nodeName, SGPropertyNode_ptr config) { + return false; + } + + virtual void update( bool firstTime, double dt ) { + SG_UNUSED(firstTime); + inner->update(dt); + } private: - simgear::StateMachine_ptr inner; + simgear::StateMachine_ptr inner; }; class StateMachineFunctor : public FunctorBase diff --git a/src/Autopilot/autopilotgroup.cxx b/src/Autopilot/autopilotgroup.cxx index ea4782ac7..0176f4598 100644 --- a/src/Autopilot/autopilotgroup.cxx +++ b/src/Autopilot/autopilotgroup.cxx @@ -40,13 +40,12 @@ using std::vector; using simgear::PropertyList; using FGXMLAutopilot::Autopilot; -class FGXMLAutopilotGroupImplementation: - public FGXMLAutopilotGroup +class FGXMLAutopilotGroupImplementation : public FGXMLAutopilotGroup { - public: +public: FGXMLAutopilotGroupImplementation(const std::string& nodeName): - FGXMLAutopilotGroup(), - _nodeName(nodeName) + FGXMLAutopilotGroup(), + _nodeName(nodeName) {} virtual void addAutopilot( const std::string& name, @@ -57,10 +56,9 @@ class FGXMLAutopilotGroupImplementation: InitStatus incrementalInit(); void reinit(); - private: +private: void initFrom( SGPropertyNode_ptr rootNode, const char * childName ); std::string _nodeName; - }; //------------------------------------------------------------------------------ diff --git a/src/Autopilot/autopilotgroup.hxx b/src/Autopilot/autopilotgroup.hxx index b0885a47f..3b7887a0f 100644 --- a/src/Autopilot/autopilotgroup.hxx +++ b/src/Autopilot/autopilotgroup.hxx @@ -26,19 +26,19 @@ /** * @brief Model an autopilot system by implementing a SGSubsystemGroup - * + * */ class FGXMLAutopilotGroup : public SGSubsystemGroup { public: static FGXMLAutopilotGroup * createInstance(const std::string& nodeName); - + void addAutopilotFromFile( const std::string & name, SGPropertyNode_ptr apNode, const char * path ); virtual void addAutopilot( const std::string & name, SGPropertyNode_ptr apNode, SGPropertyNode_ptr config ) = 0; virtual void removeAutopilot( const std::string & name ) = 0; + protected: FGXMLAutopilotGroup() : SGSubsystemGroup("FGXMLAutopilotGroup") {} - }; #endif // _XMLAUTO_HXX diff --git a/src/Autopilot/component.hxx b/src/Autopilot/component.hxx index 71297bf01..4afdb4658 100644 --- a/src/Autopilot/component.hxx +++ b/src/Autopilot/component.hxx @@ -35,17 +35,15 @@ namespace FGXMLAutopilot { /** * @brief Base class for other autopilot components */ -class Component : public SGSubsystem { - +class Component : public SGSubsystem +{ private: - SGSharedPtr _condition; SGPropertyNode_ptr _enable_prop; std::string * _enable_value; bool _enabled; protected: - virtual bool configure( SGPropertyNode& cfg_node, const std::string& cfg_name, SGPropertyNode& prop_root ); @@ -55,10 +53,10 @@ protected: */ virtual void update( double dt ); - /** + /** * @brief pure virtual function to be implemented by the derived classes. Gets called from * the update method if it's not disabled with the firstTime parameter set to true if this - * is the first call after being enabled + * is the first call after being enabled * @param firstTime set to true if this is the first update call since this component has been enabled. Set to false for every subsequent call. * @param dt the elapsed time since the last call @@ -71,21 +69,20 @@ protected: */ virtual void disabled( double dt ) {} - /** + /** * @brief debug flag, true if this component should generate some useful output * on every iteration */ bool _debug; - /** + /** * @brief a (historic) flag signalling the derived class that it should compute it's internal * state but shall not set the output properties if /autopilot/locks/passive-mode is true. */ bool _honor_passive; - + public: - /** * @brief A constructor for an empty Component. */ @@ -124,7 +121,7 @@ public: * <enable> section * @return true if the enable-condition is true. * - * If a <condition> is defined, this condition is evaluated, + * If a <condition> is defined, this condition is evaluated, * <prop> and <value> tags are ignored. * * If a <prop> is defined and no <value> is defined, the property @@ -139,6 +136,6 @@ public: bool isPropertyEnabled(); }; - } + #endif // COMPONENT_HXX diff --git a/src/Autopilot/digitalcomponent.hxx b/src/Autopilot/digitalcomponent.hxx index ade691635..5b2f6b780 100644 --- a/src/Autopilot/digitalcomponent.hxx +++ b/src/Autopilot/digitalcomponent.hxx @@ -90,12 +90,14 @@ typedef SGSharedPtr DigitalOutput_ptr; *
  • any number of output properties
  • * */ -class DigitalComponent : public Component { +class DigitalComponent : public Component +{ public: DigitalComponent(); - class InputMap : public std::map > { - public: + class InputMap : public std::map > + { + public: bool get_value( const std::string & name ) const; }; diff --git a/src/Autopilot/digitalfilter.hxx b/src/Autopilot/digitalfilter.hxx index 956faaba2..6a497d35c 100644 --- a/src/Autopilot/digitalfilter.hxx +++ b/src/Autopilot/digitalfilter.hxx @@ -37,16 +37,16 @@ namespace FGXMLAutopilot { */ class DigitalFilter : public AnalogComponent { - private: +private: SGSharedPtr _implementation; enum InitializeTo { - INITIALIZE_OUTPUT, - INITIALIZE_INPUT, - INITIALIZE_NONE + INITIALIZE_OUTPUT, + INITIALIZE_INPUT, + INITIALIZE_NONE }; - protected: +protected: virtual bool configure( SGPropertyNode& cfg_node, const std::string& cfg_name, SGPropertyNode& prop_root ); @@ -64,7 +64,6 @@ public: virtual bool configure( SGPropertyNode& prop_root, SGPropertyNode& cfg ); - }; } // namespace FGXMLAutopilot diff --git a/src/Autopilot/flipflop.hxx b/src/Autopilot/flipflop.hxx index 343020e75..8c4d73667 100644 --- a/src/Autopilot/flipflop.hxx +++ b/src/Autopilot/flipflop.hxx @@ -34,7 +34,7 @@ protected: /** * @brief configure this component from a property node. Iterates through all nodes found * as childs under configNode and calls configure of the derived class for each child. - * @param configNode the property node containing the configuration + * @param configNode the property node containing the configuration */ virtual bool configure( SGPropertyNode& cfg_node, const std::string& cfg_name, @@ -54,7 +54,7 @@ public: /** * @brief configure this component from a property node. Iterates through all nodes found * as childs under configNode and calls configure of the derived class for each child. - * @param configNode the property node containing the configuration + * @param configNode the property node containing the configuration */ bool configure( SGPropertyNode& prop_root, SGPropertyNode& cfg ); @@ -63,12 +63,14 @@ public: /** * @brief A simple flipflop implementation */ -class FlipFlop : public Logic { +class FlipFlop : public Logic +{ public: + protected: /** * @brief Over-rideable hook method to allow derived classes to refine top-level - * node parsing. + * node parsing. * @param aName * @param aNode * @return true if the node was handled, false otherwise. @@ -77,10 +79,10 @@ protected: const std::string& cfg_name, SGPropertyNode& prop_root ); - /** + /** * @brief Implementation of the pure virtual function of the Component class. Gets called from * the update method if it's not disabled with the firstTime parameter set to true if this - * is the first call after being enabled + * is the first call after being enabled * @param firstTime set to true if this is the first update call since this component has been enabled. Set to false for every subsequent call. * @param dt the elapsed time since the last call @@ -88,11 +90,10 @@ protected: void update( bool firstTime, double dt ); private: - /** + /** * @brief Pointer to the actual flip flop implementation */ SGSharedPtr _implementation; - }; } diff --git a/src/Autopilot/logic.hxx b/src/Autopilot/logic.hxx index 44add3a43..28407445b 100644 --- a/src/Autopilot/logic.hxx +++ b/src/Autopilot/logic.hxx @@ -32,11 +32,13 @@ namespace FGXMLAutopilot { /** * @brief A simple logic class writing <condition> to a property */ -class Logic : public DigitalComponent { +class Logic : public DigitalComponent +{ public: bool get_input() const; void set_output( bool value ); bool get_output() const; + protected: void update( bool firstTime, double dt ); }; diff --git a/src/Autopilot/pidcontroller.hxx b/src/Autopilot/pidcontroller.hxx index 4590de6e5..2dce7cfd4 100644 --- a/src/Autopilot/pidcontroller.hxx +++ b/src/Autopilot/pidcontroller.hxx @@ -37,8 +37,8 @@ namespace FGXMLAutopilot { /** * Roy Ovesen's PID controller */ -class PIDController : public AnalogComponent { - +class PIDController : public AnalogComponent +{ private: // Configuration values InputValueList Kp; // proportional gain @@ -65,6 +65,7 @@ protected: virtual bool configure( SGPropertyNode& cfg_node, const std::string& cfg_name, SGPropertyNode& prop_root ); + public: PIDController(); ~PIDController() {} diff --git a/src/Autopilot/pisimplecontroller.hxx b/src/Autopilot/pisimplecontroller.hxx index 3753df021..b03e06408 100644 --- a/src/Autopilot/pisimplecontroller.hxx +++ b/src/Autopilot/pisimplecontroller.hxx @@ -37,10 +37,10 @@ namespace FGXMLAutopilot { /** * A simplistic P [ + I ] PI controller */ -class PISimpleController : public AnalogComponent { +class PISimpleController : public AnalogComponent +{ private: - // proportional component data InputValueList _Kp; @@ -54,7 +54,6 @@ protected: SGPropertyNode& prop_root ); public: - PISimpleController(); ~PISimpleController() {} diff --git a/src/Autopilot/predictor.hxx b/src/Autopilot/predictor.hxx index 7221d5ec2..0fe743f69 100644 --- a/src/Autopilot/predictor.hxx +++ b/src/Autopilot/predictor.hxx @@ -44,8 +44,8 @@ namespace FGXMLAutopilot { * 0.1 would mean (9 parts past value + 1 part current value) / 10 * 0.25 would mean (3 parts past value + 1 part current value) / 4 */ -class Predictor : public AnalogComponent { - +class Predictor : public AnalogComponent +{ private: double _last_value; double _average; @@ -53,9 +53,9 @@ private: InputValueList _filter_gain; protected: - virtual bool configure( SGPropertyNode& cfg_node, - const std::string& cfg_name, - SGPropertyNode& prop_root ); + virtual bool configure( SGPropertyNode& cfg_node, + const std::string& cfg_name, + SGPropertyNode& prop_root ); public: Predictor(); diff --git a/src/Autopilot/route_mgr.hxx b/src/Autopilot/route_mgr.hxx index fbfd36551..59840f515 100644 --- a/src/Autopilot/route_mgr.hxx +++ b/src/Autopilot/route_mgr.hxx @@ -35,127 +35,128 @@ class PropertyWatcher; /** * Top level route manager class - * + * */ -class FGRouteMgr : public SGSubsystem, +class FGRouteMgr : public SGSubsystem, public flightgear::FlightPlan::Delegate { public: - FGRouteMgr(); - ~FGRouteMgr(); + FGRouteMgr(); + ~FGRouteMgr(); - void init (); - void postinit (); - void bind (); - void unbind (); - void update (double dt); - - bool isRouteActive() const; - - int currentIndex() const; - - void setFlightPlan(const flightgear::FlightPlanRef& plan); - flightgear::FlightPlanRef flightPlan() const; - - void clearRoute(); - - flightgear::Waypt* currentWaypt() const; - - int numLegs() const; - -// deprecated - int numWaypts() const - { return numLegs(); } - -// deprecated - flightgear::Waypt* wayptAtIndex(int index) const; - - SGPropertyNode_ptr wayptNodeAtIndex(int index) const; - - void removeLegAtIndex(int aIndex); - - /** - * Activate a built route. This checks for various mandatory pieces of - * data, such as departure and destination airports, and creates waypoints - * for them on the route structure. - * - * returns true if the route was activated successfully, or false if the - * route could not be activated for some reason - */ - bool activate(); - - /** - * deactivate the route if active - */ - void deactivate(); + void init (); + void postinit (); + void bind (); + void unbind (); + void update (double dt); - /** - * Set the current waypoint to the specified index. - */ - void jumpToIndex(int index); - - bool saveRoute(const SGPath& p); - bool loadRoute(const SGPath& p); - - flightgear::WayptRef waypointFromString(const std::string& target); + bool isRouteActive() const; + + int currentIndex() const; + + void setFlightPlan(const flightgear::FlightPlanRef& plan); + flightgear::FlightPlanRef flightPlan() const; + + void clearRoute(); + + flightgear::Waypt* currentWaypt() const; + + int numLegs() const; + + // deprecated + int numWaypts() const + { return numLegs(); } + + // deprecated + flightgear::Waypt* wayptAtIndex(int index) const; + + SGPropertyNode_ptr wayptNodeAtIndex(int index) const; + + void removeLegAtIndex(int aIndex); + + /** + * Activate a built route. This checks for various mandatory pieces of + * data, such as departure and destination airports, and creates waypoints + * for them on the route structure. + * + * returns true if the route was activated successfully, or false if the + * route could not be activated for some reason + */ + bool activate(); + + /** + * deactivate the route if active + */ + void deactivate(); + + /** + * Set the current waypoint to the specified index. + */ + void jumpToIndex(int index); + + bool saveRoute(const SGPath& p); + bool loadRoute(const SGPath& p); + + flightgear::WayptRef waypointFromString(const std::string& target); + + static const char* subsystemName() { return "route-manager"; } - static const char* subsystemName() { return "route-manager"; } private: bool commandDefineUserWaypoint(const SGPropertyNode * arg, SGPropertyNode * root); bool commandDeleteUserWaypoint(const SGPropertyNode * arg, SGPropertyNode * root); - + flightgear::FlightPlanRef _plan; - + time_t _takeoffTime; time_t _touchdownTime; // automatic inputs SGPropertyNode_ptr magvar; - - // automatic outputs + + // automatic outputs SGPropertyNode_ptr departure; ///< departure airport information SGPropertyNode_ptr destination; ///< destination airport information SGPropertyNode_ptr alternate; ///< alternate airport information SGPropertyNode_ptr cruise; ///< cruise information - + SGPropertyNode_ptr totalDistance; SGPropertyNode_ptr distanceToGo; SGPropertyNode_ptr ete; SGPropertyNode_ptr elapsedFlightTime; - + SGPropertyNode_ptr active; SGPropertyNode_ptr airborne; - + SGPropertyNode_ptr wp0; SGPropertyNode_ptr wp1; SGPropertyNode_ptr wpn; - - + + SGPropertyNode_ptr _pathNode; SGPropertyNode_ptr _currentWpt; - - - /** + + + /** * Signal property to notify people that the route was edited */ SGPropertyNode_ptr _edited; - + /** * Signal property to notify when the last waypoint is reached */ SGPropertyNode_ptr _finished; - + SGPropertyNode_ptr _flightplanChanged; - + void setETAPropertyFromDistance(SGPropertyNode_ptr aProp, double aDistance); - + /** * retrieve the cached path distance along a leg */ double cachedLegPathDistanceM(int index) const; double cachedWaypointPathTotalDistance(int index) const; - + class InputListener : public SGPropertyChangeListener { public: InputListener(FGRouteMgr *m) : mgr(m) {} @@ -167,47 +168,47 @@ private: SGPropertyNode_ptr input; SGPropertyNode_ptr weightOnWheels; SGPropertyNode_ptr groundSpeed; - + InputListener *listener; - SGPropertyNode_ptr mirror; - + SGPropertyNode_ptr mirror; + /** * Helper to keep various pieces of state in sync when the route is * modified (waypoints added, inserted, removed). Notably, this fires the * 'edited' signal. */ virtual void waypointsChanged(); - + void update_mirror(); - + virtual void currentWaypointChanged(); - -// tied getters and setters + + // tied getters and setters std::string getDepartureICAO() const; std::string getDepartureName() const; void setDepartureICAO(const std::string& aIdent); - + std::string getDepartureRunway() const; void setDepartureRunway(const std::string& aIdent); - + std::string getSID() const; void setSID(const std::string& aIdent); - + std::string getDestinationICAO() const; std::string getDestinationName() const; void setDestinationICAO(const std::string& aIdent); std::string getDestinationRunway() const; void setDestinationRunway(const std::string& aIdent); - + std::string getApproach() const; void setApproach(const std::string& aIdent); - + std::string getSTAR() const; void setSTAR(const std::string& aIdent); - - double getDepartureFieldElevation() const; - double getDestinationFieldElevation() const; + + double getDepartureFieldElevation() const; + double getDestinationFieldElevation() const; int getCruiseAltitudeFt() const; void setCruiseAltitudeFt(int ft); @@ -226,5 +227,4 @@ private: void setAlternate(const std::string &icao); }; - #endif // _ROUTE_MGR_HXX diff --git a/src/Canvas/canvas_mgr.hxx b/src/Canvas/canvas_mgr.hxx index 4a3cc5a00..a82e1be25 100644 --- a/src/Canvas/canvas_mgr.hxx +++ b/src/Canvas/canvas_mgr.hxx @@ -22,10 +22,9 @@ #include #include -class CanvasMgr: - public simgear::canvas::CanvasMgr +class CanvasMgr : public simgear::canvas::CanvasMgr { - public: +public: CanvasMgr(); virtual void init(); @@ -43,7 +42,8 @@ class CanvasMgr: unsigned int getCanvasTexId(const simgear::canvas::CanvasPtr& canvas) const; static const char* subsystemName() { return "Canvas"; } - protected: + +protected: osg::observer_ptr _gui_camera; SGPropertyChangeCallback _cb_model_reinit; diff --git a/src/Canvas/gui_mgr.hxx b/src/Canvas/gui_mgr.hxx index 30ba7c9c7..5c78950af 100644 --- a/src/Canvas/gui_mgr.hxx +++ b/src/Canvas/gui_mgr.hxx @@ -34,10 +34,9 @@ namespace osgGA } class GUIEventHandler; -class GUIMgr: - public SGSubsystem +class GUIMgr : public SGSubsystem { - public: +public: GUIMgr(); simgear::canvas::WindowPtr createWindow(const std::string& name = ""); @@ -68,8 +67,7 @@ class GUIMgr: */ void ungrabPointer(const simgear::canvas::WindowPtr& window); - protected: - +protected: simgear::canvas::GroupPtr _desktop; osg::ref_ptr _event_handler; diff --git a/src/Cockpit/NavDisplay.hxx b/src/Cockpit/NavDisplay.hxx index efa6fad2b..6bf73e72c 100644 --- a/src/Cockpit/NavDisplay.hxx +++ b/src/Cockpit/NavDisplay.hxx @@ -69,29 +69,30 @@ public: { _cachedItemsValid = false; } - + double textureSize() const { return _textureSize; } - + void forceUpdate() { _forceUpdate = true; } - + bool anyRuleForType(const std::string& type) const; bool isPositionedShown(FGPositioned* pos); + protected: std::string _name; int _num; double _time; double _updateInterval; bool _forceUpdate; - + SGPropertyNode_ptr _serviceable_node; SGPropertyNode_ptr _Instrument; SGPropertyNode_ptr _radar_mode_control_node; SGPropertyNode_ptr _user_heading_node; SGPropertyNode_ptr _testModeNode; SGPropertyNode_ptr _userLatNode, _userLonNode, _userPositionEnable; - + FGODGauge *_odg; // Convenience function for creating a property node with a @@ -102,13 +103,13 @@ protected: private: friend class SymbolRule; friend class SymbolDef; - + void addRule(SymbolRule*); - + void addSymbolsToScene(); void addSymbolToScene(SymbolInstance* sym); void limitDisplayedSymbols(); - + void findItems(); void isPositionedShownInner(FGPositioned* pos, SymbolRuleVector& rules); void foundPositionedItem(FGPositioned* pos); @@ -120,59 +121,58 @@ private: FGNavRecord* processNavRadio(const SGPropertyNode_ptr& radio); void processAI(); void computeAIStates(const SGPropertyNode* ai, string_set& states); - + void computeCustomSymbolStates(const SGPropertyNode* sym, string_set& states); void processCustomSymbols(); - + void findRules(const std::string& type, const string_set& states, SymbolRuleVector& rules); - + SymbolInstance* addSymbolInstance(const osg::Vec2& proj, double heading, SymbolDef* def, SGPropertyNode* vars); void addLine(osg::Vec2 a, osg::Vec2 b, const osg::Vec4& color); osg::Vec2 projectBearingRange(double bearingDeg, double rangeNm) const; osg::Vec2 projectGeod(const SGGeod& geod) const; bool isProjectedClipped(const osg::Vec2& projected) const; void updateFont(); - + void addTestSymbol(const std::string& type, const std::string& states, const SGGeod& pos, double heading, SGPropertyNode* vars); void addTestSymbols(); - + std::string _texture_path; unsigned int _textureSize; float _scale; // factor to convert nm to display units float _view_heading; - + SGPropertyNode_ptr _Radar_controls; - SGPropertyNode_ptr _font_node; SGPropertyNode_ptr _ai_enabled_node; SGPropertyNode_ptr _navRadio1Node; SGPropertyNode_ptr _navRadio2Node; SGPropertyNode_ptr _xCenterNode, _yCenterNode; SGPropertyNode_ptr _viewHeadingNode; - + osg::ref_ptr _symbolTexture; osg::ref_ptr _radarGeode; osg::ref_ptr _textGeode; - + osg::Geometry *_geom; - + osg::DrawArrays* _symbolPrimSet; osg::Vec2Array *_vertices; osg::Vec2Array *_texCoords; osg::Vec4Array* _quadColors; - + osg::Geometry* _lineGeometry; osg::DrawArrays* _linePrimSet; osg::Vec2Array* _lineVertices; osg::Vec4Array* _lineColors; - - + + osg::Matrixf _centerTrans; osg::Matrixf _projectMat; - + osg::ref_ptr _font; osg::Vec4 _font_color; float _font_size; @@ -182,24 +182,24 @@ private: SGGeod _pos; double _rangeNm; SGPropertyNode_ptr _rangeNode; - + SymbolDefVector _definitions; SymbolRuleVector _rules; FGNavRecord* _nav1Station; FGNavRecord* _nav2Station; std::vector _symbols; std::set _routeSources; - + bool _cachedItemsValid; SGVec3d _cachedPos; FGPositionedList _itemsInRange; SGPropertyNode_ptr _excessDataNode; int _maxSymbols; SGPropertyNode_ptr _customSymbols; - + class CacheListener; std::unique_ptr _cacheListener; - + class ForceUpdateListener; std::unique_ptr _forceUpdateListener; }; diff --git a/src/Cockpit/agradar.hxx b/src/Cockpit/agradar.hxx index dda152e0b..a95812a4c 100644 --- a/src/Cockpit/agradar.hxx +++ b/src/Cockpit/agradar.hxx @@ -1,7 +1,7 @@ // Air Ground Radar // // Written by Vivian MEAZZA, started Feb 2008. -// +// // // Copyright (C) 2008 Vivain MEAZZA - vivian.meazza@lineone.net // @@ -30,9 +30,9 @@ #include "wxradar.hxx" -class agRadar : public wxRadarBg{ +class agRadar : public wxRadarBg +{ public: - agRadar ( SGPropertyNode *node ); agRadar (); virtual ~agRadar (); diff --git a/src/Cockpit/cockpitDisplayManager.hxx b/src/Cockpit/cockpitDisplayManager.hxx index 53febaff9..fe59b7007 100644 --- a/src/Cockpit/cockpitDisplayManager.hxx +++ b/src/Cockpit/cockpitDisplayManager.hxx @@ -29,23 +29,22 @@ class SGPropertyNode; namespace flightgear { - + /** * Manage aircraft displays. */ class CockpitDisplayManager : public SGSubsystemGroup { public: - CockpitDisplayManager (); virtual ~CockpitDisplayManager (); - + virtual void init(); virtual InitStatus incrementalInit(); private: bool build (SGPropertyNode* config_props); - + std::vector _displays; }; diff --git a/src/Cockpit/groundradar.hxx b/src/Cockpit/groundradar.hxx index ec439c273..a69f58a63 100644 --- a/src/Cockpit/groundradar.hxx +++ b/src/Cockpit/groundradar.hxx @@ -36,7 +36,9 @@ class FGPavement; // Built-in layer for the atc radar. //////////////////////////////////////////////////////////////////////// -class GroundRadar : public SGSubsystem, public SGPropertyChangeListener, private FGODGauge +class GroundRadar : public SGSubsystem, + public SGPropertyChangeListener, + private FGODGauge { public: static const int TextureHalfSize = 256; @@ -45,12 +47,13 @@ public: void updateTexture(); virtual void valueChanged(SGPropertyNode*); virtual void update (double dt); + protected: void createTexture(const char* texture_name); - + void addRunwayVertices(const FGRunwayBase* aRunway, double aTowerLat, double aTowerLon, double aScale, osg::Vec3Array* aVertices); osg::Geometry *addPavementGeometry(const FGPavement* aPavement, double aTowerLat, double aTowerLon, double aScale); - + osg::ref_ptr _geode; SGPropertyNode_ptr _airport_node; SGPropertyNode_ptr _range_node; diff --git a/src/Cockpit/wxradar.hxx b/src/Cockpit/wxradar.hxx index 8aba4c2cb..086ecb51c 100644 --- a/src/Cockpit/wxradar.hxx +++ b/src/Cockpit/wxradar.hxx @@ -36,16 +36,17 @@ class FGODGauge; -class wxRadarBg : public SGSubsystem, public SGPropertyChangeListener { +class wxRadarBg : public SGSubsystem, + public SGPropertyChangeListener +{ public: - wxRadarBg(SGPropertyNode *node); wxRadarBg(); virtual ~wxRadarBg(); virtual void init(); virtual void shutdown(); - + virtual void update(double dt); virtual void valueChanged(SGPropertyNode *); @@ -75,7 +76,7 @@ protected: double elevation; double bumpiness; double elapsed_time; - }ground_echo; + } ground_echo; typedef std::vector ground_echo_vector_type; typedef ground_echo_vector_type::iterator ground_echo_vector_iterator; @@ -200,5 +201,4 @@ SGPropertyNode *wxRadarBg::getInstrumentNode(const char *name, const char *value return result; } - #endif // _INST_WXRADAR_HXX diff --git a/src/Environment/environment_ctrl.hxx b/src/Environment/environment_ctrl.hxx index fd734e8bb..f17dbd90b 100644 --- a/src/Environment/environment_ctrl.hxx +++ b/src/Environment/environment_ctrl.hxx @@ -25,10 +25,13 @@ #include namespace Environment { - class LayerInterpolateController : public SGSubsystem { - public: - static LayerInterpolateController * createInstance( SGPropertyNode_ptr rootNode ); - }; + +class LayerInterpolateController : public SGSubsystem +{ +public: + static LayerInterpolateController * createInstance( SGPropertyNode_ptr rootNode ); +}; + } // namespace #endif // _ENVIRONMENT_CTRL_HXX diff --git a/src/Environment/environment_mgr.hxx b/src/Environment/environment_mgr.hxx index 08e0b7fe2..5948112a5 100644 --- a/src/Environment/environment_mgr.hxx +++ b/src/Environment/environment_mgr.hxx @@ -38,62 +38,60 @@ class SGSky; */ class FGEnvironmentMgr : public SGSubsystemGroup { - public: + enum { + MAX_CLOUD_LAYERS = 5 + }; - enum { - MAX_CLOUD_LAYERS = 5 - }; + FGEnvironmentMgr (); + virtual ~FGEnvironmentMgr (); - FGEnvironmentMgr (); - virtual ~FGEnvironmentMgr (); + virtual InitStatus incrementalInit (); + virtual void reinit (); + virtual void shutdown (); + virtual void bind (); + virtual void unbind (); + virtual void update (double dt); - virtual InitStatus incrementalInit (); - virtual void reinit (); - virtual void shutdown (); - virtual void bind (); - virtual void unbind (); - virtual void update (double dt); + /** + * Get the environment information for the plane's current position. + */ + virtual FGEnvironment getEnvironment () const; - /** - * Get the environment information for the plane's current position. - */ - virtual FGEnvironment getEnvironment () const; + /** + * Get the environment information for another location. + */ + virtual FGEnvironment getEnvironment (double lat, double lon, + double alt) const; + virtual FGEnvironment getEnvironment(const SGGeod& aPos) const; - /** - * Get the environment information for another location. - */ - virtual FGEnvironment getEnvironment (double lat, double lon, - double alt) const; - - virtual FGEnvironment getEnvironment(const SGGeod& aPos) const; private: - void updateClosestAirport(); - - double get_cloud_layer_span_m (int index) const; - void set_cloud_layer_span_m (int index, double span_m); - double get_cloud_layer_elevation_ft (int index) const; - void set_cloud_layer_elevation_ft (int index, double elevation_ft); - double get_cloud_layer_thickness_ft (int index) const; - void set_cloud_layer_thickness_ft (int index, double thickness_ft); - double get_cloud_layer_transition_ft (int index) const; - void set_cloud_layer_transition_ft (int index, double transition_ft); - const char * get_cloud_layer_coverage (int index) const; - void set_cloud_layer_coverage (int index, const char * coverage); - int get_cloud_layer_coverage_type (int index) const; - void set_cloud_layer_coverage_type (int index, int type ); - double get_cloud_layer_visibility_m (int index) const; - void set_cloud_layer_visibility_m (int index, double visibility_m); - double get_cloud_layer_maxalpha (int index ) const; - void set_cloud_layer_maxalpha (int index, double maxalpha); + void updateClosestAirport(); - FGEnvironment * _environment; // always the same, for now - FGClouds *fgClouds; - bool _cloudLayersDirty; - simgear::TiedPropertyList _tiedProperties; - SGPropertyChangeListener * _3dCloudsEnableListener; - SGSky* _sky; + double get_cloud_layer_span_m (int index) const; + void set_cloud_layer_span_m (int index, double span_m); + double get_cloud_layer_elevation_ft (int index) const; + void set_cloud_layer_elevation_ft (int index, double elevation_ft); + double get_cloud_layer_thickness_ft (int index) const; + void set_cloud_layer_thickness_ft (int index, double thickness_ft); + double get_cloud_layer_transition_ft (int index) const; + void set_cloud_layer_transition_ft (int index, double transition_ft); + const char * get_cloud_layer_coverage (int index) const; + void set_cloud_layer_coverage (int index, const char * coverage); + int get_cloud_layer_coverage_type (int index) const; + void set_cloud_layer_coverage_type (int index, int type ); + double get_cloud_layer_visibility_m (int index) const; + void set_cloud_layer_visibility_m (int index, double visibility_m); + double get_cloud_layer_maxalpha (int index ) const; + void set_cloud_layer_maxalpha (int index, double maxalpha); + + FGEnvironment * _environment; // always the same, for now + FGClouds *fgClouds; + bool _cloudLayersDirty; + simgear::TiedPropertyList _tiedProperties; + SGPropertyChangeListener * _3dCloudsEnableListener; + SGSky* _sky; }; #endif // _ENVIRONMENT_MGR_HXX diff --git a/src/Environment/ephemeris.hxx b/src/Environment/ephemeris.hxx index 8250b7a8c..0e51b0007 100644 --- a/src/Environment/ephemeris.hxx +++ b/src/Environment/ephemeris.hxx @@ -36,25 +36,24 @@ class SGPropertyNode; class Ephemeris : public SGSubsystem { public: + Ephemeris(); + ~Ephemeris(); - Ephemeris(); - ~Ephemeris(); - - virtual void bind(); - virtual void unbind(); - virtual void update(double dt); - virtual void init(); + virtual void bind(); + virtual void unbind(); + virtual void update(double dt); + virtual void init(); virtual void shutdown(); virtual void postinit(); static const char* subsystemName() { return "ephemeris"; } SGEphemeris* data(); + private: - std::unique_ptr _impl; - SGPropertyNode_ptr _latProp; - SGPropertyNode_ptr _moonlight; + std::unique_ptr _impl; + SGPropertyNode_ptr _latProp; + SGPropertyNode_ptr _moonlight; }; #endif // of FG_ENVIRONMENT_EPHEMERIS_HXX - diff --git a/src/Environment/magvarmanager.hxx b/src/Environment/magvarmanager.hxx index b79ca5db3..202c00d97 100644 --- a/src/Environment/magvarmanager.hxx +++ b/src/Environment/magvarmanager.hxx @@ -33,17 +33,17 @@ class FGMagVarManager : public SGSubsystem public: FGMagVarManager(); virtual ~FGMagVarManager(); - + virtual void init(); virtual void bind(); virtual void unbind(); - + virtual void update(double dt); - + private: - std::unique_ptr _magVar; - - SGPropertyNode_ptr _magVarNode, _magDipNode; + std::unique_ptr _magVar; + + SGPropertyNode_ptr _magVarNode, _magDipNode; }; #endif // of FG_MAGVAR_MANAGER diff --git a/src/Environment/realwx_ctrl.cxx b/src/Environment/realwx_ctrl.cxx index 783be9be8..c1e0f44e6 100644 --- a/src/Environment/realwx_ctrl.cxx +++ b/src/Environment/realwx_ctrl.cxx @@ -171,6 +171,7 @@ public: typedef std::vector MetarPropertiesList; MetarPropertiesList::iterator findMetarAtPath(const string &propPath); + protected: void bind(); void unbind(); @@ -189,7 +190,6 @@ protected: simgear::TiedPropertyList _tiedProperties; MetarPropertiesList _metarProperties; MetarRequester* _requester; - }; static bool commandRequestMetar(const SGPropertyNode * arg, SGPropertyNode * root) @@ -400,7 +400,8 @@ void BasicRealWxController::checkNearbyMetar() /* -------------------------------------------------------------------------------- */ -class NoaaMetarRealWxController : public BasicRealWxController, MetarRequester { +class NoaaMetarRealWxController : public BasicRealWxController, MetarRequester +{ public: NoaaMetarRealWxController( SGPropertyNode_ptr rootNode ); @@ -410,6 +411,7 @@ public: virtual ~NoaaMetarRealWxController() { } + private: std::string noaa_base_url; }; diff --git a/src/Environment/realwx_ctrl.hxx b/src/Environment/realwx_ctrl.hxx index ebe3255bd..943910b89 100644 --- a/src/Environment/realwx_ctrl.hxx +++ b/src/Environment/realwx_ctrl.hxx @@ -25,13 +25,15 @@ #include #include + namespace Environment { + class RealWxController : public SGSubsystem { public: virtual ~RealWxController(); - - static RealWxController * createInstance( SGPropertyNode_ptr rootNode ); + + static RealWxController * createInstance( SGPropertyNode_ptr rootNode ); }; } // namespace diff --git a/src/Environment/ridge_lift.hxx b/src/Environment/ridge_lift.hxx index 642683c06..26dc5e309 100644 --- a/src/Environment/ridge_lift.hxx +++ b/src/Environment/ridge_lift.hxx @@ -4,7 +4,7 @@ // Copyright (C) 2009 Patrice Poly - p.polypa@gmail.com // // -// Entirely based on the paper : +// Entirely based on the paper : // http://carrier.csi.cam.ac.uk/forsterlewis/soaring/sim/fsx/dev/sim_probe/sim_probe_paper.html // by Ian Forster-Lewis, University of Cambridge, 26th December 2007 // @@ -38,50 +38,50 @@ using std::string; #include -class FGRidgeLift : public SGSubsystem { +class FGRidgeLift : public SGSubsystem +{ public: + FGRidgeLift(); + ~FGRidgeLift(); - FGRidgeLift(); - ~FGRidgeLift(); - - virtual void bind(); - virtual void unbind(); - virtual void update(double dt); - virtual void init(); + virtual void bind(); + virtual void unbind(); + virtual void update(double dt); + virtual void init(); - inline double getStrength() const { return strength; }; + inline double getStrength() const { return strength; }; - inline double get_probe_elev_m( int index ) const { return probe_elev_m[index]; }; - inline double get_probe_lat_deg( int index ) const { return probe_lat_deg[index]; }; - inline double get_probe_lon_deg( int index ) const { return probe_lon_deg[index]; }; - inline double get_slope( int index ) const { return slope[index]; }; + inline double get_probe_elev_m( int index ) const { return probe_elev_m[index]; }; + inline double get_probe_lat_deg( int index ) const { return probe_lat_deg[index]; }; + inline double get_probe_lon_deg( int index ) const { return probe_lon_deg[index]; }; + inline double get_slope( int index ) const { return slope[index]; }; private: - static const double dist_probe_m[5]; + static const double dist_probe_m[5]; - double strength; - double timer; + double strength; + double timer; - double probe_lat_deg[5]; - double probe_lon_deg[5]; - double probe_elev_m[5]; + double probe_lat_deg[5]; + double probe_lon_deg[5]; + double probe_elev_m[5]; - double slope[4]; + double slope[4]; - double lift_factor; + double lift_factor; - SGPropertyNode_ptr _enabled_node; - SGPropertyNode_ptr _ridge_lift_fps_node; + SGPropertyNode_ptr _enabled_node; + SGPropertyNode_ptr _ridge_lift_fps_node; - SGPropertyNode_ptr _surface_wind_from_deg_node; - SGPropertyNode_ptr _surface_wind_speed_node; + SGPropertyNode_ptr _surface_wind_from_deg_node; + SGPropertyNode_ptr _surface_wind_speed_node; - SGPropertyNode_ptr _user_altitude_agl_ft_node; - SGPropertyNode_ptr _user_longitude_node; - SGPropertyNode_ptr _user_latitude_node; - SGPropertyNode_ptr _ground_elev_node; + SGPropertyNode_ptr _user_altitude_agl_ft_node; + SGPropertyNode_ptr _user_longitude_node; + SGPropertyNode_ptr _user_latitude_node; + SGPropertyNode_ptr _ground_elev_node; - simgear::TiedPropertyList _tiedProperties; + simgear::TiedPropertyList _tiedProperties; }; #endif // _FG_RidgeLift_HXX diff --git a/src/Environment/terrainsampler.cxx b/src/Environment/terrainsampler.cxx index caf2548a0..f298b25df 100644 --- a/src/Environment/terrainsampler.cxx +++ b/src/Environment/terrainsampler.cxx @@ -1,7 +1,7 @@ // terrainsampler.cxx -- // // Written by Torsten Dreyer, started July 2010 -// Based on local weather implementation in nasal from +// Based on local weather implementation in nasal from // Thorsten Renk // // Copyright (C) 2010 Curtis Olson @@ -40,10 +40,12 @@ using std::string; #include namespace Environment { + /** * @brief Class for presampling the terrain roughness */ -class AreaSampler : public SGSubsystem { +class AreaSampler : public SGSubsystem +{ public: AreaSampler( SGPropertyNode_ptr rootNode ); virtual ~AreaSampler(); @@ -54,13 +56,13 @@ public: void reinit(); int getElevationHistogramStep() const { return _elevationHistogramStep; } - void setElevationHistograpStep( int value ) { + void setElevationHistograpStep( int value ) { _elevationHistogramStep = value > 0 ? value : 500; _elevationHistogramCount = _elevationHistogramMax / _elevationHistogramStep; } int getElevationHistogramMax() const { return _elevationHistogramMax; } - void setElevationHistograpMax( int value ) { + void setElevationHistograpMax( int value ) { _elevationHistogramMax = value > 0 ? value : 10000; _elevationHistogramCount = _elevationHistogramMax / _elevationHistogramStep; } @@ -192,9 +194,9 @@ void AreaSampler::update( double dt ) // get the aircraft's position if requested if( _useAircraftPosition && _speed_kt < 0.5 ) { - _inputPosition = SGGeod::fromDegM( - _positionLongitudeNode->getDoubleValue(), - _positionLatitudeNode->getDoubleValue(), + _inputPosition = SGGeod::fromDegM( + _positionLongitudeNode->getDoubleValue(), + _positionLatitudeNode->getDoubleValue(), SG_MAX_ELEVATION_M ); } @@ -231,11 +233,11 @@ void AreaSampler::update( double dt ) SGGeod probe = SGGeod::fromGeoc(center.advanceRadM( course, distance )); double elevation_m = 0.0; - if (scenery->get_elevation_m( probe, elevation_m, NULL )) + if (scenery->get_elevation_m( probe, elevation_m, NULL )) _elevations.push_front(elevation_m *= SG_METER_TO_FEET); - + if( _elevations.size() >= (deque::size_type)_max_samples ) { - // sampling complete? + // sampling complete? analyse(); _outputPosition = _inputPosition; _signalNode->setBoolValue( true ); @@ -249,7 +251,7 @@ void AreaSampler::analyse() double sum; vector histogram(_elevationHistogramCount,0); - + for( deque::size_type i = 0; i < _elevations.size(); i++ ) { int idx = SGMisc::clip( (int)(_elevations[i]/_elevationHistogramStep), 0, histogram.size()-1 ); histogram[idx]++; @@ -275,7 +277,7 @@ void AreaSampler::analyse() } } - _altMean = 0.0; + _altMean = 0.0; for( vector::size_type i = 0; i < histogram.size(); i++ ) { _altMean += histogram[i] * i; } @@ -319,7 +321,7 @@ class TerrainSamplerImplementation : public TerrainSampler public: TerrainSamplerImplementation ( SGPropertyNode_ptr rootNode ); virtual ~TerrainSamplerImplementation (); - + virtual void init (); virtual InitStatus incrementalInit (); virtual void postinit(); @@ -327,11 +329,12 @@ public: virtual void bind(); virtual void unbind(); virtual void update (double delta_time_sec); + private: inline string areaSubsystemName( unsigned i ) { - ostringstream name; - name << "area" << i; - return name.str(); + ostringstream name; + name << "area" << i; + return name.str(); } SGPropertyNode_ptr _rootNode; @@ -348,7 +351,7 @@ TerrainSamplerImplementation::TerrainSamplerImplementation( SGPropertyNode_ptr r TerrainSamplerImplementation::~TerrainSamplerImplementation() { } - + SGSubsystem::InitStatus TerrainSamplerImplementation::incrementalInit() { init(); @@ -358,7 +361,7 @@ SGSubsystem::InitStatus TerrainSamplerImplementation::incrementalInit() void TerrainSamplerImplementation::init() { PropertyList areaNodes = _rootNode->getChildren( "area" ); - + for( PropertyList::size_type i = 0; i < areaNodes.size(); i++ ) set_subsystem( areaSubsystemName(i), new AreaSampler( areaNodes[i] ) ); @@ -380,7 +383,7 @@ void TerrainSamplerImplementation::reinit() subsys->unbind(); delete subsys; } - + init(); } diff --git a/src/Environment/terrainsampler.hxx b/src/Environment/terrainsampler.hxx index e56178392..39bd1112a 100644 --- a/src/Environment/terrainsampler.hxx +++ b/src/Environment/terrainsampler.hxx @@ -1,7 +1,7 @@ -// terrainsampler.hxx -- +// terrainsampler.hxx -- // // Written by Torsten Dreyer, started July 2010 -// Based on local weather implementation in nasal from +// Based on local weather implementation in nasal from // Thorsten Renk // // Copyright (C) 2010 Curtis Olson @@ -26,11 +26,12 @@ #include namespace Environment { + class TerrainSampler : public SGSubsystemGroup { public: TerrainSampler() : SGSubsystemGroup("TerrainSampler") {} - static TerrainSampler * createInstance( SGPropertyNode_ptr rootNode ); + static TerrainSampler * createInstance( SGPropertyNode_ptr rootNode ); }; } // namespace diff --git a/src/FDM/ExternalNet/ExternalNet.hxx b/src/FDM/ExternalNet/ExternalNet.hxx index 899650b41..c5f3cf83d 100644 --- a/src/FDM/ExternalNet/ExternalNet.hxx +++ b/src/FDM/ExternalNet/ExternalNet.hxx @@ -31,10 +31,9 @@ #include -class FGExternalNet: public FGInterface { - +class FGExternalNet : public FGInterface +{ private: - int data_in_port; int data_out_port; int cmd_port; @@ -49,7 +48,6 @@ private: FGNetFDM fdm; public: - // Constructor FGExternalNet( double dt, std::string host, int dop, int dip, int cp ); @@ -61,8 +59,6 @@ public: // update the fdm void update( double dt ); - }; - #endif // _EXTERNAL_NET_HXX diff --git a/src/FDM/ExternalPipe/ExternalPipe.hxx b/src/FDM/ExternalPipe/ExternalPipe.hxx index 1881bffba..934ed07f6 100644 --- a/src/FDM/ExternalPipe/ExternalPipe.hxx +++ b/src/FDM/ExternalPipe/ExternalPipe.hxx @@ -32,10 +32,9 @@ #include -class FGExternalPipe: public FGInterface { - +class FGExternalPipe : public FGInterface +{ private: - bool valid; std::string fifo_name_1; @@ -63,8 +62,8 @@ private: void update_property( double dt ); void process_set_command( const string_list &tokens ); -public: +public: // Constructor FGExternalPipe( double dt, std::string fifo_name, std::string protocol ); @@ -76,8 +75,6 @@ public: // update the fdm void update( double dt ); - }; - #endif // _EXTERNAL_PIPE_HXX diff --git a/src/FDM/JSBSim/JSBSim.hxx b/src/FDM/JSBSim/JSBSim.hxx index 81dabbda0..cb6ddb084 100644 --- a/src/FDM/JSBSim/JSBSim.hxx +++ b/src/FDM/JSBSim/JSBSim.hxx @@ -98,11 +98,12 @@ CLASS DOCUMENTATION CLASS DECLARATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -class FGJSBsim: public FGInterface { - +class FGJSBsim : public FGInterface +{ public: /// Constructor FGJSBsim( double dt ); + /// Destructor ~FGJSBsim(); @@ -221,6 +222,7 @@ public: double get_agl_ft(double t, const JSBSim::FGColumnVector3& loc, double alt_off, double contact[3], double normal[3], double vel[3], double angularVel[3]); + private: JSBSim::FGFDMExec *fdmex; JSBSim::FGInitialCondition *fgic; @@ -274,7 +276,7 @@ private: SGPropertyNode_ptr ab_brake_engaged; SGPropertyNode_ptr ab_brake_left_pct; SGPropertyNode_ptr ab_brake_right_pct; - + SGPropertyNode_ptr gear_pos_pct; SGPropertyNode_ptr wing_fold_pos_pct; SGPropertyNode_ptr tailhook_pos_pct; @@ -324,5 +326,4 @@ private: void update_external_forces(double t_off); }; - #endif // _JSBSIM_HXX diff --git a/src/FDM/LaRCsim/LaRCsim.hxx b/src/FDM/LaRCsim/LaRCsim.hxx index c7db857d5..b4708f860 100644 --- a/src/FDM/LaRCsim/LaRCsim.hxx +++ b/src/FDM/LaRCsim/LaRCsim.hxx @@ -32,10 +32,9 @@ #include "IO360.hxx" #include "LaRCsimIC.hxx" -class FGLaRCsim: public FGInterface { - +class FGLaRCsim : public FGInterface +{ private: - FGNewEngine eng; LaRCsimIC* lsic; void set_ls(void); @@ -44,47 +43,46 @@ private: SGPropertyNode_ptr aero; SGPropertyNode_ptr uiuc_type; double mass, i_xx, i_yy, i_zz, i_xz; - -public: +public: FGLaRCsim( double dt ); ~FGLaRCsim(void); - + // copy FDM state to LaRCsim structures bool copy_to_LaRCsim(); // copy FDM state from LaRCsim structures bool copy_from_LaRCsim(); - // reset flight params to a specific position + // reset flight params to a specific position void init(); // update position based on inputs, positions, velocities, etc. void update( double dt ); - + // Positions void set_Latitude(double lat); //geocentric - void set_Longitude(double lon); + void set_Longitude(double lon); void set_Altitude(double alt); // triggers re-calc of AGL altitude void set_AltitudeAGL(double altagl); // and vice-versa - + // Speeds -- setting any of these will trigger a re-calc of the rest void set_V_calibrated_kts(double vc); void set_Mach_number(double mach); void set_Velocities_Local( double north, double east, double down ); void set_Velocities_Body( double u, double v, double w); - - // Euler angles + + // Euler angles void set_Euler_Angles( double phi, double theta, double psi ); - + // Flight Path void set_Climb_Rate( double roc); void set_Gamma_vert_rad( double gamma); - + // Earth void set_Static_pressure(double p); - void set_Static_temperature(double T); - void set_Density(double rho); + void set_Static_temperature(double T); + void set_Density(double rho); // Inertias double get_Mass() const { return mass; } @@ -103,7 +101,4 @@ public: } }; - #endif // _LARCSIM_HXX - - diff --git a/src/FDM/NullFDM.hxx b/src/FDM/NullFDM.hxx index 3741a983a..c966e2e7c 100644 --- a/src/FDM/NullFDM.hxx +++ b/src/FDM/NullFDM.hxx @@ -29,18 +29,17 @@ #include "flight.hxx" -class FGNullFDM: public FGInterface { - +class FGNullFDM : public FGInterface +{ public: FGNullFDM( double dt ); ~FGNullFDM(); - // reset flight params to a specific position + // reset flight params to a specific position void init(); // update position based on inputs, positions, velocities, etc. void update( double dt ); }; - #endif // _NULLFDM_HXX diff --git a/src/FDM/SP/ACMS.hxx b/src/FDM/SP/ACMS.hxx index e34c9795c..23d43c178 100644 --- a/src/FDM/SP/ACMS.hxx +++ b/src/FDM/SP/ACMS.hxx @@ -28,25 +28,23 @@ #include -class FGACMS: public FGInterface +class FGACMS : public FGInterface { public: FGACMS( double dt ); ~FGACMS(); - // reset flight params to a specific position + // reset flight params to a specific position void init(); // update position based on properties void update( double dt ); private: - SGPropertyNode_ptr _alt, _speed, _climb_rate; SGPropertyNode_ptr _pitch, _roll, _heading; SGPropertyNode_ptr _acc_lat, _acc_lon, _acc_down; SGPropertyNode_ptr _temp, _wow; }; - #endif // _ACMS_HXX diff --git a/src/FDM/SP/ADA.hxx b/src/FDM/SP/ADA.hxx index 532cfb7f3..a87a1094f 100644 --- a/src/FDM/SP/ADA.hxx +++ b/src/FDM/SP/ADA.hxx @@ -26,10 +26,9 @@ class SGSocket; #include -class FGADA: public FGInterface { - +class FGADA : public FGInterface +{ private: - SGSocket *fdmsock; #if 0 // Auxilliary Flight Model parameters, basically for HUD @@ -71,17 +70,14 @@ private: bool copy_from_FGADA(); public: - FGADA( double dt ); ~FGADA(); - // reset flight params to a specific position + // reset flight params to a specific position void init(); // update position based on inputs, positions, velocities, etc. void update(double dt); - }; - #endif // _ADA_HXX diff --git a/src/FDM/SP/AISim.hpp b/src/FDM/SP/AISim.hpp index c154bb56b..168ea85b3 100644 --- a/src/FDM/SP/AISim.hpp +++ b/src/FDM/SP/AISim.hpp @@ -38,18 +38,18 @@ #else # include "simd.hxx" # include "simd4x4.hxx" -# define SG_METER_TO_FEET 3.2808399 -# define SG_FEET_TO_METER (1/SG_METER_TO_FEET) -# define SGD_DEGREES_TO_RADIANS 0.0174532925 -# define SGD_RADIANS_TO_DEGREES (1/SGD_DEGREES_TO_RADIANS) -# define SGD_PI 3.1415926535 +# define SG_METER_TO_FEET 3.2808399 +# define SG_FEET_TO_METER (1/SG_METER_TO_FEET) +# define SGD_DEGREES_TO_RADIANS 0.0174532925 +# define SGD_RADIANS_TO_DEGREES (1/SGD_DEGREES_TO_RADIANS) +# define SGD_PI 3.1415926535 #endif // #define SG_DEGREES_TO_RADIANS 0.0174532925f - // max. no. gears, maxi. no. engines -#define AISIM_MAX 4 -#define AISIM_G 32.174f +// max. no. gears, maxi. no. engines +#define AISIM_MAX 4 +#define AISIM_G 32.174f class FGAISim #ifdef ENABLE_SP_FDM @@ -75,7 +75,7 @@ public: FGAISim(double dt); ~FGAISim(); - // reset flight params to a specific location + // reset flight params to a specific location void init(); // update location based on properties @@ -104,7 +104,7 @@ public: xClmnT.ptr()[AILERON][ROLL] = Clda_n*f; xClmnT.ptr()[AILERON][YAW] = Cnda_n*f; } - inline void set_flaps_norm(float f) { + inline void set_flaps_norm(float f) { xCDYLT.ptr()[FLAPS][LIFT] = CLdf_n*f; xCDYLT.ptr()[FLAPS][DRAG] = CDdf_n*std::abs(f); xClmnT.ptr()[FLAPS][PITCH] = Cmdf_n*f; @@ -154,7 +154,7 @@ public: inline void set_beta_rad(float f) { xCDYLT.ptr()[BETA][DRAG] = CDb*std::abs(f); xCDYLT.ptr()[BETA][SIDE] = CYb*f; - xClmnT.ptr()[BETA][ROLL] = Clb*f; + xClmnT.ptr()[BETA][ROLL] = Clb*f; xClmnT.ptr()[BETA][YAW] = Cnb*f; AOA[BETA] = f; } @@ -171,33 +171,33 @@ private: simd4x4_t invert_inertia(simd4x4_t mtx); /* aircraft normalized controls */ - float th; /* throttle command */ - float br; /* brake command */ + float th; /* throttle command */ + float br; /* brake command */ /* aircraft state */ - simd4_t location_geod; /* lat, lon, altitude */ - simd4_t aXYZ; /* local body accelrations */ - simd4_t NEDdot; /* North, East, Down velocity */ - simd4_t vUVW; /* fwd, side, down velocity */ - simd4_t vUVWdot; /* fwd, side, down accel. */ - simd4_t vPQR; /* roll, pitch, yaw rate */ - simd4_t vPQRdot; /* roll, pitch, yaw accel. */ - simd4_t AOA; /* alpha, beta */ - simd4_t AOAdot; /* adot, bdot */ - simd4_t euler; /* phi, theta, psi */ - simd4_t euler_dot; /* change in phi, theta, psi */ - simd4_t wind_ned; /* wind north, east, down */ + simd4_t location_geod; /* lat, lon, altitude */ + simd4_t aXYZ; /* local body accelrations */ + simd4_t NEDdot; /* North, East, Down velocity */ + simd4_t vUVW; /* fwd, side, down velocity */ + simd4_t vUVWdot; /* fwd, side, down accel. */ + simd4_t vPQR; /* roll, pitch, yaw rate */ + simd4_t vPQRdot; /* roll, pitch, yaw accel. */ + simd4_t AOA; /* alpha, beta */ + simd4_t AOAdot; /* adot, bdot */ + simd4_t euler; /* phi, theta, psi */ + simd4_t euler_dot; /* change in phi, theta, psi */ + simd4_t wind_ned; /* wind north, east, down */ /* ---------------------------------------------------------------- */ - /* This should reduce the time spent in update() since controls */ - /* change less often than the update function runs which might */ - /* run 20 to 60 times (or more) per second */ + /* This should reduce the time spent in update() since controls */ + /* change less often than the update function runs which might */ + /* run 20 to 60 times (or more) per second */ /* cache */ - simd4_t vUVWaero; /* airmass relative to the body */ - simd4_t FT[AISIM_MAX]; /* thrust force */ - simd4_t FTM[AISIM_MAX]; /* thrust due to mach force */ - simd4_t MT[AISIM_MAX]; /* thrust moment */ + simd4_t vUVWaero; /* airmass relative to the body */ + simd4_t FT[AISIM_MAX]; /* thrust force */ + simd4_t FTM[AISIM_MAX]; /* thrust due to mach force */ + simd4_t MT[AISIM_MAX]; /* thrust moment */ simd4_t b_2U, cbar_2U; simd4_t inv_m; float velocity, mach; @@ -214,17 +214,17 @@ private: /* ---------------------------------------------------------------- */ /* aircraft static data */ int no_engines, no_gears; - simd4x4_t mI, mIinv; /* inertia matrix */ - simd4_t gear_pos[AISIM_MAX]; /* pos in structural frame */ - simd4_t cg; /* center of gravity */ - simd4_t I; /* inertia */ - float S, cbar, b; /* wing area, mean average chord, span */ - float m; /* mass */ + simd4x4_t mI, mIinv; /* inertia matrix */ + simd4_t gear_pos[AISIM_MAX]; /* pos in structural frame */ + simd4_t cg; /* center of gravity */ + simd4_t I; /* inertia */ + float S, cbar, b; /* wing area, mean average chord, span */ + float m; /* mass */ - /* static coefficients, *_n is for normalized surface deflection */ - float Cg_spring[AISIM_MAX]; /* gear spring coeffients */ - float Cg_damp[AISIM_MAX]; /* gear damping coefficients */ - float CTmax, CTu; /* thrust max, due to speed */ + /* static coefficients, *_n is for normalized surface deflection */ + float Cg_spring[AISIM_MAX]; /* gear spring coeffients */ + float Cg_damp[AISIM_MAX]; /* gear damping coefficients */ + float CTmax, CTu; /* thrust max, due to speed */ float CLmin, CLa, CLadot, CLq, CLdf_n; float CDmin, CDa, CDb, CDi, CDdf_n; float CYb, CYp, CYr, CYdr_n; diff --git a/src/FDM/SP/Balloon.h b/src/FDM/SP/Balloon.h index 5b132f420..ecac4bd57 100644 --- a/src/FDM/SP/Balloon.h +++ b/src/FDM/SP/Balloon.h @@ -1,6 +1,6 @@ /***************************************************************************** - Header: BalloonSimInterface.h + Header: BalloonSimInterface.h Author: Christian Mayer Date started: 07.10.99 @@ -25,11 +25,11 @@ FUNCTIONAL DESCRIPTION ------------------------------------------------------------------------------ -interface to the the hot air balloon simulator +interface to the hot air balloon simulator HISTORY ------------------------------------------------------------------------------ -07.10.1999 Christian Mayer Created +07.10.1999 Christian Mayer Created *****************************************************************************/ /****************************************************************************/ @@ -39,28 +39,27 @@ HISTORY #define BalloonSimInterface_H /****************************************************************************/ -/* INCLUDES */ +/* INCLUDES */ /****************************************************************************/ #include #include "BalloonSim.h" - + /****************************************************************************/ -/* DEFINES */ +/* DEFINES */ /****************************************************************************/ /****************************************************************************/ -/* DECLARATIONS */ +/* DECLARATIONS */ /****************************************************************************/ -class FGBalloonSim: public FGInterface { - +class FGBalloonSim : public FGInterface +{ balloon current_balloon; public: - FGBalloonSim( double dt ); ~FGBalloonSim(); @@ -70,17 +69,12 @@ public: // copy FDM state from BalloonSim structures bool copy_from_BalloonSim(); - // reset flight params to a specific position + // reset flight params to a specific position void init(); // update position based on inputs, positions, velocities, etc. void update( double dt ); }; - /****************************************************************************/ #endif /*BalloonSimInterface_H*/ - - - - diff --git a/src/FDM/SP/MagicCarpet.hxx b/src/FDM/SP/MagicCarpet.hxx index 8124c81ae..5b09a57f6 100644 --- a/src/FDM/SP/MagicCarpet.hxx +++ b/src/FDM/SP/MagicCarpet.hxx @@ -28,19 +28,17 @@ #include -class FGMagicCarpet: public FGInterface { - +class FGMagicCarpet : public FGInterface +{ public: FGMagicCarpet( double dt ); ~FGMagicCarpet(); - // reset flight params to a specific position + // reset flight params to a specific position void init(); // update position based on inputs, positions, velocities, etc. void update( double dt ); - }; - #endif // _MAGICCARPET_HXX diff --git a/src/FDM/UFO.hxx b/src/FDM/UFO.hxx index d22832f70..dd9569eb8 100644 --- a/src/FDM/UFO.hxx +++ b/src/FDM/UFO.hxx @@ -27,15 +27,17 @@ #include "flight.hxx" -class FGUFO: public FGInterface { +class FGUFO : public FGInterface +{ private: - - class lowpass { + class lowpass + { private: static double _dt; double _coeff; double _last; bool _initialized; + public: lowpass(double coeff) : _coeff(coeff), _initialized(false) {} static inline void set_delta(double dt) { _dt = dt; } @@ -67,8 +69,6 @@ public: // update position based on inputs, positions, velocities, etc. void update( double dt ); - }; - #endif // _UFO_HXX diff --git a/src/FDM/YASim/YASim.hxx b/src/FDM/YASim/YASim.hxx index 5739032af..a41aabbc9 100644 --- a/src/FDM/YASim/YASim.hxx +++ b/src/FDM/YASim/YASim.hxx @@ -6,7 +6,8 @@ namespace yasim { class FGFDM; }; -class YASim : public FGInterface { +class YASim : public FGInterface +{ public: YASim(double dt); ~YASim(); @@ -19,8 +20,7 @@ public: // Run an iteration virtual void update(double dt); - private: - +private: void report(); void copyFromYASim(); void copyToYASim(bool copyState); diff --git a/src/FDM/fdm_shell.hxx b/src/FDM/fdm_shell.hxx index e4b32ab5a..74d120296 100644 --- a/src/FDM/fdm_shell.hxx +++ b/src/FDM/fdm_shell.hxx @@ -41,36 +41,36 @@ class FGAIManager; class FDMShell : public SGSubsystem { public: - FDMShell(); - ~FDMShell() override; - - void init() override; - void shutdown() override; - void reinit() override; - void postinit() override; - - void bind() override; - void unbind() override; - - void update(double dt) override; + FDMShell(); + ~FDMShell() override; + + void init() override; + void shutdown() override; + void reinit() override; + void postinit() override; + + void bind() override; + void unbind() override; + + void update(double dt) override; FGInterface* getInterface() const; static const char* subsystemName() { return "flight"; } -private: - void createImplementation(); - - TankPropertiesList _tankProperties; - SGSharedPtr _impl; - SGPropertyNode_ptr _props; // root property tree for this FDM instance - bool _dataLogging; - - SGPropertyNode_ptr _wind_north, _wind_east,_wind_down; - SGPropertyNode_ptr _control_fdm_atmo,_temp_degc,_pressure_inhg; - SGPropertyNode_ptr _density_slugft, _data_logging, _replay_master; - - SGPropertyNode_ptr _initialFdmProperties; +private: + void createImplementation(); + + TankPropertiesList _tankProperties; + SGSharedPtr _impl; + SGPropertyNode_ptr _props; // root property tree for this FDM instance + bool _dataLogging; + + SGPropertyNode_ptr _wind_north, _wind_east,_wind_down; + SGPropertyNode_ptr _control_fdm_atmo,_temp_degc,_pressure_inhg; + SGPropertyNode_ptr _density_slugft, _data_logging, _replay_master; + + SGPropertyNode_ptr _initialFdmProperties; SGSharedPtr _ai_mgr; SGPropertyNode_ptr _max_radius_nm; diff --git a/src/FDM/flight.hxx b/src/FDM/flight.hxx index 348e8098b..7f45207a0 100644 --- a/src/FDM/flight.hxx +++ b/src/FDM/flight.hxx @@ -99,35 +99,37 @@ class FGAIAircraft; * life/visibility, computes the track if the * position has changed. */ -class TrackComputer { +class TrackComputer +{ public: - inline TrackComputer( double & track, double & path, const SGGeod & position ) : - _track( track ), - _path( path ), - _position( position ), - _prevPosition( position ) { - } - - inline ~TrackComputer() { - if( _prevPosition == _position ) return; -// _track = SGGeodesy::courseDeg( _prevPosition, _position ); - double d = .0; - double distance = .0; - if( SGGeodesy::inverse( _prevPosition, _position, _track, d, distance ) ) { - d = _position.getElevationM() - _prevPosition.getElevationM(); - _path = atan2( d, distance ) * SGD_RADIANS_TO_DEGREES; + inline TrackComputer( double & track, double & path, const SGGeod & position ) : + _track( track ), + _path( path ), + _position( position ), + _prevPosition( position ) { } - } + + inline ~TrackComputer() { + if( _prevPosition == _position ) return; +// _track = SGGeodesy::courseDeg( _prevPosition, _position ); + double d = .0; + double distance = .0; + if( SGGeodesy::inverse( _prevPosition, _position, _track, d, distance ) ) { + d = _position.getElevationM() - _prevPosition.getElevationM(); + _path = atan2( d, distance ) * SGD_RADIANS_TO_DEGREES; + } + } + private: - double & _track; - double & _path; - const SGGeod & _position; - const SGGeod _prevPosition; + double & _track; + double & _path; + const SGGeod & _position; + const SGGeod _prevPosition; }; // This is based heavily on LaRCsim/ls_generic.h -class FGInterface : public SGSubsystem { - +class FGInterface : public SGSubsystem +{ // Has the init() method been called. This is used to delay // initialization until scenery can be loaded and we know the true // ground elevation. @@ -220,16 +222,14 @@ class FGInterface : public SGSubsystem { void set_A_Z_pilot(double z) { _set_Accels_Pilot_Body(_state.a_pilot_body_v[0], _state.a_pilot_body_v[1], z); } - protected: - int _calc_multiloop (double dt); - // deliberately not virtual so that - // FGInterface constructor will call - // the right version + // deliberately not virtual so that + // FGInterface constructor will call + // the right version void _setup(); void _busdump(void); @@ -245,92 +245,92 @@ protected: void _update_ground_elev_at_pos( void ); inline void _set_CG_Position( double dx, double dy, double dz ) { - _state.d_cg_rp_body_v[0] = dx; - _state.d_cg_rp_body_v[1] = dy; - _state.d_cg_rp_body_v[2] = dz; + _state.d_cg_rp_body_v[0] = dx; + _state.d_cg_rp_body_v[1] = dy; + _state.d_cg_rp_body_v[2] = dz; } inline void _set_Accels_Local( double north, double east, double down ) { - _state.v_dot_local_v[0] = north; - _state.v_dot_local_v[1] = east; - _state.v_dot_local_v[2] = down; + _state.v_dot_local_v[0] = north; + _state.v_dot_local_v[1] = east; + _state.v_dot_local_v[2] = down; } inline void _set_Accels_Body( double u, double v, double w ) { - _state.v_dot_body_v[0] = u; - _state.v_dot_body_v[1] = v; - _state.v_dot_body_v[2] = w; + _state.v_dot_body_v[0] = u; + _state.v_dot_body_v[1] = v; + _state.v_dot_body_v[2] = w; } inline void _set_Accels_CG_Body( double x, double y, double z ) { - _state.a_cg_body_v[0] = x; - _state.a_cg_body_v[1] = y; - _state.a_cg_body_v[2] = z; + _state.a_cg_body_v[0] = x; + _state.a_cg_body_v[1] = y; + _state.a_cg_body_v[2] = z; } inline void _set_Accels_Pilot_Body( double x, double y, double z ) { - _state.a_pilot_body_v[0] = x; - _state.a_pilot_body_v[1] = y; - _state.a_pilot_body_v[2] = z; + _state.a_pilot_body_v[0] = x; + _state.a_pilot_body_v[1] = y; + _state.a_pilot_body_v[2] = z; } inline void _set_Accels_CG_Body_N( double x, double y, double z ) { - _state.n_cg_body_v[0] = x; - _state.n_cg_body_v[1] = y; - _state.n_cg_body_v[2] = z; + _state.n_cg_body_v[0] = x; + _state.n_cg_body_v[1] = y; + _state.n_cg_body_v[2] = z; } void _set_Nlf(double n) { _state.nlf=n; } inline void _set_Velocities_Local( double north, double east, double down ){ - _state.v_local_v[0] = north; - _state.v_local_v[1] = east; - _state.v_local_v[2] = down; + _state.v_local_v[0] = north; + _state.v_local_v[1] = east; + _state.v_local_v[2] = down; } inline void _set_Velocities_Ground(double north, double east, double down) { - _state.v_local_rel_ground_v[0] = north; - _state.v_local_rel_ground_v[1] = east; - _state.v_local_rel_ground_v[2] = down; + _state.v_local_rel_ground_v[0] = north; + _state.v_local_rel_ground_v[1] = east; + _state.v_local_rel_ground_v[2] = down; } inline void _set_Velocities_Local_Airmass( double north, double east, - double down) + double down) { - _state.v_local_airmass_v[0] = north; - _state.v_local_airmass_v[1] = east; - _state.v_local_airmass_v[2] = down; + _state.v_local_airmass_v[0] = north; + _state.v_local_airmass_v[1] = east; + _state.v_local_airmass_v[2] = down; } inline void _set_Velocities_Body( double u, double v, double w) { - _state.v_body_v[0] = u; - _state.v_body_v[1] = v; - _state.v_body_v[2] = w; + _state.v_body_v[0] = u; + _state.v_body_v[1] = v; + _state.v_body_v[2] = w; } inline void _set_V_rel_wind(double vt) { _state.v_rel_wind = vt; } inline void _set_V_ground_speed( double v) { _state.v_ground_speed = v; } inline void _set_V_equiv_kts( double kts ) { _state.v_equiv_kts = kts; } inline void _set_V_calibrated_kts( double kts ) { _state.v_calibrated_kts = kts; } inline void _set_Omega_Body( double p, double q, double r ) { - _state.omega_body_v[0] = p; - _state.omega_body_v[1] = q; - _state.omega_body_v[2] = r; + _state.omega_body_v[0] = p; + _state.omega_body_v[1] = q; + _state.omega_body_v[2] = r; } inline void _set_Euler_Rates( double phi, double theta, double psi ) { - _state.euler_rates_v[0] = phi; - _state.euler_rates_v[1] = theta; - _state.euler_rates_v[2] = psi; + _state.euler_rates_v[0] = phi; + _state.euler_rates_v[1] = theta; + _state.euler_rates_v[2] = psi; } void set_Phi_dot_degps(double x) { - _state.euler_rates_v[0] = x * SGD_DEGREES_TO_RADIANS; + _state.euler_rates_v[0] = x * SGD_DEGREES_TO_RADIANS; } void set_Theta_dot_degps(double x) { - _state.euler_rates_v[1] = x * SGD_DEGREES_TO_RADIANS; + _state.euler_rates_v[1] = x * SGD_DEGREES_TO_RADIANS; } void set_Psi_dot_degps(double x) { - _state.euler_rates_v[2] = x * SGD_DEGREES_TO_RADIANS; + _state.euler_rates_v[2] = x * SGD_DEGREES_TO_RADIANS; } inline void _set_Geocentric_Rates( double lat, double lon, double rad ) { - _state.geocentric_rates_v[0] = lat; - _state.geocentric_rates_v[1] = lon; - _state.geocentric_rates_v[2] = rad; + _state.geocentric_rates_v[0] = lat; + _state.geocentric_rates_v[1] = lon; + _state.geocentric_rates_v[2] = rad; } inline void _set_Geocentric_Position( double lat, double lon, double rad ) { _state.geocentric_position_v.setLatitudeRad(lat); @@ -363,9 +363,9 @@ protected: _state.geodetic_position_v.setElevationFt(alt); } inline void _set_Euler_Angles( double phi, double theta, double psi ) { - _state.euler_angles_v[0] = phi; - _state.euler_angles_v[1] = theta; - _state.euler_angles_v[2] = psi; + _state.euler_angles_v[0] = phi; + _state.euler_angles_v[1] = theta; + _state.euler_angles_v[2] = psi; } // FIXME, for compatibility with JSBSim inline void _set_T_Local_to_Body( int i, int j, double value) { } @@ -386,7 +386,6 @@ protected: inline void _set_Climb_Rate(double rate) { _state.climb_rate = rate; } public: - FGInterface(); FGInterface( double dt ); virtual ~FGInterface(); @@ -403,31 +402,31 @@ public: // Define the various supported flight models (many not yet implemented) enum { - // Magic Carpet mode - FG_MAGICCARPET = 0, + // Magic Carpet mode + FG_MAGICCARPET = 0, - // The NASA LaRCsim (Navion) flight model - FG_LARCSIM = 1, + // The NASA LaRCsim (Navion) flight model + FG_LARCSIM = 1, - // Jon S. Berndt's new FDM written from the ground up in C++ - FG_JSBSIM = 2, + // Jon S. Berndt's new FDM written from the ground up in C++ + FG_JSBSIM = 2, - // Christian's hot air balloon simulation - FG_BALLOONSIM = 3, + // Christian's hot air balloon simulation + FG_BALLOONSIM = 3, - // Aeronautical DEvelopment AGEncy, Bangalore India - FG_ADA = 4, + // Aeronautical DEvelopment AGEncy, Bangalore India + FG_ADA = 4, - // The following aren't implemented but are here to spark - // thoughts and discussions, and maybe even action. - FG_ACM = 5, - FG_SUPER_SONIC = 6, - FG_HELICOPTER = 7, - FG_AUTOGYRO = 8, - FG_PARACHUTE = 9, + // The following aren't implemented but are here to spark + // thoughts and discussions, and maybe even action. + FG_ACM = 5, + FG_SUPER_SONIC = 6, + FG_HELICOPTER = 7, + FG_AUTOGYRO = 8, + FG_PARACHUTE = 9, - // Driven externally via a serial port, net, file, etc. - FG_EXTERNAL = 10 + // Driven externally via a serial port, net, file, etc. + FG_EXTERNAL = 10 }; // initialization @@ -445,10 +444,10 @@ public: virtual void set_Altitude(double alt); // triggers re-calc of AGL altitude virtual void set_AltitudeAGL(double altagl); // and vice-versa virtual void set_Latitude_deg (double lat) { - set_Latitude(lat * SGD_DEGREES_TO_RADIANS); + set_Latitude(lat * SGD_DEGREES_TO_RADIANS); } virtual void set_Longitude_deg (double lon) { - set_Longitude(lon * SGD_DEGREES_TO_RADIANS); + set_Longitude(lon * SGD_DEGREES_TO_RADIANS); } // Speeds -- setting any of these will trigger a re-calc of the rest @@ -456,44 +455,44 @@ public: virtual void set_Mach_number(double mach); virtual void set_Velocities_Local( double north, double east, double down ); inline void set_V_north (double north) { - set_Velocities_Local(north, _state.v_local_v[1], _state.v_local_v[2]); + set_Velocities_Local(north, _state.v_local_v[1], _state.v_local_v[2]); } inline void set_V_east (double east) { - set_Velocities_Local(_state.v_local_v[0], east, _state.v_local_v[2]); + set_Velocities_Local(_state.v_local_v[0], east, _state.v_local_v[2]); } inline void set_V_down (double down) { - set_Velocities_Local(_state.v_local_v[0], _state.v_local_v[1], down); + set_Velocities_Local(_state.v_local_v[0], _state.v_local_v[1], down); } virtual void set_Velocities_Body( double u, double v, double w); virtual void set_uBody (double uBody) { - set_Velocities_Body(uBody, _state.v_body_v[1], _state.v_body_v[2]); + set_Velocities_Body(uBody, _state.v_body_v[1], _state.v_body_v[2]); } virtual void set_vBody (double vBody) { - set_Velocities_Body(_state.v_body_v[0], vBody, _state.v_body_v[2]); + set_Velocities_Body(_state.v_body_v[0], vBody, _state.v_body_v[2]); } virtual void set_wBody (double wBody) { - set_Velocities_Body(_state.v_body_v[0], _state.v_body_v[1], wBody); + set_Velocities_Body(_state.v_body_v[0], _state.v_body_v[1], wBody); } // Euler angles virtual void set_Euler_Angles( double phi, double theta, double psi ); virtual void set_Phi (double phi) { - set_Euler_Angles(phi, get_Theta(), get_Psi()); + set_Euler_Angles(phi, get_Theta(), get_Psi()); } virtual void set_Theta (double theta) { - set_Euler_Angles(get_Phi(), theta, get_Psi()); + set_Euler_Angles(get_Phi(), theta, get_Psi()); } virtual void set_Psi (double psi) { - set_Euler_Angles(get_Phi(), get_Theta(), psi); + set_Euler_Angles(get_Phi(), get_Theta(), psi); } virtual void set_Phi_deg (double phi) { - set_Phi(phi * SGD_DEGREES_TO_RADIANS); + set_Phi(phi * SGD_DEGREES_TO_RADIANS); } virtual void set_Theta_deg (double theta) { - set_Theta(theta * SGD_DEGREES_TO_RADIANS); + set_Theta(theta * SGD_DEGREES_TO_RADIANS); } virtual void set_Psi_deg (double psi) { - set_Psi(psi * SGD_DEGREES_TO_RADIANS); + set_Psi(psi * SGD_DEGREES_TO_RADIANS); } // Flight Path @@ -507,8 +506,8 @@ public: virtual void set_Density(double rho); virtual void set_Velocities_Local_Airmass (double wnorth, - double weast, - double wdown ); + double weast, + double wdown ); // ========== Mass properties and geometry values ========== @@ -604,10 +603,10 @@ public: return _state.geocentric_position_v.getLatitudeRad(); } inline double get_Lon_geocentric() const { - return _state.geocentric_position_v.getLongitudeRad(); + return _state.geocentric_position_v.getLongitudeRad(); } inline double get_Radius_to_vehicle() const { - return _state.geocentric_position_v.getRadiusFt(); + return _state.geocentric_position_v.getRadiusFt(); } const SGGeod& getPosition() const { return _state.geodetic_position_v; } @@ -662,7 +661,7 @@ public: inline double get_Sea_level_radius() const { return _state.sea_level_radius; } inline double get_Earth_position_angle() const { - return _state.earth_position_angle; + return _state.earth_position_angle; } inline double get_Runway_altitude() const { return _state.runway_altitude; } diff --git a/src/GUI/new_gui.hxx b/src/GUI/new_gui.hxx index f89acb1f2..d98db1407 100644 --- a/src/GUI/new_gui.hxx +++ b/src/GUI/new_gui.hxx @@ -30,7 +30,6 @@ class puFont; class NewGUI : public SGSubsystem { public: - /** * Constructor. */ @@ -47,7 +46,7 @@ public: virtual void init (); virtual void shutdown (); - + /** * Reinitialize the GUI subsystem. Reloads all XML dialogs. */ @@ -174,7 +173,6 @@ public: static const char* subsystemName() { return "gui"; } protected: - /** * Test if the menubar is visible. * @@ -203,9 +201,10 @@ protected: bool getMenuBarOverlapHide() const; void setMenuBarOverlapHide(bool hide); + private: void createMenuBarImplementation(); - + struct ltstr { bool operator()(const char* s1, const char* s2) const { @@ -228,18 +227,16 @@ private: FGDialog * _active_dialog; typedef std::map DialogDict; DialogDict _active_dialogs; - + typedef std::map NamePathDict; // mapping from dialog names to the corresponding XML property list // which defines them NamePathDict _dialog_names; - + // cache of loaded dialog proeprties typedef std::map NameDialogDict; NameDialogDict _dialog_props; - }; - #endif // __NEW_GUI_HXX diff --git a/src/Input/FGEventInput.hxx b/src/Input/FGEventInput.hxx index b07662f08..05f3954e9 100644 --- a/src/Input/FGEventInput.hxx +++ b/src/Input/FGEventInput.hxx @@ -36,38 +36,39 @@ class SGInterpTable; /* - * A base structure for event data. + * A base structure for event data. * To be extended for O/S specific implementation data */ struct FGEventData { - FGEventData( double aValue, double aDt, int aModifiers ) : modifiers(aModifiers), value(aValue), dt(aDt) {} - int modifiers; - double value; - double dt; + FGEventData( double aValue, double aDt, int aModifiers ) : modifiers(aModifiers), value(aValue), dt(aDt) {} + int modifiers; + double value; + double dt; }; -class FGEventSetting : public SGReferenced { +class FGEventSetting : public SGReferenced +{ public: - FGEventSetting( SGPropertyNode_ptr base ); + FGEventSetting( SGPropertyNode_ptr base ); - bool Test(); + bool Test(); - /* - * access for the value property - */ - double GetValue(); + /* + * access for the value property + */ + double GetValue(); protected: - double value; - SGPropertyNode_ptr valueNode; - SGSharedPtr condition; + double value; + SGPropertyNode_ptr valueNode; + SGSharedPtr condition; }; typedef SGSharedPtr FGEventSetting_ptr; typedef std::vector setting_list_t; class FGReportSetting : public SGReferenced, - public SGPropertyChangeListener + public SGPropertyChangeListener { public: FGReportSetting( SGPropertyNode_ptr base ); @@ -87,19 +88,19 @@ public: std::string reportBytes(const std::string& moduleName) const; virtual void valueChanged(SGPropertyNode * node); + protected: unsigned int reportId; std::string nasalFunction; bool dirty; - }; typedef SGSharedPtr FGReportSetting_ptr; typedef std::vector report_setting_list_t; /* - * A wrapper class for a configured event. - * + * A wrapper class for a configured event. + * * * Change the view pitch * rel-x-rotate @@ -119,102 +120,110 @@ typedef std::vector report_setting_list_t; * */ class FGInputDevice; -class FGInputEvent : public SGReferenced,FGCommonInput { +class FGInputEvent : public SGReferenced, + FGCommonInput +{ public: + /* + * Constructor for the class. The arg node shall point + * to the property corresponding to the node + */ + FGInputEvent( FGInputDevice * device, SGPropertyNode_ptr node ); + virtual ~FGInputEvent(); - /* - * Constructor for the class. The arg node shall point - * to the property corresponding to the node - */ - FGInputEvent( FGInputDevice * device, SGPropertyNode_ptr node ); - virtual ~FGInputEvent(); + /* + * dispatch the event value through all bindings + */ + virtual void fire( FGEventData & eventData ); - /* - * dispatch the event value through all bindings - */ - virtual void fire( FGEventData & eventData ); + /* + * access for the name property + */ + std::string GetName() const { return name; } - /* - * access for the name property - */ - std::string GetName() const { return name; } + /* + * access for the description property + */ + std::string GetDescription() const { return desc; } - /* - * access for the description property - */ - std::string GetDescription() const { return desc; } + virtual void update( double dt ); - virtual void update( double dt ); - - static FGInputEvent * NewObject( FGInputDevice * device, SGPropertyNode_ptr node ); + static FGInputEvent * NewObject( FGInputDevice * device, SGPropertyNode_ptr node ); protected: - virtual void fire( SGBinding * binding, FGEventData & eventData ); - /* A more or less meaningfull description of the event */ - std::string desc; + virtual void fire( SGBinding * binding, FGEventData & eventData ); + /* A more or less meaningfull description of the event */ + std::string desc; - /* One of the predefined names of the event */ - std::string name; + /* One of the predefined names of the event */ + std::string name; - /* A list of SGBinding objects */ - binding_list_t bindings[KEYMOD_MAX]; + /* A list of SGBinding objects */ + binding_list_t bindings[KEYMOD_MAX]; - /* A list of FGEventSetting objects */ - setting_list_t settings; + /* A list of FGEventSetting objects */ + setting_list_t settings; - /* A pointer to the associated device */ - FGInputDevice * device; + /* A pointer to the associated device */ + FGInputDevice * device; - double lastDt; - double intervalSec; - double lastSettingValue; + double lastDt; + double intervalSec; + double lastSettingValue; }; -class FGButtonEvent : public FGInputEvent { +class FGButtonEvent : public FGInputEvent +{ public: - FGButtonEvent( FGInputDevice * device, SGPropertyNode_ptr node ); - virtual void fire( FGEventData & eventData ); + FGButtonEvent( FGInputDevice * device, SGPropertyNode_ptr node ); + virtual void fire( FGEventData & eventData ); void update( double dt ) override; protected: - bool repeatable; - bool lastState; + bool repeatable; + bool lastState; }; -class FGAxisEvent : public FGInputEvent { +class FGAxisEvent : public FGInputEvent +{ public: - FGAxisEvent( FGInputDevice * device, SGPropertyNode_ptr node ); - ~FGAxisEvent(); - - void SetMaxRange( double value ) { maxRange = value; } - void SetMinRange( double value ) { minRange = value; } - void SetRange( double min, double max ) { minRange = min; maxRange = max; } + FGAxisEvent( FGInputDevice * device, SGPropertyNode_ptr node ); + ~FGAxisEvent(); + + void SetMaxRange( double value ) { maxRange = value; } + void SetMinRange( double value ) { minRange = value; } + void SetRange( double min, double max ) { minRange = min; maxRange = max; } + protected: - virtual void fire( FGEventData & eventData ); - double tolerance; - double minRange; - double maxRange; - double center; - double deadband; - double lowThreshold; - double highThreshold; - double lastValue; - std::unique_ptr interpolater; - bool mirrorInterpolater = false; + virtual void fire( FGEventData & eventData ); + double tolerance; + double minRange; + double maxRange; + double center; + double deadband; + double lowThreshold; + double highThreshold; + double lastValue; + std::unique_ptr interpolater; + bool mirrorInterpolater = false; }; -class FGRelAxisEvent : public FGAxisEvent { +class FGRelAxisEvent : public FGAxisEvent +{ public: - FGRelAxisEvent( FGInputDevice * device, SGPropertyNode_ptr node ); + FGRelAxisEvent( FGInputDevice * device, SGPropertyNode_ptr node ); + protected: - virtual void fire( SGBinding * binding, FGEventData & eventData ); + virtual void fire( SGBinding * binding, FGEventData & eventData ); }; -class FGAbsAxisEvent : public FGAxisEvent { +class FGAbsAxisEvent : public FGAxisEvent +{ public: - FGAbsAxisEvent( FGInputDevice * device, SGPropertyNode_ptr node ) : FGAxisEvent( device, node ) {} + FGAbsAxisEvent( FGInputDevice * device, SGPropertyNode_ptr node ) : FGAxisEvent( device, node ) {} + protected: - virtual void fire( SGBinding * binding, FGEventData & eventData ); + virtual void fire( SGBinding * binding, FGEventData & eventData ); }; typedef class SGSharedPtr FGInputEvent_ptr; @@ -224,73 +233,74 @@ typedef class SGSharedPtr FGInputEvent_ptr; * all operating systems. This is the base class for the O/S-specific * implementation of input device handlers */ -class FGInputDevice : public SGReferenced { +class FGInputDevice : public SGReferenced +{ public: - FGInputDevice() {} - FGInputDevice( std::string aName, std::string aSerial = {} ) : - name(aName), serialNumber(aSerial) {} - - virtual ~FGInputDevice(); + FGInputDevice() {} + FGInputDevice( std::string aName, std::string aSerial = {} ) : + name(aName), serialNumber(aSerial) {} - virtual bool Open() = 0; - virtual void Close() = 0; + virtual ~FGInputDevice(); - virtual void Send( const char * eventName, double value ) = 0; + virtual bool Open() = 0; + virtual void Close() = 0; - inline void Send( const std::string & eventName, double value ) { - Send( eventName.c_str(), value ); - } + virtual void Send( const char * eventName, double value ) = 0; + + inline void Send( const std::string & eventName, double value ) { + Send( eventName.c_str(), value ); + } virtual void SendFeatureReport(unsigned int reportId, const std::string& data); - virtual const char * TranslateEventName( FGEventData & eventData ) = 0; + virtual const char * TranslateEventName( FGEventData & eventData ) = 0; - void SetName( std::string name ); - std::string & GetName() { return name; } + void SetName( std::string name ); + std::string & GetName() { return name; } - void SetUniqueName(const std::string& name); - const std::string GetUniqueName() const - { return _uniqueName; } + void SetUniqueName(const std::string& name); + const std::string GetUniqueName() const + { return _uniqueName; } - void SetSerialNumber( std::string serial ); - std::string& GetSerialNumber() { return serialNumber; } - - void HandleEvent( FGEventData & eventData ); + void SetSerialNumber( std::string serial ); + std::string& GetSerialNumber() { return serialNumber; } - virtual void AddHandledEvent( FGInputEvent_ptr handledEvent ); + void HandleEvent( FGEventData & eventData ); - virtual void Configure( SGPropertyNode_ptr deviceNode ); + virtual void AddHandledEvent( FGInputEvent_ptr handledEvent ); - virtual void update( double dt ); + virtual void Configure( SGPropertyNode_ptr deviceNode ); - bool GetDebugEvents () const { return debugEvents; } + virtual void update( double dt ); - bool GetGrab() const { return grab; } + bool GetDebugEvents () const { return debugEvents; } - const std::string & GetNasalModule() const { return nasalModule; } + bool GetGrab() const { return grab; } + + const std::string & GetNasalModule() const { return nasalModule; } protected: - // A map of events, this device handles - std::map handledEvents; + // A map of events, this device handles + std::map handledEvents; - // the device has a name to be recognized - std::string name; + // the device has a name to be recognized + std::string name; - // serial number string to disambiguate multiple instances - // of the same device - std::string serialNumber; - - // print out events comming in from the device - // if true - bool debugEvents = false; + // serial number string to disambiguate multiple instances + // of the same device + std::string serialNumber; - // grab the device exclusively, if O/S supports this - // so events are not sent to other applications - bool grab = false; + // print out events comming in from the device + // if true + bool debugEvents = false; - SGPropertyNode_ptr deviceNode; - std::string nasalModule; + // grab the device exclusively, if O/S supports this + // so events are not sent to other applications + bool grab = false; + + SGPropertyNode_ptr deviceNode; + std::string nasalModule; report_setting_list_t reportSettings; @@ -304,32 +314,35 @@ typedef SGSharedPtr FGInputDevice_ptr; /* - * The Subsystem for the event input device + * The Subsystem for the event input device */ -class FGEventInput : public SGSubsystem,FGCommonInput { +class FGEventInput : public SGSubsystem, + FGCommonInput +{ public: - FGEventInput(); - virtual ~FGEventInput(); - void init() override; - void postinit() override; - void update( double dt ) override; - void shutdown() override; + FGEventInput(); + virtual ~FGEventInput(); + void init() override; + void postinit() override; + void update( double dt ) override; + void shutdown() override; + + const static unsigned MAX_DEVICES = 1000; + const static unsigned INVALID_DEVICE_INDEX = MAX_DEVICES + 1; - const static unsigned MAX_DEVICES = 1000; - const static unsigned INVALID_DEVICE_INDEX = MAX_DEVICES + 1; protected: - static const char * PROPERTY_ROOT; + static const char * PROPERTY_ROOT; - unsigned AddDevice( FGInputDevice * inputDevice ); - void RemoveDevice( unsigned index ); + unsigned AddDevice( FGInputDevice * inputDevice ); + void RemoveDevice( unsigned index ); - std::map input_devices; - FGDeviceConfigurationMap configMap; + std::map input_devices; + FGDeviceConfigurationMap configMap; - SGPropertyNode_ptr nasalClose; + SGPropertyNode_ptr nasalClose; private: - std::string computeDeviceIndexName(FGInputDevice *dev) const; + std::string computeDeviceIndexName(FGInputDevice *dev) const; }; #endif diff --git a/src/Input/FGHIDEventInput.hxx b/src/Input/FGHIDEventInput.hxx index 182e648f2..764283629 100644 --- a/src/Input/FGHIDEventInput.hxx +++ b/src/Input/FGHIDEventInput.hxx @@ -35,21 +35,22 @@ void writeBits(uint8_t* bytes, size_t bitOffset, size_t bitSize, int value); class FGHIDEventInput : public FGEventInput { public: - FGHIDEventInput(); + FGHIDEventInput(); - virtual ~FGHIDEventInput(); - - void update(double dt) override; - void init() override; - void reinit() override; - void postinit(); - void shutdown() override; + virtual ~FGHIDEventInput(); + + void update(double dt) override; + void init() override; + void reinit() override; + void postinit(); + void shutdown() override; + + static const char* subsystemName() { return "input-hid"; } - static const char* subsystemName() { return "input-hid"; } private: - class FGHIDEventInputPrivate; - - std::unique_ptr d; + class FGHIDEventInputPrivate; + + std::unique_ptr d; }; #endif diff --git a/src/Input/FGJoystickInput.hxx b/src/Input/FGJoystickInput.hxx index 1087be9bd..862295a0b 100644 --- a/src/Input/FGJoystickInput.hxx +++ b/src/Input/FGJoystickInput.hxx @@ -36,72 +36,73 @@ //////////////////////////////////////////////////////////////////////// // The Joystick Input Class //////////////////////////////////////////////////////////////////////// -class FGJoystickInput : public SGSubsystem,FGCommonInput { +class FGJoystickInput : public SGSubsystem, + FGCommonInput +{ public: - FGJoystickInput(); - virtual ~FGJoystickInput(); + FGJoystickInput(); + virtual ~FGJoystickInput(); - virtual void init(); - virtual void postinit(); - virtual void reinit(); - virtual void update( double dt ); + virtual void init(); + virtual void postinit(); + virtual void reinit(); + virtual void update( double dt ); - static const int MAX_JOYSTICKS = 16; - static const int MAX_JOYSTICK_AXES = _JS_MAX_AXES; - static const int MAX_JOYSTICK_BUTTONS = 32; + static const int MAX_JOYSTICKS = 16; + static const int MAX_JOYSTICK_AXES = _JS_MAX_AXES; + static const int MAX_JOYSTICK_BUTTONS = 32; private: - /** - * @brief computeDeviceIndexName - compute the name including the index, based - * on the number of identically named devices. This is used to allow multiple - * different files for identical hardware, especially throttles - * @param name - the base joystick name - * @param lastIndex - don't check names at this index or above. Needed to - * ensure we only check as far as the joystick we are currently processing - * @return - */ - std::string computeDeviceIndexName(const std::string &name, int lastIndex) const; - - void _remove(bool all); - SGPropertyNode_ptr status_node; + /** + * @brief computeDeviceIndexName - compute the name including the index, based + * on the number of identically named devices. This is used to allow multiple + * different files for identical hardware, especially throttles + * @param name - the base joystick name + * @param lastIndex - don't check names at this index or above. Needed to + * ensure we only check as far as the joystick we are currently processing + * @return + */ + std::string computeDeviceIndexName(const std::string &name, int lastIndex) const; - /** - * Settings for a single joystick axis. - */ - struct axis { - axis (); - virtual ~axis (); - float last_value; - float tolerance; - binding_list_t bindings[KEYMOD_MAX]; - float low_threshold; - float high_threshold; - FGButton low; - FGButton high; - float interval_sec, delay_sec, release_delay_sec; - double last_dt; - }; + void _remove(bool all); + SGPropertyNode_ptr status_node; - /** - * Settings for a joystick. - */ - struct joystick { - joystick (); - virtual ~joystick (); - int jsnum; - std::unique_ptr plibJS; - int naxes; - int nbuttons; - axis * axes; - FGButton * buttons; - bool predefined; - - void clearAxesAndButtons(); - }; - - joystick joysticks[MAX_JOYSTICKS]; - void updateJoystick(int index, joystick* joy, double dt); + /** + * Settings for a single joystick axis. + */ + struct axis { + axis (); + virtual ~axis (); + float last_value; + float tolerance; + binding_list_t bindings[KEYMOD_MAX]; + float low_threshold; + float high_threshold; + FGButton low; + FGButton high; + float interval_sec, delay_sec, release_delay_sec; + double last_dt; + }; + /** + * Settings for a joystick. + */ + struct joystick { + joystick (); + virtual ~joystick (); + int jsnum; + std::unique_ptr plibJS; + int naxes; + int nbuttons; + axis * axes; + FGButton * buttons; + bool predefined; + + void clearAxesAndButtons(); + }; + + joystick joysticks[MAX_JOYSTICKS]; + void updateJoystick(int index, joystick* joy, double dt); }; #endif diff --git a/src/Input/FGKeyboardInput.hxx b/src/Input/FGKeyboardInput.hxx index 886823269..35ba39277 100644 --- a/src/Input/FGKeyboardInput.hxx +++ b/src/Input/FGKeyboardInput.hxx @@ -37,37 +37,39 @@ //////////////////////////////////////////////////////////////////////// // The Keyboard Input Class //////////////////////////////////////////////////////////////////////// -class FGKeyboardInput : public SGSubsystem,FGCommonInput { +class FGKeyboardInput : public SGSubsystem, + FGCommonInput +{ public: - FGKeyboardInput(); - virtual ~FGKeyboardInput(); + FGKeyboardInput(); + virtual ~FGKeyboardInput(); - virtual void init(); - virtual void postinit(); - virtual void bind(); - virtual void unbind(); - virtual void update( double dt ); + virtual void init(); + virtual void postinit(); + virtual void bind(); + virtual void unbind(); + virtual void update( double dt ); - static const int MAX_KEYS = 1024; + static const int MAX_KEYS = 1024; private: - const binding_list_t& _find_key_bindings (unsigned int k, int modifiers); - void doKey (int k, int modifiers, int x, int y); + const binding_list_t& _find_key_bindings (unsigned int k, int modifiers); + void doKey (int k, int modifiers, int x, int y); - static void keyHandler(int key, int keymod, int mousex, int mousey); - static FGKeyboardInput * keyboardInput; - FGButton bindings[MAX_KEYS]; - SGPropertyNode_ptr _key_event; - int _key_code; - int _key_modifiers; - bool _key_pressed; - bool _key_shift; - bool _key_ctrl; - bool _key_alt; - bool _key_meta; - bool _key_super; - bool _key_hyper; - simgear::TiedPropertyList _tiedProperties; + static void keyHandler(int key, int keymod, int mousex, int mousey); + static FGKeyboardInput * keyboardInput; + FGButton bindings[MAX_KEYS]; + SGPropertyNode_ptr _key_event; + int _key_code; + int _key_modifiers; + bool _key_pressed; + bool _key_shift; + bool _key_ctrl; + bool _key_alt; + bool _key_meta; + bool _key_super; + bool _key_hyper; + simgear::TiedPropertyList _tiedProperties; }; #endif diff --git a/src/Input/FGLinuxEventInput.hxx b/src/Input/FGLinuxEventInput.hxx index 63e7f99ad..49cf5a0c6 100644 --- a/src/Input/FGLinuxEventInput.hxx +++ b/src/Input/FGLinuxEventInput.hxx @@ -27,48 +27,51 @@ #include struct FGLinuxEventData : public FGEventData { - FGLinuxEventData( struct input_event & event, double dt, int modifiers ) : - FGEventData( (double)event.value, dt, modifiers ), - type(event.type), - code(event.code) { - } - unsigned type; - unsigned code; + FGLinuxEventData( struct input_event & event, double dt, int modifiers ) : + FGEventData( (double)event.value, dt, modifiers ), + type(event.type), + code(event.code) { + } + unsigned type; + unsigned code; }; /* * A implementation for linux event devices */ -class FGLinuxInputDevice : public FGInputDevice { +class FGLinuxInputDevice : public FGInputDevice +{ public: - FGLinuxInputDevice(); - FGLinuxInputDevice( std::string name, std::string devname, std::string aSerial ); - virtual ~FGLinuxInputDevice(); + FGLinuxInputDevice(); + FGLinuxInputDevice( std::string name, std::string devname, std::string aSerial ); + virtual ~FGLinuxInputDevice(); - bool Open() override; - void Close() override; - void Send( const char * eventName, double value ) override; - const char * TranslateEventName( FGEventData & eventData ) override; + bool Open() override; + void Close() override; + void Send( const char * eventName, double value ) override; + const char * TranslateEventName( FGEventData & eventData ) override; - void SetDevname( const std::string & name ); - std::string GetDevname() const { return devname; } + void SetDevname( const std::string & name ); + std::string GetDevname() const { return devname; } - int GetFd() { return fd; } + int GetFd() { return fd; } + + double Normalize( struct input_event & event ); - double Normalize( struct input_event & event ); private: - std::string devname; - int fd; + std::string devname; + int fd; - std::map absinfo; + std::map absinfo; }; -class FGLinuxEventInput : public FGEventInput { +class FGLinuxEventInput : public FGEventInput +{ public: - FGLinuxEventInput(); - virtual ~ FGLinuxEventInput(); - virtual void update (double dt); - virtual void postinit(); + FGLinuxEventInput(); + virtual ~ FGLinuxEventInput(); + virtual void update (double dt); + virtual void postinit(); protected: }; diff --git a/src/Input/FGMacOSXEventInput.hxx b/src/Input/FGMacOSXEventInput.hxx index 050f16b0d..ff0d3287b 100644 --- a/src/Input/FGMacOSXEventInput.hxx +++ b/src/Input/FGMacOSXEventInput.hxx @@ -33,28 +33,30 @@ class FGMacOSXEventInputPrivate; struct FGMacOSXEventData : public FGEventData { - FGMacOSXEventData(std::string name, double value, double dt, int modifiers) : - FGEventData(value, dt, modifiers), name(name) {} - std::string name; + FGMacOSXEventData(std::string name, double value, double dt, int modifiers) : + FGEventData(value, dt, modifiers), name(name) {} + std::string name; }; // // Mac OS X specific FGEventInput // -class FGMacOSXEventInput : public FGEventInput { +class FGMacOSXEventInput : public FGEventInput +{ public: FGMacOSXEventInput(); - virtual ~FGMacOSXEventInput(); - virtual void update(double dt); - virtual void init(); + virtual ~FGMacOSXEventInput(); + virtual void update(double dt); + virtual void init(); virtual void postinit(); virtual void shutdown(); + private: friend class FGMacOSXEventInputPrivate; - - std::unique_ptr d; + + std::unique_ptr d; }; #endif diff --git a/src/Input/FGMouseInput.hxx b/src/Input/FGMouseInput.hxx index 989a2267a..a6c3cee42 100644 --- a/src/Input/FGMouseInput.hxx +++ b/src/Input/FGMouseInput.hxx @@ -38,7 +38,9 @@ namespace osgGA { class GUIEventAdapter; } //////////////////////////////////////////////////////////////////////// // The Mouse Input Class //////////////////////////////////////////////////////////////////////// -class FGMouseInput : public SGSubsystem, FGCommonInput { +class FGMouseInput : public SGSubsystem, + FGCommonInput +{ public: FGMouseInput(); virtual ~FGMouseInput() = default; @@ -59,17 +61,17 @@ public: * @return */ bool isRightDragToLookEnabled() const; - + /** * @brief check if the active mode passes clicks through to the UI or not */ bool isActiveModePassThrough() const; + private: - void processMotion(int x, int y, const osgGA::GUIEventAdapter* ea); - - class FGMouseInputPrivate; - std::unique_ptr d; - + void processMotion(int x, int y, const osgGA::GUIEventAdapter* ea); + + class FGMouseInputPrivate; + std::unique_ptr d; }; #endif diff --git a/src/Input/input.hxx b/src/Input/input.hxx index ce9a7aaee..e31ab9f4c 100644 --- a/src/Input/input.hxx +++ b/src/Input/input.hxx @@ -45,18 +45,17 @@ class FGInput : public SGSubsystemGroup { public: - /** - * Default constructor. - */ - FGInput (); + /** + * Default constructor. + */ + FGInput (); - /** - * Destructor. - */ - virtual ~FGInput(); - - static const char* subsystemName() { return "input"; } + /** + * Destructor. + */ + virtual ~FGInput(); + static const char* subsystemName() { return "input"; } }; #endif // _INPUT_HXX diff --git a/src/Instrumentation/HUD/HUD.hxx b/src/Instrumentation/HUD/HUD.hxx index 95066d2ed..29fefbc5d 100644 --- a/src/Instrumentation/HUD/HUD.hxx +++ b/src/Instrumentation/HUD/HUD.hxx @@ -40,7 +40,8 @@ class fntTexFont; class FGViewer; class ClipBox; -class LineSegment { +class LineSegment +{ public: LineSegment(GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1) : _x0(x0), _y0(y0), _x1(x1), _y1(y1) {} @@ -56,7 +57,8 @@ private: -class LineList { +class LineList +{ public: void add(const LineSegment& seg) { _list.push_back(seg); } void erase() { _list.erase(_list.begin(), _list.end()); } @@ -76,7 +78,8 @@ private: -class HUDText { +class HUDText +{ public: HUDText(fntRenderer *f, float x, float y, const char *s, int align = 0, int digits = 0); void draw(); @@ -91,7 +94,8 @@ private: -class TextList { +class TextList +{ public: TextList() { _font = 0; } @@ -111,14 +115,16 @@ private: -class HUD : public SGSubsystem, public SGPropertyChangeListener { +class HUD : public SGSubsystem, + public SGPropertyChangeListener +{ public: HUD(); ~HUD(); void init(); void update(double); - void reinit(); + void reinit(); // called from Main/renderer.cxx to draw 2D and 3D HUD void draw(osg::State&); @@ -163,12 +169,12 @@ protected: private: void deinit(); - + void draw3D(); void draw2D(GLfloat, GLfloat, GLfloat, GLfloat); void currentColorChanged(); - + class Input; class Item; class Label; diff --git a/src/Instrumentation/KLN89/kln89.hxx b/src/Instrumentation/KLN89/kln89.hxx index 1758f4a69..b55f91aeb 100644 --- a/src/Instrumentation/KLN89/kln89.hxx +++ b/src/Instrumentation/KLN89/kln89.hxx @@ -1,9 +1,9 @@ // kln89_page.hxx - a class to manage the simulation of a KLN89 -// GPS unit. Note that this is primarily the +// GPS unit. Note that this is primarily the // simulation of the user interface and display // - the core GPS calculations such as position -// and waypoint sequencing are done (or should -// be done) by FG code. +// and waypoint sequencing are done (or should +// be done) by FG code. // // Written by David Luff, started 2005. // @@ -34,36 +34,36 @@ class KLN89Page; const int KLN89MapScales[2][21] = {{1, 2, 3, 5, 7, 10, 12, 15, 17, 20, 25, 30, 40, 60, 80, 100, 120, 160, 240, 320, 500}, - {2, 4, 6, 9, 13, 18, 22, 28, 32, 37, 46, 55, 75, 110, 150, 185, 220, 300, 440, 600, 925}}; + {2, 4, 6, 9, 13, 18, 22, 28, 32, 37, 46, 55, 75, 110, 150, 185, 220, 300, 440, 600, 925}}; enum KLN89Mode { - KLN89_MODE_DISP, - KLN89_MODE_CRSR + KLN89_MODE_DISP, + KLN89_MODE_CRSR }; enum KLN89DistanceUnits { - GPS_DIST_UNITS_NM = 0, - GPS_DIST_UNITS_KM + GPS_DIST_UNITS_NM = 0, + GPS_DIST_UNITS_KM }; enum KLN89SpeedUnits { - GPS_VEL_UNITS_KT, - GPS_VEL_UNITS_KPH + GPS_VEL_UNITS_KT, + GPS_VEL_UNITS_KPH }; enum KLN89AltitudeUnits { - GPS_ALT_UNITS_FT, - GPS_ALT_UNITS_M + GPS_ALT_UNITS_FT, + GPS_ALT_UNITS_M }; enum KLN89PressureUnits { - GPS_PRES_UNITS_IN = 1, - GPS_PRES_UNITS_MB, - GPS_PRES_UNITS_HP + GPS_PRES_UNITS_IN = 1, + GPS_PRES_UNITS_MB, + GPS_PRES_UNITS_HP }; /* -const char* KLN89TimeCodes[20] = { "UTC", "GST", "GDT", "ATS", "ATD", "EST", "EDT", "CST", "CDT", "MST", +const char* KLN89TimeCodes[20] = { "UTC", "GST", "GDT", "ATS", "ATD", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", "PDT", "AKS", "AKD", "HAS", "HAD", "SST", "SDT", "LCL" }; */ @@ -74,286 +74,286 @@ typedef airport_id_str_map_type::iterator airport_id_str_map_iterator; typedef std::vector kln89_page_list_type; typedef kln89_page_list_type::iterator kln89_page_list_itr; -class KLN89 : public DCLGPS { - - friend class KLN89Page; - friend class KLN89AptPage; - friend class KLN89VorPage; - friend class KLN89NDBPage; - friend class KLN89IntPage; - friend class KLN89UsrPage; - friend class KLN89ActPage; - friend class KLN89NavPage; - friend class KLN89FplPage; - friend class KLN89CalPage; - friend class KLN89SetPage; - friend class KLN89OthPage; - friend class KLN89AltPage; - friend class KLN89DirPage; - friend class KLN89NrstPage; - +class KLN89 : public DCLGPS +{ + friend class KLN89Page; + friend class KLN89AptPage; + friend class KLN89VorPage; + friend class KLN89NDBPage; + friend class KLN89IntPage; + friend class KLN89UsrPage; + friend class KLN89ActPage; + friend class KLN89NavPage; + friend class KLN89FplPage; + friend class KLN89CalPage; + friend class KLN89SetPage; + friend class KLN89OthPage; + friend class KLN89AltPage; + friend class KLN89DirPage; + friend class KLN89NrstPage; + public: - KLN89(RenderArea2D* instrument); - ~KLN89(); - - void bind(); - void unbind(); - void init(); - void update(double dt); - - // Set Units - // m if true, ft if false - inline void SetAltUnitsSI(bool b) { _altUnits = (b ? GPS_ALT_UNITS_M : GPS_ALT_UNITS_FT); } - // Returns true if alt units are SI (m), false if ft - inline bool GetAltUnitsSI() { return(_altUnits == GPS_ALT_UNITS_M ? true : false); } - // km and k/h if true, nm and kt if false - inline void SetDistVelUnitsSI(bool b) { _distUnits = (b ? GPS_DIST_UNITS_KM : GPS_DIST_UNITS_NM); _velUnits = (b ? GPS_VEL_UNITS_KPH : GPS_VEL_UNITS_KT); } - // Returns true if dist/vel units are SI - inline bool GetDistVelUnitsSI() { return(_distUnits == GPS_DIST_UNITS_KM && _velUnits == GPS_VEL_UNITS_KPH ? true : false); } - // Set baro units - 1 = in, 2 = mB, 3 = hP Wrapping if for the convienience of the GPS setter. - void SetBaroUnits(int n, bool wrap = false); - // Get baro units: 1 = in, 2 = mB, 3 = hP - inline int GetBaroUnits() { return((int)_baroUnits); } - - inline void SetTurnAnticipation(bool b) { _turnAnticipationEnabled = b; } - inline bool GetTurnAnticipation() { return(_turnAnticipationEnabled); } + KLN89(RenderArea2D* instrument); + ~KLN89(); - inline void SetSuaAlertEnabled(bool b) { _suaAlertEnabled = b; } - inline bool GetSuaAlertEnabled() { return(_suaAlertEnabled); } - - inline void SetAltAlertEnabled(bool b) { _altAlertEnabled = b; } - inline bool GetAltAlertEnabled() { return(_altAlertEnabled); } + void bind(); + void unbind(); + void init(); + void update(double dt); - void SetMinDisplayBrightness(int n); // Set minDisplayBrightness (between 1 and 9) - void DecrementMinDisplayBrightness(); // Decrease by 1 - void IncrementMinDisplayBrightness(); // Increase by 1 - inline int GetMinDisplayBrightness() { return(_minDisplayBrightness); } - - inline bool GetMsgAlert() const { return(!_messageStack.empty()); } - - void Knob1Right1(); - void Knob1Left1(); - void Knob2Right1(); - void Knob2Left1(); - void CrsrPressed(); - void EntPressed(); - void ClrPressed(); - void DtoPressed(); - void NrstPressed(); - void AltPressed(); - void OBSPressed(); - void MsgPressed(); - - void CreateDefaultFlightPlans(); + // Set Units + // m if true, ft if false + inline void SetAltUnitsSI(bool b) { _altUnits = (b ? GPS_ALT_UNITS_M : GPS_ALT_UNITS_FT); } + // Returns true if alt units are SI (m), false if ft + inline bool GetAltUnitsSI() { return(_altUnits == GPS_ALT_UNITS_M ? true : false); } + // km and k/h if true, nm and kt if false + inline void SetDistVelUnitsSI(bool b) { _distUnits = (b ? GPS_DIST_UNITS_KM : GPS_DIST_UNITS_NM); _velUnits = (b ? GPS_VEL_UNITS_KPH : GPS_VEL_UNITS_KT); } + // Returns true if dist/vel units are SI + inline bool GetDistVelUnitsSI() { return(_distUnits == GPS_DIST_UNITS_KM && _velUnits == GPS_VEL_UNITS_KPH ? true : false); } + // Set baro units - 1 = in, 2 = mB, 3 = hP Wrapping if for the convienience of the GPS setter. + void SetBaroUnits(int n, bool wrap = false); + // Get baro units: 1 = in, 2 = mB, 3 = hP + inline int GetBaroUnits() { return((int)_baroUnits); } + + inline void SetTurnAnticipation(bool b) { _turnAnticipationEnabled = b; } + inline bool GetTurnAnticipation() { return(_turnAnticipationEnabled); } + + inline void SetSuaAlertEnabled(bool b) { _suaAlertEnabled = b; } + inline bool GetSuaAlertEnabled() { return(_suaAlertEnabled); } + + inline void SetAltAlertEnabled(bool b) { _altAlertEnabled = b; } + inline bool GetAltAlertEnabled() { return(_altAlertEnabled); } + + void SetMinDisplayBrightness(int n); // Set minDisplayBrightness (between 1 and 9) + void DecrementMinDisplayBrightness(); // Decrease by 1 + void IncrementMinDisplayBrightness(); // Increase by 1 + inline int GetMinDisplayBrightness() { return(_minDisplayBrightness); } + + inline bool GetMsgAlert() const { return(!_messageStack.empty()); } + + void Knob1Right1(); + void Knob1Left1(); + void Knob2Right1(); + void Knob2Left1(); + void CrsrPressed(); + void EntPressed(); + void ClrPressed(); + void DtoPressed(); + void NrstPressed(); + void AltPressed(); + void OBSPressed(); + void MsgPressed(); + + void CreateDefaultFlightPlans(); private: - void ToggleOBSMode(); - - // Initiate Direct To operation to the supplied ID. - void DtoInitiate(const std::string& id); + void ToggleOBSMode(); - //----------------------- Drawing functions which take CHARACTER units ------------------------- - // Render string s in display field field at position x, y - // WHERE POSITION IS IN CHARACTER UNITS! - // zero y at bottom? - // invert: -1 => no inversion, 0 -> n => 1 char - s[invert] gets inverted, 99 => entire string gets inverted - void DrawText(const std::string& s, int field, int px, int py, bool bold = false, int invert = -1); - - void DrawLatitude(double d, int field, int px, int py); - void DrawLongitude(double d, int field, int px, int py); + // Initiate Direct To operation to the supplied ID. + void DtoInitiate(const std::string& id); - // Draw a frequency as xxx.xx - void DrawFreq(double d, int field, int px, int py); - - // Draw a time in seconds as hh:mm - // NOTE: px is RIGHT JUSTIFIED! - void DrawTime(double time, int field, int px, int py); + //----------------------- Drawing functions which take CHARACTER units ------------------------- + // Render string s in display field field at position x, y + // WHERE POSITION IS IN CHARACTER UNITS! + // zero y at bottom? + // invert: -1 => no inversion, 0 -> n => 1 char - s[invert] gets inverted, 99 => entire string gets inverted + void DrawText(const std::string& s, int field, int px, int py, bool bold = false, int invert = -1); - // Draw an integer heading, where px specifies the position of the degrees sign at the RIGHT of the value. - void DrawHeading(int h, int field, int px, int py); - - // Draw a distance spec'd as nm as an integer (TODO - may need 1 decimal place if < 100) where px specifies RHS of units. - // Some uses definately don't want decimal place though (as at present), so would have to be arg. - void DrawDist(double d, int field, int px, int py); - - // Draw a speed specifed in knots. px is RHS of the units. Can draw up to 2 decimal places. - void DrawSpeed(double v, int field, int px, int py, int decimals = 0); - - void Underline(int field, int px, int py, int len); - - // Render a char at a given position as above (position in CHARACTER units) - void DrawChar(char c, int field, int px, int py, bool bold = false, bool invert = false); - void DrawSpecialChar(char c, int field, int cx, int cy, bool bold = false); - - // Draws the dir/dist field at the bottom of the main field - void DrawDirDistField(double lat, double lon, int field, int px, int py, bool to_flag = true, bool cursel = false); - // - //--------------------------------- end char units ----------------------------------------------- - - //----------------------- Drawing functions which take PIXEL units ------------------------------ - // - // Takes instrument *pixel* co-ordinates NOT character units - // Position is specified by the bottom of the *visible* portion, by default the left position unless align_right is true. - // The return value is the pixel width of the visible portion - int DrawSmallChar(char c, int x, int y, bool align_right = false); - - void DrawFreeChar(char c, int x, int y, bool draw_background = false); - // - //----------------------------------- end pixel unit functions ----------------------------------- - - void DrawDivider(); - - void DrawEnt(int field = 1, int px = 0, int py = 1); - - void DrawMessageAlert(); - - void DrawKPH(int field, int cx, int cy); - - void DrawDTO(int field, int cx, int cy); - - // Draw the bar that indicates which page we're on (zero-based) - void DrawBar(int page); - - void DrawCDI(); - - void DrawLegTail(int py); - void DrawLongLegTail(int py); - void DrawHalfLegTail(int py); - - void UpdateMapHeading(); - - // Draw the moving map - // Apt, VOR and SUA drawing can be suspended by setting draw_avs to false, without affecting the stored drawing preference state. - void DrawMap(bool draw_avs = true); - - // Set whether the display should be drawn pixelated (more primitives, but might be closer to real-life) - // or not (in which case it is assumed that pixels are square and can be merged into quads). - bool _pixelated; - - // Flashing output should be hidden when blink is true - bool _blink; - - double _cum_dt; - - // In Crsr mode, CRSR pressed events are passed to the active page, in disp mode they change which page is active - KLN89Mode _mode; - // And the facility to save a mode - KLN89Mode _lastMode; - - // Increment/Decrement a character in the KLN89 A-Z,0-9 scheme. - // Set gap to true to get a space between A and 9 when wrapping, set wrap to false to disable wrap. - char IncChar(char c, bool gap = false, bool wrap = true); - char DecChar(char c, bool gap = false, bool wrap = true); + void DrawLatitude(double d, int field, int px, int py); + void DrawLongitude(double d, int field, int px, int py); - // ==================== Page organisation stuff ============= - // The list of cyclical pages that the user can cycle through - kln89_page_list_type _pages; - - // The currently active page - KLN89Page* _activePage; - // And a facility to save the immediately preceding active page - KLN89Page* _lastActivePage; - - // Ugly hack. Housekeeping to allow us to temporarily display one page, while remembering which - // other page to "jump" back to. Used when the waypoint pages are used to review waypoint entry - // from the flightplan page. - int _entJump; // The page to jump back to if ENT is pressed. -1 indicates no jump. - int _clrJump; // The page to jump back to if CLR is pressed. -1 indicates no jump. - bool _jumpRestoreCrsr; // Indicates that jump back at this point should restore cursor mode. - - // Misc pages that aren't in the cyclic list. - // ALT - KLN89Page* _alt_page; - // Direct To - KLN89Page* _dir_page; - // Nearest - KLN89Page* _nrst_page; - // ====================== end of page stuff =================== - - // Moving-map display stuff - int _mapOrientation; // 0 => North (true) up, 1 => DTK up, 2 => TK up, 3 => heading up (only when connected to external heading source). - double _mapHeading; // Degrees. The actual map heading gets updated at a lower frequency than DrawMap() is called at, hence we need to store it. - double _mapHeadingUpdateTimer; // Timer to determine when to update the above. - bool _mapScaleAuto; // Indicates that map should autoscale when true. - int _mapScaleIndex; // Index into array of available map scales. - int _mapScaleUnits; // 0 => nm, 1 => km. - double _mapScale; // nm or km from aircraft position to top of map. - // Note that aircraft position differs depending on orientation, but 'scale' retains the same meaning, - // so the scale per pixel alters to suit the defined scale when the rendered aircraft position changes. - bool _drawSUA; // special user airspace - bool _drawVOR; - bool _drawApt; - - // Convert map to instrument coordinates - void MapToInstrument(int &x, int &y); - - // The following map drawing functions all take MAP co-ordinates, NOT instrument co-ordinates! - - // Draw the diamond style of user pos - void DrawUser1(int x, int y); + // Draw a frequency as xxx.xx + void DrawFreq(double d, int field, int px, int py); - // Draw the airplane style of user pos - void DrawUser2(int x, int y); - - // Draw an airport symbol on the moving map - void DrawApt(int x, int y); - - // Draw a waypoint on the moving map - void DrawWaypoint(int x, int y); - - // Draw a VOR on the moving map - void DrawVOR(int x, int y); - - // Draw an airport or waypoint label on the moving map - // Specify position by the map pixel co-ordinate of the left or right, bottom, of the *visible* portion of the label. - // The black background quad will automatically overlap this by 1 pixel. - void DrawLabel(const std::string& s, int x1, int y1, bool right_align = false); - - int GetLabelQuadrant(double h); - int GetLabelQuadrant(double h1, double h2); - - // Draw a line on the moving map - void DrawLine(int x1, int y1, int x2, int y2); - - // Draw normal sized text on the moving map - void DrawMapText(const std::string& s, int x, int y, bool draw_background = false); - - void DrawMapUpArrow(int x, int y); - - // Draw a Quad on the moving map - void DrawMapQuad(int x1, int y1, int x2, int y2, bool invert = false); - - // Airport town and state mapped by ID, since currently FG does not store this - airport_id_str_map_type _airportTowns; - airport_id_str_map_type _airportStates; - - // NOTE - It is a deliberate decision not to have a proper message page class, - // since button events get directed to the page that was active before the - // message was displayed, not the message page itself. - bool _dispMsg; // Set true while the message page is being displayed - - // Sometimes the datapages can be used to review a waypoint whilst the user makes a decision, - // and we need to remember why. - bool _dtoReview; // Set true when we a reviewing a waypoint for DTO operation. - - // Configuration settings that the user can set via. the KLN89 SET pages. - KLN89SpeedUnits _velUnits; - KLN89DistanceUnits _distUnits; - KLN89PressureUnits _baroUnits; - KLN89AltitudeUnits _altUnits; - bool _suaAlertEnabled; // Alert user to potential SUA entry - bool _altAlertEnabled; // Alert user to min safe alt violation - int _minDisplayBrightness; // Minimum display brightness in low light. - char _defaultFirstChar; // Default first waypoint character. - - // The user-settable barometric pressure. - // This can be set in the range 22.00 -> 32.99", or 745 -> 1117mB/hPa. - // For user input, we maintain a single integer value that is either between 2200 and 3299 (") - // or between 745 and 1117 (mB/hPa). It gets converted from one to the other only when the - // units are changed. - // For internal VNAV calculations (which we don't currently do) this will be converted to a floating - // point value before use. - int _userBaroSetting; + // Draw a time in seconds as hh:mm + // NOTE: px is RIGHT JUSTIFIED! + void DrawTime(double time, int field, int px, int py); + + // Draw an integer heading, where px specifies the position of the degrees sign at the RIGHT of the value. + void DrawHeading(int h, int field, int px, int py); + + // Draw a distance spec'd as nm as an integer (TODO - may need 1 decimal place if < 100) where px specifies RHS of units. + // Some uses definately don't want decimal place though (as at present), so would have to be arg. + void DrawDist(double d, int field, int px, int py); + + // Draw a speed specifed in knots. px is RHS of the units. Can draw up to 2 decimal places. + void DrawSpeed(double v, int field, int px, int py, int decimals = 0); + + void Underline(int field, int px, int py, int len); + + // Render a char at a given position as above (position in CHARACTER units) + void DrawChar(char c, int field, int px, int py, bool bold = false, bool invert = false); + void DrawSpecialChar(char c, int field, int cx, int cy, bool bold = false); + + // Draws the dir/dist field at the bottom of the main field + void DrawDirDistField(double lat, double lon, int field, int px, int py, bool to_flag = true, bool cursel = false); + // + //--------------------------------- end char units ----------------------------------------------- + + //----------------------- Drawing functions which take PIXEL units ------------------------------ + // + // Takes instrument *pixel* co-ordinates NOT character units + // Position is specified by the bottom of the *visible* portion, by default the left position unless align_right is true. + // The return value is the pixel width of the visible portion + int DrawSmallChar(char c, int x, int y, bool align_right = false); + + void DrawFreeChar(char c, int x, int y, bool draw_background = false); + // + //----------------------------------- end pixel unit functions ----------------------------------- + + void DrawDivider(); + + void DrawEnt(int field = 1, int px = 0, int py = 1); + + void DrawMessageAlert(); + + void DrawKPH(int field, int cx, int cy); + + void DrawDTO(int field, int cx, int cy); + + // Draw the bar that indicates which page we're on (zero-based) + void DrawBar(int page); + + void DrawCDI(); + + void DrawLegTail(int py); + void DrawLongLegTail(int py); + void DrawHalfLegTail(int py); + + void UpdateMapHeading(); + + // Draw the moving map + // Apt, VOR and SUA drawing can be suspended by setting draw_avs to false, without affecting the stored drawing preference state. + void DrawMap(bool draw_avs = true); + + // Set whether the display should be drawn pixelated (more primitives, but might be closer to real-life) + // or not (in which case it is assumed that pixels are square and can be merged into quads). + bool _pixelated; + + // Flashing output should be hidden when blink is true + bool _blink; + + double _cum_dt; + + // In Crsr mode, CRSR pressed events are passed to the active page, in disp mode they change which page is active + KLN89Mode _mode; + // And the facility to save a mode + KLN89Mode _lastMode; + + // Increment/Decrement a character in the KLN89 A-Z,0-9 scheme. + // Set gap to true to get a space between A and 9 when wrapping, set wrap to false to disable wrap. + char IncChar(char c, bool gap = false, bool wrap = true); + char DecChar(char c, bool gap = false, bool wrap = true); + + // ==================== Page organisation stuff ============= + // The list of cyclical pages that the user can cycle through + kln89_page_list_type _pages; + + // The currently active page + KLN89Page* _activePage; + // And a facility to save the immediately preceding active page + KLN89Page* _lastActivePage; + + // Ugly hack. Housekeeping to allow us to temporarily display one page, while remembering which + // other page to "jump" back to. Used when the waypoint pages are used to review waypoint entry + // from the flightplan page. + int _entJump; // The page to jump back to if ENT is pressed. -1 indicates no jump. + int _clrJump; // The page to jump back to if CLR is pressed. -1 indicates no jump. + bool _jumpRestoreCrsr; // Indicates that jump back at this point should restore cursor mode. + + // Misc pages that aren't in the cyclic list. + // ALT + KLN89Page* _alt_page; + // Direct To + KLN89Page* _dir_page; + // Nearest + KLN89Page* _nrst_page; + // ====================== end of page stuff =================== + + // Moving-map display stuff + int _mapOrientation; // 0 => North (true) up, 1 => DTK up, 2 => TK up, 3 => heading up (only when connected to external heading source). + double _mapHeading; // Degrees. The actual map heading gets updated at a lower frequency than DrawMap() is called at, hence we need to store it. + double _mapHeadingUpdateTimer; // Timer to determine when to update the above. + bool _mapScaleAuto; // Indicates that map should autoscale when true. + int _mapScaleIndex; // Index into array of available map scales. + int _mapScaleUnits; // 0 => nm, 1 => km. + double _mapScale; // nm or km from aircraft position to top of map. + // Note that aircraft position differs depending on orientation, but 'scale' retains the same meaning, + // so the scale per pixel alters to suit the defined scale when the rendered aircraft position changes. + bool _drawSUA; // special user airspace + bool _drawVOR; + bool _drawApt; + + // Convert map to instrument coordinates + void MapToInstrument(int &x, int &y); + + // The following map drawing functions all take MAP co-ordinates, NOT instrument co-ordinates! + + // Draw the diamond style of user pos + void DrawUser1(int x, int y); + + // Draw the airplane style of user pos + void DrawUser2(int x, int y); + + // Draw an airport symbol on the moving map + void DrawApt(int x, int y); + + // Draw a waypoint on the moving map + void DrawWaypoint(int x, int y); + + // Draw a VOR on the moving map + void DrawVOR(int x, int y); + + // Draw an airport or waypoint label on the moving map + // Specify position by the map pixel co-ordinate of the left or right, bottom, of the *visible* portion of the label. + // The black background quad will automatically overlap this by 1 pixel. + void DrawLabel(const std::string& s, int x1, int y1, bool right_align = false); + + int GetLabelQuadrant(double h); + int GetLabelQuadrant(double h1, double h2); + + // Draw a line on the moving map + void DrawLine(int x1, int y1, int x2, int y2); + + // Draw normal sized text on the moving map + void DrawMapText(const std::string& s, int x, int y, bool draw_background = false); + + void DrawMapUpArrow(int x, int y); + + // Draw a Quad on the moving map + void DrawMapQuad(int x1, int y1, int x2, int y2, bool invert = false); + + // Airport town and state mapped by ID, since currently FG does not store this + airport_id_str_map_type _airportTowns; + airport_id_str_map_type _airportStates; + + // NOTE - It is a deliberate decision not to have a proper message page class, + // since button events get directed to the page that was active before the + // message was displayed, not the message page itself. + bool _dispMsg; // Set true while the message page is being displayed + + // Sometimes the datapages can be used to review a waypoint whilst the user makes a decision, + // and we need to remember why. + bool _dtoReview; // Set true when we a reviewing a waypoint for DTO operation. + + // Configuration settings that the user can set via. the KLN89 SET pages. + KLN89SpeedUnits _velUnits; + KLN89DistanceUnits _distUnits; + KLN89PressureUnits _baroUnits; + KLN89AltitudeUnits _altUnits; + bool _suaAlertEnabled; // Alert user to potential SUA entry + bool _altAlertEnabled; // Alert user to min safe alt violation + int _minDisplayBrightness; // Minimum display brightness in low light. + char _defaultFirstChar; // Default first waypoint character. + + // The user-settable barometric pressure. + // This can be set in the range 22.00 -> 32.99", or 745 -> 1117mB/hPa. + // For user input, we maintain a single integer value that is either between 2200 and 3299 (") + // or between 745 and 1117 (mB/hPa). It gets converted from one to the other only when the + // units are changed. + // For internal VNAV calculations (which we don't currently do) this will be converted to a floating + // point value before use. + int _userBaroSetting; }; #endif // _KLN89_HXX diff --git a/src/Instrumentation/adf.hxx b/src/Instrumentation/adf.hxx index 56a491bcd..6877d82d9 100644 --- a/src/Instrumentation/adf.hxx +++ b/src/Instrumentation/adf.hxx @@ -39,9 +39,7 @@ class SGSampleGroup; */ class ADF : public AbstractInstrument { - public: - ADF ( SGPropertyNode *node ); virtual ~ADF (); @@ -49,7 +47,6 @@ public: virtual void update (double delta_time_sec); private: - void set_bearing (double delta_time_sec, double bearing); void search (double frequency, const SGGeod& pos); @@ -82,5 +79,4 @@ private: SGSharedPtr _sgr; }; - #endif // __INSTRUMENTS_ADF_HXX diff --git a/src/Instrumentation/airspeed_indicator.hxx b/src/Instrumentation/airspeed_indicator.hxx index 1df6fe09b..91aa26664 100644 --- a/src/Instrumentation/airspeed_indicator.hxx +++ b/src/Instrumentation/airspeed_indicator.hxx @@ -36,9 +36,7 @@ class FGEnvironmentMgr; */ class AirspeedIndicator : public SGSubsystem { - public: - AirspeedIndicator ( SGPropertyNode *node ); virtual ~AirspeedIndicator (); @@ -58,7 +56,7 @@ private: double _ias_limit; double _mach_limit; double _alt_threshold; - + SGPropertyNode_ptr _ias_limit_node; SGPropertyNode_ptr _mach_limit_node; SGPropertyNode_ptr _alt_threshold_node; @@ -71,7 +69,7 @@ private: SGPropertyNode_ptr _pressure_alt; SGPropertyNode_ptr _mach_node; SGPropertyNode_ptr _tas_node; - + FGEnvironmentMgr* _environmentManager; }; diff --git a/src/Instrumentation/altimeter.hxx b/src/Instrumentation/altimeter.hxx index 45c3a4e61..d8da96a6c 100644 --- a/src/Instrumentation/altimeter.hxx +++ b/src/Instrumentation/altimeter.hxx @@ -29,9 +29,7 @@ */ class Altimeter : public SGSubsystem { - public: - Altimeter (SGPropertyNode *node, const std::string& aDefaultName, double quantum = 0); virtual ~Altimeter (); @@ -58,7 +56,7 @@ private: double _settingInHg; bool _encodeModeC; bool _encodeModeS; - + SGPropertyNode_ptr _serviceable_node; SGPropertyNode_ptr _pressure_node; SGPropertyNode_ptr _press_alt_node; diff --git a/src/Instrumentation/attitude_indicator.hxx b/src/Instrumentation/attitude_indicator.hxx index 14453511d..f75cc6a07 100644 --- a/src/Instrumentation/attitude_indicator.hxx +++ b/src/Instrumentation/attitude_indicator.hxx @@ -38,9 +38,7 @@ */ class AttitudeIndicator : public SGSubsystem { - public: - AttitudeIndicator ( SGPropertyNode *node ); virtual ~AttitudeIndicator (); @@ -51,7 +49,6 @@ public: virtual void update (double dt); private: - std::string _name; int _num; std::string _suction; diff --git a/src/Instrumentation/clock.hxx b/src/Instrumentation/clock.hxx index f4fcba846..88567ff00 100644 --- a/src/Instrumentation/clock.hxx +++ b/src/Instrumentation/clock.hxx @@ -26,7 +26,8 @@ * /instrumentation/clock/indicated-sec * /instrumentation/clock/indicated-string */ -class Clock : public SGSubsystem { +class Clock : public SGSubsystem +{ public: Clock(SGPropertyNode *node); virtual ~Clock(); diff --git a/src/Instrumentation/commradio.cxx b/src/Instrumentation/commradio.cxx index 784f60585..b7f2dd33c 100644 --- a/src/Instrumentation/commradio.cxx +++ b/src/Instrumentation/commradio.cxx @@ -454,40 +454,40 @@ private: /* ------------- The CommRadio implementation ---------------------- */ -class CommRadioImpl: public CommRadio, OutputProperties { - +class CommRadioImpl: public CommRadio, + OutputProperties +{ public: - CommRadioImpl(SGPropertyNode_ptr node); - virtual ~CommRadioImpl(); + CommRadioImpl(SGPropertyNode_ptr node); + virtual ~CommRadioImpl(); - void update(double dt) override; - void init() override; - void bind() override; - void unbind() override; + void update(double dt) override; + void init() override; + void bind() override; + void unbind() override; private: - bool _useEightPointThree = false; - MetarBridgeRef _metarBridge; - AtisSpeaker _atisSpeaker; - SGSharedPtr _useFrequencyFormatter; - SGSharedPtr _stbyFrequencyFormatter; - const SignalQualityComputerRef _signalQualityComputer; + bool _useEightPointThree = false; + MetarBridgeRef _metarBridge; + AtisSpeaker _atisSpeaker; + SGSharedPtr _useFrequencyFormatter; + SGSharedPtr _stbyFrequencyFormatter; + const SignalQualityComputerRef _signalQualityComputer; - double _stationTTL = 0.0; - double _frequency = -1.0; - flightgear::CommStationRef _commStationForFrequency; + double _stationTTL = 0.0; + double _frequency = -1.0; + flightgear::CommStationRef _commStationForFrequency; - PropertyObject _volume_norm; - PropertyObject _atis; - PropertyObject _addNoise; - PropertyObject _cutoffSignalQuality; - - std::string _soundPrefix; - void stopAudio(); - void updateAudio(); - - SGSampleGroup* _sampleGroup = nullptr; + PropertyObject _volume_norm; + PropertyObject _atis; + PropertyObject _addNoise; + PropertyObject _cutoffSignalQuality; + std::string _soundPrefix; + void stopAudio(); + void updateAudio(); + + SGSampleGroup* _sampleGroup = nullptr; }; CommRadioImpl::CommRadioImpl(SGPropertyNode_ptr node) : diff --git a/src/Instrumentation/commradio.hxx b/src/Instrumentation/commradio.hxx index 827b1c535..e3bdeb5ae 100644 --- a/src/Instrumentation/commradio.hxx +++ b/src/Instrumentation/commradio.hxx @@ -28,10 +28,11 @@ namespace Instrumentation { -class SignalQualityComputer : public SGReferenced { +class SignalQualityComputer : public SGReferenced +{ public: - virtual ~SignalQualityComputer(); - virtual double computeSignalQuality( double distance_nm ) const = 0; + virtual ~SignalQualityComputer(); + virtual double computeSignalQuality( double distance_nm ) const = 0; }; typedef SGSharedPtr SignalQualityComputerRef; @@ -39,7 +40,7 @@ typedef SGSharedPtr SignalQualityComputerRef; class CommRadio : public AbstractInstrument { public: - static SGSubsystem * createInstance( SGPropertyNode_ptr rootNode ); + static SGSubsystem * createInstance( SGPropertyNode_ptr rootNode ); }; } diff --git a/src/Instrumentation/dclgps.hxx b/src/Instrumentation/dclgps.hxx index 4febcd64e..f0c72873d 100644 --- a/src/Instrumentation/dclgps.hxx +++ b/src/Instrumentation/dclgps.hxx @@ -51,20 +51,20 @@ class FGFix; // NOTE - ORDERING IS IMPORTANT HERE - it matches the Bendix-King page ordering! enum GPSWpType { - GPS_WP_APT = 0, - GPS_WP_VOR, - GPS_WP_NDB, - GPS_WP_INT, - GPS_WP_USR, - GPS_WP_VIRT // Used for virtual waypoints, such as the start of DTO operation. + GPS_WP_APT = 0, + GPS_WP_VOR, + GPS_WP_NDB, + GPS_WP_INT, + GPS_WP_USR, + GPS_WP_VIRT // Used for virtual waypoints, such as the start of DTO operation. }; enum GPSAppWpType { - GPS_IAF, // Initial approach fix - GPS_IAP, // Waypoint on approach sequence that isn't any of the others. - GPS_FAF, // Final approach fix - GPS_MAP, // Missed approach point - GPS_MAHP, // Initial missed approach holding point. + GPS_IAF, // Initial approach fix + GPS_IAP, // Waypoint on approach sequence that isn't any of the others. + GPS_FAF, // Final approach fix + GPS_MAP, // Missed approach point + GPS_MAHP, // Initial missed approach holding point. GPS_HDR, // A virtual 'waypoint' to represent the approach header in the fpl page GPS_FENCE, // A virtual 'waypoint' to represent the NO WPT SEQ fence. GPS_APP_NONE // Not part of the approach sequence - the default. @@ -74,18 +74,18 @@ std::ostream& operator << (std::ostream& os, GPSAppWpType type); struct GPSWaypoint { GPSWaypoint(); - - GPSWaypoint(const std::string& aIdent, float lat, float lon, GPSWpType aType); - - static GPSWaypoint* createFromPositioned(const FGPositioned* aFix); - + + GPSWaypoint(const std::string& aIdent, float lat, float lon, GPSWpType aType); + + static GPSWaypoint* createFromPositioned(const FGPositioned* aFix); + ~GPSWaypoint(); - std::string GetAprId(); // Returns the id with i, f, m or h added if appropriate. (Initial approach fix, final approach fix, etc) - std::string id; - float lat; // Radians - float lon; // Radians - GPSWpType type; - GPSAppWpType appType; // only used for waypoints that are part of an approach sequence + std::string GetAprId(); // Returns the id with i, f, m or h added if appropriate. (Initial approach fix, final approach fix, etc) + std::string id; + float lat; // Radians + float lon; // Radians + GPSWpType type; + GPSAppWpType appType; // only used for waypoints that are part of an approach sequence }; typedef std::vector < GPSWaypoint* > gps_waypoint_array; @@ -94,56 +94,60 @@ typedef std::map < std::string, gps_waypoint_array > gps_waypoint_map; typedef gps_waypoint_map::iterator gps_waypoint_map_iterator; typedef gps_waypoint_map::const_iterator gps_waypoint_map_const_iterator; -class GPSFlightPlan { +class GPSFlightPlan +{ public: - std::vector waypoints; - inline bool IsEmpty() { return waypoints.empty(); } + std::vector waypoints; + inline bool IsEmpty() { return waypoints.empty(); } }; // TODO - probably de-public the internals of the next 2 classes and add some methods! // Instrument approach procedure base class -class FGIAP { +class FGIAP +{ public: - FGIAP(); - virtual ~FGIAP() = 0; -//protected: + FGIAP(); + virtual ~FGIAP() = 0; - std::string _aptIdent; // The ident of the airport this approach is for - std::string _ident; // The approach ident. - std::string _name; // The full approach name. - std::string _rwyStr; // The string used to specify the rwy - eg "B" in this instance. - bool _precision; // True for precision approach, false for non-precision. +//protected: + std::string _aptIdent; // The ident of the airport this approach is for + std::string _ident; // The approach ident. + std::string _name; // The full approach name. + std::string _rwyStr; // The string used to specify the rwy - eg "B" in this instance. + bool _precision; // True for precision approach, false for non-precision. }; // Non-precision instrument approach procedure -class FGNPIAP : public FGIAP { +class FGNPIAP : public FGIAP +{ public: - FGNPIAP(); - ~FGNPIAP(); + FGNPIAP(); + ~FGNPIAP(); + //private: public: - std::vector _approachRoutes; // The approach route(s) from the IAF(s) to the IF. - // NOTE: It is an assumption in the code that uses this that there is a unique IAF per approach route. - std::vector _IAP; // The compulsory waypoints of the approach procedure (may duplicate one of the above). - // _IAP includes the FAF and MAF, and the missed approach waypoints. + std::vector _approachRoutes; // The approach route(s) from the IAF(s) to the IF. + // NOTE: It is an assumption in the code that uses this that there is a unique IAF per approach route. + std::vector _IAP; // The compulsory waypoints of the approach procedure (may duplicate one of the above). + // _IAP includes the FAF and MAF, and the missed approach waypoints. }; typedef std::vector < FGIAP* > iap_list_type; typedef std::map < std::string, iap_list_type > iap_map_type; typedef iap_map_type::iterator iap_map_iterator; -// A class to encapsulate hr:min representation of time. - -class ClockTime { +// A class to encapsulate hr:min representation of time. +class ClockTime +{ public: ClockTime(); ClockTime(int hr, int min); ~ClockTime(); inline void set_hr(int hr) { _hr = hr; } - inline int hr() const { return(_hr); } + inline int hr() const { return(_hr); } inline void set_min(int min) { _min = min; } inline int min() const { return(_min); } - + ClockTime operator+ (const ClockTime& t) { int cumMin = _hr * 60 + _min + t.hr() * 60 + t.min(); ClockTime t2(cumMin / 60, cumMin % 60); @@ -168,8 +172,8 @@ private: // AlignedProjection - a class to project an area local to a runway onto an orthogonal co-ordinate system // with the origin at the threshold and the runway aligned with the y axis. -class AlignedProjection { - +class AlignedProjection +{ public: AlignedProjection(); AlignedProjection(const SGGeod& centre, double heading); @@ -184,311 +188,312 @@ public: SGGeod ConvertFromLocal(const SGVec3d& pt); private: - SGGeod _origin; // lat/lon of local area origin (the threshold) - double _theta; // the rotation angle for alignment in radians - double _correction_factor; // Reduction in surface distance per degree of longitude due to latitude. Saves having to do a cos() every call. - + SGGeod _origin; // lat/lon of local area origin (the threshold) + double _theta; // the rotation angle for alignment in radians + double _correction_factor; // Reduction in surface distance per degree of longitude due to latitude. Saves having to do a cos() every call. }; // ------------------------------------------------------------------------------ // TODO - merge generic GPS functions instead and split out KLN specific stuff. -class DCLGPS : public SGSubsystem { - +class DCLGPS : public SGSubsystem +{ public: - DCLGPS(RenderArea2D* instrument); - virtual ~DCLGPS() = 0; - - virtual void draw(osg::State& state); - - virtual void init(); - virtual void bind(); - virtual void unbind(); - virtual void update(double dt); - - // Expand a SIAP ident to the full procedure name. - std::string ExpandSIAPIdent(const std::string& ident); + DCLGPS(RenderArea2D* instrument); + virtual ~DCLGPS() = 0; - // Render string s in display field field at position x, y - // WHERE POSITION IS IN CHARACTER UNITS! - // zero y at bottom? - virtual void DrawText(const std::string& s, int field, int px, int py, bool bold = false); - - // Render a char at a given position as above - virtual void DrawChar(char c, int field, int px, int py, bool bold = false); - - virtual void ToggleOBSMode(); - - // Set the number of fields - inline void SetNumFields(int n) { _nFields = (n > _maxFields ? _maxFields : (n < 1 ? 1 : n)); } - - // It is expected that specific GPS units will override these functions. - // Increase the CDI full-scale deflection (ie. increase the nm per dot) one (GPS unit dependent) increment. Wraps if necessary (GPS unit dependent). - virtual void CDIFSDIncrease(); - // Ditto for decrease the distance per dot - virtual void CDIFSDDecrease(); - - // Host specifc - ////inline void SetOverlays(Overlays* overlays) { _overlays = overlays; } - - virtual void CreateDefaultFlightPlans(); - - void SetOBSFromWaypoint(); - - GPSWaypoint* GetActiveWaypoint(); - // Get the (zero-based) position of the active waypoint in the active flightplan - // Returns -1 if no active waypoint. - int GetActiveWaypointIndex(); - // Ditto for an arbitrary waypoint id - int GetWaypointIndex(const std::string& id); - - // Returns meters - float GetDistToActiveWaypoint(); - // Returns degrees (magnetic) - float GetHeadingToActiveWaypoint(); - // Returns degrees (magnetic) - float GetHeadingFromActiveWaypoint(); - // Get the time to the active waypoint in seconds. - // Returns -1 if groundspeed < 30 kts - double GetTimeToActiveWaypoint(); - // Get the time to the final waypoint in seconds. - // Returns -1 if groundspeed < 30 kts - double GetETE(); - // Get the time to a given waypoint (spec'd by ID) in seconds. - // returns -1 if groundspeed is less than 30kts. - // If the waypoint is an unreached part of the active flight plan the time will be via each leg. - // otherwise it will be a direct-to time. - double GetTimeToWaypoint(const std::string& id); - - // Return true if waypoint alerting is occuring - inline bool GetWaypointAlert() const { return(_waypointAlert); } - // Return true if in OBS mode - inline bool GetOBSMode() const { return(_obsMode); } - // Return true if in Leg mode - inline bool GetLegMode() const { return(!_obsMode); } - - // Clear a flightplan - void ClearFlightPlan(int n); - void ClearFlightPlan(GPSFlightPlan* fp); - - // Returns true if an approach is loaded/armed/active in the active flight plan - inline bool ApproachLoaded() const { return(_approachLoaded); } - inline bool GetApproachArm() const { return(_approachArm); } - inline bool GetApproachActive() const { return(_approachActive); } - double GetCDIDeflection() const; - inline bool GetToFlag() const { return(_headingBugTo); } - - // Initiate Direct To operation to the supplied ID. - virtual void DtoInitiate(const std::string& id); - // Cancel Direct To operation - void DtoCancel(); - -protected: - // Maximum number of display fields for this device - int _maxFields; - // Current number of on-screen fields - int _nFields; - // Full x border - int _xBorder; - // Full y border - int _yBorder; - // Lower (y) border per field - int _yFieldBorder[4]; - // Left (x) border per field - int _xFieldBorder[4]; - // Field start in x dir (border is part of field since it is the normal char border - sometimes map mode etc draws in it) - int _xFieldStart[4]; - // Field start in y dir (for completeness - KLN89 only has vertical divider. - int _yFieldStart[4]; - - // The number of pages on the cyclic knob control - unsigned int _nPages; - // The current page we're on (Not sure how this ties in with extra pages such as direct or nearest). - unsigned int _curPage; - - // 2D rendering area - RenderArea2D* _instrument; - - // CDI full-scale deflection, specified either as an index into a vector of values (standard values) or as a double precision float (intermediate values). - // This will influence how an externally driven CDI will display as well as the NAV1 page. - // Hence the variables are located here, not in the nav page class. - std::vector _cdiScales; - unsigned int _currentCdiScaleIndex; - bool _cdiScaleTransition; // Set true when the floating CDI value is used during transitions - double _currentCdiScale; // The floating value to use. - unsigned int _targetCdiScaleIndex; // The target indexed value to attain during a transition. - unsigned int _sourceCdiScaleIndex; // The source indexed value during a transition - so we know which way we're heading! - // Timers to handle the transitions - not sure if we need these. - double _apprArmTimer; - double _apprActvTimer; - double _cdiTransitionTime; // Time for transition to occur in - normally 30sec but may be quicker if time to FAF < 30sec? - // - - // Data and lookup functions + virtual void draw(osg::State& state); + virtual void init(); + virtual void bind(); + virtual void unbind(); + virtual void update(double dt); + + // Expand a SIAP ident to the full procedure name. + std::string ExpandSIAPIdent(const std::string& ident); + + // Render string s in display field field at position x, y + // WHERE POSITION IS IN CHARACTER UNITS! + // zero y at bottom? + virtual void DrawText(const std::string& s, int field, int px, int py, bool bold = false); + + // Render a char at a given position as above + virtual void DrawChar(char c, int field, int px, int py, bool bold = false); + + virtual void ToggleOBSMode(); + + // Set the number of fields + inline void SetNumFields(int n) { _nFields = (n > _maxFields ? _maxFields : (n < 1 ? 1 : n)); } + + // It is expected that specific GPS units will override these functions. + // Increase the CDI full-scale deflection (ie. increase the nm per dot) one (GPS unit dependent) increment. Wraps if necessary (GPS unit dependent). + virtual void CDIFSDIncrease(); + // Ditto for decrease the distance per dot + virtual void CDIFSDDecrease(); + + // Host specifc + ////inline void SetOverlays(Overlays* overlays) { _overlays = overlays; } + + virtual void CreateDefaultFlightPlans(); + + void SetOBSFromWaypoint(); + + GPSWaypoint* GetActiveWaypoint(); + // Get the (zero-based) position of the active waypoint in the active flightplan + // Returns -1 if no active waypoint. + int GetActiveWaypointIndex(); + // Ditto for an arbitrary waypoint id + int GetWaypointIndex(const std::string& id); + + // Returns meters + float GetDistToActiveWaypoint(); + // Returns degrees (magnetic) + float GetHeadingToActiveWaypoint(); + // Returns degrees (magnetic) + float GetHeadingFromActiveWaypoint(); + // Get the time to the active waypoint in seconds. + // Returns -1 if groundspeed < 30 kts + double GetTimeToActiveWaypoint(); + // Get the time to the final waypoint in seconds. + // Returns -1 if groundspeed < 30 kts + double GetETE(); + // Get the time to a given waypoint (spec'd by ID) in seconds. + // returns -1 if groundspeed is less than 30kts. + // If the waypoint is an unreached part of the active flight plan the time will be via each leg. + // otherwise it will be a direct-to time. + double GetTimeToWaypoint(const std::string& id); + + // Return true if waypoint alerting is occuring + inline bool GetWaypointAlert() const { return(_waypointAlert); } + // Return true if in OBS mode + inline bool GetOBSMode() const { return(_obsMode); } + // Return true if in Leg mode + inline bool GetLegMode() const { return(!_obsMode); } + + // Clear a flightplan + void ClearFlightPlan(int n); + void ClearFlightPlan(GPSFlightPlan* fp); + + // Returns true if an approach is loaded/armed/active in the active flight plan + inline bool ApproachLoaded() const { return(_approachLoaded); } + inline bool GetApproachArm() const { return(_approachArm); } + inline bool GetApproachActive() const { return(_approachActive); } + double GetCDIDeflection() const; + inline bool GetToFlag() const { return(_headingBugTo); } + + // Initiate Direct To operation to the supplied ID. + virtual void DtoInitiate(const std::string& id); + // Cancel Direct To operation + void DtoCancel(); protected: - void LoadApproachData(); + // Maximum number of display fields for this device + int _maxFields; + // Current number of on-screen fields + int _nFields; + // Full x border + int _xBorder; + // Full y border + int _yBorder; + // Lower (y) border per field + int _yFieldBorder[4]; + // Left (x) border per field + int _xFieldBorder[4]; + // Field start in x dir (border is part of field since it is the normal char border - sometimes map mode etc draws in it) + int _xFieldStart[4]; + // Field start in y dir (for completeness - KLN89 only has vertical divider. + int _yFieldStart[4]; - // Find first of any type of waypoint by id. (TODO - Possibly we should return multiple waypoints here). - GPSWaypoint* FindFirstById(const std::string& id) const; - GPSWaypoint* FindFirstByExactId(const std::string& id) const; - - FGNavRecord* FindFirstVorById(const std::string& id, bool &multi, bool exact = false); - FGNavRecord* FindFirstNDBById(const std::string& id, bool &multi, bool exact = false); - const FGAirport* FindFirstAptById(const std::string& id, bool &multi, bool exact = false); - const FGFix* FindFirstIntById(const std::string& id, bool &multi, bool exact = false); - // Find the closest VOR to a position in RADIANS. - FGNavRecord* FindClosestVor(double lat_rad, double lon_rad); + // The number of pages on the cyclic knob control + unsigned int _nPages; + // The current page we're on (Not sure how this ties in with extra pages such as direct or nearest). + unsigned int _curPage; - // helper to implement the above FindFirstXXX methods - FGPositioned* FindTypedFirstById(const std::string& id, FGPositioned::Type ty, bool &multi, bool exact); + // 2D rendering area + RenderArea2D* _instrument; - // Position, orientation and velocity. - // These should be read from FG's built-in GPS logic if possible. - // Use the property node pointers below to do this. + // CDI full-scale deflection, specified either as an index into a vector of values (standard values) or as a double precision float (intermediate values). + // This will influence how an externally driven CDI will display as well as the NAV1 page. + // Hence the variables are located here, not in the nav page class. + std::vector _cdiScales; + unsigned int _currentCdiScaleIndex; + bool _cdiScaleTransition; // Set true when the floating CDI value is used during transitions + double _currentCdiScale; // The floating value to use. + unsigned int _targetCdiScaleIndex; // The target indexed value to attain during a transition. + unsigned int _sourceCdiScaleIndex; // The source indexed value during a transition - so we know which way we're heading! + // Timers to handle the transitions - not sure if we need these. + double _apprArmTimer; + double _apprActvTimer; + double _cdiTransitionTime; // Time for transition to occur in - normally 30sec but may be quicker if time to FAF < 30sec? + // + + // Data and lookup functions + +protected: + void LoadApproachData(); + + // Find first of any type of waypoint by id. (TODO - Possibly we should return multiple waypoints here). + GPSWaypoint* FindFirstById(const std::string& id) const; + GPSWaypoint* FindFirstByExactId(const std::string& id) const; + + FGNavRecord* FindFirstVorById(const std::string& id, bool &multi, bool exact = false); + FGNavRecord* FindFirstNDBById(const std::string& id, bool &multi, bool exact = false); + const FGAirport* FindFirstAptById(const std::string& id, bool &multi, bool exact = false); + const FGFix* FindFirstIntById(const std::string& id, bool &multi, bool exact = false); + // Find the closest VOR to a position in RADIANS. + FGNavRecord* FindClosestVor(double lat_rad, double lon_rad); + + // helper to implement the above FindFirstXXX methods + FGPositioned* FindTypedFirstById(const std::string& id, FGPositioned::Type ty, bool &multi, bool exact); + + // Position, orientation and velocity. + // These should be read from FG's built-in GPS logic if possible. + // Use the property node pointers below to do this. SGPropertyNode_ptr _lon_node; SGPropertyNode_ptr _lat_node; SGPropertyNode_ptr _alt_node; - SGPropertyNode_ptr _grnd_speed_node; - SGPropertyNode_ptr _true_track_node; - SGPropertyNode_ptr _mag_track_node; - // Present position. (Radians) - double _lat, _lon; - // Present altitude (ft). (Yuk! but it saves converting ft->m->ft every update). - double _alt; - // Reported position as measured by GPS. For now this is the same - // as present position, but in the future we might want to model - // GPS lat and lon errors. - // Note - we can depriciate _gpsLat and _gpsLon if we implement error handling in FG - // gps code and not our own. - double _gpsLat, _gpsLon; //(Radians) - // Hack - it seems that the GPS gets initialised before FG's initial position is properly set. - // By checking for abnormal slew in the position we can force a re-initialisation of active flight - // plan leg and anything else that might be affected. - // TODO - sort FlightGear's initialisation order properly!!! - double _checkLat, _checkLon; // (Radians) - double _groundSpeed_ms; // filtered groundspeed (m/s) - double _groundSpeed_kts; // ditto in knots - double _track; // filtered true track (degrees) - double _magTrackDeg; // magnetic track in degrees calculated from true track above - - // _navFlagged is set true when GPS navigation is either not possible or not logical. - // This includes not receiving adequate signals, and not having an active flightplan entered. - bool _navFlagged; - - // Positional functions copied from ATCutils that might get replaced - // INPUT in RADIANS, returns DEGREES! - // Magnetic - double GetMagHeadingFromTo(double latA, double lonA, double latB, double lonB); - // True - //double GetHeadingFromTo(double latA, double lonA, double latB, double lonB); - - // Given two positions (lat & lon in RADIANS), get the HORIZONTAL separation (in meters) - //double GetHorizontalSeparation(double lat1, double lon1, double lat2, double lon2); - - // Proper great circle positional functions from The Aviation Formulary - // Returns distance in Nm, input in RADIANS. - double GetGreatCircleDistance(double lat1, double lon1, double lat2, double lon2) const; - - // Input in RADIANS, output in DEGREES. - // True - double GetGreatCircleCourse(double lat1, double lon1, double lat2, double lon2) const; - - // Return a position on a radial from wp1 given distance d (nm) and magnetic heading h (degrees) - // Note that d should be less that 1/4 Earth diameter! - GPSWaypoint GetPositionOnMagRadial(const GPSWaypoint& wp1, double d, double h); - - // Return a position on a radial from wp1 given distance d (nm) and TRUE heading h (degrees) - // Note that d should be less that 1/4 Earth diameter! - GPSWaypoint GetPositionOnRadial(const GPSWaypoint& wp1, double d, double h); - - // Calculate the current cross-track deviation in nm. - // Returns zero if a sensible value cannot be calculated. - double CalcCrossTrackDeviation() const; - - // Calculate the cross-track deviation between 2 arbitrary waypoints in nm. - // Returns zero if a sensible value cannot be calculated. - double CalcCrossTrackDeviation(const GPSWaypoint& wp1, const GPSWaypoint& wp2) const; - - // Flightplans - // GPS can have up to _maxFlightPlans flightplans stored, PLUS an active FP which may or my not be one of the stored ones. - // This is from KLN89, but is probably not far off the mark for most if not all GPS. - std::vector _flightPlans; - unsigned int _maxFlightPlans; - GPSFlightPlan* _activeFP; - - // Modes of operation. - // This is currently somewhat Bendix-King specific, but probably applies fundamentally to other units as well - // Mode defaults to leg, but is OBS if _obsMode is true. - bool _obsMode; - // _dto is set true for DTO operation - bool _dto; - // In leg mode, we need to know if we are displaying a from and to waypoint, or just the to waypoint (eg. when OBS mode is cancelled). - bool _fullLegMode; - // In OBS mode we need to know the set OBS heading - int _obsHeading; - - // Operational variables - GPSWaypoint _activeWaypoint; - GPSWaypoint _fromWaypoint; - float _dist2Act; - float _crosstrackDist; // UNITS ?????????? - double _eta; // ETA in SECONDS to active waypoint. - // Desired track for active leg, true and magnetic, in degrees - double _dtkTrue, _dtkMag; - bool _headingBugTo; // Set true when the heading bug is TO, false when FROM. - bool _waypointAlert; // Set true when waypoint alerting is happening. (This is a variable NOT a user-setting). - bool _departed; // Set when groundspeed first exceeds 30kts. - std::string _departureTimeString; // Ditto. - double _elapsedTime; // Elapsed time in seconds since departure - ClockTime _powerOnTime; // Time (hr:min) of unit power-up. - bool _powerOnTimerSet; // Indicates that we have set the above following power-up. - void SetPowerOnTimer(); + SGPropertyNode_ptr _grnd_speed_node; + SGPropertyNode_ptr _true_track_node; + SGPropertyNode_ptr _mag_track_node; + // Present position. (Radians) + double _lat, _lon; + // Present altitude (ft). (Yuk! but it saves converting ft->m->ft every update). + double _alt; + // Reported position as measured by GPS. For now this is the same + // as present position, but in the future we might want to model + // GPS lat and lon errors. + // Note - we can depriciate _gpsLat and _gpsLon if we implement error handling in FG + // gps code and not our own. + double _gpsLat, _gpsLon; //(Radians) + // Hack - it seems that the GPS gets initialised before FG's initial position is properly set. + // By checking for abnormal slew in the position we can force a re-initialisation of active flight + // plan leg and anything else that might be affected. + // TODO - sort FlightGear's initialisation order properly!!! + double _checkLat, _checkLon; // (Radians) + double _groundSpeed_ms; // filtered groundspeed (m/s) + double _groundSpeed_kts; // ditto in knots + double _track; // filtered true track (degrees) + double _magTrackDeg; // magnetic track in degrees calculated from true track above + + // _navFlagged is set true when GPS navigation is either not possible or not logical. + // This includes not receiving adequate signals, and not having an active flightplan entered. + bool _navFlagged; + + // Positional functions copied from ATCutils that might get replaced + // INPUT in RADIANS, returns DEGREES! + // Magnetic + double GetMagHeadingFromTo(double latA, double lonA, double latB, double lonB); + // True + //double GetHeadingFromTo(double latA, double lonA, double latB, double lonB); + + // Given two positions (lat & lon in RADIANS), get the HORIZONTAL separation (in meters) + //double GetHorizontalSeparation(double lat1, double lon1, double lat2, double lon2); + + // Proper great circle positional functions from The Aviation Formulary + // Returns distance in Nm, input in RADIANS. + double GetGreatCircleDistance(double lat1, double lon1, double lat2, double lon2) const; + + // Input in RADIANS, output in DEGREES. + // True + double GetGreatCircleCourse(double lat1, double lon1, double lat2, double lon2) const; + + // Return a position on a radial from wp1 given distance d (nm) and magnetic heading h (degrees) + // Note that d should be less that 1/4 Earth diameter! + GPSWaypoint GetPositionOnMagRadial(const GPSWaypoint& wp1, double d, double h); + + // Return a position on a radial from wp1 given distance d (nm) and TRUE heading h (degrees) + // Note that d should be less that 1/4 Earth diameter! + GPSWaypoint GetPositionOnRadial(const GPSWaypoint& wp1, double d, double h); + + // Calculate the current cross-track deviation in nm. + // Returns zero if a sensible value cannot be calculated. + double CalcCrossTrackDeviation() const; + + // Calculate the cross-track deviation between 2 arbitrary waypoints in nm. + // Returns zero if a sensible value cannot be calculated. + double CalcCrossTrackDeviation(const GPSWaypoint& wp1, const GPSWaypoint& wp2) const; + + // Flightplans + // GPS can have up to _maxFlightPlans flightplans stored, PLUS an active FP which may or my not be one of the stored ones. + // This is from KLN89, but is probably not far off the mark for most if not all GPS. + std::vector _flightPlans; + unsigned int _maxFlightPlans; + GPSFlightPlan* _activeFP; + + // Modes of operation. + // This is currently somewhat Bendix-King specific, but probably applies fundamentally to other units as well + // Mode defaults to leg, but is OBS if _obsMode is true. + bool _obsMode; + // _dto is set true for DTO operation + bool _dto; + // In leg mode, we need to know if we are displaying a from and to waypoint, or just the to waypoint (eg. when OBS mode is cancelled). + bool _fullLegMode; + // In OBS mode we need to know the set OBS heading + int _obsHeading; + + // Operational variables + GPSWaypoint _activeWaypoint; + GPSWaypoint _fromWaypoint; + float _dist2Act; + float _crosstrackDist; // UNITS ?????????? + double _eta; // ETA in SECONDS to active waypoint. + // Desired track for active leg, true and magnetic, in degrees + double _dtkTrue, _dtkMag; + bool _headingBugTo; // Set true when the heading bug is TO, false when FROM. + bool _waypointAlert; // Set true when waypoint alerting is happening. (This is a variable NOT a user-setting). + bool _departed; // Set when groundspeed first exceeds 30kts. + std::string _departureTimeString; // Ditto. + double _elapsedTime; // Elapsed time in seconds since departure + ClockTime _powerOnTime; // Time (hr:min) of unit power-up. + bool _powerOnTimerSet; // Indicates that we have set the above following power-up. + void SetPowerOnTimer(); + public: - void ResetPowerOnTimer(); - // Set the alarm to go off at a given time. - inline void SetAlarm(int hr, int min) { - _alarmTime.set_hr(hr); - _alarmTime.set_min(min); - _alarmSet = true; - } + void ResetPowerOnTimer(); + // Set the alarm to go off at a given time. + inline void SetAlarm(int hr, int min) { + _alarmTime.set_hr(hr); + _alarmTime.set_min(min); + _alarmSet = true; + } + protected: - ClockTime _alarmTime; - bool _alarmSet; - - // Configuration that affects flightplan operation - bool _turnAnticipationEnabled; + ClockTime _alarmTime; + bool _alarmSet; - std::list _messageStack; + // Configuration that affects flightplan operation + bool _turnAnticipationEnabled; + + std::list _messageStack; + + virtual void CreateFlightPlan(GPSFlightPlan* fp, std::vector ids, std::vector wps); + + // Orientate the GPS unit to a flightplan - ie. figure out from current position + // and possibly orientation which leg of the FP we are on. + virtual void OrientateToFlightPlan(GPSFlightPlan* fp); + + // Ditto for active fp. Probably all we need really! + virtual void OrientateToActiveFlightPlan(); + + int _cleanUpPage; // -1 => no cleanup required. + + // IAP stuff + iap_map_type _np_iap; // Non-precision approaches + iap_map_type _pr_iap; // Precision approaches + bool _approachLoaded; // Set true when an approach is loaded in the active flightplan + bool _approachArm; // Set true when in approach-arm mode + bool _approachReallyArmed; // Apparently, approach-arm mode can be set from an external GPS-APR switch outside 30nm from airport, + // but the CDI scale change doesn't happen until 30nm from airport. Bizarre that it can be armed without + // the scale change, but it's in the manual... + bool _approachActive; // Set true when in approach-active mode + GPSFlightPlan* _approachFP; // Current approach - not necessarily loaded. + std::string _approachID; // ID of the airport we have an approach loaded for - bit of a hack that can hopefully be removed in future. + // More hackery since we aren't actually storing an approach class... Doh! + std::string _approachAbbrev; + std::string _approachRwyStr; - virtual void CreateFlightPlan(GPSFlightPlan* fp, std::vector ids, std::vector wps); - - // Orientate the GPS unit to a flightplan - ie. figure out from current position - // and possibly orientation which leg of the FP we are on. - virtual void OrientateToFlightPlan(GPSFlightPlan* fp); - - // Ditto for active fp. Probably all we need really! - virtual void OrientateToActiveFlightPlan(); - - int _cleanUpPage; // -1 => no cleanup required. - - // IAP stuff - iap_map_type _np_iap; // Non-precision approaches - iap_map_type _pr_iap; // Precision approaches - bool _approachLoaded; // Set true when an approach is loaded in the active flightplan - bool _approachArm; // Set true when in approach-arm mode - bool _approachReallyArmed; // Apparently, approach-arm mode can be set from an external GPS-APR switch outside 30nm from airport, - // but the CDI scale change doesn't happen until 30nm from airport. Bizarre that it can be armed without - // the scale change, but it's in the manual... - bool _approachActive; // Set true when in approach-active mode - GPSFlightPlan* _approachFP; // Current approach - not necessarily loaded. - std::string _approachID; // ID of the airport we have an approach loaded for - bit of a hack that can hopefully be removed in future. - // More hackery since we aren't actually storing an approach class... Doh! - std::string _approachAbbrev; - std::string _approachRwyStr; private: - simgear::TiedPropertyList _tiedProperties; + simgear::TiedPropertyList _tiedProperties; }; #endif // _DCLGPS_HXX diff --git a/src/Instrumentation/dme.hxx b/src/Instrumentation/dme.hxx index b69f53bd0..252a8232a 100644 --- a/src/Instrumentation/dme.hxx +++ b/src/Instrumentation/dme.hxx @@ -34,9 +34,7 @@ class FGNavRecord; */ class DME : public AbstractInstrument { - public: - DME ( SGPropertyNode *node ); virtual ~DME (); @@ -70,5 +68,4 @@ private: class AudioIdent * _audioIdent; }; - #endif // __INSTRUMENTS_DME_HXX diff --git a/src/Instrumentation/gps.hxx b/src/Instrumentation/gps.hxx index 87ebdab99..2e174cb78 100644 --- a/src/Instrumentation/gps.hxx +++ b/src/Instrumentation/gps.hxx @@ -31,7 +31,7 @@ * /environment/magnetic-variation-deg * /systems/electrical/outputs/gps * /instrumentation/gps/serviceable - * + * * * Output properties: * @@ -64,7 +64,7 @@ public: GPS (); virtual ~GPS (); - // SGSubsystem interface + // SGSubsystem interface virtual void init (); virtual void reinit (); virtual void update (double delta_time_sec); @@ -72,7 +72,7 @@ public: virtual void bind(); virtual void unbind(); - // RNAV interface + // RNAV interface virtual SGGeod position(); virtual double trackDeg(); virtual double groundSpeedKts(); @@ -93,51 +93,51 @@ private: class Config { public: - Config(); + Config(); - void bind(GPS* aOwner, SGPropertyNode* aCfg); + void bind(GPS* aOwner, SGPropertyNode* aCfg); - bool turnAnticipationEnabled() const { return _enableTurnAnticipation; } + bool turnAnticipationEnabled() const { return _enableTurnAnticipation; } - /** - * Desired turn rate in degrees/second. From this we derive the turn - * radius and hence how early we need to anticipate it. - */ - double turnRateDegSec() const { return _turnRate; } + /** + * Desired turn rate in degrees/second. From this we derive the turn + * radius and hence how early we need to anticipate it. + */ + double turnRateDegSec() const { return _turnRate; } - /** - * Distance at which we switch to next waypoint. - */ - double overflightDistanceNm() const { return _overflightDistance; } - /** - * Distance at which we arm overflight sequencing. Once inside this - * distance, a change of the wp1 'TO' flag to false will be considered - * overlight of the wp. - */ - double overflightArmDistanceNm() const { return _overflightArmDistance; } - /** - * abs angle at which we arm overflight sequencing. - */ - double overflightArmAngleDeg() const { return _overflightArmAngle; } + /** + * Distance at which we switch to next waypoint. + */ + double overflightDistanceNm() const { return _overflightDistance; } + /** + * Distance at which we arm overflight sequencing. Once inside this + * distance, a change of the wp1 'TO' flag to false will be considered + * overlight of the wp. + */ + double overflightArmDistanceNm() const { return _overflightArmDistance; } + /** + * abs angle at which we arm overflight sequencing. + */ + double overflightArmAngleDeg() const { return _overflightArmAngle; } - /** - * Time before the next WP to activate an external annunciator - */ - double waypointAlertTime() const { return _waypointAlertTime; } + /** + * Time before the next WP to activate an external annunciator + */ + double waypointAlertTime() const { return _waypointAlertTime; } - bool requireHardSurface() const { return _requireHardSurface; } + bool requireHardSurface() const { return _requireHardSurface; } - bool cdiDeflectionIsAngular() const { return (_cdiMaxDeflectionNm <= 0.0); } + bool cdiDeflectionIsAngular() const { return (_cdiMaxDeflectionNm <= 0.0); } - double cdiDeflectionLinearPeg() const - { - assert(_cdiMaxDeflectionNm > 0.0); - return _cdiMaxDeflectionNm; - } + double cdiDeflectionLinearPeg() const + { + assert(_cdiMaxDeflectionNm > 0.0); + return _cdiMaxDeflectionNm; + } - bool driveAutopilot() const { return _driveAutopilot; } + bool driveAutopilot() const { return _driveAutopilot; } - bool courseSelectable() const { return _courseSelectable; } + bool courseSelectable() const { return _courseSelectable; } /** * Select whether we fly the leg track between waypoints, or @@ -149,34 +149,34 @@ private: bool followLegTrackToFix() const { return _followLegTrackToFix; } private: - bool _enableTurnAnticipation; + bool _enableTurnAnticipation; - // desired turn rate in degrees per second - double _turnRate; + // desired turn rate in degrees per second + double _turnRate; - // distance from waypoint to arm overflight sequencing (in nm) - double _overflightDistance; + // distance from waypoint to arm overflight sequencing (in nm) + double _overflightDistance; - // distance from waypoint to arm overflight sequencing (in nm) - double _overflightArmDistance; + // distance from waypoint to arm overflight sequencing (in nm) + double _overflightArmDistance; - //abs angle from course to waypoint to arm overflight sequencing (in deg) - double _overflightArmAngle; + //abs angle from course to waypoint to arm overflight sequencing (in deg) + double _overflightArmAngle; - // time before reaching a waypoint to trigger annunciator light/sound - // (in seconds) - double _waypointAlertTime; + // time before reaching a waypoint to trigger annunciator light/sound + // (in seconds) + double _waypointAlertTime; - // should we require a hard-surfaced runway when filtering? - bool _requireHardSurface; + // should we require a hard-surfaced runway when filtering? + bool _requireHardSurface; - double _cdiMaxDeflectionNm; + double _cdiMaxDeflectionNm; - // should we drive the autopilot directly or not? - bool _driveAutopilot; + // should we drive the autopilot directly or not? + bool _driveAutopilot; - // is selected-course-deg read to set desired-course or not? - bool _courseSelectable; + // is selected-course-deg read to set desired-course or not? + bool _courseSelectable; // do we fly direct to fixes, or follow the leg track closely? bool _followLegTrackToFix; @@ -185,10 +185,10 @@ private: class SearchFilter : public FGPositioned::Filter { public: - virtual bool pass(FGPositioned* aPos) const; + virtual bool pass(FGPositioned* aPos) const; - virtual FGPositioned::Type minType() const; - virtual FGPositioned::Type maxType() const; + virtual FGPositioned::Type minType() const; + virtual FGPositioned::Type maxType() const; }; /** reset all output properties to default / non-service values */ @@ -219,20 +219,20 @@ private: * valid or not. */ bool isScratchPositionValid() const; FGPositionedRef positionedFromScratch() const; - + #if FG_210_COMPAT void setScratchFromPositioned(FGPositioned* aPos, int aIndex); void setScratchFromCachedSearchResult(); void setScratchFromRouteWaypoint(int aIndex); - + /** Add airport-specific information to a scratch result */ void addAirportToScratch(FGAirport* aAirport); - + FGPositioned::Filter* createFilter(FGPositioned::Type aTy); - + /** Search kernel - called each time we step through a result */ void performSearch(); - + // command handlers void loadRouteWaypoint(); void loadNearest(); @@ -242,7 +242,7 @@ private: void defineWaypoint(); void insertWaypointAtIndex(int aIndex); void removeWaypointAtIndex(int aIndex); - + // tied-property getter/setters double getScratchDistance() const; double getScratchMagBearing() const; @@ -250,13 +250,13 @@ private: bool getScratchHasNext() const; #endif - -// command handlers + + // command handlers void selectLegMode(); void selectOBSMode(flightgear::Waypt* waypt); void directTo(); -// tied-property getter/setters + // tied-property getter/setters void setCommand(const char* aCmd); const char* getCommand() const { return ""; } @@ -310,22 +310,22 @@ private: /** helper, tie the lat/lon/elev of a SGGeod to the named children of aNode */ void tieSGGeod(SGPropertyNode* aNode, SGGeod& aRef, const char* lonStr, const char* latStr, const char* altStr); - + /** helper, tie a SGGeod to proeprties, but read-only */ void tieSGGeodReadOnly(SGPropertyNode* aNode, SGGeod& aRef, const char* lonStr, const char* latStr, const char* altStr); -// FlightPlan::Delegate + // FlightPlan::Delegate virtual void currentWaypointChanged(); virtual void waypointsChanged(); virtual void cleared(); virtual void endOfFlightPlan(); - + void sequence(); void routeManagerFlightPlanChanged(SGPropertyNode*); void routeActivated(SGPropertyNode*); - -// members + + // members SGPropertyNode_ptr _gpsNode; SGPropertyNode_ptr _currentWayptNode; SGPropertyNode_ptr _magvar_node; @@ -340,13 +340,13 @@ private: SGPropertyNode_ptr _magnetic_bug_error_node; SGPropertyNode_ptr _eastWestVelocity; SGPropertyNode_ptr _northSouthVelocity; - - // SGPropertyNode_ptr _route_active_node; + + // SGPropertyNode_ptr _route_active_node; SGPropertyNode_ptr _route_current_wp_node; SGPropertyNode_ptr _routeDistanceNm; SGPropertyNode_ptr _routeETE; SGPropertyNode_ptr _desiredCourseNode; - + double _selectedCourse; double _desiredCourse; @@ -367,7 +367,7 @@ private: * and not to worry about electrical power or similar. */ bool _defaultGPSMode; - + std::string _mode; Config _config; std::string _name; @@ -377,12 +377,12 @@ private: SGGeod _indicated_pos; double _legDistanceNm; -// scratch data + // scratch data SGGeod _scratchPos; SGPropertyNode_ptr _scratchNode; bool _scratchValid; #if FG_210_COMPAT -// search data + // search data int _searchResultIndex; std::string _searchQuery; FGPositioned::Type _searchType; @@ -392,8 +392,8 @@ private: bool _searchHasNext; ///< is there a result after this one? bool _searchNames; ///< set if we're searching names instead of idents #endif - -// turn data + + // turn data bool _computeTurnData; ///< do we need to update the turn data? bool _anticipateTurn; ///< are we anticipating the next turn or not? bool _inTurn; // is a turn in progress? @@ -409,14 +409,14 @@ private: flightgear::WayptRef _prevWaypt; flightgear::WayptRef _currentWaypt; -// autopilot drive properties + // autopilot drive properties SGPropertyNode_ptr _apDrivingFlag; SGPropertyNode_ptr _apTrueHeading; - + simgear::TiedPropertyList _tiedProperties; flightgear::FlightPlanRef _route; - + SGPropertyChangeCallback _callbackFlightPlanChanged; SGPropertyChangeCallback _callbackRouteActivated; }; diff --git a/src/Instrumentation/gsdi.hxx b/src/Instrumentation/gsdi.hxx index 0d8ef2e36..fa769be41 100644 --- a/src/Instrumentation/gsdi.hxx +++ b/src/Instrumentation/gsdi.hxx @@ -44,26 +44,26 @@ class GSDI : public SGSubsystem { public: - GSDI(SGPropertyNode *node); - virtual ~GSDI(); + GSDI(SGPropertyNode *node); + virtual ~GSDI(); - virtual void init(); - virtual void update(double dt); + virtual void init(); + virtual void update(double dt); private: - std::string _name; - unsigned int _num; + std::string _name; + unsigned int _num; - SGPropertyNode_ptr _serviceableN; - SGPropertyNode_ptr _headingN; - SGPropertyNode_ptr _ubodyN; - SGPropertyNode_ptr _vbodyN; - SGPropertyNode_ptr _wind_speedN; - SGPropertyNode_ptr _wind_dirN; - SGPropertyNode_ptr _drift_uN; - SGPropertyNode_ptr _drift_vN; - SGPropertyNode_ptr _drift_speedN; - SGPropertyNode_ptr _drift_angleN; + SGPropertyNode_ptr _serviceableN; + SGPropertyNode_ptr _headingN; + SGPropertyNode_ptr _ubodyN; + SGPropertyNode_ptr _vbodyN; + SGPropertyNode_ptr _wind_speedN; + SGPropertyNode_ptr _wind_dirN; + SGPropertyNode_ptr _drift_uN; + SGPropertyNode_ptr _drift_vN; + SGPropertyNode_ptr _drift_speedN; + SGPropertyNode_ptr _drift_angleN; }; #endif // _INSTRUMENTS_GSDI_HXX diff --git a/src/Instrumentation/heading_indicator.hxx b/src/Instrumentation/heading_indicator.hxx index f340c05dd..2f5bfec6b 100644 --- a/src/Instrumentation/heading_indicator.hxx +++ b/src/Instrumentation/heading_indicator.hxx @@ -34,9 +34,7 @@ */ class HeadingIndicator : public SGSubsystem { - public: - HeadingIndicator ( SGPropertyNode *node ); HeadingIndicator (); virtual ~HeadingIndicator (); @@ -48,7 +46,6 @@ public: virtual void update (double dt); private: - Gyro _gyro; double _last_heading_deg; @@ -62,7 +59,6 @@ private: SGPropertyNode_ptr _heading_out_node; SGPropertyNode_ptr _heading_bug_error_node; SGPropertyNode_ptr _heading_bug_node; - }; #endif // __INSTRUMENTS_HEADING_INDICATOR_HXX diff --git a/src/Instrumentation/heading_indicator_dg.hxx b/src/Instrumentation/heading_indicator_dg.hxx index 5efa505f7..bbb9d13fc 100644 --- a/src/Instrumentation/heading_indicator_dg.hxx +++ b/src/Instrumentation/heading_indicator_dg.hxx @@ -32,9 +32,7 @@ */ class HeadingIndicatorDG : public SGSubsystem { - public: - HeadingIndicatorDG ( SGPropertyNode *node ); HeadingIndicatorDG (); virtual ~HeadingIndicatorDG (); @@ -46,7 +44,6 @@ public: virtual void update (double dt); private: - Gyro _gyro; double _last_heading_deg, _last_indicated_heading_dg; diff --git a/src/Instrumentation/heading_indicator_fg.hxx b/src/Instrumentation/heading_indicator_fg.hxx index 9ed2bce0b..62efe7bf6 100644 --- a/src/Instrumentation/heading_indicator_fg.hxx +++ b/src/Instrumentation/heading_indicator_fg.hxx @@ -34,9 +34,7 @@ */ class HeadingIndicatorFG : public SGSubsystem { - public: - HeadingIndicatorFG ( SGPropertyNode *node ); HeadingIndicatorFG (); virtual ~HeadingIndicatorFG (); @@ -48,24 +46,20 @@ public: virtual void update (double dt); private: - Gyro _gyro; double _last_heading_deg; std::string name; int num; - + SGPropertyNode_ptr _offset_node; SGPropertyNode_ptr _heading_in_node; SGPropertyNode_ptr _serviceable_node; SGPropertyNode_ptr _heading_out_node; - SGPropertyNode_ptr _electrical_node; - SGPropertyNode_ptr _error_node; - SGPropertyNode_ptr _nav1_error_node; + SGPropertyNode_ptr _electrical_node; + SGPropertyNode_ptr _error_node; + SGPropertyNode_ptr _nav1_error_node; SGPropertyNode_ptr _off_node; - - - }; #endif // __INSTRUMENTS_HEADING_INDICATOR_HXX diff --git a/src/Instrumentation/inst_vertical_speed_indicator.hxx b/src/Instrumentation/inst_vertical_speed_indicator.hxx index dc205a7b9..2782550c4 100644 --- a/src/Instrumentation/inst_vertical_speed_indicator.hxx +++ b/src/Instrumentation/inst_vertical_speed_indicator.hxx @@ -50,9 +50,7 @@ class SGInterpTable; */ class InstVerticalSpeedIndicator : public SGSubsystem { - public: - InstVerticalSpeedIndicator ( SGPropertyNode *node ); virtual ~InstVerticalSpeedIndicator (); @@ -61,7 +59,6 @@ public: virtual void update (double dt); private: - std::string _name; int _num; diff --git a/src/Instrumentation/instrument_mgr.hxx b/src/Instrumentation/instrument_mgr.hxx index 58d92afbe..dcd30d88f 100644 --- a/src/Instrumentation/instrument_mgr.hxx +++ b/src/Instrumentation/instrument_mgr.hxx @@ -28,18 +28,17 @@ class FGInstrumentMgr : public SGSubsystemGroup { public: - FGInstrumentMgr (); virtual ~FGInstrumentMgr (); - + virtual void init(); virtual InitStatus incrementalInit(); private: bool build (SGPropertyNode* config_props); - + bool _explicitGps; - + std::vector _instruments; }; diff --git a/src/Instrumentation/kr_87.hxx b/src/Instrumentation/kr_87.hxx index 626b50283..46ff924f1 100644 --- a/src/Instrumentation/kr_87.hxx +++ b/src/Instrumentation/kr_87.hxx @@ -140,17 +140,17 @@ public: inline void set_rotation( double rot ) { rotation = rot; } inline bool get_power_btn() const { return power_btn; } inline void set_power_btn( bool val ) { - power_btn = val; + power_btn = val; } inline bool get_audio_btn() const { return audio_btn; } inline void set_audio_btn( bool val ) { - audio_btn = val; + audio_btn = val; } inline double get_vol_btn() const { return vol_btn; } inline void set_vol_btn( double val ) { - if ( val < 0.0 ) val = 0.0; - if ( val > 1.0 ) val = 1.0; - vol_btn = val; + if ( val < 0.0 ) val = 0.0; + if ( val > 1.0 ) val = 1.0; + vol_btn = val; } inline bool get_adf_btn() const { return adf_btn; } inline void set_adf_btn( bool val ) { adf_btn = val; } @@ -166,7 +166,7 @@ public: // outputs inline int get_freq () const { return freq; } inline void set_freq( int f ) { - freq = f; + freq = f; need_update = true; } int get_stby_freq () const; @@ -185,5 +185,4 @@ public: inline bool get_et_ann() const { return et_ann; } }; - #endif // _FG_KR_87_HXX diff --git a/src/Instrumentation/mag_compass.hxx b/src/Instrumentation/mag_compass.hxx index 1d05c302c..3e9106896 100644 --- a/src/Instrumentation/mag_compass.hxx +++ b/src/Instrumentation/mag_compass.hxx @@ -40,9 +40,7 @@ */ class MagCompass : public SGSubsystem { - public: - MagCompass ( SGPropertyNode *node); MagCompass (); virtual ~MagCompass (); @@ -52,7 +50,6 @@ public: virtual void update (double dt); private: - double _rate_degps; std::string _name; @@ -71,7 +68,6 @@ private: SGPropertyNode_ptr _y_accel_node; SGPropertyNode_ptr _z_accel_node; SGPropertyNode_ptr _out_node; - }; #endif // __INSTRUMENTS_MAG_COMPASS_HXX diff --git a/src/Instrumentation/marker_beacon.hxx b/src/Instrumentation/marker_beacon.hxx index 10b27cd98..6b18c8e6f 100644 --- a/src/Instrumentation/marker_beacon.hxx +++ b/src/Instrumentation/marker_beacon.hxx @@ -33,7 +33,6 @@ class SGSampleGroup; class FGMarkerBeacon : public AbstractInstrument { - // Inputs SGPropertyNode_ptr lon_node; SGPropertyNode_ptr lat_node; @@ -57,7 +56,6 @@ class FGMarkerBeacon : public AbstractInstrument SGSharedPtr _sgr; public: - enum fgMkrBeacType { NOBEACON = 0, INNER, diff --git a/src/Instrumentation/mk_viii.hxx b/src/Instrumentation/mk_viii.hxx index 8919a6f50..aeea823cb 100644 --- a/src/Instrumentation/mk_viii.hxx +++ b/src/Instrumentation/mk_viii.hxx @@ -1255,7 +1255,7 @@ class MK_VIII : public SGSubsystem void get_altitude_above_field (Parameter *parameter); void update_above_field_callout (); - + bool is_bank_angle (double abs_roll_angle, double bias); bool is_high_bank_angle (); unsigned int get_bank_angle_alerts (); diff --git a/src/Instrumentation/mrg.hxx b/src/Instrumentation/mrg.hxx index 7f8f97742..9a3fc6e93 100644 --- a/src/Instrumentation/mrg.hxx +++ b/src/Instrumentation/mrg.hxx @@ -35,9 +35,7 @@ class MasterReferenceGyro : public SGSubsystem { - public: - MasterReferenceGyro ( SGPropertyNode *node ); MasterReferenceGyro (); virtual ~MasterReferenceGyro (); @@ -49,7 +47,6 @@ public: virtual void update (double dt); private: - static const double gravity; //conversion factor std::string _name; diff --git a/src/Instrumentation/navradio.hxx b/src/Instrumentation/navradio.hxx index 4ee81c7ae..cdaad8f12 100644 --- a/src/Instrumentation/navradio.hxx +++ b/src/Instrumentation/navradio.hxx @@ -34,7 +34,8 @@ class SGSampleGroup; -class FGNavRadio : public AbstractInstrument, public SGPropertyChangeListener +class FGNavRadio : public AbstractInstrument, + public SGPropertyChangeListener { SGPropertyNode_ptr _radio_node; @@ -53,7 +54,7 @@ class FGNavRadio : public AbstractInstrument, public SGPropertyChangeListener SGPropertyNode_ptr cdi_serviceable_node; SGPropertyNode_ptr gs_serviceable_node; SGPropertyNode_ptr tofrom_serviceable_node; - + // property outputs SGPropertyNode_ptr fmt_freq_node; // formated frequency SGPropertyNode_ptr fmt_alt_freq_node; // formated alternate frequency @@ -106,7 +107,7 @@ class FGNavRadio : public AbstractInstrument, public SGPropertyChangeListener SGPropertyNode_ptr gps_course_node; SGPropertyNode_ptr gps_xtrack_error_nm_node; SGPropertyNode_ptr _magvarNode; - + // realism setting, are false courses and GS lobes enabled? SGPropertyNode_ptr falseCoursesEnabledNode; @@ -117,7 +118,7 @@ class FGNavRadio : public AbstractInstrument, public SGPropertyChangeListener double _last_freq; FGNavRecordRef _navaid; FGNavRecordRef _gs; - + double target_radial; double effective_range; double target_gs; @@ -142,16 +143,16 @@ class FGNavRadio : public AbstractInstrument, public SGPropertyChangeListener double _gsDirect; class AudioIdent * _audioIdent; - + bool updateWithPower(double aDt); // model standard VOR/DME/TACAN service volumes as per AIM 1-1-8 double adjustNavRange( double stationElev, double aircraftElev, - double nominalRange ); + double nominalRange ); // model standard ILS service volumes as per AIM 1-1-9 double adjustILSRange( double stationElev, double aircraftElev, - double offsetDegrees, double distance ); + double offsetDegrees, double distance ); void updateAudio( double dt ); @@ -160,16 +161,15 @@ class FGNavRadio : public AbstractInstrument, public SGPropertyChangeListener void updateGPSSlaved(); void updateCDI(double dt); void updateFormattedFrequencies(); - + void clearOutputs(); FGNavRecord* findPrimaryNavaid(const SGGeod& aPos, double aFreqMHz); - - - // implement SGPropertyChangeListener - virtual void valueChanged (SGPropertyNode * prop); -public: + // implement SGPropertyChangeListener + virtual void valueChanged (SGPropertyNode * prop); + +public: FGNavRadio(SGPropertyNode *node); ~FGNavRadio(); @@ -182,5 +182,4 @@ public: void updateNav(); }; - #endif // _FG_NAVRADIO_HXX diff --git a/src/Instrumentation/newnavradio.cxx b/src/Instrumentation/newnavradio.cxx index 91e826208..112ad887d 100644 --- a/src/Instrumentation/newnavradio.cxx +++ b/src/Instrumentation/newnavradio.cxx @@ -802,48 +802,51 @@ void GS::display( NavIndicator & navIndicator ) /* ------------- The NavRadio implementation ---------------------- */ -class NavRadioImpl : public NavRadio { +class NavRadioImpl : public NavRadio +{ public: - NavRadioImpl( SGPropertyNode_ptr node ); - virtual ~NavRadioImpl(); + NavRadioImpl( SGPropertyNode_ptr node ); + virtual ~NavRadioImpl(); + + virtual void update( double dt ); + virtual void init(); - virtual void update( double dt ); - virtual void init(); private: - void search(); + void search(); - class Legacy { - public: - Legacy( NavRadioImpl * navRadioImpl ) : _navRadioImpl( navRadioImpl ) {} + class Legacy { + public: + Legacy( NavRadioImpl * navRadioImpl ) : _navRadioImpl( navRadioImpl ) {} - void init(); - void update( double dt ); - private: - NavRadioImpl * _navRadioImpl; - SGPropertyNode_ptr is_valid_node; - SGPropertyNode_ptr nav_serviceable_node; - SGPropertyNode_ptr nav_id_node; - SGPropertyNode_ptr id_c1_node; - SGPropertyNode_ptr id_c2_node; - SGPropertyNode_ptr id_c3_node; - SGPropertyNode_ptr id_c4_node; - } _legacy; + void init(); + void update( double dt ); - const static int VOR_COMPONENT = 0; - const static int LOC_COMPONENT = 1; - const static int GS_COMPONENT = 2; + private: + NavRadioImpl * _navRadioImpl; + SGPropertyNode_ptr is_valid_node; + SGPropertyNode_ptr nav_serviceable_node; + SGPropertyNode_ptr nav_id_node; + SGPropertyNode_ptr id_c1_node; + SGPropertyNode_ptr id_c2_node; + SGPropertyNode_ptr id_c3_node; + SGPropertyNode_ptr id_c4_node; + } _legacy; - std::string _name; - int _num; - SGPropertyNode_ptr _rootNode; - FrequencyFormatter _useFrequencyFormatter; - FrequencyFormatter _stbyFrequencyFormatter; - std::vector _components; - NavIndicator _navIndicator; - double _stationTTL; - double _frequency; - PropertyObject _cdiDisconnected; - PropertyObject _navType; + const static int VOR_COMPONENT = 0; + const static int LOC_COMPONENT = 1; + const static int GS_COMPONENT = 2; + + std::string _name; + int _num; + SGPropertyNode_ptr _rootNode; + FrequencyFormatter _useFrequencyFormatter; + FrequencyFormatter _stbyFrequencyFormatter; + std::vector _components; + NavIndicator _navIndicator; + double _stationTTL; + double _frequency; + PropertyObject _cdiDisconnected; + PropertyObject _navType; }; NavRadioImpl::NavRadioImpl( SGPropertyNode_ptr node ) : diff --git a/src/Instrumentation/newnavradio.hxx b/src/Instrumentation/newnavradio.hxx index e3be74995..2e64579b4 100644 --- a/src/Instrumentation/newnavradio.hxx +++ b/src/Instrumentation/newnavradio.hxx @@ -27,10 +27,11 @@ #include namespace Instrumentation { + class NavRadio : public SGSubsystem { public: - static SGSubsystem * createInstance( SGPropertyNode_ptr rootNode ); + static SGSubsystem * createInstance( SGPropertyNode_ptr rootNode ); }; } diff --git a/src/Instrumentation/rad_alt.hxx b/src/Instrumentation/rad_alt.hxx index 568d6741b..4e18f1506 100644 --- a/src/Instrumentation/rad_alt.hxx +++ b/src/Instrumentation/rad_alt.hxx @@ -1,7 +1,7 @@ // Radar Altimeter // // Written by Vivian MEAZZA, started Feb 2008. -// +// // // Copyright (C) 2008 Vivain MEAZZA - vivian.meazza@lineone.net // @@ -31,39 +31,35 @@ class RadarAltimeter : public SGSubsystem { public: - RadarAltimeter ( SGPropertyNode *node ); virtual ~RadarAltimeter (); private: - virtual void init (); virtual void update (double dt); void update_altitude(); void updateSetHeight(); - + double getDistanceAntennaToHit(const SGVec3d& h) const; SGVec3d getCartAntennaPos()const; - + SGVec3d rayVector(double az, double el) const; - + SGPropertyNode_ptr _Instrument; SGPropertyNode_ptr _user_alt_agl_node; SGPropertyNode_ptr _rad_alt_warning_node; SGPropertyNode_ptr _serviceable_node; SGPropertyNode_ptr _sceneryLoaded; - - + SGVec3d _antennaOffset; // in aircraft local XYZ frame - + std::string _name; int _num; double _time; double _interval; double _min_radalt; - }; #endif // _INST_AGRADAR_HXX diff --git a/src/Instrumentation/slip_skid_ball.hxx b/src/Instrumentation/slip_skid_ball.hxx index 87b691e3f..e0ad396b0 100644 --- a/src/Instrumentation/slip_skid_ball.hxx +++ b/src/Instrumentation/slip_skid_ball.hxx @@ -30,9 +30,7 @@ */ class SlipSkidBall : public SGSubsystem { - public: - SlipSkidBall ( SGPropertyNode *node ); virtual ~SlipSkidBall (); @@ -49,7 +47,6 @@ private: SGPropertyNode_ptr _z_accel_node; SGPropertyNode_ptr _out_node; SGPropertyNode_ptr _override_node; - }; #endif // __INSTRUMENTS_SLIP_SKID_BALL_HXX diff --git a/src/Instrumentation/tacan.hxx b/src/Instrumentation/tacan.hxx index fcbc737c8..680d2bae9 100644 --- a/src/Instrumentation/tacan.hxx +++ b/src/Instrumentation/tacan.hxx @@ -31,11 +31,10 @@ * /instrumentation/"name"/indicated-ground-speed-kt * /instrumentation/"name"/indicated-time-kt */ -class TACAN : public SGSubsystem, public SGPropertyChangeListener +class TACAN : public SGSubsystem, + public SGPropertyChangeListener { - - public: - +public: TACAN(SGPropertyNode *node); virtual ~TACAN(); @@ -43,8 +42,7 @@ class TACAN : public SGSubsystem, public SGPropertyChangeListener virtual void reinit (); virtual void update (double delta_time_sec); - private: - +private: void disabled(bool force = false); void search (double frequency, const SGGeod& pos); @@ -89,5 +87,4 @@ class TACAN : public SGSubsystem, public SGPropertyChangeListener int _listener_active; }; - #endif // __INSTRUMENTS_TACAN_HXX diff --git a/src/Instrumentation/tcas.hxx b/src/Instrumentation/tcas.hxx index 0bc81b572..aaf1327bb 100644 --- a/src/Instrumentation/tcas.hxx +++ b/src/Instrumentation/tcas.hxx @@ -50,7 +50,6 @@ class SGSampleGroup; class TCAS : public SGSubsystem { - typedef enum { AdvisoryClear = 0, /*< Clear of traffic */ @@ -99,7 +98,7 @@ class TCAS : public SGSubsystem typedef struct { - float Tau; /*< vertical/horizontal protection range in seconds */ + float Tau; /*< vertical/horizontal protection range in seconds */ float DMOD; /*< horizontal protection range in nm */ float ALIM; /*< vertical protection range in ft */ } Thresholds; @@ -154,10 +153,10 @@ class TCAS : public SGSubsystem class PropertiesHandler : public FGVoicePlayer::PropertiesHandler { public: - PropertiesHandler (TCAS *) : - FGVoicePlayer::PropertiesHandler() {} + PropertiesHandler (TCAS *) : + FGVoicePlayer::PropertiesHandler() {} - PropertiesHandler (void) : FGVoicePlayer::PropertiesHandler() {} + PropertiesHandler (void) : FGVoicePlayer::PropertiesHandler() {} }; ///////////////////////////////////////////////////////////////////////////// @@ -169,7 +168,7 @@ class TCAS : public SGSubsystem { public: VoicePlayer (TCAS* tcas) : - FGVoicePlayer(&tcas->properties_handler, "tcas") {} + FGVoicePlayer(&tcas->properties_handler, "tcas") {} ~VoicePlayer (void) {} @@ -177,22 +176,22 @@ class TCAS : public SGSubsystem struct { - Voice* pTrafficTraffic; - Voice* pClimb; - Voice* pClimbNow; - Voice* pClimbCrossing; - Voice* pClimbIncrease; - Voice* pDescend; - Voice* pDescendNow; - Voice* pDescendCrossing; - Voice* pDescendIncrease; - Voice* pClear; - Voice* pAdjustVSpeed; - Voice* pMaintVSpeed; - Voice* pMonitorVSpeed; - Voice* pLevelOff; - Voice* pTestOk; - Voice* pTestFail; + Voice* pTrafficTraffic; + Voice* pClimb; + Voice* pClimbNow; + Voice* pClimbCrossing; + Voice* pClimbIncrease; + Voice* pDescend; + Voice* pDescendNow; + Voice* pDescendCrossing; + Voice* pDescendIncrease; + Voice* pClear; + Voice* pAdjustVSpeed; + Voice* pMaintVSpeed; + Voice* pMonitorVSpeed; + Voice* pLevelOff; + Voice* pTestOk; + Voice* pTestFail; } Voices; private: SGPropertyNode_ptr nodeSoundFilePrefix; @@ -275,7 +274,7 @@ class TCAS : public SGSubsystem bool newTargets; TrackerTargets targets; }; - + ///////////////////////////////////////////////////////////////////////////// // TCAS::AdvisoryGenerator ////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// @@ -342,7 +341,7 @@ class TCAS : public SGSubsystem #ifdef FEATURE_TCAS_DEBUG_THREAT_DETECTOR int checkCount; #endif // of FEATURE_TCAS_DEBUG_THREAT_DETECTOR - + SGPropertyNode_ptr nodeLat; SGPropertyNode_ptr nodeLon; SGPropertyNode_ptr nodePressureAlt; diff --git a/src/Instrumentation/transponder.hxx b/src/Instrumentation/transponder.hxx index acd7cae75..317b5745d 100644 --- a/src/Instrumentation/transponder.hxx +++ b/src/Instrumentation/transponder.hxx @@ -27,7 +27,8 @@ #include #include -class Transponder : public AbstractInstrument, public SGPropertyChangeListener +class Transponder : public AbstractInstrument, + public SGPropertyChangeListener { public: Transponder(SGPropertyNode *node); @@ -37,20 +38,18 @@ public: void update (double dt) override; void bind() override; void unbind() override; - + protected: bool isPowerSwitchOn() const override; - + private: - enum Mode - { + enum Mode { MODE_A = 0, MODE_C, MODE_S }; - - enum KnobPosition - { + + enum KnobPosition { KNOB_OFF = 0, KNOB_STANDBY, KNOB_TEST, @@ -58,7 +57,7 @@ private: KNOB_ON, KNOB_ALT }; - + // annunciators, for KT-70 compatibility only // these should be replaced with conditionals in the instrument bool getFLAnnunciator() const; @@ -67,7 +66,7 @@ private: bool getOnAnnunciator() const; bool getStandbyAnnunciator() const; bool getReplyAnnunciator() const; - + // Inputs SGPropertyNode_ptr _pressureAltitude_node; SGPropertyNode_ptr _autoGround_node; @@ -77,13 +76,13 @@ private: SGPropertyNode_ptr _knob_node; SGPropertyNode_ptr _idCode_node; SGPropertyNode_ptr _digit_node[4]; - + simgear::TiedPropertyList _tiedProperties; - + SGPropertyNode_ptr _identBtn_node; bool _identMode = false; bool _kt70Compat; - + // Outputs SGPropertyNode_ptr _altitude_node; SGPropertyNode_ptr _altitudeValid_node; @@ -101,9 +100,9 @@ private: std::string _altitudeSourcePath; std::string _autoGroundPath; std::string _airspeedSourcePath; - + void valueChanged (SGPropertyNode *) override; - + int setMinMax(int val); }; diff --git a/src/Instrumentation/turn_indicator.hxx b/src/Instrumentation/turn_indicator.hxx index 3cb9c84ef..ac85243a3 100644 --- a/src/Instrumentation/turn_indicator.hxx +++ b/src/Instrumentation/turn_indicator.hxx @@ -20,7 +20,7 @@ /** * Model an electric-powered turn indicator. * - * This class does not model the slip/skid ball; that is properly + * This class does not model the slip/skid ball; that is properly * a separate instrument. * * Input properties: @@ -37,9 +37,7 @@ */ class TurnIndicator : public SGSubsystem { - public: - TurnIndicator ( SGPropertyNode *node ); virtual ~TurnIndicator (); @@ -50,7 +48,6 @@ public: virtual void update (double dt); private: - Gyro _gyro; double _last_rate; @@ -61,7 +58,6 @@ private: SGPropertyNode_ptr _yaw_rate_node; SGPropertyNode_ptr _electric_current_node; SGPropertyNode_ptr _rate_out_node; - }; #endif // __INSTRUMENTS_TURN_INDICATOR_HXX diff --git a/src/Instrumentation/vertical_speed_indicator.hxx b/src/Instrumentation/vertical_speed_indicator.hxx index e290f8064..103806e0b 100644 --- a/src/Instrumentation/vertical_speed_indicator.hxx +++ b/src/Instrumentation/vertical_speed_indicator.hxx @@ -33,9 +33,7 @@ */ class VerticalSpeedIndicator : public SGSubsystem { - public: - VerticalSpeedIndicator ( SGPropertyNode *node ); virtual ~VerticalSpeedIndicator (); @@ -44,7 +42,6 @@ public: virtual void update (double dt); private: - double _casing_pressure_Pa = 0.0; double _casing_airmass_kg = 0.0; double _casing_density_kgpm3 = 0.0; @@ -61,7 +58,6 @@ private: SGPropertyNode_ptr _speed_fpm_node; SGPropertyNode_ptr _speed_mps_node; SGPropertyNode_ptr _speed_kts_node; - }; #endif // __INSTRUMENTS_VERTICAL_SPEED_INDICATOR_HXX diff --git a/src/Main/FGInterpolator.hxx b/src/Main/FGInterpolator.hxx index 548522ddb..d317403e5 100644 --- a/src/Main/FGInterpolator.hxx +++ b/src/Main/FGInterpolator.hxx @@ -21,13 +21,11 @@ #include -class FGInterpolator: - public simgear::PropertyInterpolationMgr +class FGInterpolator : public simgear::PropertyInterpolationMgr { - public: +public: FGInterpolator(); ~FGInterpolator(); }; - #endif /* FG_INTERPOLATOR_HXX_ */ diff --git a/src/Main/fg_io.hxx b/src/Main/fg_io.hxx index 63115764b..a45af25b9 100644 --- a/src/Main/fg_io.hxx +++ b/src/Main/fg_io.hxx @@ -55,20 +55,17 @@ public: */ static bool isMultiplayerRequested(); private: - void add_channel(const std::string& config); FGProtocol* parse_port_config( const std::string& cfgstr ); private: - // define the global I/O channel list //io_container global_io_list; - + typedef std::vector< FGProtocol* > ProtocolVec; ProtocolVec io_channels; - + SGPropertyNode_ptr _realDeltaTime; }; - #endif // _FG_IO_HXX diff --git a/src/Main/fg_props.hxx b/src/Main/fg_props.hxx index 23af6fa49..d0c6f367f 100644 --- a/src/Main/fg_props.hxx +++ b/src/Main/fg_props.hxx @@ -127,7 +127,7 @@ inline SGPropertyNode * fgGetNode (const std::string & path, bool create = false * @return The node, or 0 if none exists and none was created. */ extern SGPropertyNode * fgGetNode (const char * path, - int index, bool create = false); + int index, bool create = false); /** * Get a property node with separate index. @@ -144,7 +144,7 @@ extern SGPropertyNode * fgGetNode (const char * path, * @return The node, or 0 if none exists and none was created. */ inline SGPropertyNode * fgGetNode (const std::string & path, - int index, bool create = false) + int index, bool create = false) { return fgGetNode(path.c_str(), index, create ); } @@ -179,7 +179,7 @@ inline bool fgHasNode (const std::string & path) * any given in the string). */ extern void fgAddChangeListener (SGPropertyChangeListener * listener, - const char * path); + const char * path); /** * Add a listener to a node. @@ -190,7 +190,7 @@ extern void fgAddChangeListener (SGPropertyChangeListener * listener, * any given in the string). */ inline void fgAddChangeListener (SGPropertyChangeListener * listener, - const std::string & path) + const std::string & path) { fgAddChangeListener( listener, path.c_str() ); } @@ -205,7 +205,7 @@ inline void fgAddChangeListener (SGPropertyChangeListener * listener, * any given in the string). */ extern void fgAddChangeListener (SGPropertyChangeListener * listener, - const char * path, int index); + const char * path, int index); /** * Add a listener to a node. @@ -216,7 +216,7 @@ extern void fgAddChangeListener (SGPropertyChangeListener * listener, * any given in the string). */ inline void fgAddChangeListener (SGPropertyChangeListener * listener, - const std::string & path, int index) + const std::string & path, int index) { fgAddChangeListener( listener, path.c_str(), index ); } @@ -417,7 +417,7 @@ inline double fgGetDouble (const std::string & name, double defaultValue = 0.0) * @return The property's value as a string, or the default value provided. */ extern const char * fgGetString (const char * name, - const char * defaultValue = ""); + const char * defaultValue = ""); /** * Get a string value for a property. @@ -721,7 +721,7 @@ extern void fgUntie (const char * name); * @param name The property name to tie (full path). * @param getter The getter function, or 0 if the value is unreadable. * @param setter The setter function, or 0 if the value is unmodifiable. - * @param useDefault true if the setter should be invoked with any existing + * @param useDefault true if the setter should be invoked with any existing * property value should be; false if the old value should be * discarded; defaults to true. */ @@ -731,9 +731,9 @@ fgTie (const char * name, V (*getter)(), void (*setter)(V) = 0, bool useDefault = true) { if (!globals->get_props()->tie(name, SGRawValueFunctions(getter, setter), - useDefault)) + useDefault)) SG_LOG(SG_GENERAL, SG_WARN, - "Failed to tie property " << name << " to functions"); + "Failed to tie property " << name << " to functions"); } @@ -751,7 +751,7 @@ fgTie (const char * name, V (*getter)(), void (*setter)(V) = 0, * setter functions. * @param getter The getter function, or 0 if the value is unreadable. * @param setter The setter function, or 0 if the value is unmodifiable. - * @param useDefault true if the setter should be invoked with any existing + * @param useDefault true if the setter should be invoked with any existing * property value should be; false if the old value should be * discarded; defaults to true. */ @@ -761,12 +761,12 @@ fgTie (const char * name, int index, V (*getter)(int), void (*setter)(int, V) = 0, bool useDefault = true) { if (!globals->get_props()->tie(name, - SGRawValueFunctionsIndexed(index, - getter, - setter), - useDefault)) + SGRawValueFunctionsIndexed(index, + getter, + setter), + useDefault)) SG_LOG(SG_GENERAL, SG_WARN, - "Failed to tie property " << name << " to indexed functions"); + "Failed to tie property " << name << " to indexed functions"); } @@ -785,7 +785,7 @@ fgTie (const char * name, int index, V (*getter)(int), * unreadable. * @param setter The object's setter method, or 0 if the value is * unmodifiable. - * @param useDefault true if the setter should be invoked with any existing + * @param useDefault true if the setter should be invoked with any existing * property value should be; false if the old value should be * discarded; defaults to true. */ @@ -795,10 +795,10 @@ fgTie (const char * name, T * obj, V (T::*getter)() const, void (T::*setter)(V) = 0, bool useDefault = true) { if (!globals->get_props()->tie(name, - SGRawValueMethods(*obj, getter, setter), - useDefault)) + SGRawValueMethods(*obj, getter, setter), + useDefault)) SG_LOG(SG_GENERAL, SG_WARN, - "Failed to tie property " << name << " to object methods"); + "Failed to tie property " << name << " to object methods"); } @@ -817,24 +817,24 @@ fgTie (const char * name, T * obj, V (T::*getter)() const, * setter methods. * @param getter The getter method, or 0 if the value is unreadable. * @param setter The setter method, or 0 if the value is unmodifiable. - * @param useDefault true if the setter should be invoked with any existing + * @param useDefault true if the setter should be invoked with any existing * property value should be; false if the old value should be * discarded; defaults to true. */ template -inline void +inline void fgTie (const char * name, T * obj, int index, V (T::*getter)(int) const, void (T::*setter)(int, V) = 0, bool useDefault = true) { if (!globals->get_props()->tie(name, - SGRawValueMethodsIndexed(*obj, - index, - getter, - setter), - useDefault)) + SGRawValueMethodsIndexed(*obj, + index, + getter, + setter), + useDefault)) SG_LOG(SG_GENERAL, SG_WARN, - "Failed to tie property " << name << " to indexed object methods"); + "Failed to tie property " << name << " to indexed object methods"); } diff --git a/src/Main/logger.hxx b/src/Main/logger.hxx index ea6f581e7..51d59ac18 100644 --- a/src/Main/logger.hxx +++ b/src/Main/logger.hxx @@ -20,30 +20,28 @@ class FGLogger : public SGSubsystem { public: - // Implementation of SGSubsystem - virtual void init (); - virtual void reinit (); - virtual void bind (); - virtual void unbind (); - virtual void update (double dt); + // Implementation of SGSubsystem + virtual void init (); + virtual void reinit (); + virtual void bind (); + virtual void unbind (); + virtual void update (double dt); private: + /** + * A single instance of a log file (the logger can contain many). + */ + struct Log { + Log (); - /** - * A single instance of a log file (the logger can contain many). - */ - struct Log { - Log (); - - std::vector nodes; - std::unique_ptr output; - long interval_ms; - double last_time_ms; - char delimiter; - }; - - std::vector< std::unique_ptr > _logs; + std::vector nodes; + std::unique_ptr output; + long interval_ms; + double last_time_ms; + char delimiter; + }; + std::vector< std::unique_ptr > _logs; }; #endif // __LOGGER_HXX diff --git a/src/Model/acmodel.hxx b/src/Model/acmodel.hxx index 9ac8d6474..628953fca 100644 --- a/src/Model/acmodel.hxx +++ b/src/Model/acmodel.hxx @@ -11,7 +11,7 @@ #include #include -#include // for SGSubsystem +#include // for SGSubsystem // Don't pull in the headers, since we don't need them here. @@ -21,32 +21,32 @@ class FGFX; class FGAircraftModel : public SGSubsystem { public: + FGAircraftModel (); + virtual ~FGAircraftModel (); - FGAircraftModel (); - virtual ~FGAircraftModel (); - - virtual void init (); - virtual void shutdown (); - virtual void reinit (); - virtual void bind (); - virtual void unbind (); - virtual void update (double dt); - virtual SGModelPlacement * get3DModel() { return _aircraft.get(); } - virtual SGVec3d& getVelocity() { return _velocity; } + virtual void init (); + virtual void shutdown (); + virtual void reinit (); + virtual void bind (); + virtual void unbind (); + virtual void update (double dt); + virtual SGModelPlacement * get3DModel() { return _aircraft.get(); } + virtual SGVec3d& getVelocity() { return _velocity; } static const char* subsystemName() { return "aircraft-model"; } + private: - void deinit (); - + void deinit (); + std::unique_ptr _aircraft; std::unique_ptr _interior; - - SGVec3d _velocity; - SGSharedPtr _fx; - SGPropertyNode_ptr _speed_n; - SGPropertyNode_ptr _speed_e; - SGPropertyNode_ptr _speed_d; + SGVec3d _velocity; + SGSharedPtr _fx; + + SGPropertyNode_ptr _speed_n; + SGPropertyNode_ptr _speed_e; + SGPropertyNode_ptr _speed_d; }; #endif // __ACMODEL_HXX diff --git a/src/Model/modelmgr.hxx b/src/Model/modelmgr.hxx index 299652be1..6fb2cb0cc 100644 --- a/src/Model/modelmgr.hxx +++ b/src/Model/modelmgr.hxx @@ -9,7 +9,7 @@ #include #include -#include // for SG_USING_STD +#include // for SG_USING_STD #include // Don't pull in headers, since we don't need them here. @@ -23,88 +23,87 @@ class SGModelPlacement; class FGModelMgr : public SGSubsystem { public: + /** + * A dynamically-placed model using properties. + * + * The model manager uses the property nodes to update the model's + * position and orientation; any of the property node pointers may + * be set to zero to avoid update. Normally, a caller should + * load the model by instantiating SGModelPlacement with the path + * to the model or its XML wrapper, then assign any relevant + * property node pointers. + * + * @see SGModelPlacement + * @see FGModelMgr#add_instance + */ + struct Instance + { + Instance (); + virtual ~Instance (); + SGModelPlacement * model; + SGPropertyNode_ptr node; + SGPropertyNode_ptr lon_deg_node; + SGPropertyNode_ptr lat_deg_node; + SGPropertyNode_ptr elev_ft_node; + SGPropertyNode_ptr roll_deg_node; + SGPropertyNode_ptr pitch_deg_node; + SGPropertyNode_ptr heading_deg_node; + bool shadow; + }; - /** - * A dynamically-placed model using properties. - * - * The model manager uses the property nodes to update the model's - * position and orientation; any of the property node pointers may - * be set to zero to avoid update. Normally, a caller should - * load the model by instantiating SGModelPlacement with the path - * to the model or its XML wrapper, then assign any relevant - * property node pointers. - * - * @see SGModelPlacement - * @see FGModelMgr#add_instance - */ - struct Instance - { - Instance (); - virtual ~Instance (); - SGModelPlacement * model; - SGPropertyNode_ptr node; - SGPropertyNode_ptr lon_deg_node; - SGPropertyNode_ptr lat_deg_node; - SGPropertyNode_ptr elev_ft_node; - SGPropertyNode_ptr roll_deg_node; - SGPropertyNode_ptr pitch_deg_node; - SGPropertyNode_ptr heading_deg_node; - bool shadow; - }; + FGModelMgr (); + virtual ~FGModelMgr (); - FGModelMgr (); - virtual ~FGModelMgr (); + virtual void init (); + virtual void shutdown (); - virtual void init (); - virtual void shutdown (); + virtual void bind (); + virtual void unbind (); + virtual void update (double dt); - virtual void bind (); - virtual void unbind (); - virtual void update (double dt); + virtual void add_model (SGPropertyNode * node); - virtual void add_model (SGPropertyNode * node); - - /** - * Add an instance of a dynamic model to the manager. - * - * NOTE: pointer ownership is transferred to the model manager! - * - * The caller is responsible for setting up the Instance structure - * as required. The model manager will continuously update the - * location and orientation of the model based on the current - * values of the properties. - */ - virtual void add_instance (Instance * instance); + /** + * Add an instance of a dynamic model to the manager. + * + * NOTE: pointer ownership is transferred to the model manager! + * + * The caller is responsible for setting up the Instance structure + * as required. The model manager will continuously update the + * location and orientation of the model based on the current + * values of the properties. + */ + virtual void add_instance (Instance * instance); - /** - * Remove an instance of a dynamic model from the manager. - * - * NOTE: the manager will delete the instance as well. - */ - virtual void remove_instance (Instance * instance); + /** + * Remove an instance of a dynamic model from the manager. + * + * NOTE: the manager will delete the instance as well. + */ + virtual void remove_instance (Instance * instance); static const char* subsystemName() { return "model-manager"; } + private: - /** - * Listener class that adds models at runtime. - */ - class Listener : public SGPropertyChangeListener - { - public: - Listener(FGModelMgr *mgr) : _mgr(mgr) {} - virtual void childAdded (SGPropertyNode * parent, SGPropertyNode * child); - virtual void childRemoved (SGPropertyNode * parent, SGPropertyNode * child); + /** + * Listener class that adds models at runtime. + */ + class Listener : public SGPropertyChangeListener + { + public: + Listener(FGModelMgr *mgr) : _mgr(mgr) {} + virtual void childAdded (SGPropertyNode * parent, SGPropertyNode * child); + virtual void childRemoved (SGPropertyNode * parent, SGPropertyNode * child); - private: - FGModelMgr * _mgr; - }; + private: + FGModelMgr * _mgr; + }; - SGPropertyNode_ptr _models; - std::unique_ptr _listener; + SGPropertyNode_ptr _models; + std::unique_ptr _listener; std::vector _instances; - }; #endif // __MODELMGR_HXX diff --git a/src/MultiPlayer/multiplaymgr.hxx b/src/MultiPlayer/multiplaymgr.hxx index 5d6f0ef42..e8fa8e72e 100644 --- a/src/MultiPlayer/multiplaymgr.hxx +++ b/src/MultiPlayer/multiplaymgr.hxx @@ -51,82 +51,82 @@ class FGAIMultiplayer; class FGMultiplayMgr : public SGSubsystem { public: - FGMultiplayMgr(); - ~FGMultiplayMgr(); + FGMultiplayMgr(); + ~FGMultiplayMgr(); - virtual void init(void); - virtual void update(double dt); + virtual void init(void); + virtual void update(double dt); - virtual void shutdown(void); - virtual void reinit(); + virtual void shutdown(void); + virtual void reinit(); - // transmitter + // transmitter - void SendTextMessage(const std::string &sMsgText); - // receiver + void SendTextMessage(const std::string &sMsgText); + // receiver private: - friend class MPPropertyListener; + friend class MPPropertyListener; - void setPropertiesChanged() - { - mPropertiesChanged = true; - } - int getProtocolToUse() - { - int protocolVersion = pProtocolVersion->getIntValue(); - if (protocolVersion >= MIN_MP_PROTOCOL_VERSION && protocolVersion <= MAX_MP_PROTOCOL_VERSION) - return protocolVersion; - else - return MIN_MP_PROTOCOL_VERSION; - } + void setPropertiesChanged() + { + mPropertiesChanged = true; + } + int getProtocolToUse() + { + int protocolVersion = pProtocolVersion->getIntValue(); + if (protocolVersion >= MIN_MP_PROTOCOL_VERSION && protocolVersion <= MAX_MP_PROTOCOL_VERSION) + return protocolVersion; + else + return MIN_MP_PROTOCOL_VERSION; + } - void findProperties(); + void findProperties(); - void Send(); - void SendMyPosition(const FGExternalMotionData& motionInfo); - short get_scaled_short(double v, double scale); + void Send(); + void SendMyPosition(const FGExternalMotionData& motionInfo); + short get_scaled_short(double v, double scale); - union MsgBuf; - FGAIMultiplayer* addMultiplayer(const std::string& callsign, - const std::string& modelName, - const int fallback_model_index); - FGAIMultiplayer* getMultiplayer(const std::string& callsign); - void FillMsgHdr(T_MsgHdr *MsgHdr, int iMsgId, unsigned _len = 0u); - void ProcessPosMsg(const MsgBuf& Msg, const simgear::IPAddress& SenderAddress, - long stamp); - void ProcessChatMsg(const MsgBuf& Msg, const simgear::IPAddress& SenderAddress); - bool isSane(const FGExternalMotionData& motionInfo); + union MsgBuf; + FGAIMultiplayer* addMultiplayer(const std::string& callsign, + const std::string& modelName, + const int fallback_model_index); + FGAIMultiplayer* getMultiplayer(const std::string& callsign); + void FillMsgHdr(T_MsgHdr *MsgHdr, int iMsgId, unsigned _len = 0u); + void ProcessPosMsg(const MsgBuf& Msg, const simgear::IPAddress& SenderAddress, + long stamp); + void ProcessChatMsg(const MsgBuf& Msg, const simgear::IPAddress& SenderAddress); + bool isSane(const FGExternalMotionData& motionInfo); - /// maps from the callsign string to the FGAIMultiplayer - typedef std::map > MultiPlayerMap; - MultiPlayerMap mMultiPlayerMap; + /// maps from the callsign string to the FGAIMultiplayer + typedef std::map > MultiPlayerMap; + MultiPlayerMap mMultiPlayerMap; - std::unique_ptr mSocket; - simgear::IPAddress mServer; - bool mHaveServer; - bool mInitialised; - std::string mCallsign; + std::unique_ptr mSocket; + simgear::IPAddress mServer; + bool mHaveServer; + bool mInitialised; + std::string mCallsign; - // Map between the property id's from the multiplayers network packets - // and the property nodes - typedef std::map > PropertyMap; - PropertyMap mPropertyMap; - SGPropertyNode *pProtocolVersion; - SGPropertyNode *pXmitLen; - SGPropertyNode *pMultiPlayDebugLevel; - SGPropertyNode *pMultiPlayRange; - SGPropertyNode *pMultiPlayTransmitPropertyBase; + // Map between the property id's from the multiplayers network packets + // and the property nodes + typedef std::map > PropertyMap; + PropertyMap mPropertyMap; + SGPropertyNode *pProtocolVersion; + SGPropertyNode *pXmitLen; + SGPropertyNode *pMultiPlayDebugLevel; + SGPropertyNode *pMultiPlayRange; + SGPropertyNode *pMultiPlayTransmitPropertyBase; - typedef std::map PropertyDefinitionMap; - PropertyDefinitionMap mPropertyDefinition; + typedef std::map PropertyDefinitionMap; + PropertyDefinitionMap mPropertyDefinition; - bool mPropertiesChanged; + bool mPropertiesChanged; - MPPropertyListener* mListener; + MPPropertyListener* mListener; - double mDt; // reciprocal of /sim/multiplay/tx-rate-hz - double mTimeUntilSend; + double mDt; // reciprocal of /sim/multiplay/tx-rate-hz + double mTimeUntilSend; }; #endif diff --git a/src/Network/DNSClient.hxx b/src/Network/DNSClient.hxx index cdccb4e79..2366e19e8 100644 --- a/src/Network/DNSClient.hxx +++ b/src/Network/DNSClient.hxx @@ -30,19 +30,20 @@ class FGDNSClient : public SGSubsystem public: FGDNSClient(); virtual ~FGDNSClient(); - + void makeRequest(const simgear::DNS::Request_ptr& req); // simgear::HTTP::Client* client() { return _http.get(); } // simgear::HTTP::Client const* client() const { return _http.get(); } - + virtual void init(); virtual void postinit(); virtual void shutdown(); virtual void update(double); static const char* subsystemName() { return "dns"; } -private: + +private: bool _inited; std::unique_ptr _dns; }; diff --git a/src/Network/HTTPClient.hxx b/src/Network/HTTPClient.hxx index e358508db..70de53934 100644 --- a/src/Network/HTTPClient.hxx +++ b/src/Network/HTTPClient.hxx @@ -30,12 +30,12 @@ class FGHTTPClient : public SGSubsystem public: FGHTTPClient(); virtual ~FGHTTPClient(); - + void makeRequest(const simgear::HTTP::Request_ptr& req); simgear::HTTP::Client* client() { return _http.get(); } simgear::HTTP::Client const* client() const { return _http.get(); } - + virtual void init(); virtual void postinit(); virtual void shutdown(); @@ -47,9 +47,10 @@ public: std::string getDefaultCatalogId() const; std::string getDefaultCatalogUrl() const; std::string getDefaultCatalogFallbackUrl() const; - + static const char* subsystemName() { return "http"; } -private: + +private: bool _inited; std::unique_ptr _http; }; diff --git a/src/Network/fgcom.hxx b/src/Network/fgcom.hxx index e5b5ac54c..fcb115522 100644 --- a/src/Network/fgcom.hxx +++ b/src/Network/fgcom.hxx @@ -23,9 +23,10 @@ #include #include -class FGCom : public SGSubsystem, public SGPropertyChangeListener +class FGCom : public SGSubsystem, + public SGPropertyChangeListener { - public: +public: FGCom(); virtual ~FGCom(); @@ -38,9 +39,7 @@ class FGCom : public SGSubsystem, public SGPropertyChangeListener virtual void shutdown(); void iaxTextEvent(struct iaxc_ev_text text); - - private: - +private: SGPropertyNode_ptr _ptt_node; // PTT; nonzero int indicating channel number (instrumentation/comm/[channel-1]) SGPropertyNode_ptr _selected_comm_node; // selected channel (fgcom); nonzero channel int indicating channel number (instrumentation/comm/[channel-1]) SGPropertyNode_ptr _commFrequencyNode; // current comm node in use; e.g. /instrumentation/comm[0] @@ -68,7 +67,6 @@ class FGCom : public SGSubsystem, public SGPropertyChangeListener SGPropertyNode_ptr _mpTransmitFrequencyNode; // sim/multiplay/comm-transmit-frequency-mhz SGPropertyNode_ptr _mpTransmitPowerNode; // sim/multiplay/comm-transmit-power-norm - double _maxRange; double _minRange; double _currentCommFrequency; @@ -98,7 +96,6 @@ class FGCom : public SGSubsystem, public SGPropertyChangeListener void updateCall(); void connectToCommFrequency(); void testMode(bool testMode); - }; #endif // of FG_FGCOM_HXX diff --git a/src/Network/http/httpd.cxx b/src/Network/http/httpd.cxx index f929e2a6f..661809b11 100644 --- a/src/Network/http/httpd.cxx +++ b/src/Network/http/httpd.cxx @@ -166,73 +166,72 @@ public: * * Mongoose API is documented here: http://cesanta.com/docs/API.shtml */ -class MongooseHttpd: public FGHttpd { +class MongooseHttpd : public FGHttpd +{ public: + /** + * Construct a MongooseHttpd object from options in a PropertyNode + */ + MongooseHttpd(SGPropertyNode_ptr); - /** - * Construct a MongooseHttpd object from options in a PropertyNode - */ - MongooseHttpd(SGPropertyNode_ptr); + /** + * Cleanup et.al. + */ + ~MongooseHttpd(); - /** - * Cleanup et.al. - */ - ~MongooseHttpd(); + /** + * override SGSubsystem::init() + * + * Reads the configuration PropertyNode, installs URIHandlers and configures mongoose + */ + void init(); - /** - * override SGSubsystem::init() - * - * Reads the configuration PropertyNode, installs URIHandlers and configures mongoose - */ - void init(); + /** + * override SGSubsystem::bind() + * + * Currently a noop + */ + void bind(); - /** - * override SGSubsystem::bind() - * - * Currently a noop - */ - void bind(); + /** + * override SGSubsystem::unbind() + * shutdown of mongoose, clear connections, unregister URIHandlers + */ + void unbind(); - /** - * override SGSubsystem::unbind() - * shutdown of mongoose, clear connections, unregister URIHandlers - */ - void unbind(); + /** + * overrride SGSubsystem::update() + * poll connections, check for changed properties + */ + void update(double dt); - /** - * overrride SGSubsystem::update() - * poll connections, check for changed properties - */ - void update(double dt); + /** + * Returns a URIHandler for the given uri + * + * @see URIHandlerMap::findHandler( const std::string & uri ) + */ + SGSharedPtr findHandler(const std::string & uri) { + return _uriHandler.findHandler(uri); + } - /** - * Returns a URIHandler for the given uri - * - * @see URIHandlerMap::findHandler( const std::string & uri ) - */ - SGSharedPtr findHandler(const std::string & uri) - { - return _uriHandler.findHandler(uri); - } - - Websocket * newWebsocket(const string & uri); + Websocket * newWebsocket(const string & uri); private: - int poll(struct mg_connection * connection); - int auth(struct mg_connection * connection); - int request(struct mg_connection * connection); - int onConnect(struct mg_connection * connection); - void close(struct mg_connection * connection); + int poll(struct mg_connection * connection); + int auth(struct mg_connection * connection); + int request(struct mg_connection * connection); + int onConnect(struct mg_connection * connection); + void close(struct mg_connection * connection); - static int staticRequestHandler(struct mg_connection *, mg_event event); + static int staticRequestHandler(struct mg_connection *, mg_event event); - struct mg_server *_server; - SGPropertyNode_ptr _configNode; + struct mg_server *_server; + SGPropertyNode_ptr _configNode; - typedef int (MongooseHttpd::*handler_t)(struct mg_connection *); - URIHandlerMap _uriHandler; + typedef int (MongooseHttpd::*handler_t)(struct mg_connection *); + URIHandlerMap _uriHandler; - PropertyChangeObserver _propertyChangeObserver; + PropertyChangeObserver _propertyChangeObserver; }; class MongooseConnection: public Connection { diff --git a/src/Network/http/httpd.hxx b/src/Network/http/httpd.hxx index 764785ced..1574a5cb7 100644 --- a/src/Network/http/httpd.hxx +++ b/src/Network/http/httpd.hxx @@ -26,6 +26,7 @@ namespace flightgear { + namespace http { extern const char * PROPERTY_ROOT; @@ -36,7 +37,8 @@ public: static FGHttpd * createInstance( SGPropertyNode_ptr configNode ); }; -} +} // namespace http + } // namespace flightgear #endif // FG_HTTPD_HXX diff --git a/src/Scenery/scenery.hxx b/src/Scenery/scenery.hxx index 648a00565..28304bfa3 100644 --- a/src/Scenery/scenery.hxx +++ b/src/Scenery/scenery.hxx @@ -25,9 +25,9 @@ #define _SCENERY_HXX -#ifndef __cplusplus +#ifndef __cplusplus # error This library requires C++ -#endif +#endif #include #include @@ -52,7 +52,6 @@ class FGScenery : public SGSubsystem class ScenerySwitchListener; friend class ScenerySwitchListener; - // scene graph osg::ref_ptr scene_graph; osg::ref_ptr terrain_branch; @@ -61,7 +60,7 @@ class FGScenery : public SGSubsystem osg::ref_ptr interior_branch; osg::ref_ptr particles_branch; osg::ref_ptr precipitation_branch; - + osg::ref_ptr _pager; ScenerySwitchListener* _listener; @@ -88,7 +87,7 @@ public: /// The altitude hit is returned in the alt argument. /// The method returns true if the scenery is available for the given /// lat/lon pair. If there is no scenery for that point, the altitude - /// value is undefined. + /// value is undefined. /// All values are meant to be in meters or degrees. bool get_elevation_m(const SGGeod& geod, double& alt, const simgear::BVHMaterial** material, @@ -110,7 +109,7 @@ public: const simgear::BVHMaterial** material, const osg::Node* butNotFrom = 0); - /// Compute the nearest intersection point of the line starting from + /// Compute the nearest intersection point of the line starting from /// start going in direction dir with the terrain. /// The input and output values should be in cartesian coordinates in the /// usual earth centered wgs84 coordinate system. Units are meters. @@ -126,7 +125,7 @@ public: osg::Group *get_interior_branch () const { return interior_branch.get(); } osg::Group *get_particles_branch () const { return particles_branch.get(); } osg::Group *get_precipitation_branch () const { return precipitation_branch.get(); } - + /// Returns true if scenery is available for the given lat, lon position /// within a range of range_m. /// lat and lon are expected to be in degrees. @@ -138,7 +137,7 @@ public: static void resetPagerSingleton(); flightgear::SceneryPager* getPager() { return _pager.get(); } - + // tile mgr api bool schedule_scenery(const SGGeod& position, double range_m, double duration=0.0); void materialLibChanged(); @@ -149,7 +148,7 @@ private: // the terrain engine FGTerrain* _terrain; - // The state of the scene graph. + // The state of the scene graph. bool _inited; }; diff --git a/src/Scripting/NasalSys.hxx b/src/Scripting/NasalSys.hxx index 22bf5adbf..fd39faa4f 100644 --- a/src/Scripting/NasalSys.hxx +++ b/src/Scripting/NasalSys.hxx @@ -54,7 +54,7 @@ public: bool parseAndRunWithOutput(const std::string& source, std::string& output, std::string& errors); - + // Slightly more complicated hook to get a handle to a precompiled // Nasal script that can be invoked via a call() method. The // caller is expected to delete the FGNasalScript returned from @@ -74,13 +74,13 @@ public: naRef cmdArgGhost(); void setCmdArg(SGPropertyNode* aNode); - + /** * create Nasal props.Node for an SGPropertyNode* * This is the actual ghost, wrapped in a Nasal sugar class. */ naRef wrappedPropsNode(SGPropertyNode* aProps); - + // Callbacks for command and timer bindings virtual bool handleCommand( const char* moduleName, const char* fileName, @@ -99,7 +99,7 @@ public: void addCommand(naRef func, const std::string& name); void removeCommand(const std::string& name); - + /** * Set member of specified hash to given value */ @@ -112,12 +112,12 @@ public: naRef call(naRef code, int argc, naRef* args, naRef locals); naRef callWithContext(naContext ctx, naRef code, int argc, naRef* args, naRef locals); - + naRef callMethod(naRef code, naRef self, int argc, naRef* args, naRef locals); naRef callMethodWithContext(naContext ctx, naRef code, naRef self, int argc, naRef* args, naRef locals); - + naRef propNodeGhost(SGPropertyNode* handle); - + void registerToLoad(FGNasalModelData* data); void registerToUnload(FGNasalModelData* data); @@ -127,7 +127,7 @@ public: nasal::Hash getGlobals() const { return nasal::Hash(_globals, _context); } - + // This mechanism is here to allow naRefs to be passed to // locations "outside" the interpreter. Normally, such a // reference would be garbage collected unexpectedly. By passing @@ -157,6 +157,7 @@ public: { return _log.get(); } static const char* subsystemName() { return "nasal"; } + private: //friend class FGNasalScript; friend class FGNasalListener; @@ -171,9 +172,9 @@ private: // Listener std::map _listener; std::vector _dead_listener; - + std::vector _moduleListeners; - + static int _listenerId; void loadPropertyScripts(); @@ -193,12 +194,12 @@ private: SGPropertyNode_ptr _cmdArg; std::unique_ptr _log; - + typedef std::map NasalCommandDict; NasalCommandDict _commands; - + naRef _wrappedNodeFunc; - + // track NasalTimer instances (created via settimer() call) - // this allows us to clean these up on shutdown std::vector _nasalTimers; @@ -206,15 +207,15 @@ private: // NasalTimer is a friend to invoke handleTimer and do the actual // dispatch of the settimer-d callback friend NasalTimer; - + void handleTimer(NasalTimer* t); - + // track persistent timers. These are owned from the Nasal side, so we // only track a non-owning reference here. std::vector _persistentTimers; - + friend TimerObj; - + void addPersistentTimer(TimerObj* pto); void removePersistentTimer(TimerObj* obj); @@ -222,7 +223,8 @@ private: }; #if 0 -class FGNasalScript { +class FGNasalScript +{ public: ~FGNasalScript() { _nas->gcRelease(_gcKey); } @@ -231,8 +233,9 @@ public: naCall(_nas->_context, _code, 0, &n, naNil(), naNil()); return naGetError(_nas->_context) == 0; } - + FGNasalSys* sys() const { return _nas; } + private: friend class FGNasalSys; naRef _code; diff --git a/src/Sound/voice.hxx b/src/Sound/voice.hxx index 5625a9784..b22651b61 100644 --- a/src/Sound/voice.hxx +++ b/src/Sound/voice.hxx @@ -50,51 +50,56 @@ using std::vector; -class FGVoiceMgr : public SGSubsystem { +class FGVoiceMgr : public SGSubsystem +{ public: - FGVoiceMgr(); - ~FGVoiceMgr(); - void init(void); - void shutdown(); - void update(double dt); + FGVoiceMgr(); + ~FGVoiceMgr(); + void init(void); + void shutdown(); + void update(double dt); + class FGVoice; - class FGVoice; protected: - friend class FGFestivalVoice; + friend class FGFestivalVoice; + #if defined(ENABLE_THREADS) - class FGVoiceThread; - FGVoiceThread *_thread; + class FGVoiceThread; + FGVoiceThread *_thread; #endif - std::string _host; - std::string _port; - bool _enabled; - SGPropertyNode_ptr _pausedNode; - bool _paused; - std::vector _voices; + std::string _host; + std::string _port; + bool _enabled; + SGPropertyNode_ptr _pausedNode; + bool _paused; + std::vector _voices; }; #if defined(ENABLE_THREADS) -class FGVoiceMgr::FGVoiceThread : public OpenThreads::Thread { +class FGVoiceMgr::FGVoiceThread : public OpenThreads::Thread +{ public: - FGVoiceThread(FGVoiceMgr *mgr) : _mgr(mgr) {} - void run(); - void wake_up() { _jobs.signal(); } + FGVoiceThread(FGVoiceMgr *mgr) : _mgr(mgr) {} + void run(); + void wake_up() { _jobs.signal(); } private: - void wait_for_jobs() { OpenThreads::ScopedLock g(_mutex); _jobs.wait(&_mutex); } - OpenThreads::Condition _jobs; - OpenThreads::Mutex _mutex; + void wait_for_jobs() { OpenThreads::ScopedLock g(_mutex); _jobs.wait(&_mutex); } + OpenThreads::Condition _jobs; + OpenThreads::Mutex _mutex; + protected: - FGVoiceMgr *_mgr; + FGVoiceMgr *_mgr; }; #endif -class FGVoiceMgr::FGVoice : public SGPropertyChangeListener { +class FGVoiceMgr::FGVoice : public SGPropertyChangeListener +{ public: FGVoice(FGVoiceMgr * mgr ) : _mgr(mgr) {} virtual ~FGVoice() {} @@ -108,13 +113,11 @@ protected: FGVoiceMgr *_mgr; - #if defined(ENABLE_THREADS) +#if defined(ENABLE_THREADS) SGLockedQueue _msg; #else std::queue _msg; #endif - - }; #endif // _VOICE_HXX diff --git a/src/Systems/electrical.hxx b/src/Systems/electrical.hxx index 248fbc720..5eff6779b 100644 --- a/src/Systems/electrical.hxx +++ b/src/Systems/electrical.hxx @@ -37,20 +37,18 @@ class FGElectricalSystem; // Base class for other electrical components -class FGElectricalComponent { - +class FGElectricalComponent +{ public: - -enum FGElectricalComponentType { - FG_UNKNOWN, - FG_SUPPLIER, - FG_BUS, - FG_OUTPUT, - FG_CONNECTOR -}; + enum FGElectricalComponentType { + FG_UNKNOWN, + FG_SUPPLIER, + FG_BUS, + FG_OUTPUT, + FG_CONNECTOR + }; protected: - using comp_list = std::vector ; int kind; @@ -67,7 +65,6 @@ protected: simgear::PropertyList props; public: - FGElectricalComponent(); virtual ~FGElectricalComponent() {} @@ -108,10 +105,9 @@ public: // Electrical supplier -class FGElectricalSupplier : public FGElectricalComponent { - +class FGElectricalSupplier : public FGElectricalComponent +{ public: - enum FGSupplierType { FG_BATTERY, FG_ALTERNATOR, @@ -120,7 +116,6 @@ public: }; private: - SGPropertyNode_ptr _rpm_node; FGSupplierType model; // store supplier type @@ -139,7 +134,6 @@ private: float charge_amps; // maximum charge load battery can draw public: - FGElectricalSupplier ( SGPropertyNode *node ); ~FGElectricalSupplier () {} @@ -153,10 +147,9 @@ public: // Electrical bus (can take multiple inputs and provide multiple // outputs) -class FGElectricalBus : public FGElectricalComponent { - +class FGElectricalBus : public FGElectricalComponent +{ public: - FGElectricalBus ( SGPropertyNode *node ); ~FGElectricalBus () {} }; @@ -164,10 +157,9 @@ public: // A lot like an FGElectricalBus, but here for convenience and future // flexibility -class FGElectricalOutput : public FGElectricalComponent { - +class FGElectricalOutput : public FGElectricalComponent +{ public: - FGElectricalOutput ( SGPropertyNode *node ); ~FGElectricalOutput () {} }; @@ -175,16 +167,14 @@ public: // Model an electrical switch. If the rating_amps > 0 then this // becomes a circuit breaker type switch that can trip -class FGElectricalSwitch { - +class FGElectricalSwitch +{ private: - SGPropertyNode_ptr switch_node; float rating_amps; bool circuit_breaker; public: - FGElectricalSwitch( SGPropertyNode *node ); ~FGElectricalSwitch() { }; @@ -196,15 +186,14 @@ public: // Connects multiple sources to multiple destinations with optional // switches/fuses/circuit breakers inline -class FGElectricalConnector : public FGElectricalComponent { - +class FGElectricalConnector : public FGElectricalComponent +{ comp_list inputs; comp_list outputs; typedef vector< FGElectricalSwitch> switch_list; switch_list switches; public: - FGElectricalConnector ( SGPropertyNode *node, FGElectricalSystem *es ); ~FGElectricalConnector () {} @@ -221,14 +210,12 @@ public: /** * Model an electrical system. This is a fairly simplistic system - * + * */ class FGElectricalSystem : public SGSubsystem { - public: - FGElectricalSystem ( SGPropertyNode *node ); virtual ~FGElectricalSystem (); @@ -244,11 +231,9 @@ public: FGElectricalComponent *find ( const std::string &name ); protected: - typedef vector comp_list; private: - std::string name; int num; std::string path; @@ -266,5 +251,4 @@ private: bool _serviceable = true; }; - #endif // _SYSTEMS_ELECTRICAL_HXX diff --git a/src/Systems/pitot.hxx b/src/Systems/pitot.hxx index f694439d9..520a1d08a 100644 --- a/src/Systems/pitot.hxx +++ b/src/Systems/pitot.hxx @@ -40,9 +40,7 @@ using std::string; */ class PitotSystem : public SGSubsystem { - public: - PitotSystem ( SGPropertyNode *node ); virtual ~PitotSystem (); @@ -52,7 +50,6 @@ public: virtual void update (double dt); private: - std::string _name; int _num; double _stall_factor; diff --git a/src/Systems/static.hxx b/src/Systems/static.hxx index ccb30cafd..41ea28aa8 100644 --- a/src/Systems/static.hxx +++ b/src/Systems/static.hxx @@ -35,9 +35,7 @@ */ class StaticSystem : public SGSubsystem { - public: - StaticSystem ( SGPropertyNode *node ); StaticSystem ( int i ); virtual ~StaticSystem (); @@ -49,7 +47,6 @@ public: virtual void update (double dt); private: - std::string _name; int _num; double _tau; @@ -61,7 +58,6 @@ private: SGPropertyNode_ptr _beta_node; SGPropertyNode_ptr _alpha_node; SGPropertyNode_ptr _mach_node; - }; #endif // __SYSTEMS_STATIC_HXX diff --git a/src/Systems/system_mgr.hxx b/src/Systems/system_mgr.hxx index ca5d64fa3..f2ea8c0d4 100644 --- a/src/Systems/system_mgr.hxx +++ b/src/Systems/system_mgr.hxx @@ -28,11 +28,9 @@ class FGSystemMgr : public SGSubsystemGroup { public: - FGSystemMgr (); virtual ~FGSystemMgr (); bool build (SGPropertyNode* config_props); - }; #endif // __SYSTEM_MGR_HXX diff --git a/src/Systems/vacuum.hxx b/src/Systems/vacuum.hxx index c9507c816..162c203d1 100644 --- a/src/Systems/vacuum.hxx +++ b/src/Systems/vacuum.hxx @@ -35,9 +35,7 @@ */ class VacuumSystem : public SGSubsystem { - public: - VacuumSystem( SGPropertyNode *node ); VacuumSystem( int i ); virtual ~VacuumSystem (); @@ -49,7 +47,6 @@ public: virtual void update (double dt); private: - std::string _name; int _num; string_list _rpms; @@ -58,7 +55,6 @@ private: std::vector _rpm_nodes; SGPropertyNode_ptr _pressure_node; SGPropertyNode_ptr _suction_node; - }; #endif // __SYSTEMS_VACUUM_HXX diff --git a/src/Time/TimeManager.hxx b/src/Time/TimeManager.hxx index 612536b4c..0f928a857 100644 --- a/src/Time/TimeManager.hxx +++ b/src/Time/TimeManager.hxx @@ -27,84 +27,85 @@ // forward decls class SGTime; -class TimeManager : public SGSubsystem, public SGPropertyChangeListener +class TimeManager : public SGSubsystem, + public SGPropertyChangeListener { public: - TimeManager(); - virtual ~TimeManager(); - - void computeTimeDeltas(double& simDt, double& realDt); - - void init() override; - void reinit() override; - void postinit() override; - void shutdown() override; - void unbind() override; - void update(double dt) override; - - // SGPropertyChangeListener overrides - void valueChanged(SGPropertyNode *) override; - - void setTimeOffset(const std::string& offset_type, long int offset); + TimeManager(); + virtual ~TimeManager(); + + void computeTimeDeltas(double& simDt, double& realDt); + + void init() override; + void reinit() override; + void postinit() override; + void shutdown() override; + void unbind() override; + void update(double dt) override; + + // SGPropertyChangeListener overrides + void valueChanged(SGPropertyNode *) override; + + void setTimeOffset(const std::string& offset_type, long int offset); + + inline double getMPProtocolClockSec() const { return _mpProtocolClock; } + inline double getSteadyClockSec() const { return _steadyClock; } + + static const char* subsystemName() { return "time"; } - inline double getMPProtocolClockSec() const { return _mpProtocolClock; } - inline double getSteadyClockSec() const { return _steadyClock; } - - static const char* subsystemName() { return "time"; } private: - - /** - * Ensure a consistent update-rate using a combination of - * sleep()-ing and busy-waiting. - */ - void throttleUpdateRate(); - - /** - * Compute frame (update) rate and write it to a property - */ - void computeFrameRate(); - - void updateLocalTime(); - - // set up a time offset (aka warp) if one is specified - void initTimeOffset(); - - bool _inited; - SGTime* _impl; - SGTimeStamp _lastStamp; - SGTimeStamp _systemStamp; - bool _firstUpdate; - double _dtRemainder; - SGPropertyNode_ptr _maxDtPerFrame; - SGPropertyNode_ptr _clockFreeze; - SGPropertyNode_ptr _timeOverride; - SGPropertyNode_ptr _warp; - SGPropertyNode_ptr _warpDelta; - SGPropertyNode_ptr _simTimeFactor; - SGPropertyNode_ptr _mpProtocolClockNode; - SGPropertyNode_ptr _steadyClockNode; - SGPropertyNode_ptr _mpClockOffset; - SGPropertyNode_ptr _steadyClockDrift; - SGPropertyNode_ptr _computeDrift; - SGPropertyNode_ptr _frameWait; - SGPropertyNode_ptr _maxFrameRate; + /** + * Ensure a consistent update-rate using a combination of + * sleep()-ing and busy-waiting. + */ + void throttleUpdateRate(); - bool _lastClockFreeze; - bool _adjustWarpOnUnfreeze; - - // frame-rate / worst-case latency / update-rate counters - SGPropertyNode_ptr _frameRate; - SGPropertyNode_ptr _frameRateWorst; - SGPropertyNode_ptr _frameLatency; - time_t _lastFrameTime; - double _frameLatencyMax; - double _mpProtocolClock; - double _steadyClock; - int _frameCount; - - SGPropertyNode_ptr _sceneryLoaded; - SGPropertyNode_ptr _modelHz; - SGPropertyNode_ptr _timeDelta, _simTimeDelta; + /** + * Compute frame (update) rate and write it to a property + */ + void computeFrameRate(); + + void updateLocalTime(); + + // set up a time offset (aka warp) if one is specified + void initTimeOffset(); + + bool _inited; + SGTime* _impl; + SGTimeStamp _lastStamp; + SGTimeStamp _systemStamp; + bool _firstUpdate; + double _dtRemainder; + SGPropertyNode_ptr _maxDtPerFrame; + SGPropertyNode_ptr _clockFreeze; + SGPropertyNode_ptr _timeOverride; + SGPropertyNode_ptr _warp; + SGPropertyNode_ptr _warpDelta; + SGPropertyNode_ptr _simTimeFactor; + SGPropertyNode_ptr _mpProtocolClockNode; + SGPropertyNode_ptr _steadyClockNode; + SGPropertyNode_ptr _mpClockOffset; + SGPropertyNode_ptr _steadyClockDrift; + SGPropertyNode_ptr _computeDrift; + SGPropertyNode_ptr _frameWait; + SGPropertyNode_ptr _maxFrameRate; + + bool _lastClockFreeze; + bool _adjustWarpOnUnfreeze; + + // frame-rate / worst-case latency / update-rate counters + SGPropertyNode_ptr _frameRate; + SGPropertyNode_ptr _frameRateWorst; + SGPropertyNode_ptr _frameLatency; + time_t _lastFrameTime; + double _frameLatencyMax; + double _mpProtocolClock; + double _steadyClock; + int _frameCount; + + SGPropertyNode_ptr _sceneryLoaded; + SGPropertyNode_ptr _modelHz; + SGPropertyNode_ptr _timeDelta, _simTimeDelta; }; #endif // of FG_TIME_TIMEMANAGER_HXX diff --git a/src/Time/light.hxx b/src/Time/light.hxx index 221688ef7..1d3443f9e 100644 --- a/src/Time/light.hxx +++ b/src/Time/light.hxx @@ -25,9 +25,9 @@ #define _LIGHT_HXX -#ifndef __cplusplus +#ifndef __cplusplus # error This library requires C++ -#endif +#endif #ifdef HAVE_CONFIG_H @@ -45,9 +45,7 @@ // Define a structure containing the global lighting parameters class FGLight : public SGSubsystem { - private: - /* * Lighting look up tables (based on sun angle with local horizon) */ @@ -120,7 +118,7 @@ private: // properties for chrome light; not a tie because I want to fire // property listeners when the values change. SGPropertyNode_ptr _chromeProps[4]; - + SGPropertyNode_ptr _sunAngleRad; SGPropertyNode_ptr _moonAngleRad; @@ -138,7 +136,6 @@ private: } public: - FGLight (); virtual ~FGLight (); diff --git a/src/Traffic/TrafficMgr.hxx b/src/Traffic/TrafficMgr.hxx index a399bc7e9..929602c26 100644 --- a/src/Traffic/TrafficMgr.hxx +++ b/src/Traffic/TrafficMgr.hxx @@ -21,26 +21,26 @@ /************************************************************************** * This file contains the class definitions for a (Top Level) traffic - * manager for FlightGear. - * - * This is traffic manager version II. The major difference from version + * manager for FlightGear. + * + * This is traffic manager version II. The major difference from version * I is that the Flight Schedules are decoupled from the AIAircraft * entities. This allows for a much greater flexibility in setting up * Irregular schedules. Traffic Manager II also makes no longer use of .xml - * based configuration files. - * + * based configuration files. + * * Here is a step plan to achieve the goal of creating Traffic Manager II - * + * * 1) Read aircraft data from a simple text file, like the one provided by * Gabor Toth - * 2) Create a new database structure of SchedFlights. This new database + * 2) Create a new database structure of SchedFlights. This new database * should not be part of the Schedule class, but of TrafficManager itself * 3) Each aircraft should have a list of possible Flights it can operate - * (i.e. airline and AC type match). - * 4) Aircraft processing proceeds as current. During initialization, we seek - * the most urgent flight that needs to be operated + * (i.e. airline and AC type match). + * 4) Aircraft processing proceeds as current. During initialization, we seek + * the most urgent flight that needs to be operated * 5) Modify the getNextLeg function so that the next flight is loaded smoothly. - + **************************************************************************/ #ifndef _TRAFFICMGR_HXX_ @@ -59,10 +59,10 @@ class Heuristic { public: - std::string registration; - unsigned int runCount; - unsigned int hits; - unsigned int lastRun; + std::string registration; + unsigned int runCount; + unsigned int hits; + unsigned int lastRun; }; typedef std::vector heuristicsVector; @@ -72,54 +72,52 @@ typedef std::map < std::string, Heuristic> HeuristicMap; typedef HeuristicMap::iterator HeuristicMapIterator; - class ScheduleParseThread; class FGTrafficManager : public SGSubsystem { private: - bool inited; - bool doingInit; + bool inited; + bool doingInit; bool trafficSyncRequested; - - double waitingMetarTime; - std::string waitingMetarStation; - - ScheduleVector scheduledAircraft; - ScheduleVectorIterator currAircraft, currAircraftClosest; - - FGScheduledFlightMap flights; - void readTimeTableFromFile(SGPath infilename); + double waitingMetarTime; + std::string waitingMetarStation; + + ScheduleVector scheduledAircraft; + ScheduleVectorIterator currAircraft, currAircraftClosest; + + FGScheduledFlightMap flights; + + void readTimeTableFromFile(SGPath infilename); void Tokenize(const std::string& str, std::vector& tokens, const std::string& delimiters = " "); - simgear::PropertyObject enabled, aiEnabled, realWxEnabled, metarValid, active, aiDataUpdateNow; - - void loadHeuristics(); - - bool doDataSync(); - void finishInit(); - void shutdown(); - - friend class ScheduleParseThread; - std::unique_ptr scheduleParser; - - // helper to read and parse the schedule data. - // this is run on a helper thread, so be careful about - // accessing properties during parsing - void parseSchedule(const SGPath& path); - - bool metarReady(double dt); + simgear::PropertyObject enabled, aiEnabled, realWxEnabled, metarValid, active, aiDataUpdateNow; + + void loadHeuristics(); + + bool doDataSync(); + void finishInit(); + void shutdown(); + + friend class ScheduleParseThread; + std::unique_ptr scheduleParser; + + // helper to read and parse the schedule data. + // this is run on a helper thread, so be careful about + // accessing properties during parsing + void parseSchedule(const SGPath& path); + + bool metarReady(double dt); public: - FGTrafficManager(); - ~FGTrafficManager(); - void init(); - void update(double time); + FGTrafficManager(); + ~FGTrafficManager(); + void init(); + void update(double time); FGScheduledFlightVecIterator getFirstFlight(const std::string &ref) { return flights[ref].begin(); } FGScheduledFlightVecIterator getLastFlight(const std::string &ref) { return flights[ref].end(); } - }; #endif diff --git a/src/Viewer/view.hxx b/src/Viewer/view.hxx index 773909b69..591b5c2f8 100644 --- a/src/Viewer/view.hxx +++ b/src/Viewer/view.hxx @@ -25,7 +25,7 @@ #ifndef _VIEWER_HXX -#define _VIEWER_HXX +#define _VIEWER_HXX #include @@ -43,15 +43,14 @@ namespace flightgear { // Define a structure containing view information -class View : public SGSubsystem { - +class View : public SGSubsystem +{ public: - enum ScalingType { // nominal Field Of View actually applies to ... - FG_SCALING_WIDTH, // window width - FG_SCALING_MAX // max(width, height) - // FG_SCALING_G_MEAN, // geometric_mean(width, height) - // FG_SCALING_INDEPENDENT // whole screen + FG_SCALING_WIDTH, // window width + FG_SCALING_MAX // max(width, height) + // FG_SCALING_G_MEAN, // geometric_mean(width, height) + // FG_SCALING_INDEPENDENT // whole screen }; enum ViewType { @@ -89,7 +88,7 @@ public: // Reference geodetic position of view from position... // These are the actual aircraft position (pilot in // pilot view, model in model view). - // FIXME: the model view position (ie target positions) + // FIXME: the model view position (ie target positions) // should be in the model class. @@ -102,15 +101,15 @@ public: // Position offsets from reference // These offsets position they "eye" in the scene according to a given - // location. For example in pilot view they are used to position the + // location. For example in pilot view they are used to position the // head inside the aircraft. - // Note that in pilot view these are applied "before" the orientation - // rotations (see below) so that the orientation rotations have the - // effect of the pilot staying in his seat and "looking out" in + // Note that in pilot view these are applied "before" the orientation + // rotations (see below) so that the orientation rotations have the + // effect of the pilot staying in his seat and "looking out" in // different directions. - // In chase view these are applied "after" the application of the - // orientation rotations listed below. This has the effect of the - // eye moving around and "looking at" the object (model) from + // In chase view these are applied "after" the application of the + // orientation rotations listed below. This has the effect of the + // eye moving around and "looking at" the object (model) from // different angles. SGVec3d getOffset_m () const { return _offset_m; } double getXOffset_m () const { return _offset_m.x(); } @@ -126,8 +125,8 @@ public: void setTargetYOffset_m (double y_offset_m); void setTargetZOffset_m (double z_offset_m); void setPositionOffsets (double x_offset_m, - double y_offset_m, - double z_offset_m); + double y_offset_m, + double z_offset_m); // Reference orientation rotations... // These are rotations that represent the plane attitude effect on @@ -186,7 +185,6 @@ public: void set_dirty() { _dirty = true; } private: - // Constructor View( ViewType Type, bool from_model, int from_model_index, bool at_model, int at_model_index, @@ -260,8 +258,6 @@ private: void setTargetOrientation (double roll_deg, double pitch_deg, double heading_deg); - - // Orientation offsets rotations from reference orientation. // Goal settings are for smooth transition from prior // offset when changing view direction. @@ -282,7 +278,7 @@ private: void setOrientationOffsets (double roll_offset_deg, double heading_offset_deg, double pitch_offset_deg); - + void set_aspect_ratio_multiplier( double m ) { _aspect_ratio_multiplier = m; } @@ -304,7 +300,7 @@ private: ////////////////////////////////////////////////////////////////// std::string _name, _typeString; - + // flag forcing a recalc of derived view parameters bool _dirty; @@ -331,7 +327,7 @@ private: SGVec3d _dampTarget; ///< current target value we are damping towards SGVec3d _dampOutput; ///< current output of damping filter SGVec3d _dampFactor; ///< weighting of the damping filter - + // Position offsets from FDM origin. The X axis is positive // out the tail, Y is out the right wing, and Z is positive up. // distance in meters @@ -380,7 +376,7 @@ private: { public: PositionAttitudeProperties(); - + void init(SGPropertyNode_ptr parent, const std::string& prefix); virtual ~PositionAttitudeProperties(); @@ -392,7 +388,7 @@ private: virtual void valueChanged(SGPropertyNode* prop); private: -// disable copy + // disable copy PositionAttitudeProperties(const PositionAttitudeProperties&); SGPropertyNode_ptr resolvePathProperty(SGPropertyNode_ptr p); @@ -424,30 +420,28 @@ private: void setDampTarget(double h, double p, double r); void getDampOutput(double& roll, double& pitch, double& heading); - + void updateDampOutput(double dt); - + // add to _heading_offset_deg inline void incHeadingOffset_deg( double amt ) { - set_dirty(); - _heading_offset_deg += amt; + set_dirty(); + _heading_offset_deg += amt; } // add to _pitch_offset_deg inline void incPitchOffset_deg( double amt ) { - set_dirty(); - _pitch_offset_deg += amt; + set_dirty(); + _pitch_offset_deg += amt; } // add to _roll_offset_deg inline void incRollOffset_deg( double amt ) { - set_dirty(); - _roll_offset_deg += amt; + set_dirty(); + _roll_offset_deg += amt; } - }; // of class View } // of namespace flightgear - #endif // _VIEWER_HXX diff --git a/src/Viewer/viewmgr.hxx b/src/Viewer/viewmgr.hxx index 8093323d8..14f763860 100644 --- a/src/Viewer/viewmgr.hxx +++ b/src/Viewer/viewmgr.hxx @@ -42,9 +42,7 @@ namespace flightgear // Define a structure containing view information class FGViewMgr : public SGSubsystem { - public: - // Constructor FGViewMgr( void ); @@ -58,26 +56,27 @@ public: virtual void update (double dt); virtual void reinit (); virtual void shutdown(); - + // getters inline int size() const { return views.size(); } inline int get_current() const { return current; } - + flightgear::View* get_current_view(); const flightgear::View* get_current_view() const; - + flightgear::View* get_view( int i ); const flightgear::View* get_view( int i ) const; - + flightgear::View* next_view(); flightgear::View* prev_view(); - + // setters void clear(); void add_view( flightgear::View * v ); - + static const char* subsystemName() { return "view-manager"; } + private: simgear::TiedPropertyList _tiedProperties; @@ -93,5 +92,4 @@ private: int current; }; - #endif // _VIEWMGR_HXX diff --git a/utils/fgpanel/FGPanel.hxx b/utils/fgpanel/FGPanel.hxx index dc0003574..1be60898d 100644 --- a/utils/fgpanel/FGPanel.hxx +++ b/utils/fgpanel/FGPanel.hxx @@ -51,59 +51,59 @@ using namespace std; * redraw themselves when necessary, and will pass mouse clicks on to * the appropriate instruments for processing. */ -class FGPanel : public SGSubsystem { +class FGPanel : public SGSubsystem +{ public: - FGPanel (const SGPropertyNode_ptr root); - virtual ~FGPanel (); + FGPanel (const SGPropertyNode_ptr root); + virtual ~FGPanel (); - // Update the panel (every frame). - virtual void init (); - virtual void bind (); - virtual void unbind (); - // virtual void draw (); - virtual void update (const double dt); + // Update the panel (every frame). + virtual void init (); + virtual void bind (); + virtual void unbind (); + // virtual void draw (); + virtual void update (const double dt); - // transfer pointer ownership!!! - virtual void addInstrument (FGPanelInstrument * const instrument); + // transfer pointer ownership!!! + virtual void addInstrument (FGPanelInstrument * const instrument); - // Background texture. - virtual void setBackground (const FGCroppedTexture_ptr texture); - void setBackgroundWidth (const double d); - void setBackgroundHeight (const double d); + // Background texture. + virtual void setBackground (const FGCroppedTexture_ptr texture); + void setBackgroundWidth (const double d); + void setBackgroundHeight (const double d); - // Background multiple textures. - virtual void setMultiBackground (const FGCroppedTexture_ptr texture , const int idx); + // Background multiple textures. + virtual void setMultiBackground (const FGCroppedTexture_ptr texture , const int idx); - // Full width of panel. - virtual void setWidth (const int width); - virtual int getWidth () const; + // Full width of panel. + virtual void setWidth (const int width); + virtual int getWidth () const; - // Full height of panel. - virtual void setHeight (const int height); - virtual int getHeight () const; + // Full height of panel. + virtual void setHeight (const int height); + virtual int getHeight () const; private: + typedef vector instrument_list_type; + int m_width; + int m_height; - typedef vector instrument_list_type; - int m_width; - int m_height; + SGPropertyNode_ptr m_flipx; - SGPropertyNode_ptr m_flipx; + FGCroppedTexture_ptr m_bg; + double m_bg_width; + double m_bg_height; + FGCroppedTexture_ptr m_mbg[8]; + // List of instruments in panel. + instrument_list_type m_instruments; - FGCroppedTexture_ptr m_bg; - double m_bg_width; - double m_bg_height; - FGCroppedTexture_ptr m_mbg[8]; - // List of instruments in panel. - instrument_list_type m_instruments; + void getInitDisplayList (); - void getInitDisplayList (); - - static GLuint Textured_Layer_Program_Object; - static GLint Textured_Layer_Position_Loc; - static GLint Textured_Layer_Tex_Coord_Loc; - static GLint Textured_Layer_MVP_Loc; - static GLint Textured_Layer_Sampler_Loc; + static GLuint Textured_Layer_Program_Object; + static GLint Textured_Layer_Position_Loc; + static GLint Textured_Layer_Tex_Coord_Loc; + static GLint Textured_Layer_MVP_Loc; + static GLint Textured_Layer_Sampler_Loc; }; #endif diff --git a/utils/fgpanel/FGPanelProtocol.hxx b/utils/fgpanel/FGPanelProtocol.hxx index c58e2f1d3..dec45f687 100644 --- a/utils/fgpanel/FGPanelProtocol.hxx +++ b/utils/fgpanel/FGPanelProtocol.hxx @@ -28,20 +28,21 @@ class PropertySetter; typedef vector PropertySetterVector; -class FGPanelProtocol : public SGSubsystem { +class FGPanelProtocol : public SGSubsystem +{ public: - FGPanelProtocol (SGPropertyNode_ptr a_Root); - virtual ~FGPanelProtocol (); - virtual void init (); - virtual void reinit (); - virtual void update (double dt); + FGPanelProtocol (SGPropertyNode_ptr a_Root); + virtual ~FGPanelProtocol (); + virtual void init (); + virtual void reinit (); + virtual void update (double dt); protected: private: - SGPropertyNode_ptr root; - SGIOChannel *io; - PropertySetterVector propertySetterVector; + SGPropertyNode_ptr root; + SGIOChannel *io; + PropertySetterVector propertySetterVector; }; #endif diff --git a/utils/fgpanel/panel_io.hxx b/utils/fgpanel/panel_io.hxx index bc502b09a..cf9d5feed 100644 --- a/utils/fgpanel/panel_io.hxx +++ b/utils/fgpanel/panel_io.hxx @@ -31,9 +31,10 @@ #include "FGPanel.hxx" -class FGReadablePanel : public FGPanel { +class FGReadablePanel : public FGPanel +{ public: - static SGSharedPtr read (SGPropertyNode_ptr root); + static SGSharedPtr read (SGPropertyNode_ptr root); }; #endif // __PANEL_IO_HXX