Completed support for automatic detection of plugin features.
Cleaned up debug out of various plugins to ensure a clean osgconv --formats.
This commit is contained in:
parent
3ec2da76e8
commit
a0a06c8b2a
@ -235,6 +235,7 @@ class OSGDB_EXPORT ReaderWriter : public osg::Object
|
||||
|
||||
enum ReadStatus
|
||||
{
|
||||
NOT_IMPLEMENTED, //!< raad*() method not implemented in concreate ReaderWriter.
|
||||
FILE_NOT_HANDLED, //!< File is not appropriate for this file reader, due to some incompatibility, but *not* a read error.
|
||||
FILE_NOT_FOUND, //!< File could not be found or could not be read.
|
||||
FILE_LOADED, //!< File successfully found, loaded, and converted into osg.
|
||||
@ -278,7 +279,7 @@ class OSGDB_EXPORT ReaderWriter : public osg::Object
|
||||
bool success() const { return _status==FILE_LOADED || _status==FILE_LOADED_FROM_CACHE ; }
|
||||
bool loadedFromCache() const { return _status==FILE_LOADED_FROM_CACHE; }
|
||||
bool error() const { return _status==ERROR_IN_READING_FILE; }
|
||||
bool notHandled() const { return _status==FILE_NOT_HANDLED; }
|
||||
bool notHandled() const { return _status==FILE_NOT_HANDLED || _status==NOT_IMPLEMENTED; }
|
||||
bool notFound() const { return _status==FILE_NOT_FOUND; }
|
||||
|
||||
protected:
|
||||
@ -295,6 +296,7 @@ class OSGDB_EXPORT ReaderWriter : public osg::Object
|
||||
|
||||
enum WriteStatus
|
||||
{
|
||||
NOT_IMPLEMENTED, //!< write*() method not implemented in concreate ReaderWriter.
|
||||
FILE_NOT_HANDLED,
|
||||
FILE_SAVED,
|
||||
ERROR_IN_WRITING_FILE
|
||||
@ -312,7 +314,7 @@ class OSGDB_EXPORT ReaderWriter : public osg::Object
|
||||
WriteStatus status() const { return _status; }
|
||||
bool success() const { return _status==FILE_SAVED; }
|
||||
bool error() const { return _status==ERROR_IN_WRITING_FILE; }
|
||||
bool notHandled() const { return _status==FILE_NOT_HANDLED; }
|
||||
bool notHandled() const { return _status==FILE_NOT_HANDLED || _status==NOT_IMPLEMENTED; }
|
||||
|
||||
protected:
|
||||
|
||||
@ -328,34 +330,34 @@ class OSGDB_EXPORT ReaderWriter : public osg::Object
|
||||
};
|
||||
|
||||
/** open an archive for reading, writing, or to create an empty archive for writing to.*/
|
||||
virtual ReadResult openArchive(const std::string& /*fileName*/,ArchiveStatus, unsigned int =4096, const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); }
|
||||
virtual ReadResult openArchive(const std::string& /*fileName*/,ArchiveStatus, unsigned int =4096, const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); }
|
||||
|
||||
/** open an archive for reading.*/
|
||||
virtual ReadResult openArchive(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); }
|
||||
virtual ReadResult openArchive(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); }
|
||||
|
||||
virtual ReadResult readObject(const std::string& /*fileName*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); }
|
||||
virtual ReadResult readImage(const std::string& /*fileName*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); }
|
||||
virtual ReadResult readHeightField(const std::string& /*fileName*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); }
|
||||
virtual ReadResult readNode(const std::string& /*fileName*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); }
|
||||
virtual ReadResult readShader(const std::string& /*fileName*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); }
|
||||
virtual ReadResult readObject(const std::string& /*fileName*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); }
|
||||
virtual ReadResult readImage(const std::string& /*fileName*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); }
|
||||
virtual ReadResult readHeightField(const std::string& /*fileName*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); }
|
||||
virtual ReadResult readNode(const std::string& /*fileName*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); }
|
||||
virtual ReadResult readShader(const std::string& /*fileName*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); }
|
||||
|
||||
virtual WriteResult writeObject(const osg::Object& /*obj*/,const std::string& /*fileName*/,const Options* =NULL) const {return WriteResult(WriteResult::FILE_NOT_HANDLED); }
|
||||
virtual WriteResult writeImage(const osg::Image& /*image*/,const std::string& /*fileName*/,const Options* =NULL) const {return WriteResult(WriteResult::FILE_NOT_HANDLED); }
|
||||
virtual WriteResult writeHeightField(const osg::HeightField& /*heightField*/,const std::string& /*fileName*/,const Options* =NULL) const {return WriteResult(WriteResult::FILE_NOT_HANDLED); }
|
||||
virtual WriteResult writeNode(const osg::Node& /*node*/,const std::string& /*fileName*/,const Options* =NULL) const { return WriteResult(WriteResult::FILE_NOT_HANDLED); }
|
||||
virtual WriteResult writeShader(const osg::Shader& /*shader*/,const std::string& /*fileName*/,const Options* =NULL) const {return WriteResult(WriteResult::FILE_NOT_HANDLED); }
|
||||
virtual WriteResult writeObject(const osg::Object& /*obj*/,const std::string& /*fileName*/,const Options* =NULL) const {return WriteResult(WriteResult::NOT_IMPLEMENTED); }
|
||||
virtual WriteResult writeImage(const osg::Image& /*image*/,const std::string& /*fileName*/,const Options* =NULL) const {return WriteResult(WriteResult::NOT_IMPLEMENTED); }
|
||||
virtual WriteResult writeHeightField(const osg::HeightField& /*heightField*/,const std::string& /*fileName*/,const Options* =NULL) const {return WriteResult(WriteResult::NOT_IMPLEMENTED); }
|
||||
virtual WriteResult writeNode(const osg::Node& /*node*/,const std::string& /*fileName*/,const Options* =NULL) const { return WriteResult(WriteResult::NOT_IMPLEMENTED); }
|
||||
virtual WriteResult writeShader(const osg::Shader& /*shader*/,const std::string& /*fileName*/,const Options* =NULL) const {return WriteResult(WriteResult::NOT_IMPLEMENTED); }
|
||||
|
||||
virtual ReadResult readObject(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); }
|
||||
virtual ReadResult readImage(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); }
|
||||
virtual ReadResult readHeightField(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); }
|
||||
virtual ReadResult readNode(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); }
|
||||
virtual ReadResult readShader(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::FILE_NOT_HANDLED); }
|
||||
virtual ReadResult readObject(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); }
|
||||
virtual ReadResult readImage(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); }
|
||||
virtual ReadResult readHeightField(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); }
|
||||
virtual ReadResult readNode(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); }
|
||||
virtual ReadResult readShader(std::istream& /*fin*/,const Options* =NULL) const { return ReadResult(ReadResult::NOT_IMPLEMENTED); }
|
||||
|
||||
virtual WriteResult writeObject(const osg::Object& /*obj*/,std::ostream& /*fout*/,const Options* =NULL) const { return WriteResult(WriteResult::FILE_NOT_HANDLED); }
|
||||
virtual WriteResult writeImage(const osg::Image& /*image*/,std::ostream& /*fout*/,const Options* =NULL) const { return WriteResult(WriteResult::FILE_NOT_HANDLED); }
|
||||
virtual WriteResult writeHeightField(const osg::HeightField& /*heightField*/,std::ostream& /*fout*/,const Options* =NULL) const { return WriteResult(WriteResult::FILE_NOT_HANDLED); }
|
||||
virtual WriteResult writeNode(const osg::Node& /*node*/,std::ostream& /*fout*/,const Options* =NULL) const { return WriteResult(WriteResult::FILE_NOT_HANDLED); }
|
||||
virtual WriteResult writeShader(const osg::Shader& /*shader*/,std::ostream& /*fout*/,const Options* =NULL) const { return WriteResult(WriteResult::FILE_NOT_HANDLED); }
|
||||
virtual WriteResult writeObject(const osg::Object& /*obj*/,std::ostream& /*fout*/,const Options* =NULL) const { return WriteResult(WriteResult::NOT_IMPLEMENTED); }
|
||||
virtual WriteResult writeImage(const osg::Image& /*image*/,std::ostream& /*fout*/,const Options* =NULL) const { return WriteResult(WriteResult::NOT_IMPLEMENTED); }
|
||||
virtual WriteResult writeHeightField(const osg::HeightField& /*heightField*/,std::ostream& /*fout*/,const Options* =NULL) const { return WriteResult(WriteResult::NOT_IMPLEMENTED); }
|
||||
virtual WriteResult writeNode(const osg::Node& /*node*/,std::ostream& /*fout*/,const Options* =NULL) const { return WriteResult(WriteResult::NOT_IMPLEMENTED); }
|
||||
virtual WriteResult writeShader(const osg::Shader& /*shader*/,std::ostream& /*fout*/,const Options* =NULL) const { return WriteResult(WriteResult::NOT_IMPLEMENTED); }
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -63,8 +63,27 @@ void ReaderWriter::supportsOption(const std::string& fmt, const std::string& des
|
||||
|
||||
ReaderWriter::Features ReaderWriter::supportedFeatures() const
|
||||
{
|
||||
Features features = FEATURE_ALL;
|
||||
return features;
|
||||
int features = FEATURE_NONE;
|
||||
std::string dummyFilename;
|
||||
|
||||
if (readObject(dummyFilename,0).status()!=ReadResult::NOT_IMPLEMENTED) features |= FEATURE_READ_OBJECT;
|
||||
if (readImage(dummyFilename,0).status()!=ReadResult::NOT_IMPLEMENTED) features |= FEATURE_READ_IMAGE;
|
||||
if (readHeightField(dummyFilename,0).status()!=ReadResult::NOT_IMPLEMENTED) features |= FEATURE_READ_HEIGHT_FIELD;
|
||||
if (readShader(dummyFilename,0).status()!=ReadResult::NOT_IMPLEMENTED) features |= FEATURE_READ_SHADER;
|
||||
if (readNode(dummyFilename,0).status()!=ReadResult::NOT_IMPLEMENTED) features |= FEATURE_READ_NODE;
|
||||
|
||||
osg::ref_ptr<osg::Image> image = new osg::Image;
|
||||
osg::ref_ptr<osg::HeightField> hf = new osg::HeightField;
|
||||
osg::ref_ptr<osg::Shader> shader = new osg::Shader;
|
||||
osg::ref_ptr<osg::Node> node = new osg::Node;
|
||||
|
||||
if (writeObject(*image, dummyFilename,0).status()!=WriteResult::NOT_IMPLEMENTED) features |= FEATURE_WRITE_OBJECT;
|
||||
if (writeImage(*image,dummyFilename,0).status()!=WriteResult::NOT_IMPLEMENTED) features |= FEATURE_WRITE_IMAGE;
|
||||
if (writeHeightField(*hf,dummyFilename,0).status()!=WriteResult::NOT_IMPLEMENTED) features |= FEATURE_WRITE_HEIGHT_FIELD;
|
||||
if (writeShader(*shader,dummyFilename,0).status()!=WriteResult::NOT_IMPLEMENTED) features |= FEATURE_WRITE_SHADER;
|
||||
if (writeNode(*node, dummyFilename,0).status()!=WriteResult::NOT_IMPLEMENTED) features |= FEATURE_WRITE_NODE;
|
||||
|
||||
return Features(features);
|
||||
}
|
||||
|
||||
ReaderWriter::FeatureList ReaderWriter::featureAsString(ReaderWriter::Features feature)
|
||||
|
@ -429,9 +429,9 @@ class FLTReaderWriter : public ReaderWriter
|
||||
{
|
||||
if ( fileName.empty() )
|
||||
{
|
||||
osg::notify( osg::FATAL ) << "fltexp: writeNode: empty file name" << std::endl;
|
||||
return WriteResult::FILE_NOT_HANDLED;
|
||||
}
|
||||
|
||||
std::string ext = osgDB::getLowerCaseFileExtension( fileName );
|
||||
if ( !acceptsExtension(ext) )
|
||||
return WriteResult::FILE_NOT_HANDLED;
|
||||
|
@ -58,6 +58,8 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
|
||||
|
||||
virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options) const
|
||||
{
|
||||
if (file.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
if (osgDB::equalCaseInsensitive(osgDB::getFileExtension(file),"gdal"))
|
||||
{
|
||||
return readObject(osgDB::getNameLessExtension(file),options);
|
||||
@ -81,6 +83,8 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
|
||||
|
||||
virtual ReadResult readImage(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const
|
||||
{
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
if (osgDB::equalCaseInsensitive(osgDB::getFileExtension(fileName),"gdal"))
|
||||
{
|
||||
return readImage(osgDB::getNameLessExtension(fileName),options);
|
||||
@ -92,6 +96,8 @@ class ReaderWriterGDAL : public osgDB::ReaderWriter
|
||||
|
||||
virtual ReadResult readHeightField(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const
|
||||
{
|
||||
if (fileName.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
if (osgDB::equalCaseInsensitive(osgDB::getFileExtension(fileName),"gdal"))
|
||||
{
|
||||
return readHeightField(osgDB::getNameLessExtension(fileName),options);
|
||||
|
@ -25,7 +25,7 @@ class ReaderWriterUBrowser : public osgDB::ReaderWriter
|
||||
|
||||
ReaderWriterUBrowser()
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"ReaderWriterUBrowser::ReaderWriterUBrowser()"<<std::endl;
|
||||
osg::notify(osg::INFO)<<"ReaderWriterUBrowser::ReaderWriterUBrowser()"<<std::endl;
|
||||
|
||||
supportsExtension("gecko","browser image");
|
||||
supportsExtension("browser","browser image");
|
||||
@ -41,7 +41,7 @@ class ReaderWriterUBrowser : public osgDB::ReaderWriter
|
||||
osgWidget::BrowserManager::instance()->setApplication(previousManager->getApplication());
|
||||
}
|
||||
|
||||
osg::notify(osg::NOTICE)<<"ReaderWriterUBrowser::ReaderWriterUBrowser() done"<<std::endl;
|
||||
osg::notify(osg::INFO)<<"ReaderWriterUBrowser::ReaderWriterUBrowser() done"<<std::endl;
|
||||
}
|
||||
|
||||
virtual ~ReaderWriterUBrowser()
|
||||
|
@ -46,19 +46,22 @@ UBrowserManager::UBrowserManager():
|
||||
_nativeWindowHandle(0),
|
||||
_previousButtonMask(0)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"UBrowserManager::UBrowserManager()"<<std::endl;
|
||||
osg::notify(osg::INFO)<<"UBrowserManager::UBrowserManager()"<<std::endl;
|
||||
}
|
||||
|
||||
UBrowserManager::~UBrowserManager()
|
||||
{
|
||||
_thread->setDone(true);
|
||||
|
||||
while(_thread->isRunning())
|
||||
if (_thread.valid())
|
||||
{
|
||||
OpenThreads::Thread::YieldCurrentThread();
|
||||
}
|
||||
_thread->setDone(true);
|
||||
|
||||
_thread = 0;
|
||||
while(_thread->isRunning())
|
||||
{
|
||||
OpenThreads::Thread::YieldCurrentThread();
|
||||
}
|
||||
|
||||
_thread = 0;
|
||||
}
|
||||
}
|
||||
|
||||
osgWidget::BrowserImage* UBrowserManager::createBrowserImage(const std::string& url, int width, int height)
|
||||
|
@ -109,7 +109,9 @@ public:
|
||||
|
||||
virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"OGR::readNode("<<file<<")"<<std::endl;
|
||||
osg::notify(osg::INFO)<<"OGR::readNode("<<file<<")"<<std::endl;
|
||||
|
||||
if (file.empty()) return ReadResult::FILE_NOT_FOUND;
|
||||
|
||||
if (osgDB::equalCaseInsensitive(osgDB::getFileExtension(file),"ogr"))
|
||||
{
|
||||
|
@ -84,12 +84,14 @@ private:
|
||||
class CreateStlVisitor : public osg::NodeVisitor {
|
||||
public:
|
||||
|
||||
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) {
|
||||
if (options && (options->getOptionString() == "separateFiles")) {
|
||||
osg::notify(osg::INFO) << "ReaderWriterSTL::writeNode: Files are seperated written" << std::endl;
|
||||
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)
|
||||
{
|
||||
if (options && (options->getOptionString() == "separateFiles"))
|
||||
{
|
||||
osg::notify(osg::INFO) << "ReaderWriterSTL::writeNode: Files are seperated written" << std::endl;
|
||||
} else {
|
||||
m_f = new std::ofstream(m_fout.c_str());
|
||||
*m_f << "solid " << counter << std::endl;
|
||||
m_f = new std::ofstream(m_fout.c_str());
|
||||
*m_f << "solid " << counter << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
@ -448,16 +450,20 @@ bool ReaderWriterSTL::ReaderObject::readStlBinary(FILE* fp)
|
||||
return true;
|
||||
}
|
||||
|
||||
osgDB::ReaderWriter::WriteResult ReaderWriterSTL::writeNode(const osg::Node& node,const std::string& fout, const Options* opts) const {
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(fout);
|
||||
if (ext != "stl" ){
|
||||
osgDB::ReaderWriter::WriteResult ReaderWriterSTL::writeNode(const osg::Node& node,const std::string& fileName, const Options* opts) const
|
||||
{
|
||||
if (fileName.empty()) return WriteResult::FILE_NOT_HANDLED;
|
||||
|
||||
std::string ext = osgDB::getLowerCaseFileExtension(fileName);
|
||||
if (ext != "stl" )
|
||||
{
|
||||
// sta - extension implies STL-Binary...
|
||||
osg::notify(osg::FATAL) << "ReaderWriterSTL::writeNode: Only STL-ASCII-files supported'" << std::endl;
|
||||
osg::notify(osg::INFO) << "ReaderWriterSTL::writeNode: Only STL-ASCII-files supported'" << std::endl;
|
||||
return WriteResult::FILE_NOT_HANDLED;
|
||||
}
|
||||
|
||||
try {
|
||||
CreateStlVisitor createStlVisitor( fout, opts );
|
||||
CreateStlVisitor createStlVisitor( fileName, opts );
|
||||
const_cast<osg::Node&>(node).accept( createStlVisitor );
|
||||
} catch(...) {
|
||||
return WriteResult::ERROR_IN_WRITING_FILE;
|
||||
|
@ -30,12 +30,12 @@ osg::ref_ptr<BrowserManager>& BrowserManager::instance()
|
||||
|
||||
BrowserManager::BrowserManager()
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Constructing base BrowserManager"<<std::endl;
|
||||
osg::notify(osg::INFO)<<"Constructing base BrowserManager"<<std::endl;
|
||||
}
|
||||
|
||||
BrowserManager::~BrowserManager()
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Destructing base BrowserManager"<<std::endl;
|
||||
osg::notify(osg::INFO)<<"Destructing base BrowserManager"<<std::endl;
|
||||
}
|
||||
|
||||
void BrowserManager::init(const std::string& application)
|
||||
@ -45,7 +45,7 @@ void BrowserManager::init(const std::string& application)
|
||||
|
||||
BrowserImage* BrowserManager::createBrowserImage(const std::string& url, int width, int height)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Cannot created browser"<<std::endl;
|
||||
osg::notify(osg::NOTICE)<<"Cannot create browser"<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user