-
Notifications
You must be signed in to change notification settings - Fork 5
/
imageviewer2d.h
205 lines (170 loc) · 6.63 KB
/
imageviewer2d.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
/********************************************************************************
MIT License
Copyright (c) 2021 Jothy Selvaraj
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
********************************************************************************/
#ifndef IMAGEVIEWER2D_H
#define IMAGEVIEWER2D_H
#include <QVTKWidget.h>
#include <vtkActor.h>
#include <vtkAngleWidget.h>
#include <vtkAnnotatedCubeActor.h>
#include <vtkAutoInit.h>
#include <vtkAxesActor.h>
#include <vtkBoxWidget2.h>
#include <vtkColorSeries.h>
#include <vtkCornerAnnotation.h>
#include <vtkCursor2D.h>
#include <vtkDistanceWidget.h>
#include <vtkImageActor.h>
#include <vtkImageData.h>
#include <vtkImagePlaneWidget.h>
#include <vtkInteractorStyleImage.h>
#include <vtkInteractorStyleUser.h>
#include <vtkLineWidget2.h>
#include <vtkOrientationMarkerWidget.h>
#include <vtkPolyData.h>
#include <vtkRenderer.h>
#include <vtkScalarBarActor.h>
#include <vtkSmartPointer.h>
#include <vtkSphereSource.h>
#include <vtkTransform.h>
#include <vtkVolume.h>
#include <vtkinteractorstyleimagecustom.h>
#include <vtklinecallbackdose.h>
// Initialize vtk modules
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkRenderingFreeType);
VTK_MODULE_INIT(vtkInteractionStyle);
VTK_MODULE_INIT(vtkRenderingContextOpenGL2); // Needed for charts
#include <QAction>
#include <QActionGroup>
#include <QKeyEvent>
#include <QList>
#include <QString>
#include <QWheelEvent>
#include <QWidget>
#include <vector>
namespace Ui {
class ImageViewer2D;
}
class ImageViewer2D : public QWidget {
Q_OBJECT
public:
explicit ImageViewer2D(QWidget *parent = nullptr,
QActionGroup *contextMenus = 0);
~ImageViewer2D();
void SetImageData(vtkSmartPointer<vtkImageData> Img);
void SetRTDose(vtkSmartPointer<vtkImageData> Dose);
void SetInteractorStyleToRegistration();
// 0=Axial,1=Sagittal,2=Coronal
void SetSliceOrientation(int Orientation);
void SetUpView();
void ShowImageAndDose(double SliceLoc);
virtual void SliceImageAndDose(double SliceLoc);
void ShowCursor(double *Bounds);
void TriggerActionShowBeams();
void TriggerActionShowDose();
void TriggerActionShowContours();
void TriggerReset_WL_WW();
void DisplayROIs(double SliceLoc, int Orientation);
void DisplayBeams(double SliceLoc, int Orientation);
void DisplayPOIs(double SliceLoc, int Orientation);
void DisplayScalarBar();
void HideBeams();
void HideContours();
void HideDose();
void UpdateView();
void MoveToLocation(double loc);
void AdjustDoseRange(double min, double max);
void AdjustImageWLWW();
double SliceStep;
int SliceOrientation; // Axial by default
double WindowUp = 600, WindowLow = -400; // corresponds to WW=1000 & WL=100
double WindowWidth = 0.0, Windowlevel = 0.0;
double Bounds[6];
double DoseRange[2] = {0.0, 1.0};
double SliceLoc;
double (*ROIColors)[3]; // 50 ROIs supported as of now
int NumOfROIs;
bool BeamVisibility;
bool ContourVisibility;
bool DoseVisibility;
bool POIVisibility;
bool ScalarBarVisibility;
vtkSmartPointer<vtkImageData> ImageData;
vtkSmartPointer<vtkImageData> RTDose;
vtkSmartPointer<vtkCornerAnnotation> ImgPositionAnnotation;
vtkSmartPointer<vtkCornerAnnotation> WLWAnnotation;
vtkSmartPointer<vtkAnnotatedCubeActor> AnnotatedCube;
vtkSmartPointer<vtkInteractorStyleUser> InteractorImage2D;
vtkSmartPointer<vtkInteractorStyleImageCustom> InteractorImage;
vtkSmartPointer<vtkDistanceWidget> DistanceWidget;
vtkSmartPointer<vtkAngleWidget> AngleWidget;
vtkSmartPointer<vtkTransform> UserTransform;
vtkSmartPointer<vtkActor> CursorActor;
vtkSmartPointer<vtkActor> ROIActor;
vtkSmartPointer<vtkRenderer> ViewRenderer;
vtkSmartPointer<vtkImageActor> ImageSlice;
vtkSmartPointer<vtkImageActor> DoseSlice;
vtkSmartPointer<vtkActor> CutROI(vtkPolyData *mesh, double sliceNo, double R,
double G, double B, int Orientation);
vtkSmartPointer<vtkActorCollection> ContourActors;
vtkSmartPointer<vtkActorCollection> BeamActors;
vtkSmartPointer<vtkActorCollection> POIActors;
vtkSmartPointer<vtkColorSeries> BeamColors;
vtkSmartPointer<vtkAxesActor> IsocentreAxes;
vtkSmartPointer<vtkScalarBarActor> DoseScalarBar;
vtkSmartPointer<vtkLookupTable> DoseLUT;
vtkSmartPointer<vtkLineCallbackDose> lineCallbackDose;
vtkSmartPointer<vtkLineWidget2> lineWidget;
vtkSmartPointer<vtkScalarBarActor> ScalarBar;
vtkSmartPointer<vtkImageReslice> ImageReslice;
vtkSmartPointer<vtkAxesActor> Axes;
vtkSmartPointer<vtkActor> HumanActor;
vtkSmartPointer<vtkOrientationMarkerWidget> MarkerWidget;
vtkSmartPointer<vtkOrientationMarkerWidget> AxesWidget;
std::vector<vtkSmartPointer<vtkPolyData> > MeshList;
std::vector<vtkSmartPointer<vtkPolyData> > BeamList;
std::vector<vtkSmartPointer<vtkPolyData> > POIList;
QList<QString> ROINames;
QList<QString> ROITypes;
QList<int> ROINo;
private slots:
void on_toolButtonSagittal_clicked();
void on_toolButtonAxial_clicked();
void on_toolButtonCoronal_clicked();
void on_toolButtonScreenshot_clicked();
void on_verticalScrollBar_valueChanged(int value);
virtual void on_toolButtonContrast_clicked();
void on_actionMeasureDistance_triggered();
void on_actionMeasureAngle_triggered();
void on_actionReset_WL_WW_triggered();
void on_toolButtonProbe_clicked();
void on_toolButtonScalarBar_clicked();
void on_actionShowContours_triggered();
void on_actionShowDose_triggered();
void on_actionRubberBandZoom_triggered();
void on_actionShowBeams_triggered();
void on_actionShow_Image_Extent_triggered();
private:
Ui::ImageViewer2D *ui;
protected:
void keyPressEvent(QKeyEvent *event);
void wheelEvent(QWheelEvent *event);
};
#endif // IMAGEVIEWER2D_H