]> git.mxchange.org Git - flightgear.git/blobdiff - src/Cockpit/panel_io.cxx
Fixed an property tieing issue on sim reset.
[flightgear.git] / src / Cockpit / panel_io.cxx
index 6c624e2fce4fb48213f8f1a41e54c826f76a31f0..ecd6efd89a02c674463529642c5899e92bbb6ef2 100644 (file)
 #  include <config.h>
 #endif
 
-#ifdef HAVE_WINDOWS_H          
-#  include <windows.h>
-#endif
-
 #include <string.h>            // for strcmp()
 
 #include <simgear/compiler.h>
@@ -34,9 +30,9 @@
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/props/props.hxx>
 
-#include STL_IOSTREAM
-#include STL_FSTREAM
-#include STL_STRING
+#include <istream>
+#include <fstream>
+#include <string>
 
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
@@ -50,9 +46,9 @@
 //built-in layers
 #include "built_in/FGMagRibbon.hxx"
 
-SG_USING_STD(istream);
-SG_USING_STD(ifstream);
-SG_USING_STD(string);
+using std::istream;
+using std::ifstream;
+using std::string;
 
 
 \f
@@ -178,7 +174,7 @@ readAction (const SGPropertyNode * node, float w_scale, float h_scale)
   // button-less actions are fired initially
   if (!node->hasValue("w") || !node->hasValue("h")) {
     for (i = 0; i < bindings.size(); i++) {
-      FGBinding b(bindings[i]);
+      SGBinding b(bindings[i], globals->get_props());
       b.fire();
     }
     return 0;
@@ -198,7 +194,7 @@ readAction (const SGPropertyNode * node, float w_scale, float h_scale)
   SGPropertyNode * dest = fgGetNode("/sim/bindings/panel", true);
 
   for (i = 0; i < bindings.size(); i++) {
-    SG_LOG(SG_INPUT, SG_INFO, "Reading binding "
+    SG_LOG(SG_INPUT, SG_BULK, "Reading binding "
       << bindings[i]->getStringValue("command"));
 
     j = 0;
@@ -207,7 +203,7 @@ readAction (const SGPropertyNode * node, float w_scale, float h_scale)
 
     binding = dest->getChild("binding", j, true);
     copyProperties(bindings[i], binding);
-    action->addBinding(new FGBinding(binding), 0);
+    action->addBinding(new SGBinding(binding, globals->get_props()), 0);
   }
 
   if (node->hasChild("mod-up")) {
@@ -219,7 +215,7 @@ readAction (const SGPropertyNode * node, float w_scale, float h_scale)
 
       binding = dest->getChild("binding", j, true);
       copyProperties(bindings[i], binding);
-      action->addBinding(new FGBinding(binding), 1);
+      action->addBinding(new SGBinding(binding, globals->get_props()), 1);
     }
   }
 
@@ -264,7 +260,7 @@ readTransformation (const SGPropertyNode * node, float w_scale, float h_scale)
   SGPropertyNode * target = 0;
 
   if (type.empty()) {
-    SG_LOG( SG_COCKPIT, SG_INFO,
+    SG_LOG( SG_COCKPIT, SG_BULK,
             "No type supplied for transformation " << name
             << " assuming \"rotation\"" );
     type = "rotation";
@@ -286,22 +282,9 @@ readTransformation (const SGPropertyNode * node, float w_scale, float h_scale)
                                // Check for an interpolation table
   const SGPropertyNode * trans_table = node->getNode("interpolation");
   if (trans_table != 0) {
-    SG_LOG( SG_COCKPIT, SG_INFO, "Found interpolation table with "
-            << trans_table->nChildren() << "children" );
-    t->table = new SGInterpTable();
-    for(int i = 0; i < trans_table->nChildren(); i++) {
-      const SGPropertyNode * node = trans_table->getChild(i);
-      if (!strcmp(node->getName(), "entry")) {
-       double ind = node->getDoubleValue("ind", 0.0);
-       double dep = node->getDoubleValue("dep", 0.0);
-       SG_LOG( SG_COCKPIT, SG_INFO, "Adding interpolation entry "
-                << ind << "==>" << dep );
-       t->table->addEntry(ind, dep);
-      } else {
-       SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName()
-                << " in interpolation" );
-      }
-    }
+    SG_LOG( SG_COCKPIT, SG_DEBUG, "Found interpolation table with "
+            << trans_table->nChildren() << " children" );
+    t->table = new SGInterpTable(trans_table);
   } else {
     t->table = 0;
   }
@@ -447,7 +430,7 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale)
 
 
   if (type.empty()) {
-    SG_LOG( SG_COCKPIT, SG_INFO,
+    SG_LOG( SG_COCKPIT, SG_BULK,
             "No type supplied for layer " << name
             << " assuming \"texture\"" );
     type = "texture";
@@ -491,7 +474,7 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale)
     tlayer->setPointSize(pointSize);
 
                                // Set the font.
-    string fontName = node->getStringValue("font", "default");
+    string fontName = node->getStringValue("font", "Helvetica");
     tlayer->setFontName(fontName);
 
     const SGPropertyNode * chunk_group = node->getNode("chunks");
@@ -658,7 +641,6 @@ readInstrument (const SGPropertyNode * node)
   }
 
   readConditions(instrument, node);
-  SG_LOG( SG_COCKPIT, SG_DEBUG, "Done reading instrument " << name );
   return instrument;
 }
 
