MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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:
24 : SoPointingAction(owner, "SoCSODrawOnSurfaceAction")
25 {
26 setTriggerMask(modifierKey);
27 }
28
29 void setTriggerMask(int modifierKey)
30 {
31 if (modifierKey == AllModifiersMask) {
33 }
34 else {
35 setTrigger(Button1Mask | modifierKey);
36 }
37 }
38
40 {
41 const SbVec2s& windowSize = pos.getAction()->getViewportRegion().getWindowSize();
42 return (pos[0] >= 0) && (pos[1] >= 0) && (pos[0] <= windowSize[0]) && (pos[1] <= windowSize[1]);
43 }
44
45 bool isSensitiveAt(const SoPointerPosition& pos) override
46 {
47 if (pos.getAction() && static_cast<SoCSODrawOnSurface*>(getOwner())->hasCSOList()) {
48 const SoPickedPoint* pickedPoint = pos.getAction()->getPickedPoint();
49 if (pickedPoint) {
50 return true;
51 }
52 }
53 return false;
54 }
55
56 void startPressAt(const SoPointerPosition& pos) override
57 {
58 static_cast<SoCSODrawOnSurface*>(getOwner())->startPressAt(pos);
59 }
60
61 void dragMoveTo(const SoPointerPosition& pos) override
62 {
63 if (!isInViewportRegion(pos)) {
64 static_cast<SoCSODrawOnSurface*>(getOwner())->cancel();
65 }
66 else {
67 static_cast<SoCSODrawOnSurface*>(getOwner())->dragMoveTo(pos);
68 }
69 }
70
72 {
73 static_cast<SoCSODrawOnSurface*>(getOwner())->endPress();
74 return nullptr;
75 }
76
77 int getCurrentCursor(SoViewerProxy*) const override
78 {
79 return static_cast<SoCSODrawOnSurface*>(getOwner())->cursorShapeDraw.getValue();
80 }
81};
82
84
91
98
100{
101 static_cast<SoCSODrawOnSurface*>(getOwner())->cancel();
102}
103
105
107{
108public:
110 void execute() override;
111};
112
119
121{
122 static_cast<SoCSODrawOnSurface*>(getOwner())->undo();
123}
124
126
128{
129public:
131 void execute() override;
132};
133
140
142{
143 static_cast<SoCSODrawOnSurface*>(getOwner())->redo();
144}
SoCSODrawOnSurfaceCancelCommandAction(SoCSODrawOnSurface *owner)
void execute() override
Executes the action. Must be overridden by user.
void startPressAt(const SoPointerPosition &pos) override
Starts a drag at given device position.
SoPointingAction * endPress(int) override
Ends the drag at last device position.
bool isSensitiveAt(const SoPointerPosition &pos) override
Returns true if the gesture is startable at the given device position.
int getCurrentCursor(SoViewerProxy *) const override
Returns the cursor ID to display for this action, as defined in SoViewerProxy.h - this gets (at least...
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.
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...
bool setShortcut(const std::string &shortcut)
Sets the (only) default key shortcut (as string describing the shortcut, see ManagedKeyboardShortcut:...
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.
SoPointingAction is the base class for any mouse based interaction.
@ Button1Mask
Left button.
void setTrigger(int triggerMask, int ignoreMask=0)
Sets the (only) default modifier/button mask for triggering this action.
This class gives access to state of a viewer during scene graph traversal.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.