Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   Namespace Members   Compound Members   Related Pages  

Composition::GizmoI Class Reference

Gizmo interface. More...

#include <GizmoI.h>

Inheritance diagram for Composition::GizmoI:

Edit::EditableI Edit::DataBlockI List of all members.

Public Methods

Protected Methods


Detailed Description

Gizmo interface.

Gizmo holds a set of parameters, which should form a logical group of information, such as geometric transformation of the effect. Gizmo interface also contains logic to respond the change of a parameter. This respond can be for example to get information from thru a file parameter and pass it to other parameters.

The developer of the plugin is responsible to write a gizmo class for each different gizmo that is used by the plugin. If only simple gizmo is needed, use Composition::AutoGizmoC class instead.

To create a new instace of the gizmo class a static member should be created, which takes care of the instantiating. The member could look like this:

An ID is attached to each gizmo. When a parameter is changed on a gizmo, the parameter send a notify to the gizmo via the update_notify() method, the update notify is relayed to the effect via effects update_notify method. When handling a notify message each parameter and gizmo can be identified from the ID.

        TestGizmoC*
        TestGizmoC::create_new( EffectI* pParent, uint32 ui32Id )
        {
            return new TestGizmoC( pParent, ui32Id );
        }


Constructor & Destructor Documentation

GizmoI ( ) [protected]
 

Default constructor.

GizmoI ( EffectI * pParent,
PajaTypes::uint32 ui32Id ) [protected]
 

Constructor.

Parameters:
pParent   pointer to the effect which is holds this gizmo.
ui32Id   ID of the gizmo, this ID is passed to the update_notify() method.

GizmoI ( Edit::EditableI * pOriginal ) [protected]
 

Constructor with reference to the original.

~GizmoI ( ) [protected, virtual]
 

Default destructor.


Member Function Documentation

void add_flags ( PajaTypes::int32 i32Flags ) [virtual]
 

Sets only specified flags.

Implemented by the GizmoI class.

void copy ( Edit::DataBlockI * pBlock ) [virtual]
 

Deep copy from a data block, see Edit::DataBlockI::copy().

When overriding this method the base class member should be called first.

Example:

            void
            TestGizmoC::copy( DataBlockI* pBlock )
            {
                GizmoI::copy( pBlock );
                TestGizmoC* pGizmo = (TestGizmoC*)pBlock;
                m_pParamPos->copy( pGizmo->m_pParamPos );
                m_pParamSize->copy( pGizmo->m_pParamSize );
                m_pParamFile->copy( pGizmo->m_pParamFile );
                m_pParamCamera->copy( pGizmo->m_pParamCamera );
            }

Reimplemented from Edit::EditableI.

void del_flags ( PajaTypes::int32 i32Flags ) [virtual]
 

Removes only specified flags.

Implemented by the GizmoI class.

PajaTypes::int32 get_flags ( ) [virtual]
 

Returns gizmo flags.

Implemented by the GizmoI class.

PajaTypes::uint32 get_id ( ) [virtual]
 

Returns the ID of the gizmo.

Implemented by the GizmoI class.

const char * get_name ( ) const [virtual]
 

Returns the name of the gizmo as NULL terminated string.

Implemented by the GizmoI class.

ParamI * get_parameter ( PajaTypes::int32 i32Index ) [pure virtual]
 

Returns parameter at specified index.

PajaTypes::int32 get_parameter_count ( ) [pure virtual]
 

Returns number of parameters in the gizmo.

PajaTypes::uint32 load ( FileIO::LoadC * pLoad ) [virtual]
 

Serialize the gizmo from a Demopaja input stream.

The base class implementation of this method has to be called in the overridden method.

Example:

            uint32
            TestGizmoC::load( LoadC* pLoad )
            {
                uint32  ui32Error = IO_OK;
                while( (ui32Error = pLoad->open_chunk()) == IO_OK ) {
                    switch( pLoad->get_chunk_id() ) {
                    case CHUNK_TESTGIZMO_GIZMOI:
                        if( pLoad->get_chunk_version() == TESTGIZMO_VERSION )
                            ui32Error = GizmoI::load( pLoad );
                        break;
                    default:
                        assert( 0 );
                    }
                    pLoad->close_chunk();
                    if( ui32Error != IO_OK && ui32Error != IO_END )
                        return ui32Error;
                }
                return ui32Error;
            }

