]> git.mxchange.org Git - flightgear.git/commitdiff
Consolidate the different ReaderWriterOptions classes.
authorMathias Froehlich <Mathias.Froehlich@web.de>
Sat, 12 Nov 2011 18:45:20 +0000 (19:45 +0100)
committerMathias Froehlich <Mathias.Froehlich@web.de>
Sun, 13 Nov 2011 17:34:53 +0000 (18:34 +0100)
src/Airports/groundnetwork.cxx
src/Main/fgviewer.cxx
src/Scenery/tilemgr.cxx
src/Scenery/tilemgr.hxx
utils/fgviewer/fgviewer.cxx

index f817e30351f6935370094579b5a87b42acc64f4c..d722b86ab5428df4f465d25128a750ac44a01f19 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <math.h>
 #include <algorithm>
+#include <fstream>
 
 
 #include <osg/Geode>
index e7f46005b5e819bec44e63cae6db9fee4af18632..99bdd8e65319fac1a692fdd6c8437a0d530b2e00 100644 (file)
@@ -25,7 +25,7 @@
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/scene/material/EffectCullVisitor.hxx>
 #include <simgear/scene/material/matlib.hxx>
-#include <simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 #include <simgear/scene/tgdb/userdata.hxx>
 #include <simgear/scene/tgdb/TileEntry.hxx>
 #include <simgear/scene/model/ModelRegistry.hxx>
@@ -223,15 +223,14 @@ fgviewerMain(int argc, char** argv)
     // The file path list must be set in the registry.
     osgDB::Registry::instance()->getDataFilePathList() = filePathList;
 
-    SGReaderWriterBTGOptions* btgOptions = new SGReaderWriterBTGOptions;
-    btgOptions->getDatabasePathList() = filePathList;
-    btgOptions->setMatlib(globals->get_matlib());
-    btgOptions->setUseRandomObjects(fgGetBool("/sim/rendering/random-objects", false));
-    btgOptions->setUseRandomVegetation(fgGetBool("/sim/rendering/random-vegetation", false));
+    simgear::SGReaderWriterOptions* options = new simgear::SGReaderWriterOptions;
+    options->getDatabasePathList() = filePathList;
+    options->setMaterialLib(globals->get_matlib());
+    options->setPropertyNode(globals->get_props());
 
     // read the scene from the list of file specified command line args.
     osg::ref_ptr<osg::Node> loadedModel;
-    loadedModel = osgDB::readNodeFiles(dataFiles, btgOptions);
+    loadedModel = osgDB::readNodeFiles(dataFiles, options);
 
     // if no model has been successfully loaded report failure.
     if (!loadedModel.valid()) {
index bfd3c9de0a3d4da0fbb118a8626347d721de258b..363ea858b7a16c1ccac9a3096f0589bfcf12eec6 100644 (file)
@@ -35,7 +35,7 @@
 #include <simgear/debug/logstream.hxx>
 #include <simgear/structure/exception.hxx>
 #include <simgear/scene/model/modellib.hxx>
-#include <simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 #include <simgear/scene/tsync/terrasync.hxx>
 
 #include <Main/globals.hxx>
@@ -55,33 +55,11 @@ using simgear::TileEntry;
 using simgear::TileCache;
 
 
-// helper: listen to property changes affecting tile loading
-class LoaderPropertyWatcher : public SGPropertyChangeListener
-{
-public:
-    LoaderPropertyWatcher(FGTileMgr* pTileMgr) :
-        _pTileMgr(pTileMgr)
-    {
-    }
-
-    virtual void valueChanged(SGPropertyNode*)
-    {
-        _pTileMgr->configChanged();
-    }
-
-private:
-    FGTileMgr* _pTileMgr;
-};
-
-
 FGTileMgr::FGTileMgr():
     state( Start ),
     vis( 16000 ),
-    _terra_sync(NULL),
-    _propListener(new LoaderPropertyWatcher(this))
+    _terra_sync(NULL)
 {
-    _randomObjects = fgGetNode("/sim/rendering/random-objects", true);
-    _randomVegetation = fgGetNode("/sim/rendering/random-vegetation", true);
     _maxTileRangeM = fgGetNode("/sim/rendering/static-lod/bare", true);
 }
 
@@ -91,8 +69,6 @@ FGTileMgr::~FGTileMgr()
     // remove all nodes we might have left behind
     osg::Group* group = globals->get_scenery()->get_terrain_branch();
     group->removeChildren(0, group->getNumChildren());
-    delete _propListener;
-    _propListener = NULL;
     // clear OSG cache
     osgDB::Registry::instance()->clearObjectCache();
 }
