diff --git a/src/Cockpit/panel.cxx b/src/Cockpit/panel.cxx index d59c06f51..35cff0df1 100644 --- a/src/Cockpit/panel.cxx +++ b/src/Cockpit/panel.cxx @@ -825,6 +825,28 @@ FGLayeredInstrument::addTransformation (FGPanelTransformation * transformation) } + +//////////////////////////////////////////////////////////////////////// +// Implementation of FGSpecialInstrument. +//////////////////////////////////////////////////////////////////////// + +FGSpecialInstrument::FGSpecialInstrument (DCLGPS* sb) + : FGPanelInstrument() +{ + complex = sb; +} + +FGSpecialInstrument::~FGSpecialInstrument () +{ +} + +void +FGSpecialInstrument::draw () +{ + complex->draw(); +} + + //////////////////////////////////////////////////////////////////////// // Implementation of FGInstrumentLayer. diff --git a/src/Cockpit/panel.hxx b/src/Cockpit/panel.hxx index 221698106..f4dbd7eb2 100644 --- a/src/Cockpit/panel.hxx +++ b/src/Cockpit/panel.hxx @@ -48,6 +48,7 @@ #include
#include +#include SG_USING_STD(vector); SG_USING_STD(map); @@ -428,6 +429,28 @@ protected: }; +/** + * An empty-shell instrument that exists soley in + * order to redirect commands from the panel to a + * complex instrument inherited from SGSubsystem. + * + * Currently the only complex instrument is the KLN89, + * which we've hardwired this to for now. + */ +class FGSpecialInstrument : public FGPanelInstrument +{ +public: + FGSpecialInstrument(DCLGPS* sb); + //FGSpecialInstrument (int x, int y, int w, int h); + virtual ~FGSpecialInstrument (); + + virtual void draw (); + +protected: + DCLGPS* complex; +}; + + /** * An instrument layer containing a group of sublayers. * diff --git a/src/Cockpit/panel_io.cxx b/src/Cockpit/panel_io.cxx index 375630652..a8ae3f882 100644 --- a/src/Cockpit/panel_io.cxx +++ b/src/Cockpit/panel_io.cxx @@ -787,11 +787,14 @@ readPanel (const SGPropertyNode * root) // Warning - hardwired size!!! RenderArea2D* instrument = new RenderArea2D(158, 40, 158, 40, x, y); - // FIXME: shift-F3 (panel reload) kill's us here due to duplicate subsystem! - KLN89* gps = new KLN89(instrument); - panel->addInstrument(gps); - globals->add_subsystem("kln89", gps); - //gps->init(); // init seems to get called automagically. + KLN89* gps = (KLN89*)globals->get_subsystem("kln89"); + if(gps == NULL) { + gps = new KLN89(instrument); + globals->add_subsystem("kln89", gps); + } + //gps->init(); // init seems to get called automagically. + FGSpecialInstrument* gpsinst = new FGSpecialInstrument(gps); + panel->addInstrument(gpsinst); } else { SG_LOG( SG_COCKPIT, SG_WARN, "Unknown special instrument found" ); } diff --git a/src/Instrumentation/KLN89/kln89.cxx b/src/Instrumentation/KLN89/kln89.cxx index 78a817f9e..b491bcc31 100644 --- a/src/Instrumentation/KLN89/kln89.cxx +++ b/src/Instrumentation/KLN89/kln89.cxx @@ -44,6 +44,7 @@ #include #include +#include
#include SG_USING_STD(cout); diff --git a/src/Instrumentation/KLN89/kln89_page_apt.cxx b/src/Instrumentation/KLN89/kln89_page_apt.cxx index db283003e..1ea7022b0 100644 --- a/src/Instrumentation/KLN89/kln89_page_apt.cxx +++ b/src/Instrumentation/KLN89/kln89_page_apt.cxx @@ -23,6 +23,7 @@ #include "kln89_page_apt.hxx" #include +#include
// This function is copied from Airports/runways.cxx // TODO - Make the original properly available and remove this instance!!!! diff --git a/src/Instrumentation/KLN89/kln89_page_nav.cxx b/src/Instrumentation/KLN89/kln89_page_nav.cxx index 5074376c1..968c3bb4c 100644 --- a/src/Instrumentation/KLN89/kln89_page_nav.cxx +++ b/src/Instrumentation/KLN89/kln89_page_nav.cxx @@ -22,6 +22,7 @@ // $Id$ #include "kln89_page_nav.hxx" +#include
KLN89NavPage::KLN89NavPage(KLN89* parent) : KLN89Page(parent) { diff --git a/src/Instrumentation/dclgps.cxx b/src/Instrumentation/dclgps.cxx index b78806b28..d4084136f 100644 --- a/src/Instrumentation/dclgps.cxx +++ b/src/Instrumentation/dclgps.cxx @@ -26,6 +26,8 @@ #include "dclgps.hxx" #include +#include +#include
#include SG_USING_STD(cout); diff --git a/src/Instrumentation/dclgps.hxx b/src/Instrumentation/dclgps.hxx index 442105df8..3dce50401 100644 --- a/src/Instrumentation/dclgps.hxx +++ b/src/Instrumentation/dclgps.hxx @@ -32,8 +32,6 @@ #include #include -#include - #include #include #include @@ -203,7 +201,7 @@ typedef vector gps_page_list_type; typedef gps_page_list_type::iterator gps_page_list_itr; // TODO - merge generic GPS functions instead and split out KLN specific stuff. -class DCLGPS : public SGSubsystem, public FGPanelInstrument { +class DCLGPS : public SGSubsystem { friend class GPSPage;