Changeset 153 for osgVisual/src
- Timestamp:
- Nov 11, 2010, 9:03:48 PM (14 years ago)
- Location:
- osgVisual/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
osgVisual/src/distortion/visual_distortion.cpp
r152 r153 175 175 } 176 176 177 178 179 177 return true; 180 178 } -
osgVisual/src/vista2D/visual_vista2D.cpp
r145 r153 24 24 // Create a Vista2D View 25 25 view = new Vista2D::VistaView(); 26 27 filename = ""; 28 paintBackground = false;; 29 position_x = 600; 30 position_y = 400; 31 zoom = 0.5; 26 32 } 27 33 … … 30 36 } 31 37 32 void visual_vista2D:: init(std::string vista2DFilename_)33 { 38 void visual_vista2D::startVista2D(std::string vista2DFilename_) 39 { 34 40 /*************** 35 41 load view 36 42 ***************/ 37 view->load( vista2DFilename_);38 view->setBackgroundMode( false); // don't paint background39 view->setPosition( 800,450);40 view->setZoom( 0.5);43 view->load( filename ); 44 view->setBackgroundMode(paintBackground); // don't paint background 45 view->setPosition( position_x,position_y); 46 view->setZoom( zoom ); 41 47 42 48 /*************** … … 48 54 } 49 55 50 bool visual_vista2D::createVistaOverlay( std::string vista2DFilename_, osg::CoordinateSystemNode *sceneGraphRoot_ ) 51 { 56 bool visual_vista2D::processXMLConfiguration() 57 { 58 // Init XML 59 xmlDoc* tmpDoc; 60 bool disabled; 61 xmlNode* config = util::getModuleXMLConfig( configFileName, "vista2D", tmpDoc, disabled ); 62 63 if( disabled) 64 { 65 OSG_NOTIFY( osg::ALWAYS ) << "..disabled by XML configuration file." << std::endl; 66 return false; 67 } 68 69 // extract configuration values 70 if(config) 71 { 72 xmlNode* a_node = config->children; 73 74 for (xmlNode *cur_node = a_node; cur_node; cur_node = cur_node->next) 75 { 76 std::string node_name=reinterpret_cast<const char*>(cur_node->name); 77 //OSG_ALWAYS << "----visual_vista2D::processXMLConfiguration() - node type="<< cur_node->type <<", name=" << cur_node->name << std::endl; 78 79 // Check for vista2d node 80 if(cur_node->type == XML_ELEMENT_NODE && node_name == "vista2d") 81 { 82 // Check attributes 83 xmlAttr *attr = cur_node->properties; 84 while ( attr ) 85 { 86 std::string attr_name=reinterpret_cast<const char*>(attr->name); 87 std::string attr_value=reinterpret_cast<const char*>(attr->children->content); 88 89 if( attr_name == "filename" ) 90 { 91 filename=attr_value 92 } 93 94 if( attr_name == "paintBackground" ) 95 { 96 paintBackground = (attr_value == "yes") ? true : false; 97 } 98 99 if( attr_name == "position_x" ) 100 { 101 std::stringstream sstr(attr_value); 102 sstr >> position_x; 103 } 104 105 if( attr_name == "position_y" ) 106 { 107 std::stringstream sstr(attr_value); 108 sstr >> position_y; 109 } 110 111 if( attr_name == "zoom" ) 112 { 113 std::stringstream sstr(attr_value); 114 sstr >> zoom; 115 } 116 117 attr = attr->next; 118 } // WHILE attr END 119 } // IF node == vista2d END 120 } // FOR end 121 122 // clean up 123 xmlFreeDoc(tmpDoc); xmlCleanupParser(); 124 return true; 125 } // IF Config valid END 126 else 127 { 128 OSG_WARN << "ERROR: visual_vista2D::processXMLConfiguration() - Module configuration not found" << std::endl; 129 return false; 130 } 131 132 return true; 133 } 134 135 bool visual_vista2D::init( osg::CoordinateSystemNode *sceneGraphRoot_, std::string configFileName ) 136 { 137 OSG_NOTIFY (osg::ALWAYS ) << "visual_vista2D initialize.."; // The sentence is finished by the init result... 138 139 this->configFileName = configFileName; 140 141 // Analyse XML configuration file 142 // Process XML configuration 143 if(!processXMLConfiguration()) 144 return false; // Abort vista2D initialization. 145 52 146 // Check if Vista2D file exist 53 if (! osgDB::fileExists( vista2DFilename_) )54 { 55 osg::notify( osg::WARN ) << "WARNING: Could not find specified Vista2D projectfile. Skip adding Vista2D project." << std::endl;147 if (! osgDB::fileExists( filename ) ) 148 { 149 osg::notify( osg::WARN ) << "WARNING: visual_vista2D::createVistaOverlay - Could not find specified Vista2D projectfile. Skip adding Vista2D project." << std::endl; 56 150 return false; 57 151 } … … 92 186 // Add Payload: Vista2D 93 187 osg::ref_ptr<visual_vista2D> vista2D = new visual_vista2D(); 94 vista2D-> init( vista2DFilename_ );188 vista2D->startVista2D( vista2DFilename_ ); 95 189 96 190 vista2D.get()->setUseDisplayList( false );
Note: See TracChangeset
for help on using the changeset viewer.