]> git.mxchange.org Git - flightgear.git/commitdiff
User-visible
authorcurt <curt>
Tue, 2 May 2000 18:26:00 +0000 (18:26 +0000)
committercurt <curt>
Tue, 2 May 2000 18:26:00 +0000 (18:26 +0000)
- knobs now continue to rotate when you hold down the mouse
- the middle mouse button makes knobs rotate much faster
- there are NAV1, NAV2, and ADF radios that can be tuned using the mouse
- there are standby frequencies for NAV1 and NAV2, and buttons to swap
- there is a crude, rather silly-looking DME, hard-wired to NAV1
- there is a crude, rather silly-looking autopilot that can lock
  the heading (to the bug on the gyro), can lock to NAV1, and can lock
  the current altitude
- the knobs for changing the radials on NAV1 and NAV2 look much better
  and are in the right place
- tuning into an ILS frequency doesn't change the displayed radial for
  NAV1

Code

- I've created a new module, sp_panel.[ch]xx, that constructs the
  default single-prop panel; this works entirely outside of FGPanel,
  so it is possible to construct similar modules for other sorts of
  panels; all code specific to the default panel has been removed from
  panel.cxx
- current_panel is now a pointer
- radiostack.[ch]xx keeps track both of the actual radial and of the
  selected radial (they will differ with ILS); the NAV gauges should
  not spin around automatically to show the actual radial (we need to
  do something similar with the autopilot)
- the panel is initialized fairly early
- make sure that standby frequencies also get initialized
- I've started combining and clipping small textures to save texture
  memory; there's a lot more to do, but at least I've made a start

15 files changed:
src/Cockpit/Makefile.am
src/Cockpit/cockpit.cxx
src/Cockpit/panel.cxx
src/Cockpit/panel.hxx
src/Cockpit/proposed-navaids.hpp [deleted file]
src/Cockpit/radiostack.cxx
src/Cockpit/radiostack.hxx
src/Cockpit/sp_panel.cxx [new file with mode: 0644]
src/Cockpit/sp_panel.hxx [new file with mode: 0644]
src/Cockpit/steam.cxx
src/GUI/gui.cxx
src/Main/bfi.cxx
src/Main/bfi.hxx
src/Main/fg_init.cxx
src/Main/options.cxx

index 7fe7c3b945f172f66ed05be69751cc3865313b17..f155615738a30c11ddabf0e4dfeee962321970c8 100644 (file)
@@ -9,6 +9,7 @@ libCockpit_a_SOURCES = \
        hud_scal.cxx hud_tbi.cxx \
        panel.cxx panel.hxx \
        radiostack.cxx radiostack.hxx \
+       sp_panel.cxx sp_panel.hxx \
        steam.cxx steam.hxx
 
 INCLUDES += -I$(top_builddir) -I$(top_builddir)/src
index ed832c5ad9ff49e0268d7c15c7a00c8168897cec..4b381f3714ea671eda5cb3fd781adf0eee9d6abd 100644 (file)
@@ -459,10 +459,6 @@ bool fgCockpitInit( fgAIRCRAFT *cur_aircraft )
     fgHUDInit( cur_aircraft );
     ac_cockpit = new fg_Cockpit();
     
-    if ( current_options.get_panel_status() ) {
-        new FGPanel;
-    }
-
     // Have to set the LatLon display type
     fgLatLonFormat = toDM;
     
@@ -535,5 +531,5 @@ void fgCockpitUpdate( void ) {
     
     xglViewport( 0, 0, iwidth, iheight );
 
-    current_panel.update();
+    current_panel->update();
 }
index 7e0ac75647a39037f47a9a8108001a5e124d0374..9a3cd00a48ec8d48410fb6b7494248be83cf77e4 100644 (file)
 
 #include <plib/ssg.h>
 #include <plib/fnt.h>
-#include <GL/glut.h>
 
 #include <simgear/debug/logstream.hxx>
 #include <simgear/misc/fgpath.hxx>
 #include <Main/options.hxx>
 #include <Main/views.hxx>
-#include <Main/bfi.hxx>
 #include <Objects/texload.h>
-#include <Time/fg_time.hxx>
 
-#include "cockpit.hxx"
-#include "panel.hxx"
 #include "hud.hxx"
