root/OpenSceneGraph/trunk/src/osgWrappers/serializers/osgManipulator/Dragger.cpp @ 13041

Revision 13041, 3.1 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1#include <osgManipulator/Constraint>
2#include <osgManipulator/Dragger>
3#include <osgDB/ObjectWrapper>
4#include <osgDB/InputStream>
5#include <osgDB/OutputStream>
6
7// TransformUpdating
8static bool checkTransformUpdating( const osgManipulator::Dragger& dragger )
9{
10    return dragger.getDraggerCallbacks().size()>0;
11}
12
13static bool readTransformUpdating( osgDB::InputStream& is, osgManipulator::Dragger& dragger )
14{
15    unsigned int size = is.readSize(); is >> osgDB::BEGIN_BRACKET;
16    for ( unsigned int i=0; i<size; ++i )
17    {
18        std::string name; is >> name >> osgDB::BEGIN_BRACKET;
19        if ( name=="DraggerTransformCallback" )
20        {
21            osg::MatrixTransform* transform = dynamic_cast<osg::MatrixTransform*>( is.readObject() );
22            if ( transform ) dragger.addTransformUpdating( transform );
23        }
24        is >> osgDB::END_BRACKET;
25    }
26    is >> osgDB::END_BRACKET;
27    return true;
28}
29
30static bool writeTransformUpdating( osgDB::OutputStream& os, const osgManipulator::Dragger& dragger )
31{
32    const osgManipulator::Dragger::DraggerCallbacks& callbacks = dragger.getDraggerCallbacks();
33    os.writeSize( callbacks.size() ); os << osgDB::BEGIN_BRACKET << std::endl;
34    for ( osgManipulator::Dragger::DraggerCallbacks::const_iterator itr=callbacks.begin();
35          itr!=callbacks.end(); ++itr )
36    {
37        osgManipulator::DraggerTransformCallback* dtcb =
38            dynamic_cast<osgManipulator::DraggerTransformCallback*>( itr->get() );
39        if ( dtcb )
40        {
41            os << std::string("DraggerTransformCallback") << osgDB::BEGIN_BRACKET << std::endl;
42            os << dtcb->getTransform();
43        }
44        else
45        {
46            os << std::string("DraggerCallback") << osgDB::BEGIN_BRACKET << std::endl;
47        }
48        os << osgDB::END_BRACKET << std::endl;
49    }
50    os << osgDB::END_BRACKET << std::endl;
51    return true;
52}
53
54// DefaultGeometry: FIXME - add a setUseDefaultGeometry(bool) here?
55static bool checkDefaultGeometry( const osgManipulator::Dragger& dragger )
56{ return true; }
57
58static bool readDefaultGeometry( osgDB::InputStream& is, osgManipulator::Dragger& dragger )
59{
60    bool useDefGeometry = false; is >> useDefGeometry;
61    dragger.setupDefaultGeometry();
62    return true;
63}
64
65static bool writeDefaultGeometry( osgDB::OutputStream& os, const osgManipulator::Dragger& dragger )
66{
67    os << true << std::endl;
68    return true;
69}
70
71REGISTER_OBJECT_WRAPPER( osgManipulator_Dragger,
72                         /*new osgManipulator::Dragger*/NULL,
73                         osgManipulator::Dragger,
74                         "osg::Object osg::Node osg::Transform osg::MatrixTransform osgManipulator::Dragger" )
75{
76    // Dragger should not record children seperately, so ignore the osg::Group class wrapper
77
78    ADD_BOOL_SERIALIZER( HandleEvents, false );  // _handleEvents
79    ADD_BOOL_SERIALIZER( DraggerActive, false );  // _draggerActive
80    ADD_UINT_SERIALIZER( ActivationModKeyMask, 0 );  // _activationModKeyMask
81    ADD_INT_SERIALIZER( ActivationKeyEvent, 0 );  // _activationKeyEvent
82    ADD_USER_SERIALIZER( TransformUpdating );  // _draggerCallbacks
83    ADD_USER_SERIALIZER( DefaultGeometry );
84}
Note: See TracBrowser for help on using the browser.