MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
SoInteractionOwner.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2014, 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_INTERACTION_OWNER_H
14#define SO_INTERACTION_OWNER_H
15
18
20
21#include <ThirdPartyWarningsDisable.h>
22#include <string>
23#include <ThirdPartyWarningsRestore.h>
24
26
29{
30public:
32
34 virtual void interactionAdded(SoInteractionOwner* /*owner*/, SoInteraction* /*interaction*/)
35 {}
36
39 virtual void interactionRemoved(SoInteractionOwner* /*owner*/, SoInteraction* /*interaction*/)
40 {}
41
43 virtual void ownerDeleted(SoInteractionOwner* /*owner*/)
44 {}
45};
46
50{
51 friend class SoInteraction;
52
53public:
56
59
64 virtual void objRef() = 0;
65 virtual void objUnref() = 0;
66
68 virtual std::string getID() const;
69
71 std::list<SoInteraction*> getInteractions(SoState* state) override;
72
74 void pointerPosition(SoState* state, const SoPointerPosition& pos) override;
75
77 void pointerLeftWindow(SoState* state) override;
78
81
84
85protected:
87 virtual void pointerPosition(const SoPointerPosition& /*pos*/)
88 {}
89
91 virtual void pointerLeftWindow()
92 {}
93
95 bool hasInteractions() const
96 {
97 return !_interactions.empty();
98 }
99
101 template <class T> bool hasInteractionsOfType() const;
102
105 [[deprecated("Happens in constructor of SoInteraction now")]]
107
108 [[deprecated("Happens in constructor of SoInteraction now")]]
110
111 [[deprecated("Happens in constructor of SoInteraction now")]]
114
115private:
118
120 void addInteraction(SoInteraction* interaction);
121
123 void removeInteraction(SoInteraction* interaction);
124
126 std::list<SoInteraction*> _interactions;
127
129 std::list<SoInteractionOwnerListenerInterface*> _listeners;
130
132 bool _inDestructor;
133};
134
135template <class T> bool SoInteractionOwner::hasInteractionsOfType() const
136{
137 std::list<SoInteraction*>::const_iterator it = _interactions.begin();
138 for (; it != _interactions.end(); it++) {
139 if ((*it)->isOfType<T>()) {
140 return true;
141 }
142 }
143 return false;
144}
145
146#endif // __SoInteractionOwner_H
@ T
#define SOMANAGEDINTERACTION_API
File to resolve system dependencies in View2D library.
SoCommandAction is the base class for instantaneous actions.
Interface for getting notified about changes in the interaction list of an owner.
virtual void interactionAdded(SoInteractionOwner *, SoInteraction *)
This gets called when an interaction is added to the owner.
virtual ~SoInteractionOwnerListenerInterface()=default
virtual void interactionRemoved(SoInteractionOwner *, SoInteraction *)
This gets called when an interaction is removed from the owner (this is not called when the owner is ...
virtual void ownerDeleted(SoInteractionOwner *)
This gets called when the owner is deleted.
SoInteractionOwner is a mix-in class for instances of SoNode that should have interaction objects.
virtual void objRef()=0
Memory management by reference counting; must be implemented in derived classes.
virtual void pointerPosition(const SoPointerPosition &)
Override this if you always need to be informed of the current mouse cursor position.
void pointerPosition(SoState *state, const SoPointerPosition &pos) override
Same as below, with additional SoState argument. By default, simply calls the below version.
void pointerLeftWindow(SoState *state) override
Same as below, with additional SoState argument. By defaults, simply calls the below version.
void addCommandAction(SoCommandAction *)
~SoInteractionOwner() override
The destructor will destroy all interactions created with this object as owner.
std::list< SoInteraction * > getInteractions(SoState *state) override
Returns the list of all interactions of this provider.
bool hasInteractionsOfType() const
Same as above, but asking for a specific type of interaction.
virtual std::string getID() const
Returns the ID string for identifying the provider and its actions.
void addPointingAction(SoPointingAction *)
void addOffsetAction(SoOffsetAction *)
bool hasInteractions() const
Returns whether there are any actions defined by this owner.
void addListener(SoInteractionOwnerListenerInterface *listener)
Adds a listener object that is notified of changes in the interaction list.
void removeListener(SoInteractionOwnerListenerInterface *listener)
Removes a listener object that was notified of changes in the interaction list.
virtual void pointerLeftWindow()
This is called when the mouse cursor leaves the window.
SoInteractionOwner()
Default constructor.
virtual void objUnref()=0
SoInteractionProvider is an abstract interface class that provides interactions to the SoInteractionC...
virtual void pointerLeftWindow(SoState *state)=0
This is called when the mouse cursor leaves the window.
virtual void pointerPosition(SoState *state, const SoPointerPosition &pos)=0
Override this to always be informed of the current mouse cursor position.
SoInteraction is the base class for SoCommandAction, SoPointingAction, and SoOffsetAction.
SoOffsetAction is the base class for any interaction that only provides (numeric) offsets in one or t...
SoPointerPosition manages the current position of the mouse cursor.
SoPointingAction is the base class for any mouse based interaction.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.