Interactor
[The interaction protocol]

Collaboration diagram for Interactor:

TO DO . More...

Classes

class  OMK::Iii::InteractiveExtension
 The extension to make an object interactive. More...
class  OMK::Iii::InteractorExtension
 Ancestor of every interactive, interactor or inspector objects. More...
class  OMK::Iii::InteractorOutput
 This class defines informations about interactor output. More...
class  OMK::Iii::SessionPrm
 Define a session of interaction between an interactor and an interactive object. More...

Detailed Description

TO DO .

How to define an interactor object ?

To define an interactor object you have to:

Create interactor extension

To define your own interactor you have to define a new interactor extension. By using InteractorExtension as base class you don't have to create the interactor outputs, they will be automatically created with the informations find in the configuration parameters of the extension.

The main job to do in your extension is to create a state machine call by the postComputeParameters. The state of the machine will evolve according to events that the object will receive, so you will need to define some listeners and associated call back methods to update the internal state of your states machine.

Example of interactor

The following example shows a code that define an interactor object based on the SimplePoint which define a position in the space. To convert this simple object in an interactor we have to define a interactor extension and add this one to it. In the code, we found To use the extension you have to add it to the object in the configuration file
interactor
{
  Class SimplePoint
  Scheduling
  {
    Frequency 60
  }
  Extensions
  {
    interactor
    {
      Class MyInteractorExtension
      Level 0                       // The access level of the interactor
      Outputs                       // Define the interactor outputs
      {
        Position                    // for the attribute "Position"
        {
          Category "absolute"       // The category of the output
        }
      }
      VisuName visuOgre             // Specific parameter of MyInteractorExtension to activate the keyboard
    }
  }
}

Example of session

Written like this, the interactor cannot control anything. We must add to it some features to get the id of an interactive object. This id can be gotten by picking in a scene or by an event sent to the interactor,...
Once this is done, it can start the interaction. To do this part of its job, it can use the session object. This object is designed to manage the communication through events of the protocol between the interactor and an interactive object.
First it must start the session with a simulated object indicated by its id.
startSessionWith( _interactiveObject ) ;
This command creates a session and send the "parameters ?" event to the simulated object. If this one is an interactive one, it is answering with the list of its interactive parameters according to the access level of the interactor and those of its parameters. When the listener of the interactor receives this list it is mapping the type and category of the each parameters to those of the interactor outputs. Once this is done, the session is initialized and a list of the parameters controllable is established. Now the session object knows which parameter can be controlled and by which output.
The next step can be to retrieve the current values of the parameters. This is useful to initialize the output values to avoid difference between the output which will take the control of a parameter and the current value of this one. The answer calls indirectly the call back method associated to each interactor output.
To ask for all available parameters associable to an interactor output, the call is:
(*getSessionWith( _interactiveObject )).c( OM::Iii::getCurrentValues ) ;
If only some parameters are wanted, you must specify the output you want to use, the call becomes:
(*getSessionWith( _interactiveObject )).c( Prm::integerValue ).c( OM::Iii::getCurrentValues ) ;
The same syntax is used for 'control take over', 'control release', 'control freeze' and 'control unfreeze'

How to extend the behavior ?

As shown in How to extend the behavior ? the accessors can do few more things than only accessed the parameters, they can define new behaviors. The other way to extend the behavior is to define new kind of session with more functionalities.

By creating a new kind of session

This example shows a session object, which uses id to indicate if the interactive parameter will be frozen when its control is taken over. This example cannot be used as this, it is not functional.

This new session object will be created like this by the interactor:
class MyInteractorObject : public OM::Iii::InteractiveSimulatedObject
{
  //...  
  // Overwrites the startSessionWith method to use the new session object instead of the old one 
  virtual void startSessionWith( const PsName& interactiveObject ) 
  {
    OMASSERT( _eventInteractiveObjectListener && "cannot be null, must be an initialized interactor object" ) ;
    _eventInteractiveObjectListener->addSession( SessionPrmBis::create( _eventInteractiveObjectListener, interactiveObject ) ) ;
  } 
  //...
} ;
The startSessionWith method can be overwritten by the EventInteractiveObjectListener, which can also extend the behavior. It can offer different session types.
So there is no change to start a session in the interactor methods:
startSessionWith( _interactiveObject ) ;
And it will be used like this with the 'control take over' operation:
(*getSessionWith( _interactiveObject ))).c( Prm::integerValue  ).c( frozen )
                                        .c( Prm::floatingValue ).c( notFrozen )
                                        .c( OM::Iii::controlTakeOver ) ;

logo OpenMask

Documentation generated on Mon Jun 9 11:46:00 2008

Generated with doxygen by Dimitri van Heesch ,   1997-2007