MeVisLab Toolbox Reference
SoView2DLabel.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 
15 
16 #pragma once
17 
18 #include "SoView2DSystem.h"
20 
21 #include <Inventor/fields/SoSFString.h>
22 #include <Inventor/fields/SoSFFloat.h>
23 #include <Inventor/fields/SoSFEnum.h>
24 #include <Inventor/fields/SoSFInt32.h>
25 #include <Inventor/fields/SoSFVec3f.h>
26 #include <Inventor/fields/SoSFVec2f.h>
27 #include <Inventor/SbBox.h>
28 #include <DCMTree_Tag.h>
29 
30 
31 class SoView2D;
32 class View2DFont;
33 
34 // Constant name definitions
35 
39  POS_BELOW
40 };
41 
45  POS_RIGHT
46 };
47 
51 };
52 
54 {
55  SO_NODE_HEADER(SoView2DLabel);
56 
57 public:
58 
61  {
65  DEPTH_IN_MM
66  };
67 
70  {
76  FONT_SIZE_IN_VOXELS
77  };
78 
81  {
84  SHOW_BORDER_ALWAYS
85  };
86 
88 
89  SoSFString text;
90  SoSFString viewerId;
91 
92  SoSFEnum textPositioning;
93  SoSFVec3f worldPosition;
95 
96  SoSFEnum verticalPosition;
97  SoSFFloat verticalOffset;
99  SoSFFloat horizontalOffset;
100 
101  SoSFInt32 fontSize;
102  SoSFEnum fontSizeMode;
103  SoSFFloat alpha;
104  SoSFBool textShadow;
105 
107  SoSFBool highlighted;
108 
110  SoSFTypedEnum<BorderMode> borderMode;
111  SoSFColor borderColor;
112 
115  SoSFFloat depthVisibility;
116 
119 
122 
124 
125  SoSFFloat depthMinimumAlpha;
126 
127  SoSFInt32 timePoint;
129 
130  // field for definition of background box
131  SoSFBool drawBackground;
132  SoSFColor backgroundColor;
133  SoSFFloat backgroundAlpha;
138 
139  SoSFBool isUnderMouse;
142 
144  static void initClass();
145 
148 
149  ~SoView2DLabel() override;
150 
152  void draw(View2DSliceList *dsl, View2DSlice* dslice, int slice) override;
153 
154  float getDepthVisibilityBlendValue(float distance, float voxelSizeZ);
155 
156 protected:
157  bool getTextLocation(View2DSliceList *dsl, View2DSlice* dslice, int slice, float& alphaToUse, float& dx, float& dy, int& textWidth, int& textHeight);
158 
159  bool implementsManagedInteractionAndClassicEventHandling() const override { return false; }
160 
163  bool isSensitiveAt(const SoPointerPosition& pos) override;
164  void setHighlightAt(const SoPointerPosition& pos) override;
165  void unsetHighlight() override;
166  void startPressAt(const SoPointerPosition& pos) override;
167  void dragMoveTo(const SoPointerPosition& pos) override;
169 
172  void pointerPosition(SoState* state, const SoPointerPosition& pos) override;
173  void pointerLeftWindow(SoState* state) override;
175 
176 
177 
178 private:
179  float getFontSizeInPixels(View2DSlice* dslice) const;
180  bool labelIsVisibleOnTimePoint(const SoView2D* const view2D) const;
181  void getVisibleDeviceArea(View2DSlice *dsl, float& minX, float& maxX, float& minY, float& maxY) const;
182 
183  SbVec2f _startDragDevicePosition;
184  SbVec3f _startWorldPosition;
185  SbVec2f _startRelativePosition;
186  SbBox2f _labelBounds;
187  int _currentInteractionSlice;
188 };
HorizPositionMode
Definition: SoView2DLabel.h:42
@ POS_RIGHT
Definition: SoView2DLabel.h:45
@ POS_LEFT
Definition: SoView2DLabel.h:43
@ POS_HCENTER
Definition: SoView2DLabel.h:44
VertPositionMode
Definition: SoView2DLabel.h:36
@ POS_ABOVE
Definition: SoView2DLabel.h:37
@ POS_BELOW
Definition: SoView2DLabel.h:39
@ POS_VCENTER
Definition: SoView2DLabel.h:38
TextPositioningMode
Definition: SoView2DLabel.h:48
@ WORLD_COORDINATES
Definition: SoView2DLabel.h:49
@ RELATIVE_TO_VIEWER
Definition: SoView2DLabel.h:50
#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...
SoSFBool drawBackground
SoSFVec2f relativeViewerPosition
Definition: SoView2DLabel.h:94
SoSFEnum depthVisibilityMode
select the mode for depth visibility
SoSFBool showLabelOnAllTimePoints
SoSFFloat depthVisibility
defines up to which distance markers are visible value is either in slices or in mm depending on the ...
SoSFBool highlighted
Set to true while the label should be highlighted, usually draws a border around the label.
SoSFColor backgroundColor
SoSFVec3f worldPosition
Definition: SoView2DLabel.h:93
SoSFInt32 timePoint
bool isSensitiveAt(const SoPointerPosition &pos) override
interface forwarded from SoPointingAction:
SoSFBool isUnderMouse
SoSFEnum verticalPosition
Definition: SoView2DLabel.h:96
SoSFFloat depthMinimumAlpha
void setHighlightAt(const SoPointerPosition &pos) override
void startPressAt(const SoPointerPosition &pos) override
SoSFFloat backgroundMarginBottom
bool getTextLocation(View2DSliceList *dsl, View2DSlice *dslice, int slice, float &alphaToUse, float &dx, float &dy, int &textWidth, int &textHeight)
SoSFEnum horizontalPosition
Definition: SoView2DLabel.h:98
SoSFString viewerId
Definition: SoView2DLabel.h:90
void dragMoveTo(const SoPointerPosition &pos) override
SoSFInt32 fontSize
SoSFFloat alpha
SoSFFloat backgroundMarginLeft
static void initClass()
inventor runtime type system
~SoView2DLabel() override
SoSFBool useDepthVisibility
enables depth visibility
SoSFFloat verticalOffset
Definition: SoView2DLabel.h:97
SoSFFloat horizontalOffset
Definition: SoView2DLabel.h:99
SoSFBool textShadow
SoSFBool keepCursorPositionInViewerWhenMoving
BorderMode
Border mode.
Definition: SoView2DLabel.h:81
@ SHOW_BORDER_WHEN_HIGHLIGHTED
Definition: SoView2DLabel.h:83
void unsetHighlight() override
depthVisibilityType
Depth visibility mode.
Definition: SoView2DLabel.h:61
@ DEPTH_IN_SLICES
The depth visibility in number of slices.
Definition: SoView2DLabel.h:63
SoSFString text
Fields.
Definition: SoView2DLabel.h:89
SoSFColor borderColor
void pointerPosition(SoState *state, const SoPointerPosition &pos) override
Update isUnderMouse.
SoSFEnum textPositioning
Definition: SoView2DLabel.h:92
FontSizeMode
Font size mode.
Definition: SoView2DLabel.h:70
@ FONT_SIZE_IN_PIXELS
Font size in pixels.
Definition: SoView2DLabel.h:72
@ FONT_SIZE_IN_MM
Font size in mm.
Definition: SoView2DLabel.h:74
SoSFFloat backgroundAlpha
SoSFFloat backgroundMarginRight
bool implementsManagedInteractionAndClassicEventHandling() const override
return true if this node is a hybrid module providing managed interaction and classic event handling ...
SoSFTypedEnum< BorderMode > borderMode
Defines the border mode.
void pointerLeftWindow(SoState *state) override
Same as below, with additional SoState argument. Be defaults simply calls the below version.
float getDepthVisibilityBlendValue(float distance, float voxelSizeZ)
SoView2DLabel()
Constructor.
void draw(View2DSliceList *dsl, View2DSlice *dslice, int slice) override
draw annotations on slice
SoSFFloat backgroundMarginTop
SoSFBool keepLabelInViewer
SoSFEnum fontSizeMode
SoView2D is a 2D viewer for image data.
Definition: SoView2D.h:62
Abstract GL font drawing using FTGL.
Definition: View2DFont.h:30
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