MeVisLab Toolbox Reference
SoPointingAction.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_POINTING_ACTION_H
14 #define SO_POINTING_ACTION_H
15 
16 #include "SoInteraction.h"
17 #include "SoPointerPosition.h"
18 
20 
21 class SoViewerProxy;
22 class SoPointingAction;
25 
26 class SoOffsetAction;
27 
28 // typedef for callback that signals that the controller should release its
29 // pointing grab
30 typedef void (*grabReleaseFunc) (SoPointingAction*, void*);
31 
89 {
91  friend class SoOffsetPointingAction;
92 
93 public:
95  typedef enum {
99 
102  enum {
107  };
108 
110 
114 
116  typedef std::list<Trigger> TriggerList;
117 
123  SoPointingAction(SoInteractionOwner* owner, std::string id, bool positionSensitive = true);
124 
131  virtual bool isPositionSensitive() const { return _positionSensitive; }
132 
134  void clearTriggers() { _triggers.clear(); }
135 
138  void setTrigger(int triggerMask, int ignoreMask = 0);
139 
141  void setTrigger(const Trigger& trigger);
142 
144  void addTrigger(const Trigger& trigger);
145 
147  TriggerList getTriggers() const { return _triggers; }
148 
153  virtual bool triggersAction(int mask);
154 
158  virtual int getNumModes() const { return 1; }
159 
166  virtual int getCurrentCursor(SoViewerProxy* /*viewerProxy*/) const { return -1; }
167 
172  virtual std::string getCurrentStatusMessage() const { return std::string(); }
173 
178  virtual void setMode(int /*mode*/) {}
179 
185  virtual bool isSensitiveAt(const SoPointerPosition& pos) = 0;
186 
189  virtual void setHighlightAt(const SoPointerPosition& /*pos*/) {}
190 
194  virtual void unsetHighlight() {}
195 
199  virtual void startPressAt(const SoPointerPosition& pos) = 0;
200 
202  virtual void dragMoveTo(const SoPointerPosition& pos) = 0;
203 
219  virtual SoPointingAction* endPress(int clickCount) = 0;
220 
226  virtual void dragCancelled() { endPress(0); }
227 
236  virtual bool wantsMouseOverUpdates() { return false; }
237 
240  void grabReleased();
241 
248  virtual void releaseGrab(StopMode /*mode*/) {}
249 
256  virtual bool wantsImmediateDragUpdates() { return true; }
257 
258 protected:
259  // Internal interface, do not override:
260  // For SoOffsetPointingAction this returns the SoOffsetAction that is proxied by this object.
261  virtual SoOffsetAction* proxiedOffsetAction() const { return nullptr; }
262 
263 private:
266 
269  void setGrabReleaseCB (grabReleaseFunc cb, void* data);
270 
272  bool _positionSensitive;
273 
276  TriggerList _triggers;
277 
279  grabReleaseFunc _grabReleaseCB;
280 
282  void* _grabReleaseData;
283 };
284 
285 #endif // __SoPointingAction_H
#define SOMANAGEDINTERACTION_API
File to resolve system dependencies in View2D library.
void(* grabReleaseFunc)(SoPointingAction *, void *)
@ Button2Mask
Middle button.
Class ManagedMouseButtonTrigger encapsulates the combination of required and ignored mouse buttons an...
Provides coordinating interface to the SoInteractionHandlers in the scene.
SoInteractionOwner is a mix-in class for instances of SoNode that should have interaction objects.
SoInteractionProvider is an abstract interface class that provides interactions to the SoInteractionC...
SoInteraction is the base class for SoCommandAction, SoPointingAction, and SoOffsetAction.
Definition: SoInteraction.h:36
SoOffsetAction is the base class for any interaction that only provides (numeric) offsets in one or t...
SoOffsetPointingAction is an internal proxy class that helps controlling SoOffsetActions through a So...
SoPointingAction * endPress(int clickCount) override
Ends the drag at last device position.
SoPointerPosition manages the current position of the mouse cursor.
SoPointingAction is the base class for any mouse based interaction.
@ Button1Mask
Left button.
@ Button2Mask
Middle button.
@ Button3Mask
Right button.
@ AllButtonsMask
All buttons.
StopMode
Argument type for releaseGrab()
@ AbortAction
Current action should be aborted.
@ FinishAction
Current action should be finished.
TriggerList getTriggers() const
Returns the list of default modifier/button mask combinations set for this action.
SoPointingAction(SoInteractionOwner *owner, std::string id, bool positionSensitive=true)
Standard constructor.
virtual void dragCancelled()
This is called if the current drag operation is cancelled, e.g.
void addTrigger(const Trigger &trigger)
Adds another default modifier/button mask as trigger.
virtual void unsetHighlight()
Remove any highlighting if this method is called.
virtual SoOffsetAction * proxiedOffsetAction() const
virtual std::string getCurrentStatusMessage() const
Returns a status message for display in status bar (make it short!), this will get called at same tim...
ManagedMouseButtonTrigger Trigger
Class Trigger encapsulates the combination of required and ignored button and modifier keys that acti...
virtual void setMode(int)
This gets called if the mode was changed and before startPressAt is called.
virtual int getCurrentCursor(SoViewerProxy *) const
Returns the cursor ID to display for this action, as defined in SoViewerProxy.h - this gets (at least...
virtual bool isPositionSensitive() const
Position sensitive actions can only start at positions where isSensitiveAt() return true.
virtual SoPointingAction * endPress(int clickCount)=0
Ends the drag at last device position.
virtual int getNumModes() const
Returns the number of different modes this action has - modes can be changed during drag and handle d...
virtual void startPressAt(const SoPointerPosition &pos)=0
Starts a drag at given device position.
virtual bool wantsImmediateDragUpdates()
Let this method return false if you don't want dragMoveTo to be called until it is clear that the int...
void clearTriggers()
remove all triggers
std::list< Trigger > TriggerList
List of triggers.
void setTrigger(const Trigger &trigger)
Same with Trigger object.
virtual void releaseGrab(StopMode)
This will be called by the controller if you should release the grab established by endPress.
void setTrigger(int triggerMask, int ignoreMask=0)
Sets the (only) default modifier/button mask for triggering this action.
virtual bool wantsMouseOverUpdates()
Override this to return true if this action should get location updates directly before rendering,...
virtual bool triggersAction(int mask)
Returns whether the given modifier/button combination activates this action according to the default ...
virtual void setHighlightAt(const SoPointerPosition &)
This method is called so that highlighting of objects under the mouse cursor can occur.
virtual void dragMoveTo(const SoPointerPosition &pos)=0
Continues the drag to given device position.
void grabReleased()
Call this to release an interaction grab that has been established by the return value of endPress(),...
virtual bool isSensitiveAt(const SoPointerPosition &pos)=0
Returns true if the gesture is startable at the given device position.
This class gives access to state of a viewer during scene graph traversal.
Definition: SoViewerProxy.h:30