MeVisLab Toolbox Reference
SoCSOLiveWireEditor.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
19#include <SoSFMLImage.h>
21
23
26{
27 SO_NODE_HEADER(SoCSOLiveWireEditor);
28
29public:
30
35
37 static void initClass();
38
52 SoSFFloat weightGradient;
54 SoSFFloat weightLaplacian;
57
58 void createStartPressAt(const SoPointerPosition& pos) override;
59
60 void createNewCSO( const SoPointerPosition& pos );
61 void createDragMoveTo(const SoPointerPosition& pos) override;
62 bool createEndPress(int clickCount) override;
64
65 void pointerPosition(const SoPointerPosition&) override;
66
68 void selectAndMoveDragMoveTo(const SoPointerPosition& pos) override;
69 SoPointingAction* selectAndMoveEndPress(int clickCount) override;
70
73 SoPointingAction* insertSeedPointEndPress(int clickCount) override;
74
75 int cursorShape() const override { return _cursorShape; }
76
77 bool deleteSeedPoint(ml::CSO* cso, ml::CSOSeedPoint* seedPoint) override;
78
79 void cancel() override;
80
81 void initMembers() override;
82
83protected:
84
86
87private:
88
89 enum CSO_REACT_ON_DOUBLE_CLICK
90 {
91 CSO_EDITOR_DOUBLE_CLICK_SET_SINGLE_SEED = 0,
92 CSO_EDITOR_DOUBLE_CLICK_SET_DOUBLE_SEEDS,
93 CSO_EDITOR_DOUBLE_CLICK_FINISH,
94 CSO_EDITOR_DOUBLE_CLICK_CLOSE,
95 CSO_EDITOR_DOUBLE_CLICK_FINISH_NO_CLOSE
96 };
97
98 void setLiveWireStartPosition(const ml::Vector3& worldPosition);
99 void interpolatePathPoints(ml::CSOSeedPoint* seedPoint);
100 void interpolatePathPoints(ml::CSOPathPoints* pathPoints);
101 void interpolateAllPathPointLists(ml::CSO* cso);
102 void interpolateSinglePathPointList(ml::CSO* cso, ml::CSOSeedPoint* predSeedPoint, ml::CSOSeedPoint* succSeedPoint);
103 void fillPathPoints(ml::CSOPathPoints* pathPoints, const std::vector<ml::VoxelPos>& pathPositions);
104
105 bool couldCloseCSO(const SoPointerPosition& pos, ml::CSO* cso);
106 bool isCurrentPositionOnTopOfPreviousSeedPoint() const;
107 void checkCanCloseAndSetCursorShape(const SoPointerPosition& pos, ml::CSO* cso);
108 float getFirstLastSeedPointDeviceDistance(const SoPointerPosition& pos, ml::CSO* cso) const;
109 ml::CSOPathPoints* getLastPathPointList(ml::CSO* cso);
110 void removeSeedPointAndInterpolateRemainingPath(ml::CSO* cso, ml::CSOSeedPoint* seedPoint);
111
112 void removeSeedPointFromMiddleOfCSO(ml::CSO* cso, ml::CSOSeedPoint* seedPoint);
113
114 bool liveWireGraphNeedsUpdate(const SoPointerPosition& pos);
115 void updateLiveWireGraph(const SoPointerPosition& pos);
116 void configureLiveWireGraph();
117
118 bool areEqual(const XVImageSize& imageSize1, const XVImageSize& imageSize2) const;
119
120 bool isEndSeedPoint(ml::CSOSeedPoint* seedPoint);
121
122 ml::VoxelPos getVoxelPosition(const ml::Vector3& worldPosition) const;
123 ml::Vector3 getWorldPosition(const ml::VoxelPos& voxelPosition) const;
124
125 void initialize();
126
127 void fieldChanged(SoField*);
128 void inputImageChanged(SoField*);
129
130 SbVec3f _startPosition;
131 ml::Vector3 _currentPosition;
132 SoPointerPosition _startPointerPosition;
133 SoPointerPosition _currentPointerPosition;
134
135 ml::Matrix4 _imageWorldToVoxelMatrix;
136 ml::Matrix4 _imageVoxelToWorldMatrix;
137 int _cursorShape;
138
139 bool _couldCloseCurrentCSO;
140
141 bool _shouldCloseWhenStartedInFreehand;
142 bool _hasStartedFreehand;
143 bool _isDrawingFreehand;
144 ml::CSOLiveWireGraph* _liveWireGraph;
145 int _sliceZ;
146 int _startSliceZ;
147 unsigned int _lastImageSerialNumber;
148};
149
#define SOCSO_EXPORT
Header file for system independent resolution.
Definition SoCSOSystem.h:21
SoCSOLineCreatorEditorExtension()
Hidden constructor.
SoSFBool useLaplacianSmoothing
Shall the CSOs be smoothed by a Laplacian smoothing?
SoSFFloat weightLaplacian
Weight of Laplace zero crossing cost.
void createStartPressAt(const SoPointerPosition &pos) override
void createNewCSO(const SoPointerPosition &pos)
~SoCSOLiveWireEditor() override
Destructor.
SoSFEnum doubleClickMode
Defines how the module should react on a double-click.
void selectAndMoveDragMoveTo(const SoPointerPosition &pos) override
SoPointingAction * selectAndMoveEndPress(int clickCount) override
SoSFMLImage inputImage
Input image.
void pointerPositionIfAllowedAt(const SoPointerPosition &pos) override
void insertSeedPointDragMoveTo(const SoPointerPosition &pos) override
int cursorShape() const override
Returns the cursor shape that indicates the next creation.
void pointerPosition(const SoPointerPosition &) override
Called when the mouse moves over a viewer.
SoSFEnum neighborhoodMode
Neighborhood modes (4/8).
SoSFInt32 numLaplacianSmoothingPasses
Sets the smoothing amount for Laplacian smoothing.
void createDragMoveTo(const SoPointerPosition &pos) override
SoSFFloat weightDirectional
Weight of directional cost.
void cancel() override
Cancels an action like generating a CSO. Depends on concrete editor.
void initMembers() override
static void initClass()
init class in inventor runtime
ml::Vector3 getCurrentPositon(const SoPointerPosition &pos)
SoSFFloat weightGradient
Weight of the gradient.
bool createEndPress(int clickCount) override
SoSFBool inputImageIsCostImage
Is the input image already a cost image?
void insertSeedPointStartPressAt(const SoPointerPosition &pos) override
SoCSOLiveWireEditor()
Standard constructor.
void selectAndMoveStartPressAt(const SoPointerPosition &pos) override
bool deleteSeedPoint(ml::CSO *cso, ml::CSOSeedPoint *seedPoint) override
Removes the given seed point from the given CSO and returns whether that was successful.
SoPointingAction * insertSeedPointEndPress(int clickCount) override
SoPointerPosition manages the current position of the mouse cursor.
SoSFMLImage - field interface to ML images and related classes.
Definition SoSFMLImage.h:32
The class maintains a graph for applying a shortest path algorithm on.
Definition CSO.h:44
Tmat4< MLdouble > Matrix4
The standard 4x4 matrix of type double.
Definition mlMatrix4.h:713
Tvec3< MLdouble > Vector3
A vector with three components of type double.
Definition mlVector3.h:286
Structure holding a 2D voxel position.