MeVisLab Toolbox Reference
SoCommandAction Class Referenceabstract

SoCommandAction is the base class for instantaneous actions. More...

#include <SoCommandAction.h>

Inheritance diagram for SoCommandAction:
SoInteraction CSOCancelCommandAction CSOCopyCommandAction CSOCutCommandAction CSODeleteCSOCommandAction CSODeleteSeedPointCommandAction CSOPasteCommandAction CSORedoCommandAction CSORemoveAllCommandAction CSOUndoCommandAction SoCSODrawOnSurfaceCancelCommandAction SoCSODrawOnSurfaceRedoCommandAction SoCSODrawOnSurfaceUndoCommandAction SoView2DKeyboardAction

Public Types

enum  { TypeId = TypeCommandAction }
 
typedef ManagedKeyboardShortcut Shortcut
 Class Shortcut encapsulates the combination of modifier keys and another key that activates a command. More...
 
typedef std::list< ShortcutShortcutList
 A list of shortcuts. More...
 
typedef ManagedKeyboardShortcut Trigger
 Also define Trigger as synonym for Shortcut, since that name is used by the other interactions. More...
 
typedef std::list< ShortcutTriggerList
 Define TriggerList as synonym for ShortcutList. More...
 
- Public Types inherited from SoInteraction
enum  {
  NoModifier = ManagedActionTrigger::NoModifier , ShiftModifier = ManagedActionTrigger::ShiftModifier , ControlModifier = ManagedActionTrigger::ControlModifier , AltModifier = ManagedActionTrigger::AltModifier ,
  AllModifiersMask = ManagedActionTrigger::AllModifiersMask , ShiftMask = ShiftModifier , CtrlMask = ControlModifier , AltMask = AltModifier
}
 Constants to use where keyboard modifiers must be specified. More...
 
enum  InteractionType { TypePointingAction , TypeCommandAction , TypeOffsetAction }
 Enum identifying sub-types of this class. More...
 

Public Member Functions

 SoCommandAction (SoInteractionOwner *owner, std::string id)
 Standard constructor: More...
 
bool setShortcut (const std::string &shortcut)
 Set the (only) default key shortcut (as string describing the shortcut, see ManagedKeyboardShortcut::fromString) More...
 
void setShortcut (const Shortcut &shortcut)
 Set the (only) default key shortcut. More...
 
void addShortcut (const Shortcut &shortcut)
 Add another default key shortcut. More...
 
void clearShortcuts ()
 Clear all currently set shortcuts. More...
 
ShortcutList getShortcuts () const
 Get the default key shortcuts. More...
 
TriggerList getTriggers () const
 Alternative name for getShortcuts() More...
 
virtual bool isShortcut (int modifiers, SoKeyboardEvent::Key keyCode) const
 Check if the given key with the given modifiers is a shortcut for this action; see SoInteraction for possible modifiers. More...
 
virtual void execute ()=0
 Execute the action. Must be overridden by user. More...
 
- Public Member Functions inherited from SoInteraction
 SoInteraction (InteractionType type, SoInteractionOwner *owner, const std::string &id, bool registerWithOwner=true)
 Standard constructor. More...
 
virtual ~SoInteraction ()
 Virtual destructor. More...
 
SoInteractionOwnergetOwner () const
 
virtual bool isEnabled () const
 
virtual void setEnabled (bool enabled)
 Sets the enabled status of this interaction. More...
 
std::string getID () const
 
void setID (const std::string &id)
 Sets the id of this interaction. More...
 
std::string getFullID () const
 Returns the ID string consisting of the id of the provider and this action's id, separated by '. More...
 
InteractionType getInteractionType () const
 Get type of interaction object. More...
 
template<class T >
bool isOfType () const
 Convenience method for checking type. More...
 
int getMenuPriority () const
 
void setMenuPriority (int priority)
 Sets the priority value for ordered display in menus/tool boxes. More...
 
virtual std::string getUserName () const
 
virtual void setUserName (const std::string &name)
 Sets the user name of this interaction entry. More...
 
virtual std::string getIconFile () const
 
virtual void setIconFile (const std::string &file)
 Sets the filename of an icon used for this interaction entry. More...
 
virtual std::string getDescription () const
 
virtual void setDescription (const std::string &descr)
 Sets the description for user help. More...
 
virtual void ref ()
 
virtual void unref ()
 
int getStateVersion () const
 
void touch ()
 Increments the version number of attribute state to mark attribute changes. More...
 

Detailed Description

SoCommandAction is the base class for instantaneous actions.

You need to override execute() in derived classes!

Some special action IDs should be reserved for special purposes (or rather for standard edit commands): undo, redo, cut, copy, paste, and selectAll; - if you implement these, implement the expected behavior!

Note
If you want to implement commands that act on a specific cursor location you need to override the methods SoInteractionProvider::pointerPosition and SoInteractionProvider::pointerLeftWindow in your node and store the required information in member variables.
You should always disable a SoCommandAction if it currently can't be applied, so that other command actions that use the same keyboard shortcut can be applied instead.

Definition at line 44 of file SoCommandAction.h.

Member Typedef Documentation

◆ Shortcut

Class Shortcut encapsulates the combination of modifier keys and another key that activates a command.

Definition at line 53 of file SoCommandAction.h.

◆ ShortcutList

A list of shortcuts.

Definition at line 56 of file SoCommandAction.h.

◆ Trigger

Also define Trigger as synonym for Shortcut, since that name is used by the other interactions.

Definition at line 59 of file SoCommandAction.h.

◆ TriggerList

Define TriggerList as synonym for ShortcutList.

Definition at line 62 of file SoCommandAction.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
TypeId 

Definition at line 49 of file SoCommandAction.h.

Constructor & Destructor Documentation

◆ SoCommandAction()

SoCommandAction::SoCommandAction ( SoInteractionOwner owner,
std::string  id 
)

Standard constructor:

Parameters
owneris the SoInteractionOwner to which the action is added. Ownership is automatically transferred, you don't need to free this object.
idis the name of this interaction, it should hint at its purpose

Member Function Documentation

◆ addShortcut()

void SoCommandAction::addShortcut ( const Shortcut shortcut)

Add another default key shortcut.

◆ clearShortcuts()

void SoCommandAction::clearShortcuts ( )
inline

Clear all currently set shortcuts.

Definition at line 81 of file SoCommandAction.h.

◆ execute()

◆ getShortcuts()

ShortcutList SoCommandAction::getShortcuts ( ) const
inline

Get the default key shortcuts.

Definition at line 84 of file SoCommandAction.h.

◆ getTriggers()

TriggerList SoCommandAction::getTriggers ( ) const
inline

Alternative name for getShortcuts()

Definition at line 87 of file SoCommandAction.h.

◆ isShortcut()

virtual bool SoCommandAction::isShortcut ( int  modifiers,
SoKeyboardEvent::Key  keyCode 
) const
virtual

Check if the given key with the given modifiers is a shortcut for this action; see SoInteraction for possible modifiers.

Overrides from the interaction controller are ignored by this method.

◆ setShortcut() [1/2]

void SoCommandAction::setShortcut ( const Shortcut shortcut)

Set the (only) default key shortcut.

◆ setShortcut() [2/2]


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