]> git.mxchange.org Git - flightgear.git/blobdiff - src/Cockpit/panel_io.cxx
Property patches from Frederic Bouvier:
[flightgear.git] / src / Cockpit / panel_io.cxx
index c5e87329116be108387cef62379552fb730dc28d..14f4358af25ecf966eddae722df9fc88ccfb7241 100644 (file)
@@ -48,6 +48,9 @@
 #include "steam.hxx"
 #include "panel_io.hxx"
 
+//built-in layers
+#include "built_in/FGMagRibbon.hxx"
+
 #if !defined (SG_HAVE_NATIVE_SGI_COMPILERS)
 SG_USING_STD(istream);
 SG_USING_STD(ifstream);
@@ -55,69 +58,6 @@ SG_USING_STD(ifstream);
 SG_USING_STD(string);
 
 
-\f
-////////////////////////////////////////////////////////////////////////
-// Built-in layer for the magnetic compass ribbon layer.
-//
-// TODO: move this out into a special directory for built-in
-// layers of various sorts.
-////////////////////////////////////////////////////////////////////////
-
-class FGMagRibbon : public FGTexturedLayer
-{
-public:
-  FGMagRibbon (int w, int h);
-  virtual ~FGMagRibbon () {}
-
-  virtual void draw ();
-};
-
-FGMagRibbon::FGMagRibbon (int w, int h)
-  : FGTexturedLayer(w, h)
-{
-  FGCroppedTexture texture("Aircraft/Instruments/Textures/compass-ribbon.rgb");
-  setTexture(texture);
-}
-
-void
-FGMagRibbon::draw ()
-{
-  double heading = FGSteam::get_MH_deg();
-  double xoffset, yoffset;
-
-  while (heading >= 360.0) {
-    heading -= 360.0;
-  }
-  while (heading < 0.0) {
-    heading += 360.0;
-  }
-
-  if (heading >= 60.0 && heading <= 180.0) {
-    xoffset = heading / 240.0;
-    yoffset = 0.75;
-  } else if (heading >= 150.0 && heading <= 270.0) {
-    xoffset = (heading - 90.0) / 240.0;
-    yoffset = 0.50;
-  } else if (heading >= 240.0 && heading <= 360.0) {
-    xoffset = (heading - 180.0) / 240.0;
-    yoffset = 0.25;
-  } else {
-    if (heading < 270.0)
-      heading += 360.0;
-    xoffset = (heading - 270.0) / 240.0;
-    yoffset = 0.0;
-  }
-
-  xoffset = 1.0 - xoffset;
-                               // Adjust to put the number in the centre
-  xoffset -= 0.25;
-
-  FGCroppedTexture &t = getTexture();
-  t.setCrop(xoffset, yoffset, xoffset + 0.5, yoffset + 0.25);
-  FGTexturedLayer::draw();
-}
-
-
 \f
 ////////////////////////////////////////////////////////////////////////
 // Read and construct a panel.
@@ -243,7 +183,7 @@ readAction (const SGPropertyNode * node, float w_scale, float h_scale)
 
   FGPanelAction * action = new FGPanelAction(button, x, y, w, h);
 
-  vector<const SGPropertyNode *>bindings = node->getChildren("binding");
+  vector<SGPropertyNode_ptr>bindings = node->getChildren("binding");
   for (unsigned int i = 0; i < bindings.size(); i++) {
     SG_LOG(SG_INPUT, SG_INFO, "Reading binding "
           << bindings[i]->getStringValue("command"));
@@ -290,7 +230,7 @@ readTransformation (const SGPropertyNode * node, float w_scale, float h_scale)
   string propName = node->getStringValue("property", "");
   SGPropertyNode * target = 0;
 
-  if (type == "") {
+  if (type.empty()) {
     SG_LOG( SG_COCKPIT, SG_ALERT,
             "No type supplied for transformation " << name
             << " assuming \"rotation\"" );
@@ -392,7 +332,7 @@ readTextChunk (const SGPropertyNode * node)
   string format = node->getStringValue("format");
 
                                // Default to literal text.
-  if (type == "") {
+  if (type.empty()) {
     SG_LOG( SG_COCKPIT, SG_INFO, "No type provided for text chunk " << name
             << " assuming \"literal\"");
     type = "literal";
@@ -467,7 +407,7 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale)
     h = int(h * h_scale);
 
 
-  if (type == "") {
+  if (type.empty()) {
     SG_LOG( SG_COCKPIT, SG_ALERT,
             "No type supplied for layer " << name
             << " assuming \"texture\"" );
@@ -550,7 +490,7 @@ readLayer (const SGPropertyNode * node, float w_scale, float h_scale)
       layer = new FGMagRibbon(w, h);
     }
 
-    else if (layerclass == "") {
+    else if (layerclass.empty()) {
       SG_LOG( SG_COCKPIT, SG_ALERT, "No class provided for built-in layer "
               << name );
       return 0;
@@ -717,7 +657,7 @@ readPanel (const SGPropertyNode * root)
   // Assign the background texture, if any, or a bogus chequerboard.
   //
   string bgTexture = root->getStringValue("background");
-  if (bgTexture == "")
+  if (bgTexture.empty())
     bgTexture = "FOO";
   panel->setBackground(FGTextureManager::createTexture(bgTexture.c_str()));
   SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << bgTexture );
@@ -731,43 +671,43 @@ readPanel (const SGPropertyNode * root)
     SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );
 
     mbgTexture = root->getStringValue("multibackground[1]");
-    if (mbgTexture == "")
+    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 == "")
+    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 == "")
+    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 == "")
+    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 == "")
+    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 == "")
+    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 == "")
+    if (mbgTexture.empty())
       mbgTexture = "FOO";
     panel->setMultiBackground(FGTextureManager::createTexture(mbgTexture.c_str()), 7);
     SG_LOG( SG_COCKPIT, SG_INFO, "Set background texture to " << mbgTexture );