-#include "steam.hxx"
-
-#define SIX_X 200
-#define SIX_Y 345
-#define SIX_W 128
-#define SIX_SPACING (SIX_W + 5)
-#define SMALL_W 112
-
-
-\f
-////////////////////////////////////////////////////////////////////////
-// Static functions for obtaining settings.
-//
-// These should be replaced with functions from a global facade,
-// or BFI (Big Friendly Interface).
-////////////////////////////////////////////////////////////////////////
-
-static char * panelGetTime (char * buf)
-{
-  struct tm * t = FGTime::cur_time_params->getGmt();
-  sprintf(buf, " %.2d:%.2d:%.2d",
-         t->tm_hour, t->tm_min, t->tm_sec);
-  return buf;
-}
-
-
-\f
-////////////////////////////////////////////////////////////////////////
-// Static factory functions to create textured gauges.
-//
-// These will be replaced first with a giant table, and then with
-// configuration files read from an external source, but for now
-// they're hard-coded.
-////////////////////////////////////////////////////////////////////////
-
-
-#define createTexture(a) FGTextureManager::createTexture(a)
-
-/**
- * Construct an airspeed indicator for a single-engine prop.
- */
-static FGPanelInstrument *
-createAirspeedIndicator (int x, int y)
-{
-  FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W, SIX_W);
-
-                               // Layer 0: gauge background.
-  inst->addLayer(0, createTexture("Textures/Panel/airspeed.rgb"));
-
-                               // Layer 1: needle.
-                               // Rotates with airspeed.
-  inst->addLayer(1, createTexture("Textures/Panel/long-needle.rgb"));
-  inst->addTransformation(1, FGInstrumentLayer::ROTATION,
-                         FGSteam::get_ASI_kias,
-                         30.0, 220.0, 36.0 / 20.0, -54.0);
-  return inst;
-}
-
-
-/**
- * Construct an artificial horizon.
- */
-static FGPanelInstrument *
-createHorizon (int x, int y)
-{
-  FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W, SIX_W);
-
-                               // Layer 0: coloured background
-                               // moves with roll only
-  inst->addLayer(0, createTexture("Textures/Panel/horizon-bg.rgb"));
-  inst->addTransformation(0, FGInstrumentLayer::ROTATION,
-                         FGBFI::getRoll,
-                         -360.0, 360.0, -1.0, 0.0);
-
-                               // Layer 1: floating horizon
-                               // moves with roll and pitch
-  inst->addLayer(1, createTexture("Textures/Panel/horizon-float.rgb"));
-  inst->addTransformation(1, FGInstrumentLayer::ROTATION,
-                         FGBFI::getRoll,
-                         -360.0, 360.0, -1.0, 0.0);
-  inst->addTransformation(1, FGInstrumentLayer::YSHIFT,
-                         FGBFI::getPitch,
-                         -20.0, 20.0, -(1.5 / 160.0) * SIX_W, 0.0);
-
-                               // Layer 2: rim
-                               // moves with roll only
-  inst->addLayer(2, createTexture("Textures/Panel/horizon-rim.rgb"));
-  inst->addTransformation(2, FGInstrumentLayer::ROTATION,
-                         FGBFI::getRoll,
-                         -360.0, 360.0, -1.0, 0.0);
-
-                               // Layer 3: glass front of gauge
-                               // fixed, with markings
-  inst->addLayer(3, createTexture("Textures/Panel/horizon-fg.rgb"));
-
-  return inst;
-}
-
-
-/**
- * Construct an altimeter.
- */
-static FGPanelInstrument *
-createAltimeter (int x, int y)
-{
-  FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W, SIX_W);
-
-                               // Layer 0: gauge background
-  inst->addLayer(0, createTexture("Textures/Panel/altimeter.rgb"));
-
-                               // Layer 1: hundreds needle (long)
-                               // moves with altitude
-  inst->addLayer(1, createTexture("Textures/Panel/long-needle.rgb"));
-  inst->addTransformation(1, FGInstrumentLayer::ROTATION,
-                         FGSteam::get_ALT_ft,
-                         0.0, 100000.0, 360.0 / 1000.0, 0.0);
-
-                               // Layer 2: thousands needle (short)
-                               // moves with altitude
-  inst->addLayer(2, createTexture("Textures/Panel/short-needle.rgb"));
-  inst->addTransformation(2, FGInstrumentLayer::ROTATION,
-                         FGSteam::get_ALT_ft,
-                         0.0, 100000.0, 360.0 / 10000.0, 0.0);
-
-                               // Layer 3: ten thousands bug (outside)
-                               // moves with altitude
-  inst->addLayer(3, createTexture("Textures/Panel/bug.rgb"));
-  inst->addTransformation(3, FGInstrumentLayer::ROTATION,
-                         FGSteam::get_ALT_ft,
-                         0.0, 100000.0, 360.0 / 100000.0, 0.0);
-
-  return inst;
-}
-
-
-/**
- * Construct a turn coordinator.
- */
-static FGPanelInstrument *
-createTurnCoordinator (int x, int y)
-{
-  FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W, SIX_W);
-
-                               // Layer 0: background
-  inst->addLayer(0, createTexture("Textures/Panel/turn-bg.rgb"));
-
-                               // Layer 1: little plane
-                               // moves with roll
-  inst->addLayer(1, createTexture("Textures/Panel/turn.rgb"));
-  inst->addTransformation(1, FGInstrumentLayer::ROTATION,
-                         FGSteam::get_TC_radps,
-                         -30.0, 30.0, 1.0, 0.0);
-
-                               // Layer 2: little ball
-                               // moves with slip/skid
-  inst->addLayer(2, createTexture("Textures/Panel/ball.rgb"));
-  inst->addTransformation(2, FGInstrumentLayer::ROTATION,
-                         FGSteam::get_TC_rad,
-                         -0.1, 0.1, 450.0, 0.0);
-
-  return inst;
-}
-
-
-/**
- * Construct a gyro compass.
- */
-static FGPanelInstrument *
-createGyroCompass (int x, int y)
-{
-  FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W, SIX_W);
-
-                               // Action: move bug counter-clockwise
-  inst->addAction(SIX_W/2 - SIX_W/5, -SIX_W/2, SIX_W/10, SIX_W/5,
-                 new FGAdjustAction(FGBFI::getAPHeading,
-                                    FGBFI::setAPHeading,
-                                    -1.0, 0.0, 360.0, true));
-
-                               // Action: move bug clockwise
-  inst->addAction(SIX_W/2 - SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
-                 new FGAdjustAction(FGBFI::getAPHeading,
-                                    FGBFI::setAPHeading,
-                                    1.0, 0.0, 360.0, true));
-
-                               // Layer 0: compass background
-                               // rotates with heading
-  inst->addLayer(0, createTexture("Textures/Panel/gyro-bg.rgb"));
-  inst->addTransformation(0, FGInstrumentLayer::ROTATION,
-                         FGSteam::get_DG_deg,
-                         -360.0, 360.0, -1.0, 0.0);
-
-                               // Layer 1: heading bug
-                               // rotates with heading and AP heading
-  inst->addLayer(1, createTexture("Textures/Panel/bug.rgb"));
-  inst->addTransformation(1, FGInstrumentLayer::ROTATION,
-                         FGSteam::get_DG_deg,
-                         -360.0, 360.0, -1.0, 0.0);
-  inst->addTransformation(1, FGInstrumentLayer::ROTATION,
-                         FGBFI::getAPHeading,
-                         -360.0, 360.0, 1.0, 0.0);
-
-                               // Layer 2: fixed center
-  inst->addLayer(2, createTexture("Textures/Panel/gyro-fg.rgb"));
-
-                               // Layer 3: heading knob
-                               // rotates with AP heading
-  inst->addLayer(3, createTexture("Textures/Panel/heading-knob.rgb"));
-  inst->addTransformation(3, FGInstrumentLayer::XSHIFT, SIX_W/2 - 10); 
-  inst->addTransformation(3, FGInstrumentLayer::YSHIFT, -SIX_W/2 + 10); 
-  inst->addTransformation(3, FGInstrumentLayer::ROTATION,
-                         FGBFI::getAPHeading,
-                         -360.0, 360.0, 1.0, 0.0);
-
-  return inst;
-}
-
-
-/**
- * Construct a vertical velocity indicator.
- */
-static FGPanelInstrument *
-createVerticalVelocity (int x, int y)
-{
-  FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W, SIX_W);
-
-                               // Layer 0: gauge background
-  inst->addLayer(0, createTexture("Textures/Panel/vertical.rgb"));
-
-                               // Layer 1: needle
-                               // moves with vertical velocity
-  inst->addLayer(1, createTexture("Textures/Panel/long-needle.rgb"));
-  inst->addTransformation(1, FGInstrumentLayer::ROTATION,
-                         FGSteam::get_VSI_fps,
-                         -2000.0, 2000.0, 42.0/500.0, 270.0);
-
-  return inst;
-}
-
-
-/**
- * Construct an RPM gauge.
- */
-static FGPanelInstrument *
-createRPMGauge (int x, int y)
-{
-  FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SMALL_W, SMALL_W);
-
-                               // Layer 0: gauge background
-  inst->addLayer(0, createTexture("Textures/Panel/rpm.rgb"));
-
-                               // Layer 1: long needle
-                               // FIXME: moves with throttle (for now)
-  inst->addLayer(1, createTexture("Textures/Panel/long-needle.rgb"));
-  inst->addTransformation(1, FGInstrumentLayer::ROTATION,
-                         FGBFI::getThrottle,
-                         0.0, 100.0, 300.0, -150.0);
-
-  return inst;
-}
-
-
-/**
- * Construct a flap position indicator.
- */
-static FGPanelInstrument *
-createFlapIndicator (int x, int y)
-{
-  FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SMALL_W, SMALL_W);
-
-                               // Layer 0: gauge background
-  inst->addLayer(0, createTexture("Textures/Panel/flaps.rgb"));
-
-                               // Layer 1: long needle
-                               // shifted over, rotates with flap position
-  inst->addLayer(1, createTexture("Textures/Panel/long-needle.rgb"));
-  inst->addTransformation(1, FGInstrumentLayer::XSHIFT,
-                         -(SMALL_W / 4) + (SMALL_W / 16));
-  inst->addTransformation(1, FGInstrumentLayer::ROTATION,
-                         FGBFI::getFlaps,
-                         0.0, 1.0, 120.0, 30.0);
-
-  return inst;
-}
-
-static FGPanelInstrument *
-createChronometer (int x, int y)
-{
-  FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SMALL_W, SMALL_W);
-
-                               // Layer 0: gauge background
-  inst->addLayer(0, createTexture("Textures/Panel/clock.rgb"));
-
-                               // Layer 1: text
-                               // displays current GMT
-  FGCharInstrumentLayer * text =
-    new FGCharInstrumentLayer(panelGetTime,
-                             SMALL_W, SMALL_W, 1);
-  text->setPointSize(14);
-  text->setColor(0.2, 0.2, 0.2);
-  inst->addLayer(text);
-  inst->addTransformation(1, FGInstrumentLayer::XSHIFT, SMALL_W * -0.38);
-  inst->addTransformation(1, FGInstrumentLayer::YSHIFT, SMALL_W * -0.06);
-
-  return inst;
-}
-
-
-/**
- * Construct control-position indicators.
- */
-static FGPanelInstrument *
-createControls (int x, int y)
-{
-  FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SMALL_W, SMALL_W);
-
-                               // Layer 0: gauge background
-  inst->addLayer(0, createTexture("Textures/Panel/controls.rgb"));
-
-                               // Layer 1: bug
-                               // moves left-right with aileron
-  inst->addLayer(1, createTexture("Textures/Panel/bug.rgb"));
-  inst->addTransformation(1, FGInstrumentLayer::XSHIFT, FGBFI::getAileron,
-                         -1.0, 1.0, SMALL_W * .75 / 2.0, 0.0);
-
-                               // Layer 2: bug
-                               // moves left-right with rudder
-  inst->addLayer(2, createTexture("Textures/Panel/bug.rgb"));
-  inst->addTransformation(2, FGInstrumentLayer::ROTATION, 180.0);
-  inst->addTransformation(2, FGInstrumentLayer::XSHIFT, FGBFI::getRudder,
-                         -1.0, 1.0, -SMALL_W * .75 / 2.0, 0.0);
-
-                               // Layer 3: bug
-                               // moves up-down with elevator trim
-  inst->addLayer(3, createTexture("Textures/Panel/bug.rgb"));
-  inst->addTransformation(3, FGInstrumentLayer::ROTATION, 270.0);
-  inst->addTransformation(3, FGInstrumentLayer::YSHIFT,
-                         -SMALL_W * (3.0 / 8.0));
-  inst->addTransformation(3, FGInstrumentLayer::XSHIFT, FGBFI::getElevatorTrim,
-                         -1.0, 1.0, SMALL_W * .75 / 2.0, 0.0);
-
-                               // Layer 4: bug
-                               // moves up-down with elevator
-  inst->addLayer(4, createTexture("Textures/Panel/bug.rgb"));
-  inst->addTransformation(4, FGInstrumentLayer::ROTATION, 90.0);
-  inst->addTransformation(4, FGInstrumentLayer::YSHIFT,
-                         -SMALL_W * (3.0 / 8.0));
-  inst->addTransformation(4, FGInstrumentLayer::XSHIFT, FGBFI::getElevator,
-                         -1.0, 1.0, -SMALL_W * .75 / 2.0, 0.0);
-
-  return inst;
-}
-
-
-/**
- * Construct a NAV1 gauge (hardwired).
- */
-static FGPanelInstrument *
-createNAV1 (int x, int y)
-{
-  FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W, SIX_W);
-
-                               // Action: increase selected radial
-  inst->addAction(SIX_W/2 - SIX_W/5, -SIX_W/2, SIX_W/10, SIX_W/5,
-                 new FGAdjustAction(FGBFI::getNAV1Radial,
-                                    FGBFI::setNAV1Radial,
-                                    1.0, 0.0, 360.0, true));
-
-                               // Action: decrease selected radial
-  inst->addAction(SIX_W/2 - SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
-                 new FGAdjustAction(FGBFI::getNAV1Radial,
-                                    FGBFI::setNAV1Radial,
-                                    -1.0, 0.0, 360.0, true));
-
-                               // Layer 0: background
-  inst->addLayer(0, createTexture("Textures/Panel/gyro-bg.rgb"));
-  inst->addTransformation(0, FGInstrumentLayer::ROTATION,
-                         FGBFI::getNAV1Radial,
-                         -360.0, 360.0, -1.0, 0.0);
-
-                               // Layer 1: left-right needle.
-  inst->addLayer(1, createTexture("Textures/Panel/nav-needle.rgb"));
-  inst->addTransformation(1, FGInstrumentLayer::XSHIFT,
-                         FGSteam::get_HackVOR1_deg,
-                         -10.0, 10.0, SIX_W / 40.0, 0.0);
-
-                               // Layer 2: glidescope needle
-  inst->addLayer(2, createTexture("Textures/Panel/nav-needle.rgb"));
-  inst->addTransformation(2, FGInstrumentLayer::YSHIFT,
-                         FGSteam::get_HackGS_deg,
-                         -1.0, 1.0, SIX_W / 5.0, 0.0);
-  inst->addTransformation(2, FGInstrumentLayer::ROTATION,
-                         90 );
-
-                               // Layer 3: face with markings
-  inst->addLayer(3, createTexture("Textures/Panel/nav-face.rgb"));
-
-                               // Layer 4: heading knob
-                               // rotates with selected radial
-  inst->addLayer(4, createTexture("Textures/Panel/heading-knob.rgb"));
-  inst->addTransformation(4, FGInstrumentLayer::XSHIFT, SIX_W/2 - 10); 
-  inst->addTransformation(4, FGInstrumentLayer::YSHIFT, -SIX_W/2 + 10); 
-  inst->addTransformation(4, FGInstrumentLayer::ROTATION,
-                         FGBFI::getNAV1Radial,
-                         -360.0, 360.0, -1.0, 0.0);
-
-  return inst;
-}
-
-
-/**
- * Construct a NAV2 gauge.
- */
-static FGPanelInstrument *
-createNAV2 (int x, int y)
-{
-  FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W, SIX_W);
-
-                               // Action: increase selected radial
-  inst->addAction(SIX_W/2 - SIX_W/5, -SIX_W/2, SIX_W/10, SIX_W/5,
-                 new FGAdjustAction(FGBFI::getNAV2Radial,
-                                    FGBFI::setNAV2Radial,
-                                    1.0, 0.0, 360.0, true));
-
-                               // Action: decrease selected radial
-  inst->addAction(SIX_W/2 - SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
-                 new FGAdjustAction(FGBFI::getNAV2Radial,
-                                    FGBFI::setNAV2Radial,
-                                    -1.0, 0.0, 360.0, true));
-
-                               // Layer 0: background
-  inst->addLayer(0, createTexture("Textures/Panel/gyro-bg.rgb"));
-  inst->addTransformation(0, FGInstrumentLayer::ROTATION,
-                         FGBFI::getNAV2Radial,
-                         -360.0, 360.0, -1.0, 0.0);
-
-                               // Layer 1: left-right needle.
-  inst->addLayer(1, createTexture("Textures/Panel/nav-needle.rgb"));
-  inst->addTransformation(1, FGInstrumentLayer::XSHIFT,
-                         FGSteam::get_HackVOR2_deg,
-                         -10.0, 10.0, SIX_W / 40.0, 0.0);
-//   inst->addTransformation(1, FGInstrumentLayer::YSHIFT,
-//                       -SIX_W / 4.4 );
-
-                               // Layer 2: face with markings.
-  inst->addLayer(2, createTexture("Textures/Panel/nav-face.rgb"));
-
-                               // Layer 3: heading knob
-                               // rotates with selected radial
-  inst->addLayer(3, createTexture("Textures/Panel/heading-knob.rgb"));
-  inst->addTransformation(3, FGInstrumentLayer::XSHIFT, SIX_W/2 - 10); 
-  inst->addTransformation(3, FGInstrumentLayer::YSHIFT, -SIX_W/2 + 10); 
-  inst->addTransformation(3, FGInstrumentLayer::ROTATION,
-                         FGBFI::getNAV2Radial,
-                         -360.0, 360.0, -1.0, 0.0);
-
-  return inst;
-}
-
-
-/**
- * Construct an ADF gauge (hardwired).
- */
-static FGPanelInstrument *
-createADF (int x, int y)
-{
-  FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W, SIX_W);
-
-                               // Action: increase selected rotation
-  inst->addAction(SIX_W/2 - SIX_W/5, -SIX_W/2, SIX_W/10, SIX_W/5,
-                 new FGAdjustAction(FGBFI::getADFRotation,
-                                    FGBFI::setADFRotation,
-                                    1.0, 0.0, 360.0, true));
-
-                               // Action: decrease selected rotation
-  inst->addAction(SIX_W/2 - SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
-                 new FGAdjustAction(FGBFI::getADFRotation,
-                                    FGBFI::setADFRotation,
-                                    -1.0, 0.0, 360.0, true));
-
-                               // Layer 0: background
-  inst->addLayer(0, createTexture("Textures/Panel/gyro-bg.rgb"));
-  inst->addTransformation(0, FGInstrumentLayer::ROTATION,
-                         FGBFI::getADFRotation,
-                         0.0, 360.0, 1.0, 0.0);
-
-                               // Layer 1: Direction needle.
-  inst->addLayer(1, createTexture("Textures/Panel/long-needle.rgb"));
-  inst->addTransformation(1, FGInstrumentLayer::ROTATION,
-                         FGSteam::get_HackADF_deg,
-                         -720.0, 720.0, 1.0, 0.0);
-
-                               // Layer 2: heading knob
-                               // rotates with selected radial
-  inst->addLayer(2, createTexture("Textures/Panel/heading-knob.rgb"));
-  inst->addTransformation(2, FGInstrumentLayer::XSHIFT, SIX_W/2 - 10); 
-  inst->addTransformation(2, FGInstrumentLayer::YSHIFT, -SIX_W/2 + 10); 
-  inst->addTransformation(2, FGInstrumentLayer::ROTATION,
-                         FGBFI::getADFRotation,
-                         -360.0, 360.0, -1.0, 0.0);
-  return inst;
-}
+#include "panel.hxx"
 
 
 \f
@@ -577,12 +72,15 @@ FGTextureManager::createTexture (const char * relativePath)
 // Implementation of FGPanel.
 ////////////////////////////////////////////////////////////////////////
 
-FGPanel current_panel;
+FGPanel * current_panel = NULL;
 
-FGPanel::FGPanel ()
-  : _initialized(false),
-    _visibility(false)
+FGPanel::FGPanel (int x, int y, int w, int h)
+  : _mouseDown(false),
+    _mouseInstrument(0),
+    _x(x), _y(y), _w(w), _h(h)
 {
+  setVisibility(current_options.get_panel_status());
+  _panel_h = (int)(h * 0.5768 + 1);
 }
 
 FGPanel::~FGPanel ()
