MeVisLab Toolbox Reference
SoView2DPlane.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 #pragma once
14 
16 
17 #include <Inventor/fields/SoSFPlane.h>
18 #include <Inventor/fields/SoSFFloat.h>
19 #include <Inventor/fields/SoSFVec3f.h>
20 #include <Inventor/fields/SoSFBool.h>
21 #include <Inventor/fields/SoSFInt32.h>
22 #include <Inventor/fields/SoSFMatrix.h>
23 
24 class SoView2D;
25 
27 {
28  SO_NODE_HEADER(SoView2DPlane);
29 
30 public:
34  BOTH
35  };
36 
37  enum NormalShape {
39  ARROW
40  };
41 
43 
45  SoSFPlane plane;
46 
50  SoSFEnum interactionMode;
51 
54  SoSFBool maskValidAndHit;
55 
57  SoSFFloat blendMin;
59  SoSFFloat blendMax;
61  SoSFBool normalOn;
63  SoSFBool shadowOn;
71  SoSFFloat centerGapSize;
73  SoSFInt32 normalSize;
75  SoSFFloat normalOffset;
77  SoSFEnum normalShape;
79  SoSFMatrix rotationDifference;
89  SoSFBool fixedLineWidth;
91  SoSFBool useAntiAliasing;
93  SoSFBool useMouseCursors;
95 
97  static void initClass();
98 
101 
103  void draw(View2DSliceList *dsl, View2DSlice* dslice, int slice) override;
104 
106  bool evalEvent(SoView2D* view2d, View2DSliceList* slicelist,
107  View2DEvent* ec, View2DEventPhase phase) override;
108 
109  void setExternalRotationAxis(SbVec3f rotPosition){_rotPos = rotPosition;}
110 
111 protected:
113  void clipLinePoint (float &p1x, float &p1y, float p2x, float p2y,
114  float x0, float x1);
115 
117  bool clipToSliceRect(SbVec2f& p1, SbVec2f& p2, View2DSlice *dslice);
118 
120  void drawPlaneLine (View2DSliceList *dsl, View2DSlice *dslice, SbVec2f p1, SbVec2f p2);
121 
123  void drawNormal (View2DSliceList *dsl, View2DSlice *dslice, SbVec2f p1, SbVec2f p2);
124 
126  enum HIT_MODE {NO_HIT, HIT_ROTATE, HIT_TRANSLATE, HIT_CENTER};
127 
129  HIT_MODE _hitPlane(const SbVec3f &point, View2DSliceList* dsl, int& proposedCursorShape);
130 
132  void dragMoveTo(const SbVec3f& point, View2DSliceList* slicelist);
133 
136  int getCurrentCursor(SoViewerProxy* viewerProxy) override;
137  bool isSensitiveAt(const SoPointerPosition& pos) override;
138  void startPressAt(const SoPointerPosition& pos) override;
139  void dragMoveTo(const SoPointerPosition& pos) override;
140  SoPointingAction* endPress(int clickCount) override;
142 
143 private:
145  SbVec3f _edge[2];
146 
148  float _oldDistance;
149 
151  SbVec3f _rotPos;
152 
154  SbVec3f _startPos, _lastPos;
155 
157  HIT_MODE _eventHitMode;
159  int _cursorShape;
160 
161  SbBool _rotPosIsValid;
162 };
@ ARROW
Renders an arrow tip at the endpoint.
View2DEventPhase
event phase for simple extensions that grab the focus, do something (motion) and are released afterwa...
#define SOVIEW2D_API
File to resolve system dependencies in View2D library.
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...
SoSFFloat translationRangeMax
maximum value for plane parameter d
Definition: SoView2DPlane.h:87
SoSFBool normalOn
draw normal
Definition: SoView2DPlane.h:61
SoSFFloat centerGapSize
don't draw plane around rotationAxis (only if fixedLineWidth is set), gap size in pixels
Definition: SoView2DPlane.h:71
SoSFBool fixedLineWidth
use translation range for plane parameter d
Definition: SoView2DPlane.h:89
SoSFBool externalRotationAxisOn
set external rotation axis
Definition: SoView2DPlane.h:65
void drawNormal(View2DSliceList *dsl, View2DSlice *dslice, SbVec2f p1, SbVec2f p2)
draw a normal on the slice
SoSFInt32 normalSize
size of normal to be drawn (in pixels)
Definition: SoView2DPlane.h:73
bool clipToSliceRect(SbVec2f &p1, SbVec2f &p2, View2DSlice *dslice)
clip line to device rectangle of slice, returns false if nothing is left afterwards
SoPointingAction * endPress(int clickCount) override
SoSFEnum interactionMode
interaction mode plane can be rotated or translated or both
Definition: SoView2DPlane.h:50
void draw(View2DSliceList *dsl, View2DSlice *dslice, int slice) override
reimplemented from SoView2DExtension
SoSFBool useTranslationRange
use translation range for plane parameter d
Definition: SoView2DPlane.h:83
SoView2DPlane()
Constructor.
void dragMoveTo(const SoPointerPosition &pos) override
SoSFFloat translationLineFraction
Fraction of the visible line that is associated with translation (percent)
Definition: SoView2DPlane.h:81
SoSFBool allowMoveExternalRotationAxis
allow to move the external rotation axis point with mouse
Definition: SoView2DPlane.h:67
SoSFFloat translationRangeMin
minimum value for plane parameter d
Definition: SoView2DPlane.h:85
SoSFBool useMouseCursors
use mouse cursors to indicate next interaction
Definition: SoView2DPlane.h:93
SoSFVec3f externalRotationAxis
external rotation axis position
Definition: SoView2DPlane.h:69
SoSFMatrix rotationDifference
Rotation between previous and current orientation.
Definition: SoView2DPlane.h:79
bool isSensitiveAt(const SoPointerPosition &pos) override
static void initClass()
inventor runtime type system
bool evalEvent(SoView2D *view2d, View2DSliceList *slicelist, View2DEvent *ec, View2DEventPhase phase) override
reimplemented from SoView2DExtension
void dragMoveTo(const SbVec3f &point, View2DSliceList *slicelist)
implement dragging, parameter is world position
SoSFFloat blendMax
maximum blend value
Definition: SoView2DPlane.h:59
SoSFBool useAntiAliasing
use anti-aliasing for rendering lines
Definition: SoView2DPlane.h:91
HIT_MODE _hitPlane(const SbVec3f &point, View2DSliceList *dsl, int &proposedCursorShape)
is mouse cursor on plane?
SoSFBool maskValidAndHit
gives the state of the mask, which calculated by the current mousebuttons and modifier key compared t...
Definition: SoView2DPlane.h:54
SoSFFloat normalOffset
offset of the normal from the plane
Definition: SoView2DPlane.h:75
void startPressAt(const SoPointerPosition &pos) override
int getCurrentCursor(SoViewerProxy *viewerProxy) override
interface forwarded from SoPointingAction:
SoSFBool shadowOn
draw shadow
Definition: SoView2DPlane.h:63
void clipLinePoint(float &p1x, float &p1y, float p2x, float p2y, float x0, float x1)
clip a line and a point in 2D, returns new point in p1x,p1y
void setExternalRotationAxis(SbVec3f rotPosition)
SoSFFloat blendMin
minimum blend value
Definition: SoView2DPlane.h:57
HIT_MODE
describes if we hit the line and how
void drawPlaneLine(View2DSliceList *dsl, View2DSlice *dslice, SbVec2f p1, SbVec2f p2)
draw plane line, possibly including the normal indicator
SoSFPlane plane
Fields.
Definition: SoView2DPlane.h:45
SoSFEnum normalShape
shape of normal indicator
Definition: SoView2DPlane.h:77
SoView2D is a 2D viewer for image data.
Definition: SoView2D.h:62
This class gives access to state of a viewer during scene graph traversal.
Definition: SoViewerProxy.h:30
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