MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
SoCSOTransformEditor.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
19
21
23class CSO;
25
27
30{
31 SO_NODE_HEADER(SoCSOTransformEditor);
32
33public:
38
40 void draw(const CSODrawCSOInfos& csoInfos, const CSODrawView2DInfos& view2DInfos,
42
44 static void initClass();
45
46 virtual bool evaluateHitPoint(const ml::Vector3& worldPosition, View2DSliceList* slicelist, ml::CSOList* csoList,
52 float&) override
53 {
54 return false;
55 }
56
57 bool isModificationEditor() const override
58 {
59 return true;
60 }
61 void cancel() override;
62
65
68
70
72 {}
73 void createDragMoveTo(const SoPointerPosition&) override
74 {}
75 bool createEndPress(int) override
76 {
77 return false;
78 }
80 {}
81
83 {}
85 {}
87 {
88 return nullptr;
89 }
90
91 int cursorShape() const override
92 {
93 return _cursorShape;
94 }
95
96 bool shouldRenderSpecific(ml::CSO*) const override
97 {
98 return false;
99 }
100 bool shouldRenderGeneral(ml::CSO*) const override
101 {
102 return true;
103 }
104
106
110
113
115
118
127
129
130protected:
132
133 void initMembers() override;
134
135private:
137 enum ScaleDirection {
138 UN = -1,
139 NW = 0,
140 N = 1,
141 NE = 2,
142 W = 3,
143 E = 4,
144 SW = 5,
145 S = 6,
146 SE = 7
147 };
148
149 void performScaling(const SoPointerPosition& pos);
150 void performRotation(const SoPointerPosition& pos);
151 void performTranslation(const SoPointerPosition& pos);
152
154 static void baseEventCB(void* userData, ml::BaseEvent* event);
157 void attachAsListenerTo(ml::CSOList* csoList);
159 ml::CSOList* _listenToCSOList;
160
162 bool isInSelectionDistance(const SbVec2f& pos1, const SbVec2f& pos2, float selectionDistance) const;
164 bool isInTranslationArea(const SbVec2f& mouseDevicePosition,
165 const std::vector<SbVec2f>& translateHandlesPositions) const;
166
167
169 void clearHandlesPositions();
171 void setScaleCursorShape();
173 void limitScaleOffset(SbVec2f& scaleOffset);
175 void computeMoveAndScaleFactors(const SbVec3f& offsetX, const SbVec3f& offsetY, float voxelBBX, float voxelBBY,
176 float& voxelMoveX, float& voxelMoveY, float& voxelScaleX, float& voxelScaleY) const;
177
179 void computeMoveAndScaleFactorsForIsotropicScaling(const SbVec3f& bbVoxelCenterPoint,
181 float& voxelScaleY);
183 void drawRotateIndicatorLine(ml::CSO* cso, const SbVec2f& rotateHandlePosition, float rotateHandleOffset);
184
185 boost::unordered_map<MatrixHashPair, std::vector<SbVec2f>, MatrixHashFunction> _scaleHandlesPositionsCache;
186 boost::unordered_map<MatrixHashPair, std::vector<SbVec2f>, MatrixHashFunction> _translateHandlesPositionsCache;
187
188 boost::unordered_map<MatrixHashPair, SbVec2f, MatrixHashFunction> _rotateHandlePositionCache;
189 boost::unordered_map<MatrixHashPair, SbVec2f, MatrixHashFunction> _rotateCenterCache;
190
192 void resetActiveHandleIndices()
193 {
194 _activeScaleHandleIndex = -1;
195 _activeTranslateHandleIndex = -1;
196 _activeRotateHandleIndex = -1;
197 }
198
200 bool shouldShowHandles() const;
201
202 bool _isInteracting;
203 bool _isRotating;
204
205 int _activeScaleHandleIndex;
206 int _activeTranslateHandleIndex;
207 int _activeRotateHandleIndex;
208
209 SbVec2f _startDevicePosition;
210 SbVec3f _startVoxelPositionForIsotropicScaling;
211 SbVec3f _lastWorldPosition;
212 SbVec3f _lastGoodCurrentWorldPosition;
213
214 int _cursorShape;
215
216 ml::CSO _originalCSO;
217
218 SbVec2f _rotationCenterDevice;
219 void setRotationCenter(View2DSliceList* slicelist);
220 ml::Matrix4 composeMLRotationMatrix(const SoPointerPosition& pos);
221
222 ml::Matrix4 convertInventorToMLMatrix(const SbMatrix& matrix);
223
224 ml::CSO* _selectedCSO;
225};
226
#define SOCSO_EXPORT
Header file for system independent resolution.
Definition SoCSOSystem.h:21
@ N
@ E
@ W
@ S
Base class for an editor extension for the SoView2DCSOExtensibleEditor.
Extension for transforming existing CSOs.
virtual bool evaluateHitPoint(const ml::Vector3 &worldPosition, View2DSliceList *slicelist, ml::CSOList *csoList, ml::CSO *&cso, SoView2DCSOExtensibleEditor *editor)
bool shouldRenderGeneral(ml::CSO *) const override
Returns whether a given CSO should be rendered by this general extension.
void transformStartPressAt(const SoPointerPosition &pos)
void createStartPressAt(const SoPointerPosition &) override
void selectAndMoveStartPressAt(const SoPointerPosition &) override
SoPointingAction * selectAndMoveEndPress(int) override
bool isEligibleForTransforming(ml::CSO *cso, View2DSliceList *slicelist, SoView2DCSOExtensibleEditor *editor)
Returns whether the given CSO is eligible for transforming by this editor.
SoCSOTransformEditor()
Standard constructor.
~SoCSOTransformEditor() override
Destructor.
int cursorShape() const override
Returns the cursor shape that indicates the next creation.
bool shouldRenderSpecific(ml::CSO *) const override
Returns whether a given CSO should be rendered by this specific extension.
bool isModificationEditor() const override
Returns whether the editor is a modification editor.
void selectAndMoveDragMoveTo(const SoPointerPosition &) override
void draw(const CSODrawCSOInfos &csoInfos, const CSODrawView2DInfos &view2DInfos, const CSODrawSliceInformation &drawSliceInfo, SoView2DCSOExtensibleEditor *editor) override
Drawing routine.
bool evaluateHitPoint(const ml::Vector3 &, View2DSliceList *, ml::CSOList *, const ml::CSOBoundingBox &, SoView2DCSOExtensibleEditor *, ml::CSO *&, ml::CSOSeedPoint *&, ml::CSOPathPoints *&, float &) override
Overload the method and always return false so no CSO can be picked.
void createDragMoveTo(const SoPointerPosition &) override
void drawInteractionHandleAsSeedPointAt(ml::CSO *cso, float deviceX, float deviceY)
void pointerPositionIfAllowedAt(const SoPointerPosition &) override
Sets seed points while moving the mouse – but not while dragging.
void initMembers() override
static void initClass()
init class in inventor runtime
void cancel() override
Cancels an action like generating a CSO. Depends on concrete editor.
bool createEndPress(int) override
SoPointingAction * transformEndPress(int clickCount)
void transformDragMoveTo(const SoPointerPosition &pos)
SoPointerPosition manages the current position of the mouse cursor.
SoPointingAction is the base class for any mouse based interaction.
a list that holds all View2DSlice objects (lazily created) of a SoView2D
BaseEvent is the base class for all events emitted from EventSourceBase.
The CSOBoundingBox defines an axis-parallel bounding box with double precision.
A CSOList comprises a number of CSOs and CSOGroups and is the central object for contour segmentation...
Definition CSOList.h:61
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.
Struct for retrieving a hash key for a Matrix4 that is used in the caches for voxel bounding boxes.