@@ -602,63 +100,6 @@ FGPanel::addInstrument (FGPanelInstrument * instrument)
   _instruments.push_back(instrument);
 }
 
-void
-FGPanel::init (int x, int y, int finx, int finy)
-{
-  _x = x;
-  _y = y;
-  _w = finx - x;
-  _h = finy - y;
-  _panel_h = (int)((finy - y) * 0.5768 + 1);
-
-                               // Don't reconstruct all of the
-                               // instruments.
-  if (_initialized)
-    return;
-
-  x = SIX_X;
-  y = SIX_Y;
-
-  _bg = createTexture("Textures/Panel/panel-bg.rgb");
-
-                               // Chronometer alone at side
-  x = SIX_X - SIX_SPACING - 8;
-  addInstrument(createChronometer(x, y));
-
-                               // Top row
-  x = SIX_X;
-  addInstrument(createAirspeedIndicator(x, y));
-  x += SIX_SPACING;
-  addInstrument(createHorizon(x, y));
-  x += SIX_SPACING;
-  addInstrument(createAltimeter(x, y));
-  x += SIX_SPACING + 20;
-  addInstrument(createNAV1(x, y));
-
-                               // Middle row
-  x = SIX_X;
-  y -= SIX_SPACING;
-  addInstrument(createTurnCoordinator(x, y));
-  x += SIX_SPACING;
-  addInstrument(createGyroCompass(x, y));
-  x += SIX_SPACING;
-  addInstrument(createVerticalVelocity(x, y));
-  x += SIX_SPACING + 20;
-  addInstrument(createNAV2(x, y));
-
-                               // Bottom row
-  x = SIX_X;
-  y -= SIX_SPACING + 10;
-  addInstrument(createControls(x, y));
-  x += SIX_SPACING;
-  addInstrument(createFlapIndicator(x, y));
-  x += SIX_SPACING;
-  addInstrument(createRPMGauge(x, y));
-  x += SIX_SPACING + 20;
-  y += 10;
-  addInstrument(createADF(x, y));
-}
-
 void
 FGPanel::update () const
 {
@@ -666,6 +107,16 @@ FGPanel::update () const
   if (!_visibility)
     return;
 
+                               // If the mouse is down, do something
+  if (_mouseDown) {
+    _mouseDelay--;
+    if (_mouseDelay < 0) {
+      _mouseInstrument->doMouseAction(_mouseButton, _mouseX, _mouseY);
+      _mouseDelay = 2;
+    }
+  }
+
+                               // Now, draw the panel
   glMatrixMode(GL_PROJECTION);
   glPushMatrix();
   glLoadIdentity();
@@ -724,12 +175,21 @@ FGPanel::getVisibility () const
   return _visibility;
 }
 
+void
+FGPanel::setBackground (ssgTexture * texture)
+{
+  _bg = texture;
+}
+
 bool
 FGPanel::doMouseAction (int button, int updown, int x, int y)
 {
-                               // For now, ignore the release
-  if (updown == 1) 
+                               // Note a released button and return
+  if (updown == 1) {
+    _mouseDown = false;
+    _mouseInstrument = 0;
     return true;
+  }
 
   x = (int)(((float)x / current_view.get_winWidth()) * _w);
   y = (int)(_h - (((float)y / current_view.get_winHeight()) * _h));
@@ -742,7 +202,15 @@ FGPanel::doMouseAction (int button, int updown, int x, int y)
     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';
-      return inst->doMouseAction(button, updown, x - ix, y - iy);
+      _mouseDown = true;
+      _mouseDelay = 20;
+      _mouseInstrument = inst;
+      _mouseButton = button;
+      _mouseX = x - ix;
+      _mouseY = y - iy;
+                               // Always do the action once.
+      _mouseInstrument->doMouseAction(_mouseButton, _mouseX, _mouseY);
+      return true;
     }
   }
   cout << "Did not click on an instrument\n";
@@ -783,6 +251,52 @@ FGAdjustAction::doAction ()
 }
 
 
+\f
+////////////////////////////////////////////////////////////////////////
+// Implementation of FGSwapAction.
+////////////////////////////////////////////////////////////////////////
+
+FGSwapAction::FGSwapAction (getter_type getter1, setter_type setter1,
+                           getter_type getter2, setter_type setter2)
+  : _getter1(getter1), _setter1(setter1),
+    _getter2(getter2), _setter2(setter2)
+{
+}
+
+FGSwapAction::~FGSwapAction ()
+{
+}
+
+void
+FGSwapAction::doAction ()
+{
+  double value = (*_getter1)();
+  (*_setter1)((*_getter2)());
+  (*_setter2)(value);
+}
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Implementation of FGToggleAction.
+////////////////////////////////////////////////////////////////////////
+
+FGToggleAction::FGToggleAction (getter_type getter, setter_type setter)
+  : _getter(getter), _setter(setter)
+{
+}
+
+FGToggleAction::~FGToggleAction ()
+{
+}
+
+void
+FGToggleAction::doAction ()
+{
+  (*_setter)(!((*_getter)()));
+}
+
+
 \f
 ////////////////////////////////////////////////////////////////////////
 // Implementation of FGPanelInstrument.
@@ -849,10 +363,11 @@ FGPanelInstrument::getHeight () const
 }
 
 void
