MeVisLab Toolbox Reference
SoCSODistanceLineEditor.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2012, 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 
20 
21 #include "EndpointDecorator.h"
22 
24 
27 {
28  SO_NODE_HEADER(SoCSODistanceLineEditor);
29 
30 public:
31 
34 
36  SoSFTypedEnum<DecorationTypes> decorationTypeAtStart;
38  SoSFTypedEnum<DecorationTypes> decorationTypeAtEnd;
39 
40  SoSFTypedEnum<DecorationLineStyleOverwriteModes> decorationOverwriteLineStyleAtStart;
41  SoSFTypedEnum<DecorationLineStyleOverwriteModes> decorationOverwriteLineStyleAtEnd;
42 
45 
48 
51 
58 
60  SoSFBool shouldSnapAngle;
62  SoSFFloat snapAngle;
65 
67  void draw(const CSODrawCSOInfos& csoInfos, const CSODrawView2DInfos& view2DInfos, const CSODrawSliceInformation& drawSliceInfo, SoView2DCSOExtensibleEditor* editor) override;
68 
70  static void initClass();
71 
72  void cancel() override;
73 
74  void createStartPressAt(const SoPointerPosition& pos) override;
75 
76  bool deleteSeedPoint(ml::CSO* cso, ml::CSOSeedPoint* seedPoint) override;
77 
78  void createNewCSO( const SoPointerPosition& pos );
79  void createDragMoveTo(const SoPointerPosition& pos) override;
80  bool createEndPress(int clickCount) override;
82 
83  void selectAndMoveStartPressAt(const SoPointerPosition& pos) override;
84  void selectAndMoveDragMoveTo(const SoPointerPosition& pos) override;
85  SoPointingAction* selectAndMoveEndPress(int clickCount) override;
86 
87 protected:
88 
89 private:
90 
91  void computeDeviceShadowOffset(const CSODrawCSOInfos& csoInfos, const CSODrawView2DInfos& view2DInfos, SbVec2f& shadowOffsetDevice);
92 
93  void drawEndpointDecorations(const CSODrawCSOInfos& csoInfos, const CSODrawView2DInfos& view2DInfos, const CSODrawSliceInformation& drawSliceInfo, const SbVec2f& shadowOffsetDevice);
94 
95  unsigned short getStipplePattern(ml::CSO* cso, bool isAboveTopPlane, bool isAboveBottomPlane, unsigned short overwriteStipplePattern);
96  void getColor(ml::CSO* cso, bool isAboveTopPlane, bool isAboveBottomPlane, bool isMouseOver, SbColor& color, float& alpha);
97  float getLineWidth(ml::CSO* cso, bool isAboveTopPlane, bool isAboveBottomPlane, bool isMouseOver);
98 
99  void createLineFixedLength();
100  ml::Vector3 getFixedEndPosition(const ml::Vector3& startPosition);
101 
102  ml::Vector3 getInteractiveSeedPointPosition(const SoPointerPosition& pos, const SbVec3f& currentPosition);
103 
104  ml::Vector3 snapDistanceLineToAngle(const SoPointerPosition& pos, const SbVec3f& currentPosition, ml::Vector3 modifiedPosition);
105 
106  ml::Vector3 getPositionOfOtherSeedPoint(ml::CSOSeedPoint* seedPoint);
107  MLdouble getDirectionAngle(const ml::Vector3& interactivePositionVoxel, const ml::Vector3& fixedPositionVoxel);
108 
109  MLdouble toDegree(MLdouble radians) { return radians * 180.0 / ML_M_PI; }
110  MLdouble toRadians(MLdouble degree) { return degree * ML_M_PI / 180.0; }
111 
112  int doubleModulo(MLdouble number, MLdouble divisor);
113 
114  bool _wasCanceled;
115 
116  SbVec3f _startPosition;
117  SoPointerPosition _startPointerPosition;
118 };
119 
#define SOCSO_EXPORT
Header file for system independent resolution.
Definition: SoCSOSystem.h:21
Base class for extensions that extend the editor with interaction and rendering for specific CSO type...
Extension for rendering, generating, and modifying a distance line CSO.
void selectAndMoveStartPressAt(const SoPointerPosition &pos) override
SoSFBool shouldRenderDecorationOnGhost
Should the decoration also be rendered on ghosts of CSOs?
void createStartPressAt(const SoPointerPosition &pos) override
void createNewCSO(const SoPointerPosition &pos)
SoSFInt32 endPositionDeviceOffsetY
The fixed length in y-direction of a single-click created line in pixel.
bool createEndPress(int clickCount) override
SoSFBool shouldUseShiftToToggleSnapAngle
Should SHIFT toggle snap angle/no snap angle?
void selectAndMoveDragMoveTo(const SoPointerPosition &pos) override
SoSFTypedEnum< DecorationLineStyleOverwriteModes > decorationOverwriteLineStyleAtEnd
SoSFInt32 decorationPixelSizeAtStart
The size of the decoration at the start of the distance line.
SoPointingAction * selectAndMoveEndPress(int clickCount) override
SoSFInt32 endPositionDeviceOffsetX
The fixed length in x-direction of a single-click created line in pixel.
SoSFBool createLineWithSingleClick
Shall a line with fixed length in pixel be created with a single click?
SoSFTypedEnum< DecorationLineStyleOverwriteModes > decorationOverwriteLineStyleAtStart
SoSFBool shouldSnapAngle
Should the line snap to an angle relative to the voxel grid?
SoCSODistanceLineEditor()
Standard constructor.
void pointerPositionIfAllowedAt(const SoPointerPosition &) override
Sets seed points while moving the mouse – but not while dragging.
static void initClass()
init class in inventor runtime
void cancel() override
Cancels an action like generating a CSO. Depends on concrete editor.
bool deleteSeedPoint(ml::CSO *cso, ml::CSOSeedPoint *seedPoint) override
Removes the given seed point from the given CSO and returns whether that was successful.
SoSFFloat snapAngle
The angle for snapping.
void draw(const CSODrawCSOInfos &csoInfos, const CSODrawView2DInfos &view2DInfos, const CSODrawSliceInformation &drawSliceInfo, SoView2DCSOExtensibleEditor *editor) override
Drawing routine.
SoSFTypedEnum< DecorationTypes > decorationTypeAtEnd
The decoration to be rendered at the end of the distance line.
void createDragMoveTo(const SoPointerPosition &pos) override
SoSFTypedEnum< DecorationTypes > decorationTypeAtStart
The decoration to be rendered at the start of the distance line.
SoSFInt32 decorationPixelSizeAtEnd
The size of the decoration at the end of the distance line.
SoPointerPosition manages the current position of the mouse cursor.
SoPointingAction is the base class for any mouse based interaction.
The CSOSeedPoint can be interactively set and modified and is the framework for contours.
Definition: CSOSeedPoint.h:35
The CSO represents a contour segmentation object.
Definition: CSO.h:44
double MLdouble
Definition: mlTypeDefs.h:223
#define ML_M_PI
Pi as ML constant for backward compatibility.
Definition: mlTypeDefs.h:455