Computer Assisted Medical Intervention Tool Kit  version 5.2
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-2024 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"
32 #include "ImageOrientationHelper.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 
43 // -- QT stuff classes
44 class QMenu;
45 class QTableView;
46 class QVector3D;
47 class QVariant;
48 class QTableView;
49 class QStandardItemModel;
50 
51 
52 
53 namespace camitk {
54 
55 class MeshComponent;
56 class SingleImageComponent;
57 class ArbitrarySingleImageComponent;
58 
78  Q_OBJECT
79 
80 public:
83  ImageComponent(const QString& file);
84 
95  ImageComponent(vtkSmartPointer<vtkImageData> anImageData, const QString& name, bool copy = false, ImageOrientationHelper::PossibleImageOrientations initialOrientation = ImageOrientationHelper::RAI);
96 
98  ~ImageComponent() override;
99 
101  void setSelected(const bool b, const bool recursive = false) override;
102 
104 
112  CAMITK_API_DEPRECATED("Please use setVisibility(QString viewerName, bool) instead") virtual void setVisibility(Viewer*, bool) override;
114 
116  virtual void setVisibility(QString, bool) override;
117 
119  QString getImageName() const;
120  void setImageName(const QString&);
121 
123  vtkSmartPointer<vtkImageData> getImageData() const override {
124  return originalImageData;
125  }
126 
132  vtkSmartPointer<vtkImageData> getImageDataWithFrameTransform();
133 
136  return initialOrientation;
137  }
138 
143  void pixelPicked(double x, double y, double z) override;
144 
147  void getLastPixelPicked(int* x, int* y, int* z);
148 
151  void getLastPointPickedImageCoords(double* x, double* y, double* z);
152 
155  void getLastPointPickedWorldCoords(double* x, double* y, double* z);
156 
157 
162  int getNumberOfColors() const override;
163 
165  double getMinColor() const;
166 
168  double getMaxColor() const;
169 
173  int getActualNumberOfColors() const;
174 
176  double getActualMinColor() const;
177 
179  double getActualMaxColor() const;
180 
182  int getNumberOfSlices() const override;
183 
185  virtual void setLut(vtkSmartPointer<vtkWindowLevelLookupTable> lookupTable);
186 
188  virtual vtkSmartPointer<vtkWindowLevelLookupTable> getLut();
189 
191  virtual const vtkSmartPointer<vtkWindowLevelLookupTable> getLut() const;
192 
195  void refresh() override;
196 
198  SingleImageComponent* getAxialSlices();
200  SingleImageComponent* getCoronalSlices();
202  SingleImageComponent* getSagittalSlices();
204  ArbitrarySingleImageComponent* getArbitrarySlices();
206  MeshComponent* getVolumeRenderingChild();
207 
213  virtual void replaceImageData(vtkSmartPointer<vtkImageData> anImageData, bool copy = false, ImageOrientationHelper::PossibleImageOrientations initialOrientation = ImageOrientationHelper::RAI);
214 
221  void updateProperty(QString, QVariant) override;
222 
224  unsigned int getNumberOfPropertyWidget() override;
225 
227  QWidget* getPropertyWidgetAt(unsigned int i) override;
229 
230  const vtkSmartPointer<vtkMatrix4x4> getRotationMatrix() {
231  return rotationMatrix;
232  }
233 
240  virtual QVariant toVariant() const override;
241 
243  virtual void fromVariant(const QVariant&) override;
245 
246 
247 protected:
248 
256  void setImageData(vtkSmartPointer<vtkImageData> anImageData,
257  bool copy,
259  vtkSmartPointer<vtkMatrix4x4> initialTransformMatrix = nullptr);
260 
270  void setSingleImageComponents(SingleImageComponent* axialSlices, SingleImageComponent* sagittalSlices, SingleImageComponent* coronalSlices, ArbitrarySingleImageComponent* arbitrarySlices);
271 
272 private:
283  void initImageProperties();
284 
286  void initRepresentation() override {}
287 
288  // builds default lookup table
289  void initLookupTable();
290 
292  void buildImageComponents();
293 
295  void updateImageComponents();
296 
302  void update3DViewer();
303 
306  vtkSmartPointer<vtkPolyData> getBoundingBox();
307 
309  vtkSmartPointer<vtkImageData> originalImageData;
310 
312  SingleImageComponent* axialSlices;
313 
315  SingleImageComponent* sagittalSlices;
316 
318  SingleImageComponent* coronalSlices;
319 
321  ArbitrarySingleImageComponent* arbitrarySlices;
322 
325  MeshComponent* volumeRenderingChild;
326 
328  vtkSmartPointer<vtkWindowLevelLookupTable> lut;
329 
331  double currentPixelPicked[3];
332 
334  void init();
335 
337  QTableView* selectionView;
338 
340  QStandardItemModel* model;
341 
344 
348  vtkSmartPointer<vtkTransform> initialImageDataTransform;
349 
354  vtkSmartPointer<vtkTransform> initialFrameTransform;
355 
358  vtkSmartPointer<vtkMatrix4x4> rotationMatrix;
359 };
360 
361 }
362 
363 #endif //IMAGE_COMPONENT_H
#define CAMITK_API_DEPRECATED(X)
Definition: CamiTKAPI.h:94
#define CAMITK_API
Definition: CamiTKAPI.h:49
This Component manages the specific case of arbitrary orientation of a sub-component of the image com...
Definition: ArbitrarySingleImageComponent.h:65
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:303
The manager of the Image Volume data.
Definition: ImageComponent.h:77
const vtkSmartPointer< vtkMatrix4x4 > getRotationMatrix()
Definition: ImageComponent.h:230
ImageOrientationHelper::PossibleImageOrientations getInitialOrientation() const
Get the initial image orientation.
Definition: ImageComponent.h:135
vtkSmartPointer< vtkImageData > getImageData() const override
get the image volume managed by this Component
Definition: ImageComponent.h:123
PossibleImageOrientations
For each axis (x, y or z), 6 possibilities:
Definition: ImageOrientationHelper.h:52
@ RAI
Direct Orientations X: Right to Left, Y: Anterior to Posterior, Z: Inferior to Superiror.
Definition: ImageOrientationHelper.h:55
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:61
Viewer is an abstract class that is the base class for all viewers.
Definition: Viewer.h:181
Definition: Action.cpp:36
void refresh()
refresh the display