-FGPanelInstrument::addAction (int x, int y, int w, int h,
+FGPanelInstrument::addAction (int button, int x, int y, int w, int h,
                              FGPanelAction * action)
 {
   FGPanelInstrument::inst_action act;
+  act.button = button;
   act.x = x;
   act.y = y;
   act.w = w;
@@ -863,7 +378,7 @@ FGPanelInstrument::addAction (int x, int y, int w, int h,
 
                                // Coordinates relative to centre.
 bool
-FGPanelInstrument::doMouseAction (int button, int updown, int x, int y)
+FGPanelInstrument::doMouseAction (int button, int x, int y)
 {
   action_list_type::iterator it = _actions.begin();
   action_list_type::iterator last = _actions.end();
@@ -871,7 +386,8 @@ FGPanelInstrument::doMouseAction (int button, int updown, int x, int y)
   for ( ; it != last; it++) {
     cout << "Trying action at " << it->x << ',' << it->y << ','
         << it->w <<',' << it->h << '\n';
-    if (x >= it->x && x < it->x + it->w && y >= it->y && y < it->y + it->h) {
+    if (button == it->button &&
+       x >= it->x && x < it->x + it->w && y >= it->y && y < it->y + it->h) {
       it->action->doAction();
       return true;
     }
@@ -898,46 +414,54 @@ FGLayeredInstrument::~FGLayeredInstrument ()
 void
 FGLayeredInstrument::draw () const
 {
-  layer_list::const_iterator it = _layers.begin();
-  layer_list::const_iterator last = _layers.end();
-  while (it != last) {
-    (*it)->draw();
-    it++;
+  for (int i = 0; i < _layers.size(); i++) {
+    glPushMatrix();
+    glTranslatef(0.0, 0.0, (i / 100.0) + 0.1);
+    _layers[i]->draw();
+    glPopMatrix();
   }
 }
 
-void
+int
 FGLayeredInstrument::addLayer (FGInstrumentLayer *layer)
 {
+  int n = _layers.size();
   _layers.push_back(layer);
+  return n;
 }
 
-void
-FGLayeredInstrument::addLayer (int layer, ssgTexture * texture)
+int
+FGLayeredInstrument::addLayer (ssgTexture * texture)
 {
-  addLayer(new FGTexturedInstrumentLayer(texture, _w, _h, layer));
+  return addLayer(new FGTexturedLayer(texture, _w, _h));
 }
 
 void
-FGLayeredInstrument::addTransformation (int layer,
-                                       FGInstrumentLayer::transform_type type,
+FGLayeredInstrument::addTransformation (FGInstrumentLayer::transform_type type,
                                        FGInstrumentLayer::transform_func func,
                                        double min, double max,
                                        double factor, double offset)
 {
+  int layer = _layers.size() - 1;
   _layers[layer]->addTransformation(type, func, min, max, factor, offset);
 }
 
+void
+FGLayeredInstrument::addTransformation (FGInstrumentLayer::transform_type type,
+                                       double offset)
+{
+  addTransformation(type, 0, 0.0, 0.0, 1.0, offset);
+}
+
 
 \f
 ////////////////////////////////////////////////////////////////////////
 // Implementation of FGInstrumentLayer.
 ////////////////////////////////////////////////////////////////////////
 
-FGInstrumentLayer::FGInstrumentLayer (int w, int h, int z)
+FGInstrumentLayer::FGInstrumentLayer (int w, int h)
   : _w(w),
-    _h(h),
-    _z(z)
+    _h(h)
 {
 }
 
@@ -954,8 +478,6 @@ FGInstrumentLayer::~FGInstrumentLayer ()
 void
 FGInstrumentLayer::transform () const
 {
-  glTranslatef(0.0, 0.0, (_z / 100.0) + 0.1);
-
   transformation_list::const_iterator it = _transformations.begin();
   transformation_list::const_iterator last = _transformations.end();
   while (it != last) {
@@ -1002,93 +524,92 @@ FGInstrumentLayer::addTransformation (transform_type type,
 
 \f
 ////////////////////////////////////////////////////////////////////////
-// Implementation of FGTexturedInstrumentLayer.
+// Implementation of FGTexturedLayer.
 ////////////////////////////////////////////////////////////////////////
 
-// FGTexturedInstrumentLayer::FGTexturedInstrumentLayer (const char *tname,
-//                                                   int w, int h, int z)
-//   : FGInstrumentLayer(w, h, z)
-// {
-//   setTexture(tname);
-// }
-
-FGTexturedInstrumentLayer::FGTexturedInstrumentLayer (ssgTexture * texture,
-                                                     int w, int h, int z)
-  : FGInstrumentLayer(w, h, z)
+FGTexturedLayer::FGTexturedLayer (ssgTexture * texture, int w, int h,
+                                 double texX1 = 0.0, double texY1 = 0.0,
+                                 double texX2 = 1.0, double texY2 = 1.0)
+  : FGInstrumentLayer(w, h),
+    _texX1(texX1), _texY1(texY1), _texX2(texX2), _texY2(texY2)
 {
   setTexture(texture);
 }
 
-FGTexturedInstrumentLayer::~FGTexturedInstrumentLayer ()
+FGTexturedLayer::~FGTexturedLayer ()
 {
 }
 
 void
-FGTexturedInstrumentLayer::draw () const
+FGTexturedLayer::draw () const
 {
   int w2 = _w / 2;
   int h2 = _h / 2;
 
-  glPushMatrix();
   transform();
   glBindTexture(GL_TEXTURE_2D, _texture->getHandle());
   glBegin(GL_POLYGON);
-                               // FIXME: is this really correct
-                               // for layering?
-  glTexCoord2f(0.0, 0.0); glVertex2f(-w2, -h2);
-  glTexCoord2f(1.0, 0.0); glVertex2f(w2, -h2);
-  glTexCoord2f(1.0, 1.0); glVertex2f(w2, h2);
-  glTexCoord2f(0.0, 1.0); glVertex2f(-w2, h2);
+
+  glTexCoord2f(_texX1, _texY1); glVertex2f(-w2, -h2);
+  glTexCoord2f(_texX2, _texY1); glVertex2f(w2, -h2);
+  glTexCoord2f(_texX2, _texY2); glVertex2f(w2, h2);
+  glTexCoord2f(_texX1, _texY2); glVertex2f(-w2, h2);
   glEnd();
-  glPopMatrix();
 }
 
-// void
-// FGTexturedInstrumentLayer::setTexture (const char *textureName)
-// {
-//   FGPath tpath(current_options.get_fg_root());
-//   tpath.append(textureName);
-//   ssgTexture * texture = new ssgTexture((char *)tpath.c_str(), false, false);
-//   setTexture(texture);
-// }
-
 
 \f
 ////////////////////////////////////////////////////////////////////////
-// Implementation of FGCharInstrumentLayer.
+// Implementation of FGTextLayer.
 ////////////////////////////////////////////////////////////////////////
 
-FGCharInstrumentLayer::FGCharInstrumentLayer (text_func func,
-                                             int w, int h, int z)
-  : FGInstrumentLayer(w, h, z),
-    _func(func)
+FGTextLayer::FGTextLayer (int w, int h)
+  : FGInstrumentLayer(w, h)
 {
-  _renderer.setFont(guiFntHandle);
-  _renderer.setPointSize(14);
   _color[0] = _color[1] = _color[2] = 0.0;
   _color[3] = 1.0;
 }
 
-FGCharInstrumentLayer::~FGCharInstrumentLayer ()
+FGTextLayer::~FGTextLayer ()
 {
+  chunk_list::iterator it = _chunks.begin();
+  chunk_list::iterator last = _chunks.end();
+  for ( ; it != last; it++) {
+    delete *it;
+  }
 }
 
 void
-FGCharInstrumentLayer::draw () const
+FGTextLayer::draw () const
 {
   glPushMatrix();
   glColor4fv(_color);
   transform();
+  _renderer.setFont(guiFntHandle);
+  _renderer.setPointSize(14);
   _renderer.begin();
   _renderer.start3f(0, 0, 0);
-  _renderer.puts((*_func)(_buf));
+
+                               // Render each of the chunks.
+  chunk_list::const_iterator it = _chunks.begin();
+  chunk_list::const_iterator last = _chunks.end();
+  for ( ; it != last; it++) {
+    _renderer.puts((*it)->getValue());
+  }
+
   _renderer.end();
   glColor4f(1.0, 1.0, 1.0, 1.0);       // FIXME
   glPopMatrix();
 }
 
 void
-FGCharInstrumentLayer::setColor (float r, float g, float b)
+FGTextLayer::addChunk (FGTextLayer::Chunk * chunk)
+{
+  _chunks.push_back(chunk);
+}
+
+void
+FGTextLayer::setColor (float r, float g, float b)
 {
   _color[0] = r;
   _color[1] = g;
@@ -1097,17 +618,88 @@ FGCharInstrumentLayer::setColor (float r, float g, float b)
 }
 
 void
-FGCharInstrumentLayer::setPointSize (const float size)
+FGTextLayer::setPointSize (const float size)
 {
   _renderer.setPointSize(size);
 }
 
 void
-FGCharInstrumentLayer::setFont(fntFont * font)
+FGTextLayer::setFont(fntFont * font)
 {
   _renderer.setFont(font);
 }
 
 
+\f
+////////////////////////////////////////////////////////////////////////
+// Implementation of FGTextLayer::Chunk.
+////////////////////////////////////////////////////////////////////////
+
+FGTextLayer::Chunk::Chunk (char * text, char * fmt = "%s")
+  : _type(FGTextLayer::TEXT), _fmt(fmt)
+{
+  _value._text = text;
+}
+
+FGTextLayer::Chunk::Chunk (text_func func, char * fmt = "%s")
+  : _type(FGTextLayer::TEXT_FUNC), _fmt(fmt)
+{
+  _value._tfunc = func;
+}
+
+FGTextLayer::Chunk::Chunk (double_func func, char * fmt = "%.2f",
+                          double mult = 1.0)
+  : _type(FGTextLayer::DOUBLE_FUNC), _fmt(fmt), _mult(mult)
+{
+  _value._dfunc = func;
+}
+
+char *
+FGTextLayer::Chunk::getValue () const
+{
+  switch (_type) {
+  case TEXT:
+    sprintf(_buf, _fmt, _value._text);
+    return _buf;
+  case TEXT_FUNC:
+    sprintf(_buf, _fmt, (*(_value._tfunc))());
+    break;
+  case DOUBLE_FUNC:
+    sprintf(_buf, _fmt, (*(_value._dfunc))() * _mult);
+    break;
+  }
+  return _buf;
+}
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Implementation of FGSwitchLayer.
+////////////////////////////////////////////////////////////////////////
+
+FGSwitchLayer::FGSwitchLayer (int w, int h, switch_func func,
+                             FGInstrumentLayer * layer1,
+                             FGInstrumentLayer * layer2)
+  : FGInstrumentLayer(w, h), _func(func), _layer1(layer1), _layer2(layer2)
+{
+}
+
+FGSwitchLayer::~FGSwitchLayer ()
+{
+  delete _layer1;
+  delete _layer2;
+}
+
+void
+FGSwitchLayer::draw () const
+{
+  transform();
+  if ((*_func)()) {
+    _layer1->draw();
+  } else {
+    _layer2->draw();
+  }
+}
+
 \f
 // end of panel.cxx
index 58f02569b00c1f175b0e0ccaab616bfcd930d955..b90b4fa797febc45a0c89d088a4a043cf2de4cea 100644 (file)
@@ -50,6 +50,8 @@ class FGPanelInstrument;
 \f
 ////////////////////////////////////////////////////////////////////////
 // Texture manager (should migrate out into FGFS).
+//
+// This class ensures that no texture is loaded more than once.
 ////////////////////////////////////////////////////////////////////////
 
 class FGTextureManager
@@ -63,28 +65,42 @@ private:
 \f
 ////////////////////////////////////////////////////////////////////////
 // Instrument panel class.
+//
+// The panel is a container that has a background texture and holds
+// zero or more instruments.  The panel will order the instruments to
+// redraw themselves when necessary, and will pass mouse clicks on to
+// the appropriate instruments for processing.
 ////////////////////////////////////////////////////////////////////////
 
 class FGPanel
 {
 public:
 
-  FGPanel ();
+  FGPanel (int x, int y, int w, int h);
   virtual ~FGPanel ();
 
                                // transfer pointer ownership!!!
   virtual void addInstrument (FGPanelInstrument * instrument);
-  virtual void init (int x, int y, int finx, int finy);
+
+                               // Update the panel (every frame).
   virtual void update () const;
-  
+
+                               // Background texture.
+  virtual void setBackground (ssgTexture * texture);
+
+                               // Make the panel visible or invisible.
   virtual bool getVisibility () const;
   virtual void setVisibility (bool visibility);
 
+                               // Handle a mouse click.
   virtual bool doMouseAction (int button, int updown, int x, int y);
 
 private:
-  bool _initialized;
   bool _visibility;
+  bool _mouseDown;
+  int _mouseButton, _mouseX, _mouseY;
+  mutable int _mouseDelay;
+  FGPanelInstrument * _mouseInstrument;
   typedef vector<FGPanelInstrument *> instrument_list_type;
   int _x, _y, _w, _h;
   int _panel_h;
@@ -97,6 +113,10 @@ private:
 \f
 ////////////////////////////////////////////////////////////////////////
 // Base class for user action types.
+//
+// Individual instruments can have actions associated with a mouse
+// click in a rectangular area.  Current concrete classes are
+// FGAdjustAction and FGSwapAction.
 ////////////////////////////////////////////////////////////////////////
 
 class FGPanelAction
@@ -109,6 +129,11 @@ public:
 \f
 ////////////////////////////////////////////////////////////////////////
 // Adjustment action.
+//
+// This is an action to increase or decrease an FGFS value by a certain
+// increment within a certain range.  If the wrap flag is true, the
+// value will wrap around if it goes below min or above max; otherwise,
+// it will simply stop at min or max.
 ////////////////////////////////////////////////////////////////////////
 
 class FGAdjustAction : public FGPanelAction
@@ -121,6 +146,7 @@ public:
                  double min, double max, bool wrap=false);
   virtual ~FGAdjustAction ();
   virtual void doAction ();
+
 private:
   getter_type _getter;
   setter_type _setter;
@@ -133,7 +159,61 @@ private:
 
 \f
 ////////////////////////////////////////////////////////////////////////
-// Instrument base class.
+// Swap action.
+//
+// This is an action to swap two values.  It's currently used in the
+// navigation radios.
+////////////////////////////////////////////////////////////////////////
+
+class FGSwapAction : public FGPanelAction
+{
+public:
+  typedef double (*getter_type)();
+  typedef void (*setter_type)(double);
+
+  FGSwapAction (getter_type getter1, setter_type setter1,
+               getter_type getter2, setter_type setter2);
+  virtual ~FGSwapAction ();
+  virtual void doAction ();
+
+private:
+  getter_type _getter1, _getter2;
+  setter_type _setter1, _setter2;
+};
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Toggle action.
+//
+// This is an action to toggle a boolean value.
+////////////////////////////////////////////////////////////////////////
+
+class FGToggleAction : public FGPanelAction
+{
+public:
+  typedef bool (*getter_type)();
+  typedef void (*setter_type)(bool);
+
+  FGToggleAction (getter_type getter, setter_type setter);
+  virtual ~FGToggleAction ();
+  virtual void doAction ();
+
+private:
+  getter_type _getter;
+  setter_type _setter;
+};
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Abstract base class for a panel instrument.
+//
+// A panel instrument consists of zero or more actions, associated
+// with mouse clicks in rectangular areas.  Currently, the only
+// concrete class derived from this is FGLayeredInstrument, but others
+// may show up in the future (some complex instruments could be 
+// entirely hand-coded, for example).
 ////////////////////////////////////////////////////////////////////////
 
 class FGPanelInstrument
@@ -155,15 +235,16 @@ public:
 
                                // Coordinates relative to centre.
                                // Transfer pointer ownership!!
-  virtual void addAction (int x, int y, int w, int h,
+  virtual void addAction (int button, int x, int y, int w, int h,
                          FGPanelAction * action);
 
                                // Coordinates relative to centre.
-  virtual bool doMouseAction (int button, int updown, int x, int y);
+  virtual bool doMouseAction (int button, int x, int y);
 
 protected:
   int _x, _y, _w, _h;
   typedef struct {
+    int button;
     int x;
     int y;
     int w;
@@ -177,7 +258,12 @@ protected:
 
 \f
 ////////////////////////////////////////////////////////////////////////
-// A single layer of an instrument.
+// Abstract base class for an instrument layer.
+//
+// The FGLayeredInstrument class builds up instruments by using layers
+// of textures or text.  Each layer can have zero or more
+// transformations applied to it: for example, a needle layer can
+// rotate to show the altitude or airspeed.
 ////////////////////////////////////////////////////////////////////////
 
 /**
@@ -200,7 +286,7 @@ public:
 
 
   FGInstrumentLayer ();
-  FGInstrumentLayer (int w, int h, int z);
+  FGInstrumentLayer (int w, int h);
   virtual ~FGInstrumentLayer ();
 
   virtual void draw () const = 0;
@@ -211,7 +297,7 @@ public:
                                  double factor = 1.0, double offset = 0.0);
 
 protected:
-  int _w, _h, _z;
+  int _w, _h;
 
   typedef struct {
     transform_type type;
@@ -228,7 +314,13 @@ protected:
 
 \f
 ////////////////////////////////////////////////////////////////////////
-// An instrument composed of layered textures.
+// An instrument composed of layers.
+//
+// This class represents an instrument which is simply a series of
+// layers piled one on top of the other, each one undergoing its own
+// set of transformations.  For example, one layer can represent
+// the instrument's face (which doesn't move), while the next layer
+// can represent a needle that rotates depending on an FGFS variable.
 ////////////////////////////////////////////////////////////////////////
 
 
@@ -248,18 +340,14 @@ public:
   virtual void draw () const;
 
                                // Transfer pointer ownership!!
-  virtual void addLayer (FGInstrumentLayer *layer);
-  virtual void addLayer (int i, ssgTexture * texture);
-  virtual void addTransformation (int layer,
-                                 FGInstrumentLayer::transform_type type,
+  virtual int addLayer (FGInstrumentLayer *layer);
+  virtual int addLayer (ssgTexture * texture);
+  virtual void addTransformation (FGInstrumentLayer::transform_type type,
                                  FGInstrumentLayer::transform_func func,
                                  double min, double max,
                                  double factor = 1.0, double offset = 0.0);
-  virtual void addTransformation (int layer,
-                                 FGInstrumentLayer::transform_type type,
-                                 double offset) {
-    addTransformation(layer, type, 0, 0.0, 0.0, 1.0, offset);
-  }
+  virtual void addTransformation (FGInstrumentLayer::transform_type type,
+                                 double offset);
 
 protected:
   layer_list _layers;
@@ -269,21 +357,19 @@ protected:
 \f
 ////////////////////////////////////////////////////////////////////////
 // A textured layer of an instrument.
+//
+// This is a layer holding a single texture.  Normally, the texture's
+// backgound should be transparent so that lower layers and the panel
+// background can show through.
 ////////////////////////////////////////////////////////////////////////
 
-/**
- * A textured layer of an instrument.
- *
- * This is a type of layer designed to hold a texture; normally,
- * the texture's background should be transparent so that
- * other layers or the panel background show through.
- */
-class FGTexturedInstrumentLayer : public FGInstrumentLayer
+class FGTexturedLayer : public FGInstrumentLayer
 {
 public:
-  FGTexturedInstrumentLayer (ssgTexture * texture,
-                            int w, int h, int z);
-  virtual ~FGTexturedInstrumentLayer ();
+  FGTexturedLayer (ssgTexture * texture, int w, int h,
+                  double texX1 = 0.0, double texY1 = 0.0,
+                  double texX2 = 1.0, double texY2 = 1.0);
+  virtual ~FGTexturedLayer ();
 
   virtual void draw () const;
 
@@ -291,33 +377,90 @@ public:
 
 private:
   ssgTexture * _texture;
+  double _texX1, _texY1, _texX2, _texY2;
 };
 
 
 \f
 ////////////////////////////////////////////////////////////////////////
 // A text layer of an instrument.
+//
+// This is a layer holding a string of static and/or generated text.
+// It is useful for instruments that have text displays, such as
+// a chronometer, GPS, or NavCom radio.
 ////////////////////////////////////////////////////////////////////////
 
-class FGCharInstrumentLayer : public FGInstrumentLayer
+class FGTextLayer : public FGInstrumentLayer
 {
 public:
-  typedef char * (*text_func)(char *);
-  FGCharInstrumentLayer (text_func func,
-                        int w, int h, int z);
-  virtual ~FGCharInstrumentLayer ();
+  typedef char * (*text_func)();
+  typedef double (*double_func)();
+  typedef enum ChunkType {
+    TEXT,
+    TEXT_FUNC,
+    DOUBLE_FUNC
+  };
+
+  class Chunk {
+  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);
+
+    char * getValue () const;
+  private:
+    ChunkType _type;
+    union {
+      char * _text;
+      text_func _tfunc;
+      double_func _dfunc;
+    } _value;
+    char * _fmt;
+    double _mult;
+    mutable char _buf[1024];
+  };
+
+  FGTextLayer (int w, int h);
+  virtual ~FGTextLayer ();
 
   virtual void draw () const;
+
+                               // Transfer pointer!!
+  virtual void addChunk (Chunk * chunk);
   virtual void setColor (float r, float g, float b);
   virtual void setPointSize (float size);
   virtual void setFont (fntFont * font);
 
 private:
-  text_func _func;
+  typedef vector<Chunk *> chunk_list;
+  chunk_list _chunks;
   float _color[4];
                                // FIXME: need only one globally
   mutable fntRenderer _renderer;
-  mutable char _buf[1024];
+};
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// A layer that switches between two other layers.
+////////////////////////////////////////////////////////////////////////
+
+class FGSwitchLayer : public FGInstrumentLayer
+{
+public:
+  typedef bool (*switch_func)();
+
+                               // Transfer pointers!!
+  FGSwitchLayer (int w, int h, switch_func func,
+                FGInstrumentLayer * layer1,
+                FGInstrumentLayer * layer2);
+  virtual ~FGSwitchLayer ();
+
+  virtual void draw () const;
+
+private:
+  switch_func _func;
+  FGInstrumentLayer * _layer1, * _layer2;
 };
 
 
@@ -326,7 +469,7 @@ private:
 // The current panel, if any.
 ////////////////////////////////////////////////////////////////////////
 
-extern FGPanel current_panel;
+extern FGPanel current_panel;
 
 
 \f
diff --git a/src/Cockpit/proposed-navaids.hpp b/src/Cockpit/proposed-navaids.hpp
deleted file mode 100644 (file)
index df09c2c..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/**************************************************************************
- * navaids.hpp -- navigation defines and prototypes
- *
- * Written by Charles Hotchkiss, started March 1998.
- *
- * Copyright (C) 1998  Charles Hotchkiss chotchkiss@namg.us.anritsu.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., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- **************************************************************************/
-
-
-// Class nav_aid
-//
-//  Includes NDB and IMO Markers, base for all other navigational aids.
-//  The destructor is virtual to permit use of nav_aid pointers to derived
-//  classes, but is instantiable none the less.
-//  Assumes global pointer to current aircraft.
-
-class nav_aid
-  private:
-    LRECT  here_at;   // Codes left = Long,
-                      //        top = Lat,
-                      //      right = Alt,
-                      //     bottom = Range
-    UINT   frequency; // special coding
-    UINT   range;
-    char  *ID;
-    char  *Name;
-
-  public:
-    nav_aid( LRECT loc,
-             UNIT freq, UINT range,
-             const char *eye_dee, const char *MyName );
-
-    virtual ~nav_aid();
-    operator ==
-
-    void update_status( void );  // Called by main loop?
-
-    bool        in_range   ( LRECT loc );
-    const char *pID        ( void );
-    const char *pName      ( void );
-    Cartestian  Location   ( void );
-};
-
-// Class ATIS_stn
-//
-
-class ATIS_stn :: public nav_aid {
-  private:
-    int   runways;
-    int  *pref_rnwys; // prefered runway list;
-    char *format;
-
-  public:
-    bool set_message( const char *pmsg ); // MSFS coded message
-    ~ATIS_stn();
-    ATIS_stn( LRECT here,
-              UINT  radius,
-              char *eye_dee,
-              char *itsname,
-              int  *runways,
-              char *defaultmsg);
-};
-
-// Class DirBeacon
-//
-// Includes VOR Stations. Base for Omni?
-
-class DirBeacon :: public nav_aid{
-  private:
-    UINT        radial;
-
-  public:
-    int         phase_angle( void );
-    int         deflection ( void );
-    double      ground_rate( void );
-};
-
-// Class ils_station
-//
-// Includes ILS
-
-class ils_station :: public DirBeacon{
-  private:
-    long slope_freq;
-    UINT glide_angle;
-    UINT approach_angle;
-
-  public:
-    ULONG deflection( void );
-};
index 298314a2321ee2c7d9bf46f16847e64044d33377..3123cc0207a966fbb0709495dc9abceed7075a4d 100644 (file)
@@ -47,6 +47,8 @@ void FGRadioStack::update( double lon, double lat, double elev ) {
 
     // nav1
     FGILS ils;
+    FGNav nav;
+
     if ( current_ilslist->query( lon, lat, elev, nav1_freq,
                                 &ils, &nav1_heading, &nav1_dist) ) {
        nav1_inrange = true;
@@ -62,13 +64,22 @@ void FGRadioStack::update( double lon, double lat, double elev ) {
        // cout << " id = " << ils.get_locident() << endl;
        // cout << " heading = " << nav1_heading
        //      << " dist = " << nav1_dist << endl;
+    } else if ( current_navlist->query( lon, lat, elev, nav1_freq,
+                                &nav, &nav1_heading, &nav1_dist) ) {
+                               // not ILS
+       nav1_inrange = true;
+       nav1_loc = false;
+       nav1_lon = nav.get_lon();
+       nav1_lat = nav.get_lat();
+       nav1_elev = nav.get_elev();
+       nav1_target_gs = 0.0;
+       nav1_radial = nav1_sel_radial;
     } else {
        nav1_inrange = false;
        // cout << "not picking up vor. :-(" << endl;
     }
 
     // nav2
-    FGNav nav;
     if ( current_navlist->query( lon, lat, elev, nav2_freq,
                                 &nav, &nav2_heading, &nav2_dist) ) {
        nav2_inrange = true;
@@ -76,13 +87,7 @@ void FGRadioStack::update( double lon, double lat, double elev ) {
        nav2_lon = nav.get_lon();
        nav2_lat = nav.get_lat();
        nav2_elev = nav.get_elev();
-       nav2_radial = nav2_heading + 180.0;
-       while ( nav2_radial <   0.0 ) { nav2_radial += 360.0; }
-       while ( nav2_radial > 360.0 ) { nav2_radial -= 360.0; }
-       // cout << "Found a vor station in range" << endl;
-       // cout << " id = " << nav.get_ident() << endl;
-       // cout << " heading = " << nav2_heading
-       //      << " dist = " << nav2_dist << endl;
+       nav2_radial = nav2_sel_radial;
     } else {
        nav2_inrange = false;
        // cout << "not picking up vor. :-(" << endl;
index 1bcda8a09dafde486963803d301d09ea25f24cb3..41129d08fef03672902df60f2f090c06cb683bfa 100644 (file)
@@ -37,6 +37,7 @@ class FGRadioStack {
     double nav1_freq;
     double nav1_alt_freq;
     double nav1_radial;
+    double nav1_sel_radial;
     double nav1_lon;
     double nav1_lat;
     double nav1_elev;
@@ -49,6 +50,7 @@ class FGRadioStack {
     double nav2_freq;
     double nav2_alt_freq;
     double nav2_radial;
+    double nav2_sel_radial;
     double nav2_lon;
     double nav2_lat;
     double nav2_elev;
@@ -78,8 +80,8 @@ public:
        nav1_freq = freq; need_update = true;
     }
     inline void set_nav1_alt_freq( double freq ) { nav1_alt_freq = freq; }
-    inline void set_nav1_radial( double radial ) {
-       nav1_radial = radial; need_update = true;
+    inline void set_nav1_sel_radial( double radial ) {
+       nav1_sel_radial = radial; need_update = true;
     }
 
     // NAV2 Setters
@@ -87,8 +89,8 @@ public:
        nav2_freq = freq; need_update = true;
     }
     inline void set_nav2_alt_freq( double freq ) { nav2_alt_freq = freq; }
-    inline void set_nav2_radial( double radial ) {
-       nav2_radial = radial; need_update = true;
+    inline void set_nav2_sel_radial( double radial ) {
+       nav2_sel_radial = radial; need_update = true;
     }
 
     // ADF Setters
@@ -100,19 +102,19 @@ public:
 
 
     // NAV1 Accessors
-    inline double get_nav1_freq () { return nav1_freq; }
-    inline double get_nav1_alt_freq () { return nav1_alt_freq; }
-    inline double get_nav1_radial() const { return nav1_radial; }
+    inline double get_nav1_freq () const { return nav1_freq; }
+    inline double get_nav1_alt_freq () const { return nav1_alt_freq; }
+    inline double get_nav1_sel_radial() const { return nav1_sel_radial; }
 
     // NAV2 Accessors
-    inline double get_nav2_freq () { return nav2_freq; }
-    inline double get_nav2_alt_freq () { return nav2_alt_freq; }
-    inline double get_nav2_radial() const { return nav2_radial; }
+    inline double get_nav2_freq () const { return nav2_freq; }
+    inline double get_nav2_alt_freq () const { return nav2_alt_freq; }
+    inline double get_nav2_sel_radial() const { return nav2_sel_radial; }
 
     // ADF Accessors
-    inline double get_adf_freq () { return adf_freq; }
-    inline double get_adf_alt_freq () { return adf_alt_freq; }
-    inline double get_adf_rotation () { return adf_rotation; }
+    inline double get_adf_freq () const { return adf_freq; }
+    inline double get_adf_alt_freq () const { return adf_alt_freq; }
+    inline double get_adf_rotation () const { return adf_rotation; }
 
     // Calculated values.
     inline bool get_nav1_inrange() const { return nav1_inrange; }
@@ -122,6 +124,7 @@ public:
     inline double get_nav1_elev() const { return nav1_elev; }
     inline double get_nav1_dist() const { return nav1_dist; }
     inline double get_nav1_heading() const { return nav1_heading; }
+    inline double get_nav1_radial() const { return nav1_radial; }
     inline double get_nav1_target_gs() const { return nav1_target_gs; }
 
     inline bool get_nav2_inrange() const { return nav2_inrange; }
@@ -131,6 +134,7 @@ public:
     inline double get_nav2_elev() const { return nav2_elev; }
     inline double get_nav2_dist() const { return nav2_dist; }
     inline double get_nav2_heading() const { return nav2_heading; }
+    inline double get_nav2_radial() const { return nav2_radial; }
     inline double get_nav2_target_gs() const { return nav2_target_gs; }
 
     inline bool get_adf_inrange() const { return adf_inrange; }
diff --git a/src/Cockpit/sp_panel.cxx b/src/Cockpit/sp_panel.cxx
new file mode 100644 (file)
index 0000000..1d59fd3
--- /dev/null
@@ -0,0 +1,896 @@
+//  sp_panel.cxx - default, 2D single-engine prop instrument panel
+//
+//  Written by David Megginson, started January 2000.
+//
+//  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., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+//  $Id$
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#ifdef HAVE_WINDOWS_H          
+#  include <windows.h>
+#endif
+
+#include <simgear/debug/logstream.hxx>
+#include <Main/bfi.hxx>
+#include <Time/fg_time.hxx>
+
+#include "panel.hxx"
+#include "steam.hxx"
+
+                               // Macros for instrument sizes
+                               // (these aren't used consistently
+                               // anyway, and should probably be
+                               // removed).
+#define SIX_X 200
+#define SIX_Y 345
+#define SIX_W 128
+#define SIX_SPACING (SIX_W + 5)
+#define SMALL_W 112
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Static functions for obtaining settings.
+////////////////////////////////////////////////////////////////////////
+
+static char * panelGetTime ()
+{
+  static char buf[1024];       // FIXME: not thread-safe
+  struct tm * t = FGTime::cur_time_params->getGmt();
+  sprintf(buf, " %.2d:%.2d:%.2d",
+         t->tm_hour, t->tm_min, t->tm_sec);
+  return buf;
+}
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Static factory functions to create textured gauges.
+//
+// These will be replaced first with a giant table, and then with
+// configuration files read from an external source, but for now
+// they're hard-coded.
+////////////////////////////////////////////////////////////////////////
+
+
+#define createTexture(a) FGTextureManager::createTexture(a)
+
+/**
+ * Construct an airspeed indicator for a single-engine prop.
+ */
+static FGPanelInstrument *
+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"));
+
+                               // Layer 1: needle.
+                               // Rotates with airspeed.
+  inst->addLayer(createTexture("Textures/Panel/long-needle.rgb"));
+  inst->addTransformation(FGInstrumentLayer::ROTATION,
+                         FGSteam::get_ASI_kias,
+                         30.0, 220.0, 36.0 / 20.0, -54.0);
+  return inst;
+}
+
+
+/**
+ * Construct an artificial horizon.
+ */
+static FGPanelInstrument *
+createHorizon (int x, int y)
+{
+  FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W, SIX_W);
+
+                               // Layer 0: coloured background
+                               // moves with roll only
+  inst->addLayer(createTexture("Textures/Panel/horizon-bg.rgb"));
+  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->addTransformation(FGInstrumentLayer::ROTATION,
+                         FGBFI::getRoll,
+                         -360.0, 360.0, -1.0, 0.0);
+  inst->addTransformation(FGInstrumentLayer::YSHIFT,
+                         FGBFI::getPitch,
+                         -20.0, 20.0, -(1.5 / 160.0) * SIX_W, 0.0);
+
+                               // Layer 2: rim
+                               // moves with roll only
+  inst->addLayer(createTexture("Textures/Panel/horizon-rim.rgb"));
+  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"));
+
+  return inst;
+}
+
+
+/**
+ * Construct an altimeter.
+ */
+static FGPanelInstrument *
+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"));
+
+                               // Layer 1: hundreds needle (long)
+                               // moves with altitude
+  inst->addLayer(createTexture("Textures/Panel/long-needle.rgb"));
+  inst->addTransformation(FGInstrumentLayer::ROTATION,
+                         FGSteam::get_ALT_ft,
+                         0.0, 100000.0, 360.0 / 1000.0, 0.0);
+
+                               // Layer 2: thousands needle (short)
+                               // moves with altitude
+  inst->addLayer(createTexture("Textures/Panel/short-needle.rgb"));
+  inst->addTransformation(FGInstrumentLayer::ROTATION,
+                         FGSteam::get_ALT_ft,
+                         0.0, 100000.0, 360.0 / 10000.0, 0.0);
+
+                               // Layer 3: ten thousands bug (outside)
+                               // moves with altitude
+  inst->addLayer(createTexture("Textures/Panel/bug.rgb"));
+  inst->addTransformation(FGInstrumentLayer::ROTATION,
+                         FGSteam::get_ALT_ft,
+                         0.0, 100000.0, 360.0 / 100000.0, 0.0);
+
+  return inst;
+}
+
+
+/**
+ * Construct a turn coordinator.
+ */
+static FGPanelInstrument *
+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"));
+
+                               // Layer 1: little plane
+                               // moves with roll
+  inst->addLayer(createTexture("Textures/Panel/turn.rgb"));
+  inst->addTransformation(FGInstrumentLayer::ROTATION,
+                         FGSteam::get_TC_radps,
+                         -30.0, 30.0, 1.0, 0.0);
+
+                               // Layer 2: little ball
+                               // moves with slip/skid
+  inst->addLayer(createTexture("Textures/Panel/ball.rgb"));
+  inst->addTransformation(FGInstrumentLayer::ROTATION,
+                         FGSteam::get_TC_rad,
+                         -0.1, 0.1, -450.0, 0.0);
+
+  return inst;
+}
+
+
+/**
+ * Construct a gyro compass.
+ */
+static FGPanelInstrument *
+createGyroCompass (int x, int y)
+{
+  FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W, SIX_W);
+
+                               // Action: move heading bug
+  inst->addAction(0, SIX_W/2 - SIX_W/5, -SIX_W/2, SIX_W/10, SIX_W/5,
+                 new FGAdjustAction(FGBFI::getAPHeading,
+                                    FGBFI::setAPHeading,
+                                    -1.0, -360.0, 360.0, true));
+  inst->addAction(0, SIX_W/2 - SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
+                 new FGAdjustAction(FGBFI::getAPHeading,
+                                    FGBFI::setAPHeading,
+                                    1.0, -360.0, 360.0, true));
+  inst->addAction(1, SIX_W/2 - SIX_W/5, -SIX_W/2, SIX_W/10, SIX_W/5,
+                 new FGAdjustAction(FGBFI::getAPHeading,
+                                    FGBFI::setAPHeading,
+                                    -5.0, -360.0, 360.0, true));
+  inst->addAction(1, SIX_W/2 - SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
+                 new FGAdjustAction(FGBFI::getAPHeading,
+                                    FGBFI::setAPHeading,
+                                    5.0, -360.0, 360.0, true));
+
+                               // Layer 0: compass background
+                               // rotates with heading
+  inst->addLayer(createTexture("Textures/Panel/gyro-bg.rgb"));
+  inst->addTransformation(FGInstrumentLayer::ROTATION,
+                         FGBFI::getHeading,
+                         -360.0, 360.0, -1.0, 0.0);
+
+                               // Layer 1: heading bug
+                               // rotates with heading and AP heading
+  inst->addLayer(createTexture("Textures/Panel/bug.rgb"));
+  inst->addTransformation(FGInstrumentLayer::ROTATION,
+                         FGBFI::getHeading,
+                         -360.0, 360.0, -1.0, 0.0);
+  inst->addTransformation(FGInstrumentLayer::ROTATION,
+                         FGBFI::getAPHeading,
+                         -360.0, 360.0, 1.0, 0.0);
+
+                               // Layer 2: fixed center
+  inst->addLayer(createTexture("Textures/Panel/gyro-fg.rgb"));
+
+                               // 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->addTransformation(FGInstrumentLayer::XSHIFT, SIX_W/2 - 10); 
+  inst->addTransformation(FGInstrumentLayer::YSHIFT, -SIX_W/2 + 10); 
+  inst->addTransformation(FGInstrumentLayer::ROTATION,
+                         FGBFI::getAPHeading,
+                         -360.0, 360.0, 1.0, 0.0);
+
+  return inst;
+}
+
+
+/**
+ * Construct a vertical velocity indicator.
+ */
+static FGPanelInstrument *
+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"));
+
+                               // Layer 1: needle
+                               // moves with vertical velocity
+  inst->addLayer(createTexture("Textures/Panel/long-needle.rgb"));
+  inst->addTransformation(FGInstrumentLayer::ROTATION,
+                         FGSteam::get_VSI_fps,
+                         -2000.0, 2000.0, 42.0/500.0, 270.0);
+
+  return inst;
+}
+
+
+/**
+ * Construct an RPM gauge.
+ */
+static FGPanelInstrument *
+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"));
+
+                               // Layer 1: long needle
+                               // FIXME: moves with throttle (for now)
+  inst->addLayer(createTexture("Textures/Panel/long-needle.rgb"));
+  inst->addTransformation(FGInstrumentLayer::ROTATION,
+                         FGBFI::getThrottle,
+                         0.0, 100.0, 300.0, -150.0);
+
+  return inst;
+}
+
+
+/**
+ * Construct a flap position indicator.
+ */
+static FGPanelInstrument *
+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"));
+
+                               // Layer 1: long needle
+                               // shifted over, rotates with flap position
+  inst->addLayer(createTexture("Textures/Panel/long-needle.rgb"));
+  inst->addTransformation(FGInstrumentLayer::XSHIFT,
+                         -(SMALL_W / 4) + (SMALL_W / 16));
+  inst->addTransformation(FGInstrumentLayer::ROTATION,
+                         FGBFI::getFlaps,
+                         0.0, 1.0, 120.0, 30.0);
+
+  return inst;
+}
+
+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"));
+
+                               // Layer 1: text
+                               // displays current GMT
+  FGTextLayer * text = new FGTextLayer(SMALL_W, SMALL_W);
+  text->addChunk(new FGTextLayer::Chunk(panelGetTime));
+  text->setPointSize(14);
+  text->setColor(0.2, 0.2, 0.2);
+  inst->addLayer(text);
+  inst->addTransformation(FGInstrumentLayer::XSHIFT, SMALL_W * -0.38);
+  inst->addTransformation(FGInstrumentLayer::YSHIFT, SMALL_W * -0.06);
+
+  return inst;
+}
+
+
+/**
+ * Construct control-position indicators.
+ */
+static FGPanelInstrument *
+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"));
+
+                               // Layer 1: bug
+                               // moves left-right with aileron
+  inst->addLayer(createTexture("Textures/Panel/bug.rgb"));
+  inst->addTransformation(FGInstrumentLayer::XSHIFT, FGBFI::getAileron,
+                         -1.0, 1.0, SMALL_W * .75 / 2.0, 0.0);
+
+                               // Layer 2: bug
+                               // moves left-right with rudder
+  inst->addLayer(createTexture("Textures/Panel/bug.rgb"));
+  inst->addTransformation(FGInstrumentLayer::ROTATION, 180.0);
+  inst->addTransformation(FGInstrumentLayer::XSHIFT, FGBFI::getRudder,
+                         -1.0, 1.0, -SMALL_W * .75 / 2.0, 0.0);
+
+                               // Layer 3: bug
+                               // moves up-down with elevator trim
+  inst->addLayer(createTexture("Textures/Panel/bug.rgb"));
+  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);
+
+                               // Layer 4: bug
+                               // moves up-down with elevator
+  inst->addLayer(createTexture("Textures/Panel/bug.rgb"));
+  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);
+
+  return inst;
+}
+
+
+/**
+ * Construct a NAV1 gauge (hardwired).
+ */
+static FGPanelInstrument *
+createNAV1 (int x, int y)
+{
+  FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W, SIX_W);
+
+                               // Action: change selected radial.
+  inst->addAction(0, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5,
+                 new FGAdjustAction(FGBFI::getNAV1SelRadial,
+                                    FGBFI::setNAV1SelRadial,
+                                    1.0, 0.0, 360.0, true));
+  inst->addAction(0, -SIX_W/2 + SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
+                 new FGAdjustAction(FGBFI::getNAV1SelRadial,
+                                    FGBFI::setNAV1SelRadial,
+                                    -1.0, 0.0, 360.0, true));
+  inst->addAction(1, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5,
+                 new FGAdjustAction(FGBFI::getNAV1SelRadial,
+                                    FGBFI::setNAV1SelRadial,
+                                    5.0, 0.0, 360.0, true));
+  inst->addAction(1, -SIX_W/2 + SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
+                 new FGAdjustAction(FGBFI::getNAV1SelRadial,
+                                    FGBFI::setNAV1SelRadial,
+                                    -5.0, 0.0, 360.0, true));
+
+                               // Layer 0: background
+  inst->addLayer(createTexture("Textures/Panel/gyro-bg.rgb"));
+  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"));
+  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"));
+  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;
+}
+
+
+/**
+ * Construct a NAV2 gauge.
+ */
+static FGPanelInstrument *
+createNAV2 (int x, int y)
+{
+  FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W, SIX_W);
+
+                               // Action: change selected radial.
+  inst->addAction(0, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5,
+                 new FGAdjustAction(FGBFI::getNAV2SelRadial,
+                                    FGBFI::setNAV2SelRadial,
+                                    1.0, 0.0, 360.0, true));
+  inst->addAction(0, -SIX_W/2 + SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
+                 new FGAdjustAction(FGBFI::getNAV2SelRadial,
+                                    FGBFI::setNAV2SelRadial,
+                                    -1.0, 0.0, 360.0, true));
+  inst->addAction(1, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5,
+                 new FGAdjustAction(FGBFI::getNAV2SelRadial,
+                                    FGBFI::setNAV2SelRadial,
+                                    5.0, 0.0, 360.0, true));
+  inst->addAction(1, -SIX_W/2 + SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
+                 new FGAdjustAction(FGBFI::getNAV2SelRadial,
+                                    FGBFI::setNAV2SelRadial,
+                                    -5.0, 0.0, 360.0, true));
+
+                               // Layer 0: background
+  inst->addLayer(createTexture("Textures/Panel/gyro-bg.rgb"));
+  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 2: face with markings.
+  inst->addLayer(createTexture("Textures/Panel/nav-face.rgb"));
+
+                               // Layer 3: 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::getNAV2SelRadial,
+                         -360.0, 360.0, 1.0, 0.0);
+
+  return inst;
+}
+
+
+/**
+ * Construct an ADF gauge.
+ */
+static FGPanelInstrument *
+createADF (int x, int y)
+{
+  FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W, SIX_W);
+
+                               // Action: change selected rotation.
+  inst->addAction(0, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5,
+                 new FGAdjustAction(FGBFI::getADFRotation,
+                                    FGBFI::setADFRotation,
+                                    -1.0, 0.0, 360.0, true));
+  inst->addAction(0, -SIX_W/2 + SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
+                 new FGAdjustAction(FGBFI::getADFRotation,
+                                    FGBFI::setADFRotation,
+                                    1.0, 0.0, 360.0, true));
+  inst->addAction(1, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5,
+                 new FGAdjustAction(FGBFI::getADFRotation,
+                                    FGBFI::setADFRotation,
+                                    -5.0, 0.0, 360.0, true));
+  inst->addAction(1, -SIX_W/2 + SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
+                 new FGAdjustAction(FGBFI::getADFRotation,
+                                    FGBFI::setADFRotation,
+                                    5.0, 0.0, 360.0, true));
+
+                               // Layer 0: background
+  inst->addLayer(createTexture("Textures/Panel/gyro-bg.rgb"));
+  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->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->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);
+  return inst;
+}
+
+
+/**
+ * Create Nav-Com radio 1.
+ */
+static FGPanelInstrument *
+createNavCom1 (int x, int y)
+{
+  FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W*2, SIX_W/2);
+
+                               // 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,
+                 new FGSwapAction(FGBFI::getNAV1Freq,
+                                  FGBFI::setNAV1Freq,
+                                  FGBFI::getNAV1AltFreq,
+                                  FGBFI::setNAV1AltFreq));
+
+                               // Use the knob to tune the standby NAV
+  inst->addAction(0, SIX_W-SIX_W/4, -SIX_W/4, SIX_W/8, SIX_W/4,
+                 new FGAdjustAction(FGBFI::getNAV1AltFreq,
+                                    FGBFI::setNAV1AltFreq,
+                                    -0.05, 108.0, 117.95, true));
+  inst->addAction(0, SIX_W-SIX_W/8, -SIX_W/4, SIX_W/8, SIX_W/4,
+                 new FGAdjustAction(FGBFI::getNAV1AltFreq,
+                                    FGBFI::setNAV1AltFreq,
+                                    0.05, 108.0, 117.95, true));
+  inst->addAction(1, SIX_W-SIX_W/4, -SIX_W/4, SIX_W/8, SIX_W/4,
+                 new FGAdjustAction(FGBFI::getNAV1AltFreq,
+                                    FGBFI::setNAV1AltFreq,
+                                    -0.5, 108.0, 117.95, true));
+  inst->addAction(1, SIX_W-SIX_W/8, -SIX_W/4, SIX_W/8, SIX_W/4,
+                 new FGAdjustAction(FGBFI::getNAV1AltFreq,
+                                    FGBFI::setNAV1AltFreq,
+                                    0.5, 108.0, 117.95, true));
+
+                               // Layer 0: background
+  FGTexturedLayer * layer =
+    new FGTexturedLayer(createTexture("Textures/Panel/radios.rgb"),
+                       SIX_W*2, SIX_W/2, 0.0, 0.75, 1.0, 1.0);
+  inst->addLayer(layer);
+
+                               // Layer 1: NAV frequencies
+  FGTextLayer * text = new FGTextLayer(SIX_W*2, SMALL_W/2);
+  text->addChunk(new FGTextLayer::Chunk(FGBFI::getNAV1Freq, "%.2f"));
+  text->addChunk(new FGTextLayer::Chunk(FGBFI::getNAV1AltFreq, "%7.2f"));
+  text->setPointSize(14);
+  text->setColor(1.0, 0.5, 0.0);
+  inst->addLayer(text);
+  inst->addTransformation(FGInstrumentLayer::XSHIFT, 3);
+  inst->addTransformation(FGInstrumentLayer::YSHIFT, 5);
+
+  return inst;
+}
+
+
+/**
+ * Create Nav-Com radio 2.
+ */
+static FGPanelInstrument *
+createNavCom2 (int x, int y)
+{
+  FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W*2, SIX_W/2);
+
+                               // 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,
+                 new FGSwapAction(FGBFI::getNAV2Freq,
+                                  FGBFI::setNAV2Freq,
+                                  FGBFI::getNAV2AltFreq,
+                                  FGBFI::setNAV2AltFreq));
+
+                               // Use the knob to tune the standby NAV
+  inst->addAction(0, SIX_W-SIX_W/4, -SIX_W/4, SIX_W/8, SIX_W/4,
+                 new FGAdjustAction(FGBFI::getNAV2AltFreq,
+                                    FGBFI::setNAV2AltFreq,
+                                    -0.05, 108.0, 117.95, true));
+  inst->addAction(0, SIX_W-SIX_W/8, -SIX_W/4, SIX_W/8, SIX_W/4,
+                 new FGAdjustAction(FGBFI::getNAV2AltFreq,
+                                    FGBFI::setNAV2AltFreq,
+                                    0.05, 108.0, 117.95, true));
+  inst->addAction(1, SIX_W-SIX_W/4, -SIX_W/4, SIX_W/8, SIX_W/4,
+                 new FGAdjustAction(FGBFI::getNAV2AltFreq,
+                                    FGBFI::setNAV2AltFreq,
+                                    -0.5, 108.0, 117.95, true));
+  inst->addAction(1, SIX_W-SIX_W/8, -SIX_W/4, SIX_W/8, SIX_W/4,
+                 new FGAdjustAction(FGBFI::getNAV2AltFreq,
+                                    FGBFI::setNAV2AltFreq,
+                                    0.5, 108.0, 117.95, true));
+
+                               // Layer 0: background
+  FGTexturedLayer * layer =
+    new FGTexturedLayer(createTexture("Textures/Panel/radios.rgb"),
+                       SIX_W*2, SIX_W/2, 0.0, 0.75, 1.0, 1.0);
+  inst->addLayer(layer);
+
+                               // Layer 1: NAV frequencies
+  FGTextLayer * text = new FGTextLayer(SIX_W*2, SIX_W/2);
+  text->addChunk(new FGTextLayer::Chunk(FGBFI::getNAV2Freq, "%.2f"));
+  text->addChunk(new FGTextLayer::Chunk(FGBFI::getNAV2AltFreq, "%7.2f"));
+  text->setPointSize(14);
+  text->setColor(1.0, 0.5, 0.0);
+  inst->addLayer(text);
+  inst->addTransformation(FGInstrumentLayer::XSHIFT, 3);
+  inst->addTransformation(FGInstrumentLayer::YSHIFT, 5);
+
+  return inst;
+}
+
+
+/**
+ * Create ADF radio.
+ */
+static FGPanelInstrument *
+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,
+                 new FGAdjustAction(FGBFI::getADFFreq,
+                                    FGBFI::setADFFreq,
+                                    -0.05, 111.0, 999.95, true));
+  inst->addAction(0, SIX_W * 0.79, -SIX_W * 0.07, SIX_W * 0.09, SIX_W * 0.14,
+                 new FGAdjustAction(FGBFI::getADFFreq,
+                                    FGBFI::setADFFreq,
+                                    0.05, 111.0, 999.95, true));
+  inst->addAction(1, SIX_W * 0.7, -SIX_W * 0.07, SIX_W * 0.09, SIX_W * 0.14,
+                 new FGAdjustAction(FGBFI::getADFFreq,
+                                    FGBFI::setADFFreq,
+                                    -5.0, 111.0, 999.95, true));
+  inst->addAction(1, SIX_W * 0.79, -SIX_W * 0.07, SIX_W * 0.09, SIX_W * 0.14,
+                 new FGAdjustAction(FGBFI::getADFFreq,
+                                    FGBFI::setADFFreq,
+                                    5.0, 111.0, 999.95, true));
+
+                               // Layer 0: background
+  FGTexturedLayer * layer =
+    new FGTexturedLayer(createTexture("Textures/Panel/radios.rgb"),
+                       SIX_W*2, SIX_W/2, 0.0, 0.5, 1.0, 0.75);
+  inst->addLayer(layer);
+
+                               // Layer: ADF frequency
+  FGTextLayer * text = new FGTextLayer(SIX_W*2, SIX_W/2);
+  text->addChunk(new FGTextLayer::Chunk(FGBFI::getADFFreq, "%.2f"));
+  text->setPointSize(14);
+  text->setColor(1.0, 0.5, 0.0);
+  inst->addLayer(text);
+  inst->addTransformation(FGInstrumentLayer::XSHIFT, -SIX_W + 12);
+
+  return inst;
+}
+
+
+/**
+ * Construct the autopilot.
+ */
+
+FGPanelInstrument *
+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,
+                 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,
+                 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,
+                 new FGToggleAction(FGBFI::getAPAltitudeLock,
+                                    FGBFI::setAPAltitudeLock));
+
+                               // Layer: AP background
+  FGTexturedLayer * layer;
+  layer = new FGTexturedLayer(createTexture("Textures/Panel/radios.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"),
+                       SIX_W/4, SIX_W/8,
+                       7.0/16.0, 27.0/32.0, 9.0/16.0, 15.0/16.0);
+  FGTexturedLayer *l2 =
+    new FGTexturedLayer(createTexture("Textures/Panel/knobs.rgb"),
+                       SIX_W/4, SIX_W/8,
+                       1.0/4.0, 27.0/32.0, 3.0/8.0, 15.0/16.0);
+  FGSwitchLayer * sw =
+    new FGSwitchLayer(SIX_W/4, SIX_W/8, FGBFI::getAPHeadingLock, l1, l2);
+  inst->addLayer(sw);
+  inst->addTransformation(FGInstrumentLayer::XSHIFT, -SIX_W * 0.5);
+
+                               // Display NAV button
+  l1 =
+    new FGTexturedLayer(createTexture("Textures/Panel/knobs.rgb"),
+                       SIX_W/4, SIX_W/8,
+                       7.0/16.0, 3.0/4.0, 9.0/16.0, 27.0/32.0);
+  l2 =
+    new FGTexturedLayer(createTexture("Textures/Panel/knobs.rgb"),
+                       SIX_W/4, SIX_W/8,
+                       1.0/4.0, 3.0/4.0, 3.0/8.0, 27.0/32.0);
+  sw =
+    new FGSwitchLayer(SIX_W/4, SIX_W/8, FGBFI::getAPNAV1Lock, l1, l2);
+  inst->addLayer(sw);
+  inst->addTransformation(FGInstrumentLayer::XSHIFT, -SIX_W * 0.25);
+
+                               // Display ALT button
+  l1 =
+    new FGTexturedLayer(createTexture("Textures/Panel/knobs.rgb"),
+                       SIX_W/4, SIX_W/8,
+                       7.0/16.0, 9.0/16.0, 9.0/16.0, 21.0/32.0);
+  l2 =
+    new FGTexturedLayer(createTexture("Textures/Panel/knobs.rgb"),
+                       SIX_W/4, SIX_W/8,
+                       1.0/4.0, 9.0/16.0, 3.0/8.0, 21.0/32.0);
+  sw =
+    new FGSwitchLayer(SIX_W/4, SIX_W/8, FGBFI::getAPAltitudeLock, l1, l2);
+  inst->addLayer(sw);
+
+  return inst;
+}
+
+FGPanelInstrument * 
+createDME (int x, int y)
+{
+  FGLayeredInstrument * inst = new FGLayeredInstrument(x, y,
+                                                      SIX_W * 0.75,
+                                                      SIX_W * 0.25);
+
+                               // Layer: background
+  FGTexturedLayer * layer =
+    new FGTexturedLayer(createTexture("Textures/Panel/radios.rgb"),
+                       SIX_W * 0.75, 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::getNAV1Dist, "%05.1f",
+                                       METER_TO_NM));
+  text->setPointSize(14);
+  text->setColor(1.0, 0.5, 0.0);
+  inst->addLayer(text);
+  inst->addTransformation(FGInstrumentLayer::XSHIFT, -20);
+  inst->addTransformation(FGInstrumentLayer::YSHIFT, -6);
+
+  return inst;
+}
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Construct a panel for a small, single-prop plane.
+////////////////////////////////////////////////////////////////////////
+
+FGPanel *
+fgCreateSmallSinglePropPanel (int x, int y, int finx, int finy)
+{
+  FGPanel * panel = new FGPanel(x, y, finx - x, finy - y);
+
+  x = SIX_X;
+  y = SIX_Y;
+
+                               // Set the background texture
+  panel->setBackground(createTexture("Textures/Panel/panel-bg.rgb"));
+
+                               // Chronometer alone at side
+  x = SIX_X - SIX_SPACING - 8;
+  panel->addInstrument(createChronometer(x, y));
+
+                               // Top row
+  x = SIX_X;
+  panel->addInstrument(createAirspeedIndicator(x, y));
+  x += SIX_SPACING;
+  panel->addInstrument(createHorizon(x, y));
+  x += SIX_SPACING;
+  panel->addInstrument(createAltimeter(x, y));
+  x += SIX_SPACING + 20;
+  panel->addInstrument(createNAV1(x, y));
+
+                               // Middle row
+  x = SIX_X;
+  y -= SIX_SPACING;
+  panel->addInstrument(createTurnCoordinator(x, y));
+  x += SIX_SPACING;
+  panel->addInstrument(createGyroCompass(x, y));
+  x += SIX_SPACING;
+  panel->addInstrument(createVerticalVelocity(x, y));
+  x += SIX_SPACING + 20;
+  panel->addInstrument(createNAV2(x, y));
+
+                               // Bottom row
+  x = SIX_X;
+  y -= SIX_SPACING + 10;
+  panel->addInstrument(createControls(x, y));
+  x += SIX_SPACING;
+  panel->addInstrument(createFlapIndicator(x, y));
+  x += SIX_SPACING;
+  panel->addInstrument(createRPMGauge(x, y));
+  x += SIX_SPACING + 20;
+  y += 10;
+  panel->addInstrument(createADF(x, y));
+
+                               // Radio stack
+  x = SIX_X + (SIX_SPACING * 5);
+  y = SIX_Y;
+  panel->addInstrument(createDME(x, y));
+  y -= (int)(SIX_W * 0.375);
+  panel->addInstrument(createNavCom1(x, y));
+  y -= SIX_W / 2;
+  panel->addInstrument(createNavCom2(x, y));
+  y -= SIX_W / 2;
+  panel->addInstrument(createADFRadio(x, y));
+  y -= (int)(SIX_W * 0.375);
+  panel->addInstrument(createAP(x, y));
+
+  return panel;
+}
+
+// end of sp_panel.cxx
diff --git a/src/Cockpit/sp_panel.hxx b/src/Cockpit/sp_panel.hxx
new file mode 100644 (file)
index 0000000..3353634
--- /dev/null
@@ -0,0 +1,35 @@
+//  sp_panel.hxx - default, 2D single-engine prop instrument panel
+//
+//  Written by David Megginson, started January 2000.
+//
+//  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., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+//  $Id$
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#ifdef HAVE_WINDOWS_H          
+#  include <windows.h>
+#endif
+
+#include "panel.hxx"
+
+extern FGPanel * fgCreateSmallSinglePropPanel (int x, int y,
+                                              int finx, int finy);
+
+// end of sp_panel.hxx
+
index 57267e996cda7d881f80550ed905bec430e0e244..9ed946f56d16a7e6b0d9a5cf0c2a9eeaf8328313 100644 (file)
@@ -229,7 +229,9 @@ double FGSteam::get_HackGS_deg () {
     return 3.0 - (y/x) * 60.0 / 6000.0;
 #endif
 
-    if ( current_radiostack->get_nav1_inrange() ) {
+    if ( current_radiostack->get_nav1_inrange() && 
+        current_radiostack->get_nav1_loc() )
+    {
        double x = current_radiostack->get_nav1_dist();
        double y = (FGBFI::getAltitude() - current_radiostack->get_nav1_elev())
            * FEET_TO_METER;
index 08e19fbc08c421582a943c594a43755384ba36ea..cc0c0b1414d8f7fd0b9300d07b500470a93e7591 100644 (file)
@@ -644,7 +644,7 @@ void guiMouseFunc(int button, int updown, int x, int y)
     // know what's going on.
     if (mouse_mode == MOUSE_POINTER) {
       if (!puMouse (button, updown, x,y)) {
-       current_panel.doMouseAction(button, updown, x, y);
+       current_panel->doMouseAction(button, updown, x, y);
       }
     }
     
index 1834b229999778b455fbf2a00b4793beb6e01649..85a0f80b98f927d7710342bfbc6a05cfbdfc974b 100644 (file)
@@ -429,7 +429,7 @@ FGBFI::getSideSlip ()
 
 
 /**
- * Return the current climb rate in feet/second (FIXME: verify).
+ * Return the current climb rate in feet/minute
  */
 double
 FGBFI::getVerticalSpeed ()
@@ -681,8 +681,8 @@ FGBFI::getAPAltitudeLock ()
 void
 FGBFI::setAPAltitudeLock (bool lock)
 {
-    current_autopilot->set_AltitudeEnabled( true );
-    current_autopilot->set_AltitudeMode( FGAutopilot::FG_ALTITUDE_LOCK );
+  current_autopilot->set_AltitudeMode(FGAutopilot::FG_ALTITUDE_LOCK);
+  current_autopilot->set_AltitudeEnabled(lock);
 }
 
 
@@ -712,7 +712,9 @@ FGBFI::setAPAltitude (double altitude)
 bool
 FGBFI::getAPHeadingLock ()
 {
-    return current_autopilot->get_HeadingEnabled();
+    return
+      (current_autopilot->get_HeadingEnabled() &&
+       current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_LOCK);
 }
 
 
@@ -722,8 +724,10 @@ FGBFI::getAPHeadingLock ()
 void
 FGBFI::setAPHeadingLock (bool lock)
 {
-    current_autopilot->set_HeadingEnabled( true );
-    current_autopilot->set_HeadingMode( FGAutopilot::FG_HEADING_LOCK );
+  double heading = getAPHeading();
+  current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_LOCK);
+  current_autopilot->set_HeadingEnabled(lock);
+  setAPHeading(heading);
 }
 
 
@@ -747,6 +751,29 @@ FGBFI::setAPHeading (double heading)
 }
 
 
+/**
+ * Return true if the autopilot is locked to NAV1.
+ */
+bool
+FGBFI::getAPNAV1Lock ()
+{
+  return
+    (current_autopilot->get_HeadingEnabled() &&
+     current_autopilot->get_HeadingMode() == FGAutopilot::FG_HEADING_NAV1);
+}
+
+
+/**
+ * Set the autopilot NAV1 lock.
+ */
+void
+FGBFI::setAPNAV1Lock (bool lock)
+{
+  current_autopilot->set_HeadingMode(FGAutopilot::FG_HEADING_NAV1);
+  current_autopilot->set_HeadingEnabled(lock);
+}
+
+
 \f
 ////////////////////////////////////////////////////////////////////////
 // Radio navigation.
@@ -770,6 +797,18 @@ FGBFI::getNAV1Radial ()
   return current_radiostack->get_nav1_radial();
 }
 
