-
Notifications
You must be signed in to change notification settings - Fork 2
/
QVTKImageWidget.h
executable file
·246 lines (175 loc) · 6.18 KB
/
QVTKImageWidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
//
// QVTKImageWidget.h
// US_Probe_Calibration
//
// Created by Zian Fanti on 01/12/11.
// Copyright (c) 2011 __UNAM__. All rights reserved.
//
#ifndef US_Probe_Calibration_QVTKImageWidget_h
#define US_Probe_Calibration_QVTKImageWidget_h
#include <QtGui>
#include <QWidget>
#include <QVTKWidget.h>
#include <itkImage.h>
#include <itkRGBPixel.h>
#include <vtkSmartPointer.h>
#include <vtkImageData.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkCamera.h>
#include <vtkImageActor.h>
#include <vtkCommand.h>
#include <vtkImageViewer2.h>
#include <vtkCornerAnnotation.h>
typedef itk::RGBPixel< unsigned char > RGBPixelType;
typedef itk::Image< unsigned char > ImageType;
typedef itk::Image< RGBPixelType, 2> RGBImageType;
class QVTKImageWidget : public QWidget {
Q_OBJECT
public:
/**
* Constructor for this ImageWidget
*/
QVTKImageWidget(QWidget *parent = 0);
/**
* Destructor
*/
virtual ~QVTKImageWidget();
/**
* Sets and display an image from a given image path
*/
void setAndDisplayImage(QString imageFilename);
/**
* \brief Sets and display the given vtkImageData
* \param[in] a vtkImageData to set and display
*/
void setAndDisplayImage(vtkSmartPointer<vtkImageData> image);
/**
* \brief Set and display multiple images from a given images filenames. Display
* the image corresponding to the first element on the filenmaes list.
* \param[in] a QStringList that contain the filename of each image
*/
void setAndDisplayMultipleImages(QStringList filenames);
/**
* \brief Set and display multiple images from a given vtkImageData Array.
* \param[in] a std::vector of vtkImageData
*/
void setAndDisplayMultipleImages(std::vector< vtkSmartPointer<vtkImageData> > imageStack);
/**
* \brief display an image stored in this imageStack.
* \param[in] the index in the stack position of the image
*/
void displaySelectedImage(int idx);
/***************************
* get and set methods
***************************/
QString getPixelType();
QString getImageType();
QString getNumOfDimesions();
/** \brief return this image stack */
std::vector< vtkSmartPointer<vtkImageData> > getImageStack();
/**
* returns an array with the width and height of the image
*/
int* getImageSize();
/**
* returns this image width
*/
int getImageWidth();
/**
* returns this image heigth
*/
int getImageHeigth();
/**
* \brief Return the mouse x coordinate position when mouse left button is pressed
* \param[out] int x position
*/
int getXPicked();
/**
* \brief Return the mouse y coordinate position when mouse left button is pressed
* \param[out] int y position
*/
int getYPicked();
/**
* \brief Set the mouse x coordinate position when mouse left button is pressed
* \param[out] int x position
*/
void setXPicked(int xPosition);
/**
* \brief Set the mouse y coordinate position when mouse left button is pressed
* \param[out] int y position
*/
void setYPicked(int yPosition);
/**
* \brief Return this widget image viewer
* \param[out] imageViewer vtkImageViewer2 target 2D image.
*/
vtkSmartPointer<vtkImageViewer2> getImageViewer();
/**
* \brief Return this qvtkWidget
* \param[out] the QVTKWidget
*/
QVTKWidget* getQVTKWidget();
/** \brief If an image stack is loaded, then return the index in the image
* stack of displayed image
*/
int getImageDisplayedIndex();
/** \brief Flag to know if it's displayed an image stack */
bool isImageStackLoaded;
private:
/**
* The QVTKWidget for display and interact with the images
*/
QVTKWidget* qvtkWidget;
/** The grayscale image displayed in this widget */
ImageType::Pointer itkImage;
/** The RGB image displayed for this widget */
RGBImageType::Pointer rgbItkImage;
/** The VTK image to display i this window */
vtkSmartPointer <vtkImageData> vtkImage;
/** \brief A vtkImageData Vector for keep the image references when load an
* image stack.
*/
std::vector< vtkSmartPointer<vtkImageData> > imageStack;
/** The type of the image pixels */
std::string pixelType;
/** the number of scalar components in the image 1 => grayscale, 3 => rgb */
int imageType;
/** The number of the image dimensions */
size_t numDimensions;
/** Width of the image */
int imageWidth;
/** Heigth of the image */
int imageHeight;
/** current x coordinate of mouse position over the image */
int xPosition;
/** current y coordinate of mouse position over the image */
int yPosition;
/** The x coordinate of the picked position over the image */
int xPicked;
/** current y coordinate of picked position over the image */
int yPicked;
/** If image stack is displayed this sets a reference to current image displayed */
int imageDisplayedIndex;
/**
* Set the needed image properties (pixelType, imageType, num of dimensions)
*/
void setImageProperties(bool verbose);
/**
* Display the given vtkImage
*/
void displayImage(vtkImageData *image);
/* -------- necesary vtk objects to display an image ------ */
/** the image viewer for display images */
vtkSmartPointer<vtkImageViewer2> imageViewer;
/** \brief Object for display information in the corners of the vtkImageViewer2 */
vtkSmartPointer<vtkCornerAnnotation> cornerAnnotation;
/** the actor for the image */
// vtkSmartPointer<vtkImageActor> actor;
/** the camera to include into imageViewer */
// vtkSmartPointer<vtkCamera> camera;
// vtkSmartPointer<vtkRenderer> renderer;
// vtkSmartPointer<vtkRenderWindow> renderWindow;
// vtkSmartPointer<vtkRenderWindowInteractor> interactor;
};
#endif