]> git.mxchange.org Git - flightgear.git/commitdiff
Sep 8, 2000 panel updates from David Megginson.
authorcurt <curt>
Fri, 8 Sep 2000 20:47:18 +0000 (20:47 +0000)
committercurt <curt>
Fri, 8 Sep 2000 20:47:18 +0000 (20:47 +0000)
src/Cockpit/panel.cxx
src/Cockpit/panel.hxx
src/Cockpit/panel_io.cxx
src/Cockpit/sp_panel.cxx
src/FDM/UIUCModel/Makefile.am

index 829734d80988eae9e3cd4b88fea62505e07e358d..d8e7e4c2b197121db8c8fc6b639717afeca6f69b 100644 (file)
@@ -86,12 +86,11 @@ FGPanel::FGPanel (int x, int y, int w, int h)
 
 FGPanel::~FGPanel ()
 {
-  instrument_list_type::iterator current = _instruments.begin();
-  instrument_list_type::iterator last = _instruments.end();
-  
-  for ( ; current != last; ++current) {
-    delete *current;
-    *current = 0;
+  for (instrument_list_type::iterator it = _instruments.begin();
+       it != _instruments.end();
+       it++) {
+    delete *it;
+    *it = 0;
   }
 }
 
@@ -208,7 +207,6 @@ FGPanel::doMouseAction (int button, int updown, int x, int y)
     int iw = inst->getWidth() / 2;
     int ih = inst->getHeight() / 2;
     if (x >= ix - iw && x < ix + iw && y >= iy - ih && y < iy + ih) {
-//       cout << "Do mouse action for component " << i << '\n';
       _mouseDown = true;
       _mouseDelay = 20;
       _mouseInstrument = inst;
@@ -220,19 +218,39 @@ FGPanel::doMouseAction (int button, int updown, int x, int y)
       return true;
     }
   }
-//   cout << "Did not click on an instrument\n";
   return false;
 }
 
 
+\f
+////////////////////////////////////////////////////////////////////////.
+// Implementation of FGPanelAction.
+////////////////////////////////////////////////////////////////////////
+
+FGPanelAction::FGPanelAction ()
+{
+}
+
+FGPanelAction::FGPanelAction (int button, int x, int y, int w, int h)
+  : _button(button), _x(x), _y(y), _w(w), _h(h)
+{
+}
+
+FGPanelAction::~FGPanelAction ()
+{
+}
+
+
 \f
 ////////////////////////////////////////////////////////////////////////
 // Implementation of FGAdjustAction.
 ////////////////////////////////////////////////////////////////////////
 
-FGAdjustAction::FGAdjustAction (SGValue * value, float increment, 
+FGAdjustAction::FGAdjustAction (int button, int x, int y, int w, int h,
+                               SGValue * value, float increment, 
                                float min, float max, bool wrap=false)
-  : _value(value), _increment(increment), _min(min), _max(max), _wrap(wrap)
+  : FGPanelAction(button, x, y, w, h),
+    _value(value), _increment(increment), _min(min), _max(max), _wrap(wrap)
 {
 }
 
@@ -244,14 +262,12 @@ void
 FGAdjustAction::doAction ()
 {
   float val = _value->getFloatValue();
-//   cout << "Do action; value=" << value << '\n';
   val += _increment;
   if (val < _min) {
     val = (_wrap ? _max : _min);
   } else if (val > _max) {
     val = (_wrap ? _min : _max);
   }
-//   cout << "New value is " << value << '\n';
   _value->setDoubleValue(val);
 }
 
@@ -261,8 +277,9 @@ FGAdjustAction::doAction ()
 // Implementation of FGSwapAction.
 ////////////////////////////////////////////////////////////////////////
 
-FGSwapAction::FGSwapAction (SGValue * value1, SGValue * value2)
-  : _value1(value1), _value2(value2)
+FGSwapAction::FGSwapAction (int button, int x, int y, int w, int h,
+                           SGValue * value1, SGValue * value2)
+  : FGPanelAction(button, x, y, w, h), _value1(value1), _value2(value2)
 {
 }
 
@@ -284,8 +301,9 @@ FGSwapAction::doAction ()
 // Implementation of FGToggleAction.
 ////////////////////////////////////////////////////////////////////////
 
-FGToggleAction::FGToggleAction (SGValue * value)
-  : _value(value)
+FGToggleAction::FGToggleAction (int button, int x, int y, int w, int h,
+                               SGValue * value)
+  : FGPanelAction(button, x, y, w, h), _value(value)
 {
 }
 
@@ -300,6 +318,29 @@ FGToggleAction::doAction ()
 }
 
 
+\f
+////////////////////////////////////////////////////////////////////////
+// Implementation of FGPanelTransformation.
+////////////////////////////////////////////////////////////////////////
+
+FGPanelTransformation::FGPanelTransformation ()
+{
+}
+
+FGPanelTransformation::FGPanelTransformation (Type _type,
+                                             const SGValue * _value,
+                                             float _min, float _max,
+                                             float _factor, float _offset)
+  : type(_type), value(_value), min(_min), max(_max),
+    factor(_factor), offset(_offset)
+{
+}
+
+FGPanelTransformation::~FGPanelTransformation ()
+{
+}
+
+
 \f
 ////////////////////////////////////////////////////////////////////////
 // Implementation of FGPanelInstrument.
@@ -320,10 +361,11 @@ FGPanelInstrument::FGPanelInstrument (int x, int y, int w, int h)
 
 FGPanelInstrument::~FGPanelInstrument ()
 {
-  action_list_type::iterator it = _actions.begin();
-  action_list_type::iterator last = _actions.end();
-  for ( ; it != last; it++) {
-    delete it->action;
+  for (action_list_type::iterator it = _actions.begin();
+       it != _actions.end();
+       it++) {
+    delete *it;
+    *it = 0;
   }
 }
 
@@ -366,17 +408,9 @@ FGPanelInstrument::getHeight () const
 }
 
 void
-FGPanelInstrument::addAction (int button, int x, int y, int w, int h,
-                             FGPanelAction * action)
+FGPanelInstrument::addAction (FGPanelAction * action)
 {
-  FGPanelInstrument::inst_action act;
-  act.button = button;
-  act.x = x;
-  act.y = y;
-  act.w = w;
-  act.h = h;
-  act.action = action;
-  _actions.push_back(act);
+  _actions.push_back(action);
 }
 
                                // Coordinates relative to centre.
