VR-Forces 4.0.4 Class Documentation
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions
makVrv::DtInputDriver Class Reference

This class's main responsibility is to handle keyboard and mouse events from OSG (Qt events are routed through OSG when a Qt window is used). More...

Inheritance diagram for makVrv::DtInputDriver:
Inheritance graph
[legend]

List of all members.

Public Types

typedef std::list
< DtEventProcessorInterface * > 
EventProcessorList
 A list of DtEventProcessorInterface, called in order for each event until one handles it.
typedef std::map< std::string,
makArchives::DtObserverStateRecord
ObserverStateMap
 A map of observer names, to DtObserverStateRecords.
typedef std::map< std::string,
DtObserverConfiguration
ObserverConfigurationMap
 A map of observer names, to DtObserverConfigurations.

Public Member Functions

 DtInputDriver (DtAgentManager &agentManager, const std::string &instanceName)
 CTOR.
virtual ~DtInputDriver ()
 DTOR.
virtual bool onStart ()
 Create and initialize our listener.
virtual bool onStop ()
 Uninitialize and destroy our listener.
virtual bool onTick ()
 Tick our keyboard/mouse listener.
virtual const std::string & className () const
 Get the class name for the input driver.
virtual bool processKeyEvent (const DtKeyEvent &keyEvent, DtChannel *channel)
 handle a key event from our listener
virtual bool processMouseEvent (const DtMouseEvent &mouseEvent, DtChannel *channel)
 handle a mouse event from our listener
virtual void hideMouse (DtChannel *channel, float mouseX, float mouseY)
 hide the mouse cursor
virtual bool isMouseHidden () const
 Check to see if the mouse is hidden.
virtual void showMouse (DtChannel *channel)
 show the mouse cursor
virtual void centerMouse (DtChannel *channel)
 warp the mouse cursor to the center of the view
virtual void setMousePosition (DtChannel *channel, float x, float y)
 warp the mouse cursor to the given window position
virtual void clearState ()
 clear any remembered keyboard modifiers and stop any observer motion
DtChannelcurrentChannel () const
 the last channel a mouse or keyboard event was received in.
virtual void addEventProcessorToFront (DtEventProcessorInterface *epi)
 This transfers resource management of the event processor to the input driver.
virtual void addEventProcessorToBack (DtEventProcessorInterface *epi)
 Add an event processor to the driver.
virtual EventProcessorListeventProcessorList ()
 Get the list of event processors.
virtual DtEventProcessorInterfacefindEventProcessor (const std::string &className)
 Find an event processor owned by the input driver that has the specified class name.
virtual void removeEventProcessor (DtEventProcessorInterface *epi)
 Remove an event processor from the driver.
bool saveKeyMapToFile (const DtKeyMap &keyMap, const std::string &filename) const
 Save a key map to a file.
DtKeyMaploadKeyMapFromFile (const std::string &filename, bool createBackup=false)
 Save a key map to a file.
void setKeyMap (const std::string &mapName)
 explicitly set a key map
const std::string & keyMap () const
 Get the name of the current keyMap.
DtKeyMapcreateKeyMap (const std::string &mapName)
 create a (blank) key map
DtKeyMapfindKeyMap (const std::string &mapName)
 lookup a key map
void addKeyBinding (DtKeyMap *map, DtKeyState::KeyType key, std::string functionName, DtKeyState::KeyModifier modifiers=DtKeyState::NO_MODIFIER, bool replace=false, DtKeyEvent::KeyEventType eventType=DtKeyEvent::KEY_DOWN)
 bind a key down or key up event (possibly modified) to a function name
void addBinaryKeyBinding (DtKeyMap *map, DtKeyState::KeyType key, std::string binaryName, DtKeyState::KeyModifier modifiers=DtKeyState::NO_MODIFIER, bool replace=false)
 bind the up and down events for a key (possibly modified) to a binary function set
virtual void realizeConfiguration (const DtInputDriverConfiguration &configuration)
 Realize the driver using the configuration.
