Changeset 9890

Show
Ignore:
Timestamp:
03/10/09 18:27:39 (6 years ago)
Author:
robert
Message:

Completed support for automatic detection of plugin features.

Cleaned up debug out of various plugins to ensure a clean osgconv --formats.

Location:
OpenSceneGraph/trunk
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/include/osgDB/ReaderWriter

    r9887 r9890  
    236236                enum ReadStatus 
    237237                { 
     238                    NOT_IMPLEMENTED, //!< raad*() method not implemented in concreate ReaderWriter. 
    238239                    FILE_NOT_HANDLED, //!< File is not appropriate for this file reader, due to some incompatibility, but *not* a read error. 
    239240                    FILE_NOT_FOUND, //!< File could not be found or could not be read. 
     
    279280                bool loadedFromCache() const { return _status==FILE_LOADED_FROM_CACHE; } 
    280281                bool error() const { return _status==ERROR_IN_READING_FILE; } 
    281                 bool notHandled() const { return _status==FILE_NOT_HANDLED; } 
     282                bool notHandled() const { return _status==FILE_NOT_HANDLED || _status==NOT_IMPLEMENTED; } 
    282283                bool notFound() const { return _status==FILE_NOT_FOUND; } 
    283284 
     
    296297                enum WriteStatus 
    297298                { 
     299                    NOT_IMPLEMENTED, //!< write*() method not implemented in concreate ReaderWriter. 
    298300                    FILE_NOT_HANDLED, 
    299301                    FILE_SAVED, 
     
    313315                bool success() const { return _status==FILE_SAVED; } 
    314316                bool error() const { return _status==ERROR_IN_WRITING_FILE; } 
    315                 bool notHandled() const { return _status==FILE_NOT_HANDLED; } 
     317                bool notHandled() const { return _status==FILE_NOT_HANDLED || _status==NOT_IMPLEMENTED; } 
    316318 
    317319            protected: 
     
    329331 
    330332        /** open an archive for reading, writing, or to create an empty archive for writing to.*/  
    331         virtual ReadResult openArchive(const std::string& /*fileName*/,ArchiveStatus, unsigned int =4096, const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); } 
     333        virtual ReadResult openArchive(const std::string& /*fileName*/,ArchiveStatus, unsigned int =4096, const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); } 
    332334 
    333335        /** open an archive for reading.*/  
    334         virtual ReadResult openArchive(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); } 
    335  
    336         virtual ReadResult readObject(const std::string& /*fileName*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); } 
    337         virtual ReadResult readImage(const std::string& /*fileName*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); } 
    338         virtual ReadResult readHeightField(const std::string& /*fileName*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); } 
    339         virtual ReadResult readNode(const std::string& /*fileName*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); } 
    340         virtual ReadResult readShader(const std::string& /*fileName*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); } 
    341  
    342         virtual WriteResult writeObject(const osg::Object& /*obj*/,const std::string& /*fileName*/,const Options* =NULL) const {return WriteResult(WriteResult::FILE_NOT_HANDLED); } 
    343         virtual WriteResult writeImage(const osg::Image& /*image*/,const std::string& /*fileName*/,const Options* =NULL) const {return WriteResult(WriteResult::FILE_NOT_HANDLED); } 
    344         virtual WriteResult writeHeightField(const osg::HeightField& /*heightField*/,const std::string& /*fileName*/,const Options* =NULL) const {return WriteResult(WriteResult::FILE_NOT_HANDLED); } 
    345         virtual WriteResult writeNode(const osg::Node& /*node*/,const std::string& /*fileName*/,const Options* =NULL) const { return WriteResult(WriteResult::FILE_NOT_HANDLED); } 
    346         virtual WriteResult writeShader(const osg::Shader& /*shader*/,const std::string& /*fileName*/,const Options* =NULL) const {return WriteResult(WriteResult::FILE_NOT_HANDLED); } 
    347  
    348         virtual ReadResult readObject(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); } 
    349         virtual ReadResult readImage(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); } 
    350         virtual ReadResult readHeightField(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); } 
    351         virtual ReadResult readNode(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); } 
    352         virtual ReadResult readShader(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); } 
    353  
    354         virtual WriteResult writeObject(const osg::Object& /*obj*/,std::ostream& /*fout*/,const Options* =NULL) const { return WriteResult(WriteResult::FILE_NOT_HANDLED); } 
    355         virtual WriteResult writeImage(const osg::Image& /*image*/,std::ostream& /*fout*/,const Options* =NULL) const { return WriteResult(WriteResult::FILE_NOT_HANDLED); } 
    356         virtual WriteResult writeHeightField(const osg::HeightField& /*heightField*/,std::ostream& /*fout*/,const Options* =NULL) const { return WriteResult(WriteResult::FILE_NOT_HANDLED); } 
    357         virtual WriteResult writeNode(const osg::Node& /*node*/,std::ostream& /*fout*/,const Options* =NULL) const { return WriteResult(WriteResult::FILE_NOT_HANDLED); } 
    358         virtual WriteResult writeShader(const osg::Shader& /*shader*/,std::ostream& /*fout*/,const Options* =NULL) const { return WriteResult(WriteResult::FILE_NOT_HANDLED); } 
     336        virtual ReadResult openArchive(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); } 
     337 
     338        virtual ReadResult readObject(const std::string& /*fileName*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); } 
     339        virtual ReadResult readImage(const std::string& /*fileName*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); } 
     340        virtual ReadResult readHeightField(const std::string& /*fileName*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); } 
     341        virtual ReadResult readNode(const std::string& /*fileName*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); } 
     342        virtual ReadResult readShader(const std::string& /*fileName*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); } 
     343 
     344        virtual WriteResult writeObject(const osg::Object& /*obj*/,const std::string& /*fileName*/,const Options* =NULL) const {return WriteResult(WriteResult::NOT_IMPLEMENTED); } 
     345        virtual WriteResult writeImage(const osg::Image& /*image*/,const std::string& /*fileName*/,const Options* =NULL) const {return WriteResult(WriteResult::NOT_IMPLEMENTED); } 
     346        virtual WriteResult writeHeightField(const osg::HeightField& /*heightField*/,const std::string& /*fileName*/,const Options* =NULL) const {return WriteResult(WriteResult::NOT_IMPLEMENTED); } 
     347        virtual WriteResult writeNode(const osg::Node& /*node*/,const std::string& /*fileName*/,const Options* =NULL) const { return WriteResult(WriteResult::NOT_IMPLEMENTED); } 
     348        virtual WriteResult writeShader(const osg::Shader& /*shader*/,const std::string& /*fileName*/,const Options* =NULL) const {return WriteResult(WriteResult::NOT_IMPLEMENTED); } 
     349 
     350        virtual ReadResult readObject(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); } 
     351        virtual ReadResult readImage(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); } 
     352        virtual ReadResult readHeightField(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); } 
     353        virtual ReadResult readNode(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); } 
     354        virtual ReadResult readShader(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); } 
     355 
     356        virtual WriteResult writeObject(const osg::Object& /*obj*/,std::ostream& /*fout*/,const Options* =NULL) const { return WriteResult(WriteResult::NOT_IMPLEMENTED); } 
     357        virtual WriteResult writeImage(const osg::Image& /*image*/,std::ostream& /*fout*/,const Options* =NULL) const { return WriteResult(WriteResult::NOT_IMPLEMENTED); } 
     358        virtual WriteResult writeHeightField(const osg::HeightField& /*heightField*/,std::ostream& /*fout*/,const Options* =NULL) const { return WriteResult(WriteResult::NOT_IMPLEMENTED); } 
     359        virtual WriteResult writeNode(const osg::Node& /*node*/,std::ostream& /*fout*/,const Options* =NULL) const { return WriteResult(WriteResult::NOT_IMPLEMENTED); } 
     360        virtual WriteResult writeShader(const osg::Shader& /*shader*/,std::ostream& /*fout*/,const Options* =NULL) const { return WriteResult(WriteResult::NOT_IMPLEMENTED); } 
    359361 
    360362    protected: 
  • OpenSceneGraph/trunk/src/osgDB/ReaderWriter.cpp

    r9887 r9890  
    6464ReaderWriter::Features ReaderWriter::supportedFeatures() const 
    6565{ 
    66     Features features = FEATURE_ALL; 
    67     return features; 
     66    int features = FEATURE_NONE; 
     67    std::string dummyFilename; 
     68 
     69    if (readObject(dummyFilename,0).status()!=ReadResult::NOT_IMPLEMENTED) features |= FEATURE_READ_OBJECT; 
     70    if (readImage(dummyFilename,0).status()!=ReadResult::NOT_IMPLEMENTED) features |= FEATURE_READ_IMAGE; 
     71    if (readHeightField(dummyFilename,0).status()!=ReadResult::NOT_IMPLEMENTED) features |= FEATURE_READ_HEIGHT_FIELD; 
     72    if (readShader(dummyFilename,0).status()!=ReadResult::NOT_IMPLEMENTED) features |= FEATURE_READ_SHADER; 
     73    if (readNode(dummyFilename,0).status()!=ReadResult::NOT_IMPLEMENTED) features |= FEATURE_READ_NODE; 
     74 
     75    osg::ref_ptr<osg::Image> image = new osg::Image; 
     76    osg::ref_ptr<osg::HeightField> hf = new osg::HeightField; 
     77    osg::ref_ptr<osg::Shader> shader = new osg::Shader; 
     78    osg::ref_ptr<osg::Node> node = new osg::Node; 
     79 
     80    if (writeObject(*image, dummyFilename,0).status()!=WriteResult::NOT_IMPLEMENTED) features |= FEATURE_WRITE_OBJECT; 
     81    if (writeImage(*image,dummyFilename,0).status()!=WriteResult::NOT_IMPLEMENTED) features |= FEATURE_WRITE_IMAGE; 
     82    if (writeHeightField(*hf,dummyFilename,0).status()!=WriteResult::NOT_IMPLEMENTED) features |= FEATURE_WRITE_HEIGHT_FIELD; 
     83    if (writeShader(*shader,dummyFilename,0).status()!=WriteResult::NOT_IMPLEMENTED) features |= FEATURE_WRITE_SHADER; 
     84    if (writeNode(*node, dummyFilename,0).status()!=WriteResult::NOT_IMPLEMENTED) features |= FEATURE_WRITE_NODE; 
     85 
     86    return Features(features); 
    6887} 
    6988 
  • OpenSceneGraph/trunk/src/osgPlugins/OpenFlight/ReaderWriterFLT.cpp

    r9124 r9890  
    430430            if ( fileName.empty() ) 
    431431            { 
    432                 osg::notify( osg::FATAL ) << "fltexp: writeNode: empty file name" << std::endl; 
    433432                return WriteResult::FILE_NOT_HANDLED; 
    434433            } 
     434 
    435435            std::string ext = osgDB::getLowerCaseFileExtension( fileName ); 
    436436            if ( !acceptsExtension(ext) ) 
  • OpenSceneGraph/trunk/src/osgPlugins/gdal/ReaderWriterGDAL.cpp

    r8578 r9890  
    5959        virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options) const 
    6060        { 
     61            if (file.empty()) return ReadResult::FILE_NOT_FOUND; 
     62         
    6163            if (osgDB::equalCaseInsensitive(osgDB::getFileExtension(file),"gdal")) 
    6264            { 
     
    8284        virtual ReadResult readImage(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const 
    8385        { 
     86            if (fileName.empty()) return ReadResult::FILE_NOT_FOUND; 
     87         
    8488            if (osgDB::equalCaseInsensitive(osgDB::getFileExtension(fileName),"gdal")) 
    8589            { 
     
    9397        virtual ReadResult readHeightField(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const 
    9498        { 
     99            if (fileName.empty()) return ReadResult::FILE_NOT_FOUND; 
     100         
    95101            if (osgDB::equalCaseInsensitive(osgDB::getFileExtension(fileName),"gdal")) 
    96102            { 
  • OpenSceneGraph/trunk/src/osgPlugins/gecko/ReaderWriterUBrowser.cpp

    r9324 r9890  
    2626        ReaderWriterUBrowser() 
    2727        {         
    28              osg::notify(osg::NOTICE)<<"ReaderWriterUBrowser::ReaderWriterUBrowser()"<<std::endl; 
     28             osg::notify(osg::INFO)<<"ReaderWriterUBrowser::ReaderWriterUBrowser()"<<std::endl; 
    2929 
    3030             supportsExtension("gecko","browser image"); 
     
    4242             } 
    4343              
    44              osg::notify(osg::NOTICE)<<"ReaderWriterUBrowser::ReaderWriterUBrowser() done"<<std::endl; 
     44             osg::notify(osg::INFO)<<"ReaderWriterUBrowser::ReaderWriterUBrowser() done"<<std::endl; 
    4545        } 
    4646     
  • OpenSceneGraph/trunk/src/osgPlugins/gecko/UBrowser.cpp

    r9325 r9890  
    4747    _previousButtonMask(0) 
    4848{ 
    49     osg::notify(osg::NOTICE)<<"UBrowserManager::UBrowserManager()"<<std::endl; 
     49    osg::notify(osg::INFO)<<"UBrowserManager::UBrowserManager()"<<std::endl; 
    5050} 
    5151 
    5252UBrowserManager::~UBrowserManager() 
    5353{ 
    54     _thread->setDone(true); 
    55      
    56     while(_thread->isRunning())  
     54    if (_thread.valid()) 
    5755    { 
    58         OpenThreads::Thread::YieldCurrentThread(); 
    59     } 
    60  
    61     _thread = 0; 
     56        _thread->setDone(true); 
     57 
     58        while(_thread->isRunning())  
     59        { 
     60            OpenThreads::Thread::YieldCurrentThread(); 
     61        } 
     62 
     63        _thread = 0; 
     64    } 
    6265} 
    6366 
  • OpenSceneGraph/trunk/src/osgPlugins/ogr/ReaderWriterOGR.cpp

    r9812 r9890  
    110110    virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const 
    111111    { 
    112         osg::notify(osg::NOTICE)<<"OGR::readNode("<<file<<")"<<std::endl; 
     112        osg::notify(osg::INFO)<<"OGR::readNode("<<file<<")"<<std::endl; 
     113         
     114        if (file.empty()) return ReadResult::FILE_NOT_FOUND; 
    113115     
    114116        if (osgDB::equalCaseInsensitive(osgDB::getFileExtension(file),"ogr")) 
  • OpenSceneGraph/trunk/src/osgPlugins/stl/ReaderWriterSTL.cpp

    r9343 r9890  
    8585  public: 
    8686 
    87     CreateStlVisitor( std::string const & fout, const osgDB::ReaderWriter::Options* options = 0): osg::NodeVisitor( osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN ), counter(0), m_fout(fout), m_options(options) { 
    88       if (options && (options->getOptionString() == "separateFiles")) { 
    89     osg::notify(osg::INFO) << "ReaderWriterSTL::writeNode: Files are seperated written" << std::endl;                 
     87    CreateStlVisitor( std::string const & fout, const osgDB::ReaderWriter::Options* options = 0): osg::NodeVisitor( osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN ), counter(0), m_fout(fout), m_options(options) 
     88    { 
     89      if (options && (options->getOptionString() == "separateFiles")) 
     90      { 
     91        osg::notify(osg::INFO) << "ReaderWriterSTL::writeNode: Files are seperated written" << std::endl; 
    9092      } else { 
    91     m_f = new std::ofstream(m_fout.c_str());         
    92     *m_f << "solid " << counter << std::endl; 
     93        m_f = new std::ofstream(m_fout.c_str());         
     94        *m_f << "solid " << counter << std::endl; 
    9395      } 
    9496    }; 
     
    449451} 
    450452 
    451 osgDB::ReaderWriter::WriteResult ReaderWriterSTL::writeNode(const osg::Node& node,const std::string& fout, const Options* opts) const { 
    452   std::string ext = osgDB::getLowerCaseFileExtension(fout); 
    453   if (ext != "stl" ){ 
     453osgDB::ReaderWriter::WriteResult ReaderWriterSTL::writeNode(const osg::Node& node,const std::string& fileName, const Options* opts) const 
     454{ 
     455  if (fileName.empty()) return WriteResult::FILE_NOT_HANDLED; 
     456 
     457  std::string ext = osgDB::getLowerCaseFileExtension(fileName); 
     458  if (ext != "stl" ) 
     459  { 
    454460    // sta - extension implies STL-Binary... 
    455     osg::notify(osg::FATAL) << "ReaderWriterSTL::writeNode: Only STL-ASCII-files supported'" << std::endl; 
     461    osg::notify(osg::INFO) << "ReaderWriterSTL::writeNode: Only STL-ASCII-files supported'" << std::endl; 
    456462    return WriteResult::FILE_NOT_HANDLED; 
    457463  } 
    458464   
    459465  try { 
    460     CreateStlVisitor createStlVisitor( fout, opts ); 
     466    CreateStlVisitor createStlVisitor( fileName, opts ); 
    461467    const_cast<osg::Node&>(node).accept( createStlVisitor ); 
    462468  } catch(...) { 
  • OpenSceneGraph/trunk/src/osgWidget/Browser.cpp

    r9325 r9890  
    3131BrowserManager::BrowserManager() 
    3232{ 
    33     osg::notify(osg::NOTICE)<<"Constructing base BrowserManager"<<std::endl; 
     33    osg::notify(osg::INFO)<<"Constructing base BrowserManager"<<std::endl; 
    3434} 
    3535 
    3636BrowserManager::~BrowserManager() 
    3737{ 
    38     osg::notify(osg::NOTICE)<<"Destructing base BrowserManager"<<std::endl; 
     38    osg::notify(osg::INFO)<<"Destructing base BrowserManager"<<std::endl; 
    3939} 
    4040 
     
    4646BrowserImage* BrowserManager::createBrowserImage(const std::string& url, int width, int height) 
    4747{ 
    48     osg::notify(osg::NOTICE)<<"Cannot created browser"<<std::endl; 
     48    osg::notify(osg::NOTICE)<<"Cannot create browser"<<std::endl; 
    4949    return 0; 
    5050}