@@ -385,13 +419,9 @@ FGPanelInstrument::doMouseAction (int button, int x, int y)
 {
   action_list_type::iterator it = _actions.begin();
   action_list_type::iterator last = _actions.end();
-//   cout << "Mouse action at " << x << ',' << y << '\n';
   for ( ; it != last; it++) {
-//     cout << "Trying action at " << it->x << ',' << it->y << ','
-//      << it->w <<',' << it->h << '\n';
-    if (button == it->button &&
-       x >= it->x && x < it->x + it->w && y >= it->y && y < it->y + it->h) {
-      it->action->doAction();
+    if ((*it)->inArea(button, x, y)) {
+      (*it)->doAction();
       return true;
     }
   }
@@ -411,7 +441,10 @@ FGLayeredInstrument::FGLayeredInstrument (int x, int y, int w, int h)
 
 FGLayeredInstrument::~FGLayeredInstrument ()
 {
-  // FIXME: free layers
+  for (layer_list::iterator it = _layers.begin(); it != _layers.end(); it++) {
+    delete *it;
+    *it = 0;
+  }
 }
 
 void
@@ -447,20 +480,10 @@ FGLayeredInstrument::addLayer (CroppedTexture &texture,
 }
 
 void
-FGLayeredInstrument::addTransformation (FGInstrumentLayer::transform_type type,
-                                       const SGValue * value,
-                                       float min, float max,
-                                       float factor, float offset)
+FGLayeredInstrument::addTransformation (FGPanelTransformation * transformation)
 {
   int layer = _layers.size() - 1;
-  _layers[layer]->addTransformation(type, value, min, max, factor, offset);
-}
-
-void
-FGLayeredInstrument::addTransformation (FGInstrumentLayer::transform_type type,
-                                       float offset)
-{
-  addTransformation(type, 0, 0.0, 0.0, 1.0, offset);
+  _layers[layer]->addTransformation(transformation);
 }
 
 
@@ -477,11 +500,11 @@ FGInstrumentLayer::FGInstrumentLayer (int w, int h)
 
 FGInstrumentLayer::~FGInstrumentLayer ()
 {
-  transformation_list::iterator it = _transformations.begin();
-  transformation_list::iterator end = _transformations.end();
-  while (it != end) {
+  for (transformation_list::iterator it = _transformations.begin();
+       it != _transformations.end();
+       it++) {
     delete *it;
-    it++;
+    *it = 0;
   }
 }
 
@@ -491,7 +514,7 @@ FGInstrumentLayer::transform () const
   transformation_list::const_iterator it = _transformations.begin();
   transformation_list::const_iterator last = _transformations.end();
   while (it != last) {
-    transformation *t = *it;
+    FGPanelTransformation *t = *it;
     float val = (t->value == 0 ? 0.0 : t->value->getFloatValue());
     if (val < t->min) {
       val = t->min;
@@ -501,13 +524,13 @@ FGInstrumentLayer::transform () const
     val = val * t->factor + t->offset;
 
     switch (t->type) {
-    case XSHIFT:
+    case FGPanelTransformation::XSHIFT:
       glTranslatef(val, 0.0, 0.0);
       break;
-    case YSHIFT:
+    case FGPanelTransformation::YSHIFT:
       glTranslatef(0.0, val, 0.0);
       break;
-    case ROTATION:
+    case FGPanelTransformation::ROTATION:
       glRotatef(-val, 0.0, 0.0, 1.0);
       break;
     }
@@ -516,19 +539,9 @@ FGInstrumentLayer::transform () const
 }
 
 void
-FGInstrumentLayer::addTransformation (transform_type type,
-                                     const SGValue * value,
-                                     float min, float max,
-                                     float factor, float offset)
+FGInstrumentLayer::addTransformation (FGPanelTransformation * transformation)
 {
-  transformation *t = new transformation;
-  t->type = type;
-  t->value = value;
-  t->min = min;
-  t->max = max;
-  t->factor = factor;
-  t->offset = offset;
-  _transformations.push_back(t);
+  _transformations.push_back(transformation);
 }
 
 
@@ -557,17 +570,17 @@ FGTexturedLayer::draw ()
   int h2 = _h / 2;
 
   transform();
-  glBindTexture(GL_TEXTURE_2D, _texture->texture->getHandle());
+  glBindTexture(GL_TEXTURE_2D, _texture.texture->getHandle());
   glBegin(GL_POLYGON);
   if ( cur_light_params.sun_angle * RAD_TO_DEG < 95.0 ) {
       glColor4fv( cur_light_params.scene_diffuse );
   } else {
       glColor4f(0.7, 0.2, 0.2, 1.0);
   }
-  glTexCoord2f(_texture->minX, _texture->minY); glVertex2f(-w2, -h2);
-  glTexCoord2f(_texture->maxX, _texture->minY); glVertex2f(w2, -h2);
-  glTexCoord2f(_texture->maxX, _texture->maxY); glVertex2f(w2, h2);
-  glTexCoord2f(_texture->minX, _texture->maxY); glVertex2f(-w2, h2);
+  glTexCoord2f(_texture.minX, _texture.minY); glVertex2f(-w2, -h2);
+  glTexCoord2f(_texture.maxX, _texture.minY); glVertex2f(w2, -h2);
+  glTexCoord2f(_texture.maxX, _texture.maxY); glVertex2f(w2, h2);
+  glTexCoord2f(_texture.minX, _texture.maxY); glVertex2f(-w2, h2);
   glEnd();
 }
 
index bc70ff2166af8e88ab982e0d57cdfd59e35d8398..2fff6a31033fd1a1f552271e8007dcaef8f9288a 100644 (file)
@@ -120,11 +120,11 @@ public:
   virtual bool doMouseAction (int button, int updown, int x, int y);
 
 private:
-  bool _visibility;
-  bool _mouseDown;
-  int _mouseButton, _mouseX, _mouseY;
+  mutable bool _visibility;
+  mutable bool _mouseDown;
+  mutable int _mouseButton, _mouseX, _mouseY;
   mutable int _mouseDelay;
-  FGPanelInstrument * _mouseInstrument;
+  mutable FGPanelInstrument * _mouseInstrument;
   typedef vector<FGPanelInstrument *> instrument_list_type;
   int _x, _y, _w, _h;
   int _panel_h;
@@ -139,14 +139,46 @@ private:
 // 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.
+// click in a rectangular area.  Current concrete classes include
+// FGAdjustAction, FGSwapAction, and FGToggleAction.
 ////////////////////////////////////////////////////////////////////////
 
 class FGPanelAction
 {
 public:
+  FGPanelAction ();
+  FGPanelAction (int button, int x, int y, int w, int h);
+  virtual ~FGPanelAction ();
+
+  virtual int getButton () const { return _button; }
+  virtual int getX () const { return _x; }
+  virtual int getY () const { return _y; }
+  virtual int getWidth () const { return _w; }
+  virtual int getHeight () const { return _h; }
+
+  virtual void setButton (int button) { _button = button; }
+  virtual void setX (int x) { _x = x; }
+  virtual void setY (int y) { _y = y; }
+  virtual void setWidth (int w) { _w = w; }
+  virtual void setHeight (int h) { _h = h; }
+
+  virtual bool inArea (int button, int x, int y)
+  {
+    return (button == _button &&
+           x >= _x &&
+           x < _x + _w &&
+           y >= _y &&
+           y < _y + _h);
+  }
+
   virtual void doAction () = 0;
+
+private:
+  int _button;
+  int _x;
+  int _y;
+  int _w;
+  int _h;
 };
 
 
@@ -163,7 +195,8 @@ public:
 class FGAdjustAction : public FGPanelAction
 {
 public:
-  FGAdjustAction (SGValue * value, float increment,
+  FGAdjustAction (int button, int x, int y, int w, int h,
+                 SGValue * value, float increment,
                  float min, float max, bool wrap=false);
   virtual ~FGAdjustAction ();
   virtual void doAction ();
@@ -188,7 +221,8 @@ private:
 class FGSwapAction : public FGPanelAction
 {
 public:
-  FGSwapAction (SGValue * value1, SGValue * value2);
+  FGSwapAction (int button, int x, int y, int w, int h,
+               SGValue * value1, SGValue * value2);
   virtual ~FGSwapAction ();
   virtual void doAction ();
 
@@ -208,7 +242,8 @@ private:
 class FGToggleAction : public FGPanelAction
 {
 public:
-  FGToggleAction (SGValue * value);
+  FGToggleAction (int button, int x, int y, int w, int h,
+                 SGValue * value);
   virtual ~FGToggleAction ();
   virtual void doAction ();
 
@@ -247,23 +282,14 @@ public:
 
                                // Coordinates relative to centre.
                                // Transfer pointer ownership!!
-  virtual void addAction (int button, int x, int y, int w, int h,
-                         FGPanelAction * action);
+  virtual void addAction (FGPanelAction * action);
 
                                // Coordinates relative to centre.
   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;
-    int h;
-    FGPanelAction * action;
-  } inst_action;
-  typedef vector<inst_action> action_list_type;
+  typedef vector<FGPanelAction *> action_list_type;
   action_list_type _actions;
 };
 
@@ -278,6 +304,35 @@ protected:
 // rotate to show the altitude or airspeed.
 ////////////////////////////////////////////////////////////////////////
 
+
+/**
+ * A transformation for a layer.
+ */
+class FGPanelTransformation {
+public:
+
+  enum Type {
+    XSHIFT,
+    YSHIFT,
+    ROTATION
+  };
+
+  FGPanelTransformation ();
+  FGPanelTransformation (Type type, const SGValue * value,
+                        float min, float max,
+                        float factor, float offset);
+  virtual ~FGPanelTransformation ();
+
+  Type type;
+  const SGValue * value;
+  float min;
+  float max;
+  float factor;
+  float offset;
+};
+
+
+
 /**
  * A single layer of a multi-layered instrument.
  *
@@ -288,11 +343,6 @@ protected:
 class FGInstrumentLayer
 {
 public:
-  typedef enum {
-    XSHIFT,
-    YSHIFT,
-    ROTATION
-  } transform_type;
 
   FGInstrumentLayer (int w = -1, int h = -1);
   virtual ~FGInstrumentLayer ();
@@ -305,22 +355,14 @@ public:
   virtual void setWidth (int w) { _w = w; }
   virtual void setHeight (int h) { _h = h; }
 
-  virtual void addTransformation (transform_type type, const SGValue * value,
-                                 float min, float max,
-                                 float factor = 1.0, float offset = 0.0);
+                               // Transfer pointer ownership!!
+                               // DEPRECATED
+  virtual void addTransformation (FGPanelTransformation * transformation);
 
 protected:
   int _w, _h;
 
-  typedef struct {
-    transform_type type;
-    const SGValue * value;
-    float min;
-    float max;
-    float factor;
-    float offset;
-  } transformation;
-  typedef vector<transformation *> transformation_list;
+  typedef vector<FGPanelTransformation *> transformation_list;
   transformation_list _transformations;
 };
 
@@ -354,14 +396,10 @@ public:
 
                                // Transfer pointer ownership!!
   virtual int addLayer (FGInstrumentLayer *layer);
-  virtual int addLayer (CroppedTexture &texture,
-                       int w = -1, int h = -1);
-  virtual void addTransformation (FGInstrumentLayer::transform_type type,
-                                 const SGValue * value,
-                                 float min, float max,
-                                 float factor = 1.0, float offset = 0.0);
-  virtual void addTransformation (FGInstrumentLayer::transform_type type,
-                                 float offset);
+  virtual int addLayer (CroppedTexture &texture, int w = -1, int h = -1);
+
+                               // Transfer pointer ownership!!
+  virtual void addTransformation (FGPanelTransformation * transformation);
 
 protected:
   layer_list _layers;
@@ -386,11 +424,11 @@ public:
 
   virtual void draw ();
 
-  virtual void setTexture (CroppedTexture &texture) { _texture = &texture; }
-  virtual CroppedTexture &getTexture () { return *_texture; }
+  virtual void setTexture (CroppedTexture &texture) { _texture = texture; }
+  virtual CroppedTexture &getTexture () { return _texture; }
 
 private:
-  mutable CroppedTexture _texture;
+  mutable CroppedTexture _texture;
 };
 
 
index de3210a91705653f40945de8bad39ecfa8169476..1175b0d7129f10937656babc6cba2408de4a1c21 100644 (file)
 
 #include <iostream>
 #include <string>
-#include <map>
 
 #include "panel.hxx"
 
 using std::istream;
-using std::hash_map;
 using std::string;
 
 
 \f
 ////////////////////////////////////////////////////////////////////////
-// Instruments.
+// Read and construct a panel.
 ////////////////////////////////////////////////////////////////////////
 
-struct ActionData
+
+/**
+ * Read a cropped texture.
+ */
+static CroppedTexture
+readTexture (SGPropertyNode node)
 {
-  FGPanelAction * action;
-  int button, x, y, w, h;
-};
+  CroppedTexture texture(node.getStringValue("path"),
+                        node.getFloatValue("x1"),
+                        node.getFloatValue("y1"),
+                        node.getFloatValue("x2", 1.0),
+                        node.getFloatValue("y2", 1.0));
+  FG_LOG(FG_INPUT, FG_INFO, "Read texture " << node.getName());
+  return texture;
+}
 
-struct TransData
+
+/**
+ * Read an action.
+ */
+static FGPanelAction *
+readAction (SGPropertyNode node)
 {
-  enum Type {
-    End = 0,
-    Rotation,
-    XShift,
-    YShift
-  };
-  Type type;
-  const char * propName;
-  float min, max, factor, offset;
-};
-
-struct LayerData
+  FGPanelAction * action = 0;
+
+  cerr << "Reading action\n";
+
+  string type = node.getStringValue("type");
+
+  int button = node.getIntValue("button");
+  int x = node.getIntValue("x");
+  int y = node.getIntValue("y");
+  int w = node.getIntValue("w");
+  int h = node.getIntValue("h");
+
+                               // Adjust a property value
+  if (type == "adjust") {
+    string propName = node.getStringValue("property");
+    SGValue * value = current_properties.getValue(propName, true);
+    float increment = node.getFloatValue("increment", 1.0);
+    float min = node.getFloatValue("min", 0.0);
+    float max = node.getFloatValue("max", 0.0);
+    bool wrap = node.getBoolValue("wrap", false);
+    if (min == max)
+      FG_LOG(FG_INPUT, FG_ALERT, "Action " << node.getName()
+            << " has same min and max value");
+    action = new FGAdjustAction(button, x, y, w, h, value,
+                               increment, min, max, wrap);
+  } 
+
+                               // Swap two property values
+  else if (type == "swap") {
+    string propName1 = node.getStringValue("property1");
+    string propName2 = node.getStringValue("property2");
+    SGValue * value1 = current_properties.getValue(propName1, true);
+    SGValue * value2 = current_properties.getValue(propName2, true);
+    action = new FGSwapAction(button, x, y, w, h, value1, value2);
+  } 
+
+                               // Toggle a boolean value
+  else if (type == "toggle") {
+    string propName = node.getStringValue("property");
+    SGValue * value = current_properties.getValue(propName, true);
+    action = new FGToggleAction(button, x, y, w, h, value);
+  } 
+
+                               // No type supplied
+  else if (type == "") {
+    FG_LOG(FG_INPUT, FG_ALERT, "No type specified for action "
+          << node.getName());
+    return 0;
+  } 
+
+                               // Unrecognized type
+  else {
+    FG_LOG(FG_INPUT, FG_ALERT, "Unrecognized action type " << node.getName());
+    return 0;
+  }
+
+  return action;
+}
+
+
+/**
+ * Read a single transformation.
+ */
+static FGPanelTransformation *
+readTransformation (SGPropertyNode node)
 {
-  FGInstrumentLayer * layer;
-  TransData transformations[16];
-};
+  FGPanelTransformation * t = new FGPanelTransformation;
+
+  string name = node.getName();
+  string type = node.getStringValue("type");
+  string propName = node.getStringValue("property", "");
+  SGValue * value = 0;
+
+  if (propName != "") {
+    value = current_properties.getValue(propName, true);
+  }
+
+  t->value = value;
+  t->min = node.getFloatValue("min", 0.0);
+  t->max = node.getFloatValue("max", 1.0);
+  t->factor = node.getFloatValue("factor", 1.0);
+  t->offset = node.getFloatValue("offset", 0.0);
+  if (type == "x-shift") {
+    t->type = FGPanelTransformation::XSHIFT;
+  } else if (type == "y-shift") {
+    t->type = FGPanelTransformation::YSHIFT;
+  } else if (type == "rotation") {
+    t->type = FGPanelTransformation::ROTATION;
+  } else if (type == "") {
+    FG_LOG(FG_INPUT, FG_ALERT,
+          "'type' must be specified for transformation");
+    delete t;
+    return 0;
+  } else {
+    FG_LOG(FG_INPUT, FG_ALERT, "Unrecognized transformation: " << type);
+    delete t;
+    return 0;
+  }
 
-struct InstrumentData
+  FG_LOG(FG_INPUT, FG_INFO, "Read transformation " << name);
+  return t;
+}
+
+
+/**
+ * Read a single layer of an instrument.
+ */
+static FGInstrumentLayer *
+readLayer (SGPropertyNode node)
 {
-  const char * name;
-  int x, y, w, h;
-  ActionData actions[16];
-  LayerData layers[16];
-};
+  FGInstrumentLayer * l;
+  string name = node.getName();
+
+  CroppedTexture texture = readTexture(node.getSubNode("texture"));
+  l = new FGTexturedLayer(texture,
+                         node.getIntValue("w", -1),
+                         node.getIntValue("h", -1));
+  
+  //
+  // Get the transformations for each layer.
+  //
+  SGPropertyNode trans_group = node.getSubNode("transformations");
+  int nTransformations = trans_group.size();
+  for (int k = 0; k < nTransformations; k++) {
+    FGPanelTransformation * t = readTransformation(trans_group.getChild(k));
+    if (t == 0) {
+      delete l;
+      return 0;
+    }
+    l->addTransformation(t);
+  }
+  
+  FG_LOG(FG_INPUT, FG_INFO, "Read layer " << name);
+  return l;
+}
 
 
-\f
-////////////////////////////////////////////////////////////////////////
-// Read and construct a panel.
-////////////////////////////////////////////////////////////////////////
+/**
+ * Read an instrument.
+ */
+static FGPanelInstrument *
+readInstrument (SGPropertyNode node)
+{
+  const string &name = node.getStringValue("name");
+
+  FG_LOG(FG_INPUT, FG_INFO, "Reading instrument " << name);
+
+  FGLayeredInstrument * instrument =
+    new FGLayeredInstrument(0, 0,
+                           node.getIntValue("w"),
+                           node.getIntValue("h"));
+
+  //
+  // Get the actions for the instrument.
+  //
+  SGPropertyNode action_group = node.getSubNode("actions");
+  int nActions = action_group.size();
+  cerr << "There are " << nActions << " actions\n";
+  for (int j = 0; j < nActions; j++) {
+    FGPanelAction * action = readAction(action_group.getChild(j));
+    if (action == 0) {
+      delete instrument;
+      return 0;
+    }
+    instrument->addAction(action);
+  }
+
+  //
+  // Get the layers for the instrument.
+  //
+  SGPropertyNode layer_group = node.getSubNode("layers");
+  int nLayers = layer_group.size();
+  for (int j = 0; j < nLayers; j++) {
+    FGInstrumentLayer * layer = readLayer(layer_group.getChild(j));
+    if (layer == 0) {
+      delete instrument;
+      return 0;
+    }
+    instrument->addLayer(layer);
+  }
+
+  FG_LOG(FG_INPUT, FG_INFO, "Done reading instrument " << name);
+  return instrument;
+}
 
 
 /**
@@ -95,7 +262,6 @@ FGPanel *
 fgReadPanel (istream &input)
 {
   SGPropertyList props;
-  map<string,CroppedTexture> textures;
 
 
   //
@@ -108,39 +274,18 @@ fgReadPanel (istream &input)
   FG_LOG(FG_INPUT, FG_INFO, "Read properties for panel " <<
         props.getStringValue("/name"));
 
-  //
-  // Read the cropped textures from the property list.
-  //
-  SGPropertyNode texture_group("/textures", &props);
-  int nTextures = texture_group.size();
-  cout << "There are " << nTextures << " textures" << endl;
-  for (int i = 0; i < nTextures; i++) {
-    SGPropertyNode tex = texture_group.getChild(i);
-    const string &name = tex.getName();
-    textures[name] = CroppedTexture(tex.getStringValue("path"),
-                                   tex.getFloatValue("x1"),
-                                   tex.getFloatValue("y1"),
-                                   tex.getFloatValue("x2", 1.0),
-                                   tex.getFloatValue("y2", 1.0));
-    FG_LOG(FG_INPUT, FG_INFO, "Read texture " << name);
-  }
-
-
   //
   // Construct a new, empty panel.
   //
   FGPanel * panel = new FGPanel(0, 0, 1024, 768);// FIXME: use variable size
 
-
   //
   // Assign the background texture, if any, or a bogus chequerboard.
   //
   string bgTexture = props.getStringValue("/background");
-  if (bgTexture == "") {
-    panel->setBackground(FGTextureManager::createTexture("FOO"));
-  } else {
-    panel->setBackground(textures[bgTexture].texture);
-  }
+  if (bgTexture == "")
+    bgTexture = "FOO";
+  panel->setBackground(FGTextureManager::createTexture(bgTexture.c_str()));
   FG_LOG(FG_INPUT, FG_INFO, "Set background texture to " << bgTexture);
 
 
@@ -150,95 +295,37 @@ fgReadPanel (istream &input)
   FG_LOG(FG_INPUT, FG_INFO, "Reading panel instruments");
   SGPropertyNode instrument_group("/instruments", &props);
   int nInstruments = instrument_group.size();
-  cout << "There are " << nInstruments << " instruments" << endl;
   for (int i = 0; i < nInstruments; i++) {
-    SGPropertyNode inst = instrument_group.getChild(i);
-    const string &name = inst.getName();
-    FGLayeredInstrument * instrument =
-      new FGLayeredInstrument(inst.getIntValue("x"),
-                             inst.getIntValue("y"),
-                             inst.getIntValue("w"),
-                             inst.getIntValue("h"));
-
-
-    //
-    // Get the layers for each instrument.
-    //
-    SGPropertyNode layer_group = inst.getSubNode("layers");
-    SGPropertyNode layer;
-    int nLayers = layer_group.size();
-    cout << "There are " << nLayers << " layers" << endl;
-    for (int j = 0; j < nLayers; j++) {
-      layer = layer_group.getChild(j);
-      FGInstrumentLayer * l;
-      string name = layer.getName();
-
-      string tex = layer.getStringValue("texture");
-      if (tex != "") {
-       l = new FGTexturedLayer(textures[tex],
-                               layer.getIntValue("w", -1),
-                               layer.getIntValue("h", -1));
-      } else {
-       FG_LOG(FG_INPUT, FG_ALERT, "No texture for layer " << name);
-       return 0;
-      }
-
-      //
-      // Get the transformations for each layer.
-      //
-      SGPropertyNode trans_group = layer.getSubNode("transformations");
-      SGPropertyNode trans;
-      int nTransformations = trans_group.size();
-      cout << "There are " << nTransformations << " transformations" << endl;
-      for (int k = 0; k < nTransformations; k++) {
-       trans = trans_group.getChild(k);
-       string name = trans.getName();
-       string type = trans.getStringValue("type");
-       string propName = trans.getStringValue("property", "");
-       SGValue * value = 0;
-       cout << "Type is " << type << endl;
-       if (propName != "") {
-         value = current_properties.getValue(propName, true);
-       }
-       if (type == "x-shift") {
-         l->addTransformation(FGInstrumentLayer::XSHIFT,
-                              value,
-                              trans.getFloatValue("min", 0.0),
-                              trans.getFloatValue("max", 1.0),
-                              trans.getFloatValue("factor", 1.0),
-                              trans.getFloatValue("offset", 0.0));
-       } else if (type == "y-shift") {
-         l->addTransformation(FGInstrumentLayer::YSHIFT,
-                              value,
-                              trans.getFloatValue("min", 0.0),
-                              trans.getFloatValue("max", 1.0),
-                              trans.getFloatValue("factor", 1.0),
-                              trans.getFloatValue("offset", 0.0));
-       } else if (type == "rotation") {
-         l->addTransformation(FGInstrumentLayer::ROTATION,
-                              value,
-                              trans.getFloatValue("min", -360.0),
-                              trans.getFloatValue("max", 360.0),
-                              trans.getFloatValue("factor", 1.0),
-                              trans.getFloatValue("offset", 0.0));
-       } else if (type == "") {
-         FG_LOG(FG_INPUT, FG_ALERT,
-                "'type' must be specified for transformation");
-         return 0;
-       } else {
-         FG_LOG(FG_INPUT, FG_ALERT, "Unrecognized transformation: " << type);
-         return 0;
-       }
-       FG_LOG(FG_INPUT, FG_INFO, "Read transformation " << name);
-      }
-
-      instrument->addLayer(l);
-      FG_LOG(FG_INPUT, FG_INFO, "Read layer " << name);
+    SGPropertyList props2;
+    SGPropertyNode node = instrument_group.getChild(i);
+
+    string path = node.getStringValue("path");
+    int x = node.getIntValue("x");
+    int y = node.getIntValue("y");
+    int w = node.getIntValue("w");
+    int h = node.getIntValue("h");
+
+    FG_LOG(FG_INPUT, FG_INFO, "Reading instrument "
+          << node.getName()
+          << " from "
+          << path);
+
+    if (!readPropertyList(path, &props2)) {
+      delete panel;
+      return 0;
     }
 
+    FGPanelInstrument * instrument =
+      readInstrument(SGPropertyNode("/", &props2));
+    if (instrument == 0) {
+      delete instrument;
+      delete panel;
+      return 0;
+    }
+    instrument->setPosition(x, y);
     panel->addInstrument(instrument);
-    FG_LOG(FG_INPUT, FG_INFO, "Read instrument " << name);
   }
+  FG_LOG(FG_INPUT, FG_INFO, "Done reading panel instruments");
 
 
   //
@@ -246,3 +333,6 @@ fgReadPanel (istream &input)
   //
   return panel;
 }
+
+
+// end of panel_io.cxx
index ae770f9e4e6f045ca56d4fa59dd30c39ab2463ec..84dfc4a3e84006ded7f36fa575f42dbcd02112f9 100644 (file)
@@ -383,12 +383,6 @@ MagRibbon::draw ()
 // Instruments.
 ////////////////////////////////////////////////////////////////////////
 
-struct ActionData
-{
-  FGPanelAction * action;
-  int button, x, y, w, h;
-};
-
 struct TransData
 {
   enum Type {
@@ -412,7 +406,7 @@ struct InstrumentData
 {
   const char * name;
   int x, y, w, h;
-  ActionData actions[16];
+  FGPanelAction * actions[16];
   LayerData layers[16];
 };
 
@@ -546,31 +540,31 @@ InstrumentData instruments[] =
   }},
 
   {"gyro", SIX_X+SIX_SPACING, SIX_Y-SIX_SPACING, SIX_W, SIX_W, {
-    {new FGAdjustAction(V("/autopilot/settings/heading-magnetic"),
-                       -1.0, -360.0, 360.0, true),
-       0, SIX_W/2-SIX_W/5, -SIX_W/2, SIX_W/10, SIX_W/5},
-    {new FGAdjustAction(V("/autopilot/settings/heading-magnetic"),
-                       1.0, -360.0, 360.0, true),
-       0, SIX_W/2 - SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5},
-    {new FGAdjustAction(V("/autopilot/settings/heading-magnetic"),
-                       -5.0, -360.0, 360.0, true),
-       1, SIX_W/2 - SIX_W/5, -SIX_W/2, SIX_W/10, SIX_W/5},
-    {new FGAdjustAction(V("/autopilot/settings/heading-magnetic"),
-                       5.0, -360.0, 360.0, true),
-       1, SIX_W/2 - SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5},
-    {new FGAdjustAction(V("/steam/gyro-compass-error"),
-                       -1.0, -360.0, 360.0, true),
-       0, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5},
-    {new FGAdjustAction(V("/steam/gyro-compass-error"),
-                       1.0, -360.0, 360.0, true),
-       0, -SIX_W/2+SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5},
-    {new FGAdjustAction(V("/steam/gyro-compass-error"),
-                       -5.0, -360.0, 360.0, true),
-       1, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5},
-    {new FGAdjustAction(V("/steam/gyro-compass-error"),
-                       5.0, -360.0, 360.0, true),
-       1, -SIX_W/2+SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5}
-  }, {
+    new FGAdjustAction(0, SIX_W/2-SIX_W/5, -SIX_W/2, SIX_W/10, SIX_W/5,
+                      V("/autopilot/settings/heading-magnetic"),
+                      -1.0, -360.0, 360.0, true),
+    new FGAdjustAction(0, SIX_W/2 - SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
+                      V("/autopilot/settings/heading-magnetic"),
+                      1.0, -360.0, 360.0, true),
+    new FGAdjustAction(1, SIX_W/2 - SIX_W/5, -SIX_W/2, SIX_W/10, SIX_W/5,
+                      V("/autopilot/settings/heading-magnetic"),
+                      -5.0, -360.0, 360.0, true),
+    new FGAdjustAction(1, SIX_W/2 - SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
+                      V("/autopilot/settings/heading-magnetic"),
+                      5.0, -360.0, 360.0, true),
+    new FGAdjustAction(0, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5,
+                      V("/steam/gyro-compass-error"),
+                      -1.0, -360.0, 360.0, true),
+    new FGAdjustAction(0, -SIX_W/2+SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
+                      V("/steam/gyro-compass-error"),
+                      1.0, -360.0, 360.0, true),
+    new FGAdjustAction(1, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5,
+                      V("/steam/gyro-compass-error"),
+                      -5.0, -360.0, 360.0, true),
+    new FGAdjustAction(1, -SIX_W/2+SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
+                      V("/steam/gyro-compass-error"),
+                      5.0, -360.0, 360.0, true)
+   }, {
     {new MyTexturedLayer("compassBG", -1, -1), {
       {TransData::Rotation, "/steam/gyro-compass", -720.0, 720.0, -1.0, 0.0}
     }},
@@ -608,18 +602,18 @@ InstrumentData instruments[] =
   }},
 
   {"nav1", SIX_X+(SIX_SPACING*3)+20, SIX_Y, SIX_W, SIX_W, {
-    {new FGAdjustAction(V("/radios/nav1/radials/selected"),
-                       1.0, 0.0, 360.0, true),
-       0, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5},
-    {new FGAdjustAction(V("/radios/nav1/radials/selected"),
-                       -1.0, 0.0, 360.0, true),
-       0, -SIX_W/2 + SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5},
-    {new FGAdjustAction(V("/radios/nav1/radials/selected"),
-                       5.0, 0.0, 360.0, true),
-       1, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5},
-    {new FGAdjustAction(V("/radios/nav1/radials/selected"),
-                       -5.0, 0.0, 360.0, true),
-       1, -SIX_W/2 + SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5}       
+    new FGAdjustAction(0, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5,
+                      V("/radios/nav1/radials/selected"),
+                      1.0, 0.0, 360.0, true),
+    new FGAdjustAction(0, -SIX_W/2 + SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
+                      V("/radios/nav1/radials/selected"),
+                      -1.0, 0.0, 360.0, true),
+    new FGAdjustAction(1, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5,
+                      V("/radios/nav1/radials/selected"),
+                      5.0, 0.0, 360.0, true),
+    new FGAdjustAction(1, -SIX_W/2 + SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
+                      V("/radios/nav1/radials/selected"),
+                      -5.0, 0.0, 360.0, true)
   }, {
     {new MyTexturedLayer("compassBG"), {
       {TransData::Rotation, "/radios/nav1/radials/selected",
@@ -656,18 +650,18 @@ InstrumentData instruments[] =
   }},
 
   {"nav2", SIX_X+(SIX_SPACING*3)+20, SIX_Y-SIX_SPACING, SIX_W, SIX_W, {
-    {new FGAdjustAction(V("/radios/nav2/radials/selected"),
-                       1.0, 0.0, 360.0, true),
-       0, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5},
-    {new FGAdjustAction(V("/radios/nav2/radials/selected"),
-                       -1.0, 0.0, 360.0, true),
-       0, -SIX_W/2 + SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5},
-    {new FGAdjustAction(V("/radios/nav2/radials/selected"),
-                       5.0, 0.0, 360.0, true),
-       1, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5},
-    {new FGAdjustAction(V("/radios/nav2/radials/selected"),
-                       -5.0, 0.0, 360.0, true),
-       1, -SIX_W/2 + SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5}       
+    new FGAdjustAction(0, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5,
+                      V("/radios/nav2/radials/selected"),
+                      1.0, 0.0, 360.0, true),
+    new FGAdjustAction(0, -SIX_W/2 + SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
+                      V("/radios/nav2/radials/selected"),
+                      -1.0, 0.0, 360.0, true),
+    new FGAdjustAction(1, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5,
+                      V("/radios/nav2/radials/selected"),
+                      5.0, 0.0, 360.0, true),
+    new FGAdjustAction(1, -SIX_W/2 + SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
+                      V("/radios/nav2/radials/selected"),
+                      -5.0, 0.0, 360.0, true)
   }, {
     {new MyTexturedLayer("compassBG"), {
       {TransData::Rotation, "/radios/nav2/radials/selected",
@@ -700,18 +694,19 @@ InstrumentData instruments[] =
   }},
 
   {"adf", SIX_X+(SIX_SPACING*3)+20, SIX_Y-(SIX_SPACING*2), SIX_W, SIX_W, {
-    {new FGAdjustAction(V("/radios/adf/rotation"),
-                       -1.0, 0.0, 360.0, true),
-       0, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5},
-    {new FGAdjustAction(V("/radios/adf/rotation"),
-                       1.0, 0.0, 360.0, true),
-       0, -SIX_W/2 + SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5},
-    {new FGAdjustAction(V("/radios/adf/rotation"),
-                       -5.0, 0.0, 360.0, true),
-       1, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5},
-    {new FGAdjustAction(V("/radios/adf/rotation"),
-                       5.0, 0.0, 360.0, true),
-       1, -SIX_W/2 + SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5}
+    new FGAdjustAction(0, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5,
+                      V("/radios/adf/rotation"),
+                      -1.0, 0.0, 360.0, true),
+    new FGAdjustAction(0, -SIX_W/2 + SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
+                      V("/radios/adf/rotation"),
+                      1.0, 0.0, 360.0, true),
+    new FGAdjustAction(1, -SIX_W/2, -SIX_W/2, SIX_W/10, SIX_W/5,
+                      V("/radios/adf/rotation"),
+                      -5.0, 0.0, 360.0, true),
+       
+    new FGAdjustAction(1, -SIX_W/2 + SIX_W/10, -SIX_W/2, SIX_W/10, SIX_W/5,
+                      V("/radios/adf/rotation"),
+                      5.0, 0.0, 360.0, true)
   },{
     {new MyTexturedLayer("compassBG"), {
       {TransData::Rotation, "/radios/adf/rotation", 0.0, 360.0, 1.0, 0.0}
@@ -753,22 +748,27 @@ createNavCom1 (int x, int y)
 
                                // Use the button to swap standby and active
                                // NAV frequencies
-  inst->addAction(0, int(SIX_W * .375), -SIX_W/4, SIX_W/4, SIX_W/4,
-                 new FGSwapAction(V("/radios/nav1/frequencies/selected"),
+  inst->addAction(new FGSwapAction(0, int(SIX_W * .375),
+                                  -SIX_W/4, SIX_W/4, SIX_W/4,
+                                  V("/radios/nav1/frequencies/selected"),
                                   V("/radios/nav1/frequencies/standby")));
 
                                // 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(V("/radios/nav1/frequencies/standby"),
+  inst->addAction(new FGAdjustAction(0, SIX_W-SIX_W/4, -SIX_W/4,
+                                    SIX_W/8, SIX_W/4,
+                                    V("/radios/nav1/frequencies/standby"),
                                     -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(V("/radios/nav1/frequencies/standby"),
+  inst->addAction(new FGAdjustAction(0, SIX_W-SIX_W/8, -SIX_W/4,
+                                    SIX_W/8, SIX_W/4,
+                                    V("/radios/nav1/frequencies/standby"),
                                     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(V("/radios/nav1/frequencies/standby"),
+  inst->addAction(new FGAdjustAction(1, SIX_W-SIX_W/4, -SIX_W/4,
+                                    SIX_W/8, SIX_W/4,
+                                    V("/radios/nav1/frequencies/standby"),
                                     -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(V("/radios/nav1/frequencies/standby"),
+  inst->addAction(new FGAdjustAction(1, SIX_W-SIX_W/8, -SIX_W/4,
+                                    SIX_W/8, SIX_W/4,
+                                    V("/radios/nav1/frequencies/standby"),
                                     0.5, 108.0, 117.95, true));
 
                                // Layer 0: background
@@ -787,8 +787,12 @@ createNavCom1 (int x, int y)
   text->setPointSize(14);
   text->setColor(1.0, 0.5, 0.0);
   inst->addLayer(text);
-  inst->addTransformation(FGInstrumentLayer::XSHIFT, 3);
-  inst->addTransformation(FGInstrumentLayer::YSHIFT, 5);
+  inst->addTransformation
+    (new FGPanelTransformation(FGPanelTransformation::XSHIFT, 0,
+                              0.0, 0.0, 0.0, 3));
+  inst->addTransformation
+    (new FGPanelTransformation(FGPanelTransformation::YSHIFT, 0,
+                              0.0, 0.0, 0.0, 5));
 
   return inst;
 }
@@ -804,22 +808,22 @@ createNavCom2 (int x, int y)
 
                                // Use the button to swap standby and active
                                // NAV frequencies
-  inst->addAction(0, int(SIX_W * .375), -SIX_W/4, SIX_W/4, SIX_W/4,
-                 new FGSwapAction(V("/radios/nav2/frequencies/selected"),
+  inst->addAction(new FGSwapAction(0, int(SIX_W * .375), -SIX_W/4, SIX_W/4, SIX_W/4,
+                 V("/radios/nav2/frequencies/selected"),
                                   V("/radios/nav2/frequencies/standby")));
 
                                // 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(V("/radios/nav2/frequencies/standby"),
+  inst->addAction(new FGAdjustAction(0, SIX_W-SIX_W/4, -SIX_W/4, SIX_W/8, SIX_W/4,
+                 V("/radios/nav2/frequencies/standby"),
                                     -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(V("/radios/nav2/frequencies/standby"),
+  inst->addAction(new FGAdjustAction(0, SIX_W-SIX_W/8, -SIX_W/4, SIX_W/8, SIX_W/4,
+                 V("/radios/nav2/frequencies/standby"),
                                     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(V("/radios/nav2/frequencies/standby"),
+  inst->addAction(new FGAdjustAction(1, SIX_W-SIX_W/4, -SIX_W/4, SIX_W/8, SIX_W/4,
+                 V("/radios/nav2/frequencies/standby"),
                                     -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(V("/radios/nav2/frequencies/standby"),
+  inst->addAction(new FGAdjustAction(1, SIX_W-SIX_W/8, -SIX_W/4, SIX_W/8, SIX_W/4,
+                 V("/radios/nav2/frequencies/standby"),
                                     0.5, 108.0, 117.95, true));
 
                                // Layer 0: background
@@ -838,8 +842,12 @@ createNavCom2 (int x, int y)
   text->setPointSize(14);
   text->setColor(1.0, 0.5, 0.0);
   inst->addLayer(text);
-  inst->addTransformation(FGInstrumentLayer::XSHIFT, 3);
-  inst->addTransformation(FGInstrumentLayer::YSHIFT, 5);
+  inst->addTransformation
+    (new FGPanelTransformation(FGPanelTransformation::XSHIFT, 0,
+                              0.0, 0.0, 1.0, 3));
+  inst->addTransformation
+    (new FGPanelTransformation(FGPanelTransformation::YSHIFT, 0,
+                              0.0, 0.0, 1.0, 5));
 
   return inst;
 }
@@ -854,21 +862,21 @@ 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, int(SIX_W * 0.7), int(-SIX_W * 0.07),
+  inst->addAction(new FGAdjustAction(0, int(SIX_W * 0.7), int(-SIX_W * 0.07),
                  int(SIX_W * 0.09), int(SIX_W * 0.14),
-                 new FGAdjustAction(V("/radios/adf/frequencies/selected"),
+                 V("/radios/adf/frequencies/selected"),
                                     -1.0, 100.0, 1299, true));
-  inst->addAction(0, int(SIX_W * 0.79), int(-SIX_W * 0.07),
+  inst->addAction(new FGAdjustAction(0, int(SIX_W * 0.79), int(-SIX_W * 0.07),
                  int(SIX_W * 0.09), int(SIX_W * 0.14),
-                 new FGAdjustAction(V("/radios/adf/frequencies/selected"),
+                 V("/radios/adf/frequencies/selected"),
                                     1.0, 100.0, 1299, true));
-  inst->addAction(1, int(SIX_W * 0.7), int(-SIX_W * 0.07),
+  inst->addAction(new FGAdjustAction(1, int(SIX_W * 0.7), int(-SIX_W * 0.07),
                  int(SIX_W * 0.09), int(SIX_W * 0.14),
-                 new FGAdjustAction(V("/radios/adf/frequencies/selected"),
+                 V("/radios/adf/frequencies/selected"),
                                     -25.0, 100.0, 1299, true));
-  inst->addAction(1, int(SIX_W * 0.79), int(-SIX_W * 0.07),
+  inst->addAction(new FGAdjustAction(1, int(SIX_W * 0.79), int(-SIX_W * 0.07),
                  int(SIX_W * 0.09), int(SIX_W * 0.14),
-                 new FGAdjustAction(V("/radios/adf/frequencies/selected"),
+                 V("/radios/adf/frequencies/selected"),
                                     25.0, 100.0, 1299, true));
 
                                // Layer 0: background
@@ -883,7 +891,9 @@ createADFRadio (int x, int y)
   text->setPointSize(14);
   text->setColor(1.0, 0.5, 0.0);
   inst->addLayer(text);
-  inst->addTransformation(FGInstrumentLayer::XSHIFT, -SIX_W + 18);
+  inst->addTransformation
+    (new FGPanelTransformation(FGPanelTransformation::XSHIFT, 0,
+                              0.0, 0.0, 1.0, -SIX_W + 18));
 
   return inst;
 }
@@ -899,16 +909,16 @@ createAP (int x, int y)
   FGLayeredInstrument * inst = new FGLayeredInstrument(x, y, SIX_W*2, SIX_W/4);
 
                                // Action: select HDG button
-  inst->addAction(0, int(-SIX_W*0.6125), -SIX_W/16, SIX_W/4, SIX_W/8,
-                 new FGToggleAction(V("/autopilot/locks/heading")));
+  inst->addAction(new FGToggleAction(0, int(-SIX_W*0.6125), -SIX_W/16, SIX_W/4, SIX_W/8,
+                 V("/autopilot/locks/heading")));
 
                                // Action: select NAV button
-  inst->addAction(0, int(-SIX_W*0.3625), -SIX_W/16, SIX_W/4, SIX_W/8,
-                 new FGToggleAction(V("/autopilot/locks/nav1")));
+  inst->addAction(new FGToggleAction(0, int(-SIX_W*0.3625), -SIX_W/16, SIX_W/4, SIX_W/8,
+                 V("/autopilot/locks/nav1")));
 
                                // Action: select ALT button
-  inst->addAction(0, int(-SIX_W*0.1125), -SIX_W/16, SIX_W/4, SIX_W/8,
-                 new FGToggleAction(V("/autopilot/locks/altitude")));
+  inst->addAction(new FGToggleAction(0, int(-SIX_W*0.1125), -SIX_W/16, SIX_W/4, SIX_W/8,
+                 V("/autopilot/locks/altitude")));
 
                                // Layer: AP background
   inst->addLayer(tex["autopilotBG"], SIX_W*2, SIX_W/4);
@@ -919,14 +929,18 @@ createAP (int x, int y)
                      new FGTexturedLayer(tex["hdgButtonOn"], SIX_W/4, SIX_W/8),
                      new FGTexturedLayer(tex["hdgButtonOff"], SIX_W/4, SIX_W/8));
   inst->addLayer(sw);
-  inst->addTransformation(FGInstrumentLayer::XSHIFT, -SIX_W * 0.5);
+  inst->addTransformation
+    (new FGPanelTransformation(FGPanelTransformation::XSHIFT, 0,
+                              0.0, 0.0, 1.0, -SIX_W * 0.5));
 
                                // Display NAV button
   sw = new FGSwitchLayer(SIX_W/4, SIX_W/8, V("/autopilot/locks/nav1"),
                         new FGTexturedLayer(tex["navButtonOn"], SIX_W/4, SIX_W/8),
                         new FGTexturedLayer(tex["navButtonOff"], SIX_W/4, SIX_W/8));
   inst->addLayer(sw);
-  inst->addTransformation(FGInstrumentLayer::XSHIFT, -SIX_W * 0.25);
+  inst->addTransformation
+    (new FGPanelTransformation(FGPanelTransformation::XSHIFT, 0,
+                              0.0, 0.0, 1.0, -SIX_W * 0.25));
 
                                // Display ALT button
   sw = new FGSwitchLayer(SIX_W/4, SIX_W/8, V("/autopilot/locks/altitude"),
@@ -966,8 +980,12 @@ createDME (int x, int y)
                      text1, text2);
 
   inst->addLayer(sw);
-  inst->addTransformation(FGInstrumentLayer::XSHIFT, -20);
-  inst->addTransformation(FGInstrumentLayer::YSHIFT, -6);
+  inst->addTransformation
+    (new FGPanelTransformation(FGPanelTransformation::XSHIFT, 0,
+                              0.0, 0.0, 1.0, -20));
+  inst->addTransformation
+    (new FGPanelTransformation(FGPanelTransformation::YSHIFT, 0,
+                              0.0, 0.0, 1.0, -6));
 
   return inst;
 }
@@ -1002,10 +1020,8 @@ fgCreateSmallSinglePropPanel (int xpos, int ypos, int finx, int finy)
     FGLayeredInstrument * inst =
       new FGLayeredInstrument(gauge.x, gauge.y, gauge.w, gauge.h);
 
-    for (int j = 0; gauge.actions[j].action; j++) {
-      ActionData &action = gauge.actions[j];
-      inst->addAction(action.button, action.x, action.y, action.w, action.h,
-                     action.action);
+    for (int j = 0; gauge.actions[j]; j++) {
+      inst->addAction(gauge.actions[j]);
     }
 
     for (int j = 0; gauge.layers[j].layer; j++) {
@@ -1015,26 +1031,29 @@ fgCreateSmallSinglePropPanel (int xpos, int ypos, int finx, int finy)
 
       for (int k = 0; layer.transformations[k].type; k++) {
        TransData &trans = layer.transformations[k];
-       FGInstrumentLayer::transform_type type;
+       FGPanelTransformation::Type type;
        switch (trans.type) {
        case TransData::Rotation:
-         type = FGInstrumentLayer::ROTATION;
+         type = FGPanelTransformation::ROTATION;
          break;
        case TransData::XShift:
-         type = FGInstrumentLayer::XSHIFT;
+         type = FGPanelTransformation::XSHIFT;
          break;
        case TransData::YShift:
-         type = FGInstrumentLayer::YSHIFT;
+         type = FGPanelTransformation::YSHIFT;
          break;
        default:
          break;
        }
        if (trans.propName != 0) {
-         inst->addTransformation(type, V(trans.propName),
-                                 trans.min, trans.max,
-                                 trans.factor, trans.offset);
+         inst->addTransformation
+           (new FGPanelTransformation(type, V(trans.propName),
+                                      trans.min, trans.max,
+                                      trans.factor, trans.offset));
        } else {
-         inst->addTransformation(type, trans.offset);
+         inst->addTransformation
+           (new FGPanelTransformation(type, 0,
+                                      0.0, 0.0, 1.0, trans.offset));
        }
       }
 
index 2158a57ce41aefddfd4e6b1648ccea598513f23b..0022e05cb13d80a9f3f86c4ec2a3f9acf40da000 100644 (file)
@@ -44,5 +44,6 @@ libUIUCModel_a_SOURCES = \
                         uiuc_parsefile.cpp \
                         uiuc_recorder.cpp \
                         uiuc_warnings_errors.cpp \
-                        uiuc_wrapper.cpp \
+                        uiuc_wrapper.cpp
+
 INCLUDES += -I$(top_builddir)