Changeset 234 for osgVisual/trunk


Ignore:
Timestamp:
Feb 13, 2011, 7:25:16 PM (14 years ago)
Author:
Torben Dannhauer
Message:

Now the trackingID can be updated by the external Link.

Location:
osgVisual/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/trunk/bin/osgVisualConfig.xml

    r230 r234  
    7171        </geometry>
    7272      </model>
    73       <trackmodel id="2" updater_slot=""></trackmodel>
     73      <trackmodel id="2" updater_slot="trackID"></trackmodel>
    7474    </models>
    7575    <datetime day="0" month="0" year="0" hour="12" minute="30"></datetime>
  • osgVisual/trunk/include/core/core_manipulator.h

    r231 r234  
    6363        void trackNode( int trackingID );
    6464        int getCurrentTrackingID(){return _currentTrackingID;};
     65        void setTrackingIdUpdaterSlot(std::string updaterSlot){_updaterSlot=updaterSlot;};
     66        std::string getTrackingIdUpdaterSlot(){return _updaterSlot;};
    6567
    6668private:
     69        class core_manipulatorCallback : public osg::NodeCallback
     70        {
     71        public:
     72                /**
     73                 * \brief Constructor, for setting the member variables.
     74                 *
     75                 * @param manipulators : Pointer to the manipulator and tracking class.
     76                 */
     77                core_manipulatorCallback(core_manipulator* manipulators):_manipulators(manipulators){};
     78
     79                /**
     80                 * \brief This function is executed as callback during event traversal.
     81                 *
     82                 */
     83                virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
     84        private:
     85                /** Pointer to the manipulator class to edit its value */
     86                core_manipulator* _manipulators;
     87        };
     88
     89        /** Pointer to the callback isntalled to update the tracking ID */
     90        osg::ref_ptr<core_manipulatorCallback> _callback;
     91
     92        /** core_manipulatorCallback must be a freind of this class to allow the callback to edit the member values of this class directly */
     93        friend class core_manipulatorCallback;
    6794
    6895#ifdef USE_SPACENAVIGATOR
     
    93120        int _currentTrackingID;
    94121
     122        /** Slotname to use for dynamic updated tracking ID. */
     123        std::string _updaterSlot;
     124
    95125        /**
    96126         * Pointer to the  scene root node
    97127         */
    98128        osg::ref_ptr<osg::Node> _rootNode;
     129
     130        /**
     131         * Referenced pointer to the applications viewer.
     132         */
     133        osg::ref_ptr<osgViewer::Viewer> _viewer;
    99134};
    100135
  • osgVisual/trunk/include/dataIO/visual_dataIO.h

    r221 r234  
    8080                 * \brief Constructor, for setting the member variables.
    8181                 *
    82                  * @param viewer_ : Pointer to the viewer.
    83                  * @param sceneCamera_ : Pointer to the scene camera.
     82                 * @param dataIO_ : Pointer to the dataIO class.
    8483                 */
    8584                dataIO_eventCallback(visual_dataIO* dataIO_):dataIO(dataIO_){};
    8685
    8786                /**
    88                  * \brief This function is execute d as callback during update traversal.
     87                 * \brief This function is executed as callback during event traversal.
    8988                 *
    9089                 */
  • osgVisual/trunk/src/core/core_manipulator.cpp

    r231 r234  
    3131{
    3232        _rootNode = rootNode;
     33        _viewer = viewer;
    3334
    3435        // Setup manipulators
     
    8788    viewer->addEventHandler(new osgViewer::ScreenCaptureHandler);                       // add the screen capture handler
    8889
    89 
     90        // Install Callback
     91        _callback = new core_manipulatorCallback(this);
     92        viewer->getCamera()->addEventCallback(_callback);
    9093
    9194        return true;
     
    9497void core_manipulator::shutdown()
    9598{
     99        // Remove and Delete Callback
     100        _viewer->getCamera()->removeEventCallback(_callback);
     101        _callback= NULL;
     102
    96103#ifdef USE_SPACENAVIGATOR
    97104        //Delete SpaceMouse driver
     
    107114        _nt = NULL;
    108115        _rootNode = NULL;
     116        _viewer = NULL;
    109117}
    110118
     
    160168        }
    161169}
     170
     171void core_manipulator::core_manipulatorCallback::operator()(osg::Node* node, osg::NodeVisitor* nv)
     172{
     173        //OSG_NOTIFY( osg::ALWAYS ) << "---- Executing core_manipulatorCallback .." <<  std::endl;
     174
     175        if(!_manipulators->_updaterSlot.empty())
     176        {
     177                int idToTrack = visual_dataIO::getInstance()->getSlotDataAsDouble(_manipulators->_updaterSlot, osgVisual::dataIO_slot::TO_OBJ );
     178                if(idToTrack!=_manipulators->_currentTrackingID)
     179                        _manipulators->trackNode(idToTrack);
     180        }
     181
     182        traverse(node, nv);
     183}
  • osgVisual/trunk/src/core/visual_core.cpp

    r233 r234  
    215215                                                std::string attr_value=reinterpret_cast<const char*>(attr->children->content);
    216216                                                if( attr_name == "id" ) manipulators->trackNode( util::strToInt(attr_value) );
    217 
    218 
     217                                                if( attr_name == "updater_slot" ) manipulators->setTrackingIdUpdaterSlot(attr_value);
    219218                                                attr = attr->next;
    220219                                        }
Note: See TracChangeset for help on using the changeset viewer.