MeVisLab Toolbox Reference
CSOTransformationProcessor.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2011, 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 #ifndef CSOTRANSFORMATION_PROCESSOR_H
14 #define CSOTRANSFORMATION_PROCESSOR_H
15 
16 
18 
19 #include "SoCSOSystem.h"
22 
23 
24 ML_START_NAMESPACE
25 
27 
29 {
30  SbVec3f v1, v2;
31  CSO* cso;
33  SbVec3f middle() const { return SbVec3f((v1[0]+v2[0])*.5f, (v1[1]+v2[1])*.5f, (v1[2]+v2[2])*.5f); }
34 };
35 
37 
42 };
43 
45 
51 };
52 
54 
59  ICON_TRANSLATE = 3
60 };
61 
63 
66 {
67 
68 public:
69 
72 
75  bool process(CSOEvalEventView2DInfos view2DInfos, CSOEvalEventCSOInfos csoInfos) override;
76 
78  void draw(CSODrawView2DInfos view2DInfos, CSODrawCSOInfos csoInfos) override;
79 
81  bool isCurrentlyEditing() override;
83  bool isCurrentlyGenerating() override { return false; }
85  void resetInteractionState() override;
87  void triggerSetMouseCursor(SoView2D* view2d, bool shouldSetMouseCursor) override;
88 
89  void handleNotification(Field* field) override;
90 
91 
92 protected:
93 
96 
97 private:
98 
99  // FIELDS
100  BoolField* _enableScaleFld;
101  BoolField* _enableRotateFld;
102  BoolField* _enableTranslateFld;
103 
104  FloatField* _handleScaleFld;
105  FloatField* _influenceMarginFld;
106 
107  BoolField* _useAutoLevelingFld;
108 
109  BoolField* _useCSOColorFld;
110 
111  ColorField* _scaleHandleColorFld;
112  ColorField* _rotateHandleColorFld;
113  ColorField* _translateHandleColorFld;
114 
115  FloatField* _scaleHandleAlphaFld;
116  FloatField* _rotateHandleAlphaFld;
117  FloatField* _translateHandleAlphaFld;
118 
119  BoolField* _showHandlesOnlyForSelectedCSOFld;
120  BoolField* _useUndoRedoManagerFld;
121  BoolField* _scaleIsotropicFld;
122 
123  BoolField* _useIconFileFld;
124  StringField* _iconFileFld;
125  StringField* _internalIconFileFld;
126 
127  BoolField* _storeTransformationMatrixInCSOFld;
128 
129  // METHODS
130 
131  CSO* _checkScaleHandles();
132  CSO* _checkRotateHandles();
133  CSO* _checkTranslateHandles();
134 
135  void _drawScaleHandles(const CSOInventorVoxelBoundingBox& dBB) const;
136  void _drawRotateHandles(const CSOInventorVoxelBoundingBox& dBB) const;
137  void _drawTranslateHandles(const CSOInventorVoxelBoundingBox& dBB) const;
138 
139  void _scaleCurrentCSO();
140  void _rotateCurrentCSO();
141  void _translateCurrentCSO();
142 
143  void _initializeRotation();
144  void _finishRotation();
145 
146  void _initializeHandleIcons();
147 
148  float handleMargin() const { return _handleSize * 2.0f; }
149  float handleSize() const { return _handleSize * _handleScaleFld->getFloatValue(); }
150  float influenceMargin() const { return _influenceMarginFld->getFloatValue(); }
151 
152  CSOInventorVoxelBoundingBox _convertVoxelBoundingBoxToInventor(CSO* cso, Matrix4 worldToVoxelMatrix) const;
153  Matrix4 _convertInventorToMLMatrix(const SbMatrix& inventorMatrix) const;
154 
155  void _compileActiveCSOs(CSOList* csoList, View2DSliceList* slicelist, CSOBoundingBox slabBB, std::vector<CSOInventorVoxelBoundingBox>& voxelBBList);
156 
157  Matrix4 _getCurrentTransformationMatrix(CSO* cso);
158  void _updateTransformationMatrixByTranslation(const Matrix4& translationMatrix, CSO* cso);
159  void _updateTransformationMatrixByRotation(const Matrix4& rotationMatrix, CSO* cso);
160 
161  Matrix4 _initialCSOInteractiveMatrix;
162 
163  // STATE VARIABLES
164  bool _isEditing;
165 
166  bool _shouldStoreInUndoManager;
167 
168  bool _isScaling;
169  bool _isRotating;
170  bool _isTranslating;
171 
172  bool _mouseOverScaleHandle;
173  bool _mouseOverRotateHandle;
174  bool _mouseOverTranslateHandle;
175 
176  CSO* _hitCSO;
177  CSO* _mouseOverCSO;
178  CSO _rotationCSO;
179  bool _hasRotationSingularity;
180 
181  ScaleDirection _scaleDirection;
182  CSOInventorVoxelBoundingBox _rotateBoundingBox;
183  float _rotationAngle;
184 
185  float _deviceX;
186  float _deviceY;
187 
188  float _startPosX;
189  float _startPosY;
190 
191  float _currentPosX;
192  float _currentPosY;
193 
194  float _interactionStartX;
195  float _interactionStartY;
196 
197  // member constant for global icon scaling.
198  float _handleSize;
199 
200  View2DIcons* _handleIcons;
201 
202  View2DSliceList* _slicelistDraw;
203  View2DSliceList* _slicelistEdit;
204 
205  std::vector<CSOInventorVoxelBoundingBox> _visibleCSOBoundingBoxes;
206  std::vector<CSOInventorVoxelBoundingBox> _editableCSOBoundingBoxes;
207 
208  ML_MODULE_CLASS_HEADER(CSOTransformationProcessor);
209 };
210 
212 
213 
214 ML_END_NAMESPACE
215 
216 #endif // __CSOTransformationProcessor_H
#define SOCSO_EXPORT
Header file for system independent resolution.
Definition: SoCSOSystem.h:21
SoView2D is a 2D viewer for image data.
Definition: SoView2D.h:62
Defines and implements a class to store multiple images and draw them via OpenGL.
Definition: View2DIcons.h:24
a list that holds all View2DSlice objects (lazily created) of a SoView2D
Field to encapsulate a boolean value.
Definition: mlFields.h:62
The CSOBoundingBox defines an axis parallel bounding box with double precision.
Base class for processor modules; those provide mechanisms for an interactive generation of seed poin...
Definition: CSOProcessor.h:42
Module to interactively transform CSOs.
bool process(CSOEvalEventView2DInfos view2DInfos, CSOEvalEventCSOInfos csoInfos) override
Evaluates the interaction events and interpolates the contours accordingly.
bool isCurrentlyEditing() override
Returns whether the processor is currently editing an existing contour.
CSOTransformationProcessor()
Constructor.
bool isCurrentlyGenerating() override
Returns whether the processor is currently generating an existing contour which is never.
void handleNotification(Field *field) override
Called when input changes.
void triggerSetMouseCursor(SoView2D *view2d, bool shouldSetMouseCursor) override
Triggers the setting of the processor's default mouse cursor.
void resetInteractionState() override
Sets back internal interaction state.
void draw(CSODrawView2DInfos view2DInfos, CSODrawCSOInfos csoInfos) override
Draws specific geometry.
~CSOTransformationProcessor() override
Destructor.
The CSO represents a contour segmentation object.
Definition: CSO.h:44
Field to encapsulate a vector of 3 float values representing an (rgb) color with all properties of Ve...
Definition: mlFields.h:2065
Base class for all fields used in the ML.
Definition: mlField.h:73
Field to encapsulate a float value.
Definition: mlFields.h:627
float getFloatValue() const
Returns the value of the field.
Field to encapsulate a string value.
Definition: mlFields.h:1000
#define ML_MODULE_CLASS_HEADER(className)
Like ML_CLASS_HEADER for the usage of derived classes from Module.
Tmat4< MLdouble > Matrix4
The standard 4x4 matrix of type double.
Definition: mlMatrix4.h:726
@ TRANSFORMATION_MODE_TRANSLATE