diff --git a/include/osgPresentation/SlideShowConstructor b/include/osgPresentation/SlideShowConstructor index 240eca070..8e080f644 100644 --- a/include/osgPresentation/SlideShowConstructor +++ b/include/osgPresentation/SlideShowConstructor @@ -222,10 +222,10 @@ public: struct ModelData { - ModelData(): - effect("") {} + ModelData() {} std::string effect; + std::string options; }; struct ImageData @@ -239,7 +239,8 @@ public: loopingMode(osg::ImageStream::NO_LOOPING), page(-1), backgroundColor(1.0f,1.0f,1.0f,1.0f) {} - + + std::string options; float width; float height; osg::Vec4 region; @@ -274,6 +275,7 @@ public: region[3] = region[4] = region[5] = 1.0f; } + std::string options; ShadingModel shadingModel; osg::ref_ptr transferFunction; bool useTabbedDragger; @@ -393,7 +395,7 @@ public: void addStereoImagePair(const std::string& filenameLeft, const ImageData& imageDataLeft, const std::string& filenameRight,const ImageData& imageDataRight, const PositionData& positionData); - void addGraph(const std::string& filename,const std::string& options,const PositionData& positionData, const ImageData& imageData); + void addGraph(const std::string& filename,const PositionData& positionData, const ImageData& imageData); void addVNC(const std::string& filename,const PositionData& positionData, const ImageData& imageData, const std::string& password); void addBrowser(const std::string& filename,const PositionData& positionData, const ImageData& imageData); void addPDF(const std::string& filename,const PositionData& positionData, const ImageData& imageData); diff --git a/src/osgPlugins/p3d/ReaderWriterP3D.cpp b/src/osgPlugins/p3d/ReaderWriterP3D.cpp index f4fb7e461..3665f474f 100644 --- a/src/osgPlugins/p3d/ReaderWriterP3D.cpp +++ b/src/osgPlugins/p3d/ReaderWriterP3D.cpp @@ -798,6 +798,12 @@ bool ReaderWriterP3DXML::getProperties(osgDB::XmlNode*cur, osgPresentation::Slid OSG_NOTIFY(_notifyLevel)<<"read effect \""<getTrimmedContents(), options, + constructor.addGraph(cur->getTrimmedContents(), positionRead ? positionData : constructor.getImagePositionData(), imageData); } diff --git a/src/osgPlugins/vnc/ReaderWriterVNC.cpp b/src/osgPlugins/vnc/ReaderWriterVNC.cpp index 581d20bd1..7303f6e30 100644 --- a/src/osgPlugins/vnc/ReaderWriterVNC.cpp +++ b/src/osgPlugins/vnc/ReaderWriterVNC.cpp @@ -52,8 +52,10 @@ class LibVncImage : public osgWidget::VncImage static void passwordCheck(rfbClient* client,const char* encryptedPassWord,int len); static char* getPassword(rfbClient* client); + std::string _optionString; std::string _username; std::string _password; + double _timeOfLastUpdate; double _timeOfLastRender; @@ -277,7 +279,7 @@ void LibVncImage::close() rfbBool LibVncImage::resizeImage(rfbClient* client) { - osg::Image* image = (osg::Image*)(rfbClientGetClientData(client, 0)); + LibVncImage* image = (LibVncImage*)(rfbClientGetClientData(client, 0)); int width = client->width; int height = client->height; @@ -286,15 +288,23 @@ rfbBool LibVncImage::resizeImage(rfbClient* client) OSG_NOTICE<<"resize "<_optionString.empty()) + { + if (image->_optionString.find("RGB")!=std::string::npos) gl_pixelFormat = GL_RGBA; + if (image->_optionString.find("RGBA")!=std::string::npos) gl_pixelFormat = GL_RGBA; + if (image->_optionString.find("BGR")!=std::string::npos) gl_pixelFormat = GL_BGRA; + if (image->_optionString.find("BGRA")!=std::string::npos) gl_pixelFormat = GL_BGRA; + } + image->allocateImage(width, height, 1, gl_pixelFormat, GL_UNSIGNED_BYTE); image->setInternalTextureFormat(GL_RGBA); @@ -393,6 +403,11 @@ class ReaderWriterVNC : public osgDB::ReaderWriter image->_password = details->password; } + if (options && !options->getOptionString().empty()) + { + image->_optionString = options->getOptionString(); + } + if (!image->connect(hostname)) { return "Could not connect to "+hostname; diff --git a/src/osgPresentation/SlideShowConstructor.cpp b/src/osgPresentation/SlideShowConstructor.cpp index 4e74be52b..59943247d 100644 --- a/src/osgPresentation/SlideShowConstructor.cpp +++ b/src/osgPresentation/SlideShowConstructor.cpp @@ -879,7 +879,14 @@ void SlideShowConstructor::addImage(const std::string& filename, const PositionD { if (!_currentLayer) addLayer(); - osg::Image* image = osgDB::readImageFile(filename, _options.get()); + osg::ref_ptr options = _options; + if (!imageData.options.empty()) + { + options = _options->cloneOptions(); + options->setOptionString(imageData.options); + } + + osg::Image* image = osgDB::readImageFile(filename, options.get()); if (image) recordOptionsFilePath(_options.get()); @@ -1016,12 +1023,25 @@ void SlideShowConstructor::addStereoImagePair(const std::string& filenameLeft, c { if (!_currentLayer) addLayer(); + osg::ref_ptr optionsLeft = _options; + if (!imageDataLeft.options.empty()) + { + optionsLeft = _options->cloneOptions(); + optionsLeft->setOptionString(imageDataLeft.options); + } - osg::ref_ptr imageLeft = osgDB::readImageFile(filenameLeft, _options.get()); - if (imageLeft.valid()) recordOptionsFilePath(_options.get()); + osg::ref_ptr optionsRight = _options; + if (!imageDataRight.options.empty()) + { + optionsRight = _options->cloneOptions(); + optionsRight->setOptionString(imageDataRight.options); + } - osg::ref_ptr imageRight = (filenameRight==filenameLeft) ? imageLeft.get() : osgDB::readImageFile(filenameRight, _options.get()); - if (imageRight.valid()) recordOptionsFilePath(_options.get()); + osg::ref_ptr imageLeft = osgDB::readImageFile(filenameLeft, optionsLeft.get()); + if (imageLeft.valid()) recordOptionsFilePath(optionsLeft.get()); + + osg::ref_ptr imageRight = (filenameRight==filenameLeft) ? imageLeft.get() : osgDB::readImageFile(filenameRight, optionsRight.get()); + if (imageRight.valid()) recordOptionsFilePath(optionsRight.get()); if (!imageLeft && !imageRight) return; @@ -1209,7 +1229,7 @@ void SlideShowConstructor::addStereoImagePair(const std::string& filenameLeft, c _currentLayer->addChild(subgraph); } -void SlideShowConstructor::addGraph(const std::string& contents,const std::string& options,const PositionData& positionData, const ImageData& imageData) +void SlideShowConstructor::addGraph(const std::string& contents, const PositionData& positionData, const ImageData& imageData) { static int s_count=0; @@ -1247,9 +1267,9 @@ void SlideShowConstructor::addGraph(const std::string& contents,const std::strin dotFileName = tmpDirectory+osgDB::getStrippedName(filename)+std::string(".dot"); osg::ref_ptr opts = _options.valid() ? _options->cloneOptions() : (new osgDB::Options); - if (!options.empty()) + if (!imageData.options.empty()) { - opts->setOptionString(options); + opts->setOptionString(imageData.options); } opts->setObjectCacheHint(osgDB::Options::CACHE_NONE); @@ -1327,7 +1347,14 @@ osg::Image* SlideShowConstructor::addInteractiveImage(const std::string& filenam { if (!_currentLayer) addLayer(); - osg::Image* image = osgDB::readImageFile(filename, _options.get()); + osg::ref_ptr options = _options; + if (!imageData.options.empty()) + { + options = _options->cloneOptions(); + options->setOptionString(imageData.options); + } + + osg::Image* image = osgDB::readImageFile(filename, options.get()); OSG_INFO<<"addInteractiveImage("< options = _options; + if (!modelData.options.empty()) + { + options = _options->cloneOptions(); + options->setOptionString(modelData.options); + } + osg::Node* subgraph = 0; if (filename=="sphere") @@ -1509,8 +1543,8 @@ void SlideShowConstructor::addModel(const std::string& filename, const PositionD } else { - subgraph = osgDB::readNodeFile(filename, _options.get()); - if (subgraph) recordOptionsFilePath(_options.get()); + subgraph = osgDB::readNodeFile(filename, options.get()); + if (subgraph) recordOptionsFilePath(options.get()); } if (subgraph) @@ -1763,6 +1797,13 @@ void SlideShowConstructor::addVolume(const std::string& filename, const Position PositionData positionData(in_positionData); + osg::ref_ptr options = _options; + if (!volumeData.options.empty()) + { + options = _options->cloneOptions(); + options->setOptionString(volumeData.options); + } + std::string foundFile = filename; osg::ref_ptr image; osg::ref_ptr volume; @@ -1784,7 +1825,7 @@ void SlideShowConstructor::addVolume(const std::string& filename, const Position itr != filenames.end(); ++itr) { - osg::ref_ptr loadedImage = osgDB::readImageFile(*itr); + osg::ref_ptr loadedImage = osgDB::readImageFile(*itr, options.get()); if (loadedImage.valid()) { images.push_back(loadedImage.get()); @@ -1804,7 +1845,7 @@ void SlideShowConstructor::addVolume(const std::string& filename, const Position if (fileType == osgDB::DIRECTORY) { - image = osgDB::readImageFile(foundFile+".dicom", _options.get()); + image = osgDB::readImageFile(foundFile+".dicom", options.get()); } else if (fileType == osgDB::REGULAR_FILE) { @@ -1817,14 +1858,14 @@ void SlideShowConstructor::addVolume(const std::string& filename, const Position } else { - image = osgDB::readImageFile( foundFile, _options.get() ); + image = osgDB::readImageFile( foundFile, options.get() ); } } else { // not found image, so fallback to plguins/callbacks to find the model. - image = osgDB::readImageFile( filename, _options.get() ); - if (image) recordOptionsFilePath(_options.get() ); + image = osgDB::readImageFile( filename, options.get() ); + if (image) recordOptionsFilePath(options.get() ); } }