Changeset 218
- Timestamp:
- Feb 2, 2011, 9:36:49 AM (14 years ago)
- Location:
- osgVisual/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
osgVisual/trunk/include/util/visual_util.h
r193 r218 18 18 #include <string.h> 19 19 #include <iostream> 20 #include <sstream> 20 21 #include <libxml/parser.h> 21 22 #include <libxml/tree.h> … … 269 270 static std::string getAnimationPathFromXMLConfig(std::string configFilename); 270 271 272 static int strToDouble(std::string s); 273 static double strToInt(std::string s); 274 static bool strToBool(std::string s); 275 271 276 private: 272 277 /** -
osgVisual/trunk/src/object/object_updater.cpp
r215 r218 47 47 object_->bankAngle_phi = osg::DegreesToRadians(osgVisual::visual_dataIO::getInstance()->getSlotDataAsDouble(updater_rot_x, osgVisual::dataIO_slot::TO_OBJ )); 48 48 if(!updater_label.empty()) 49 object_->updateLabelText(" autoupdated", osgVisual::visual_dataIO::getInstance()->getSlotDataAsString(updater_label, osgVisual::dataIO_slot::TO_OBJ ));49 object_->updateLabelText("default", osgVisual::visual_dataIO::getInstance()->getSlotDataAsString(updater_label, osgVisual::dataIO_slot::TO_OBJ )); 50 50 51 51 // Finally execute nested PreUpdater -
osgVisual/trunk/src/object/visual_object.cpp
r217 r218 84 84 std::string objectname="", filename="", label=""; 85 85 bool dynamic = false; 86 int trackingID=-1; 86 87 double lat=0.0, lon=0.0, alt=0.0, rot_x=0.0, rot_y=0.0, rot_z=0.0; 87 88 double cam_trans_x=0.0, cam_trans_y=0.0, cam_trans_z=0.0, cam_rot_x=0.0, cam_rot_y=0.0, cam_rot_z=0.0; … … 98 99 std::string attr_value=reinterpret_cast<const char*>(attr->children->content); 99 100 if( attr_name == "objectname" ) objectname = attr_value; 101 if( attr_name == "trackingid" ) trackingID = util::strToInt(attr_value); 100 102 if( attr_name == "label" ) label = attr_value; 101 if( attr_name == "dynamic" ) 102 { 103 if(attr_value=="yes") 104 dynamic=true; 105 else 106 dynamic=false; 107 } 103 if( attr_name == "dynamic" ) dynamic = util::strToBool(attr_value); 104 108 105 attr = attr->next; 109 106 } … … 119 116 std::string attr_name=reinterpret_cast<const char*>(attr->name); 120 117 std::string attr_value=reinterpret_cast<const char*>(attr->children->content); 121 if( attr_name == "lat" ) 122 { 123 std::stringstream sstr(attr_value); 124 sstr >> lat; 125 } 126 if( attr_name == "lon" ) 127 { 128 std::stringstream sstr(attr_value); 129 sstr >> lon; 130 } 131 if( attr_name == "alt" ) 132 { 133 std::stringstream sstr(attr_value); 134 sstr >> alt; 135 } 118 if( attr_name == "lat" ) lat = util::strToDouble(attr_value); 119 if( attr_name == "lon" ) lon = util::strToDouble(attr_value); 120 if( attr_name == "alt" ) alt = util::strToDouble(attr_value); 121 136 122 attr = attr->next; 137 123 } … … 145 131 std::string attr_name=reinterpret_cast<const char*>(attr->name); 146 132 std::string attr_value=reinterpret_cast<const char*>(attr->children->content); 147 if( attr_name == "rot_x" ) 148 { 149 std::stringstream sstr(attr_value); 150 sstr >> rot_x; 151 } 152 if( attr_name == "rot_y" ) 153 { 154 std::stringstream sstr(attr_value); 155 sstr >> rot_y; 156 } 157 if( attr_name == "rot_z" ) 158 { 159 std::stringstream sstr(attr_value); 160 sstr >> rot_z; 161 } 133 if( attr_name == "rot_x" ) rot_x = util::strToDouble(attr_value); 134 if( attr_name == "rot_y" ) rot_y = util::strToDouble(attr_value); 135 if( attr_name == "rot_z" ) rot_z = util::strToDouble(attr_value); 136 162 137 attr = attr->next; 163 138 } … … 228 203 std::string attr_name=reinterpret_cast<const char*>(attr->name); 229 204 std::string attr_value=reinterpret_cast<const char*>(attr->children->content); 230 if( attr_name == "trans_x" ) 231 { 232 std::stringstream sstr(attr_value); 233 sstr >> cam_trans_x; 234 } 235 if( attr_name == "trans_y" ) 236 { 237 std::stringstream sstr(attr_value); 238 sstr >> cam_trans_y; 239 } 240 if( attr_name == "trans_z" ) 241 { 242 std::stringstream sstr(attr_value); 243 sstr >> cam_trans_y; 244 } 205 if( attr_name == "trans_x" ) cam_trans_x = util::strToDouble(attr_value); 206 if( attr_name == "trans_y" ) cam_trans_y = util::strToDouble(attr_value); 207 if( attr_name == "trans_z" ) cam_trans_z = util::strToDouble(attr_value); 208 245 209 attr = attr->next; 246 210 } … … 253 217 std::string attr_name=reinterpret_cast<const char*>(attr->name); 254 218 std::string attr_value=reinterpret_cast<const char*>(attr->children->content); 255 if( attr_name == "rot_x" ) 256 { 257 std::stringstream sstr(attr_value); 258 sstr >> cam_rot_x; 259 } 260 if( attr_name == "rot_y" ) 261 { 262 std::stringstream sstr(attr_value); 263 sstr >> cam_rot_y; 264 } 265 if( attr_name == "rot_z" ) 266 { 267 std::stringstream sstr(attr_value); 268 sstr >> cam_rot_y; 269 } 219 if( attr_name == "rot_x" ) cam_rot_x = util::strToDouble(attr_value); 220 if( attr_name == "rot_y" ) cam_rot_y = util::strToDouble(attr_value); 221 if( attr_name == "rot_z" ) cam_rot_z = util::strToDouble(attr_value); 222 270 223 attr = attr->next; 271 224 } … … 298 251 std::string attr_name=reinterpret_cast<const char*>(attr->name); 299 252 std::string attr_value=reinterpret_cast<const char*>(attr->children->content); 300 if( attr_name == "rot_x" ) 301 { 302 std::stringstream sstr(attr_value); 303 sstr >> geometry_rot_x; 304 } 305 if( attr_name == "rot_y" ) 306 { 307 std::stringstream sstr(attr_value); 308 sstr >> geometry_rot_y; 309 } 310 if( attr_name == "rot_z" ) 311 { 312 std::stringstream sstr(attr_value); 313 sstr >> geometry_rot_z; 314 } 253 if( attr_name == "rot_x" ) geometry_rot_x = util::strToDouble(attr_value); 254 if( attr_name == "rot_y" ) geometry_rot_y = util::strToDouble(attr_value); 255 if( attr_name == "rot_z" ) geometry_rot_z = util::strToDouble(attr_value); 256 315 257 attr = attr->next; 316 258 } … … 323 265 std::string attr_name=reinterpret_cast<const char*>(attr->name); 324 266 std::string attr_value=reinterpret_cast<const char*>(attr->children->content); 325 if( attr_name == "scale_x" ) 326 { 327 std::stringstream sstr(attr_value); 328 sstr >> geometry_scale_x; 329 } 330 if( attr_name == "scale_y" ) 331 { 332 std::stringstream sstr(attr_value); 333 sstr >> geometry_scale_y; 334 } 335 if( attr_name == "scale_z" ) 336 { 337 std::stringstream sstr(attr_value); 338 sstr >> geometry_scale_z; 339 } 267 if( attr_name == "scale_x" ) geometry_scale_x = util::strToDouble(attr_value); 268 if( attr_name == "scale_y" ) geometry_scale_y = util::strToDouble(attr_value); 269 if( attr_name == "scale_z" ) geometry_scale_z = util::strToDouble(attr_value); 270 340 271 attr = attr->next; 341 272 } … … 354 285 object->bankAngle_phi = rot_z; 355 286 if(label!="") 356 object->addLabel(" XML_defined_label", label);287 object->addLabel("default", label); 357 288 if(dynamic) 358 289 { -
osgVisual/trunk/src/util/visual_util.cpp
r198 r218 535 535 return animationpath; 536 536 } 537 538 int util::strToDouble(std::string s) 539 { 540 double tmp; 541 std::stringstream sstr(s); 542 sstr >> tmp; 543 return tmp; 544 } 545 546 double util::strToInt(std::string s) 547 { 548 int tmp; 549 std::stringstream sstr(s); 550 sstr >> tmp; 551 return tmp; 552 } 553 554 bool util::strToBool(std::string s) 555 { 556 if(s=="yes") 557 return(true); 558 if(s=="no") 559 return(false); 560 OSG_ALWAYS << __FUNCTION__ << "Warning:Unable to convert "<< s <<" to bool, using false as default!" << std::endl; 561 return(false); 562 }
Note: See TracChangeset
for help on using the changeset viewer.