+double
+FGBFI::getNAV1SelRadial ()
+{
+  return current_radiostack->get_nav1_sel_radial();
+}
+
+double
+FGBFI::getNAV1Dist ()
+{
+  return current_radiostack->get_nav1_dist();
+}
+
 double
 FGBFI::getNAV2Freq ()
 {
@@ -788,6 +827,18 @@ FGBFI::getNAV2Radial ()
   return current_radiostack->get_nav2_radial();
 }
 
+double
+FGBFI::getNAV2SelRadial ()
+{
+  return current_radiostack->get_nav2_sel_radial();
+}
+
+double
+FGBFI::getNAV2Dist ()
+{
+  return current_radiostack->get_nav1_dist();
+}
+
 double
 FGBFI::getADFFreq ()
 {
@@ -819,9 +870,9 @@ FGBFI::setNAV1AltFreq (double freq)
 }
 
 void
-FGBFI::setNAV1Radial (double radial)
+FGBFI::setNAV1SelRadial (double radial)
 {
-  current_radiostack->set_nav1_radial(radial);
+  current_radiostack->set_nav1_sel_radial(radial);
 }
 
 void
@@ -837,9 +888,9 @@ FGBFI::setNAV2AltFreq (double freq)
 }
 
 void
-FGBFI::setNAV2Radial (double radial)
+FGBFI::setNAV2SelRadial (double radial)
 {
-  current_radiostack->set_nav2_radial(radial);
+  current_radiostack->set_nav2_sel_radial(radial);
 }
 
 void