@@ -693,6 +675,8 @@ readPanel (const SGPropertyNode * root)
   if (!fgHasNode("/sim/panel/y-offset"))
     fgSetInt("/sim/panel/y-offset", root->getIntValue("y-offset", 0));
 
+  panel->setAutohide(root->getBoolValue("autohide", true));
+
   //
   // Assign the background texture, if any, or a bogus chequerboard.
   //
@@ -700,7 +684,6 @@ readPanel (const SGPropertyNode * root)
   if (bgTexture.empty())
     bgTexture = "FOO";
   panel->setBackground(FGTextureManager::createTexture(bgTexture.c_str()));
-  SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << bgTexture );
 
   //
   // Get multibackground if any...
@@ -708,49 +691,41 @@ readPanel (const SGPropertyNode * root)
   string mbgTexture = root->getStringValue("multibackground[0]");
   if (!mbgTexture.empty()) {
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 0);
-    SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[1]");
     if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 1);
-    SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[2]");
     if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 2);
-    SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[3]");
     if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 3);
-    SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[4]");
     if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 4);
-    SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[5]");
     if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 5);
-    SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[6]");
     if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 6);
-    SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[7]");
     if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 7);
-    SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
   }
   
@@ -759,7 +734,7 @@ readPanel (const SGPropertyNode * root)
   //
   // Create each instrument.
   //
-  SG_LOG( SG_COCKPIT, SG_INFO, "Reading panel instruments" );
+  SG_LOG( SG_COCKPIT, SG_DEBUG, "Reading panel instruments" );
   const SGPropertyNode * instrument_group = root->getChild("instruments");
   if (instrument_group != 0) {
     int nInstruments = instrument_group->nChildren();
@@ -769,10 +744,10 @@ readPanel (const SGPropertyNode * root)
         FGPanelInstrument * instrument = readInstrument(node);
         if (instrument != 0)
           panel->addInstrument(instrument);
-      } else if(!strcmp(node->getName(), "special-instrument")) {
+      } else if (!strcmp(node->getName(), "special-instrument")) {
         //cout << "Special instrument found in instruments section!\n";
         const string name = node->getStringValue("name");
-        if(name == "KLN89 GPS") {
+        if (name == "KLN89 GPS") {
           //cout << "Special instrument is KLN89\n";
           
           int x = node->getIntValue("x", -1);
@@ -799,12 +774,12 @@ readPanel (const SGPropertyNode * root)
             h = real_h;
           }
           
-          SG_LOG( SG_COCKPIT, SG_DEBUG, "Reading instrument " << name );
+          SG_LOG( SG_COCKPIT, SG_BULK, "Reading instrument " << name );
           
           // Warning - hardwired size!!!
           RenderArea2D* instrument = new RenderArea2D(158, 40, 158, 40, x, y);
           KLN89* gps = (KLN89*)globals->get_subsystem("kln89");
-                 if(gps == NULL) {
+                 if (gps == NULL) {
                          gps = new KLN89(instrument);
                          globals->add_subsystem("kln89", gps);
                  }
@@ -815,12 +790,12 @@ readPanel (const SGPropertyNode * root)
           SG_LOG( SG_COCKPIT, SG_WARN, "Unknown special instrument found" );
         }
       } else {
-        SG_LOG( SG_COCKPIT, SG_INFO, "Skipping " << node->getName()
+        SG_LOG( SG_COCKPIT, SG_WARN, "Skipping " << node->getName()
         << " in instruments section" );
       }
     }
   }
-  SG_LOG( SG_COCKPIT, SG_INFO, "Done reading panel instruments" );
+  SG_LOG( SG_COCKPIT, SG_BULK, "Done reading panel instruments" );
 
 
   //
@@ -864,10 +839,9 @@ fgReadPanel (istream &input)
 FGPanel *
 fgReadPanel (const string &relative_path)
 {
-  SGPath path(globals->get_fg_root());
-  path.append(relative_path);
+  SGPath path = globals->resolve_aircraft_path(relative_path);
   SGPropertyNode root;
-
+  
   try {
     readProperties(path.str(), &root);
   } catch (const sg_exception &e) {