Reimplemented from Edit::EditableI.

void restore ( Edit::EditableI * pEditable ) [virtual]
 

Shallow copy from a editable, see Edit::EditableI::restore().

When overriding this method the base class member should be called first.

Example:

            void
            TestGizmoC::restore( EditableI* pEditable )
            {
                GizmoI::restore( pEditable );
                TestGizmoC* pGizmo = (TestGizmoC*)pEditable;
                m_pParamPos = pGizmo->m_pParamPos;
                m_pParamSize = pGizmo->m_pParamSize;
                m_pParamFile = pGizmo->m_pParamFile;
                m_pParamCamera = pGizmo->m_pParamCamera;
            }

Reimplemented from Edit::EditableI.

PajaTypes::uint32 save ( FileIO::SaveC * pSave ) [virtual]
 

Serialize the gizmo to a Demopaja output stream.

The base class implementation of this method has to be called in the overridden method.

Example:

            uint32
            TestGizmoC::save( SaveC* pSave )
            {
                uint32  ui32Error = IO_OK;
                // GizmoI stuff
                pSave->begin_chunk( CHUNK_TESTGIZMO_GIZMOI, TESTGIZMO_VERSION );
                    ui32Error = GizmoI::save( pSave );
                pSave->end_chunk();
                return ui32Error;
            }

Reimplemented from Edit::EditableI.

void set_flags ( PajaTypes::int32 i32Flags ) [virtual]
 

Sets the gizmo flags.

Be careful to use this method. There are some flags, which have to be in place to make the gizmo work correctly. Use add, del or toggle flags methods instead. Implemented by the GizmoI class.

void set_id ( PajaTypes::uint32 ui32Id ) [virtual]
 

Sets the ID of the gizmo.

Implemented by the GizmoI class.

void set_name ( const char * szName ) [virtual]
 

Sets the name of the gizmo.

Implemented by the GizmoI class.

void toggle_flags ( PajaTypes::int32 i32Flags ) [virtual]
 

Toggles only specified flags.

Implemented by the GizmoI class.

void update_notify ( PajaTypes::uint32 ui32Id,
PajaTypes::int32 i32Time ) [virtual]
 

This method is called when a parameter is changed.

The default implementation relays the message to the parent effect. The base class method should be called as shown in the example.

Example:

            void
            TestGizmoC::update_notify( uint32 ui32Id, int32 i32Time )
            {
                if( ui32Id == ID_TEST_PARAMFILE ) {
                    // The file has changed
                    // Get undo object from the changed parameter.
                    UndoC*          pUndo = m_pParamFile->get_undo();
                    FileHandleC*    pHandle = 0;
                    MASImportC*     pImp = 0;
                    // Get importable.
                    pHandle = m_pParamFile->get_file();
                    if( pHandle )
                        pImp = (MASImportC*)pHandle->get_importable();
                    if( pImp ) {
                        // Update labels
                        // Begin undo block.
                        UndoC*  pOldUndo = m_pParamCamera->begin_editing( pUndo );
                        // Set labels in camera parameter to the names of the cameras in the file.
                        m_pParamCamera->clear_labels();     // m_pParamCamera is integer parameter
                        for( uint32 i = 0; i < pImp->get_camera_count(); i++ ) {
                            CameraC*    pCam = pImp->get_camera( i );
                            if( !pCam ) continue;
                            m_pParamCamera->add_label( i, pCam->get_name() );
                        }
                        m_pParamCamera->set_min_max( 0, pImp->get_camera_count() );
                        // Close undo block.
                        m_pParamCamera->end_editing( pOldUndo );
                    }
                }
                // Relay the message to the effect
                GizmoI::update_notify( ui32Id, i32Time );
            }


The documentation for this class was generated from the following file:
Moppi Demopaja SDK Documentation -- Copyright © 2000 Moppi Productions