MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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:
34
36 static void initClass();
37
56
57 void createStartPressAt(const SoPointerPosition& pos) override;
58
60 void createDragMoveTo(const SoPointerPosition& pos) override;
61 bool createEndPress(int clickCount) override;
63
64 void pointerPosition(const SoPointerPosition&) override;
65
67 void selectAndMoveDragMoveTo(const SoPointerPosition& pos) override;
68 SoPointingAction* selectAndMoveEndPress(int clickCount) override;
69
72 SoPointingAction* insertSeedPointEndPress(int clickCount) override;
73
74 int cursorShape() const override
75 {
76 return _cursorShape;
77 }
78
80
81 void cancel() override;
82
83 void initMembers() override;
84
85protected:
87
88private:
89 enum CSO_REACT_ON_DOUBLE_CLICK {
90 CSO_EDITOR_DOUBLE_CLICK_SET_SINGLE_SEED = 0,
91 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
97 };
98
99 void setLiveWireStartPosition(const ml::Vector3& worldPosition);
100 void interpolatePathPoints(ml::CSOSeedPoint* seedPoint);
101 void interpolatePathPoints(ml::CSOPathPoints* pathPoints);
102 void interpolateAllPathPointLists(ml::CSO* cso);
103 void interpolateSinglePathPointList(ml::CSO* cso, ml::CSOSeedPoint* predSeedPoint, ml::CSOSeedPoint* succSeedPoint);
104 void fillPathPoints(ml::CSOPathPoints* pathPoints, const std::vector<ml::VoxelPos>& pathPositions);
105
106 bool couldCloseCSO(const SoPointerPosition& pos, ml::CSO* cso);
107 bool isCurrentPositionOnTopOfPreviousSeedPoint() const;
108 void checkCanCloseAndSetCursorShape(const SoPointerPosition& pos, ml::CSO* cso);
109 float getFirstLastSeedPointDeviceDistance(const SoPointerPosition& pos, ml::CSO* cso) const;
110 ml::CSOPathPoints* getLastPathPointList(ml::CSO* cso);
111 void removeSeedPointAndInterpolateRemainingPath(ml::CSO* cso, ml::CSOSeedPoint* seedPoint);
112
113 void removeSeedPointFromMiddleOfCSO(ml::CSO* cso, ml::CSOSeedPoint* seedPoint);
114
115 bool liveWireGraphNeedsUpdate(const SoPointerPosition& pos);
116 void updateLiveWireGraph(const SoPointerPosition& pos);
117 void configureLiveWireGraph();
118
119 bool areEqual(const XVImageSize& imageSize1, const XVImageSize& imageSize2) const;
120
121 bool isEndSeedPoint(ml::CSOSeedPoint* seedPoint);
122
123 ml::VoxelPos getVoxelPosition(const ml::Vector3& worldPosition) const;
124 ml::Vector3 getWorldPosition(const ml::VoxelPos& voxelPosition) const;
125
126 void initialize();
127
128 void fieldChanged(SoField*);
129 void inputImageChanged(SoField*);
130
131 SbVec3f _startPosition;
132 ml::Vector3 _currentPosition;
133 SoPointerPosition _startPointerPosition;
134 SoPointerPosition _currentPointerPosition;
135
136 ml::Matrix4 _imageWorldToVoxelMatrix;
137 ml::Matrix4 _imageVoxelToWorldMatrix;
138 int _cursorShape;
139
140 bool _couldCloseCurrentCSO;
141
142 bool _shouldCloseWhenStartedInFreehand;
143 bool _hasStartedFreehand;
144 bool _isDrawingFreehand;
145 ml::CSOLiveWireGraph* _liveWireGraph;
146 int _sliceZ;
147 int _startSliceZ;
148 unsigned int _lastImageSerialNumber;
149};
150
#define SOCSO_EXPORT
Header file for system independent resolution.
Definition SoCSOSystem.h:21
Base class for extensions that generate line-type CSOs with special interaction on finished CSOs.
Extension for rendering, generating, and modifying a live wire CSO.
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
Sets seed points while moving the mouse – but not while dragging.
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.
SoPointingAction is the base class for any mouse based interaction.
The SoSFMLImage field is the interface used by Inventor Nodes to access image data (in the current im...
Definition SoSFMLImage.h:84
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.
The CSOPathPoints is a list of world coordinates that are interpolated by a certain interpolation sch...
The CSOSeedPoint can be interactively set and modified, and is the framework for contours.
The CSO represents a contour segmentation object.
Definition CSO.h:44
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
Structure holding a 2D voxel position.