MeVisLab Toolbox Reference
SoCommandAction.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2008, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef SO_COMMAND_ACTION_H
14 #define SO_COMMAND_ACTION_H
15 
16 #include "SoInteraction.h"
17 
18 #include <ThirdPartyWarningsDisable.h>
19 #include <Inventor/events/SoKeyboardEvent.h>
20 
21 #include <map>
22 #include <ThirdPartyWarningsRestore.h>
23 
25 
26 class SoNode;
27 
45  : public SoInteraction
46 {
47 public:
48 
49  enum { TypeId = TypeCommandAction };
50 
54 
56  typedef std::list<Shortcut> ShortcutList;
57 
60 
62  typedef std::list<Shortcut> TriggerList;
63 
68  SoCommandAction(SoInteractionOwner* owner, std::string id);
69 
72  bool setShortcut(const std::string& shortcut);
73 
75  void setShortcut(const Shortcut& shortcut);
76 
78  void addShortcut(const Shortcut& shortcut);
79 
81  void clearShortcuts() { _shortcuts.clear(); }
82 
84  ShortcutList getShortcuts() const { return _shortcuts; }
85 
87  TriggerList getTriggers() const { return _shortcuts; }
88 
93  virtual bool isShortcut(int modifiers, SoKeyboardEvent::Key keyCode) const;
94 
96  virtual void execute() = 0;
97 
98 private:
99  ShortcutList _shortcuts;
100 };
101 
102 #endif // __SoCommandAction_H
#define SOMANAGEDINTERACTION_API
File to resolve system dependencies in View2D library.
Class ManagedKeyboardShortcut encapsulates the combination of modifier keys and another key that acti...
SoCommandAction is the base class for instantaneous actions.
ManagedKeyboardShortcut Shortcut
Class Shortcut encapsulates the combination of modifier keys and another key that activates a command...
SoCommandAction(SoInteractionOwner *owner, std::string id)
Standard constructor:
ManagedKeyboardShortcut Trigger
Also define Trigger as synonym for Shortcut, since that name is used by the other interactions.
void setShortcut(const Shortcut &shortcut)
Set the (only) default key shortcut.
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 ...
bool setShortcut(const std::string &shortcut)
Set the (only) default key shortcut (as string describing the shortcut, see ManagedKeyboardShortcut::...
virtual void execute()=0
Execute the action. Must be overridden by user.
void addShortcut(const Shortcut &shortcut)
Add another default key shortcut.
void clearShortcuts()
Clear all currently set shortcuts.
ShortcutList getShortcuts() const
Get the default key shortcuts.
std::list< Shortcut > TriggerList
Define TriggerList as synonym for ShortcutList.
std::list< Shortcut > ShortcutList
A list of shortcuts.
TriggerList getTriggers() const
Alternative name for getShortcuts()
SoInteractionOwner is a mix-in class for instances of SoNode that should have interaction objects.
SoInteraction is the base class for SoCommandAction, SoPointingAction, and SoOffsetAction.
Definition: SoInteraction.h:36