From 02b456bcfacc95fc7885f5ba58035e9b759dca4b Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 13 Jul 2008 22:18:59 +0000 Subject: [PATCH] Converted plugins to use the new supportsExtension()/supportsOptions/supportsProtocl() methods to help enable better querying of supported features --- src/osgDB/ReaderWriter.cpp | 6 +- src/osgPlugins/3dc/ReaderWriter3DC.cpp | 13 +- src/osgPlugins/3ds/ReaderWriter3DS.cpp | 3 +- src/osgPlugins/Inventor/ReaderWriterIV.cpp | 2 + src/osgPlugins/Inventor/ReaderWriterIV.h | 6 - .../OpenFlight/ReaderWriterATTR.cpp | 5 + src/osgPlugins/OpenFlight/ReaderWriterFLT.cpp | 19 ++- src/osgPlugins/bmp/ReaderWriterBMP.cpp | 7 +- src/osgPlugins/bsp/ReaderWriterQ3BSP.cpp | 10 +- src/osgPlugins/cfg/ReaderWriterCFG.cpp | 9 +- src/osgPlugins/curl/ReaderWriterCURL.cpp | 1 + src/osgPlugins/dae/ReaderWriterDAE.h | 6 +- src/osgPlugins/dds/ReaderWriterDDS.cpp | 11 +- src/osgPlugins/dw/ReaderWriterDW.cpp | 9 +- src/osgPlugins/dxf/ReaderWriterDXF.cpp | 9 +- src/osgPlugins/gdal/ReaderWriterGDAL.cpp | 8 +- src/osgPlugins/geo/ReaderWriterGEO.cpp | 7 + src/osgPlugins/gif/ReaderWriterGIF.cpp | 13 +- src/osgPlugins/glsl/ReaderWriterGLSL.cpp | 7 + src/osgPlugins/hdr/ReaderWriterHDR.cpp | 10 +- src/osgPlugins/jp2/ReaderWriterJP2.cpp | 9 +- src/osgPlugins/jpeg/ReaderWriterJPEG.cpp | 10 +- src/osgPlugins/logo/ReaderWriterLOGO.cpp | 8 +- src/osgPlugins/lwo/ReaderWriterLWO.cpp | 12 +- src/osgPlugins/lws/ReaderWriterLWS.cpp | 5 +- src/osgPlugins/md2/ReaderWriterMD2.cpp | 9 +- src/osgPlugins/net/ReaderWriterNET.cpp | 7 +- .../normals/ReaderWriterNormals.cpp | 5 +- src/osgPlugins/obj/ReaderWriterOBJ.cpp | 8 +- src/osgPlugins/ogr/ReaderWriterOGR.cpp | 8 +- .../osgShadow/ReaderWriterOsgShadow.cpp | 11 +- .../osgTerrain/ReaderWriterOsgTerrain.cpp | 7 +- .../osgViewer/ReaderWriterOsgViewer.cpp | 14 +- src/osgPlugins/osga/ReaderWriterOSGA.cpp | 9 +- src/osgPlugins/osgtgz/ReaderWriterOSGTGZ.cpp | 8 +- src/osgPlugins/pfb/ReaderWriterPFB.cpp | 124 +++++++------- src/osgPlugins/pic/ReaderWriterPIC.cpp | 6 +- src/osgPlugins/png/ReaderWriterPNG.cpp | 6 +- src/osgPlugins/pnm/ReaderWriterPNM.cpp | 14 +- src/osgPlugins/quicktime/ReaderWriterQT.cpp | 27 ++++ src/osgPlugins/rot/ReaderWriterROT.cpp | 10 +- src/osgPlugins/scale/ReaderWriterSCALE.cpp | 5 +- src/osgPlugins/stl/ReaderWriterSTL.cpp | 14 +- src/osgPlugins/svg/ReaderWriterSVG.cpp | 152 +++++++++--------- src/osgPlugins/tga/ReaderWriterTGA.cpp | 7 +- src/osgPlugins/tgz/ReaderWriterTGZ.cpp | 4 +- src/osgPlugins/tiff/ReaderWriterTIFF.cpp | 7 + src/osgPlugins/trans/ReaderWriterTRANS.cpp | 10 +- src/osgPlugins/txf/ReaderWriterTXF.cpp | 8 +- src/osgPlugins/txp/ReaderWriterTXP.h | 11 +- src/osgPlugins/vrml/ReaderWriterVRML2.h | 8 +- src/osgPlugins/x/ReaderWriterDirectX.cpp | 10 +- src/osgPlugins/xine/ReaderWriterXine.cpp | 21 ++- src/osgPlugins/zip/ReaderWriterZIP.cpp | 9 +- 54 files changed, 421 insertions(+), 323 deletions(-) diff --git a/src/osgDB/ReaderWriter.cpp b/src/osgDB/ReaderWriter.cpp index 1647d7100..105e955f8 100644 --- a/src/osgDB/ReaderWriter.cpp +++ b/src/osgDB/ReaderWriter.cpp @@ -37,8 +37,12 @@ ReaderWriter::~ReaderWriter() bool ReaderWriter::acceptsExtension(const std::string& extension) const { + // check for an exact match std::string lowercase_ext = convertToLowerCase(extension); - return (_supportedExtensions.count(lowercase_ext)!=0); + if (_supportedExtensions.count(lowercase_ext)!=0) return true; + + // if plugin supports wildcard extension then passthrough all types + return (_supportedExtensions.count("*")!=0); } void ReaderWriter::supportsProtocol(const std::string& fmt, const std::string& description) diff --git a/src/osgPlugins/3dc/ReaderWriter3DC.cpp b/src/osgPlugins/3dc/ReaderWriter3DC.cpp index 59cf7adf3..98e48faaa 100644 --- a/src/osgPlugins/3dc/ReaderWriter3DC.cpp +++ b/src/osgPlugins/3dc/ReaderWriter3DC.cpp @@ -15,14 +15,15 @@ using namespace osg; class ReaderWriter3DC : public osgDB::ReaderWriter { public: + + ReaderWriter3DC() + { + supportsExtension("3dc","3DC point cloud format"); + supportsExtension("asc","3DC point cloud format"); + } + virtual const char* className() const { return "3DC point cloud reader"; } - virtual bool acceptsExtension(const std::string& extension) const - { - return osgDB::equalCaseInsensitive(extension,"3dc") || - osgDB::equalCaseInsensitive(extension,"asc"); - } - virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const { std::string ext = osgDB::getLowerCaseFileExtension(file); diff --git a/src/osgPlugins/3ds/ReaderWriter3DS.cpp b/src/osgPlugins/3ds/ReaderWriter3DS.cpp index 8029b2c60..9280ae649 100644 --- a/src/osgPlugins/3ds/ReaderWriter3DS.cpp +++ b/src/osgPlugins/3ds/ReaderWriter3DS.cpp @@ -91,7 +91,6 @@ class ReaderWriter3DS : public osgDB::ReaderWriter ReaderWriter3DS(); virtual const char* className() const { return "3DS Auto Studio Reader"; } - virtual bool acceptsExtension(const std::string& extension) const { return osgDB::equalCaseInsensitive(extension,"3ds"); } virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const; @@ -127,6 +126,8 @@ REGISTER_OSGPLUGIN(3ds, ReaderWriter3DS) ReaderWriter3DS::ReaderWriter3DS() { + supportsExtension("3ds","3D Studio model format"); + setByteOrder(); #if 0 diff --git a/src/osgPlugins/Inventor/ReaderWriterIV.cpp b/src/osgPlugins/Inventor/ReaderWriterIV.cpp index 0d01e973b..fa8e63754 100644 --- a/src/osgPlugins/Inventor/ReaderWriterIV.cpp +++ b/src/osgPlugins/Inventor/ReaderWriterIV.cpp @@ -27,6 +27,8 @@ REGISTER_OSGPLUGIN(Inventor, ReaderWriterIV) ReaderWriterIV::ReaderWriterIV() { + supportsExtension("iv","Inventor format"); + supportsExtension("wrl","VRML world file"); } // Read file and convert to OSG diff --git a/src/osgPlugins/Inventor/ReaderWriterIV.h b/src/osgPlugins/Inventor/ReaderWriterIV.h index a8af72948..84c83db2a 100644 --- a/src/osgPlugins/Inventor/ReaderWriterIV.h +++ b/src/osgPlugins/Inventor/ReaderWriterIV.h @@ -19,12 +19,6 @@ class ReaderWriterIV : public osgDB::ReaderWriter return osgDB::equalCaseInsensitive(extension, "iv") ? true : false; } - virtual bool acceptsExtension(const std::string& extension) const - { - return isInventorExtension(extension) ? true : - osgDB::equalCaseInsensitive(extension, "wrl") ? true : false; - } - virtual ReadResult readNode(const std::string& filename, const osgDB::ReaderWriter::Options *) const; diff --git a/src/osgPlugins/OpenFlight/ReaderWriterATTR.cpp b/src/osgPlugins/OpenFlight/ReaderWriterATTR.cpp index 64ff0d224..1b09a5d13 100644 --- a/src/osgPlugins/OpenFlight/ReaderWriterATTR.cpp +++ b/src/osgPlugins/OpenFlight/ReaderWriterATTR.cpp @@ -40,6 +40,11 @@ class ReaderWriterATTR : public osgDB::ReaderWriter { public: + ReaderWriterATTR() + { + supportsExtension("attr","OpenFlight texture attribute format"); + } + virtual const char* className() const { return "ATTR Image Attribute Reader/Writer"; } virtual bool acceptsExtension(const std::string& extension) const diff --git a/src/osgPlugins/OpenFlight/ReaderWriterFLT.cpp b/src/osgPlugins/OpenFlight/ReaderWriterFLT.cpp index 01372fed1..87a504bb2 100644 --- a/src/osgPlugins/OpenFlight/ReaderWriterFLT.cpp +++ b/src/osgPlugins/OpenFlight/ReaderWriterFLT.cpp @@ -120,7 +120,24 @@ class FLTReaderWriter : public ReaderWriter public: FLTReaderWriter() : _implicitPath( "." ) - {} + { + supportsExtension("flt","OpenFlight format"); + + supportsOption("clampToEdge",""); + supportsOption("keepExternalReferences",""); + supportsOption("preserveFace",""); + supportsOption("preserveObject",""); + supportsOption("dofAnimation",""); + supportsOption("billboardCenter",""); + supportsOption("noTextureAlphaForTransparancyBinning",""); + supportsOption("readObjectRecordData",""); + supportsOption("noUnitsConversion",""); + supportsOption("convertToFeet",""); + supportsOption("convertToInches",""); + supportsOption("convertToMeters",""); + supportsOption("convertToKilometers",""); + supportsOption("convertToNauticalMiles",""); + } virtual const char* className() const { return "FLT Reader/Writer"; } diff --git a/src/osgPlugins/bmp/ReaderWriterBMP.cpp b/src/osgPlugins/bmp/ReaderWriterBMP.cpp index 3ab650d6c..d1e360ab2 100644 --- a/src/osgPlugins/bmp/ReaderWriterBMP.cpp +++ b/src/osgPlugins/bmp/ReaderWriterBMP.cpp @@ -315,8 +315,13 @@ int *numComponents_ret) class ReaderWriterBMP : public osgDB::ReaderWriter { public: + + ReaderWriterBMP() + { + supportsExtension("bmp","BMP Image format"); + } + virtual const char* className() const { return "BMP Image Reader"; } - virtual bool acceptsExtension(const std::string& extension) const { return osgDB::equalCaseInsensitive(extension,"bmp"); } ReadResult readBMPStream(std::istream& fin) const { diff --git a/src/osgPlugins/bsp/ReaderWriterQ3BSP.cpp b/src/osgPlugins/bsp/ReaderWriterQ3BSP.cpp index ec133a466..695c15edc 100644 --- a/src/osgPlugins/bsp/ReaderWriterQ3BSP.cpp +++ b/src/osgPlugins/bsp/ReaderWriterQ3BSP.cpp @@ -22,18 +22,16 @@ class ReaderWriterQ3BSP: public osgDB::ReaderWriter { public: - ReaderWriterQ3BSP() { } + ReaderWriterQ3BSP() + { + supportsExtension("bsp","Quake3 BSP model format"); + } virtual const char* className() const { return "Quake3 BSP Reader"; } - virtual bool acceptsExtension(const std::string& extension) const - { - return osgDB::equalCaseInsensitive(extension,"bsp"); - } - virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const; private: diff --git a/src/osgPlugins/cfg/ReaderWriterCFG.cpp b/src/osgPlugins/cfg/ReaderWriterCFG.cpp index 16bd2ff2a..3a5a33dac 100644 --- a/src/osgPlugins/cfg/ReaderWriterCFG.cpp +++ b/src/osgPlugins/cfg/ReaderWriterCFG.cpp @@ -189,12 +189,13 @@ class ReaderWriterProducerCFG : public osgDB::ReaderWriter { public: + ReaderWriterProducerCFG() + { + supportsExtension("cfg","Producer camera configuration file"); + } + virtual const char* className() { return "Producer cfg object reader"; } - virtual bool acceptsExtension(const std::string& extension) const - { - return osgDB::equalCaseInsensitive(extension, "cfg"); - } virtual ReadResult readObject(const std::string& fileName, const Options* options = NULL) const { diff --git a/src/osgPlugins/curl/ReaderWriterCURL.cpp b/src/osgPlugins/curl/ReaderWriterCURL.cpp index 24f9e7fb3..8619607cd 100644 --- a/src/osgPlugins/curl/ReaderWriterCURL.cpp +++ b/src/osgPlugins/curl/ReaderWriterCURL.cpp @@ -144,6 +144,7 @@ ReaderWriterCURL::ReaderWriterCURL() { supportsProtocol("http","Read from http port using libcurl."); supportsExtension("curl","Psuedo file extension, used to select curl plugin."); + supportsExtension("*","Passes all read files to other plugins to handle actual model loading."); supportsOption("OSG_CURL_PROXY","Specify the http proxy."); supportsOption("OSG_CURL_PROXYPORT","Specify the http proxy oirt."); } diff --git a/src/osgPlugins/dae/ReaderWriterDAE.h b/src/osgPlugins/dae/ReaderWriterDAE.h index f9a4f5bcc..bf9884b7a 100644 --- a/src/osgPlugins/dae/ReaderWriterDAE.h +++ b/src/osgPlugins/dae/ReaderWriterDAE.h @@ -15,15 +15,11 @@ class ReaderWriterDAE : public osgDB::ReaderWriter public: ReaderWriterDAE() { + supportsExtension(EXTENSION_NAME,"COLLADA 1.4.x DAE format"); } const char* className() const { return "COLLADA 1.4.x DAE reader/writer"; } - bool acceptsExtension(const std::string& extension) const - { - return osgDB::equalCaseInsensitive( extension, EXTENSION_NAME ); - } - ReadResult readNode(const std::string&, const Options*) const; WriteResult writeNode(const osg::Node&, const std::string&, const Options*) const; diff --git a/src/osgPlugins/dds/ReaderWriterDDS.cpp b/src/osgPlugins/dds/ReaderWriterDDS.cpp index 9ceaf141f..cddf31b62 100644 --- a/src/osgPlugins/dds/ReaderWriterDDS.cpp +++ b/src/osgPlugins/dds/ReaderWriterDDS.cpp @@ -918,16 +918,17 @@ bool WriteDDSFile(const osg::Image *img, std::ostream& fout) class ReaderWriterDDS : public osgDB::ReaderWriter { public: + + ReaderWriterDDS() + { + supportsExtension("dds","DDS image format"); + } + virtual const char* className() const { return "DDS Image Reader/Writer"; } - virtual bool acceptsExtension(const std::string& extension) const - { - return osgDB::equalCaseInsensitive(extension,"dds"); - } - virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options) const { return readImage(file,options); diff --git a/src/osgPlugins/dw/ReaderWriterDW.cpp b/src/osgPlugins/dw/ReaderWriterDW.cpp index 201606559..63b4bf49b 100644 --- a/src/osgPlugins/dw/ReaderWriterDW.cpp +++ b/src/osgPlugins/dw/ReaderWriterDW.cpp @@ -792,12 +792,13 @@ void _dwobj::buildDrawable(Group *grp, const osgDB::ReaderWriter::Options *optio class ReaderWriterDW : public osgDB::ReaderWriter { public: - virtual const char* className() const { return "Design Workshop Database Reader"; } - - virtual bool acceptsExtension(const std::string& extension) const + + ReaderWriterDW() { - return osgDB::equalCaseInsensitive(extension,"dw"); + supportsExtension("dw","Designer Workbench model format"); } + + virtual const char* className() const { return "Design Workshop Database Reader"; } virtual ReadResult readNode(const std::string& file,const osgDB::ReaderWriter::Options* options) const { diff --git a/src/osgPlugins/dxf/ReaderWriterDXF.cpp b/src/osgPlugins/dxf/ReaderWriterDXF.cpp index ab29efca8..56f8f3058 100644 --- a/src/osgPlugins/dxf/ReaderWriterDXF.cpp +++ b/src/osgPlugins/dxf/ReaderWriterDXF.cpp @@ -30,11 +30,12 @@ using namespace std; class ReaderWriterdxf : public osgDB::ReaderWriter { public: - ReaderWriterdxf() { } - virtual const char* className() { return "Autodesk DXF Reader"; } - virtual bool acceptsExtension(const std::string& extension) const { - return osgDB::equalCaseInsensitive(extension,"dxf"); + ReaderWriterdxf() + { + supportsExtension("dxf","Autodesk DXF format"); } + + virtual const char* className() { return "Autodesk DXF Reader"; } virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options*) const; protected: }; diff --git a/src/osgPlugins/gdal/ReaderWriterGDAL.cpp b/src/osgPlugins/gdal/ReaderWriterGDAL.cpp index fa7044326..06df53b70 100644 --- a/src/osgPlugins/gdal/ReaderWriterGDAL.cpp +++ b/src/osgPlugins/gdal/ReaderWriterGDAL.cpp @@ -48,11 +48,13 @@ float Hue_2_RGB( float v1, float v2, float vH ) class ReaderWriterGDAL : public osgDB::ReaderWriter { public: - virtual const char* className() const { return "GDAL Image Reader"; } - virtual bool acceptsExtension(const std::string& extension) const + + ReaderWriterGDAL() { - return osgDB::equalCaseInsensitive(extension,"gdal") || osgDB::equalCaseInsensitive(extension,"gdal"); + supportsExtension("gdal","GDAL Image reader"); } + + virtual const char* className() const { return "GDAL Image Reader"; } virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options) const { diff --git a/src/osgPlugins/geo/ReaderWriterGEO.cpp b/src/osgPlugins/geo/ReaderWriterGEO.cpp index b36c181a3..76140d5bf 100644 --- a/src/osgPlugins/geo/ReaderWriterGEO.cpp +++ b/src/osgPlugins/geo/ReaderWriterGEO.cpp @@ -2202,6 +2202,13 @@ void geoField::readfile(std::ifstream &fin, const uint id) { // is part of a rec class ReaderWriterGEO : public osgDB::ReaderWriter { public: + + ReaderWriterGEO() + { + supportsExtension("gem","CarbonGraphics Geo model format"); + supportsExtension("geo","CarbonGraphics Geo model format"); + } + virtual const char* className() const { return "GEO Reader/Writer"; } virtual bool acceptsExtension(const std::string& extension) const diff --git a/src/osgPlugins/gif/ReaderWriterGIF.cpp b/src/osgPlugins/gif/ReaderWriterGIF.cpp index 2d6abebd4..7b25c5b5a 100644 --- a/src/osgPlugins/gif/ReaderWriterGIF.cpp +++ b/src/osgPlugins/gif/ReaderWriterGIF.cpp @@ -67,7 +67,10 @@ public: GifImageStream() : _length(0), _dataNum(0), _frameNum(0), _done(false), _currentLength(0), _multiplier(1.0), - osg::ImageStream() { _status=PAUSED; } + osg::ImageStream() + { + _status=PAUSED; + } virtual Object* clone() const { return new GifImageStream; } virtual bool isSameKindAs( const Object* obj ) const { return dynamic_cast(obj) != NULL; } @@ -559,11 +562,13 @@ GifImageStream** obj) class ReaderWriterGIF : public osgDB::ReaderWriter { public: - virtual const char* className() const { return "GIF Image Reader"; } - virtual bool acceptsExtension(const std::string& extension) const + + ReaderWriterGIF() { - return osgDB::equalCaseInsensitive(extension,"gif"); + supportsExtension("gif","GIF Image format"); } + + virtual const char* className() const { return "GIF Image Reader"; } ReadResult readGIFStream(std::istream& fin) const { diff --git a/src/osgPlugins/glsl/ReaderWriterGLSL.cpp b/src/osgPlugins/glsl/ReaderWriterGLSL.cpp index 5912fc25b..cdbb81461 100644 --- a/src/osgPlugins/glsl/ReaderWriterGLSL.cpp +++ b/src/osgPlugins/glsl/ReaderWriterGLSL.cpp @@ -10,6 +10,13 @@ class ReaderWriterGLSL : public osgDB::ReaderWriter { public: + + ReaderWriterGLSL() + { + supportsExtension("gl","OpenGL Shader Language format"); + supportsExtension("glsl","OpenGL Shader Language format"); + } + virtual const char* className() const { return "GLSL Shader Reader"; } virtual bool acceptsExtension(const std::string& extension) const { diff --git a/src/osgPlugins/hdr/ReaderWriterHDR.cpp b/src/osgPlugins/hdr/ReaderWriterHDR.cpp index a8ad9bdd0..98d5698bd 100644 --- a/src/osgPlugins/hdr/ReaderWriterHDR.cpp +++ b/src/osgPlugins/hdr/ReaderWriterHDR.cpp @@ -47,8 +47,16 @@ class ReaderWriterHDR : public osgDB::ReaderWriter { public: + ReaderWriterHDR() + { + supportsExtension("hdr","High Dynamic Range image format"); + supportsOption("RGBMUL",""); + supportsOption("RGB8",""); + supportsOption("RAW",""); + supportsOption("YFLIP",""); + supportsOption("NO_YFLIP",""); + } virtual const char* className() { return "HDR Image Reader"; } - virtual bool acceptsExtension(const std::string &extension) const { return osgDB::equalCaseInsensitive(extension, "hdr"); } virtual ReadResult readImage(const std::string &_file, const osgDB::ReaderWriter::Options *_opts) const { diff --git a/src/osgPlugins/jp2/ReaderWriterJP2.cpp b/src/osgPlugins/jp2/ReaderWriterJP2.cpp index 9f2568743..1bf770cd4 100644 --- a/src/osgPlugins/jp2/ReaderWriterJP2.cpp +++ b/src/osgPlugins/jp2/ReaderWriterJP2.cpp @@ -174,6 +174,9 @@ class ReaderWriterJP2 : public osgDB::ReaderWriter ReaderWriterJP2() { + supportsExtension("jp2","Jpeg2000 image format"); + supportsExtension("jpc","Jpeg2000 image format"); + // little dance here to get around warnings created by jas_image_strtofmt use of char* rather than const char* // as a parameted and modern compilers deprecating "jp2" string being treated as char*. char* jp2 = strdup("jp2"); @@ -183,12 +186,6 @@ class ReaderWriterJP2 : public osgDB::ReaderWriter virtual const char* className() const { return "RGB Image Reader/Writer"; } - virtual bool acceptsExtension(const std::string& extension) const - { - return osgDB::equalCaseInsensitive(extension,"jp2") || - osgDB::equalCaseInsensitive(extension,"jpc"); - } - virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options) const { return readImage(file,options); diff --git a/src/osgPlugins/jpeg/ReaderWriterJPEG.cpp b/src/osgPlugins/jpeg/ReaderWriterJPEG.cpp index b12a7d531..1d6b6605c 100644 --- a/src/osgPlugins/jpeg/ReaderWriterJPEG.cpp +++ b/src/osgPlugins/jpeg/ReaderWriterJPEG.cpp @@ -612,6 +612,7 @@ int *numComponents_ret) class ReaderWriterJPEG : public osgDB::ReaderWriter { + WriteResult::WriteStatus write_JPEG_file (std::ostream &fout,int image_width,int image_height,JSAMPLE* image_buffer,int quality = 100) const { if ( (image_width == 0) || (image_height == 0) ) @@ -740,12 +741,15 @@ class ReaderWriterJPEG : public osgDB::ReaderWriter return 100; } public: - virtual const char* className() const { return "JPEG Image Reader/Writer"; } - virtual bool acceptsExtension(const std::string& extension) const + + ReaderWriterJPEG() { - return osgDB::equalCaseInsensitive(extension,"jpeg") || osgDB::equalCaseInsensitive(extension,"jpg"); + supportsExtension("jpeg","JPEG image format"); + supportsExtension("jpg","JPEG image format"); } + virtual const char* className() const { return "JPEG Image Reader/Writer"; } + ReadResult readJPGStream(std::istream& fin) const { unsigned char *imageData = NULL; diff --git a/src/osgPlugins/logo/ReaderWriterLOGO.cpp b/src/osgPlugins/logo/ReaderWriterLOGO.cpp index cb57d26f5..c894ebbf7 100644 --- a/src/osgPlugins/logo/ReaderWriterLOGO.cpp +++ b/src/osgPlugins/logo/ReaderWriterLOGO.cpp @@ -195,12 +195,12 @@ class Logos: public osg::Drawable class LOGOReaderWriter : public osgDB::ReaderWriter { public: - virtual const char* className() const { return "Logo Database Reader/Writer"; } - - virtual bool acceptsExtension(const std::string& extension) const + LOGOReaderWriter() { - return osgDB::equalCaseInsensitive(extension,"logo"); + supportsExtension("logo","Ascii logo placement format"); } + + virtual const char* className() const { return "Logo Database Reader/Writer"; } virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const { diff --git a/src/osgPlugins/lwo/ReaderWriterLWO.cpp b/src/osgPlugins/lwo/ReaderWriterLWO.cpp index 1e0a34fa9..36c4ee3e0 100644 --- a/src/osgPlugins/lwo/ReaderWriterLWO.cpp +++ b/src/osgPlugins/lwo/ReaderWriterLWO.cpp @@ -46,12 +46,14 @@ class ReaderWriterLWO : public osgDB::ReaderWriter { public: - ReaderWriterLWO() { } - - virtual const char* className() const { return "Lightwave Object Reader"; } - virtual bool acceptsExtension(const std::string& extension) const { - return osgDB::equalCaseInsensitive(extension,"lwo") || osgDB::equalCaseInsensitive(extension,"lw") || osgDB::equalCaseInsensitive(extension,"geo"); + ReaderWriterLWO() + { + supportsExtension("lwo","Lightwave object format"); + supportsExtension("lw","Lightwave object format"); + supportsExtension("geo","Lightwave geometry format"); } + + virtual const char* className() const { return "Lightwave Object Reader"; } virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const { diff --git a/src/osgPlugins/lws/ReaderWriterLWS.cpp b/src/osgPlugins/lws/ReaderWriterLWS.cpp index 2b3ebecbb..372426d65 100644 --- a/src/osgPlugins/lws/ReaderWriterLWS.cpp +++ b/src/osgPlugins/lws/ReaderWriterLWS.cpp @@ -23,7 +23,10 @@ class ReaderWriterLWS : public osgDB::ReaderWriter { public: - ReaderWriterLWS() {} + ReaderWriterLWS() + { + supportsExtension("lws","Lightwave scene format"); + } virtual const char* className() const { return "ReaderWriterLWS"; } diff --git a/src/osgPlugins/md2/ReaderWriterMD2.cpp b/src/osgPlugins/md2/ReaderWriterMD2.cpp index 18c6b8559..4d818116a 100644 --- a/src/osgPlugins/md2/ReaderWriterMD2.cpp +++ b/src/osgPlugins/md2/ReaderWriterMD2.cpp @@ -43,16 +43,15 @@ static osg::Node* load_md2 (const char *filename, const osgDB::ReaderWriter::Opt class ReaderWriterMD2 : public osgDB::ReaderWriter { public: - ReaderWriterMD2 () { } + ReaderWriterMD2 () + { + supportsExtension("md2","Quak2 MD format"); + } virtual const char* className () const { return "Quake MD2 Reader"; } - virtual bool acceptsExtension (const std::string& extension) const { - return osgDB::equalCaseInsensitive (extension, "md2") ? true : false; - } - virtual ReadResult readNode (const std::string& filename, const osgDB::ReaderWriter::Options* options) const; }; diff --git a/src/osgPlugins/net/ReaderWriterNET.cpp b/src/osgPlugins/net/ReaderWriterNET.cpp index 626d14fd0..7256f765c 100644 --- a/src/osgPlugins/net/ReaderWriterNET.cpp +++ b/src/osgPlugins/net/ReaderWriterNET.cpp @@ -86,7 +86,12 @@ class NetReader : public osgDB::ReaderWriter { public: - NetReader() {} + NetReader() + { + supportsProtocol("http","HTTP Protocol"); + supportsExtension("net","Psuedo loader extension for selecting NET plugin"); + supportsExtension("*","Passes all file loading onto other plugins"); + } virtual const char* className() const { return "HTTP Protocol Model Reader"; } diff --git a/src/osgPlugins/normals/ReaderWriterNormals.cpp b/src/osgPlugins/normals/ReaderWriterNormals.cpp index 240c71e06..a4d8199a7 100644 --- a/src/osgPlugins/normals/ReaderWriterNormals.cpp +++ b/src/osgPlugins/normals/ReaderWriterNormals.cpp @@ -13,7 +13,10 @@ class NormalsReader: public osgDB::ReaderWriter { public: - NormalsReader() {} + NormalsReader() + { + supportsExtension("normals","Normals Pseudo loader"); + } virtual const char* className() { return "Normals Pseudo Loader"; } diff --git a/src/osgPlugins/obj/ReaderWriterOBJ.cpp b/src/osgPlugins/obj/ReaderWriterOBJ.cpp index 403ccd780..35e059a75 100644 --- a/src/osgPlugins/obj/ReaderWriterOBJ.cpp +++ b/src/osgPlugins/obj/ReaderWriterOBJ.cpp @@ -52,12 +52,12 @@ class ReaderWriterOBJ : public osgDB::ReaderWriter { public: - ReaderWriterOBJ():_fixBlackMaterials(true) {} + ReaderWriterOBJ():_fixBlackMaterials(true) + { + supportsExtension("obj","Alias Wavefront OBJ format"); + } virtual const char* className() const { return "Wavefront OBJ Reader"; } - virtual bool acceptsExtension(const std::string& extension) const { - return osgDB::equalCaseInsensitive(extension,"obj"); - } virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const; diff --git a/src/osgPlugins/ogr/ReaderWriterOGR.cpp b/src/osgPlugins/ogr/ReaderWriterOGR.cpp index ffc2768cc..d616b3667 100644 --- a/src/osgPlugins/ogr/ReaderWriterOGR.cpp +++ b/src/osgPlugins/ogr/ReaderWriterOGR.cpp @@ -81,13 +81,11 @@ class ReaderWriterOGR : public osgDB::ReaderWriter { public: - ReaderWriterOGR() {} - virtual const char* className() const { return "OGR file reader"; } - virtual bool acceptsExtension(const std::string& extension) const + ReaderWriterOGR() { - return osgDB::equalCaseInsensitive(extension,"ogr") || - osgDB::equalCaseInsensitive(extension,"ogr"); + supportsExtension("ogr","OGR file reader"); } + virtual const char* className() const { return "OGR file reader"; } virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const { diff --git a/src/osgPlugins/osgShadow/ReaderWriterOsgShadow.cpp b/src/osgPlugins/osgShadow/ReaderWriterOsgShadow.cpp index c55ec9a47..3ceb96ed8 100644 --- a/src/osgPlugins/osgShadow/ReaderWriterOsgShadow.cpp +++ b/src/osgPlugins/osgShadow/ReaderWriterOsgShadow.cpp @@ -72,15 +72,14 @@ static bool getFilenameAndParams(const std::string& input, std::string& filename class ReaderWriterOsgShadow : public osgDB::ReaderWriter { public: - ReaderWriterOsgShadow() { } + ReaderWriterOsgShadow() + { + supportsExtension("osgShadow","OpenSceneGraph osgShadow extension to .osg ascii format"); + supportsExtension("shadow","OpenSceneGraph osgShadow extension pseudo loader"); + } virtual const char* className() const { return "osgShadow pseudo-loader"; } - virtual bool acceptsExtension(const std::string& extension) const - { - return osgDB::equalCaseInsensitive( extension, "osgShadow" ) || osgDB::equalCaseInsensitive( extension, "shadow" ) ; - } - virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const { std::string ext = osgDB::getLowerCaseFileExtension(fileName); diff --git a/src/osgPlugins/osgTerrain/ReaderWriterOsgTerrain.cpp b/src/osgPlugins/osgTerrain/ReaderWriterOsgTerrain.cpp index dd44730b8..d6d98fa19 100644 --- a/src/osgPlugins/osgTerrain/ReaderWriterOsgTerrain.cpp +++ b/src/osgPlugins/osgTerrain/ReaderWriterOsgTerrain.cpp @@ -19,15 +19,12 @@ class ReaderWriterTerrain : public osgDB::ReaderWriter ReaderWriterTerrain() { + supportsExtension("osgTerrain","OpenSceneGraph terrain extension to .osg ascii format"); + supportsExtension("terrain","OpenSceneGraph terrain ascii format"); } virtual const char* className() const { return "Terrain ReaderWriter"; } - virtual bool acceptsExtension(const std::string& extension) const - { - return osgDB::equalCaseInsensitive( extension, "osgTerrain" ) || osgDB::equalCaseInsensitive(extension,"terrain"); - } - virtual osgDB::ReaderWriter::ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* opt) const { std::string ext = osgDB::getLowerCaseFileExtension(file); diff --git a/src/osgPlugins/osgViewer/ReaderWriterOsgViewer.cpp b/src/osgPlugins/osgViewer/ReaderWriterOsgViewer.cpp index 3d36e8feb..1f90a38dd 100644 --- a/src/osgPlugins/osgViewer/ReaderWriterOsgViewer.cpp +++ b/src/osgPlugins/osgViewer/ReaderWriterOsgViewer.cpp @@ -23,16 +23,16 @@ class ReaderWriterOsgViewer : public osgDB::ReaderWriter { public: - ReaderWriterOsgViewer() { } + ReaderWriterOsgViewer() + { + supportsExtension("osgviewer","OpenSceneGraph viewer configuration format"); + supportsExtension("view","OpenSceneGraph viewer configuration format"); + supportsOption("precision","Set the floating point precision of output"); + supportsOption("OutputTextureFiles","Output texture image to file"); + } virtual const char* className() const { return "osgViewer configuration loader"; } - virtual bool acceptsExtension(const std::string& extension) const - { - return osgDB::equalCaseInsensitive( extension, "osgviewer" ) || osgDB::equalCaseInsensitive( extension, "view" ) ; - } - - void setPrecision(osgDB::Output& fout, const osgDB::ReaderWriter::Options* options) const { if (options) diff --git a/src/osgPlugins/osga/ReaderWriterOSGA.cpp b/src/osgPlugins/osga/ReaderWriterOSGA.cpp index e59ac7b47..bcb2e3dc4 100644 --- a/src/osgPlugins/osga/ReaderWriterOSGA.cpp +++ b/src/osgPlugins/osga/ReaderWriterOSGA.cpp @@ -9,13 +9,12 @@ class ReaderWriterOSGA : public osgDB::ReaderWriter { public: - ReaderWriterOSGA() { } + ReaderWriterOSGA() + { + supportsExtension("osga","OpenSceneGraph Archive format"); + } virtual const char* className() const { return "OpenSceneGraph Archive Reader/Writer"; } - virtual bool acceptsExtension(const std::string& extension) const - { - return osgDB::equalCaseInsensitive(extension,"osga"); - } virtual ReadResult openArchive(const std::string& file,ArchiveStatus status, unsigned int indexBlockSize = 4096, const Options* options=NULL) const { diff --git a/src/osgPlugins/osgtgz/ReaderWriterOSGTGZ.cpp b/src/osgPlugins/osgtgz/ReaderWriterOSGTGZ.cpp index 7f44f95c5..6b6da4748 100644 --- a/src/osgPlugins/osgtgz/ReaderWriterOSGTGZ.cpp +++ b/src/osgPlugins/osgtgz/ReaderWriterOSGTGZ.cpp @@ -24,11 +24,13 @@ using namespace osg; class sgReaderWriterOSGTGZ : public osgDB::ReaderWriter { public: - virtual const char* className() const { return "OSGTGZ Database Reader/Writer"; } - virtual bool acceptsExtension(const std::string& extension) const + + sgReaderWriterOSGTGZ() { - return osgDB::equalCaseInsensitive(extension,"osgtgz"); + supportsExtension("osgtgz","OpenSceneGraph tar gzid'd archive format"); } + + virtual const char* className() const { return "OSGTGZ Database Reader/Writer"; } virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const { diff --git a/src/osgPlugins/pfb/ReaderWriterPFB.cpp b/src/osgPlugins/pfb/ReaderWriterPFB.cpp index 9cee2366a..9c1ab0b52 100644 --- a/src/osgPlugins/pfb/ReaderWriterPFB.cpp +++ b/src/osgPlugins/pfb/ReaderWriterPFB.cpp @@ -31,70 +31,6 @@ class ReaderWriterPFB : public osgDB::ReaderWriter void initPerformer(); virtual const char* className() const { return "Performer Reader/Writer"; } - virtual bool acceptsExtension(const std::string& extension) const - { - return - osgDB::equalCaseInsensitive(extension,"3ds") ? true : - osgDB::equalCaseInsensitive(extension,"arcinfo") ? true : - osgDB::equalCaseInsensitive(extension,"bin") ? true : - osgDB::equalCaseInsensitive(extension,"bpoly") ? true : - osgDB::equalCaseInsensitive(extension,"bw") ? true : - osgDB::equalCaseInsensitive(extension,"byu") ? true : - osgDB::equalCaseInsensitive(extension,"closest") ? true : - osgDB::equalCaseInsensitive(extension,"csb") ? true : - osgDB::equalCaseInsensitive(extension,"ct") ? true : - osgDB::equalCaseInsensitive(extension,"dem") ? true : - osgDB::equalCaseInsensitive(extension,"doublerot") ? true : - osgDB::equalCaseInsensitive(extension,"doublescale") ? true : - osgDB::equalCaseInsensitive(extension,"doubletrans") ? true : - osgDB::equalCaseInsensitive(extension,"dted") ? true : - osgDB::equalCaseInsensitive(extension,"dwb") ? true : - osgDB::equalCaseInsensitive(extension,"dxf") ? true : - osgDB::equalCaseInsensitive(extension,"evt") ? true : - osgDB::equalCaseInsensitive(extension,"flt") ? true : - osgDB::equalCaseInsensitive(extension,"gds") ? true : - osgDB::equalCaseInsensitive(extension,"gfo") ? true : - osgDB::equalCaseInsensitive(extension,"im") ? true : - osgDB::equalCaseInsensitive(extension,"irtp") ? true : - osgDB::equalCaseInsensitive(extension,"iv20") ? true : - osgDB::equalCaseInsensitive(extension,"iv") ? true : - osgDB::equalCaseInsensitive(extension,"lodfix") ? true : - osgDB::equalCaseInsensitive(extension,"lsa") ? true : - osgDB::equalCaseInsensitive(extension,"lsb") ? true : - osgDB::equalCaseInsensitive(extension,"medit") ? true : - osgDB::equalCaseInsensitive(extension,"m") ? true : - osgDB::equalCaseInsensitive(extension,"nff") ? true : - osgDB::equalCaseInsensitive(extension,"obj") ? true : - osgDB::equalCaseInsensitive(extension,"pegg") ? true : - osgDB::equalCaseInsensitive(extension,"pfb") ? true : - osgDB::equalCaseInsensitive(extension,"pfs") ? true : - osgDB::equalCaseInsensitive(extension,"phd") ? true : - osgDB::equalCaseInsensitive(extension,"poly") ? true : - osgDB::equalCaseInsensitive(extension,"post") ? true : - osgDB::equalCaseInsensitive(extension,"proc") ? true : - osgDB::equalCaseInsensitive(extension,"projtex") ? true : - osgDB::equalCaseInsensitive(extension,"pts") ? true : - osgDB::equalCaseInsensitive(extension,"rot") ? true : - osgDB::equalCaseInsensitive(extension,"scale") ? true : - osgDB::equalCaseInsensitive(extension,"sgf") ? true : - osgDB::equalCaseInsensitive(extension,"sgo") ? true : - osgDB::equalCaseInsensitive(extension,"so") ? true : - osgDB::equalCaseInsensitive(extension,"spf") ? true : - osgDB::equalCaseInsensitive(extension,"spherepatch3") ? true : - osgDB::equalCaseInsensitive(extension,"spherepatch") ? true : - osgDB::equalCaseInsensitive(extension,"sphere") ? true : - osgDB::equalCaseInsensitive(extension,"sponge") ? true : - osgDB::equalCaseInsensitive(extension,"star") ? true : - osgDB::equalCaseInsensitive(extension,"stla") ? true : - osgDB::equalCaseInsensitive(extension,"stlb") ? true : - osgDB::equalCaseInsensitive(extension,"substclip") ? true : - osgDB::equalCaseInsensitive(extension,"sv") ? true : - osgDB::equalCaseInsensitive(extension,"trans") ? true : - osgDB::equalCaseInsensitive(extension,"tri") ? true : - osgDB::equalCaseInsensitive(extension,"unc") ? true : - osgDB::equalCaseInsensitive(extension,"vct") ? true : - false; - } virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options) const { @@ -195,6 +131,66 @@ class ReaderWriterPFB : public osgDB::ReaderWriter ReaderWriterPFB::ReaderWriterPFB() { + supportsExtension("3ds",""); + supportsExtension("arcinfo",""); + supportsExtension("bin",""); + supportsExtension("bpoly",""); + supportsExtension("bw",""); + supportsExtension("byu",""); + supportsExtension("closest",""); + supportsExtension("csb",""); + supportsExtension("ct",""); + supportsExtension("dem",""); + supportsExtension("doublerot",""); + supportsExtension("doublescale",""); + supportsExtension("doubletrans",""); + supportsExtension("dted",""); + supportsExtension("dwb",""); + supportsExtension("dxf",""); + supportsExtension("evt",""); + supportsExtension("flt",""); + supportsExtension("gds",""); + supportsExtension("gfo",""); + supportsExtension("im",""); + supportsExtension("irtp",""); + supportsExtension("iv20",""); + supportsExtension("iv",""); + supportsExtension("lodfix",""); + supportsExtension("lsa",""); + supportsExtension("lsb",""); + supportsExtension("medit",""); + supportsExtension("m",""); + supportsExtension("nff",""); + supportsExtension("obj",""); + supportsExtension("pegg",""); + supportsExtension("pfb",""); + supportsExtension("pfs",""); + supportsExtension("phd",""); + supportsExtension("poly",""); + supportsExtension("post",""); + supportsExtension("proc",""); + supportsExtension("projtex",""); + supportsExtension("pts",""); + supportsExtension("rot",""); + supportsExtension("scale",""); + supportsExtension("sgf",""); + supportsExtension("sgo",""); + supportsExtension("so",""); + supportsExtension("spf",""); + supportsExtension("spherepatch3",""); + supportsExtension("spherepatch",""); + supportsExtension("sphere",""); + supportsExtension("sponge",""); + supportsExtension("star",""); + supportsExtension("stla",""); + supportsExtension("stlb",""); + supportsExtension("substclip",""); + supportsExtension("sv",""); + supportsExtension("trans",""); + supportsExtension("tri",""); + supportsExtension("unc",""); + supportsExtension("vct",""); + _performerInitialised = false; initPerformer(); } diff --git a/src/osgPlugins/pic/ReaderWriterPIC.cpp b/src/osgPlugins/pic/ReaderWriterPIC.cpp index 47583bb3b..81c5aa913 100644 --- a/src/osgPlugins/pic/ReaderWriterPIC.cpp +++ b/src/osgPlugins/pic/ReaderWriterPIC.cpp @@ -191,8 +191,12 @@ int *numComponents_ret) class ReaderWriterPIC : public osgDB::ReaderWriter { public: + ReaderWriterPIC() + { + supportsExtension("pic","PIC Image format"); + } + virtual const char* className() const { return "PIC Image Reader"; } - virtual bool acceptsExtension(const std::string& extension) const { return osgDB::equalCaseInsensitive(extension,"pic"); } virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options =NULL) const { diff --git a/src/osgPlugins/png/ReaderWriterPNG.cpp b/src/osgPlugins/png/ReaderWriterPNG.cpp index 05f4d29fb..e72f022ef 100644 --- a/src/osgPlugins/png/ReaderWriterPNG.cpp +++ b/src/osgPlugins/png/ReaderWriterPNG.cpp @@ -80,8 +80,12 @@ void png_flush_ostream(png_structp png_ptr) class ReaderWriterPNG : public osgDB::ReaderWriter { public: + ReaderWriterPNG() + { + supportsExtension("png","PNG Image format"); + } + virtual const char* className() const { return "PNG Image Reader/Writer"; } - virtual bool acceptsExtension(const std::string& extension) const { return osgDB::equalCaseInsensitive(extension,"png"); } WriteResult::WriteStatus writePngStream(std::ostream& fout, const osg::Image& img, int compression_level) const { diff --git a/src/osgPlugins/pnm/ReaderWriterPNM.cpp b/src/osgPlugins/pnm/ReaderWriterPNM.cpp index f3ccdbaa0..c7a51876c 100644 --- a/src/osgPlugins/pnm/ReaderWriterPNM.cpp +++ b/src/osgPlugins/pnm/ReaderWriterPNM.cpp @@ -247,15 +247,15 @@ template class ReaderWriterPNM : public osgDB::ReaderWriter { public: - virtual const char* className() const { return "PNM Image Reader/Writer"; } - virtual bool acceptsExtension(const std::string& extension) const + ReaderWriterPNM() { - return osgDB::equalCaseInsensitive(extension, "pnm") || - osgDB::equalCaseInsensitive(extension, "ppm") || - osgDB::equalCaseInsensitive(extension, "pgm") || - osgDB::equalCaseInsensitive(extension, "pbm"); + supportsExtension("pnm","PNM Image format"); + supportsExtension("ppm","PNM Image format"); + supportsExtension("pgm","PNM Image format"); + supportsExtension("pbm","PNM Image format"); } - + + virtual const char* className() const { return "PNM Image Reader/Writer"; } virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options) const { diff --git a/src/osgPlugins/quicktime/ReaderWriterQT.cpp b/src/osgPlugins/quicktime/ReaderWriterQT.cpp index e4258eab3..cadafe87a 100644 --- a/src/osgPlugins/quicktime/ReaderWriterQT.cpp +++ b/src/osgPlugins/quicktime/ReaderWriterQT.cpp @@ -76,7 +76,34 @@ class ReaderWriterQT : public osgDB::ReaderWriter public: ReaderWriterQT::ReaderWriterQT() { + supportsExtension("mov","Movie format"); + supportsExtension("mpg","Movie format"); + supportsExtension("mpv","Movie format"); + supportsExtension("mp4","Movie format"); + supportsExtension("m4v","Movie format"); + supportsExtension("dv","Movie format"); + supportsExtension("avi","Movie format"); + supportsExtension("flv","Movie format"); + supportsExtension("swf","Movie format"); + + supportsExtension("live","Live video streaming"); + + #ifdef QT_HANDLE_IMAGES_ALSO + supportsExtension("rgb","rgb image format"); + supportsExtension("rgba","rgba image format"); + supportsExtension("jpg","jpg image format"); + supportsExtension("jpeg","jpeg image format"); + supportsExtension("tif","tif image format"); + supportsExtension("tiff","tiff image format"); + supportsExtension("gif","gif image format"); + supportsExtension("png","png image format"); + supportsExtension("pict","pict image format"); + supportsExtension("pct","pct image format"); + supportsExtension("tga","tga image format"); + supportsExtension("psd","psd image format"); + #endif } + ReaderWriterQT::~ReaderWriterQT() { } diff --git a/src/osgPlugins/rot/ReaderWriterROT.cpp b/src/osgPlugins/rot/ReaderWriterROT.cpp index 7178f61b4..4bf8940f3 100644 --- a/src/osgPlugins/rot/ReaderWriterROT.cpp +++ b/src/osgPlugins/rot/ReaderWriterROT.cpp @@ -93,15 +93,13 @@ static bool getFilenameAndParams(const std::string& input, std::string& filename class ReaderWriterROT : public osgDB::ReaderWriter { public: - ReaderWriterROT() { } + ReaderWriterROT() + { + supportsExtension(EXTENSION_NAME,"Rotation pseudo loader"); + } virtual const char* className() const { return "rotation pseudo-loader"; } - virtual bool acceptsExtension(const std::string& extension) const - { - return osgDB::equalCaseInsensitive( extension, EXTENSION_NAME ); - } - virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const { std::string ext = osgDB::getLowerCaseFileExtension(fileName); diff --git a/src/osgPlugins/scale/ReaderWriterSCALE.cpp b/src/osgPlugins/scale/ReaderWriterSCALE.cpp index c6a20adc4..068539754 100644 --- a/src/osgPlugins/scale/ReaderWriterSCALE.cpp +++ b/src/osgPlugins/scale/ReaderWriterSCALE.cpp @@ -96,7 +96,10 @@ static bool getFilenameAndParams(const std::string& input, std::string& filename class ReaderWriterSCALE : public osgDB::ReaderWriter { public: - ReaderWriterSCALE() { } + ReaderWriterSCALE() + { + supportsExtension(EXTENSION_NAME,"Scale Pseudo loader"); + } virtual const char* className() const { return "scaling pseudo-loader"; } diff --git a/src/osgPlugins/stl/ReaderWriterSTL.cpp b/src/osgPlugins/stl/ReaderWriterSTL.cpp index f6f18d092..690871ce5 100644 --- a/src/osgPlugins/stl/ReaderWriterSTL.cpp +++ b/src/osgPlugins/stl/ReaderWriterSTL.cpp @@ -45,16 +45,14 @@ class ReaderWriterSTL : public osgDB::ReaderWriter { public: - ReaderWriterSTL() {} - - virtual const char* className() const { - return "STL Reader/Writer"; + ReaderWriterSTL() + { + supportsExtension("stl","STL format"); + supportsExtension("sta","STL format"); } - virtual bool acceptsExtension(const std::string& extension) const { - return - osgDB::equalCaseInsensitive(extension,"stl") ? true : - osgDB::equalCaseInsensitive(extension,"sta") ? true : false; + virtual const char* className() const { + return "STL Reader"; } virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options*) const; diff --git a/src/osgPlugins/svg/ReaderWriterSVG.cpp b/src/osgPlugins/svg/ReaderWriterSVG.cpp index 5540ac954..f32d8171a 100644 --- a/src/osgPlugins/svg/ReaderWriterSVG.cpp +++ b/src/osgPlugins/svg/ReaderWriterSVG.cpp @@ -22,98 +22,96 @@ #include extern "C" { - #include - #include + #include + #include } class ReaderWriterSVG : public osgDB::ReaderWriter { public: - ReaderWriterSVG() - { - rsvg_init(); - } - virtual const char* className() const { return "SVG Image Reader"; } - virtual bool acceptsExtension(const std::string& extension) const - { - return osgDB::equalCaseInsensitive(extension,"svg"); - } + ReaderWriterSVG() + { + supportsExtension("svg","Scalar Vector Graphics format"); + rsvg_init(); + } - virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options) const - { - return readImage(file, options); - } + virtual const char* className() const { return "SVG Image Reader"; } - virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options) const - { - std::string ext = osgDB::getLowerCaseFileExtension(file); - if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED; + virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options) const + { + return readImage(file, options); + } - std::string fileName = osgDB::findDataFile( file, options ); - if (fileName.empty()) return ReadResult::FILE_NOT_FOUND; + virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options) const + { + std::string ext = osgDB::getLowerCaseFileExtension(file); + if (!acceptsExtension(ext)) return ReadResult::FILE_NOT_HANDLED; - RsvgDimensionData dimensionData; - RsvgHandle* handle = rsvg_handle_new_from_file (file.c_str(), NULL); - rsvg_handle_get_dimensions( handle, &dimensionData); + std::string fileName = osgDB::findDataFile( file, options ); + if (fileName.empty()) return ReadResult::FILE_NOT_FOUND; - osg::Image *image; - if (options) - { - unsigned int w=0, h=0; - std::string op = options->getOptionString(); - size_t i = op.find("x"); + RsvgDimensionData dimensionData; + RsvgHandle* handle = rsvg_handle_new_from_file (file.c_str(), NULL); + rsvg_handle_get_dimensions( handle, &dimensionData); - std::stringstream ss1(op.substr(0, i)); - std::stringstream ss2(op.substr(i+1, op.size())); - ss1 >> w; - ss1 >> h; - if (w==0 || h==0){ - image = createImage(handle, dimensionData.width, dimensionData.height); - } - else{ - image = createImage(handle, w, h); - } - } - else{ - image = createImage(handle, dimensionData.width, dimensionData.height); - } - rsvg_handle_free(handle); - image->setFileName(file); - return image; - } + osg::Image *image; + if (options) + { + unsigned int w=0, h=0; + std::string op = options->getOptionString(); + size_t i = op.find("x"); - osg::Image* createImage(RsvgHandle *handle, unsigned int width, unsigned int height) const - { - RsvgDimensionData dimensionData; - rsvg_handle_get_dimensions( handle, &dimensionData); - // If image resollution < 128, cairo produces some artifacts. - // I don't know why, but we check the size... - if (width < 128) width = 128; - if (height < 128) height = 128; - width = osg::Image::computeNearestPowerOfTwo(width); - height = osg::Image::computeNearestPowerOfTwo(height); - osg::Image *image = new osg::Image(); - image->allocateImage(width, height, 1, GL_RGBA, GL_UNSIGNED_BYTE); - image->setPixelFormat(GL_BGRA); + std::stringstream ss1(op.substr(0, i)); + std::stringstream ss2(op.substr(i+1, op.size())); + ss1 >> w; + ss1 >> h; + if (w==0 || h==0){ + image = createImage(handle, dimensionData.width, dimensionData.height); + } + else{ + image = createImage(handle, w, h); + } + } + else{ + image = createImage(handle, dimensionData.width, dimensionData.height); + } + rsvg_handle_free(handle); + image->setFileName(file); + return image; + } - cairo_surface_t *cairo_surface = cairo_image_surface_create_for_data(image->data(), - CAIRO_FORMAT_ARGB32, width, height, image->getRowSizeInBytes()); - cairo_t *cr = cairo_create(cairo_surface); - cairo_scale(cr,((float)width)/dimensionData.width, ((float)height)/dimensionData.height); - rsvg_handle_render_cairo(handle, cr); - - cairo_destroy(cr); - free(cairo_surface); + osg::Image* createImage(RsvgHandle *handle, unsigned int width, unsigned int height) const + { + RsvgDimensionData dimensionData; + rsvg_handle_get_dimensions( handle, &dimensionData); + // If image resollution < 128, cairo produces some artifacts. + // I don't know why, but we check the size... + if (width < 128) width = 128; + if (height < 128) height = 128; + width = osg::Image::computeNearestPowerOfTwo(width); + height = osg::Image::computeNearestPowerOfTwo(height); + osg::Image *image = new osg::Image(); + image->allocateImage(width, height, 1, GL_RGBA, GL_UNSIGNED_BYTE); + image->setPixelFormat(GL_BGRA); - image->flipVertical(); - return image; - } - protected: - virtual ~ReaderWriterSVG() - { - rsvg_term(); - } + cairo_surface_t *cairo_surface = cairo_image_surface_create_for_data(image->data(), + CAIRO_FORMAT_ARGB32, width, height, image->getRowSizeInBytes()); + cairo_t *cr = cairo_create(cairo_surface); + cairo_scale(cr,((float)width)/dimensionData.width, ((float)height)/dimensionData.height); + rsvg_handle_render_cairo(handle, cr); + + cairo_destroy(cr); + free(cairo_surface); + + image->flipVertical(); + return image; + } + protected: + virtual ~ReaderWriterSVG() + { + rsvg_term(); + } }; // now register with Registry to instantiate the above diff --git a/src/osgPlugins/tga/ReaderWriterTGA.cpp b/src/osgPlugins/tga/ReaderWriterTGA.cpp index 6aceb7069..938d554fa 100644 --- a/src/osgPlugins/tga/ReaderWriterTGA.cpp +++ b/src/osgPlugins/tga/ReaderWriterTGA.cpp @@ -467,8 +467,13 @@ int headerlen) class ReaderWriterTGA : public osgDB::ReaderWriter { public: + + ReaderWriterTGA() + { + supportsExtension("tga","Tga Image format"); + } + virtual const char* className() const { return "TGA Image Reader"; } - virtual bool acceptsExtension(const std::string& extension) const { return osgDB::equalCaseInsensitive(extension,"tga"); } ReadResult readTGAStream(std::istream& fin) const { diff --git a/src/osgPlugins/tgz/ReaderWriterTGZ.cpp b/src/osgPlugins/tgz/ReaderWriterTGZ.cpp index 03530a169..b4777011b 100644 --- a/src/osgPlugins/tgz/ReaderWriterTGZ.cpp +++ b/src/osgPlugins/tgz/ReaderWriterTGZ.cpp @@ -26,9 +26,9 @@ class ReaderWriterTGZ : public osgDB::ReaderWriter public: virtual const char* className() const { return "TGZ Database Reader/Writer"; } - virtual bool acceptsExtension(const std::string& extension) const + ReaderWriterTGZ() { - return osgDB::equalCaseInsensitive(extension,"tgz"); + supportsExtension("tgz","Tar gzip'd archive format"); } virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const diff --git a/src/osgPlugins/tiff/ReaderWriterTIFF.cpp b/src/osgPlugins/tiff/ReaderWriterTIFF.cpp index b6372ab75..ee2703bc7 100644 --- a/src/osgPlugins/tiff/ReaderWriterTIFF.cpp +++ b/src/osgPlugins/tiff/ReaderWriterTIFF.cpp @@ -631,6 +631,13 @@ simage_tiff_load(std::istream& fin, class ReaderWriterTIFF : public osgDB::ReaderWriter { public: + + ReaderWriterTIFF() + { + supportsExtension("tiff","Tiff image format"); + supportsExtension("tif","Tiff image format"); + } + virtual const char* className() const { return "TIFF Image Reader"; } virtual bool acceptsExtension(const std::string& extension) const { diff --git a/src/osgPlugins/trans/ReaderWriterTRANS.cpp b/src/osgPlugins/trans/ReaderWriterTRANS.cpp index ba2921910..2e42a8d26 100644 --- a/src/osgPlugins/trans/ReaderWriterTRANS.cpp +++ b/src/osgPlugins/trans/ReaderWriterTRANS.cpp @@ -94,15 +94,13 @@ static bool getFilenameAndParams(const std::string& input, std::string& filename class ReaderWriterTRANS : public osgDB::ReaderWriter { public: - ReaderWriterTRANS() { } + ReaderWriterTRANS() + { + supportsExtension(EXTENSION_NAME,"Translation Psuedo loader."); + } virtual const char* className() const { return "translation pseudo-loader"; } - virtual bool acceptsExtension(const std::string& extension) const - { - return osgDB::equalCaseInsensitive( extension, EXTENSION_NAME ); - } - virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const { std::string ext = osgDB::getLowerCaseFileExtension(fileName); diff --git a/src/osgPlugins/txf/ReaderWriterTXF.cpp b/src/osgPlugins/txf/ReaderWriterTXF.cpp index 5f0438c46..1ba5a5f1e 100644 --- a/src/osgPlugins/txf/ReaderWriterTXF.cpp +++ b/src/osgPlugins/txf/ReaderWriterTXF.cpp @@ -23,13 +23,13 @@ class ReaderWriterTXF : public osgDB::ReaderWriter { public: - virtual const char* className() const { return "TXF Font Reader/Writer"; } - - virtual bool acceptsExtension(const std::string& extension) const + ReaderWriterTXF() { - return osgDB::equalCaseInsensitive(extension, "txf"); // GLU texture fonts + supportsExtension("txf","TXF Font format"); } + virtual const char* className() const { return "TXF Font Reader/Writer"; } + virtual ReadResult readObject(const std::string& file, const osgDB::ReaderWriter::Options* options) const { std::string ext = osgDB::getLowerCaseFileExtension(file); diff --git a/src/osgPlugins/txp/ReaderWriterTXP.h b/src/osgPlugins/txp/ReaderWriterTXP.h index b8173f46a..0dfa362c9 100644 --- a/src/osgPlugins/txp/ReaderWriterTXP.h +++ b/src/osgPlugins/txp/ReaderWriterTXP.h @@ -53,16 +53,17 @@ namespace txp class ReaderWriterTXP : public osgDB::ReaderWriter { public: + + ReaderWriterTXP() + { + supportsExtension("txp","Terrapage txp format"); + } + virtual const char* className() const { return "TXP Reader/Writer"; } - virtual bool acceptsExtension(const std::string& extension) const - { - return osgDB::equalCaseInsensitive(extension,"txp"); - } - virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const { if( !acceptsExtension(osgDB::getFileExtension(file) )) diff --git a/src/osgPlugins/vrml/ReaderWriterVRML2.h b/src/osgPlugins/vrml/ReaderWriterVRML2.h index 4c6759256..9f006b5b3 100644 --- a/src/osgPlugins/vrml/ReaderWriterVRML2.h +++ b/src/osgPlugins/vrml/ReaderWriterVRML2.h @@ -72,17 +72,15 @@ class ReaderWriterVRML2 { public: ReaderWriterVRML2() - {} + { + supportsExtension("wrl","VRML format"); + } virtual const char* className() { return "VRML2 Reader/Writer"; } - virtual bool acceptsExtension(const std::string& extension) - { - return osgDB::equalCaseInsensitive(extension, "wrl"); - } virtual ReadResult readNode(const std::string&, const osgDB::ReaderWriter::Options *options = NULL) const; diff --git a/src/osgPlugins/x/ReaderWriterDirectX.cpp b/src/osgPlugins/x/ReaderWriterDirectX.cpp index cdd16fa22..afa2f79d0 100644 --- a/src/osgPlugins/x/ReaderWriterDirectX.cpp +++ b/src/osgPlugins/x/ReaderWriterDirectX.cpp @@ -48,17 +48,15 @@ class ReaderWriterDirectX : public osgDB::ReaderWriter { public: - ReaderWriterDirectX() { } + ReaderWriterDirectX() + { + supportsExtension("x","DirectX scene format"); + } virtual const char* className() const { return "DirectX Reader/Writer"; } - virtual bool acceptsExtension(const std::string& extension) const - { - return osgDB::equalCaseInsensitive(extension,"x"); - } - virtual ReadResult readNode(const std::string& fileName, const osgDB::ReaderWriter::Options* options) const; private: diff --git a/src/osgPlugins/xine/ReaderWriterXine.cpp b/src/osgPlugins/xine/ReaderWriterXine.cpp index e62cb1a27..5022cce55 100644 --- a/src/osgPlugins/xine/ReaderWriterXine.cpp +++ b/src/osgPlugins/xine/ReaderWriterXine.cpp @@ -311,6 +311,15 @@ class ReaderWriterXine : public osgDB::ReaderWriter ReaderWriterXine() { + supportsExtension("avi",""); + supportsExtension("db",""); + supportsExtension("flv",""); + supportsExtension("mov",""); + supportsExtension("mpg","Mpeg movie format"); + supportsExtension("mpv","Mpeg movie format"); + supportsExtension("wmv",""); + supportsExtension("xine","Xine plugin Pseduo plugin"); + _xine = xine_new(); const char* user_home = xine_get_homedir(); @@ -336,18 +345,6 @@ class ReaderWriterXine : public osgDB::ReaderWriter virtual const char* className() const { return "Xine ImageStream Reader"; } - virtual bool acceptsExtension(const std::string& extension) const - { - return osgDB::equalCaseInsensitive(extension,"mpg") || - osgDB::equalCaseInsensitive(extension,"mpv") || - osgDB::equalCaseInsensitive(extension,"db") || - osgDB::equalCaseInsensitive(extension,"flv") || - osgDB::equalCaseInsensitive(extension,"mov") || - osgDB::equalCaseInsensitive(extension,"avi") || - osgDB::equalCaseInsensitive(extension,"wmv") || - osgDB::equalCaseInsensitive(extension,"xine"); - } - virtual ReadResult readImage(const std::string& file, const osgDB::ReaderWriter::Options* options) const { std::string ext = osgDB::getLowerCaseFileExtension(file); diff --git a/src/osgPlugins/zip/ReaderWriterZIP.cpp b/src/osgPlugins/zip/ReaderWriterZIP.cpp index d4fa695be..d08d1c559 100644 --- a/src/osgPlugins/zip/ReaderWriterZIP.cpp +++ b/src/osgPlugins/zip/ReaderWriterZIP.cpp @@ -22,12 +22,13 @@ class ReaderWriterZIP : public osgDB::ReaderWriter { public: - virtual const char* className() const { return "ZIP Database Reader/Writer"; } - - virtual bool acceptsExtension(const std::string& extension) const + + ReaderWriterZIP() { - return osgDB::equalCaseInsensitive(extension,"zip"); + supportsExtension("zip","Zip archive format"); } + + virtual const char* className() const { return "ZIP Database Reader/Writer"; } virtual ReadResult readNode(const std::string& file, const osgDB::ReaderWriter::Options* options) const {