From 9dc5c9ca226cdb0c370e2a06e425522ab23b98b6 Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 15 May 2000 16:33:42 +0000 Subject: [PATCH] Instrument panel updates from David Megginson. - the panel uses much, much less texture memory, and draws much faster, at least on my hardware - there is a wet (magnetic) compass at the top of the panel - the gyro compass shows true heading again, but don't get used to it: we're going to set it up to drift soon - there are TO/FROM flags on NAV1 and NAV2 (but no GS flag yet) - the ADF looks a little more realistic (if you can forgive the ugly needle) - when the HUD is not open, the framerate is moved to the right side of the screen so that it won't be obscured by the mag compass --- src/Cockpit/cockpit.cxx | 3 +- src/Cockpit/panel.cxx | 51 ++-- src/Cockpit/panel.hxx | 54 ++-- src/Cockpit/radiostack.cxx | 4 +- src/Cockpit/sp_panel.cxx | 529 +++++++++++++++++++++++++++++-------- src/Main/bfi.cxx | 42 +++ src/Main/bfi.hxx | 7 +- 7 files changed, 530 insertions(+), 160 deletions(-) diff --git a/src/Cockpit/cockpit.cxx b/src/Cockpit/cockpit.cxx index 674b6744a..5c1313e8e 100644 --- a/src/Cockpit/cockpit.cxx +++ b/src/Cockpit/cockpit.cxx @@ -505,7 +505,8 @@ void fgCockpitUpdate( void ) { glColor3f (0.9, 0.4, 0.2); guiFnt.drawString( buf, - width/2 - guiFnt.getStringWidth(buf)/2, + // width/2 - guiFnt.getStringWidth(buf)/2, + int(width - guiFnt.getStringWidth(buf) - 10), 10 ); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); diff --git a/src/Cockpit/panel.cxx b/src/Cockpit/panel.cxx index 9a3cd00a4..96e2b90f1 100644 --- a/src/Cockpit/panel.cxx +++ b/src/Cockpit/panel.cxx @@ -201,7 +201,7 @@ FGPanel::doMouseAction (int button, int updown, int x, int y) int iw = inst->getWidth() / 2; int ih = inst->getHeight() / 2; if (x >= ix - iw && x < ix + iw && y >= iy - ih && y < iy + ih) { - cout << "Do mouse action for component " << i << '\n'; +// cout << "Do mouse action for component " << i << '\n'; _mouseDown = true; _mouseDelay = 20; _mouseInstrument = inst; @@ -213,7 +213,7 @@ FGPanel::doMouseAction (int button, int updown, int x, int y) return true; } } - cout << "Did not click on an instrument\n"; +// cout << "Did not click on an instrument\n"; return false; } @@ -224,7 +224,7 @@ FGPanel::doMouseAction (int button, int updown, int x, int y) //////////////////////////////////////////////////////////////////////// FGAdjustAction::FGAdjustAction (getter_type getter, setter_type setter, - double increment, double min, double max, + float increment, float min, float max, bool wrap=false) : _getter(getter), _setter(setter), _increment(increment), _min(min), _max(max), _wrap(wrap) @@ -238,15 +238,15 @@ FGAdjustAction::~FGAdjustAction () void FGAdjustAction::doAction () { - double value = (*_getter)(); - cout << "Do action; value=" << value << '\n'; + float value = (*_getter)(); +// cout << "Do action; value=" << value << '\n'; value += _increment; if (value < _min) { value = (_wrap ? _max : _min); } else if (value > _max) { value = (_wrap ? _min : _max); } - cout << "New value is " << value << '\n'; +// cout << "New value is " << value << '\n'; (*_setter)(value); } @@ -270,7 +270,7 @@ FGSwapAction::~FGSwapAction () void FGSwapAction::doAction () { - double value = (*_getter1)(); + float value = (*_getter1)(); (*_setter1)((*_getter2)()); (*_setter2)(value); } @@ -382,10 +382,10 @@ FGPanelInstrument::doMouseAction (int button, int x, int y) { action_list_type::iterator it = _actions.begin(); action_list_type::iterator last = _actions.end(); - cout << "Mouse action at " << x << ',' << y << '\n'; +// cout << "Mouse action at " << x << ',' << y << '\n'; for ( ; it != last; it++) { - cout << "Trying action at " << it->x << ',' << it->y << ',' - << it->w <<',' << it->h << '\n'; +// cout << "Trying action at " << it->x << ',' << it->y << ',' +// << it->w <<',' << it->h << '\n'; if (button == it->button && x >= it->x && x < it->x + it->w && y >= it->y && y < it->y + it->h) { it->action->doAction(); @@ -431,16 +431,25 @@ FGLayeredInstrument::addLayer (FGInstrumentLayer *layer) } int -FGLayeredInstrument::addLayer (ssgTexture * texture) +FGLayeredInstrument::addLayer (ssgTexture * texture, + int w = -1, int h = -1, + float texX1 = 0.0, float texY1 = 0.0, + float texX2 = 1.0, float texY2 = 1.0) { - return addLayer(new FGTexturedLayer(texture, _w, _h)); + if (w == -1) + w = _w; + if (h == -1) + h = _h; + FGTexturedLayer * layer = new FGTexturedLayer(texture, w, h); + layer->setTextureCoords(texX1, texY1, texX2, texY2); + return addLayer(layer); } void FGLayeredInstrument::addTransformation (FGInstrumentLayer::transform_type type, FGInstrumentLayer::transform_func func, - double min, double max, - double factor, double offset) + float min, float max, + float factor, float offset) { int layer = _layers.size() - 1; _layers[layer]->addTransformation(type, func, min, max, factor, offset); @@ -448,7 +457,7 @@ FGLayeredInstrument::addTransformation (FGInstrumentLayer::transform_type type, void FGLayeredInstrument::addTransformation (FGInstrumentLayer::transform_type type, - double offset) + float offset) { addTransformation(type, 0, 0.0, 0.0, 1.0, offset); } @@ -482,7 +491,7 @@ FGInstrumentLayer::transform () const transformation_list::const_iterator last = _transformations.end(); while (it != last) { transformation *t = *it; - double value = (t->func == 0 ? 0.0 : (*(t->func))()); + float value = (t->func == 0 ? 0.0 : (*(t->func))()); if (value < t->min) { value = t->min; } else if (value > t->max) { @@ -508,8 +517,8 @@ FGInstrumentLayer::transform () const void FGInstrumentLayer::addTransformation (transform_type type, transform_func func, - double min, double max, - double factor, double offset) + float min, float max, + float factor, float offset) { transformation *t = new transformation; t->type = type; @@ -528,8 +537,8 @@ FGInstrumentLayer::addTransformation (transform_type type, //////////////////////////////////////////////////////////////////////// FGTexturedLayer::FGTexturedLayer (ssgTexture * texture, int w, int h, - double texX1 = 0.0, double texY1 = 0.0, - double texX2 = 1.0, double texY2 = 1.0) + float texX1 = 0.0, float texY1 = 0.0, + float texX2 = 1.0, float texY2 = 1.0) : FGInstrumentLayer(w, h), _texX1(texX1), _texY1(texY1), _texX2(texX2), _texY2(texY2) { @@ -648,7 +657,7 @@ FGTextLayer::Chunk::Chunk (text_func func, char * fmt = "%s") } FGTextLayer::Chunk::Chunk (double_func func, char * fmt = "%.2f", - double mult = 1.0) + float mult = 1.0) : _type(FGTextLayer::DOUBLE_FUNC), _fmt(fmt), _mult(mult) { _value._dfunc = func; diff --git a/src/Cockpit/panel.hxx b/src/Cockpit/panel.hxx index b90b4fa79..db242d9fa 100644 --- a/src/Cockpit/panel.hxx +++ b/src/Cockpit/panel.hxx @@ -142,17 +142,17 @@ public: typedef double (*getter_type)(); typedef void (*setter_type)(double); - FGAdjustAction (getter_type getter, setter_type setter, double increment, - double min, double max, bool wrap=false); + FGAdjustAction (getter_type getter, setter_type setter, float increment, + float min, float max, bool wrap=false); virtual ~FGAdjustAction (); virtual void doAction (); private: getter_type _getter; setter_type _setter; - double _increment; - double _min; - double _max; + float _increment; + float _min; + float _max; bool _wrap; }; @@ -293,8 +293,8 @@ public: virtual void transform () const; virtual void addTransformation (transform_type type, transform_func func, - double min, double max, - double factor = 1.0, double offset = 0.0); + float min, float max, + float factor = 1.0, float offset = 0.0); protected: int _w, _h; @@ -302,10 +302,10 @@ protected: typedef struct { transform_type type; transform_func func; - double min; - double max; - double factor; - double offset; + float min; + float max; + float factor; + float offset; } transformation; typedef vector transformation_list; transformation_list _transformations; @@ -341,13 +341,16 @@ public: // Transfer pointer ownership!! virtual int addLayer (FGInstrumentLayer *layer); - virtual int addLayer (ssgTexture * texture); + virtual int addLayer (ssgTexture * texture, + int w = -1, int h = -1, + float texX1 = 0.0, float texY1 = 0.0, + float texX2 = 1.0, float texY2 = 1.0); virtual void addTransformation (FGInstrumentLayer::transform_type type, FGInstrumentLayer::transform_func func, - double min, double max, - double factor = 1.0, double offset = 0.0); + float min, float max, + float factor = 1.0, float offset = 0.0); virtual void addTransformation (FGInstrumentLayer::transform_type type, - double offset); + float offset); protected: layer_list _layers; @@ -367,17 +370,28 @@ class FGTexturedLayer : public FGInstrumentLayer { public: FGTexturedLayer (ssgTexture * texture, int w, int h, - double texX1 = 0.0, double texY1 = 0.0, - double texX2 = 1.0, double texY2 = 1.0); + float texX1 = 0.0, float texY1 = 0.0, + float texX2 = 1.0, float texY2 = 1.0); virtual ~FGTexturedLayer (); virtual void draw () const; virtual void setTexture (ssgTexture * texture) { _texture = texture; } + virtual void setTextureCoords (float x1, float y1, float x2, float y2) { + _texX1 = x1; _texY1 = y1; _texX2 = x2; _texY2 = y2; + } + +protected: + + virtual void setTextureCoords (float x1, float y1, + float x2, float y2) const { + _texX1 = x1; _texY1 = y1; _texX2 = x2; _texY2 = y2; + } + private: ssgTexture * _texture; - double _texX1, _texY1, _texX2, _texY2; + mutable float _texX1, _texY1, _texX2, _texY2; }; @@ -405,7 +419,7 @@ public: public: Chunk (char * text, char * fmt = "%s"); Chunk (text_func func, char * fmt = "%s"); - Chunk (double_func func, char * fmt = "%.2f", double mult = 1.0); + Chunk (double_func func, char * fmt = "%.2f", float mult = 1.0); char * getValue () const; private: @@ -416,7 +430,7 @@ public: double_func _dfunc; } _value; char * _fmt; - double _mult; + float _mult; mutable char _buf[1024]; }; diff --git a/src/Cockpit/radiostack.cxx b/src/Cockpit/radiostack.cxx index 097b57aec..80db998ed 100644 --- a/src/Cockpit/radiostack.cxx +++ b/src/Cockpit/radiostack.cxx @@ -70,7 +70,7 @@ void FGRadioStack::update( double lon, double lat, double elev ) { nav1_gs_dist = 0.0; } - if ( nav1_dme_dist < nav1_effective_range * NM_TO_METER ) { + if ( nav1_loc_dist < nav1_effective_range * NM_TO_METER ) { nav1_inrange = true; // wgs84 heading @@ -113,7 +113,7 @@ void FGRadioStack::update( double lon, double lat, double elev ) { nav2_gs_dist = 0.0; } - if ( nav2_dme_dist < nav2_effective_range * NM_TO_METER ) { + if ( nav2_loc_dist < nav2_effective_range * NM_TO_METER ) { nav2_inrange = true; // wgs84 heading diff --git a/src/Cockpit/sp_panel.cxx b/src/Cockpit/sp_panel.cxx index 38de4e5b5..724fbf139 100644 --- a/src/Cockpit/sp_panel.cxx +++ b/src/Cockpit/sp_panel.cxx @@ -32,6 +32,7 @@ #include "panel.hxx" #include "steam.hxx" +#include "radiostack.hxx" // Macros for instrument sizes // (these aren't used consistently @@ -43,10 +44,15 @@ #define SIX_SPACING (SIX_W + 5) #define SMALL_W 112 +#define createTexture(a) FGTextureManager::createTexture(a) + //////////////////////////////////////////////////////////////////////// // Static functions for obtaining settings. +// +// These are all temporary, and should be moved somewhere else +// as soon as convenient. //////////////////////////////////////////////////////////////////////// static char * panelGetTime () @@ -58,6 +64,138 @@ static char * panelGetTime () return buf; } +static bool panelGetNAV1TO () +{ + if (current_radiostack->get_nav1_inrange()) { + double heading = current_radiostack->get_nav1_heading(); + double radial = current_radiostack->get_nav1_radial(); + double var = FGBFI::getMagVar(); + if (current_radiostack->get_nav1_loc()) { + double offset = fabs(heading - radial); + return (offset<= 8.0 || offset >= 352.0); + } else { + double offset = + fabs(heading - var - radial); + return (offset <= 20.0 || offset >= 340.0); + } + } else { + return false; + } +} + +static bool panelGetNAV1FROM () +{ + if (current_radiostack->get_nav1_inrange()) { + double heading = current_radiostack->get_nav1_heading(); + double radial = current_radiostack->get_nav1_radial(); + double var = FGBFI::getMagVar(); + if (current_radiostack->get_nav1_loc()) { + double offset = fabs(heading - radial); + return (offset >= 172.0 && offset<= 188.0); + } else { + double offset = + fabs(heading - var - radial); + return (offset >= 160.0 && offset <= 200.0); + } + } else { + return false; + } +} + +static bool panelGetNAV2TO () +{ + if (current_radiostack->get_nav2_inrange()) { + double heading = current_radiostack->get_nav2_heading(); + double radial = current_radiostack->get_nav2_radial(); + double var = FGBFI::getMagVar(); + if (current_radiostack->get_nav2_loc()) { + double offset = fabs(heading - radial); + return (offset<= 8.0 || offset >= 352.0); + } else { + double offset = + fabs(heading - var - radial); + return (offset <= 20.0 || offset >= 340.0); + } + } else { + return false; + } +} + +static bool panelGetNAV2FROM () +{ + if (current_radiostack->get_nav2_inrange()) { + double heading = current_radiostack->get_nav2_heading(); + double radial = current_radiostack->get_nav2_radial(); + double var = FGBFI::getMagVar(); + if (current_radiostack->get_nav2_loc()) { + double offset = fabs(heading - radial); + return (offset >= 172.0 && offset<= 188.0); + } else { + double offset = + fabs(heading - var - radial); + return (offset >= 160.0 && offset <= 200.0); + } + } else { + return false; + } +} + + + +//////////////////////////////////////////////////////////////////////// +// Special class for magnetic compass ribbon layer. +//////////////////////////////////////////////////////////////////////// + +class MagRibbon : public FGTexturedLayer +{ +public: + MagRibbon (int w, int h); + virtual ~MagRibbon () {} + + virtual void draw () const; +}; + +MagRibbon::MagRibbon (int w, int h) + : FGTexturedLayer(createTexture("Textures/Panel/compass-ribbon.rgb"), w, h) +{ +} + +void +MagRibbon::draw () const +{ + double heading = FGSteam::get_MH_deg(); + double xoffset, yoffset; + + while (heading >= 360.0) { + heading -= 360.0; + } + while (heading < 0.0) { + heading += 360.0; + } + + if (heading >= 60.0 && heading <= 180.0) { + xoffset = heading / 240.0; + yoffset = 0.75; + } else if (heading >= 150.0 && heading <= 270.0) { + xoffset = (heading - 90.0) / 240.0; + yoffset = 0.50; + } else if (heading >= 240.0 && heading <= 360.0) { + xoffset = (heading - 180.0) / 240.0; + yoffset = 0.25; + } else { + if (heading < 270.0) + heading += 360.0; + xoffset = (heading - 270.0) / 240.0; + yoffset = 0.0; + } + + // Adjust to put the number in the centre + xoffset -= 0.25; + + setTextureCoords(xoffset, yoffset, xoffset + 0.5, yoffset + 0.25); + FGTexturedLayer::draw(); +} + //////////////////////////////////////////////////////////////////////// @@ -69,7 +207,22 @@ static char * panelGetTime () //////////////////////////////////////////////////////////////////////// -#define createTexture(a) FGTextureManager::createTexture(a) +/** + * Construct a magnetic (wet) compass. + */ +static FGPanelInstrument * +createMagneticCompass (int x, int y) +{ + FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W, SIX_W/2); + + inst->addLayer(new MagRibbon(int(SIX_W*0.8), int(SIX_W*0.2))); + + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W * (80.0/80.0)), int(SIX_W * (24.0/80.0)), + 48.0/128.0, 0.0, 1.0, 24.0/128.0); + + return inst; +} /** * Construct an airspeed indicator for a single-engine prop. @@ -80,14 +233,18 @@ createAirspeedIndicator (int x, int y) FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W, SIX_W); // Layer 0: gauge background. - inst->addLayer(createTexture("Textures/Panel/airspeed.rgb")); + inst->addLayer(createTexture("Textures/Panel/faces-2.rgb"), -1, -1, + 0, 0.5, 0.5, 1.0); // Layer 1: needle. // Rotates with airspeed. - inst->addLayer(createTexture("Textures/Panel/long-needle.rgb")); + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W*(5.0/64.0)), int(SIX_W*(7.0/16.0)), + 102.0/128.0, 100.0/128.0, 107.0/128.0, 1.0); inst->addTransformation(FGInstrumentLayer::ROTATION, FGSteam::get_ASI_kias, 30.0, 220.0, 36.0 / 20.0, -54.0); + inst->addTransformation(FGInstrumentLayer::YSHIFT, SIX_W * 12.0/64.0); return inst; } @@ -102,14 +259,17 @@ createHorizon (int x, int y) // Layer 0: coloured background // moves with roll only - inst->addLayer(createTexture("Textures/Panel/horizon-bg.rgb")); + inst->addLayer(createTexture("Textures/Panel/faces-2.rgb"), -1, -1, + 0.5, 0.5, 1.0, 1.0); inst->addTransformation(FGInstrumentLayer::ROTATION, FGBFI::getRoll, -360.0, 360.0, -1.0, 0.0); // Layer 1: floating horizon // moves with roll and pitch - inst->addLayer(createTexture("Textures/Panel/horizon-float.rgb")); + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W * (13.0/16.0)), int(SIX_W * (33.0/64.0)), + 15.0/32.0, 54.0/128.0, 28.0/32.0, 87.0/128.0); inst->addTransformation(FGInstrumentLayer::ROTATION, FGBFI::getRoll, -360.0, 360.0, -1.0, 0.0); @@ -119,14 +279,16 @@ createHorizon (int x, int y) // Layer 2: rim // moves with roll only - inst->addLayer(createTexture("Textures/Panel/horizon-rim.rgb")); + inst->addLayer(createTexture("Textures/Panel/faces-2.rgb"), -1, -1, + 0, 0, 0.5, 0.5); inst->addTransformation(FGInstrumentLayer::ROTATION, FGBFI::getRoll, -360.0, 360.0, -1.0, 0.0); // Layer 3: glass front of gauge // fixed, with markings - inst->addLayer(createTexture("Textures/Panel/horizon-fg.rgb")); + inst->addLayer(createTexture("Textures/Panel/faces-2.rgb"), -1, -1, + 0.5, 0, 1.0, 0.5); return inst; } @@ -141,28 +303,38 @@ createAltimeter (int x, int y) FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W, SIX_W); // Layer 0: gauge background - inst->addLayer(createTexture("Textures/Panel/altimeter.rgb")); + inst->addLayer(createTexture("Textures/Panel/faces-1.rgb"), -1, -1, + 0.5, 0.5, 1.0, 1.0); // Layer 1: hundreds needle (long) // moves with altitude - inst->addLayer(createTexture("Textures/Panel/long-needle.rgb")); + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W*(5.0/64.0)), int(SIX_W*(7.0/16.0)), + 102.0/128.0, 100.0/128.0, 107.0/128.0, 1.0); inst->addTransformation(FGInstrumentLayer::ROTATION, FGSteam::get_ALT_ft, 0.0, 100000.0, 360.0 / 1000.0, 0.0); + inst->addTransformation(FGInstrumentLayer::YSHIFT, SIX_W * 12.0/64.0); // Layer 2: thousands needle (short) // moves with altitude - inst->addLayer(createTexture("Textures/Panel/short-needle.rgb")); + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W * (6.0/64.0)), int(SIX_W * (18.0/64.0)), + (107.0/128.0), (110.0/128.0), (113.0/128.0), 1.0); inst->addTransformation(FGInstrumentLayer::ROTATION, FGSteam::get_ALT_ft, 0.0, 100000.0, 360.0 / 10000.0, 0.0); + inst->addTransformation(FGInstrumentLayer::YSHIFT, SIX_W/8.0); // Layer 3: ten thousands bug (outside) // moves with altitude - inst->addLayer(createTexture("Textures/Panel/bug.rgb")); + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W * (4.0/64.0)), int(SIX_W * (4.0/64.0)), + (108.0/128.0), (104.0/128.0), (112.0/128.0), (108.0/128.0)); inst->addTransformation(FGInstrumentLayer::ROTATION, FGSteam::get_ALT_ft, 0.0, 100000.0, 360.0 / 100000.0, 0.0); + inst->addTransformation(FGInstrumentLayer::YSHIFT, (SIX_W/2.0) - 4); return inst; } @@ -177,21 +349,28 @@ createTurnCoordinator (int x, int y) FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W, SIX_W); // Layer 0: background - inst->addLayer(createTexture("Textures/Panel/turn-bg.rgb")); + inst->addLayer(createTexture("Textures/Panel/faces-1.rgb"), -1, -1, + 0.5, 0, 1.0, 0.5); // Layer 1: little plane // moves with roll - inst->addLayer(createTexture("Textures/Panel/turn.rgb")); + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W * 0.75), int(SIX_W * 0.25), + 0.0, 3.0/8.0, 3.0/8.0, 0.5); inst->addTransformation(FGInstrumentLayer::ROTATION, FGSteam::get_TC_std, -2.5, 2.5, 20.0, 0.0); + inst->addTransformation(FGInstrumentLayer::YSHIFT, int(SIX_W * 0.0625)); // Layer 2: little ball // moves with slip/skid - inst->addLayer(createTexture("Textures/Panel/ball.rgb")); + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W * (4.0/64.0)), int(SIX_W * (4.0/64.0)), + (108.0/128.0), (100.0/128.0), (112.0/128.0), (104.0/128.0)); inst->addTransformation(FGInstrumentLayer::ROTATION, FGSteam::get_TC_rad, -0.1, 0.1, -450.0, 0.0); + inst->addTransformation(FGInstrumentLayer::YSHIFT, -(SIX_W/4) + 4); return inst; } @@ -225,28 +404,35 @@ createGyroCompass (int x, int y) // Layer 0: compass background // rotates with heading - inst->addLayer(createTexture("Textures/Panel/gyro-bg.rgb")); + inst->addLayer(createTexture("Textures/Panel/faces-1.rgb"), -1, -1, + 0, 0.5, 0.5, 1.0); inst->addTransformation(FGInstrumentLayer::ROTATION, - FGSteam::get_MH_deg, + FGBFI::getHeadingMag, -720.0, 720.0, -1.0, 0.0); // Layer 1: heading bug // rotates with heading and AP heading - inst->addLayer(createTexture("Textures/Panel/bug.rgb")); + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W * (4.0/64.0)), int(SIX_W * (4.0/64.0)), + (108.0/128.0), (104.0/128.0), (112.0/128.0), (108.0/128.0)); inst->addTransformation(FGInstrumentLayer::ROTATION, - FGSteam::get_MH_deg, + FGBFI::getHeadingMag, -720.0, 720.0, -1.0, 0.0); inst->addTransformation(FGInstrumentLayer::ROTATION, FGBFI::getAPHeadingMag, -720.0, 720.0, 1.0, 0.0); + inst->addTransformation(FGInstrumentLayer::YSHIFT, (SIX_W/2.0) - 4); // Layer 2: fixed center - inst->addLayer(createTexture("Textures/Panel/gyro-fg.rgb")); + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W * 0.625), int(SIX_W * 0.625), + 15.0/32.0, 11.0/16.0, 25.0/32.0, 1.0); // Layer 3: heading knob // rotates with AP heading - inst->addLayer(new FGTexturedLayer(createTexture("Textures/Panel/knobs.rgb"), - SIX_W/4, SIX_W/4, 0.0, 0.25, 0.25, 0.5)); + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W * (21.0/112.0)), int(SIX_W * (21.0/112.0)), + 0, (64.0/128.0), (21.0/128.0), (85.0/128.0)); inst->addTransformation(FGInstrumentLayer::XSHIFT, SIX_W/2 - 10); inst->addTransformation(FGInstrumentLayer::YSHIFT, -SIX_W/2 + 10); inst->addTransformation(FGInstrumentLayer::ROTATION, @@ -266,14 +452,18 @@ createVerticalVelocity (int x, int y) FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W, SIX_W); // Layer 0: gauge background - inst->addLayer(createTexture("Textures/Panel/vertical.rgb")); + inst->addLayer(createTexture("Textures/Panel/faces-1.rgb"), -1, -1, + 0, 0, 0.5, 0.5); // Layer 1: needle // moves with vertical velocity - inst->addLayer(createTexture("Textures/Panel/long-needle.rgb")); + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W*(5.0/64.0)), int(SIX_W*(7.0/16.0)), + 102.0/128.0, 100.0/128.0, 107.0/128.0, 1.0); inst->addTransformation(FGInstrumentLayer::ROTATION, FGSteam::get_VSI_fps, -2000.0, 2000.0, 42.0/500.0, 270.0); + inst->addTransformation(FGInstrumentLayer::YSHIFT, SIX_W * 12.0/64.0); return inst; } @@ -288,14 +478,18 @@ createRPMGauge (int x, int y) FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SMALL_W, SMALL_W); // Layer 0: gauge background - inst->addLayer(createTexture("Textures/Panel/rpm.rgb")); + inst->addLayer(createTexture("Textures/Panel/faces-3.rgb"), -1, -1, + 0, 0.5, 0.5, 1.0); // Layer 1: long needle // FIXME: moves with throttle (for now) - inst->addLayer(createTexture("Textures/Panel/long-needle.rgb")); + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W*(5.0/64.0)), int(SIX_W*(7.0/16.0)), + 102.0/128.0, 100.0/128.0, 107.0/128.0, 1.0); inst->addTransformation(FGInstrumentLayer::ROTATION, FGBFI::getThrottle, 0.0, 100.0, 300.0, -150.0); + inst->addTransformation(FGInstrumentLayer::YSHIFT, SIX_W * 12.0/64.0); return inst; } @@ -310,27 +504,36 @@ createFlapIndicator (int x, int y) FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SMALL_W, SMALL_W); // Layer 0: gauge background - inst->addLayer(createTexture("Textures/Panel/flaps.rgb")); + inst->addLayer(createTexture("Textures/Panel/faces-3.rgb"), -1, -1, + 0.5, 0.5, 1.0, 1.0); // Layer 1: long needle // shifted over, rotates with flap position - inst->addLayer(createTexture("Textures/Panel/long-needle.rgb")); + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W*(5.0/64.0)), int(SIX_W*(7.0/16.0)), + 102.0/128.0, 100.0/128.0, 107.0/128.0, 1.0); inst->addTransformation(FGInstrumentLayer::XSHIFT, -(SMALL_W / 4) + (SMALL_W / 16)); inst->addTransformation(FGInstrumentLayer::ROTATION, FGBFI::getFlaps, 0.0, 1.0, 120.0, 30.0); + inst->addTransformation(FGInstrumentLayer::YSHIFT, SIX_W * 12.0/64.0); return inst; } + +/** + * Construct a digital chronometer. + */ static FGPanelInstrument * createChronometer (int x, int y) { FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SMALL_W, SMALL_W); // Layer 0: gauge background - inst->addLayer(createTexture("Textures/Panel/clock.rgb")); + inst->addLayer(createTexture("Textures/Panel/faces-3.rgb"), -1, -1, + 0.5, 0, 1.0, 0.5); // Layer 1: text // displays current GMT @@ -355,38 +558,51 @@ createControls (int x, int y) FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SMALL_W, SMALL_W); // Layer 0: gauge background - inst->addLayer(createTexture("Textures/Panel/controls.rgb")); + inst->addLayer(createTexture("Textures/Panel/faces-3.rgb"), -1, -1, + 0, 0, 0.5, 0.5); // Layer 1: bug // moves left-right with aileron - inst->addLayer(createTexture("Textures/Panel/bug.rgb")); + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W * (4.0/64.0)), int(SIX_W * (4.0/64.0)), + (108.0/128.0), (104.0/128.0), (112.0/128.0), (108.0/128.0)); inst->addTransformation(FGInstrumentLayer::XSHIFT, FGBFI::getAileron, -1.0, 1.0, SMALL_W * .75 / 2.0, 0.0); + inst->addTransformation(FGInstrumentLayer::YSHIFT, (SIX_W/2.0) - 12); // Layer 2: bug // moves left-right with rudder - inst->addLayer(createTexture("Textures/Panel/bug.rgb")); + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W * (4.0/64.0)), int(SIX_W * (4.0/64.0)), + (108.0/128.0), (104.0/128.0), (112.0/128.0), (108.0/128.0)); inst->addTransformation(FGInstrumentLayer::ROTATION, 180.0); inst->addTransformation(FGInstrumentLayer::XSHIFT, FGBFI::getRudder, -1.0, 1.0, -SMALL_W * .75 / 2.0, 0.0); + inst->addTransformation(FGInstrumentLayer::YSHIFT, (SIX_W/2.0) - 12); // Layer 3: bug // moves up-down with elevator trim - inst->addLayer(createTexture("Textures/Panel/bug.rgb")); + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W * (4.0/64.0)), int(SIX_W * (4.0/64.0)), + (108.0/128.0), (104.0/128.0), (112.0/128.0), (108.0/128.0)); inst->addTransformation(FGInstrumentLayer::ROTATION, 270.0); inst->addTransformation(FGInstrumentLayer::YSHIFT, -SMALL_W * (3.0 / 8.0)); inst->addTransformation(FGInstrumentLayer::XSHIFT, FGBFI::getElevatorTrim, -1.0, 1.0, SMALL_W * .75 / 2.0, 0.0); + inst->addTransformation(FGInstrumentLayer::YSHIFT, (SIX_W/2.0) - 12); // Layer 4: bug // moves up-down with elevator - inst->addLayer(createTexture("Textures/Panel/bug.rgb")); + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W * (4.0/64.0)), int(SIX_W * (4.0/64.0)), + (108.0/128.0), (104.0/128.0), (112.0/128.0), (108.0/128.0)); inst->addTransformation(FGInstrumentLayer::ROTATION, 90.0); inst->addTransformation(FGInstrumentLayer::YSHIFT, -SMALL_W * (3.0 / 8.0)); inst->addTransformation(FGInstrumentLayer::XSHIFT, FGBFI::getElevator, -1.0, 1.0, -SMALL_W * .75 / 2.0, 0.0); + inst->addTransformation(FGInstrumentLayer::YSHIFT, (SIX_W/2.0) - 12); return inst; } @@ -418,41 +634,70 @@ createNAV1 (int x, int y) FGBFI::setNAV1SelRadial, -5.0, 0.0, 360.0, true)); - // Layer 0: background - inst->addLayer(createTexture("Textures/Panel/gyro-bg.rgb")); + // Layer: background + inst->addLayer(createTexture("Textures/Panel/faces-1.rgb"), -1, -1, + 0, 0.5, 0.5, 1.0); inst->addTransformation(FGInstrumentLayer::ROTATION, FGBFI::getNAV1SelRadial, -360.0, 360.0, -1.0, 0.0); - // Layer 1: left-right needle. - inst->addLayer(createTexture("Textures/Panel/nav-needle.rgb")); + // Layer 3: face with markings + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + SIX_W/2, int(SIX_W * (5.0 / 8.0)), + 0, 0, 0.25, (5.0 / 16.0)); + + // Layer: OBS knob + // rotates with selected radial + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W * (21.0/112.0)), int(SIX_W * (21.0/112.0)), + 0.0, (86.0/128.0), (21.0/128.0), (107.0/128.0)); + inst->addTransformation(FGInstrumentLayer::XSHIFT, -SIX_W/2 + 10); + inst->addTransformation(FGInstrumentLayer::YSHIFT, -SIX_W/2 + 10); + inst->addTransformation(FGInstrumentLayer::ROTATION, + FGBFI::getNAV1SelRadial, + -360.0, 360.0, 1.0, 0.0); + + // Layer: TO/FROM flag + int flag_w = int(SIX_W * (8.0/64.0)); + int flag_h = int(SIX_W * (6.0/64.0)); + + FGTexturedLayer * off = + new FGTexturedLayer(createTexture("Textures/Panel/misc-1.rgb"), + flag_w, flag_h, + 120.0/128.0, 0.5, 1.0, 70.0/128.0); + FGTexturedLayer * from = + new FGTexturedLayer(createTexture("Textures/Panel/misc-1.rgb"), + flag_w, flag_h, + 120.0/128.0, 80.0/128.0, 1.0, 86.0/128.0); + FGTexturedLayer * to = + new FGTexturedLayer(createTexture("Textures/Panel/misc-1.rgb"), + flag_w, flag_h, + 120.0/128.0, 74.0/128.0, 1.0, 80.0/128.0); + FGSwitchLayer * sw1 = + new FGSwitchLayer(flag_w, flag_h, panelGetNAV1FROM, from, off); + FGSwitchLayer * sw2 = + new FGSwitchLayer(flag_w, flag_h, panelGetNAV1TO, to, sw1); + inst->addLayer(sw2); + inst->addTransformation(FGInstrumentLayer::YSHIFT, -int(SIX_W*0.1875)); + + // Layer: left-right needle. + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + SIX_W * (2.0/64.0), SIX_W/2, + (56.0/128.0), 0.5, (58.0/128.0), 1.0); inst->addTransformation(FGInstrumentLayer::XSHIFT, FGSteam::get_HackVOR1_deg, -10.0, 10.0, SIX_W / 40.0, 0.0); - // Layer 2: glidescope needle - inst->addLayer(createTexture("Textures/Panel/nav-needle.rgb")); + // Layer: glidescope needle + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + SIX_W * (2.0/64.0), SIX_W/2, + (56.0/128.0), 0.5, (58.0/128.0), 1.0); inst->addTransformation(FGInstrumentLayer::YSHIFT, FGSteam::get_HackGS_deg, -1.0, 1.0, SIX_W / 5.0, 0.0); inst->addTransformation(FGInstrumentLayer::ROTATION, 90 ); - // Layer 3: face with markings - inst->addLayer(createTexture("Textures/Panel/nav-face.rgb")); - - // Layer 4: heading knob - // rotates with selected radial - FGTexturedLayer * layer = - new FGTexturedLayer(createTexture("Textures/Panel/knobs.rgb"), - SIX_W/4, SIX_W/4, 0.0, 0.5, 0.25, 0.75); - inst->addLayer(layer); - inst->addTransformation(FGInstrumentLayer::XSHIFT, -SIX_W/2 + 10); - inst->addTransformation(FGInstrumentLayer::YSHIFT, -SIX_W/2 + 10); - inst->addTransformation(FGInstrumentLayer::ROTATION, - FGBFI::getNAV1SelRadial, - -360.0, 360.0, 1.0, 0.0); - return inst; } @@ -483,35 +728,60 @@ createNAV2 (int x, int y) FGBFI::setNAV2SelRadial, -5.0, 0.0, 360.0, true)); - // Layer 0: background - inst->addLayer(createTexture("Textures/Panel/gyro-bg.rgb")); + // Layer: background + inst->addLayer(createTexture("Textures/Panel/faces-1.rgb"), -1, -1, + 0, 0.5, 0.5, 1.0); inst->addTransformation(FGInstrumentLayer::ROTATION, FGBFI::getNAV2SelRadial, -360.0, 360.0, -1.0, 0.0); - // Layer 1: left-right needle. - inst->addLayer(createTexture("Textures/Panel/nav-needle.rgb")); - inst->addTransformation(FGInstrumentLayer::XSHIFT, - FGSteam::get_HackVOR2_deg, - -10.0, 10.0, SIX_W / 40.0, 0.0); -// inst->addTransformation(FGInstrumentLayer::YSHIFT, -// -SIX_W / 4.4 ); + // Layer: face with markings. + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + SIX_W/2, int(SIX_W * (5.0 / 8.0)), + 0, 0, 0.25, (5.0 / 16.0)); - // Layer 2: face with markings. - inst->addLayer(createTexture("Textures/Panel/nav-face.rgb")); - - // Layer 3: heading knob + // Layer: OBS knob // rotates with selected radial - FGTexturedLayer * layer = - new FGTexturedLayer(createTexture("Textures/Panel/knobs.rgb"), - SIX_W/4, SIX_W/4, 0.0, 0.5, 0.25, 0.75); - inst->addLayer(layer); + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W * (21.0/112.0)), int(SIX_W * (21.0/112.0)), + 0.0, (86.0/128.0), (21.0/128.0), (107.0/128.0)); inst->addTransformation(FGInstrumentLayer::XSHIFT, -SIX_W/2 + 10); inst->addTransformation(FGInstrumentLayer::YSHIFT, -SIX_W/2 + 10); inst->addTransformation(FGInstrumentLayer::ROTATION, FGBFI::getNAV2SelRadial, -360.0, 360.0, 1.0, 0.0); + // Layer: TO/FROM flag + int flag_w = int(SIX_W * (8.0/64.0)); + int flag_h = int(SIX_W * (6.0/64.0)); + + FGTexturedLayer * off = + new FGTexturedLayer(createTexture("Textures/Panel/misc-1.rgb"), + flag_w, flag_h, + 120.0/128.0, 0.5, 1.0, 70.0/128.0); + FGTexturedLayer * from = + new FGTexturedLayer(createTexture("Textures/Panel/misc-1.rgb"), + flag_w, flag_h, + 120.0/128.0, 80.0/128.0, 1.0, 86.0/128.0); + FGTexturedLayer * to = + new FGTexturedLayer(createTexture("Textures/Panel/misc-1.rgb"), + flag_w, flag_h, + 120.0/128.0, 74.0/128.0, 1.0, 80.0/128.0); + FGSwitchLayer * sw1 = + new FGSwitchLayer(flag_w, flag_h, panelGetNAV2FROM, from, off); + FGSwitchLayer * sw2 = + new FGSwitchLayer(flag_w, flag_h, panelGetNAV2TO, to, sw1); + inst->addLayer(sw2); + inst->addTransformation(FGInstrumentLayer::YSHIFT, -int(SIX_W*0.1875)); + + // Layer: left-right needle. + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + SIX_W * (2.0/64.0), SIX_W/2, + (56.0/128.0), 0.5, (58.0/128.0), 1.0); + inst->addTransformation(FGInstrumentLayer::XSHIFT, + FGSteam::get_HackVOR2_deg, + -10.0, 10.0, SIX_W / 40.0, 0.0); + return inst; } @@ -543,28 +813,36 @@ createADF (int x, int y) 5.0, 0.0, 360.0, true)); // Layer 0: background - inst->addLayer(createTexture("Textures/Panel/gyro-bg.rgb")); + inst->addLayer(createTexture("Textures/Panel/faces-1.rgb"), -1, -1, + 0, 0.5, 0.5, 1.0); inst->addTransformation(FGInstrumentLayer::ROTATION, FGBFI::getADFRotation, 0.0, 360.0, 1.0, 0.0); // Layer 1: Direction needle. - inst->addLayer(createTexture("Textures/Panel/long-needle.rgb")); + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + SIX_W * (6.0/64.0), SIX_W * (40.0/64.0), + (120.0/128.0), (88.0/128.0), 1.0, 1.0); inst->addTransformation(FGInstrumentLayer::ROTATION, FGSteam::get_HackADF_deg, -720.0, 720.0, 1.0, 0.0); // Layer 2: heading knob // rotates with selected radial - FGTexturedLayer * layer = - new FGTexturedLayer(createTexture("Textures/Panel/knobs.rgb"), - SIX_W/4, SIX_W/4, 0.0, 0.75, 0.25, 1.0); - inst->addLayer(layer); + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W * (21.0/112.0)), int(SIX_W * (21.0/112.0)), + 0.0, (107.0/128.0), (21.0/128.0), 1.0); inst->addTransformation(FGInstrumentLayer::XSHIFT, -SIX_W/2 + 10); inst->addTransformation(FGInstrumentLayer::YSHIFT, -SIX_W/2 + 10); inst->addTransformation(FGInstrumentLayer::ROTATION, FGBFI::getADFRotation, -360.0, 360.0, -1.0, 0.0); + + // Layer 3: airplace at centre + inst->addLayer(createTexture("Textures/Panel/misc-1.rgb"), + int(SIX_W * (20.0/64.0)), int(SIX_W * (16.0/64.0)), + 102.0/128.0, 32.0/128.0, 1.0, 48.0/128.0); + return inst; } @@ -579,7 +857,7 @@ createNavCom1 (int x, int y) // Use the button to swap standby and active // NAV frequencies - inst->addAction(0, SIX_W * .375, -SIX_W/4, SIX_W/4, SIX_W/4, + inst->addAction(0, int(SIX_W * .375), -SIX_W/4, SIX_W/4, SIX_W/4, new FGSwapAction(FGBFI::getNAV1Freq, FGBFI::setNAV1Freq, FGBFI::getNAV1AltFreq, @@ -605,7 +883,7 @@ createNavCom1 (int x, int y) // Layer 0: background FGTexturedLayer * layer = - new FGTexturedLayer(createTexture("Textures/Panel/radios.rgb"), + new FGTexturedLayer(createTexture("Textures/Panel/radios-1.rgb"), SIX_W*2, SIX_W/2, 0.0, 0.75, 1.0, 1.0); inst->addLayer(layer); @@ -633,7 +911,7 @@ createNavCom2 (int x, int y) // Use the button to swap standby and active // NAV frequencies - inst->addAction(0, SIX_W * .375, -SIX_W/4, SIX_W/4, SIX_W/4, + inst->addAction(0, int(SIX_W * .375), -SIX_W/4, SIX_W/4, SIX_W/4, new FGSwapAction(FGBFI::getNAV2Freq, FGBFI::setNAV2Freq, FGBFI::getNAV2AltFreq, @@ -659,7 +937,7 @@ createNavCom2 (int x, int y) // Layer 0: background FGTexturedLayer * layer = - new FGTexturedLayer(createTexture("Textures/Panel/radios.rgb"), + new FGTexturedLayer(createTexture("Textures/Panel/radios-1.rgb"), SIX_W*2, SIX_W/2, 0.0, 0.75, 1.0, 1.0); inst->addLayer(layer); @@ -686,26 +964,30 @@ createADFRadio (int x, int y) FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W*2, SIX_W/2); // Use the knob to tune the standby NAV - inst->addAction(0, SIX_W * 0.7, -SIX_W * 0.07, SIX_W * 0.09, SIX_W * 0.14, + inst->addAction(0, int(SIX_W * 0.7), int(-SIX_W * 0.07), + int(SIX_W * 0.09), int(SIX_W * 0.14), new FGAdjustAction(FGBFI::getADFFreq, FGBFI::setADFFreq, -1.0, 100.0, 1299, true)); - inst->addAction(0, SIX_W * 0.79, -SIX_W * 0.07, SIX_W * 0.09, SIX_W * 0.14, + inst->addAction(0, int(SIX_W * 0.79), int(-SIX_W * 0.07), + int(SIX_W * 0.09), int(SIX_W * 0.14), new FGAdjustAction(FGBFI::getADFFreq, FGBFI::setADFFreq, 1.0, 100.0, 1299, true)); - inst->addAction(1, SIX_W * 0.7, -SIX_W * 0.07, SIX_W * 0.09, SIX_W * 0.14, + inst->addAction(1, int(SIX_W * 0.7), int(-SIX_W * 0.07), + int(SIX_W * 0.09), int(SIX_W * 0.14), new FGAdjustAction(FGBFI::getADFFreq, FGBFI::setADFFreq, -25.0, 100.0, 1299, true)); - inst->addAction(1, SIX_W * 0.79, -SIX_W * 0.07, SIX_W * 0.09, SIX_W * 0.14, + inst->addAction(1, int(SIX_W * 0.79), int(-SIX_W * 0.07), + int(SIX_W * 0.09), int(SIX_W * 0.14), new FGAdjustAction(FGBFI::getADFFreq, FGBFI::setADFFreq, 25.0, 100.0, 1299, true)); // Layer 0: background FGTexturedLayer * layer = - new FGTexturedLayer(createTexture("Textures/Panel/radios.rgb"), + new FGTexturedLayer(createTexture("Textures/Panel/radios-1.rgb"), SIX_W*2, SIX_W/2, 0.0, 0.5, 1.0, 0.75); inst->addLayer(layer); @@ -731,36 +1013,36 @@ createAP (int x, int y) FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W*2, SIX_W/4); // Action: select HDG button - inst->addAction(0, -SIX_W*0.6125, -SIX_W/16, SIX_W/4, SIX_W/8, + inst->addAction(0, int(-SIX_W*0.6125), -SIX_W/16, SIX_W/4, SIX_W/8, new FGToggleAction(FGBFI::getAPHeadingLock, FGBFI::setAPHeadingLock)); // Action: select NAV button - inst->addAction(0, -SIX_W*0.3625, -SIX_W/16, SIX_W/4, SIX_W/8, + inst->addAction(0, int(-SIX_W*0.3625), -SIX_W/16, SIX_W/4, SIX_W/8, new FGToggleAction(FGBFI::getAPNAV1Lock, FGBFI::setAPNAV1Lock)); // Action: select ALT button - inst->addAction(0, -SIX_W*0.1125, -SIX_W/16, SIX_W/4, SIX_W/8, + inst->addAction(0, int(-SIX_W*0.1125), -SIX_W/16, SIX_W/4, SIX_W/8, new FGToggleAction(FGBFI::getAPAltitudeLock, FGBFI::setAPAltitudeLock)); // Layer: AP background FGTexturedLayer * layer; - layer = new FGTexturedLayer(createTexture("Textures/Panel/radios.rgb"), + layer = new FGTexturedLayer(createTexture("Textures/Panel/radios-1.rgb"), SIX_W*2, SIX_W/4, 0.0, 0.375, 1.0, 0.5); inst->addLayer(layer); // Display HDG button FGTexturedLayer *l1 = - new FGTexturedLayer(createTexture("Textures/Panel/knobs.rgb"), + new FGTexturedLayer(createTexture("Textures/Panel/misc-1.rgb"), SIX_W/4, SIX_W/8, - 7.0/16.0, 27.0/32.0, 9.0/16.0, 15.0/16.0); + 39.0/128.0, 118.0/128.0, 54.0/128.0, 1.0); FGTexturedLayer *l2 = - new FGTexturedLayer(createTexture("Textures/Panel/knobs.rgb"), + new FGTexturedLayer(createTexture("Textures/Panel/misc-1.rgb"), SIX_W/4, SIX_W/8, - 1.0/4.0, 27.0/32.0, 3.0/8.0, 15.0/16.0); + 22.0/128.0, 118.0/128.0, 37.0/128.0, 1.0); FGSwitchLayer * sw = new FGSwitchLayer(SIX_W/4, SIX_W/8, FGBFI::getAPHeadingLock, l1, l2); inst->addLayer(sw); @@ -768,13 +1050,13 @@ createAP (int x, int y) // Display NAV button l1 = - new FGTexturedLayer(createTexture("Textures/Panel/knobs.rgb"), + new FGTexturedLayer(createTexture("Textures/Panel/misc-1.rgb"), SIX_W/4, SIX_W/8, - 7.0/16.0, 3.0/4.0, 9.0/16.0, 27.0/32.0); + 39.0/128.0, 106.0/128.0, 54.0/128.0, 116.0/128.0); l2 = - new FGTexturedLayer(createTexture("Textures/Panel/knobs.rgb"), + new FGTexturedLayer(createTexture("Textures/Panel/misc-1.rgb"), SIX_W/4, SIX_W/8, - 1.0/4.0, 3.0/4.0, 3.0/8.0, 27.0/32.0); + 22.0/128.0, 106.0/128.0, 37.0/128.0, 116.0/128.0); sw = new FGSwitchLayer(SIX_W/4, SIX_W/8, FGBFI::getAPNAV1Lock, l1, l2); inst->addLayer(sw); @@ -782,13 +1064,13 @@ createAP (int x, int y) // Display ALT button l1 = - new FGTexturedLayer(createTexture("Textures/Panel/knobs.rgb"), + new FGTexturedLayer(createTexture("Textures/Panel/misc-1.rgb"), SIX_W/4, SIX_W/8, - 7.0/16.0, 9.0/16.0, 9.0/16.0, 21.0/32.0); + 39.0/128.0, 82.0/128.0, 54.0/128.0, 92.0/128.0); l2 = - new FGTexturedLayer(createTexture("Textures/Panel/knobs.rgb"), + new FGTexturedLayer(createTexture("Textures/Panel/misc-1.rgb"), SIX_W/4, SIX_W/8, - 1.0/4.0, 9.0/16.0, 3.0/8.0, 21.0/32.0); + 22.0/128.0, 82.0/128.0, 37.0/128.0, 92.0/128.0); sw = new FGSwitchLayer(SIX_W/4, SIX_W/8, FGBFI::getAPAltitudeLock, l1, l2); inst->addLayer(sw); @@ -799,24 +1081,34 @@ createAP (int x, int y) FGPanelInstrument * createDME (int x, int y) { - FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, - SIX_W * 0.75, - SIX_W * 0.25); + FGLayeredInstrument * inst = + new FGLayeredInstrument(x, y, int(SIX_W * 0.75), int(SIX_W * 0.25)); // Layer: background FGTexturedLayer * layer = - new FGTexturedLayer(createTexture("Textures/Panel/radios.rgb"), - SIX_W * 0.75, SIX_W * 0.25, + new FGTexturedLayer(createTexture("Textures/Panel/radios-1.rgb"), + int(SIX_W * 0.75), int(SIX_W * 0.25), 0.0, 0.25, 0.375, 0.375); inst->addLayer(layer); // Layer: current distance - FGTextLayer * text = new FGTextLayer(SIX_W/2, SIX_W/4); - text->addChunk(new FGTextLayer::Chunk(FGBFI::getNAV1DistDME, "%05.1f", - METER_TO_NM)); - text->setPointSize(14); - text->setColor(1.0, 0.5, 0.0); - inst->addLayer(text); + + FGTextLayer * text1 = new FGTextLayer(SIX_W/2, SIX_W/4); + text1->addChunk(new FGTextLayer::Chunk(FGBFI::getNAV1DistDME, "%05.1f", + METER_TO_NM)); + text1->setPointSize(12); + text1->setColor(1.0, 0.5, 0.0); + + FGTextLayer * text2 = new FGTextLayer(SIX_W/2, SIX_W/4); + text2->addChunk(new FGTextLayer::Chunk("---.-")); + text2->setPointSize(12); + text2->setColor(1.0, 0.5, 0.0); + + FGSwitchLayer * sw = + new FGSwitchLayer(SIX_W/2, SIX_W/4, FGBFI::getNAV1DMEInRange, + text1, text2); + + inst->addLayer(sw); inst->addTransformation(FGInstrumentLayer::XSHIFT, -20); inst->addTransformation(FGInstrumentLayer::YSHIFT, -6); @@ -830,9 +1122,12 @@ createDME (int x, int y) //////////////////////////////////////////////////////////////////////// FGPanel * -fgCreateSmallSinglePropPanel (int x, int y, int finx, int finy) +fgCreateSmallSinglePropPanel (int xpos, int ypos, int finx, int finy) { - FGPanel * panel = new FGPanel(x, y, finx - x, finy - y); + int w = finx - xpos; + int h = finy - ypos; + FGPanel * panel = new FGPanel(xpos, ypos, w, h); + int x, y; x = SIX_X; y = SIX_Y; @@ -840,6 +1135,10 @@ fgCreateSmallSinglePropPanel (int x, int y, int finx, int finy) // Set the background texture panel->setBackground(createTexture("Textures/Panel/panel-bg.rgb")); + // Mag compass at top. + panel->addInstrument(createMagneticCompass((w / 2), + int(h * 0.5768) + (SIX_W / 8))); + // Chronometer alone at side x = SIX_X - SIX_SPACING - 8; panel->addInstrument(createChronometer(x, y)); diff --git a/src/Main/bfi.cxx b/src/Main/bfi.cxx index 229676e77..46365b96f 100644 --- a/src/Main/bfi.cxx +++ b/src/Main/bfi.cxx @@ -395,6 +395,16 @@ FGBFI::getHeading () } +/** + * Return the current heading in degrees. + */ +double +FGBFI::getHeadingMag () +{ + return current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG - getMagVar(); +} + + /** * Set the current heading in degrees. */ @@ -773,8 +783,14 @@ void FGBFI::setAPHeadingLock (bool lock) { if (lock) { + // We need to do this so that + // it's possible to lock onto a + // heading other than the current + // heading. + double heading = getAPHeadingMag(); current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_LOCK); current_autopilot->set_HeadingEnabled(true); + setAPHeadingMag(heading); } else if (current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_LOCK) { current_autopilot->set_HeadingEnabled(false); @@ -865,6 +881,19 @@ FGBFI::getNAV1DistDME () return current_radiostack->get_nav1_dme_dist(); } +bool +FGBFI::getNAV1InRange () +{ + return current_radiostack->get_nav1_inrange(); +} + +bool +FGBFI::getNAV1DMEInRange () +{ + return (current_radiostack->get_nav1_inrange() && + current_radiostack->get_nav1_has_dme()); +} + double FGBFI::getNAV2Freq () { @@ -895,6 +924,19 @@ FGBFI::getNAV2DistDME () return current_radiostack->get_nav2_dme_dist(); } +bool +FGBFI::getNAV2InRange () +{ + return current_radiostack->get_nav2_inrange(); +} + +bool +FGBFI::getNAV2DMEInRange () +{ + return (current_radiostack->get_nav2_inrange() && + current_radiostack->get_nav2_has_dme()); +} + double FGBFI::getADFFreq () { diff --git a/src/Main/bfi.hxx b/src/Main/bfi.hxx index 759f6d524..d27c5913c 100644 --- a/src/Main/bfi.hxx +++ b/src/Main/bfi.hxx @@ -77,7 +77,8 @@ public: // Attitude - static double getHeading (); + static double getHeading (); // true heading + static double getHeadingMag (); // exact magnetic heading static double getPitch (); static double getRoll (); @@ -137,12 +138,16 @@ public: static double getNAV1Radial (); static double getNAV1SelRadial (); static double getNAV1DistDME (); + static bool getNAV1InRange (); + static bool getNAV1DMEInRange (); static double getNAV2Freq (); static double getNAV2AltFreq (); static double getNAV2Radial (); static double getNAV2SelRadial (); static double getNAV2DistDME (); + static bool getNAV2InRange (); + static bool getNAV2DMEInRange (); static double getADFFreq (); static double getADFAltFreq (); -- 2.39.5