Separate instruments from cockpit displays.
This commit is contained in:
parent
7d547d1287
commit
4994973ef4
21 changed files with 219 additions and 39 deletions
|
@ -23,7 +23,7 @@
|
|||
#include "property_based_element.hxx"
|
||||
|
||||
#include <Canvas/canvas_fwd.hpp>
|
||||
#include <Instrumentation/od_gauge.hxx>
|
||||
#include <Cockpit/od_gauge.hxx>
|
||||
|
||||
#include <simgear/props/propertyObject.hxx>
|
||||
#include <osg/NodeCallback>
|
||||
|
|
|
@ -1,15 +1,29 @@
|
|||
include(FlightGearComponent)
|
||||
|
||||
set(SOURCES
|
||||
cockpitDisplayManager.cxx
|
||||
panel.cxx
|
||||
panel_io.cxx
|
||||
built_in/FGMagRibbon.cxx
|
||||
agradar.cxx
|
||||
groundradar.cxx
|
||||
od_gauge.cxx
|
||||
render_area_2d.cxx
|
||||
wxradar.cxx
|
||||
NavDisplay.cxx
|
||||
)
|
||||
|
||||
set(HEADERS
|
||||
cockpitDisplayManager.hxx
|
||||
panel.hxx
|
||||
panel_io.hxx
|
||||
built_in/FGMagRibbon.hxx
|
||||
agradar.hxx
|
||||
groundradar.hxx
|
||||
od_gauge.hxx
|
||||
render_area_2d.hxx
|
||||
wxradar.hxx
|
||||
NavDisplay.hxx
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ using std::string;
|
|||
|
||||
#include <Main/fg_props.hxx>
|
||||
#include <Main/globals.hxx>
|
||||
#include <Cockpit/panel.hxx>
|
||||
#include "panel.hxx"
|
||||
#include <Navaids/routePath.hxx>
|
||||
#include <Autopilot/route_mgr.hxx>
|
||||
#include <Navaids/navrecord.hxx>
|
||||
|
@ -71,8 +71,6 @@ using std::string;
|
|||
#include <Navaids/fix.hxx>
|
||||
#include <Airports/simple.hxx>
|
||||
#include <Airports/runways.hxx>
|
||||
|
||||
#include "instrument_mgr.hxx"
|
||||
#include "od_gauge.hxx"
|
||||
|
||||
static const char *DEFAULT_FONT = "typewriter.txf";
|
126
src/Cockpit/cockpitDisplayManager.cxx
Normal file
126
src/Cockpit/cockpitDisplayManager.cxx
Normal 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
|
54
src/Cockpit/cockpitDisplayManager.hxx
Normal file
54
src/Cockpit/cockpitDisplayManager.hxx
Normal 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
|
|
@ -22,12 +22,15 @@
|
|||
|
||||
#include <osg/ref_ptr>
|
||||
#include <osg/Geometry>
|
||||
|
||||
#include <simgear/props/props.hxx>
|
||||
#include "od_gauge.hxx"
|
||||
#include <simgear/structure/subsystem_mgr.hxx>
|
||||
|
||||
#include "od_gauge.hxx"
|
||||
|
||||
// forward decls
|
||||
class FGRunwayBase;
|
||||
class FGPavement;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Built-in layer for the atc radar.
|
|
@ -56,9 +56,8 @@ using std::string;
|
|||
|
||||
#include <Main/fg_props.hxx>
|
||||
#include <Main/globals.hxx>
|
||||
#include <Cockpit/panel.hxx>
|
||||
|
||||
#include "instrument_mgr.hxx"
|
||||
#include "panel.hxx" // for FGTextureManager
|
||||
#include "od_gauge.hxx"
|
||||
#include "wxradar.hxx"
|
||||
|
|
@ -2,7 +2,6 @@ include(FlightGearComponent)
|
|||
|
||||
set(SOURCES
|
||||
adf.cxx
|
||||
agradar.cxx
|
||||
airspeed_indicator.cxx
|
||||
altimeter.cxx
|
||||
attitude_indicator.cxx
|
||||
|
@ -10,7 +9,6 @@ set(SOURCES
|
|||
dclgps.cxx
|
||||
dme.cxx
|
||||
gps.cxx
|
||||
groundradar.cxx
|
||||
gsdi.cxx
|
||||
gyro.cxx
|
||||
heading_indicator.cxx
|
||||
|
@ -26,9 +24,7 @@ set(SOURCES
|
|||
mrg.cxx
|
||||
navradio.cxx
|
||||
newnavradio.cxx
|
||||
od_gauge.cxx
|
||||
rad_alt.cxx
|
||||
render_area_2d.cxx
|
||||
rnav_waypt_controller.cxx
|
||||
slip_skid_ball.cxx
|
||||
tacan.cxx
|
||||
|
@ -36,8 +32,6 @@ set(SOURCES
|
|||
transponder.cxx
|
||||
turn_indicator.cxx
|
||||
vertical_speed_indicator.cxx
|
||||
wxradar.cxx
|
||||
NavDisplay.cxx
|
||||
HUD/HUD.cxx
|
||||
HUD/HUD_dial.cxx
|
||||
HUD/HUD_gauge.cxx
|
||||
|
@ -69,7 +63,6 @@ set(SOURCES
|
|||
|
||||
set(HEADERS
|
||||
adf.hxx
|
||||
agradar.hxx
|
||||
airspeed_indicator.hxx
|
||||
altimeter.hxx
|
||||
attitude_indicator.hxx
|
||||
|
@ -77,7 +70,6 @@ set(HEADERS
|
|||
dclgps.hxx
|
||||
dme.hxx
|
||||
gps.hxx
|
||||
groundradar.hxx
|
||||
gsdi.hxx
|
||||
gyro.hxx
|
||||
heading_indicator.hxx
|
||||
|
@ -93,9 +85,7 @@ set(HEADERS
|
|||
mrg.hxx
|
||||
navradio.hxx
|
||||
newnavradio.hxx
|
||||
od_gauge.hxx
|
||||
rad_alt.hxx
|
||||
render_area_2d.hxx
|
||||
rnav_waypt_controller.hxx
|
||||
slip_skid_ball.hxx
|
||||
tacan.hxx
|
||||
|
@ -103,8 +93,6 @@ set(HEADERS
|
|||
transponder.hxx
|
||||
turn_indicator.hxx
|
||||
vertical_speed_indicator.hxx
|
||||
wxradar.hxx
|
||||
NavDisplay.hxx
|
||||
HUD/HUD.hxx
|
||||
HUD/HUD_private.hxx
|
||||
KLN89/kln89.hxx
|
||||
|
|
|
@ -26,7 +26,8 @@
|
|||
#ifndef _DCLGPS_HXX
|
||||
#define _DCLGPS_HXX
|
||||
|
||||
#include "render_area_2d.hxx"
|
||||
#include <Cockpit/render_area_2d.hxx>
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
|
|
@ -42,15 +42,11 @@
|
|||
#include "turn_indicator.hxx"
|
||||
#include "vertical_speed_indicator.hxx"
|
||||
#include "inst_vertical_speed_indicator.hxx"
|
||||
#include "wxradar.hxx"
|
||||
#include "tacan.hxx"
|
||||
#include "mk_viii.hxx"
|
||||
#include "mrg.hxx"
|
||||
#include "groundradar.hxx"
|
||||
#include "agradar.hxx"
|
||||
#include "rad_alt.hxx"
|
||||
#include "tcas.hxx"
|
||||
#include "NavDisplay.hxx"
|
||||
|
||||
FGInstrumentMgr::FGInstrumentMgr () :
|
||||
_explicitGps(false)
|
||||
|
@ -124,7 +120,6 @@ bool FGInstrumentMgr::build (SGPropertyNode* config_props)
|
|||
if (index > 0)
|
||||
subsystemname << '['<< index << ']';
|
||||
string id = subsystemname.str();
|
||||
_instruments.push_back(id);
|
||||
|
||||
if ( name == "adf" ) {
|
||||
set_subsystem( id, new ADF( node ), 0.15 );
|
||||
|
@ -189,9 +184,6 @@ bool FGInstrumentMgr::build (SGPropertyNode* config_props)
|
|||
} else if ( name == "vertical-speed-indicator" ) {
|
||||
set_subsystem( id, new VerticalSpeedIndicator( node ) );
|
||||
|
||||
} else if ( name == "radar" ) {
|
||||
set_subsystem( id, new wxRadarBg ( node ) );
|
||||
|
||||
} else if ( name == "inst-vertical-speed-indicator" ) {
|
||||
set_subsystem( id, new InstVerticalSpeedIndicator( node ) );
|
||||
|
||||
|
@ -204,27 +196,30 @@ bool FGInstrumentMgr::build (SGPropertyNode* config_props)
|
|||
} else if ( name == "master-reference-gyro" ) {
|
||||
set_subsystem( id, new MasterReferenceGyro( 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 == "groundradar" ) ||
|
||||
( name == "radar" ) ||
|
||||
( name == "air-ground-radar" ) ||
|
||||
( name == "navigation-display" ))
|
||||
{
|
||||
// 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" ) {
|
||||
set_subsystem( id, new radAlt( node ) );
|
||||
|
||||
} else if ( name == "tcas" ) {
|
||||
set_subsystem( id, new TCAS( node ), 0.2);
|
||||
|
||||
} else if ( name == "navigation-display" ) {
|
||||
set_subsystem( id, new NavDisplay( node ) );
|
||||
|
||||
} else {
|
||||
SG_LOG( SG_ALL, SG_ALERT, "Unknown top level section: "
|
||||
<< name );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// only push to our array if we actually built an insturment
|
||||
_instruments.push_back(id);
|
||||
} // of instruments iteration
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <Scenery/scenery.hxx>
|
||||
#include <simgear/scene/material/mat.hxx>
|
||||
|
||||
#include "agradar.hxx"
|
||||
#include <Cockpit/agradar.hxx>
|
||||
|
||||
class radAlt : public agRadar{
|
||||
public:
|
||||
|
|
|
@ -99,6 +99,7 @@
|
|||
#include <Viewer/viewmgr.hxx>
|
||||
#include <Navaids/NavDataCache.hxx>
|
||||
#include <Instrumentation/HUD/HUD.hxx>
|
||||
#include <Cockpit/cockpitDisplayManager.hxx>
|
||||
|
||||
#include "fg_init.hxx"
|
||||
#include "fg_io.hxx"
|
||||
|
@ -607,6 +608,7 @@ void fgCreateSubsystems() {
|
|||
globals->add_subsystem("systems", new FGSystemMgr, SGSubsystemMgr::FDM);
|
||||
globals->add_subsystem("instrumentation", new FGInstrumentMgr, SGSubsystemMgr::FDM);
|
||||
globals->add_subsystem("hud", new HUD, SGSubsystemMgr::DISPLAY);
|
||||
globals->add_subsystem("cockpit-displays", new flightgear::CockpitDisplayManager, SGSubsystemMgr::DISPLAY);
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Initialize the XML Autopilot subsystem.
|
||||
|
|
Loading…
Add table
Reference in a new issue