1
0
Fork 0

Separate instruments from cockpit displays.

This commit is contained in:
James Turner 2012-09-26 20:30:24 +01:00
parent 7d547d1287
commit 4994973ef4
21 changed files with 219 additions and 39 deletions

View file

@ -23,7 +23,7 @@
#include "property_based_element.hxx" #include "property_based_element.hxx"
#include <Canvas/canvas_fwd.hpp> #include <Canvas/canvas_fwd.hpp>
#include <Instrumentation/od_gauge.hxx> #include <Cockpit/od_gauge.hxx>
#include <simgear/props/propertyObject.hxx> #include <simgear/props/propertyObject.hxx>
#include <osg/NodeCallback> #include <osg/NodeCallback>

View file

@ -1,15 +1,29 @@
include(FlightGearComponent) include(FlightGearComponent)
set(SOURCES set(SOURCES
cockpitDisplayManager.cxx
panel.cxx panel.cxx
panel_io.cxx panel_io.cxx
built_in/FGMagRibbon.cxx built_in/FGMagRibbon.cxx
agradar.cxx
groundradar.cxx
od_gauge.cxx
render_area_2d.cxx
wxradar.cxx
NavDisplay.cxx
) )
set(HEADERS set(HEADERS
cockpitDisplayManager.hxx
panel.hxx panel.hxx
panel_io.hxx panel_io.hxx
built_in/FGMagRibbon.hxx built_in/FGMagRibbon.hxx
agradar.hxx
groundradar.hxx
od_gauge.hxx
render_area_2d.hxx
wxradar.hxx
NavDisplay.hxx
) )

View file

@ -63,7 +63,7 @@ using std::string;
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
#include <Main/globals.hxx> #include <Main/globals.hxx>
#include <Cockpit/panel.hxx> #include "panel.hxx"
#include <Navaids/routePath.hxx> #include <Navaids/routePath.hxx>
#include <Autopilot/route_mgr.hxx> #include <Autopilot/route_mgr.hxx>
#include <Navaids/navrecord.hxx> #include <Navaids/navrecord.hxx>
@ -71,8 +71,6 @@ using std::string;
#include <Navaids/fix.hxx> #include <Navaids/fix.hxx>
#include <Airports/simple.hxx> #include <Airports/simple.hxx>
#include <Airports/runways.hxx> #include <Airports/runways.hxx>
#include "instrument_mgr.hxx"
#include "od_gauge.hxx" #include "od_gauge.hxx"
static const char *DEFAULT_FONT = "typewriter.txf"; static const char *DEFAULT_FONT = "typewriter.txf";

View file

@ -0,0 +1,126 @@
// cockpitDisplayManager.cxx -- manage cockpit displays, typically
// rendered using a sub-camera or render-texture
//
// Copyright (C) 2012 James Turner zakalawe@mac.com
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "cockpitDisplayManager.hxx"
#include <simgear/structure/exception.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/sg_inlines.h>
#include <simgear/props/props_io.hxx>
#include <boost/foreach.hpp>
#include <Main/fg_props.hxx>
#include <Main/globals.hxx>
#include "agradar.hxx"
#include "NavDisplay.hxx"
#include "groundradar.hxx"
#include "wxradar.hxx"
namespace flightgear
{
CockpitDisplayManager::CockpitDisplayManager ()
{
}
CockpitDisplayManager::~CockpitDisplayManager ()
{
}
SGSubsystem::InitStatus CockpitDisplayManager::incrementalInit()
{
init();
return INIT_DONE;
}
void CockpitDisplayManager::init()
{
SGPropertyNode_ptr config_props = new SGPropertyNode;
SGPropertyNode* path_n = fgGetNode("/sim/instrumentation/path");
if (!path_n) {
SG_LOG(SG_COCKPIT, SG_WARN, "No instrumentation model specified for this model!");
return;
}
SGPath config = globals->resolve_aircraft_path(path_n->getStringValue());
SG_LOG( SG_COCKPIT, SG_INFO, "Reading cockpit displays from " << config.str() );
try {
readProperties( config.str(), config_props );
if (!build(config_props)) {
throw sg_exception(
"Detected an internal inconsistency in the instrumentation\n"
"system specification file. See earlier errors for details.");
}
} catch (const sg_exception& e) {
SG_LOG(SG_COCKPIT, SG_ALERT, "Failed to load instrumentation system model: "
<< config.str() << ":" << e.getFormattedMessage() );
}
// bind() created instruments before init.
BOOST_FOREACH(std::string s, _displays) {
get_subsystem(s)->bind();
}
SGSubsystemGroup::init();
}
bool CockpitDisplayManager::build (SGPropertyNode* config_props)
{
for ( int i = 0; i < config_props->nChildren(); ++i ) {
SGPropertyNode *node = config_props->getChild(i);
std::string name = node->getName();
std::ostringstream subsystemname;
subsystemname << "instrument-" << i << '-'
<< node->getStringValue("name", name.c_str());
int index = node->getIntValue("number", 0);
if (index > 0)
subsystemname << '['<< index << ']';
std::string id = subsystemname.str();
if ( name == "radar" ) {
set_subsystem( id, new wxRadarBg ( node ) );
} else if ( name == "groundradar" ) {
set_subsystem( id, new GroundRadar( node ) );
} else if ( name == "air-ground-radar" ) {
set_subsystem( id, new agRadar( node ) );
} else if ( name == "navigation-display" ) {
set_subsystem( id, new NavDisplay( node ) );
} else {
// probably a regular instrument
continue;
}
// only add to our list if we build a display
_displays.push_back(id);
}
return true;
}
} // of namespace flightgear

