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 
111  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 
216  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
camitk::ImageComponent::arbitrarySlices
ArbitrarySingleImageComponent * arbitrarySlices
the arbitrary slices representation (all intelligence is delegated to a Slice class instance)
Definition: ImageComponent.h:306
camitk::ImageComponent::pixelPicked
void pixelPicked(double x, double y, double z) override
Method called when a pixel has been picked in the 3D view.
Definition: ImageComponent.cpp:657
camitk::ImageComponent::getCoronalSlices
SingleImageComponent * getCoronalSlices()
Returns the coronal slice.
Definition: ImageComponent.cpp:477
camitk::ImageComponent::replaceImageData
virtual void replaceImageData(vtkSmartPointer< vtkImageData > anImageData, bool copy=false, ImageOrientationHelper::PossibleImageOrientations initialOrientation=ImageOrientationHelper::RAI)
Replaces the current image volume by the one given in parameters.
Definition: ImageComponent.cpp:436
camitk::Component::setRenderingModes
setRenderingModes
Definition: sdk/libraries/core/component/Component.h:671
ImageComponentExtension.h
camitk::Component::getTransform
const vtkSmartPointer< vtkTransform > getTransform() const override
Get the transformation with respect to the parent frame.
Definition: sdk/libraries/core/component/Component.cpp:824
CAMITK_WARNING
#define CAMITK_WARNING(MSG)
Log for warning verbosity (the most common one) Will appear by default.
Definition: Log.h:266
camitk::ImageComponent::initImageProperties
void initImageProperties()
Update the Properties displayed in the PropertyExplorer It should be called by setImageData to update...
Definition: ImageComponent.cpp:187
camitk::Component::setParentFrame
void setParentFrame(InterfaceFrame *frame, bool keepTransform=true) override
Set the parent frame and update or not its transform during the parent transition.
Definition: sdk/libraries/core/component/Component.cpp:792
camitk::ImageComponent::initLookupTable
void initLookupTable()
Definition: ImageComponent.cpp:412
camitk::ImageComponent::rotationMatrix
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
camitk::ImageComponent::coronalSlices
SingleImageComponent * coronalSlices
the coronal slices representation (all intelligence is delegated to a Slice class instance)
Definition: ImageComponent.h:303
camitk::Component::childrenComponent
ComponentList childrenComponent
The explorer sub items.
Definition: sdk/libraries/core/component/Component.h:836
camitk::Component::setOriginalVolume
setOriginalVolume
Definition: sdk/libraries/core/component/Component.h:724
SingleImageComponent.h
CamiTKAPI.h
if
if(${CMAKE_VERSION} VERSION_GREATER "3.3" OR ${CMAKE_VERSION} VERSION_EQUAL "3.3") option(CAMITK_INCLUDE_WHAT_YOU_USE "Enable the header analysis on you code
camitk::ImageComponent::getActualMaxColor
double getActualMaxColor() const
Max gray level found in the image given its data type.
Definition: ImageComponent.cpp:727
camitk::Component::setActorColor
setActorColor
Definition: sdk/libraries/core/component/Component.h:690
camitk::Component::removeChild
void removeChild(InterfaceNode *) override
remove a child node.
Definition: sdk/libraries/core/component/Component.cpp:550
camitk::ImageComponent::getMaxColor
double getMaxColor() const
Max possible gray level of the image given its data type.
Definition: ImageComponent.cpp:710
camitk::ImageComponent::getLastPointPickedImageCoords
void getLastPointPickedImageCoords(double *x, double *y, double *z)
Get the last point picked using CTRL + LEFT/RIGHT CLICK in image real coordinates (this takes into ac...
Definition: ImageComponent.cpp:783
camitk::Component::setIndexOfPropertyExplorerTab
void setIndexOfPropertyExplorerTab(unsigned int index) override final
Set the index of the tab in the ProperlyExplorer to select for display.
Definition: sdk/libraries/core/component/Component.h:492
camitk::ImageComponent::getActualMinColor
double getActualMinColor() const
Min gray level found in the image given its data type.
Definition: ImageComponent.cpp:722
camitk::ArbitrarySingleImageComponent
This Component manages the specific case of arbitrary orientation of a sub-component of the image com...
Definition: ArbitrarySingleImageComponent.h:88
camitk::ImageComponent::getNumberOfColors
int getNumberOfColors() const override
Number of colors: number of possible gray levels in the image computed from the min and the max of th...
Definition: ImageComponent.cpp:697
camitk::ImageComponent::axialSlices
SingleImageComponent * axialSlices
the axial slices representation (all intelligence is delegated to a Slice class instance)
Definition: ImageComponent.h:297
camitk::ImageComponent::getInitialOrientation
ImageOrientationHelper::PossibleImageOrientations getInitialOrientation() const
Get the initial image orientation.
Definition: ImageComponent.h:135
camitk::ImageComponent::initialOrientation
ImageOrientationHelper::PossibleImageOrientations initialOrientation
Initial image orientation.
Definition: ImageComponent.h:328
camitk::ImageComponent::getImageDataWithFrameTransform
vtkSmartPointer< vtkImageData > getImageDataWithFrameTransform()
Compute a copy of the original image data on which the frame transform has been applied.
Definition: ImageComponent.cpp:352
camitk::Slice::AXIAL
@ AXIAL
Definition: Slice.h:221
camitk::ImageComponent
The manager of the Image Volume data. An image volume data has no concrete 3D representation,...
Definition: ImageComponent.h:77
camitk::ImageComponent::updateImageComponents
void updateImageComponents()
update the image components vtkImageData of all the available SingleImageComponent
Definition: ImageComponent.cpp:637
camitk::ImageComponent::setSingleImageComponents
void setSingleImageComponents(SingleImageComponent *axialSlices, SingleImageComponent *sagittalSlices, SingleImageComponent *coronalSlices, ArbitrarySingleImageComponent *arbitrarySlices)
Set all single images.
Definition: ImageComponent.cpp:492
camitk::ImageComponent::getImageName
QString getImageName() const
getter/setter for the property
Definition: ImageComponent.cpp:530
camitk::ImageComponent::setLut
virtual void setLut(vtkSmartPointer< vtkWindowLevelLookupTable > lookupTable)
Update the lookup table of the image viewer (see InterfaceBitMap).
Definition: ImageComponent.cpp:737
camitk::ImageComponent::getLastPixelPicked
void getLastPixelPicked(int *x, int *y, int *z)
Get the last pixel picked using CTRL + LEFT/RIGHT CLICK in voxel index (i, j, k) indicates the voxel ...
Definition: ImageComponent.cpp:773
camitk::ImageComponent::lut
vtkSmartPointer< vtkWindowLevelLookupTable > lut
the current lookup table
Definition: ImageComponent.h:313
camitk::ImageComponent::~ImageComponent
~ImageComponent() override
Destructor.
Definition: ImageComponent.cpp:114
camitk::ImageComponent::getAxialSlices
SingleImageComponent * getAxialSlices()
Returns the axial slice.
Definition: ImageComponent.cpp:472
camitk::ImageComponent::getPropertyWidgetAt
QWidget * getPropertyWidgetAt(unsigned int i) override
get the property widget (to view as tabs in the property explorer): the default property widget and t...
Definition: ImageComponent.cpp:847
camitk::Property
This class describes a property that can be used in components and actions or any class that needs to...
Definition: Property.h:303
Log.h
MeshComponent.h
camitk::SingleImageComponent
This Component manages sub-component of the image component seen as a single orientation only (axial ...
Definition: SingleImageComponent.h:61
camitk::ImageComponent::getLut
virtual vtkSmartPointer< vtkWindowLevelLookupTable > getLut()
get the current lookup table
Definition: ImageComponent.cpp:742
camitk::Viewer::getName
QString getName() const
get the name of the viewer
Definition: Viewer.h:200
camitk::ImageComponent::selectionView
QTableView * selectionView
Tab displaying data selected point in the property explorer.
Definition: ImageComponent.h:322
ArbitrarySingleImageComponent.h
camitk::ImageComponent::updateProperty
void updateProperty(QString, QVariant) override
Definition: ImageComponent.cpp:231
Property.h
camitk::Component::setSelected
virtual void setSelected(const bool b, const bool recursive=true)
Update the selection flag.
Definition: sdk/libraries/core/component/Component.cpp:445
camitk::ImageComponent::getRotationMatrix
const vtkSmartPointer< vtkMatrix4x4 > getRotationMatrix()
Definition: ImageComponent.h:227
camitk::ImageComponent::initRepresentation
void initRepresentation() override
the concrete building of the 3D objects (Slice/Geometry): none in this case!
Definition: ImageComponent.h:271
camitk::Component::getName
QString getName() const override
get the name to be displayed
Definition: sdk/libraries/core/component/Component.h:907
Frame.h
camitk::ImageComponent::getSagittalSlices
SingleImageComponent * getSagittalSlices()
Returns the sagittal slice.
Definition: ImageComponent.cpp:482
camitk::ImageComponent::ImageComponent
ImageComponent(const QString &file)
constructor This method may throw an AbortException if a problem occurs.
Definition: ImageComponent.cpp:102
camitk::Component::getTransformFromWorld
const vtkSmartPointer< vtkTransform > getTransformFromWorld() const override
Transforms accessors / Modifyers.
Definition: sdk/libraries/core/component/Component.cpp:814
camitk::Slice::CORONAL
@ CORONAL
Definition: Slice.h:222
camitk::ImageOrientationHelper::RAI
@ RAI
Direct Orientations X: Right to Left, Y: Anterior to Posterior, Z: Inferior to Superiror.
Definition: ImageOrientationHelper.h:55
camitk::ImageComponent::getBoundingBox
vtkSmartPointer< vtkPolyData > getBoundingBox()
internal method used to put a mesh in volumeRenderingChild and accessoiry display the bounding box
Definition: ImageComponent.cpp:808
camitk::ImageComponent::refresh
void refresh() override
force refresh of all interactive viewers that are displaying sub-components as ImageComponent is not ...
Definition: ImageComponent.cpp:801
camitk::ImageComponent::getMinColor
double getMinColor() const
Min possible gray level of the image given its data type.
Definition: ImageComponent.cpp:705
camitk::Component::setVisibility
virtual void setVisibility(QString, bool)
set the visibility inside the viewer of the given name (the viewer needs to be a registered viewer)
Definition: sdk/libraries/core/component/Component.cpp:224
camitk::Component::setSlice
vtkSmartPointer< vtkImageData > vtkSmartPointer< vtkImageActor > vtkSmartPointer< vtkActor > updatePickPlane setSlice
Definition: sdk/libraries/core/component/Component.h:740
camitk::ImageComponent::setSelected
void setSelected(const bool b, const bool recursive=false) override
set selected will select all the Image components (axial, sagittal and coronal).
Definition: ImageComponent.cpp:747
camitk::ImageComponent::currentPixelPicked
double currentPixelPicked[3]
Store the last pixel selected, in original slices ref.
Definition: ImageComponent.h:316
camitk::Component::getChildren
const ComponentList & getChildren() override
get the list of the InterfaceNode children (sub items in the hierarchy)
Definition: sdk/libraries/core/component/Component.h:902
Component
A component is something that composed something and could also be a part of something.
Definition: modeling/libraries/pml/Component.h:48
camitk::ImageComponent::sagittalSlices
SingleImageComponent * sagittalSlices
the sagittal slices representation (all intelligence is delegated to a Slice class instance)
Definition: ImageComponent.h:300
camitk::Viewer
Viewer is an abstract class that is the base class for all viewers.
Definition: Viewer.h:180
camitk::ImageComponent::getImageData
vtkSmartPointer< vtkImageData > getImageData() const override
get the image volume managed by this Component
Definition: ImageComponent.h:123
ImageOrientationHelper.h
camitk::Slice::SAGITTAL
@ SAGITTAL
Definition: Slice.h:223
camitk::SingleImageComponent::singleImageSelected
virtual void singleImageSelected(const bool)
new method used to call the Component set selected
Definition: SingleImageComponent.cpp:92
Viewer.h
camitk::ImageComponent::update3DViewer
void update3DViewer()
Update visibility in the 3D viewer.
Definition: ImageComponent.cpp:561
camitk::InterfaceGeometry::Wireframe
@ Wireframe
the wireframe is visible
Definition: InterfaceGeometry.h:68
camitk::Property::setReadOnly
void setReadOnly(bool)
set this property as read-only
Definition: Property.cpp:82
camitk::ImageComponent::getNumberOfPropertyWidget
unsigned int getNumberOfPropertyWidget() override
return number of tabs in property explorer: there is more than one widget
Definition: ImageComponent.cpp:842
camitk::ImageComponent::getVolumeRenderingChild
MeshComponent * getVolumeRenderingChild()
Returns the MeshComponent which will contain the volume rendering actor.
Definition: ImageComponent.cpp:519
camitk::Component::setName
void setName(const QString &) override
set the name to be displayed
Definition: sdk/libraries/core/component/Component.h:932
camitk::MeshComponent
Basic component to manage any kind of mesh.
Definition: MeshComponent.h:53
camitk::Component::updateProperty
void updateProperty(QString name, QVariant value) override
update property: if you this method, do not forget to call the superclass method for the property not...
Definition: sdk/libraries/core/component/Component.cpp:506
camitk::refresh
void refresh()
refresh the display
camitk::ImageComponent::originalImageData
vtkSmartPointer< vtkImageData > originalImageData
the core Image Volume that is managed here
Definition: ImageComponent.h:294
camitk::ImageComponent::setImageData
void setImageData(vtkSmartPointer< vtkImageData > anImageData, bool copy, ImageOrientationHelper::PossibleImageOrientations initialOrientation=ImageOrientationHelper::RAI, vtkSmartPointer< vtkMatrix4x4 > initialTransformMatrix=nullptr)
Set the image data of the volumic images with the given orientation options.
Definition: ImageComponent.cpp:251
camitk::ImageComponent::volumeRenderingChild
MeshComponent * volumeRenderingChild
When an action computes volume rendering for an image, it stores the corresponding actor as a prop of...
Definition: ImageComponent.h:310
camitk::InterfaceFrame::setTransform
virtual void setTransform(vtkSmartPointer< vtkTransform > transform)=0
Set the current input frame position (according to its parent Frame)
camitk::ImageComponent::getLastPointPickedWorldCoords
void getLastPointPickedWorldCoords(double *x, double *y, double *z)
Get Get the last point picked using CTRL + LEFT/RIGHT CLICK in world coordinates This takes into acco...
Definition: ImageComponent.cpp:790
camitk::ImageComponent::getArbitrarySlices
ArbitrarySingleImageComponent * getArbitrarySlices()
Returns the arbitrary slice.
Definition: ImageComponent.cpp:487
camitk::ImageComponent::getActualNumberOfColors
int getActualNumberOfColors() const
Actual Number of colors: difference betweent the maximun and the minimum gray levels found in the ima...
Definition: ImageComponent.cpp:716
camitk::Component::refresh
virtual void refresh()
refresh all the viewer that are currently displaying this Component At the end the InterfaceNode modi...
Definition: sdk/libraries/core/component/Component.cpp:286
camitk::ImageComponent::init
void init()
initialize pointers to NULL and other attributes
Definition: ImageComponent.cpp:128
camitk::Component::addProperty
bool addProperty(Property *) override
Add a new CamiTK property to the component.
Definition: sdk/libraries/core/component/Component.cpp:517
camitk::ImageComponent::getNumberOfSlices
int getNumberOfSlices() const override
Number of axial slices (i.e.
Definition: ImageComponent.cpp:732
camitk::ImageComponent::initialImageDataTransform
vtkSmartPointer< vtkTransform > initialImageDataTransform
The initial transform to the vtkImageData.
Definition: ImageComponent.h:333
camitk::ImageComponent::buildImageComponents
void buildImageComponents()
build the SingleImageComponent (one for each image plane);
Definition: ImageComponent.cpp:580
camitk::ImageComponent::initialFrameTransform
vtkSmartPointer< vtkTransform > initialFrameTransform
The initial frame of the image at opening.
Definition: ImageComponent.h:339
camitk::ImageOrientationHelper::getOrientationAsQString
static QString getOrientationAsQString(PossibleImageOrientations orientation)
Returns the Possible Medical Image orientation in QString format from a PossibleImageOrientation enum...
Definition: ImageOrientationHelper.cpp:61
camitk::ImageOrientationHelper::PossibleImageOrientations
PossibleImageOrientations
For each axis (x, y or z), 6 possibilities:
Definition: ImageOrientationHelper.h:52
camitk::ImageComponent::model
QStandardItemModel * model
Model to display data.
Definition: ImageComponent.h:325
ImageComponent.h
camitk::Component::getNumberOfSlices
vtkSmartPointer< vtkImageData > vtkSmartPointer< vtkImageActor > vtkSmartPointer< vtkActor > updatePickPlane double double vtkSmartPointer< vtkTransform > int getNumberOfSlices() const override
see Component.cpp
Definition: sdk/libraries/core/component/Component.cpp:739
camitk::ImageComponent::setImageName
void setImageName(const QString &)
Definition: ImageComponent.cpp:524
CAMITK_API_DEPRECATED
#define CAMITK_API_DEPRECATED(X)
Definition: CamiTKAPI.h:94
camitk::ImageOrientationHelper::getTransformToRAI
static vtkSmartPointer< vtkMatrix4x4 > getTransformToRAI(PossibleImageOrientations orientation, double dimX, double dimY, double dimZ)
Given a possible Dicom Image Orientation, this method returns the transform matrix to express the ima...
Definition: ImageOrientationHelper.cpp:216
camitk::ImageComponent::setVisibility
virtual void setVisibility(QString, bool) override
set the visibility inside the viewer of the given name (override required to manage the specific case...
Definition: ImageComponent.cpp:535
camitk::Component
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition: sdk/libraries/core/component/Component.h:302
CAMITK_API
#define CAMITK_API
Definition: CamiTKAPI.h:49
camitk
Definition: Action.cpp:35
camitk::Component::getFrame
InterfaceFrame * getFrame()
get the associated frame
Definition: sdk/libraries/core/component/Component.h:917