virtual void realizeObserverConfiguration (const DtObserverConfiguration &configuration)
const ObserverConfigurationMapobserverConfigurations () const
void addObserverConfiguration (const DtObserverConfiguration &config)
 name is already in the config...
void addObserverState (const std::string &observerName, const makArchives::DtObserverStateRecord &stateRecord)
 put this state onto the observerState map and, if the observer currently exists, set its state from this record
void initializeObserver (DtObserver *observer, const makArchives::DtObserverStateRecord &stateRecord)
 set the state of the specified observer from stateRecord.
virtual void addObserver (DtObserver *observer)
 Observer Management.
virtual void removeObserver (DtObserver *observer)
 Remove an observer object from the manager.
virtual void removeObserver (const std::string &name)
 Remove an observer object from the manager.
virtual std::vector< DtObserver * > observers () const
 Get a list of all observers.
void setCurrentObserver (const std::string &observerName)
 Set the current observer by name.
DtObservercurrentObserver () const
 Get the current observer.
void setTerrainContextEnabled (bool enabled)
 Set whether terrain context menus are enabed.
bool terrainContextEnabled () const
virtual void performObserverAction (DtViewStateProcessor::ObserverAction &action)
 View controls:
virtual void toggleTerrainScaling ()
 Toggle terrain scaling on or off (XR only)
virtual void incrementTerrainScaleFactor ()
 Increment terrain scale factor (XR only)
virtual void decrementTerrainScaleFactor ()
 Decrement terrain scale factor (XR only)
virtual void toggleEntityLabels ()
 Toggle entity labels on or off.
virtual void toggleTacticalGraphics ()
 Toggle tactical graphics display on or off.
virtual void toggleEntityHatLines ()
 Toggle entity height above terrain lines display on or off.
virtual void toggleTacticalGraphicsHatLines ()
 Toggle tactical graphics height above terrain lines display on or off.
virtual void toggleEntityHatMode ()
 Toggle entity height above terrain mode.
virtual void toggleTacticalGraphicsHatMode ()
 Toggle tactical graphics height above terrain mode.
virtual void togglePropTransparencySelected ()
 Toggles the transparency of all selected props.
void resetObservers (DtUniqueID id)
 Reset all of the observers to the unique id.
void setAllowObserverReset (bool allow)
 Control whether reset observers functions or not.
void saveObservers (const std::string &filename)
 Create an observer settings file.
void loadObservers (const std::string &filename)
 Load an observer settings file.
DtElementEntry::ObjectType typeFromId (const DtUniqueID &id)
virtual DtObserverfindObserverByName (const std::string &name)
 Find an observer by its name.
virtual const DtObserverfindObserverByName (const std::string &name) const
 Find an observer by its name.

Protected Types

typedef std::map< std::string,
DtObserver * > 
ObserversMap
 Observer Manager bound.

Protected Member Functions

void setCurrentObserver (DtObserver *observer)
virtual void initializeKeyMapManager (const std::string &defaultKeyMap)
 This will eventually load up key maps.
virtual void bindFunctions ()
virtual void createMaps ()
 This creates the default key maps by hand. Kept around for now.
virtual void loadMaps (bool loadFromFactory=false)
 Load all the key maps (*.kmpx) files in the $APP_DIR/settings directory.
void removeObserver (ObserversMap &observers, DtObserver *observer)
void removeObserver (ObserversMap &observers, const std::string &name)
void destroyObservers ()
bool setCurrentObserverFromChannel (const DtChannel &channel)
void slot_channelCreated (DtChannelManager *channelManager, DtChannel *channel)
void slot_channelDestroyed (DtChannelManager *channelManager, DtChannel *channel)
void slot_channelConfigurationModified (const std::string &deName, const std::string &winName, const std::string &oldChannelName, const DtChannelConfiguration &config)
void slot_attachedToChanged (DtObserver *observer)
void createRequiredObservers (const std::string &engineName)
virtual void slot_displayEngineAdded (const DtDeRecord &igRecord)
 Called when a display engine is added. Restarts this driver.
