]> git.mxchange.org Git - flightgear.git/blobdiff - src/Cockpit/panel.cxx
Updates from David Megginson.
[flightgear.git] / src / Cockpit / panel.cxx
index 11370d7452ea70c783d1d68f5cbc1997844679de..6825dca4ea4aba53f27daac554c54399837725ed 100644 (file)
 #include <plib/fnt.h>
 
 #include <simgear/debug/logstream.hxx>
-#include <simgear/misc/fgpath.hxx>
+#include <simgear/misc/sg_path.hxx>
+
 #include <Main/globals.hxx>
+#include <Main/fg_props.hxx>
 #include <Objects/texload.h>
 #include <Time/light.hxx>
 
@@ -44,7 +46,8 @@
 bool
 fgPanelVisible ()
 {
-  return ((globals->get_options()->get_panel_status()) &&
+  return ((current_panel != 0) &&
+         (current_panel->getVisibility()) &&
          (globals->get_viewmgr()->get_current() == 0) &&
          (globals->get_current_view()->get_view_offset() == 0.0));
 }
@@ -63,7 +66,7 @@ FGTextureManager::createTexture (const string &relativePath)
   ssgTexture * texture = _textureMap[relativePath];
   if (texture == 0) {
     cerr << "Texture " << relativePath << " does not yet exist" << endl;
-    FGPath tpath(globals->get_options()->get_fg_root());
+    SGPath tpath(globals->get_fg_root());
     tpath.append(relativePath);
     texture = new ssgTexture((char *)tpath.c_str(), false, false);
     _textureMap[relativePath] = texture;
@@ -143,6 +146,7 @@ FGPanel::FGPanel (int window_x, int window_y, int window_w, int window_h)
  */
 FGPanel::~FGPanel ()
 {
+  unbind();
   for (instrument_list_type::iterator it = _instruments.begin();
        it != _instruments.end();
        it++) {
@@ -162,11 +166,45 @@ FGPanel::addInstrument (FGPanelInstrument * instrument)
 }
 
 
+/**
+ * Initialize the panel.
+ */
+void
+FGPanel::init ()
+{
+  // NO-OP
+}
+
+
+/**
+ * Bind panel properties.
+ */
+void
+FGPanel::bind ()
+{
+  fgTie("/sim/panel/visibility", &_visibility);
+  fgTie("/sim/panel/x-offset", &_x_offset);
+  fgTie("/sim/panel/y-offset", &_y_offset);
+}
+
+
+/**
+ * Unbind panel properties.
+ */
+void
+FGPanel::unbind ()
+{
+  fgUntie("/sim/panel/visibility");
+  fgUntie("/sim/panel/x-offset");
+  fgUntie("/sim/panel/y-offset");
+}
+
+
 /**
  * Update the panel.
  */
 void
-FGPanel::update () const
+FGPanel::update ()
 {
                                // Do nothing if the panel isn't visible.
   if (!fgPanelVisible())
@@ -200,7 +238,7 @@ FGPanel::update () const
   glEnable(GL_ALPHA_TEST);
   glEnable(GL_COLOR_MATERIAL);
   // glColor4f(1.0, 1.0, 1.0, 1.0);
-  if ( cur_light_params.sun_angle * RAD_TO_DEG < 95.0 ) {
+  if ( cur_light_params.sun_angle * SGD_RADIANS_TO_DEGREES < 95.0 ) {
       glColor4fv( cur_light_params.scene_diffuse );
   } else {
       glColor4f(0.7, 0.2, 0.2, 1.0);
@@ -305,8 +343,8 @@ FGPanel::doMouseAction (int button, int updown, int x, int y)
   }
 
                                // Scale for the real window size.
-  x = int(((float)x / globals->get_options()->get_xsize()) * _winw);
-  y = int(_winh - (((float)y / globals->get_options()->get_ysize())
+  x = int(((float)x / fgGetInt("/sim/startup/xsize")) * _winw);
+  y = int(_winh - (((float)y / fgGetInt("/sim/startup/ysize"))
                   * _winh));
 
                                // Adjust for offsets.
@@ -438,6 +476,7 @@ FGToggleAction::doAction ()
 ////////////////////////////////////////////////////////////////////////
 
 FGPanelTransformation::FGPanelTransformation ()
+  : table(0)
 {
 }
 
@@ -626,7 +665,11 @@ FGInstrumentLayer::transform () const
     } else if (val > t->max) {
       val = t->max;
     }
-    val = val * t->factor + t->offset;
+    if(t->table==0) {
+       val = val * t->factor + t->offset;
+    } else {
+       val = t->table->interpolate(val) * t->factor + t->offset;
+    }
 
     switch (t->type) {
     case FGPanelTransformation::XSHIFT:
@@ -680,7 +723,7 @@ FGTexturedLayer::draw ()
 
                                // From Curt: turn on the panel
                                // lights after sundown.
-  if ( cur_light_params.sun_angle * RAD_TO_DEG < 95.0 ) {
+  if ( cur_light_params.sun_angle * SGD_RADIANS_TO_DEGREES < 95.0 ) {
       glColor4fv( cur_light_params.scene_diffuse );
   } else {
       glColor4f(0.7, 0.2, 0.2, 1.0);