MeVisLab Toolbox Reference
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
38 virtual void interactionRemoved(SoInteractionOwner* /*owner*/, SoInteraction* /*interaction*/) {}
39
41 virtual void ownerDeleted(SoInteractionOwner* /*owner*/) {}
42};
43
47{
48 friend class SoInteraction;
49
50public:
53
56
61 virtual void objRef() = 0;
62 virtual void objUnref() = 0;
63
65 virtual std::string getID() const;
66
68 std::list<SoInteraction*> getInteractions(SoState* state) override;
69
71 void pointerPosition(SoState* state, const SoPointerPosition& pos) override;
72
74 void pointerLeftWindow(SoState* state) override;
75
78
81
82protected:
84 virtual void pointerPosition(const SoPointerPosition& /*pos*/) {}
85
87 virtual void pointerLeftWindow() {}
88
90 bool hasInteractions() const { return !_interactions.empty(); }
91
93 template<class T>
94 bool hasInteractionsOfType() const;
95
102
103private:
106
108 void addInteraction(SoInteraction* interaction);
109
111 void removeInteraction(SoInteraction* interaction);
112
114 std::list<SoInteraction*> _interactions;
115
117 std::list<SoInteractionOwnerListenerInterface*> _listeners;
118
120 bool _inDestructor;
121};
122
123template<class T>
125{
126 std::list<SoInteraction*>::const_iterator it = _interactions.begin();
127 for(;it!=_interactions.end();it++) {
128 if ((*it)->isOfType<T>()) {
129 return true;
130 }
131 }
132 return false;
133}
134
135#endif // __SoInteractionOwner_H
@ T
#define SOMANAGEDINTERACTION_API
File to resolve system dependencies in View2D library.
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 *)
virtual void ownerDeleted(SoInteractionOwner *)
This gets called when the owner is deleted.
virtual void objRef()=0
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
virtual void pointerLeftWindow(SoState *state)=0
This is called when the mouse cursor leaves the window.
SoInteractionProvider()
Default constructor.
virtual void pointerPosition(SoState *state, const SoPointerPosition &pos)=0
Override this to always be informed of the current mouse cursor position.
SoPointerPosition manages the current position of the mouse cursor.