std::string restoreObserversPart1 ()
 Create a temporary observer settings file using a default filename - called when a display engine is added, before shutting down.
void restoreObserversPart2 (const std::string &filename)
 Loads a temporary observer settings file and deletes the file.
virtual void slot_displayEngineRealized (const std::string &, const std::string &engineName)

Protected Attributes

DtDemyDe
EventProcessorList myEventProcessors
ObserversMap myObservers
DtObserverControllermyObserverController
ObserverConfigurationMap myObserverConfigurations
ObserverStateMap myObserverStates
std::string myClassName
DtKeyAndMouseEventListenermyKeyAndMouseEventListener
DtObservermyCurrentObserver
 Temp, so we can look this up ONCE each event.
bool myAllowResetFlag
 Control whether observers can be reset.
bool myIsTerrainContextEnabled
 Switch to enable or disable terrain context menus;.
DtChannelmyCurrentChannel
DtKeyMapManagermyCachedKeyMapManager
bool mySyncingObservers

Private Member Functions

 DtInputDriver (const DtInputDriver &)
 Copy Constructor (not implemented)
DtInputDriveroperator= (const DtInputDriver &)
 Assignment Operator (not implemented)

Detailed Description

This class's main responsibility is to handle keyboard and mouse events from OSG (Qt events are routed through OSG when a Qt window is used).


Member Typedef Documentation

A list of DtEventProcessorInterface, called in order for each event until one handles it.

A map of observer names, to DtObserverStateRecords.

A map of observer names, to DtObserverConfigurations.

typedef std::map<std::string, DtObserver*> makVrv::DtInputDriver::ObserversMap [protected]

Observer Manager bound.


Constructor & Destructor Documentation

makVrv::DtInputDriver::DtInputDriver ( DtAgentManager agentManager,
const std::string &  instanceName 
)

CTOR.

DTOR.

Copy Constructor (not implemented)


Member Function Documentation

virtual bool makVrv::DtInputDriver::onStart ( ) [virtual]

Create and initialize our listener.

Implements makVrv::DtDriver.

virtual bool makVrv::DtInputDriver::onStop ( ) [virtual]

Uninitialize and destroy our listener.

Implements makVrv::DtDriver.

virtual bool makVrv::DtInputDriver::onTick ( ) [virtual]

Tick our keyboard/mouse listener.

Implements makVrv::DtDriver.

virtual const std::string& makVrv::DtInputDriver::className ( ) const [virtual]

Get the class name for the input driver.

Implements makVrv::DtDriver.

virtual bool makVrv::DtInputDriver::processKeyEvent ( const DtKeyEvent keyEvent,
DtChannel channel 
) [virtual]

handle a key event from our listener

virtual bool makVrv::DtInputDriver::processMouseEvent ( const DtMouseEvent mouseEvent,
DtChannel channel 
) [virtual]

handle a mouse event from our listener

virtual void makVrv::DtInputDriver::hideMouse ( DtChannel channel,
float  mouseX,
float  mouseY 
) [virtual]

hide the mouse cursor

virtual bool makVrv::DtInputDriver::isMouseHidden ( ) const [virtual]

Check to see if the mouse is hidden.

virtual void makVrv::DtInputDriver::showMouse ( DtChannel channel) [virtual]

show the mouse cursor

virtual void makVrv::DtInputDriver::centerMouse ( DtChannel channel) [virtual]

warp the mouse cursor to the center of the view

virtual void makVrv::DtInputDriver::setMousePosition ( DtChannel channel,
float  x,
float  y 
) [virtual]

warp the mouse cursor to the given window position

virtual void makVrv::DtInputDriver::clearState ( ) [virtual]

clear any remembered keyboard modifiers and stop any observer motion

the last channel a mouse or keyboard event was received in.

Note that this may be Null if no events have happened on any channel OR if the last channel that received an event has been destroyed. Do not hold onto channel pointers unless you are also listening for channelToBeDestroyed signals.

