- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgPlugins/p3d/ReaderWriterP3D.cpp
r12853 r13041 1 /* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield 1 /* -*-c++-*- Present3D - Copyright (C) 1999-2006 Robert Osfield 2 2 * 3 * This software is open source and may be redistributed and/or modified under 3 * This software is open source and may be redistributed and/or modified under 4 4 * the terms of the GNU General Public License (GPL) version 2.0. 5 5 * The full license is in LICENSE.txt file included with this distribution,. 6 * 6 * 7 7 * This software is distributed in the hope that it will be useful, 8 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 10 * include LICENSE.txt for more details. 11 11 */ … … 67 67 _alignmentMap["RIGHT_CENTER"] = osgText::Text::RIGHT_CENTER; 68 68 _alignmentMap["RIGHT_BOTTOM"] = osgText::Text::RIGHT_BOTTOM; 69 69 70 70 _alignmentMap["LEFT_BASE_LINE"] = osgText::Text::LEFT_BASE_LINE; 71 71 _alignmentMap["CENTER_BASE_LINE"] = osgText::Text::CENTER_BASE_LINE; … … 102 102 _notifyLevel = osg::INFO; 103 103 } 104 104 105 105 virtual const char* className() const 106 106 { … … 109 109 110 110 virtual bool acceptsExtension(const std::string& extension) const 111 { 111 { 112 112 return osgDB::equalCaseInsensitive(extension,"p3d") || 113 113 osgDB::equalCaseInsensitive(extension,"xml") ; … … 131 131 132 132 void parseLayer(osgPresentation::SlideShowConstructor& constructor, osgDB::XmlNode*cur) const; 133 133 134 134 void parseBullets(osgPresentation::SlideShowConstructor& constructor, osgDB::XmlNode*cur, bool inheritPreviousLayers, bool defineAsBaseLayer) const; 135 135 void parseText(osgPresentation::SlideShowConstructor& constructor, osgDB::XmlNode*cur, bool inheritPreviousLayers, bool defineAsBaseLayer) const; 136 136 137 137 void parsePage (osgPresentation::SlideShowConstructor& constructor, osgDB::XmlNode*cur) const; 138 138 139 139 void parseSlide (osgPresentation::SlideShowConstructor& constructor, osgDB::XmlNode*cur, bool parseTitles=true, bool parseLayers=true) const; 140 140 … … 149 149 else return osg::Vec4(0.0f,0.0f,0.0f,1.0f); 150 150 } 151 151 152 152 inline osg::Vec4 accumulateRotation(const osg::Vec4& lhs, const osg::Vec4& rhs) const 153 153 { … … 169 169 inline bool read(const char* str, osg::Vec3& value) const; 170 170 inline bool read(const char* str, osg::Vec4& value) const; 171 171 172 172 inline bool read(const std::string& str, int& value) const; 173 173 inline bool read(const std::string& str, float& value) const; … … 191 191 bool getProperty(osgDB::XmlNode*cur, const char* token, osgText::Text::AlignmentType& value) const; 192 192 bool getProperty(osgDB::XmlNode*cur, const char* token, osgText::Text::CharacterSizeMode& value) const; 193 193 194 194 bool getProperties(osgDB::XmlNode*cur, osgPresentation::SlideShowConstructor::PositionData& value) const; 195 195 bool getProperties(osgDB::XmlNode*cur, osgPresentation::SlideShowConstructor::FontData& value) const; … … 197 197 bool getProperties(osgDB::XmlNode*cur, osgPresentation::SlideShowConstructor::ImageData& value) const; 198 198 bool getJumpProperties(osgDB::XmlNode*cur, bool& relativeJump, int& slideNum, int& layerNum) const; 199 199 200 200 bool getKeyPositionInner(osgDB::XmlNode*cur, osgPresentation::KeyPosition& keyPosition) const; 201 201 bool getKeyPosition(osgDB::XmlNode*cur, osgPresentation::KeyPosition& keyPosition) const; … … 207 207 typedef std::map<std::string, unsigned int> StringKeyMap; 208 208 209 std::string expandEnvVarsInFileName(const std::string& filename) const; 209 std::string expandEnvVarsInFileName(const std::string& filename) const; 210 210 211 211 … … 215 215 CharacterSizeModeMap _characterSizeModeMap; 216 216 StringKeyMap _stringKeyMap; 217 217 218 218 typedef std::map<std::string, osg::ref_ptr<osgDB::XmlNode> > TemplateMap; 219 219 mutable TemplateMap _templateMap; … … 231 231 std::string argument(filename); 232 232 std::string::size_type start_pos = argument.find("${"); 233 233 234 234 while (start_pos != std::string::npos) 235 { 235 { 236 236 std::string::size_type end_pos = argument.find("}",start_pos); 237 237 if (start_pos != std::string::npos) … … 483 483 bool ReaderWriterP3DXML::getProperties(osgDB::XmlNode*cur, osgPresentation::SlideShowConstructor::PositionData& value) const 484 484 { 485 bool propertiesRead=false; 485 bool propertiesRead=false; 486 486 487 487 osg::Vec3 position(0.0f,1.0f,0.0f); … … 501 501 else if (str=="slide") value.frame = osgPresentation::SlideShowConstructor::SLIDE; 502 502 else OSG_NOTIFY(_notifyLevel)<<"Parser error - coordinate_frame=\""<<str<<"\" unrecongonized value"<<std::endl; 503 503 504 504 OSG_NOTIFY(_notifyLevel)<<"read coordinate_frame "<< ((value.frame==osgPresentation::SlideShowConstructor::MODEL) ? "osgPresentation::SlideShowConstructor::MODEL" : "osgPresentation::SlideShowConstructor::SLIDE")<<std::endl; 505 505 } … … 507 507 if (value.frame==osgPresentation::SlideShowConstructor::SLIDE) 508 508 { 509 509 510 510 if (getProperty(cur, "position", str)) 511 511 { … … 516 516 osg::Vec2 vec2; 517 517 osg::Vec3 vec3; 518 518 519 519 bool fail = false; 520 520 if (str=="center") value.position.set(0.5f,.5f,0.0f); … … 536 536 537 537 propertiesRead = true; 538 538 539 539 bool fail = false; 540 540 if (str=="center") value.position.set(0.0f,1.0f,0.0f); … … 547 547 } 548 548 549 549 550 550 if (getProperty(cur, "scale", scale)) 551 551 { … … 637 637 if (getTrimmedProperty(cur, "path", str)) 638 638 { 639 639 640 640 value.absolute_path = false; 641 641 value.inverse_path = false; … … 747 747 bool ReaderWriterP3DXML::getProperties(osgDB::XmlNode*cur, osgPresentation::SlideShowConstructor::FontData& value) const 748 748 { 749 bool propertiesRead=false; 750 749 bool propertiesRead=false; 750 751 751 OSG_NOTIFY(_notifyLevel)<<"in getProperties(FontData)"<<std::endl; 752 752 … … 789 789 bool ReaderWriterP3DXML::getProperties(osgDB::XmlNode*cur, osgPresentation::SlideShowConstructor::ModelData& value) const 790 790 { 791 bool propertiesRead=false; 792 791 bool propertiesRead=false; 792 793 793 OSG_NOTIFY(_notifyLevel)<<"in getProperties(ModelData)"<<std::endl; 794 794 … … 810 810 bool ReaderWriterP3DXML::getProperties(osgDB::XmlNode*cur, osgPresentation::SlideShowConstructor::ImageData& value) const 811 811 { 812 bool propertiesRead=false; 813 812 bool propertiesRead=false; 813 814 814 OSG_NOTIFY(_notifyLevel)<<"in getProperties(ImageData)"<<std::endl; 815 815 … … 880 880 OSG_NOTIFY(_notifyLevel)<<"read texcoord_scale \""<<value.texcoord_scale<<"\""<<std::endl; 881 881 } 882 882 883 883 if (getProperty(cur, "texcoord_rotate", value.texcoord_rotate)) 884 884 { … … 894 894 bool propertyRead = false; 895 895 896 if (getProperty(cur, "slide", slideNum)) 896 if (getProperty(cur, "slide", slideNum)) 897 897 { 898 898 OSG_INFO<<"slide "<<slideNum<<std::endl; … … 931 931 { 932 932 constructor.addModel(filename, 933 positionRead ? positionData : constructor.getModelPositionData(), 933 positionRead ? positionData : constructor.getModelPositionData(), 934 934 modelData); 935 935 } … … 1032 1032 1033 1033 if (getProperty(cur, "options", volumeData.options)) {} 1034 1034 1035 1035 // check for draggers required 1036 1036 std::string dragger; … … 1055 1055 1056 1056 std::string filename = cur->getTrimmedContents(); 1057 if (!filename.empty()) 1057 if (!filename.empty()) 1058 1058 { 1059 1059 constructor.addVolume(filename, … … 1101 1101 1102 1102 1103 if (!filenameLeft.empty() && !filenameRight.empty()) 1103 if (!filenameLeft.empty() && !filenameRight.empty()) 1104 1104 constructor.addStereoImagePair(filenameLeft,imageDataLeft, 1105 1105 filenameRight, imageDataRight, … … 1203 1203 { 1204 1204 OSG_INFO<<"Layer Jump "<<relativeJump<<","<< slideNum<<", "<<layerNum<<std::endl; 1205 1205 1206 1206 constructor.setLayerJump(relativeJump, slideNum, layerNum); 1207 1207 } … … 1316 1316 getProperty(cur, "options", options); 1317 1317 1318 constructor.addGraph(cur->getTrimmedContents(), 1318 constructor.addGraph(cur->getTrimmedContents(), 1319 1319 positionRead ? positionData : constructor.getImagePositionData(), 1320 1320 imageData); … … 1611 1611 int layerNum; 1612 1612 if (getProperty(cur, "layer", layerNum)) 1613 { 1613 { 1614 1614 constructor.selectLayer(layerNum); 1615 1615 } … … 1716 1716 } 1717 1717 1718 1718 1719 1719 osgDB::ReaderWriter::ReadResult readFileCache(ObjectType type, const std::string& filename, const osgDB::Options* options) 1720 1720 { … … 2219 2219 { 2220 2220 bool fontRead = getProperties(cur,constructor.getTitleFontDataDefault()); 2221 if (fontRead) 2221 if (fontRead) 2222 2222 { 2223 2223 OSG_INFO<<"Title font details read"<<std::endl; … … 2227 2227 { 2228 2228 bool fontRead = getProperties(cur,constructor.getTextFontDataDefault()); 2229 if (fontRead) 2229 if (fontRead) 2230 2230 { 2231 2231 OSG_INFO<<"Text font details read"<<std::endl; … … 2285 2285 int slideNum; 2286 2286 if (getProperty(cur, "slide", slideNum)) 2287 { 2287 { 2288 2288 constructor.selectSlide(slideNum); 2289 2289 parseSlide (constructor, cur); … … 2306 2306 std::string name; 2307 2307 if (getProperty(cur, "name", name)) 2308 { 2308 { 2309 2309 _templateMap[name] = cur; 2310 2310 std::cout<<"Defining template slide "<<name<<std::endl; … … 2314 2314 2315 2315 osgDB::getDataFilePathList() = previousPaths; 2316 2316 2317 2317 return constructor.takePresentation(); 2318 2318 }