@@ -102,12 +78,9 @@ FGTileMgr::~FGTileMgr()
 void FGTileMgr::init() {
     SG_LOG( SG_TERRAIN, SG_INFO, "Initializing Tile Manager subsystem." );
 
-    _options = new SGReaderWriterBTGOptions;
-    _options->setMatlib(globals->get_matlib());
-
-    _randomObjects.get()->addChangeListener(_propListener, false);
-    _randomVegetation.get()->addChangeListener(_propListener, false);
-    configChanged();
+    _options = new simgear::SGReaderWriterOptions;
+    _options->setMaterialLib(globals->get_matlib());
+    _options->setPropertyNode(globals->get_props());
 
     osgDB::FilePathList &fp = _options->getDatabasePathList();
     const string_list &sc = globals->get_fg_scenery();
@@ -153,12 +126,6 @@ void FGTileMgr::reinit()
     update(0.0);
 }
 
-void FGTileMgr::configChanged()
-{
-    _options->setUseRandomObjects(_randomObjects.get()->getBoolValue());
-    _options->setUseRandomVegetation(_randomVegetation.get()->getBoolValue());
-}
-
 /* schedule a tile for loading, keep request for given amount of time.
  * Returns true if tile is already loaded. */
 bool FGTileMgr::sched_tile( const SGBucket& b, double priority, bool current_view, double duration)
index 25e965a522554f4de0466490354d38ef92af90ad..7a51f161e16861ae5afac8e5d6c0bc86047feb1c 100644 (file)
@@ -31,8 +31,6 @@
 #include <simgear/scene/tgdb/TileEntry.hxx>
 #include <simgear/scene/tgdb/TileCache.hxx>
 
-class SGReaderWriterBTGOptions;
-
 namespace osg
 {
 class Node;
@@ -41,6 +39,7 @@ class Node;
 namespace simgear
 {
 class SGTerraSync;
+class SGReaderWriterOptions;
 }
 
 class FGTileMgr : public SGSubsystem, public simgear::ModelLoadHelper {
@@ -65,7 +64,7 @@ private:
     SGBucket previous_bucket;
     SGBucket current_bucket;
     SGBucket pending;
-    osg::ref_ptr<SGReaderWriterBTGOptions> _options;
+    osg::ref_ptr<simgear::SGReaderWriterOptions> _options;
 
     // x and y distance of tiles to load/draw
     float vis;
@@ -89,9 +88,6 @@ private:
     static void refresh_tile(void* tileMgr, long tileIndex);
 
     SGPropertyNode* _visibilityMeters;
-    SGPropertyChangeListener* _propListener;
-    SGPropertyNode_ptr _randomObjects;
-    SGPropertyNode_ptr _randomVegetation;
     SGPropertyNode_ptr _maxTileRangeM;
     
 public:
@@ -105,9 +101,6 @@ public:
 
     virtual void update(double dt);
 
-    // update loader configuration options
-    void configChanged();
-
     int schedule_tiles_at(const SGGeod& location, double rangeM);
 
 
index a09cdf781c10dfad742a389105499a0bdaa40f93..222bb9ded182c876355e59be079aa4baccf6d08b 100644 (file)
@@ -18,7 +18,7 @@
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/scene/material/EffectCullVisitor.hxx>
 #include <simgear/scene/material/matlib.hxx>
-#include <simgear/scene/tgdb/SGReaderWriterBTGOptions.hxx>
+#include <simgear/scene/util/SGReaderWriterOptions.hxx>
 #include <simgear/scene/tgdb/userdata.hxx>
 #include <simgear/scene/tgdb/TileEntry.hxx>
 #include <simgear/scene/model/ModelRegistry.hxx>
@@ -151,9 +151,10 @@ main(int argc, char** argv)
     // The file path list must be set in the registry.
     osgDB::Registry::instance()->getDataFilePathList() = filePathList;
 
-    SGReaderWriterBTGOptions* btgOptions = new SGReaderWriterBTGOptions;
-    btgOptions->getDatabasePathList() = filePathList;
-    btgOptions->setMatlib(ml);
+    simgear::SGReaderWriterOptions* options = new simgear::SGReaderWriterOptions;
+    options->getDatabasePathList() = filePathList;
+    options->setMaterialLib(ml);
+    options->setPropertyNode(props);
 
     // Here, all arguments are processed
     arguments.reportRemainingOptionsAsUnrecognized();
@@ -161,7 +162,7 @@ main(int argc, char** argv)
 
     // read the scene from the list of file specified command line args.
     osg::ref_ptr<osg::Node> loadedModel;
-    loadedModel = osgDB::readNodeFiles(arguments, btgOptions);
+    loadedModel = osgDB::readNodeFiles(arguments, options);
 
     // if no model has been successfully loaded report failure.
     if (!loadedModel.valid()) {