]> git.mxchange.org Git - flightgear.git/commitdiff
Work on the NavDisplay instrument.
authorJames Turner <zakalawe@mac.com>
Tue, 4 Oct 2011 07:58:09 +0000 (08:58 +0100)
committerJames Turner <zakalawe@mac.com>
Tue, 4 Oct 2011 07:58:09 +0000 (08:58 +0100)
src/Instrumentation/CMakeLists.txt
src/Instrumentation/NavDisplay.cxx
src/Instrumentation/instrument_mgr.cxx

index 96c11b51980d768d21855d7f77333269c1843e0f..f65da924a1ea8037749abbea0decea86bb9d38db 100644 (file)
@@ -1,42 +1,42 @@
 include(FlightGearComponent)
 
 set(SOURCES
-       adf.cxx
-       agradar.cxx
-       airspeed_indicator.cxx
-       altimeter.cxx
-       attitude_indicator.cxx
-       clock.cxx
-       dclgps.cxx
-       dme.cxx
-       gps.cxx
-       groundradar.cxx
-       gsdi.cxx
-       gyro.cxx
-       heading_indicator.cxx
-       heading_indicator_dg.cxx
-       heading_indicator_fg.cxx
-       inst_vertical_speed_indicator.cxx
-       instrument_mgr.cxx
-       kr_87.cxx
-       kt_70.cxx
-       mag_compass.cxx
-       marker_beacon.cxx
-       mk_viii.cxx
-       mrg.cxx
-       navradio.cxx
-       od_gauge.cxx
-       rad_alt.cxx
-       render_area_2d.cxx
-       rnav_waypt_controller.cxx
-       slip_skid_ball.cxx
-       tacan.cxx
-       tcas.cxx
-       transponder.cxx
-       turn_indicator.cxx
-       vertical_speed_indicator.cxx
-       wxradar.cxx
-       NavDisplay.cxx
+    adf.cxx
+    agradar.cxx
+    airspeed_indicator.cxx
+    altimeter.cxx
+    attitude_indicator.cxx
+    clock.cxx
+    dclgps.cxx
+    dme.cxx
+    gps.cxx
+    groundradar.cxx
+    gsdi.cxx
+    gyro.cxx
+    heading_indicator.cxx
+    heading_indicator_dg.cxx
+    heading_indicator_fg.cxx
+    inst_vertical_speed_indicator.cxx
+    instrument_mgr.cxx
+    kr_87.cxx
+    kt_70.cxx
+    mag_compass.cxx
+    marker_beacon.cxx
+    mk_viii.cxx
+    mrg.cxx
+    navradio.cxx
+    od_gauge.cxx
+    rad_alt.cxx
+    render_area_2d.cxx
+    rnav_waypt_controller.cxx
+    slip_skid_ball.cxx
+    tacan.cxx
+    tcas.cxx
+    transponder.cxx
+    turn_indicator.cxx
+    vertical_speed_indicator.cxx
+    wxradar.cxx
+    NavDisplay.cxx
     HUD/HUD.cxx
     HUD/HUD_dial.cxx
     HUD/HUD_gauge.cxx
@@ -64,7 +64,62 @@ set(SOURCES
     KLN89/kln89_page_usr.cxx
     KLN89/kln89_page_vor.cxx
     KLN89/kln89_page_alt.cxx
-       )
-       
-       
-flightgear_component(Instruments "${SOURCES}")
\ No newline at end of file
+    )
+
+set(HEADERS
+    adf.hxx
+    agradar.hxx
+    airspeed_indicator.hxx
+    altimeter.hxx
+    attitude_indicator.hxx
+    clock.hxx
+    dclgps.hxx
+    dme.hxx
+    gps.hxx
+    groundradar.hxx
+    gsdi.hxx
+    gyro.hxx
+    heading_indicator.hxx
+    heading_indicator_dg.hxx
+    heading_indicator_fg.hxx
+    inst_vertical_speed_indicator.hxx
+    instrument_mgr.hxx
+    kr_87.hxx
+    kt_70.hxx
+    mag_compass.hxx
+    marker_beacon.hxx
+    mk_viii.hxx
+    mrg.hxx
+    navradio.hxx
+    od_gauge.hxx
+    rad_alt.hxx
+    render_area_2d.hxx
+    rnav_waypt_controller.hxx
+    slip_skid_ball.hxx
+    tacan.hxx
+    tcas.hxx
+    transponder.hxx
+    turn_indicator.hxx
+    vertical_speed_indicator.hxx
+    wxradar.hxx
+    NavDisplay.hxx
+    HUD/HUD.hxx
+    KLN89/kln89.hxx
+    KLN89/kln89_page.hxx
+    KLN89/kln89_page_act.hxx
+    KLN89/kln89_page_apt.hxx
+    KLN89/kln89_page_cal.hxx
+    KLN89/kln89_page_dir.hxx
+    KLN89/kln89_page_fpl.hxx
+    KLN89/kln89_page_int.hxx
+    KLN89/kln89_page_nav.hxx
+    KLN89/kln89_page_ndb.hxx
+    KLN89/kln89_page_nrst.hxx
+    KLN89/kln89_page_oth.hxx
+    KLN89/kln89_page_set.hxx
+    KLN89/kln89_page_usr.hxx
+    KLN89/kln89_page_vor.hxx
+    KLN89/kln89_page_alt.hxx
+    )   
+    
+flightgear_component(Instruments "${SOURCES}" "${HEADERS}")
\ No newline at end of file
index 164fb40fd903eafbddb1a32f6336f9a5389e7ad8..64c490ca154ffffeb86228ce0101fa68fb87018b 100644 (file)
@@ -124,12 +124,12 @@ static string formatPropertyValue(SGPropertyNode* nd, const string& format)
 {
     assert(nd);
     static char buf[512];
-    if (format.find('d') >= 0) {
+    if (format.find('d') != string::npos) {
         ::snprintf(buf, 512, format.c_str(), nd->getIntValue());
         return buf;
     }
     
-    if (format.find('s') >= 0) {
+    if (format.find('s') != string::npos) {
         ::snprintf(buf, 512, format.c_str(), nd->getStringValue());
         return buf;
     }
@@ -150,7 +150,7 @@ static osg::Vec2 mult(const osg::Vec2& v, const osg::Matrixf& m)
 class SymbolDef
 {
 public:
-    void initFromNode(SGPropertyNode* node)
+    bool initFromNode(SGPropertyNode* node)
     {
         type = node->getStringValue("type");
         enable = sgReadCondition(fgGetNode("/"), node->getChild("enable"));
@@ -202,6 +202,8 @@ public:
             stretchV2 = node->getFloatValue("v2");
             stretchV3 = node->getFloatValue("v3");
         }
+      
+        return true;
     }
     
     SGCondition* enable;
@@ -279,27 +281,27 @@ public:
         assert(definition->hasText);
         string r;
         
-        int pos = 0;
+        size_t pos = 0;
         int lastPos = 0;
         
-        for (; pos < (int) definition->textTemplate.size();) {
+        for (; pos < definition->textTemplate.size();) {
             pos = definition->textTemplate.find('{', pos);
-            if (pos == -1) { // no more replacements
+          if (pos == string::npos) { // no more replacements
                 r.append(definition->textTemplate.substr(lastPos));
                 break;
             }
             
             r.append(definition->textTemplate.substr(lastPos, pos - lastPos));
             
-            int endReplacement = definition->textTemplate.find('}', pos+1);
+            size_t endReplacement = definition->textTemplate.find('}', pos+1);
             if (endReplacement <= pos) {
                 return "bad replacement";
             }
 
             string spec = definition->textTemplate.substr(pos + 1, endReplacement - (pos + 1));
         // look for formatter in spec
-            int colonPos = spec.find(':');
-            if (colonPos < 0) {
+            size_t colonPos = spec.find(':');
+          if (colonPos == string::npos) {
             // simple replacement
                 r.append(props->getStringValue(spec));
             } else {
@@ -343,6 +345,18 @@ NavDisplay::NavDisplay(SGPropertyNode *node) :
     INITFONT("color/alpha", 1, Float);
 #undef INITFONT
 
+    SGPropertyNode* symbolsNode = node->getNode("symbols");
+    SGPropertyNode* symbol;
+  
+    for (int i = 0; (symbol = symbolsNode->getChild("symbol", i)) != NULL; ++i) {
+        SymbolDef* def = new SymbolDef;
+        if (!def->initFromNode(symbol)) {
+          delete def;
+          continue;
+        }
+        
+        _rules.push_back(def);
+    } // of symbol definition parsing
 }
 
 
@@ -542,12 +556,8 @@ NavDisplay::updateFont()
         tpath = path;
     }
 
-#if (FG_OSG_VERSION >= 21000)
     osg::ref_ptr<osgDB::ReaderWriter::Options> fontOptions = new osgDB::ReaderWriter::Options("monochrome");
     osg::ref_ptr<osgText::Font> font = osgText::readFontFile(tpath.c_str(), fontOptions.get());
-#else
-    osg::ref_ptr<osgText::Font> font = osgText::readFontFile(tpath.c_str());
-#endif
 
     if (font != 0) {
         _font = font;
index 4ebda4fa1b1c7bf8d457d22abd456d75d0564cb8..9bdd1bd7a917f15ba574753efdfc1cbf2c081b3d 100644 (file)
@@ -81,13 +81,13 @@ void FGInstrumentMgr::init()
   try {
     readProperties( config.str(), config_props );
     if (!build(config_props)) {
-      throw sg_error(
+      throw sg_exception(
                     "Detected an internal inconsistency in the instrumentation\n"
                     "system specification file.  See earlier errors for details.");
     }
-  } catch (const sg_exception&) {
+  } catch (const sg_exception& e) {
     SG_LOG(SG_COCKPIT, SG_ALERT, "Failed to load instrumentation system model: "
-                    << config.str() );
+                    << config.str() << ":" << e.getFormattedMessage() );
   }