MeVisLab Toolbox Reference
SoView2D.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, 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
15
16#pragma once
17
18#include "SoSFMLImage.h"
19#include "SoView2DSystem.h"
20#include "SoView2DExtension.h"
21
22#include <Inventor/fields/SoFields.h>
23#include <Inventor/nodes/SoSubNode.h>
24#include <Inventor/nodes/SoShape.h>
25#include <Inventor/sensors/SoTimerSensor.h>
26#include <Inventor/sensors/SoAlarmSensor.h>
27#include <Inventor/sensors/SoFieldSensor.h>
28#include <Inventor/sensors/SoNodeSensor.h>
29#include <Inventor/nodes/SoSubNode.h>
30#include <Inventor/elements/SoCacheElement.h>
31
33
34class View2DSliceList;
35class View2DCine;
36class View2DFont;
37class View2DLut;
38
40
42
43 class LUTFunction;
44 template <typename T> class LUTData;
45
47
49typedef int (*SliceInitFunc) (const SoView2D *view2D, SoSFMLImage *image, void *user);
50
51
52//=============================================================
54
60//=============================================================
61class SOVIEW2D_API SoView2D : public SoShape, public SoInteractionOwner
62{
63
64 SO_NODE_HEADER(SoView2D);
65
66public:
68
71
74
77
80
83
101
127
130
135
138
143
146
153
158
161
170
173
176
179
182
187
188
193
200
205
210
213
216
219
222
225
228
231
233
235
256
261
265
268
270
271
273
278
281
286
289
291
294
296 static void initClass();
297
300
302 SbString getViewerId() const { return viewerId.getValue(); }
305
308
311 SoAction *getAction() { return _action; }
312
315
318
320 void updateLayout(int viewportX, int viewportY, int viewportWidth, int viewportHeight, bool is3D = false);
321
325 bool handleKeyboardEvent(int nKey, bool shift, bool alt, bool ctrl);
326
328 void computeBBox(SoAction * action, SbBox3f &box, SbVec3f &center) override;
333
342 bool& hit, float& dx, float& dy, SbVec3f& voxelHit,
343 int& sliceID);
344
345
349
351 static View2DFont* globalFont(int /*cacheContext*/) { return globalFont(); }
352
356
365 { _sliceInitFunc = fn; _sliceInitUser = user; }
366
368 SliceInitFunc getSliceInitFunc (void) { return _sliceInitFunc; }
369
372
376
378 void translateInnerSlice(float x, float y);
379
382
384 ml::LUTFunction* getDefaultLut() { return _localLut; }
385
388
394
397
400
404
407
410 static std::string getDICOMTagValue(SoSFMLImage* image, const std::string& dicomTagName);
411
414
415protected:
417 ~SoView2D() override;
418
420
422 void objRef() override { ref(); }
423 void objUnref() override { unref(); }
424
426 std::string getID() const override;
428
432
434
439
442 bool isDeviceCoordInViewerArea (float dx, float dy, const SbVec2s& viewportSize) const;
443
448
452 void sliceUnzoomAction (void);
453
458
462
468
470
475
480
483
487 int setStartSlice (int slice, bool keepInView = false, bool noCB = false);
488
491
496
501
510
513
516
518 void layoutSlices(int wx, int wy);
519
521 void updateLayoutAndDraw(int originX, int originY, int width, int height, bool updateLayoutOnly,
522 SoNodeList* primitives=nullptr,int sharedCacheContext=-1, bool is3D = false, bool reverse = false);
523
526
529
536
543
545
547 SbBool _mouseButton[3];
548
551
554
556
559
564
569
574
576 unsigned int _imageSerialNumber;
577
581
587
592
595};
View2DLutPrecision
allows to set the precision of the LUT
#define SOVIEW2D_API
File to resolve system dependencies in View2D library.
int(* SliceInitFunc)(const SoView2D *view2D, SoSFMLImage *image, void *user)
Callback function type for external specification of initial slice position.
Definition SoView2D.h:49
SoInteractionHandler is a mix-in class for instances of SoNode to handle the interactions it provides...
SoInteractionOwner is a mix-in class for instances of SoNode that should have interaction objects.
SoInteractionProvider is an abstract interface class that provides interactions to the SoInteractionC...
The SoSFMLImage field is the interface used by Inventor Nodes to access image data (in the current im...
Definition SoSFMLImage.h:70
SoView2D is a 2D viewer for image data.
Definition SoView2D.h:62
View2DLut * _lutData
the currently allocated lut data
Definition SoView2D.h:535
SoSFTrigger renderingDone
output field is triggered from the inside when all rendering is done.
Definition SoView2D.h:293
void updateViewingCenterAndPlane()
update viewing center from sliceOrigin and sliceNumber
SoSFVec2f sliceOrigin
the internal origin of the slice in voxels (for shifting inside of the view)
Definition SoView2D.h:163
SbBool isMouseButtonPressed(int i)
returns if given mousebutton (0-2) is currently pressed this is handles by the View2D,...
SoAction * _action
pointer to current action
Definition SoView2D.h:528
SliceInitFunc getSliceInitFunc(void)
Get slice position initialization callback.
Definition SoView2D.h:368
SoSFEnum blendMode
blend mode for rendering
Definition SoView2D.h:85
void stopCineMode()
stop the cine mode
SoSFBool clipBackgroundToImage
clip background to image rect
Definition SoView2D.h:212
SoSFBool deletingEnabled
enable/disable delete-events for SoView2D-Extensions
Definition SoView2D.h:288
SoSFFloat minSliceZoomKeyboard
minimum slice zoom for keyboard modifications (always clamped by MIN_MIN_SLICE_ZOOM and 1....
Definition SoView2D.h:178
ml::LUTFunction * getLutFromScene(SoAction *action)
get the lut from the scene (default ramp if no lut is set)
View2DSliceList * getSliceList()
returns the slicelist that is used to manage the slices
SoSFVec2f upperRight
restrict the rendering to a subpart of the viewer, in normalized coordinated
Definition SoView2D.h:142
void minSliceZoomKeyboardCB(SoField *)
callback for minimum slice zoom modification that performs clamping to value range
SoSFBool passHandledFlagToInventor
Set this true if following inventor nodes should not react to events that have been handled by a SoVi...
Definition SoView2D.h:157
SoFieldSensor * _viewingCenterSensor
sensor for start slice
Definition SoView2D.h:550
SoSFFloat cineSpeed
speed of cine mode (in seconds), minimum cine speed is fixed to one repaint per image
Definition SoView2D.h:255
SbVec2f getSliceSize()
get slice size x/y in millimeters (used by SoOrthoView2D)
SoSFBool handle3DEvents
handle events when rendering in 3D
Definition SoView2D.h:218
SoSFEnum lutPrecision
defines the precision of the LUT
Definition SoView2D.h:100
SoSFEnum cineMode
mode of the Cinemode (Z,T,ZT)
Definition SoView2D.h:249
SoSFString viewerId
id string, needs to be unique in a network if used
Definition SoView2D.h:82
SoSFBool cineModeActive
read-only flag indicating whether cine mode is active or not
Definition SoView2D.h:267
SoSFInt32 numSlices
number of slices that are rendered
Definition SoView2D.h:107
SoSFInt32 cineCenterT
center of timepoint cine
Definition SoView2D.h:241
SoSFInt32 sliceStep
step to next rendered slice
Definition SoView2D.h:105
bool _mouseOverViewer
remember if the mouse cursor is over the viewer area
Definition SoView2D.h:568
SoSFTrigger startCine
Cinemode fields.
Definition SoView2D.h:237
void updateLayoutAndDraw(int originX, int originY, int width, int height, bool updateLayoutOnly, SoNodeList *primitives=nullptr, int sharedCacheContext=-1, bool is3D=false, bool reverse=false)
update layout and draw in 2D or 3D
SoSFInt32 userIndex
the user index the viewers is currently showing
Definition SoView2D.h:120
void viewingCenterChanged()
sets slice origins of all viewers according to current viewing center if synchronizePanning is on
void editObjectsAction()
switch extensions to edit mode
void generatePrimitives(SoAction *action) override
used for 3D picking
SoSFBool handle2DEvents
handle events when rendering in 2D
Definition SoView2D.h:215
static View2DFont * globalFont()
get the global font used for annotations etc.
bool checkValid()
checks if image, start slice, timepoint, and user index are valid
int getMaxStartSlice()
returns the highest sensible value for startSlice
SoSFInt32 cineCenterZ
center of z cine
Definition SoView2D.h:245
ml::LUTFunction * getDefaultLut()
get the default lut object (just a relative ramp from 0 to 1)
Definition SoView2D.h:384
SoSFInt32 timePoint
the timepoint the viewers is currently showing
Definition SoView2D.h:116
SoSFPlane plane
plane representing the slice in world coordinates
Definition SoView2D.h:137
SoSFFloat sliceZoom
the internal zoom of the slice (for zooming inside if the view)
Definition SoView2D.h:165
void updateViewingCenterAndPlaneCB(SoField *)
callback which forwards to updateViewingCenterAndPlane()
SoSFString frameOfReferenceUID
the DICOM frameOfReferenceUID of the image currently displayed.
Definition SoView2D.h:285
void handleEvent(SoHandleEventAction *action) override
handle the mouse and keyboard events and send them to extensions
int getCurrentCenterSlice()
returns the central of all currently visible slices (e.g. startSlice, if numSlices is 1)
SoSFFloat zoomModeParameter
zoom mode parameter, depends on zoomMode what its value means
Definition SoView2D.h:192
void sliceUnzoomAction(void)
Reset slice zoom and translation.
bool _dragging
remember if we are during a drag operation
Definition SoView2D.h:566
SoSFBool enableZBuffer
use Z buffer in 3D rendering
Definition SoView2D.h:224
SoSFVec2f lowerLeft
restrict the rendering to a subpart of the viewer, in normalized coordinated
Definition SoView2D.h:140
SoSFBool applyLut
select if the View2d should apply the scene LUT to the slice data (default is true)
Definition SoView2D.h:98
void updateSliceListOnImageChange()
update the slice list if the image has changed
void updateKeyboardActionEnabledStateCB(SoField *)
update enabled state of the keyboard actions
SoSFBool standardKeysNumbers
enable number keys 0-9, depends on standardKeys being enabled
Definition SoView2D.h:150
SoSFVec2f spacing
spacing between slices
Definition SoView2D.h:134
SoSFEnum cineRepeat
flag to indicated if loop or ping-pong is used
Definition SoView2D.h:253
void handleScheduledActions(const SoNodeList *primitives)
handle the actions given by deleteSelectedObject and editObjects
SoSFBool enableZWrite
write Z buffer in 3D rendering
Definition SoView2D.h:227
SoFieldSensor * _startSliceSensor
sensor for start slice
Definition SoView2D.h:553
SoSFBool enableViewingCenter
If enabled, the viewing center is activated for reading and writing.
Definition SoView2D.h:175
SoSFInt32 cineIntervalT
interval of timepoint cine
Definition SoView2D.h:243
void startCineModeCB(SoField *)
callback that calls startCineMode();
void adjustSliceOriginToCenter(float newSliceZoom)
sets the new sliceZoom value and adjusts the sliceOrigin to zoom to the center of the ROI
bool _editObjectsScheduled
flag if edit mode on extensions should be activated
Definition SoView2D.h:561
void objRef() override
Overriding SoInteractionProvider methods:
Definition SoView2D.h:422
void * _sliceInitUser
user data for _sliceInitFunc
Definition SoView2D.h:573
double _currentLUTImageMax
Definition SoView2D.h:540
SoSFInt32 maxUserIndex
the maximum user index, read from the image, used to restrict userIndex
Definition SoView2D.h:122
bool _useHighColorDepth
Definition SoView2D.h:593
void imageChangedCB(SoField *)
callback that calls imageChanged();
void getLutFromScene(SoAction *action, View2DLut *data)
render the lut into the given lut data object
void updateSliceRepresentingPlane(const SbVec3f &worldCenter)
SoSFInt32 slab
the slab that is rendered (1=only one slice)
Definition SoView2D.h:124
static std::string getDICOMTagValue(SoSFMLImage *image, const std::string &dicomTagName)
Returns the value of a DICOM tag with the given name as a string, or an empty string if the tag was n...
std::string getID() const override
Returns the id string for identifying the provider (and its actions)
SoFieldSensor * _sliceOriginSensor
sensor for slice origin
Definition SoView2D.h:558
void stopCineModeCB(SoField *)
callback that calls stopCineMode();
View2DSliceList * _sliceList
the internal slice list which stores and handles rendered slices
Definition SoView2D.h:531
SoSFFloat devicePixelSize
size of a pixel in mm when rendering in 3D
Definition SoView2D.h:230
SoInteractionHandler * _interactionHandler
Delegate that handles events for the new interaction scheme.
Definition SoView2D.h:583
void deleteSelectedObjectCB(SoField *)
callback that calls deleteSelectedObjectAction();
SoSFEnum sliceAlignY
align the image inside of the slice if there is space left, default is VIEW2D_ALIGN_CENTER
Definition SoView2D.h:186
void deleteSelectedObjectAction()
delete the selected object
bool _deleteSelectedObjectScheduled
flag if delete of object on extension should be activated
Definition SoView2D.h:563
void translateInnerSlice(float x, float y)
translates the inner slice x/y pixel on the screen
SoSFInt32 maxSlice
the maximum slice number, read from the image, used to restrict startSlice
Definition SoView2D.h:111
SoSFString instanceName
Fields.
Definition SoView2D.h:70
void editObjectsCB(SoField *)
callback that calls deleteSelectedObjectAction();
bool isDeviceCoordInViewerArea(float dx, float dy, const SbVec2s &viewportSize) const
Returns if the event of the given action is located over the viewer area for a given viewportSize The...
SoSFInt32 numXSlices
number of slices that are rendered in X
Definition SoView2D.h:109
SoAction * getAction()
get pointer to current action.
Definition SoView2D.h:311
SoSFBool reverseExtensionDrawingOrder
Reverse drawing order of extensions.
Definition SoView2D.h:160
SoSFString seriesInstanceUID
the DICOM seriesInstanceUID of the image currently displayed
Definition SoView2D.h:283
SoSFBool cineFullRangeZ
flag if the full z range or the z interval is used
Definition SoView2D.h:258
void sliceUnzoomCB(SoField *)
callback that calls sliceUnzoomAction();
SoSFString interactionProviderID
This field overrides the instanceName as providerID if specified.
Definition SoView2D.h:73
SoSFBool invertKeyPanningDirections
invert panning by keyboard
Definition SoView2D.h:195
unsigned int _imageSerialNumber
last serial number of image
Definition SoView2D.h:576
int setStartSlice(int slice, bool keepInView=false, bool noCB=false)
set start slice, but obey possible restrictions (returns effective value) if keepInView is set,...
void updateKeyboardActionEnabledState()
void sliceZoomChangedCB(SoField *)
callback which forwards to sliceToomChanged
SoSFBool drawImageData
if set to false, only the extensions of the SoView2D are drawn, not the images
Definition SoView2D.h:79
MLDataType _currentLUTImageDataType
current LUT settings
Definition SoView2D.h:538
SoSFVec3f viewingCenter
world position of the current center of the viewer
Definition SoView2D.h:172
SliceInitFunc _sliceInitFunc
external slice initialization callback
Definition SoView2D.h:571
static View2DFont * globalFont(int)
DEPRECATED: cache context id is no longer needed.
Definition SoView2D.h:351
void keepSlicesInViewCB(SoField *)
if keepSlicesInView is activated, set startSlice to a permitted value
SoSFBool useManagedInteraction
prefer to use managed interaction instead of classical event handling if a SoView2DExtension provides...
Definition SoView2D.h:221
SoSFFloat overrideAspectRatioValue
user defined aspect ratio, is only used if overrideAspectRatio is set to true
Definition SoView2D.h:204
void enableViewingCenterChangedCB(SoField *)
enable / disable viewing center usage.
SoSFBool cineFullRangeT
flag if the full time range or the time interval is used
Definition SoView2D.h:260
SoSFBool overrideAspectRatio
set if the aspect ratio should be overwritten by user aspect ratio
Definition SoView2D.h:202
SoSFVec2f margin
margin to the border of the viewer
Definition SoView2D.h:132
SoSFColor baseColor
base color in which the slices are drawn
Definition SoView2D.h:93
SoSFMLImage image
input ML image
Definition SoView2D.h:76
SoSFTrigger edit
set the extensions into edit mode
Definition SoView2D.h:277
SoFieldSensor * _sliceZoomSynchronizedSensor
Definition SoView2D.h:555
void forceImageUpdateChangedCB(SoField *field=nullptr)
void computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center) override
when rendering in 3D, calculate the bounding box of the drawn slice(s)
SoSFEnum zoomMode
zoom mode that defines mapping to the viewer area
Definition SoView2D.h:190
void getStatusString(SbString &string)
access status string
SoSFInt32 cineIntervalZ
interval of z cine
Definition SoView2D.h:247
SoSFFloat backgroundAlphaFactor
background alpha factor (0=background invisible)
Definition SoView2D.h:209
SoSFEnum cineDirection
direction of Cinemode
Definition SoView2D.h:251
void viewingCenterChangedCB(SoField *)
callback which forwards to viewingCenterChanged()
void setSliceInitFunc(SliceInitFunc fn, void *user)
Set slice position initialization callback The callback function set by this method is called when th...
Definition SoView2D.h:364
SoSFBool standardKeys
enable the keypad and 0-9 keys
Definition SoView2D.h:148
bool handleKeyboardEvent(int nKey, bool shift, bool alt, bool ctrl)
handle standard key, returns true if handles
void sliceZoomSynchronizedChanged()
updates the sliceZoom and corrects the slice origin, so that the viewing center of the slice remains ...
SoSFString status
status of current extension
Definition SoView2D.h:280
SoSFBool wrapAroundTimePointScrolling
wrap-around timepoint scrolling
Definition SoView2D.h:199
SoSFBool keepSlicesInView
if this is set, the slices are prevented from leaving the visible area.
Definition SoView2D.h:114
bool updateLutData(ml::LUTFunction *lut, View2DLut *data, SoSFMLImage *img, View2DLutPrecision precision)
renders the lut data from the lut function according to the image data (lut may be NULL,...
void cineParametersChangedCB(SoField *)
callback that calls updateCineParameters()
SoInteractionProvider * _interactionProvider
Delegate that provides the interaction objects from the SoView2DExtensions.
Definition SoView2D.h:585
SoSFEnum filterMode
filter mode for rendering
Definition SoView2D.h:87
SbVec2f getSingleSliceSize(int windowX, int windowY)
get the size of a single slice in the window area (this can be used to align annotation font size acr...
SoSFBool cineAlwaysReset
Always reset to start slice/time point and forward direction on start press (start with current posit...
Definition SoView2D.h:264
SoSFFloat alphaFactor
alpha factor for rendering
Definition SoView2D.h:91
SoSFInt32 maxTimePoint
the maximum timepoint, read from the image, used to restrict timePoint
Definition SoView2D.h:118
void updateHighColorDepthFlag()
Checks if the current GL context has a bigger bit depth than 8 per channel and if so upgrades the fla...
void imageChanged()
React on image changed.
static void initClass()
inventor runtime type system
SoSFFloat sliceZoomSynchronized
same as sliceZoom, except that changes to this member update the slice origin so that the viewing cen...
Definition SoView2D.h:167
void rayPick(SoRayPickAction *action) override
implements 3D picking
double _currentLUTImageMin
Definition SoView2D.h:539
void updateLayout(int viewportX, int viewportY, int viewportWidth, int viewportHeight, bool is3D=false)
Update layout for given viewport size.
SoSFTrigger deleteSelected
Interaction fields for extensions.
Definition SoView2D.h:275
int _currentLUTImageNumChannels
Definition SoView2D.h:541
bool _allowHighColorDepthUpgrade
Definition SoView2D.h:594
SoSFTrigger unzoom
sets sliceOrigin to (0,0) and sliceZoom to 1.0
Definition SoView2D.h:181
void layoutSlices(int wx, int wy)
layout slices inside of the window area
SoSFEnum sliceAlignX
align the image inside of the slice if there is space left, default is VIEW2D_ALIGN_CENTER
Definition SoView2D.h:184
SoSFBool useShaders
if enabled, the SoView2D tries to emulate a hardware lut by using hardware shaders,...
Definition SoView2D.h:96
SoSFBool snapToCenter
if set, the viewer snaps to center of image on each input image change
Definition SoView2D.h:145
bool getEventLocation(SoHandleEventAction *action, bool &hit, float &dx, float &dy, SbVec3f &voxelHit, int &sliceID)
get event location of the event contained in action, returns if the image is hit, the device location...
SoSFBool standardKeysNeedValidPosition
set if the keys work anywhere or only if pressed with mouse inside of a slice (needed for SoOrthoView...
Definition SoView2D.h:152
SoSFBool invertKeySlicingDirection
invert slicing by keyboard
Definition SoView2D.h:197
SoSFTrigger stopCine
stop the cine mode
Definition SoView2D.h:239
SoSFTrigger forceImageUpdate
Forces an immediate update of all fields that depend on the input image.
Definition SoView2D.h:129
void objUnref() override
Definition SoView2D.h:423
SoView2D()
constructor
void GLRender(SoGLRenderAction *action) override
reimplemented Inventor method which renders the slices
void startCineMode()
start the cine mode
~SoView2D() override
destructor
SoSFColor backgroundColor
fill slice background with given color
Definition SoView2D.h:207
SoSFBool unzoomOnImageChange
If enabled, the module unzooms automatically on an input image change.
Definition SoView2D.h:126
void sliceZoomSynchronizedChangedCB(SoField *)
callback which forwards to sliceZoomSynchronizedChanged
void sliceZoomChanged()
updates the member sliceZoomSynchronized
static SoInteractionProvider * getInteractionProvider(SoNode *node)
static method to register with SoInteractionProvider for this class
SoSFVec2f zoomCenter
center of zoom/scale operation in normalized coordinates
Definition SoView2D.h:169
View2DCine * _cine
Definition SoView2D.h:544
void updateCineParameters()
updates the cine parameters to the current field values
SoSFEnum cacheMode
caching of slices
Definition SoView2D.h:89
static ml::LUTFunction * _localLut
an internal lut which is used if there is no lut in the scene
Definition SoView2D.h:533
SbString getViewerId() const
returns the viewer id of this viewer
Definition SoView2D.h:302
SoSFInt32 startSlice
current start slice
Definition SoView2D.h:103
static View2DFont & globalFontRef()
Always return an existing font singleton as from globalFont(); used for annotations etc.
Abstract GL font drawing using FTGL.
Definition View2DFont.h:30
View2DInteractionHandler is derived from SoInteractionHandler mainly to provide additional SoView2D i...
The View2DInteractionProvider extracts the interactions from the SoView2DExtensions.
A small wrapper class for the LUT data.
Definition View2DLut.h:23
a list that holds all View2DSlice objects (lazily created) of a SoView2D
Common base class for lookup tables.
MLint32 MLDataType
MLDataType.
Definition mlTypeDefs.h:596
Target mlrange_cast(Source arg)
Generic version of checked ML casts.