/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer * * This library is based on OpenSceneGraph, open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. * * osgVisual requires for some proprietary modules a license from the correspondig manufacturer. * You have to aquire licenses for all used proprietary modules. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * OpenSceneGraph Public License for more details. */ #include #include using namespace osgVisual; dataIO_extLinkVCL::dataIO_extLinkVCL(std::vector& dataSlots_) : dataIO_extLink(dataSlots_) { OSG_NOTIFY( osg::ALWAYS ) << "extLinkVCL constructed" << std::endl; } dataIO_extLinkVCL::~dataIO_extLinkVCL(void) { OSG_NOTIFY( osg::ALWAYS ) << "extLinkVCL destroyed" << std::endl; } void dataIO_extLinkVCL::init() { OSG_NOTIFY( osg::ALWAYS ) << "extLinkVCL init()" << std::endl; std::string VCLConfigFilename = "osgVisual.xml"; if ( osgDB::fileExists( VCLConfigFilename ) ) { CVCLIO::GetInstance().LoadProject(VCLConfigFilename.c_str()); bool error = false; if( !SAENGER1_POS_LAT.Attach("VISENGINE_CAMERA_CHANNEL", "SAENGER1_POS_LAT") ) error = true; if( !SAENGER1_POS_LON.Attach("VISENGINE_CAMERA_CHANNEL", "SAENGER1_POS_LON") ) error = true; if( !SAENGER1_POS_ALT.Attach("VISENGINE_CAMERA_CHANNEL", "SAENGER1_POS_ALT") ) error = true; if( !SAENGER1_ROT_X.Attach("VISENGINE_CAMERA_CHANNEL", "SAENGER1_ROT_X") ) error = true; if( !SAENGER1_ROT_Y.Attach("VISENGINE_CAMERA_CHANNEL", "SAENGER1_ROT_Y") ) error = true; if( !SAENGER1_ROT_Z.Attach("VISENGINE_CAMERA_CHANNEL", "SAENGER1_ROT_Z") ) error = true; if( !SAENGER2_POS_LAT.Attach("VISENGINE_CAMERA_CHANNEL", "SAENGER2_POS_LAT") ) error = true; if( !SAENGER2_POS_LON.Attach("VISENGINE_CAMERA_CHANNEL", "SAENGER2_POS_LON") ) error = true; if( !SAENGER2_POS_ALT.Attach("VISENGINE_CAMERA_CHANNEL", "SAENGER2_POS_ALT") ) error = true; if( !SAENGER2_ROT_X.Attach("VISENGINE_CAMERA_CHANNEL", "SAENGER2_ROT_X") ) error = true; if( !SAENGER2_ROT_Y.Attach("VISENGINE_CAMERA_CHANNEL", "SAENGER2_ROT_Y") ) error = true; if( !SAENGER2_ROT_Z.Attach("VISENGINE_CAMERA_CHANNEL", "SAENGER2_ROT_Z") ) error = true; if( !SAENGER_POS_LAT.Attach("VISENGINE_CAMERA_CHANNEL", "SAENGER_POS_LAT") ) error = true; if( !SAENGER_POS_LON.Attach("VISENGINE_CAMERA_CHANNEL", "SAENGER_POS_LON") ) error = true; if( !SAENGER_POS_ALT.Attach("VISENGINE_CAMERA_CHANNEL", "SAENGER_POS_ALT") ) error = true; if( !SAENGER_ROT_X.Attach("VISENGINE_CAMERA_CHANNEL", "SAENGER_ROT_X") ) error = true; if( !SAENGER_ROT_Y.Attach("VISENGINE_CAMERA_CHANNEL", "SAENGER_ROT_Y") ) error = true; if( !SAENGER_ROT_Z.Attach("VISENGINE_CAMERA_CHANNEL", "SAENGER_ROT_Z") ) error = true; if (error) OSG_NOTIFY( osg::FATAL ) << "ERROR: An error occured while attaching VCL." << std::endl; initialized = true; } else { OSG_NOTIFY( osg::FATAL ) << "ERROR: Could not find VCL Configuration file " << VCLConfigFilename << std::endl; exit(-1); } } void dataIO_extLinkVCL::shutdown() { OSG_NOTIFY( osg::ALWAYS ) << "extLinkVCL shutdown()" << std::endl; } bool dataIO_extLinkVCL::readTO_OBJvalues() { OSG_NOTIFY( osg::INFO ) << "extLinkVCL readTO_OBJvalues()" << std::endl; // perform external data exchange CVCLIO::GetInstance().DoDataExchange(); // Copy data from VCL variables to slot variables: osgVisual::visual_dataIO::getInstance()->setSlotData( "SAENGER1_POS_LAT", osgVisual::dataIO_slot::TO_OBJ, SAENGER1_POS_LAT.GetValue() ); osgVisual::visual_dataIO::getInstance()->setSlotData( "SAENGER1_POS_LON", osgVisual::dataIO_slot::TO_OBJ, SAENGER1_POS_LON.GetValue() ); osgVisual::visual_dataIO::getInstance()->setSlotData( "SAENGER1_POS_ALT", osgVisual::dataIO_slot::TO_OBJ, -SAENGER1_POS_ALT.GetValue() ); // Negatives Vorzeichen da Z-Koordinaten anders herum. osgVisual::visual_dataIO::getInstance()->setSlotData( "SAENGER1_ROT_X", osgVisual::dataIO_slot::TO_OBJ, SAENGER1_ROT_X.GetValue() ); osgVisual::visual_dataIO::getInstance()->setSlotData( "SAENGER1_ROT_Y", osgVisual::dataIO_slot::TO_OBJ, SAENGER1_ROT_Y.GetValue() ); osgVisual::visual_dataIO::getInstance()->setSlotData( "SAENGER1_ROT_Z", osgVisual::dataIO_slot::TO_OBJ, SAENGER1_ROT_Z.GetValue() ); osgVisual::visual_dataIO::getInstance()->setSlotData( "SAENGER2_POS_LAT", osgVisual::dataIO_slot::TO_OBJ, SAENGER2_POS_LAT.GetValue() ); osgVisual::visual_dataIO::getInstance()->setSlotData( "SAENGER2_POS_LON", osgVisual::dataIO_slot::TO_OBJ, SAENGER2_POS_LON.GetValue() ); osgVisual::visual_dataIO::getInstance()->setSlotData( "SAENGER2_POS_ALT", osgVisual::dataIO_slot::TO_OBJ, -SAENGER2_POS_ALT.GetValue() ); // Negatives Vorzeichen da Z-Koordinaten anders herum. osgVisual::visual_dataIO::getInstance()->setSlotData( "SAENGER2_ROT_X", osgVisual::dataIO_slot::TO_OBJ, SAENGER2_ROT_X.GetValue() ); osgVisual::visual_dataIO::getInstance()->setSlotData( "SAENGER2_ROT_Y", osgVisual::dataIO_slot::TO_OBJ, SAENGER2_ROT_Y.GetValue() ); osgVisual::visual_dataIO::getInstance()->setSlotData( "SAENGER2_ROT_Z", osgVisual::dataIO_slot::TO_OBJ, SAENGER2_ROT_Z.GetValue() ); osgVisual::visual_dataIO::getInstance()->setSlotData( "SAENGER_POS_LAT", osgVisual::dataIO_slot::TO_OBJ, SAENGER_POS_LAT.GetValue() ); osgVisual::visual_dataIO::getInstance()->setSlotData( "SAENGER_POS_LON", osgVisual::dataIO_slot::TO_OBJ, SAENGER_POS_LON.GetValue() ); osgVisual::visual_dataIO::getInstance()->setSlotData( "SAENGER_POS_ALT", osgVisual::dataIO_slot::TO_OBJ, -SAENGER_POS_ALT.GetValue() ); // Negatives Vorzeichen da Z-Koordinaten anders herum. osgVisual::visual_dataIO::getInstance()->setSlotData( "SAENGER_ROT_X", osgVisual::dataIO_slot::TO_OBJ, SAENGER_ROT_X.GetValue() ); osgVisual::visual_dataIO::getInstance()->setSlotData( "SAENGER_ROT_Y", osgVisual::dataIO_slot::TO_OBJ, SAENGER_ROT_Y.GetValue() ); osgVisual::visual_dataIO::getInstance()->setSlotData( "SAENGER_ROT_Z", osgVisual::dataIO_slot::TO_OBJ, SAENGER_ROT_Z.GetValue() ); //OSG_NOTIFY( osg::ALWAYS ) << "LAT: " << osgVisual::visual_dataIO::getInstance()->getSlotDataAsDouble("SAENGER1_POS_LAT", osgVisual::dataIO_slot::TO_OBJ ) << std::endl; return true; } bool dataIO_extLinkVCL::writebackFROM_OBJvalues() { OSG_NOTIFY( osg::INFO ) << "extLinkVCL writebackFROM_OBJvalues()" << std::endl; // Copy slot data to variables // Nothing to do // Example: MY_CHANNEL.setValue( myValue ); /* In VCL no writeback transaction is done, it is postponed until the next frame beginning, where TO_OBJ exchange calls CVCLIO::GetInstance().DoDataExchange();. */ return true; }