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;
}
}
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;
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)
{
}
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);
}
// 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)
{
}
// 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)
{
}
}
+\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.
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;
}
}
}
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.
{
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;
}
}
FGLayeredInstrument::~FGLayeredInstrument ()
{
- // FIXME: free layers
+ for (layer_list::iterator it = _layers.begin(); it != _layers.end(); it++) {
+ delete *it;
+ *it = 0;
+ }
}
void
}
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);
}
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;
}
}
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;
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;
}
}
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);
}
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();
}
#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;
+}
/**
fgReadPanel (istream &input)
{
SGPropertyList props;
- map<string,CroppedTexture> textures;
//
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);
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");
//
//
return panel;
}
+
+
+// end of panel_io.cxx
// Instruments.
////////////////////////////////////////////////////////////////////////
-struct ActionData
-{
- FGPanelAction * action;
- int button, x, y, w, h;
-};
-
struct TransData
{
enum Type {
{
const char * name;
int x, y, w, h;
- ActionData actions[16];
+ FGPanelAction * actions[16];
LayerData layers[16];
};
}},
{"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}
}},
}},
{"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",
}},
{"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",
}},
{"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}
// 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
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;
}
// 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
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;
}
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
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;
}
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);
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"),
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;
}
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++) {
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));
}
}