This transfers resource management of the event processor to the input driver.

Add an event processor to the driver.

It will be added to the back of the processor list in priority. This transfers resource management of the event processor to the input driver.

Get the list of event processors.

Intended for more complex ordering of several event processors by mutating the list. Processors in the list are managed by the input driver.

virtual DtEventProcessorInterface* makVrv::DtInputDriver::findEventProcessor ( const std::string &  className) [virtual]

Find an event processor owned by the input driver that has the specified class name.

Returns 0 if none is found.

Remove an event processor from the driver.

This will remove the first processor in the list that matches the passed-in pointer. This relinquishes resource management of the event processor from the input driver.

bool makVrv::DtInputDriver::saveKeyMapToFile ( const DtKeyMap keyMap,
const std::string &  filename 
) const

Save a key map to a file.

DtKeyMap* makVrv::DtInputDriver::loadKeyMapFromFile ( const std::string &  filename,
bool  createBackup = false 
)

Save a key map to a file.

If createBackup is true, creates a backup object in the key map manager to manage key map backups

void makVrv::DtInputDriver::setKeyMap ( const std::string &  mapName)

explicitly set a key map

Note that if you name a map that does not exist, the input driver will throw an exception

const std::string& makVrv::DtInputDriver::keyMap ( ) const

Get the name of the current keyMap.

DtKeyMap* makVrv::DtInputDriver::createKeyMap ( const std::string &  mapName)

create a (blank) key map

DtKeyMap* makVrv::DtInputDriver::findKeyMap ( const std::string &  mapName)

lookup a key map

void makVrv::DtInputDriver::addKeyBinding ( DtKeyMap map,
DtKeyState::KeyType  key,
std::string  functionName,
DtKeyState::KeyModifier  modifiers = DtKeyState::NO_MODIFIER,
bool  replace = false,
DtKeyEvent::KeyEventType  eventType = DtKeyEvent::KEY_DOWN 
)

bind a key down or key up event (possibly modified) to a function name

void makVrv::DtInputDriver::addBinaryKeyBinding ( DtKeyMap map,
DtKeyState::KeyType  key,
std::string  binaryName,
DtKeyState::KeyModifier  modifiers = DtKeyState::NO_MODIFIER,
bool  replace = false 
)

bind the up and down events for a key (possibly modified) to a binary function set

virtual void makVrv::DtInputDriver::realizeConfiguration ( const DtInputDriverConfiguration configuration) [virtual]

Realize the driver using the configuration.

virtual void makVrv::DtInputDriver::realizeObserverConfiguration ( const DtObserverConfiguration configuration) [virtual]

name is already in the config...

