Computer Assisted Medical Intervention Tool Kit version 6.0
 
Loading...
Searching...
No Matches
ImageComponent.h
Go to the documentation of this file.
1/*****************************************************************************
2 * $CAMITK_LICENCE_BEGIN$
3 *
4 * CamiTK - Computer Assisted Medical Intervention ToolKit
5 * (c) 2001-2025 Univ. Grenoble Alpes, CNRS, Grenoble INP - UGA, TIMC, 38000 Grenoble, France
6 *
7 * Visit http://camitk.imag.fr for more information
8 *
9 * This file is part of CamiTK.
10 *
11 * CamiTK is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
14 *
15 * CamiTK is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22 *
23 * $CAMITK_LICENCE_END$
24 ****************************************************************************/
25
26#ifndef IMAGE_COMPONENT_H
27#define IMAGE_COMPONENT_H
28
29// -- Core image component stuff
30#include "CamiTKAPI.h"
31#include "Component.h"
33
34// -- vtk stuff
35#include <vtkPolyData.h>
36#include <vtkSmartPointer.h>
37#include <vtkImageData.h>
38#include <vtkTransform.h>
39#include <vtkImageFlip.h>
40#include <vtkWindowLevelLookupTable.h>
41#include <vtkMatrix4x4.h>
42#include <vtkUnstructuredGrid.h>
43#include <vtkActor.h>
44
45// -- QT stuff classes
46class QMenu;
47class QTableView;
48class QVector3D;
49class QVariant;
50class QTableView;
51class QStandardItemModel;
52
53namespace camitk {
54
55class MeshComponent;
56class SingleImageComponent;
57class ArbitrarySingleImageComponent;
58
77 Q_OBJECT
78
79public:
80
90 ImageComponent(const QString& file, const QString& name);
91
105 ImageComponent(vtkSmartPointer<vtkImageData> anImageData, const QString& name, bool copy = false, ImageOrientationHelper::PossibleImageOrientations initialOrientation = ImageOrientationHelper::RAI);
106
108 ~ImageComponent() override;
109
111 void setSelected(const bool b, const bool recursive = false) override;
112
114 virtual void setVisibility(QString, bool) override;
115
117 vtkSmartPointer<vtkImageData> getImageData() const override {
118 return originalImageData;
119 }
120
126 vtkSmartPointer<vtkImageData> getImageDataWithFrameTransform();
127
130 return initialOrientation;
131 }
132
137 void pixelPicked(double x, double y, double z) override;
138
142 virtual vtkSmartPointer<vtkActor> get3DCursor() override;
143
146 void getLastPixelPicked(int* x, int* y, int* z);
147
150 void getLastPointPickedDataFrame(double* x, double* y, double* z);
151
154 void getLastPointPickedWorldFrame(double* x, double* y, double* z);
155
157 void setLastPointPickedFromPixel(int x, int y, int z);
158
163 int getNumberOfColors() const override;
164
166 double getMinColor() const;
167
169 double getMaxColor() const;
170
174 int getActualNumberOfColors() const;
175
177 double getActualMinColor() const;
178
180 double getActualMaxColor() const;
181
183 int getNumberOfSlices() const override;
184
186 virtual void setLut(vtkSmartPointer<vtkWindowLevelLookupTable> lookupTable);
187
189 virtual vtkSmartPointer<vtkWindowLevelLookupTable> getLut();
190
192 virtual const vtkSmartPointer<vtkWindowLevelLookupTable> getLut() const;
193
196 void refresh() override;
197
199 SingleImageComponent* getAxialSlices();
201 SingleImageComponent* getCoronalSlices();
203 SingleImageComponent* getSagittalSlices();
205 ArbitrarySingleImageComponent* getArbitrarySlices();
207 MeshComponent* getVolumeRenderingChild();
208
214 virtual void replaceImageData(vtkSmartPointer<vtkImageData> anImageData, bool copy = false, ImageOrientationHelper::PossibleImageOrientations initialOrientation = ImageOrientationHelper::RAI);
215
222 void propertyValueChanged(QString) override;
223
225 unsigned int getNumberOfPropertyWidget() override;
226
228 QWidget* getPropertyWidgetAt(unsigned int i) override;
230
231 const vtkSmartPointer<vtkMatrix4x4> getRotationMatrix() {
232 return rotationMatrix;
233 }
234
241 virtual void setFramesAndTransformation(const std::shared_ptr<FrameOfReference>& mainFrame, const std::shared_ptr<FrameOfReference>& dataFrame, const std::shared_ptr<Transformation>& mainTransformation);
242
245 return dataFrame.get();
246 };
247
254 virtual void setFrame(const std::shared_ptr<FrameOfReference>& frame) override;
255
256 // Modify this object's frame using the given object's frame.
259 virtual void setFrameFrom(const InterfaceFrame*) override;
260
264 virtual void resetFrame() override;
265
267 virtual const std::vector<std::shared_ptr<FrameOfReference>>& getAdditionalFrames() const {
268 return additionalFrames;
269 };
270
272 virtual void addAdditionalFrame(const std::shared_ptr<FrameOfReference>& fr) {
273 additionalFrames.push_back(fr);
274 }
275
277 virtual void removeAdditionalFrame(const FrameOfReference* fr) {
278 std::erase_if(additionalFrames, [fr](auto & f) {
279 return f.get() == fr;
280 });
281 }
282
284 virtual const std::vector<std::shared_ptr<Transformation>>& getAdditionalTransformations() const {
285 return additionalTransformations;
286 }
287
289 virtual void addAdditionalTransformation(const std::shared_ptr<Transformation> tr) {
290 additionalTransformations.push_back(tr);
291 }
292
295 std::erase_if(additionalTransformations, [tr](auto t) {
296 return t.get() == tr;
297 });
298 }
299
303 virtual QMultiMap<const FrameOfReference*, Component*> getAllFrames(bool includeChildrenFrames = true) override;
304
308 virtual QMultiMap<const Transformation*, Component*> getAllTransformations(bool includeChildrenTransformations = true) override;
309
312 return mainTransformation.get();
313 }
314
316 virtual void updateMainTransformation(vtkSmartPointer<vtkMatrix4x4>);
318
325 virtual QVariant toVariant() const override;
326
328 virtual void fromVariant(const QVariant&) override;
330
331protected:
332
340 void setImageData(vtkSmartPointer<vtkImageData> anImageData,
341 bool copy,
342 ImageOrientationHelper::PossibleImageOrientations initialOrientation = ImageOrientationHelper::RAI,
343 vtkSmartPointer<vtkMatrix4x4> initialTransformMatrix = nullptr);
344
354 void setSingleImageComponents(SingleImageComponent* axialSlices, SingleImageComponent* sagittalSlices, SingleImageComponent* coronalSlices, ArbitrarySingleImageComponent* arbitrarySlices);
355
358 bool setMainTransformation(const std::shared_ptr<Transformation>& tr);
359
360private:
371 void initImageProperties();
372
374 void initRepresentation() override {}
375
376 // builds default lookup table
377 void initLookupTable();
378
380 void initCursor();
381
383 void updateCursor();
384
386 void buildImageComponents();
387
389 void updateImageComponents();
390
396 void update3DViewer();
397
400 vtkSmartPointer<vtkPolyData> getBoundingBox();
401
403 vtkSmartPointer<vtkImageData> originalImageData;
404
406 SingleImageComponent* axialSlices;
407
409 SingleImageComponent* sagittalSlices;
410
412 SingleImageComponent* coronalSlices;
413
415 ArbitrarySingleImageComponent* arbitrarySlices;
416
419 MeshComponent* volumeRenderingChild;
420
422 vtkSmartPointer<vtkWindowLevelLookupTable> lut;
423
425 double currentPixelPicked[3];
426
428 vtkSmartPointer<vtkActor> cursorActor;
429
431 vtkSmartPointer<vtkUnstructuredGrid> cursorActorPointSet;
432
434 void init();
435
437 QTableView* selectionView;
438
440 QStandardItemModel* model;
441
443 ImageOrientationHelper::PossibleImageOrientations initialOrientation;
444
448 vtkSmartPointer<vtkTransform> initialImageDataTransform;
449
454 vtkSmartPointer<vtkTransform> initialFrameTransform;
455
458 vtkSmartPointer<vtkMatrix4x4> rotationMatrix;
459
460 // InterfaceFrame extension for Images
461 std::shared_ptr<FrameOfReference> dataFrame = nullptr;
462 std::shared_ptr<Transformation> mainTransformation = nullptr;
463 std::vector<std::shared_ptr<FrameOfReference>> additionalFrames;
464 std::vector<std::shared_ptr<Transformation>> additionalTransformations;
465};
466
467}
468
469#endif //IMAGE_COMPONENT_H
#define CAMITK_API
Definition CamiTKAPI.h:66
This Component manages the specific case of arbitrary orientation of a sub-component of the image com...
Definition ArbitrarySingleImageComponent.h:89
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition sdk/libraries/core/component/Component.h:304
FrameOfReference is only a label for an abstract coordinate system.
Definition FrameOfReference.h:71
The manager of the Image Volume data.
Definition ImageComponent.h:76
virtual void removeAdditionalTransformation(const Transformation *tr)
Remove an additional Transformation from the Component.
Definition ImageComponent.h:294
vtkSmartPointer< vtkImageData > getImageDataWithFrameTransform()
Compute a copy of the original image data on which the frame transform has been applied.
const FrameOfReference * getDataFrame() const
get the data FrameOfReference (i.e., the vtkImageData frame)
Definition ImageComponent.h:244
virtual const std::vector< std::shared_ptr< Transformation > > & getAdditionalTransformations() const
get the additional Transformations
Definition ImageComponent.h:284
vtkSmartPointer< vtkImageData > getImageData() const override
get the image volume managed by this Component
Definition ImageComponent.h:117
const vtkSmartPointer< vtkMatrix4x4 > getRotationMatrix()
Definition ImageComponent.h:231
ImageOrientationHelper::PossibleImageOrientations getInitialOrientation() const
Get the initial image orientation.
Definition ImageComponent.h:129
virtual const std::vector< std::shared_ptr< FrameOfReference > > & getAdditionalFrames() const
get the other frames (neither data nor main)
Definition ImageComponent.h:267
virtual void addAdditionalFrame(const std::shared_ptr< FrameOfReference > &fr)
add an additional frame (neither data nor main)
Definition ImageComponent.h:272
virtual Transformation * getMainTransformation() const
Get main Transformation (data -> main)
Definition ImageComponent.h:311
virtual void removeAdditionalFrame(const FrameOfReference *fr)
remove an additional frame
Definition ImageComponent.h:277
virtual void addAdditionalTransformation(const std::shared_ptr< Transformation > tr)
add an additional Transformation
Definition ImageComponent.h:289
PossibleImageOrientations
For each axis (x, y or z), 6 possibilities:
Definition ImageOrientationHelper.h:52
This class describes the methods to implement in order to manage a Component position in space.
Definition InterfaceFrame.h:51
Basic component to manage any kind of mesh.
Definition MeshComponent.h:53
This Component manages sub-component of the image component seen as a single orientation only (axial ...
Definition SingleImageComponent.h:62
Transformation represents a geometrical transformation between two FrameOfReferences.
Definition Transformation.h:83
Definition Action.cpp:40