source: osgVisual/trunk/src/object/object_updater.cpp @ 415

Last change on this file since 415 was 247, checked in by Torben Dannhauer, 14 years ago

typo fix, clean up

File size: 3.8 KB
RevLine 
[221]1/* -*-c++-*- osgVisual - Copyright (C) 2009-2011 Torben Dannhauer
[31]2 *
3 * This library is based on OpenSceneGraph, open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
9 * You have to aquire licenses for all used proprietary modules.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * OpenSceneGraph Public License for more details.
15*/
16
17#include <object_updater.h>
18
19using namespace osgVisual;
20
21object_updater::object_updater(osgVisual::visual_object* object_ )
22{
[224]23        updater_lat_rad = object_->getName()+"_POS_LAT";
24        updater_lon_rad = object_->getName()+"_POS_LON";
25        updater_alt             = object_->getName()+"_POS_ALT";
26        updater_rot_x_rad = object_->getName()+"_ROT_X";
27        updater_rot_y_rad = object_->getName()+"_ROT_Y";
28        updater_rot_z_rad = object_->getName()+"_ROT_Z";
[247]29        updater_label = object_->getName()+"_LABEL";
30        object_->addLabel("default", " ");
[31]31}
32
33object_updater::~object_updater(void)
34{
35}
36
37void object_updater::preUpdate(osgVisual::visual_object* object_ )
38{
39        OSG_NOTIFY( osg::INFO ) << "preUpdate visual Object " << object_->getName() << std::endl;
40        // perform this preUpdater...
41        //For each visual_object.member,
42        //      try to search according variable in dataIO with direction TO_OBJ and copy value to visual_object.
43
[224]44        if(!updater_lat_rad.empty())
45                object_->lat = osgVisual::visual_dataIO::getInstance()->getSlotDataAsDouble(updater_lat_rad, osgVisual::dataIO_slot::TO_OBJ );
46        if(!updater_lon_rad.empty())
47                object_->lon = osgVisual::visual_dataIO::getInstance()->getSlotDataAsDouble(updater_lon_rad, osgVisual::dataIO_slot::TO_OBJ );
[215]48        if(!updater_alt.empty())
49                object_->alt = osgVisual::visual_dataIO::getInstance()->getSlotDataAsDouble(updater_alt, osgVisual::dataIO_slot::TO_OBJ );
[224]50        if(!updater_rot_z_rad.empty())
51                object_->azimuthAngle_psi = osgVisual::visual_dataIO::getInstance()->getSlotDataAsDouble(updater_rot_z_rad, osgVisual::dataIO_slot::TO_OBJ );
52        if(!updater_rot_y_rad.empty())
53                object_->pitchAngle_theta = osgVisual::visual_dataIO::getInstance()->getSlotDataAsDouble(updater_rot_y_rad, osgVisual::dataIO_slot::TO_OBJ );
54        if(!updater_rot_x_rad.empty())
55                object_->bankAngle_phi = osgVisual::visual_dataIO::getInstance()->getSlotDataAsDouble(updater_rot_x_rad, osgVisual::dataIO_slot::TO_OBJ );
[215]56        if(!updater_label.empty())
[218]57                object_->updateLabelText("default", osgVisual::visual_dataIO::getInstance()->getSlotDataAsString(updater_label, osgVisual::dataIO_slot::TO_OBJ ));
[31]58
59        // Finally execute nested PreUpdater
60        if ( updater.valid() )
61                updater->preUpdate(object_);
62}
63
64void object_updater::postUpdate(osgVisual::visual_object* object_ )
65{
66        OSG_NOTIFY( osg::INFO ) << "postUpdate visual Object " << object_->getName() << std::endl;
67
68        // Finally execute nested PostUpdater
69        if ( updater.valid() )
70                updater->postUpdate(object_);
71}
72
73void object_updater::addUpdater( object_updater* updater_ )
74{
75        if (updater.valid())
76                updater->addUpdater( updater_ );
77        else
78                updater = updater_;
[209]79}
80
[224]81void object_updater::setUpdaterSlotNames( osgVisual::visual_object* object_, std::string lat_rad_, std::string lon_rad_, std::string alt_, std::string rot_x_rad_, std::string rot_y_rad_, std::string rot_z_rad_, std::string label_)
[209]82{
[247]83        updater_lat_rad = lat_rad_;
84        updater_lon_rad = lon_rad_;
85        updater_alt = alt_;
86        updater_rot_x_rad = rot_x_rad_;
87        updater_rot_y_rad = rot_y_rad_;
88        updater_rot_z_rad = rot_z_rad_;
89        updater_label = label_;
[31]90}
Note: See TracBrowser for help on using the repository browser.