View file

@ -0,0 +1,54 @@
// cockpitDisplayManager.hxx -- manage cockpit displays, typically
// rendered using a sub-camera or render-texture
//
// Copyright (C) 2012 James Turner zakalawe@mac.com
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef COCKPIT_DISPLAY_MGR_HXX
#define COCKPIT_DISPLAY_MGR_HXX 1
#include <simgear/compiler.h>
#include <vector>
#include <simgear/structure/subsystem_mgr.hxx>
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<std::string> _displays;
};
} // of namespace lfightgear
#endif // COCKPIT_DISPLAY_MGR_HXX

View file

@ -22,12 +22,15 @@
#include <osg/ref_ptr> #include <osg/ref_ptr>
#include <osg/Geometry> #include <osg/Geometry>
#include <simgear/props/props.hxx> #include <simgear/props/props.hxx>
#include "od_gauge.hxx"
#include <simgear/structure/subsystem_mgr.hxx> #include <simgear/structure/subsystem_mgr.hxx>
#include "od_gauge.hxx"
// forward decls // forward decls
class FGRunwayBase; class FGRunwayBase;
class FGPavement;
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Built-in layer for the atc radar. // Built-in layer for the atc radar.

View file

@ -56,9 +56,8 @@ using std::string;
#include <Main/fg_props.hxx> #include <Main/fg_props.hxx>
#include <Main/globals.hxx> #include <Main/globals.hxx>
#include <Cockpit/panel.hxx>
#include "instrument_mgr.hxx" #include "panel.hxx" // for FGTextureManager
#include "od_gauge.hxx" #include "od_gauge.hxx"
#include "wxradar.hxx" #include "wxradar.hxx"

View file

