MeVisLab Toolbox Reference
SoView2DPosition.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 
19 
20 #include <Inventor/fields/SoSFVec3f.h>
21 #include <Inventor/fields/SoSFFloat.h>
22 #include <Inventor/fields/SoSFVec3f.h>
23 #include <Inventor/fields/SoSFBool.h>
24 #include <Inventor/fields/SoSFColor.h>
25 #include <Inventor/fields/SoSFInt32.h>
26 #include <Inventor/fields/SoSFUShort.h>
27 
28 #include <Inventor/SbBox.h>
29 
36 };
37 
42 };
43 
46 {
47  SO_NODE_HEADER(SoView2DPosition);
48 
49 public:
52  SoSFVec3f worldPosition;
54  SoSFEnum drawingModel;
58  SoSFFloat drawingModelSize;
60  SoSFFloat crossHairSpacing;
62  SoSFBool drawEditingRect;
64  SoSFBool colorAxes;
66  SoSFColor coronalColor;
68  SoSFColor axialColor;
70  SoSFColor sagittalColor;
71 
73  SoSFBool colorBorder;
75  SoSFFloat colorBorderWidth;
76 
78  SoSFFloat lineWidth;
80  SoSFUShort linePattern;
81 
83  SoSFFloat blendOnto;
85  SoSFFloat blendOutside;
86 
88  SoSFBool updateOnPress;
90  SoSFBool updateOnMotion;
92  SoSFBool updateOnRelease;
94  SoSFBool cooperative;
97 
99 
101  static void initClass();
102 
105 
107  void draw(View2DSliceList *dsl, View2DSlice* dslice, int slice) override;
108 
110  bool evalEvent(SoView2D* view2d, View2DSliceList* slicelist,
111  View2DEvent* ec, View2DEventPhase phase) override;
112 
114  bool ignoreEvent(View2DEvent* ec) override;
115 
116 protected:
117  // update worldPosition and firstSliceWorldPosition
118  void setPosition(const SbVec3f& pos, SoView2D* view2d, View2DSliceList* slicelist);
119 
121  void getAxisColor(char orientation, float* color);
122 
125  bool isSensitiveAt(const SoPointerPosition& pos) override;
126  void startPressAt(const SoPointerPosition& pos) override;
127  void dragMoveTo(const SoPointerPosition& pos) override;
129 
131  void pointerPosition(const SoPointerPosition& pos) override;
132 
134  SbVec3f _oldWorldPos;
137 
138 private:
139  void drawCrosshairs(View2DSliceList* dsl, View2DSlice* dslice, const SbVec3f& voxelPosition,
140  float* rgba);
141 
142  void drawRect(View2DSlice* dslice, const SbVec3f& voxelPosition, float* rgba);
143 
144  void drawEllipse(View2DSlice* dslice, const SbVec3f& voxelPosition);
145 
146  void drawBorder(View2DSliceList * dsl, View2DSlice* dslice, float * rgba);
147 
148  void calculateModelSize(View2DSlice* dslice, float vz, float& modelSize, float& modelSizeX_px,
149  float& modelSizeY_px);
150 
151  SbBox2f calculateBoundingBox(const SbVec2f& modelCenter,
152  float modelSizeX_px, float modelSizeY_px);
153 
154  SbVec2f calculateModelCenter(View2DSlice* dslice, const SbVec3f& voxelPosition);
155 
156  void setAxesColors(View2DSliceList * dsl, float * rgba);
157 };
View2DEventPhase
event phase for simple extensions that grab the focus, do something (motion) and are released afterwa...
SizeUnitType
@ SIZEUNIT_SCREEN
@ SIZEUNIT_WORLD
@ SIZEUNIT_VOXEL
drawingModelType
Draw and edit a position on the SoView2D.
@ DRAWINGMODEL_ELLIPSE
@ DRAWINGMODEL_CROSSHAIRS
@ DRAWINGMODEL_CROSSHAIRS_WITH_CIRCLE
@ DRAWINGMODEL_VOXEL_RECT
@ DRAWINGMODEL_CIRCLE
#define SOVIEW2D_API
File to resolve system dependencies in View2D library.
SoPointerPosition manages the current position of the mouse cursor.
SoView2DInteractionExtension is base class for all SoView2DExtensions that want to support the Manage...
draw and edit a position on the SoView2D
SoSFBool colorAxes
flag to draw axes in color
SoSFBool updateOnRelease
update worldPosition on release event
SoSFBool updateOnPress
update worldPosition on press event
bool _isDragging
flag if position is being dragged
SoSFFloat blendOutside
blend factor for the slice the position is not located on
void pointerPosition(const SoPointerPosition &pos) override
interface inherited from SoInteractionProvider
SoSFFloat crossHairSpacing
spacing in center of the crosshair position indicator
SoSFFloat drawingModelSize
size of the position indicator model
void startPressAt(const SoPointerPosition &pos) override
SoView2DPosition()
Constructor.
void draw(View2DSliceList *dsl, View2DSlice *dslice, int slice) override
reimplemented from SoView2DExtension
SoSFVec3f firstSliceWorldPosition
world position on first slice (useful, if numOfSlices in the corresponding viewer is > 1)
SoSFBool updateOnMotion
update worldPosition on motion event
SoSFColor coronalColor
color for coronal view
SoSFEnum drawingModel
model that shall be used for the position indicator (crosshairs, circle...)
bool evalEvent(SoView2D *view2d, View2DSliceList *slicelist, View2DEvent *ec, View2DEventPhase phase) override
reimplemented from SoView2DExtension
SoSFColor sagittalColor
color for sagittal view
SoSFUShort linePattern
line stipple pattern
SoSFBool drawEditingRect
flag to draw mini rect in cursor center
SoSFBool cooperative
enable cooperative editing
SoSFBool colorBorder
flag to draw colored borders
SoSFFloat blendOnto
blend factor for the slice the position is located on
bool ignoreEvent(View2DEvent *ec) override
Overwrite ignoreEvent -> ignore the "ignoreHandledEvents"-Field.
SbVec3f _oldWorldPos
previous world position
SoSFColor axialColor
color for axial view
void getAxisColor(char orientation, float *color)
get color of orientation
SoSFEnum drawingModelSizeUnit
unit in which cross-hair dimensions are expressed (voxel, world or screen units)
bool isSensitiveAt(const SoPointerPosition &pos) override
interface forwarded from SoPointingAction:
static void initClass()
inventor runtime type system
SoSFVec3f worldPosition
selected world position
SoSFFloat lineWidth
line width of the rendered position indicators
SoSFFloat colorBorderWidth
width of the color border
void dragMoveTo(const SoPointerPosition &pos) override
void setPosition(const SbVec3f &pos, SoView2D *view2d, View2DSliceList *slicelist)
SoView2D is a 2D viewer for image data.
Definition: SoView2D.h:62
View2DEvent stores all information on an event on a SoView2D.
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