MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
SoView2DRigidRegistrationEditorBase.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2013, 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// editor for setting a rigid registration
14
15#pragma once
16
18
19#include <Inventor/nodes/SoSubNode.h>
20#include <View2DSlice.h>
21#include <View2DSliceList.h>
22#include <View2DIcons.h>
23// include used fields
24#include <Inventor/fields/SoSFTrigger.h>
25#include <Inventor/fields/SoSFVec3f.h>
26#include <Inventor/fields/SoSFColor.h>
27#include <Inventor/fields/SoSFMatrix.h>
28#include <Inventor/sensors/SoFieldSensor.h>
29#include <Inventor/sensors/SoNodeSensor.h>
30#include <Inventor/SbLinear.h>
31
32
34
35
38{
40 SO_NODE_ABSTRACT_HEADER(SoView2DRigidRegistrationEditorBase);
41
42public:
44 SoView2DRigidRegistrationEditorBase(const std::string& actionID);
45
47 static void initClass();
48
49 void draw(View2DSliceList* list, View2DSlice* slice, int z) override;
50
53
56
60
63
67
71
77
82
83 virtual void doReset();
84
85protected:
88
90 {
91 return false;
92 }
93
96 bool isSensitiveAt(const SoPointerPosition&) override;
98 void setHighlightAt(const SoPointerPosition& pos) override;
99 void unsetHighlight() override;
100 void startPressAt(const SoPointerPosition& pos) override;
101 void dragMoveTo(const SoPointerPosition& pos) override;
102 SoPointingAction* endPress(int clickCount) override;
104
107 {
108 doReset();
109 }
111 {
112 _calcRotationCenter = true;
113 }
115 {
116 _initializeImages();
117 }
118
120 void pointerPosition(const SoPointerPosition& pos) override;
121 void pointerLeftWindow() override;
122
135
137 virtual void pushOldState(const RegistrationState& /*state*/)
138 {}
139
142
143private:
146
148 enum Part {
149 OtherPart,
150 RotationCenter,
151 RotationWheel
152 };
153
155 void _startDrag(const SbVec3f& voxelPos);
156 void _dragTo(View2DSliceList* sliceList, const SbVec3f& voxelPos);
157 void _endDrag();
159
161 bool _pointerInViewer;
162
164 bool _isDragging;
165
167 void _drawIconAt(int index, const SbVec2f& p0, const SbVec2f& d1, const SbVec2f& d2, float size);
168
170 void _drawTexture(View2DTexture* texture, const SbVec2f& p0, const SbVec2f& p1, const SbVec2f& p2);
172
174 Part _getPart(View2DSlice* slice, const SbVec3f& worldPos) const;
175
177 float _getWidgetSize(View2DSlice* slice) const;
178
180 void _initializeImages();
181
182 void _setUndoEnabled(bool enabled);
183 void _setRedoEnabled(bool enabled);
184
186 View2DIcons* _images;
187
189 View2DSlice* _currentInteractionSlice;
190
192 SbVec3f _startingPointWorld;
193
195 RegistrationState _startingState;
196
198 Part _currentPart;
199
201 bool _calcRotationCenter;
202
204 class CommandAction : public SoCommandAction
205 {
206 public:
207 CommandAction(SoView2DRigidRegistrationEditorBase* owner, const std::string& id)
208 : SoCommandAction(owner, id)
209 {}
210
211 inline SoView2DRigidRegistrationEditorBase* getWidget() const
212 {
213 return static_cast<SoView2DRigidRegistrationEditorBase*>(getOwner());
214 }
215 };
216
217 class ResetAction : public CommandAction
218 {
219 public:
220 ResetAction(SoView2DRigidRegistrationEditorBase* owner)
221 : CommandAction(owner, "ResetManualRegistration")
222 {}
223
224 void execute() override
225 {
226 getWidget()->doReset();
227 }
228 };
229
230 ResetAction* _resetAction;
232};
#define SOVIEW2D_API
File to resolve system dependencies in View2D library.
SoCommandAction is the base class for instantaneous actions.
void pointerPosition(SoState *state, const SoPointerPosition &pos) override
Same as below, with additional SoState argument. By default, simply calls the below version.
virtual void pointerLeftWindow()
This is called when the mouse cursor leaves the window.
SoPointerPosition manages the current position of the mouse cursor.
SoPointingAction is the base class for any mouse based interaction.
SoView2DInteractionExtension is base class for all SoView2DExtensions that want to support the Manage...
interactive editor to accumulate a transformation matrix
void setRegistrationState(const RegistrationState &state)
void doResetCallback(SoField *)
field change callbacks:
void pointerPosition(const SoPointerPosition &pos) override
interface inherited from SoInteractionProvider
bool implementsManagedInteractionAndClassicEventHandling() const override
this node is a hybrid module providing managed interaction and classic event handling
~SoView2DRigidRegistrationEditorBase() override
Protected destructor.
SoSFVec3f rotationCenterWorld
the current rotation center in world coordinates
int getCurrentCursor(SoViewerProxy *viewerProxy) override
interface forwarded from SoPointingAction:
SoPointingAction * endPress(int clickCount) override
void draw(View2DSliceList *list, View2DSlice *slice, int z) override
Called by the SoView2D for each slice that is rendered.
static void initClass()
Initializes this class (called on dll initialization).
bool getRegistrationState(RegistrationState &state) const
virtual void pushOldState(const RegistrationState &)
callback for undo system
SoSFString resolvedWheelImageFile
appearance configuration
void pointerLeftWindow() override
This is called when the mouse cursor leaves the window.
SoSFMatrix defaultOutputMatrix
default values for outputMatrix and rotationCenterWorld, these will propagate directly and reset the ...
void dragMoveTo(const SoPointerPosition &pos) override
void startPressAt(const SoPointerPosition &pos) override
void setHighlightAt(const SoPointerPosition &pos) override
bool isSensitiveAt(const SoPointerPosition &) override
interface forwarded from SoPointingAction:
SoSFMatrix outputMatrix
matrix with the current registration matrix
SoView2DRigidRegistrationEditorBase(const std::string &actionID)
Constructor.
This class gives access to state of a viewer during scene graph traversal.
Defines and implements a class to store multiple images and draw them via OpenGL.
Definition View2DIcons.h:24
a list that holds all View2DSlice objects (lazily created) of a SoView2D
a single slice that is stored in a View2DSliceList, typically created by a View2DSliceList
Definition View2DSlice.h:48
A class to render images as OpenGL Textures.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.