@ -2,7 +2,6 @@ include(FlightGearComponent)
set(SOURCES set(SOURCES
adf.cxx adf.cxx
agradar.cxx
airspeed_indicator.cxx airspeed_indicator.cxx
altimeter.cxx altimeter.cxx
attitude_indicator.cxx attitude_indicator.cxx
@ -10,7 +9,6 @@ set(SOURCES
dclgps.cxx dclgps.cxx
dme.cxx dme.cxx
gps.cxx gps.cxx
groundradar.cxx
gsdi.cxx gsdi.cxx
gyro.cxx gyro.cxx
heading_indicator.cxx heading_indicator.cxx
@ -26,9 +24,7 @@ set(SOURCES
mrg.cxx mrg.cxx
navradio.cxx navradio.cxx
newnavradio.cxx newnavradio.cxx
od_gauge.cxx
rad_alt.cxx rad_alt.cxx
render_area_2d.cxx
rnav_waypt_controller.cxx rnav_waypt_controller.cxx
slip_skid_ball.cxx slip_skid_ball.cxx
tacan.cxx tacan.cxx
@ -36,8 +32,6 @@ set(SOURCES
transponder.cxx transponder.cxx
turn_indicator.cxx turn_indicator.cxx
vertical_speed_indicator.cxx vertical_speed_indicator.cxx
wxradar.cxx
NavDisplay.cxx
HUD/HUD.cxx HUD/HUD.cxx
HUD/HUD_dial.cxx HUD/HUD_dial.cxx
HUD/HUD_gauge.cxx HUD/HUD_gauge.cxx
@ -69,7 +63,6 @@ set(SOURCES
set(HEADERS set(HEADERS
adf.hxx adf.hxx
agradar.hxx
airspeed_indicator.hxx airspeed_indicator.hxx
altimeter.hxx altimeter.hxx
attitude_indicator.hxx attitude_indicator.hxx
@ -77,7 +70,6 @@ set(HEADERS
dclgps.hxx dclgps.hxx
dme.hxx dme.hxx
gps.hxx gps.hxx
groundradar.hxx
gsdi.hxx gsdi.hxx
gyro.hxx gyro.hxx
heading_indicator.hxx heading_indicator.hxx
@ -93,9 +85,7 @@ set(HEADERS
mrg.hxx mrg.hxx
navradio.hxx navradio.hxx
newnavradio.hxx newnavradio.hxx
od_gauge.hxx
rad_alt.hxx rad_alt.hxx
render_area_2d.hxx
rnav_waypt_controller.hxx rnav_waypt_controller.hxx
slip_skid_ball.hxx slip_skid_ball.hxx
tacan.hxx tacan.hxx
@ -103,8 +93,6 @@ set(HEADERS
transponder.hxx transponder.hxx
turn_indicator.hxx turn_indicator.hxx
vertical_speed_indicator.hxx vertical_speed_indicator.hxx
wxradar.hxx
NavDisplay.hxx
HUD/HUD.hxx HUD/HUD.hxx
HUD/HUD_private.hxx HUD/HUD_private.hxx
KLN89/kln89.hxx KLN89/kln89.hxx

View file

@ -26,7 +26,8 @@
#ifndef _DCLGPS_HXX #ifndef _DCLGPS_HXX
#define _DCLGPS_HXX #define _DCLGPS_HXX
#include "render_area_2d.hxx" #include <Cockpit/render_area_2d.hxx>
#include <string> #include <string>
#include <list> #include <list>
#include <vector> #include <vector>

View file

@ -42,15 +42,11 @@
#include "turn_indicator.hxx" #include "turn_indicator.hxx"
#include "vertical_speed_indicator.hxx" #include "vertical_speed_indicator.hxx"
#include "inst_vertical_speed_indicator.hxx" #include "inst_vertical_speed_indicator.hxx"
#include "wxradar.hxx"
#include "tacan.hxx" #include "tacan.hxx"
#include "mk_viii.hxx" #include "mk_viii.hxx"
#include "mrg.hxx" #include "mrg.hxx"
#include "groundradar.hxx"
#include "agradar.hxx"
#include "rad_alt.hxx" #include "rad_alt.hxx"
#include "tcas.hxx" #include "tcas.hxx"
#include "NavDisplay.hxx"
FGInstrumentMgr::FGInstrumentMgr () : FGInstrumentMgr::FGInstrumentMgr () :
_explicitGps(false) _explicitGps(false)
@ -124,7 +120,6 @@ bool FGInstrumentMgr::build (SGPropertyNode* config_props)
if (index > 0) if (index > 0)
subsystemname << '['<< index << ']'; subsystemname << '['<< index << ']';
string id = subsystemname.str(); string id = subsystemname.str();
_instruments.push_back(id);
if ( name == "adf" ) { if ( name == "adf" ) {
set_subsystem( id, new ADF( node ), 0.15 ); set_subsystem( id, new ADF( node ), 0.15 );
@ -189,9 +184,6 @@ bool FGInstrumentMgr::build (SGPropertyNode* config_props)
} else if ( name == "vertical-speed-indicator" ) { } else if ( name == "vertical-speed-indicator" ) {
set_subsystem( id, new VerticalSpeedIndicator( node ) ); set_subsystem( id, new VerticalSpeedIndicator( node ) );
} else if ( name == "radar" ) {
set_subsystem( id, new wxRadarBg ( node ) );
} else if ( name == "inst-vertical-speed-indicator" ) { } else if ( name == "inst-vertical-speed-indicator" ) {
set_subsystem( id, new InstVerticalSpeedIndicator( node ) ); set_subsystem( id, new InstVerticalSpeedIndicator( node ) );
@ -204,27 +196,30 @@ bool FGInstrumentMgr::build (SGPropertyNode* config_props)
} else if ( name == "master-reference-gyro" ) { } else if ( name == "master-reference-gyro" ) {
set_subsystem( id, new MasterReferenceGyro( node ) ); set_subsystem( id, new MasterReferenceGyro( node ) );
} else if ( name == "groundradar" ) { } else if (( name == "groundradar" ) ||
set_subsystem( id, new GroundRadar( node ) ); ( name == "radar" ) ||
( name == "air-ground-radar" ) ||
} else if ( name == "air-ground-radar" ) { ( name == "navigation-display" ))
set_subsystem( id, new agRadar( node ) ); {
// these instruments are handled by the CockpitDisplayManager
// catch them here so we can still warn about bogus names in
// the instruments file
continue;
} else if ( name == "radar-altimeter" ) { } else if ( name == "radar-altimeter" ) {
set_subsystem( id, new radAlt( node ) ); set_subsystem( id, new radAlt( node ) );
} else if ( name == "tcas" ) { } else if ( name == "tcas" ) {
set_subsystem( id, new TCAS( node ), 0.2); set_subsystem( id, new TCAS( node ), 0.2);
} else if ( name == "navigation-display" ) {
set_subsystem( id, new NavDisplay( node ) );
} else { } else {
SG_LOG( SG_ALL, SG_ALERT, "Unknown top level section: " SG_LOG( SG_ALL, SG_ALERT, "Unknown top level section: "
<< name ); << name );
return false; return false;
} }
}
// only push to our array if we actually built an insturment
_instruments.push_back(id);
} // of instruments iteration
return true; return true;
} }

View file

@ -28,7 +28,7 @@
#include <Scenery/scenery.hxx> #include <Scenery/scenery.hxx>
#include <simgear/scene/material/mat.hxx> #include <simgear/scene/material/mat.hxx>
#include "agradar.hxx" #include <Cockpit/agradar.hxx>
class radAlt : public agRadar{ class radAlt : public agRadar{
public: public:

View file

@ -99,6 +99,7 @@
#include <Viewer/viewmgr.hxx> #include <Viewer/viewmgr.hxx>
#include <Navaids/NavDataCache.hxx> #include <Navaids/NavDataCache.hxx>
#include <Instrumentation/HUD/HUD.hxx> #include <Instrumentation/HUD/HUD.hxx>
#include <Cockpit/cockpitDisplayManager.hxx>
#include "fg_init.hxx" #include "fg_init.hxx"
#include "fg_io.hxx" #include "fg_io.hxx"
@ -607,6 +608,7 @@ void fgCreateSubsystems() {
globals->add_subsystem("systems", new FGSystemMgr, SGSubsystemMgr::FDM); globals->add_subsystem("systems", new FGSystemMgr, SGSubsystemMgr::FDM);
globals->add_subsystem("instrumentation", new FGInstrumentMgr, SGSubsystemMgr::FDM); globals->add_subsystem("instrumentation", new FGInstrumentMgr, SGSubsystemMgr::FDM);
globals->add_subsystem("hud", new HUD, SGSubsystemMgr::DISPLAY); globals->add_subsystem("hud", new HUD, SGSubsystemMgr::DISPLAY);
globals->add_subsystem("cockpit-displays", new flightgear::CockpitDisplayManager, SGSubsystemMgr::DISPLAY);
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Initialize the XML Autopilot subsystem. // Initialize the XML Autopilot subsystem.