MeVisLab Toolbox Reference
SoCSODrawOnSurfaceActions.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2016, 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#pragma once
14
15#include "SoCSODrawOnSurface.h"
16
17#include <View2DPosition.h>
18#include <Inventor/SoPickedPoint.h>
19
21{
22public:
23 SoCSODrawOnSurfaceDrawAction(SoCSODrawOnSurface* owner, int modifierKey) : SoPointingAction(owner, "SoCSODrawOnSurfaceAction")
24 {
25 setTriggerMask(modifierKey);
26 }
27
28 void setTriggerMask(int modifierKey)
29 {
30 if (modifierKey == AllModifiersMask)
31 {
33 }
34 else
35 {
36 setTrigger(Button1Mask | modifierKey);
37 }
38 }
39
41 {
42 const SbVec2s& windowSize = pos.getAction()->getViewportRegion().getWindowSize();
43 return (pos[0] >= 0) &&
44 (pos[1] >= 0) &&
45 (pos[0] <= windowSize[0]) &&
46 (pos[1] <= windowSize[1]);
47 }
48
49 bool isSensitiveAt(const SoPointerPosition& pos) override
50 {
51 if (pos.getAction() && static_cast<SoCSODrawOnSurface*>(getOwner())->hasCSOList())
52 {
53 const SoPickedPoint* pickedPoint = pos.getAction()->getPickedPoint();
54 if (pickedPoint)
55 {
56 return true;
57 }
58 }
59 return false;
60 }
61
62 void startPressAt(const SoPointerPosition& pos) override
63 {
64 static_cast<SoCSODrawOnSurface*>(getOwner())->startPressAt(pos);
65 }
66
67 void dragMoveTo(const SoPointerPosition& pos) override
68 {
69 if (!isInViewportRegion(pos))
70 {
71 static_cast<SoCSODrawOnSurface*>(getOwner())->cancel();
72 }
73 else
74 {
75 static_cast<SoCSODrawOnSurface*>(getOwner())->dragMoveTo(pos);
76 }
77 }
78
80 {
81 static_cast<SoCSODrawOnSurface*>(getOwner())->endPress();
82 return nullptr;
83 }
84
85 int getCurrentCursor(SoViewerProxy*) const override
86 {
87 return static_cast<SoCSODrawOnSurface*>(getOwner())->cursorShapeDraw.getValue();
88 }
89};
90
92
99
106
108{
109 static_cast<SoCSODrawOnSurface*>(getOwner())->cancel();
110}
111
113
115{
116public:
118 void execute() override;
119};
120
127
129{
130 static_cast<SoCSODrawOnSurface*>(getOwner())->undo();
131}
132
134
136{
137public:
139 void execute() override;
140};
141
148
150{
151 static_cast<SoCSODrawOnSurface*>(getOwner())->redo();
152}
SoCSODrawOnSurfaceCancelCommandAction(SoCSODrawOnSurface *owner)
void execute() override
Executes the action. Must be overridden by user.
void startPressAt(const SoPointerPosition &pos) override
SoPointingAction * endPress(int) override
bool isSensitiveAt(const SoPointerPosition &pos) override
int getCurrentCursor(SoViewerProxy *) const override
void dragMoveTo(const SoPointerPosition &pos) override
Continues the drag to given device position.
SoCSODrawOnSurfaceDrawAction(SoCSODrawOnSurface *owner, int modifierKey)
bool isInViewportRegion(const SoPointerPosition &pos) const
void execute() override
Executes the action. Must be overridden by user.
SoCSODrawOnSurfaceRedoCommandAction(SoCSODrawOnSurface *owner)
SoCSODrawOnSurfaceUndoCommandAction(SoCSODrawOnSurface *owner)
void execute() override
Executes the action. Must be overridden by user.
ManagedKeyboardShortcut Shortcut
SoCommandAction(SoInteractionOwner *owner, std::string id)
bool setShortcut(const std::string &shortcut)
virtual void setEnabled(bool enabled)
Sets the enabled status of this interaction.
SoInteractionOwner * getOwner() const
Returns the interaction provider of this entry.
SoPointerPosition manages the current position of the mouse cursor.
SoHandleEventAction * getAction() const
Returns the Inventor action.
@ Button1Mask
Left button.
SoPointingAction(SoInteractionOwner *owner, std::string id, bool positionSensitive=true)
void setTrigger(int triggerMask, int ignoreMask=0)