index dfb438dc7c8ff99488882286b91f2ae02532956f..fec77c60e357a798e831b3155b14eb49ebcb26c0 100644 (file)
@@ -124,14 +124,21 @@ public:
   static void setAPHeadingLock (bool lock);
   static void setAPHeading (double heading);
 
+  static bool getAPNAV1Lock ();
+  static void setAPNAV1Lock (bool lock);
+
                                // Radio Navigation
   static double getNAV1Freq ();
   static double getNAV1AltFreq ();
   static double getNAV1Radial ();
+  static double getNAV1SelRadial ();
+  static double getNAV1Dist ();
 
   static double getNAV2Freq ();
   static double getNAV2AltFreq ();
   static double getNAV2Radial ();
+  static double getNAV2SelRadial ();
+  static double getNAV2Dist ();
 
   static double getADFFreq ();
   static double getADFAltFreq ();
@@ -139,11 +146,11 @@ public:
 
   static void setNAV1Freq (double freq);
   static void setNAV1AltFreq (double freq);
-  static void setNAV1Radial (double radial);
+  static void setNAV1SelRadial (double radial);
 
   static void setNAV2Freq (double freq);
   static void setNAV2AltFreq (double freq);
-  static void setNAV2Radial (double radial);
+  static void setNAV2SelRadial (double radial);
 
   static void setADFFreq (double freq);
   static void setADFAltFreq (double freq);