If the input driver is already started, this will create the observer indicated. In any event, the configuration goes onto the configuration list (so it will be created on inputDriver start

void makVrv::DtInputDriver::addObserverState ( const std::string &  observerName,
const makArchives::DtObserverStateRecord stateRecord 
)

put this state onto the observerState map and, if the observer currently exists, set its state from this record

set the state of the specified observer from stateRecord.

This does NOT put the state record onto the onbserverState map; use addObserverState to do that

virtual void makVrv::DtInputDriver::addObserver ( DtObserver observer) [virtual]

Observer Management.

add an observer object to the manager

virtual void makVrv::DtInputDriver::removeObserver ( DtObserver observer) [virtual]

Remove an observer object from the manager.

virtual void makVrv::DtInputDriver::removeObserver ( const std::string &  name) [virtual]

Remove an observer object from the manager.

virtual std::vector<DtObserver*> makVrv::DtInputDriver::observers ( ) const [virtual]

Get a list of all observers.

virtual DtObserver* makVrv::DtInputDriver::findObserverByName ( const std::string &  name) [virtual]

Find an observer by its name.

virtual const DtObserver* makVrv::DtInputDriver::findObserverByName ( const std::string &  name) const [virtual]

Find an observer by its name.

void makVrv::DtInputDriver::setCurrentObserver ( const std::string &  observerName)

Set the current observer by name.

Get the current observer.

Set whether terrain context menus are enabed.

View controls:

Run a function on the "main" observer

virtual void makVrv::DtInputDriver::toggleTerrainScaling ( ) [virtual]

Toggle terrain scaling on or off (XR only)

Increment terrain scale factor (XR only)

Decrement terrain scale factor (XR only)

virtual void makVrv::DtInputDriver::toggleEntityLabels ( ) [virtual]

Toggle entity labels on or off.

Toggle tactical graphics display on or off.

virtual void makVrv::DtInputDriver::toggleEntityHatLines ( ) [virtual]

Toggle entity height above terrain lines display on or off.

Toggle tactical graphics height above terrain lines display on or off.

virtual void makVrv::DtInputDriver::toggleEntityHatMode ( ) [virtual]

Toggle entity height above terrain mode.

Toggle tactical graphics height above terrain mode.

Toggles the transparency of all selected props.

Reset all of the observers to the unique id.

Control whether reset observers functions or not.

This is used during saving/loading scene for connecting slaves not to modify the observers.

void makVrv::DtInputDriver::saveObservers ( const std::string &  filename)

Create an observer settings file.

void makVrv::DtInputDriver::loadObservers ( const std::string &  filename)

Load an observer settings file.

void makVrv::DtInputDriver::setCurrentObserver ( DtObserver observer) [protected]
virtual void makVrv::DtInputDriver::initializeKeyMapManager ( const std::string &  defaultKeyMap) [protected, virtual]

This will eventually load up key maps.

virtual void makVrv::DtInputDriver::bindFunctions ( ) [protected, virtual]
virtual void makVrv::DtInputDriver::createMaps ( ) [protected, virtual]

This creates the default key maps by hand. Kept around for now.

virtual void makVrv::DtInputDriver::loadMaps ( bool  loadFromFactory = false) [protected, virtual]

Load all the key maps (*.kmpx) files in the $APP_DIR/settings directory.

If loadFromFactory is true, loads from factory directory, not app directory

void makVrv::DtInputDriver::removeObserver ( ObserversMap observers,
DtObserver observer 
) [protected]
void makVrv::DtInputDriver::removeObserver ( ObserversMap observers,
const std::string &  name 
) [protected]
void makVrv::DtInputDriver::slot_channelCreated ( DtChannelManager channelManager,
DtChannel channel 
) [protected]
void makVrv::DtInputDriver::slot_channelDestroyed ( DtChannelManager channelManager,
DtChannel channel 
) [protected]
void makVrv::DtInputDriver::slot_channelConfigurationModified ( const std::string &  deName,
const std::string &  winName,
const std::string &  oldChannelName,
const DtChannelConfiguration config 
) [protected]
void makVrv::DtInputDriver::createRequiredObservers ( const std::string &  engineName) [protected]
virtual void makVrv::DtInputDriver::slot_displayEngineAdded ( const DtDeRecord igRecord) [protected, virtual]

Called when a display engine is added. Restarts this driver.

Reimplemented from makVrv::DtDriver.

std::string makVrv::DtInputDriver::restoreObserversPart1 ( ) [protected]

Create a temporary observer settings file using a default filename - called when a display engine is added, before shutting down.

Returns the name of the file.

void makVrv::DtInputDriver::restoreObserversPart2 ( const std::string &  filename) [protected]

Loads a temporary observer settings file and deletes the file.

virtual void makVrv::DtInputDriver::slot_displayEngineRealized ( const std::string &  ,
const std::string &  engineName 
) [protected, virtual]
DtInputDriver& makVrv::DtInputDriver::operator= ( const DtInputDriver ) [private]

Assignment Operator (not implemented)


Member Data Documentation

std::string makVrv::DtInputDriver::myClassName [protected]

Temp, so we can look this up ONCE each event.

Control whether observers can be reset.

Switch to enable or disable terrain context menus;.


The documentation for this class was generated from the following file:

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)