Changeset 153
- Timestamp:
- Nov 11, 2010, 9:03:48 PM (14 years ago)
- Location:
- osgVisual
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
osgVisual/bin/osgVisualConfig.xml
r151 r153 18 18 <module name="sky_silverlining" enabled="yes"></module> 19 19 <module name="vista2d" enabled="yes"> 20 <vista2d filename="hud.view" ></vista2d>20 <vista2d filename="hud.view" paintBackground="no" position_x="800" position_y="450" zoom="0.5"></vista2d> 21 21 </module> 22 22 -
osgVisual/include/vista2D/visual_vista2D.h
r32 r153 17 17 18 18 #include "VistaView.h" 19 20 #include <string> 19 21 20 22 #include <osg/Drawable> … … 70 72 * @return : True if successful. 71 73 */ 72 static bool createVistaOverlay( std::string vista2DFilename_, osg::CoordinateSystemNode *sceneGraphRoot_);74 static bool init( osg::CoordinateSystemNode *sceneGraphRoot_, std::string configFileName ); 73 75 74 76 /** … … 88 90 89 91 private: 92 93 bool processXMLConfiguration(); 94 90 95 /** 91 96 * \brief This function initialized the visual_vista2D object after instantiation by createVistaOverlay() 92 *93 * @param vista2DFilename_ : Vista2D project file to instantiate.94 97 */ 95 void init(std::string vista2DFilename_);98 void startVista2D(); 96 99 97 100 /** … … 109 112 */ 110 113 Vista2D::VistaView* view; 114 115 /** 116 * XML config filename 117 */ 118 std::string configFileName; 119 120 /** 121 * Filename of the Vista2D project file. 122 */ 123 std::string filename; 124 125 /** 126 * Should the background of the Vista2D project be painted? 127 */ 128 bool paintBackground; 129 130 /** 131 * X-Position to draw. 132 */ 133 int position_x; 134 135 /** 136 * Y-Position to draw. 137 */ 138 int position_y; 139 140 /** 141 * Zoom factor to draw the project. 142 */ 143 double zoom; 111 144 }; 112 145 -
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.