index 067b4aa8efdd7cc920c2d5909898f96e34d8049f..03dabc00962d864604c81bff0d05073097cb174b 100644 (file)
@@ -61,6 +61,8 @@
 #include <Autopilot/newauto.hxx>
 #include <Cockpit/cockpit.hxx>
 #include <Cockpit/radiostack.hxx>
+#include <Cockpit/panel.hxx>
+#include <Cockpit/sp_panel.hxx>
 #include <FDM/Balloon.h>
 #include <FDM/External.hxx>
 #include <FDM/JSBsim.hxx>
@@ -477,10 +479,12 @@ bool fgInitSubsystems( void ) {
     current_radiostack = new FGRadioStack;
 
     current_radiostack->set_nav1_freq( 110.30 );
-    current_radiostack->set_nav1_radial( 299.0 );
+    current_radiostack->set_nav1_alt_freq( 110.30 );
+    current_radiostack->set_nav1_sel_radial( 299.0 );
 
     current_radiostack->set_nav2_freq( 115.70 );
-    current_radiostack->set_nav2_radial( 45.0 );
+    current_radiostack->set_nav2_alt_freq( 115.70 );
+    current_radiostack->set_nav2_sel_radial( 45.0 );
 
     current_radiostack->set_adf_freq( 266.0 );
 
@@ -496,9 +500,6 @@ bool fgInitSubsystems( void ) {
        exit(-1);
     }
 
-    // Initialize the 2D panel.
-    current_panel.init(0, 0, 1024, 768);
-
     // Initialize the flight model subsystem data structures base on
     // above values
 
@@ -543,6 +544,9 @@ bool fgInitSubsystems( void ) {
     fgIOInit();
 #endif
 
+    // Initialize the 2D panel.
+    current_panel = fgCreateSmallSinglePropPanel(0, 0, 1024, 768);
+
     FG_LOG( FG_GENERAL, FG_INFO, endl);
 
     return true;
index ba0721bc454fdbf0e61acb31bbfaa35a083ae20e..2738b85ff8f738bf5f70c0f1fc3ecf3162bb6402 100644 (file)
@@ -236,10 +236,12 @@ fgOPTIONS::toggle_panel() {
     
     if( panel_status ) {
        panel_status = false;
-       current_panel.setVisibility(false);
+       if ( current_panel != NULL )
+         current_panel->setVisibility(false);
     } else {
        panel_status = true;
-       current_panel.setVisibility(true);
+       if ( current_panel != NULL )
+         current_panel->setVisibility(true);
     }
     if ( panel_status ) {
        fov *= 0.4232;
@@ -610,10 +612,12 @@ int fgOPTIONS::parse_option( const string& arg ) {
        hud_status = true;      
     } else if ( arg == "--disable-panel" ) {
        panel_status = false;
-       current_panel.setVisibility(false);
+       if ( current_panel != NULL )
+         current_panel->setVisibility(false);
     } else if ( arg == "--enable-panel" ) {
        panel_status = true;
-       current_panel.setVisibility(true);
+       if ( current_panel != NULL )
+         current_panel->setVisibility(true);
        fov *= 0.4232;
     } else if ( arg == "--disable-sound" ) {
        sound = false;