Computer Assited Medical Intervention Tool Kit  version 5.0
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-2021 Univ. Grenoble Alpes, CNRS, Grenoble INP, 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 
192  void refresh() override;
193 
195  SingleImageComponent* getAxialSlices();
197  SingleImageComponent* getCoronalSlices();
199  SingleImageComponent* getSagittalSlices();
201  ArbitrarySingleImageComponent* getArbitrarySlices();
203  MeshComponent* getVolumeRenderingChild();
204 
210  virtual void replaceImageData(vtkSmartPointer<vtkImageData> anImageData, bool copy = false, ImageOrientationHelper::PossibleImageOrientations initialOrientation = ImageOrientationHelper::RAI);
211 
218  void updateProperty(QString, QVariant) override;
219 
221  unsigned int getNumberOfPropertyWidget() override;
222 
224  QWidget* getPropertyWidgetAt(unsigned int i) override;
226 
227  const vtkSmartPointer<vtkMatrix4x4> getRotationMatrix() {
228  return rotationMatrix;
229  }
230 
231 
232 protected:
233 
241  void setImageData(vtkSmartPointer<vtkImageData> anImageData,
242  bool copy,
244  vtkSmartPointer<vtkMatrix4x4> initialTransformMatrix = nullptr);
245 
255  void setSingleImageComponents(SingleImageComponent* axialSlices, SingleImageComponent* sagittalSlices, SingleImageComponent* coronalSlices, ArbitrarySingleImageComponent* arbitrarySlices);
256 
257 private:
268  void initImageProperties();
269 
271  void initRepresentation() override {}
272 
273  // builds default lookup table
274  void initLookupTable();
275 
277  void buildImageComponents();
278 
280  void updateImageComponents();
281 
287  void update3DViewer();
288 
291  vtkSmartPointer<vtkPolyData> getBoundingBox();
292 
294  vtkSmartPointer<vtkImageData> originalImageData;
295 
298 
301 
304 
307 
311 
313  vtkSmartPointer<vtkWindowLevelLookupTable> lut;
314 
316  double currentPixelPicked[3];
317 
319  void init();
320 
322  QTableView* selectionView;
323 
325  QStandardItemModel* model;
326 
329 
333  vtkSmartPointer<vtkTransform> initialImageDataTransform;
334 
339  vtkSmartPointer<vtkTransform> initialFrameTransform;
340 
343  vtkSmartPointer<vtkMatrix4x4> rotationMatrix;
344 };
345 
346 }
347 
348 #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:302
The manager of the Image Volume data.
Definition: ImageComponent.h:77
QStandardItemModel * model
Model to display data.
Definition: ImageComponent.h:325
QTableView * selectionView
Tab displaying data selected point in the property explorer.
Definition: ImageComponent.h:322
const vtkSmartPointer< vtkMatrix4x4 > getRotationMatrix()
Definition: ImageComponent.h:227
SingleImageComponent * sagittalSlices
the sagittal slices representation (all intelligence is delegated to a Slice class instance)
Definition: ImageComponent.h:300
SingleImageComponent * coronalSlices
the coronal slices representation (all intelligence is delegated to a Slice class instance)
Definition: ImageComponent.h:303
void initRepresentation() override
the concrete building of the 3D objects (Slice/Geometry): none in this case!
Definition: ImageComponent.h:271
vtkSmartPointer< vtkTransform > initialImageDataTransform
The initial transform to the vtkImageData.
Definition: ImageComponent.h:333
ArbitrarySingleImageComponent * arbitrarySlices
the arbitrary slices representation (all intelligence is delegated to a Slice class instance)
Definition: ImageComponent.h:306
MeshComponent * volumeRenderingChild
When an action computes volume rendering for an image, it stores the corresponding actor as a prop of...
Definition: ImageComponent.h:310
ImageOrientationHelper::PossibleImageOrientations getInitialOrientation() const
Get the initial image orientation.
Definition: ImageComponent.h:135
vtkSmartPointer< vtkMatrix4x4 > rotationMatrix
The rotation matrix, that might have been altered by the user Will be saved in header file informatio...
Definition: ImageComponent.h:343
vtkSmartPointer< vtkWindowLevelLookupTable > lut
the current lookup table
Definition: ImageComponent.h:313
SingleImageComponent * axialSlices
the axial slices representation (all intelligence is delegated to a Slice class instance)
Definition: ImageComponent.h:297
vtkSmartPointer< vtkImageData > originalImageData
the core Image Volume that is managed here
Definition: ImageComponent.h:294
ImageOrientationHelper::PossibleImageOrientations initialOrientation
Initial image orientation.
Definition: ImageComponent.h:328
vtkSmartPointer< vtkTransform > initialFrameTransform
The initial frame of the image at opening.
Definition: ImageComponent.h:339
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:180
Definition: Action.cpp:35
void refresh()
refresh the display