MeVisLab Toolbox Reference
SoView2DInteraction.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2017, 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 <SoInteractionHandler.h>
16 
17 #include "SoView2DExtension.h"
18 #include "View2DPosition.h"
19 
23 {
24 public:
26  void setDevicePosition(const SbVec2f& pos) { _relPos = pos; }
27  void setVoxelPosition(const SbVec3f& pos) { _voxelPos = pos; }
28  void setViewport(const SbVec2f& origin, const SbVec2f& size)
29  {
30  _vpOrigin = origin; _vpSize = size;
31  }
32 };
33 
34 //===================================================================================
35 
40 {
41 public:
43 
44 protected:
46  bool augmentLocation(SoPointerPosition& position, bool dragging) override;
47 
49  bool isEnabled(SoPointingAction* action, int currentMask) override;
50 
53  bool isValidStartingLocation(const SoPointerPosition& location) override;
54 
58 
61 
63  bool _dragging;
64 };
65 
70 {
71 public:
73 
75  std::list<SoInteraction*> getInteractions(SoState* state) override;
76 
78  void pointerPosition(SoState* state, const SoPointerPosition& pos) override;
79 
81  void pointerLeftWindow(SoState* state) override;
82 
83 protected:
86  const SoNodeList* getExtensionList(SoState* state);
87 
90 
93 };
94 
96 {
97 public:
98  SoView2DKeyboardAction(SoView2D* view, const std::string& id, SoKeyboardEvent::Key key, bool withShift = false);
99  SoView2DKeyboardAction(SoView2D* view, const std::string& id, SoKeyboardEvent::Key key, SoKeyboardEvent::Key key2);
100 
101  bool isNumberKey() const { return _numberKey; }
102 
103  void execute() override;
104 
105 protected:
106  SoView2D* getView() const;
108 };
MutableView2DPosition just exists as a way to set the values in a View2DPosition object which will be...
void setVoxelPosition(const SbVec3f &pos)
void setDevicePosition(const SbVec2f &pos)
MutableView2DPosition(SoView2D *viewer)
void setViewport(const SbVec2f &origin, const SbVec2f &size)
SoCommandAction is the base class for instantaneous actions.
SoInteractionHandler is a mix-in class for instances of SoNode to handle the interactions it provides...
SoInteractionProvider is an abstract interface class that provides interactions to the SoInteractionC...
SoPointerPosition manages the current position of the mouse cursor.
SoPointingAction is the base class for any mouse based interaction.
SoView2DExtension Base class for all View2DExtensions used for drawing and event handling on the View...
SoView2DKeyboardAction(SoView2D *view, const std::string &id, SoKeyboardEvent::Key key, SoKeyboardEvent::Key key2)
void execute() override
Execute the action. Must be overridden by user.
SoView2DKeyboardAction(SoView2D *view, const std::string &id, SoKeyboardEvent::Key key, bool withShift=false)
SoView2D * getView() const
SoView2D is a 2D viewer for image data.
Definition: SoView2D.h:62
View2DInteractionHandler is derived from SoInteractionHandler mainly to provide additional SoView2D i...
bool _dragging
While dragging convert positions relative to the start slice.
MutableView2DPosition _view2DPosition
We always use the same View2DPosition object - we can only get one event at a time,...
bool isValidStartingLocation(const SoPointerPosition &location) override
Only start pointing actions on a valid starting location (to allow cooperation between multiple SoVie...
bool isEnabled(SoPointingAction *action, int currentMask) override
Only enable actions if the image in the SoView2D is valid.
View2DInteractionHandler(SoView2D *viewer, SoInteractionProvider *provider)
SoView2D * _viewer
Back-reference to the SoView2D object.
bool augmentLocation(SoPointerPosition &position, bool dragging) override
Set SoView2D information in position.
The View2DInteractionProvider extracts the interactions from the SoView2DExtensions.
SoView2D * _viewer
Back-reference to the SoView2D object.
const SoNodeList * getExtensionList(SoState *state)
Return list of extensions at the moment - returns NULL if the current action is not set in the SoView...
void pointerLeftWindow(SoState *state) override
Forwarding to the SoView2DExtensions.
bool isExtensionEnabled(SoView2DExtension *ext) const
return true if interactions from the given SoView2DExtension should be handled
std::list< SoInteraction * > getInteractions(SoState *state) override
return interactions from SoView2DExtensions
void pointerPosition(SoState *state, const SoPointerPosition &pos) override
Forwarding to the SoView2DExtensions.
View2DInteractionProvider(SoView2D *viewer)
This class stores all position information needed by SoView2DExtensions to handle the pointer positio...