Changeset 218


Ignore:
Timestamp:
Feb 2, 2011, 9:36:49 AM (13 years ago)
Author:
Torben Dannhauer
Message:
 
Location:
osgVisual/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/trunk/include/util/visual_util.h

    r193 r218  
    1818#include <string.h>
    1919#include <iostream>
     20#include <sstream>
    2021#include <libxml/parser.h>
    2122#include <libxml/tree.h>
     
    269270        static std::string getAnimationPathFromXMLConfig(std::string configFilename);
    270271
     272        static int strToDouble(std::string s);
     273        static double strToInt(std::string s);
     274        static bool strToBool(std::string s);
     275
    271276private:
    272277        /**
  • osgVisual/trunk/src/object/object_updater.cpp

    r215 r218  
    4747                object_->bankAngle_phi = osg::DegreesToRadians(osgVisual::visual_dataIO::getInstance()->getSlotDataAsDouble(updater_rot_x, osgVisual::dataIO_slot::TO_OBJ ));
    4848        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 ));
    5050
    5151        // Finally execute nested PreUpdater
  • osgVisual/trunk/src/object/visual_object.cpp

    r217 r218  
    8484        std::string objectname="", filename="", label="";
    8585        bool dynamic = false;
     86        int trackingID=-1;
    8687        double lat=0.0, lon=0.0, alt=0.0, rot_x=0.0, rot_y=0.0, rot_z=0.0;
    8788        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;
     
    9899                std::string attr_value=reinterpret_cast<const char*>(attr->children->content);
    99100                if( attr_name == "objectname" ) objectname = attr_value;
     101                if( attr_name == "trackingid" ) trackingID = util::strToInt(attr_value);
    100102                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
    108105                attr = attr->next;
    109106        }
     
    119116                                std::string attr_name=reinterpret_cast<const char*>(attr->name);
    120117                                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
    136122                                attr = attr->next;
    137123                        }
     
    145131                                std::string attr_name=reinterpret_cast<const char*>(attr->name);
    146132                                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
    162137                                attr = attr->next;
    163138                        }
     
    228203                                                std::string attr_name=reinterpret_cast<const char*>(attr->name);
    229204                                                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
    245209                                                attr = attr->next;
    246210                                        }
     
    253217                                                std::string attr_name=reinterpret_cast<const char*>(attr->name);
    254218                                                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
    270223                                                attr = attr->next;
    271224                                        }
     
    298251                                                std::string attr_name=reinterpret_cast<const char*>(attr->name);
    299252                                                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
    315257                                                attr = attr->next;
    316258                                        }
     
    323265                                                std::string attr_name=reinterpret_cast<const char*>(attr->name);
    324266                                                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
    340271                                                attr = attr->next;
    341272                                        }
     
    354285        object->bankAngle_phi = rot_z;
    355286        if(label!="")
    356                 object->addLabel("XML_defined_label", label);
     287                object->addLabel("default", label);
    357288        if(dynamic)
    358289        {
  • osgVisual/trunk/src/util/visual_util.cpp

    r198 r218  
    535535        return animationpath;
    536536}
     537
     538int util::strToDouble(std::string s)
     539{
     540        double tmp;
     541        std::stringstream sstr(s);
     542        sstr >> tmp;
     543        return tmp;
     544}
     545
     546double util::strToInt(std::string s)
     547{
     548        int tmp;
     549        std::stringstream sstr(s);
     550        sstr >> tmp;
     551        return tmp;
     552}
     553
     554bool 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.