]> Creatis software - openheart.git/blob - Applications/OpenHeartGui.h
commit all the files for the first time
[openheart.git] / Applications / OpenHeartGui.h
1 /**
2 * Progam made by Olivier Bernard, associate professor
3 * at Institut National des Sciences Appliquees (INSA) Lyon,
4 * CREATIS Laboratory,
5 * 69621 Villeurbanne, France,
6 * 07th of May 2014
7 */
8
9 #ifndef _OpenHeartGUI_h
10 #define _OpenHeartGUI_h
11
12 #include <vtkImageData.h>
13 #include <vtkDataSet.h>
14 #include <vtkLookupTable.h>
15 #include <vtkPointWidget.h>
16 #include <vtkImagePlaneWidget.h>
17 #include <vtkPlane.h>
18 #include <vtkCellPicker.h>
19 #include <vtkRenderWindowInteractor.h>
20 #include <vtkProperty.h>
21 #include <vtkCommand.h>
22 #include <vtkActor2D.h>
23 #include <vtkTextProperty.h>
24 #include <vtkEventQtSlotConnect.h>
25 #include <vtkTextMapper.h>
26 #include <vtkCutter.h>
27 #include <vtkContextView.h>
28 #include <vtkTable.h>
29 #include <vtkOrientationMarkerWidget.h>
30 #include <vtkMatrix4x4.h>
31 #include <list>
32
33 #include "ui_OpenHeartGui.h"
34 #include <QMainWindow>
35 #include <QtGui>
36 #include <QTimer>
37
38
39 using namespace std;
40
41 class vtkRenderer;
42 class vtkEventQtSlotConnect;
43 class vtkObject;
44 class vtkCommand;
45
46
47 struct RendererProperties
48 {
49     vtkSmartPointer<vtkLookupTable> lut;
50     vtkSmartPointer<vtkImagePlaneWidget> xIPW, yIPW, zIPW;
51     vtkSmartPointer<vtkImagePlaneWidget> xyIPW,xzIPW,yzIPW;
52     double *position;
53     vtkSmartPointer<vtkActor2D> TextActorPixel;
54     vtkSmartPointer<vtkTextMapper> TextMapperPixel;
55     vtkSmartPointer<vtkActor2D> TextActorMM;
56     vtkSmartPointer<vtkTextMapper> TextMapperMM;
57     vtkSmartPointer<vtkActor2D> TextActorValue;
58     vtkSmartPointer<vtkTextMapper> TextMapperValue;
59     vtkSmartPointer<vtkActor2D> TextActorSlice;
60     vtkSmartPointer<vtkTextMapper> TextMapperSlice;
61     vtkSmartPointer<vtkActor2D> TextActorNumFrame;
62     vtkSmartPointer<vtkTextMapper> TextMapperNumFrame;
63     vtkSmartPointer<vtkActor2D> TextActorResolution;
64     vtkSmartPointer<vtkTextMapper> TextMapperResolution;
65     vtkSmartPointer<vtkActor> MeshActor;
66     vtkSmartPointer<vtkActor> xCutActor, yCutActor, zCutActor;
67     vtkSmartPointer<vtkActor> BasalPointActor;
68     vtkSmartPointer<vtkActor> ApexPointActor;
69     vtkSmartPointer<vtkActor> LongAxisActor;
70     vtkSmartPointer<vtkActor> BoundingBoxActor;
71     list<vtkDataSetMapper*> StackMapperList;
72     list<vtkDataSetMapper*>::iterator itStackMapperList;
73     list<vtkCutter*> StackMapXCutter;
74     list<vtkCutter*>::iterator itStackMapXCutter;
75     list<vtkCutter*> StackMapYCutter;
76     list<vtkCutter*>::iterator itStackMapYCutter;
77     list<vtkCutter*> StackMapZCutter;
78     list<vtkCutter*>::iterator itStackMapZCutter;
79 };
80
81
82 class OpenHeartGui : public QMainWindow, public Ui::OpenHeartGui
83 {
84     Q_OBJECT
85     public:
86
87         OpenHeartGui();
88         ~OpenHeartGui();
89
90         vtkSmartPointer<vtkCellPicker> GetPicker() { return this->Picker; }
91         vtkSmartPointer<vtkCellPicker> GetPickerXY() { return this->PickerXY; }
92         vtkSmartPointer<vtkCellPicker> GetPickerXZ() { return this->PickerXZ; }
93         vtkSmartPointer<vtkCellPicker> GetPickerYZ() { return this->PickerYZ; }
94         RendererProperties *GetRendererProperties() { return this->Properties; }
95         vtkRenderWindow *GetRenderWindow() { return this->qVTK->GetRenderWindow(); }
96         vtkRenderWindow *GetRenderWindowXY() { return this->qVTKXY->GetRenderWindow(); }
97         vtkRenderWindow *GetRenderWindowXZ() { return this->qVTKXZ->GetRenderWindow(); }
98         vtkRenderWindow *GetRenderWindowYZ() { return this->qVTKYZ->GetRenderWindow(); }
99         vtkSmartPointer<vtkRenderer> GetMeshRenderer() { return this->Ren; }
100         vtkSmartPointer<vtkRenderer> GetMainRenderer() { return this->Ren; }
101         vtkSmartPointer<vtkRenderer> GetXYRenderer() { return this->RenXY; }
102         vtkSmartPointer<vtkRenderer> GetXZRenderer() { return this->RenXZ; }
103         vtkSmartPointer<vtkRenderer> GetYZRenderer() { return this->RenYZ; }
104
105         vtkImageData *GetCurrentImageData() { return this->ImageData; }
106         int *GetDimensions() { return this->Dims; }
107         void InterpolationManagement();
108         void CreateFromSequenceDataPointer(std::string inputFilename);
109         void UpdateForwardViewers();
110         void UpdateBackwardViewers();
111         int GetCurrentFrame() { return this->CurrentFrame; }
112         int GetNumberOfFrames() { return this->NumberOfVolumes; }
113         void SetFlagLoopEndToBegin( int val ) { this->FlagLoopEndToBegin = val; }
114         void SetFlagLoopBeginToEnd( int val ) { this->FlagLoopBeginToEnd = val; }
115         void DisplayMainAxisManagement();
116         void DisplayMeshManagement();
117         void DisplayModeManagement();
118         void HidePlanModeManagement();
119         void UpdateCoords(double *pos);
120         int GetSelectedButton() { return ViewButton; }
121         int GetFlagDisplayText() { return FlagDisplayText; }
122         void ComputePointBeforeRotation(double *pt);
123
124     public slots:
125
126         void slotMeshAlpha(int);
127         void slotRefreshViewer(int);
128         void slotTabChange(int);
129         void slotPlay();
130         void slotXYView();
131         void slotXZView();
132         void slotYZView();
133         void slot3DView();
134         void slotMeshView();
135         void slotMeshRepresentation();
136         void slotMeshColor();
137         void slotMeshCutter();
138         void slotTimerEvent();
139         void slotBasalPoint();
140         void slotApexPoint();
141         void slotReslice();
142         void slotUpdateCoords(vtkObject*);
143
144     protected:
145
146         int Dims[3];
147         int PreviousFrame;
148         int CurrentFrame;
149         int NumberOfVolumes;
150         double BasalPoint[3];
151         double ApexPoint[3];
152         vtkSmartPointer<vtkRenderer> Ren;
153         vtkSmartPointer<vtkRenderer> RenXY;
154         vtkSmartPointer<vtkRenderer> RenXZ;
155         vtkSmartPointer<vtkRenderer> RenYZ;
156         vtkRenderer* RenChart;
157         QTimer *Timer;
158         vtkEventQtSlotConnect* Connections;
159
160         list<vtkImageData*> StackVolume;
161         list<vtkImageData*>::iterator itStackVolume;
162         list<vtkPolyData*> StackMesh;
163         list<vtkPolyData*>::iterator itStackMesh;
164         vtkPolyData * Mesh;
165         vtkImageData *ImageData;
166         vtkSmartPointer <vtkOrientationMarkerWidget> OrientationWidget;
167         RendererProperties *Properties;
168         vtkSmartPointer<vtkCellPicker> Picker;
169         vtkSmartPointer<vtkCellPicker> PickerXY;
170         vtkSmartPointer<vtkCellPicker> PickerXZ;
171         vtkSmartPointer<vtkCellPicker> PickerYZ;
172         vtkSmartPointer<vtkRenderWindowInteractor> Interactor;
173         vtkSmartPointer<vtkRenderWindowInteractor> InteractorXY;
174         vtkSmartPointer<vtkRenderWindowInteractor> InteractorXZ;
175         vtkSmartPointer<vtkRenderWindowInteractor> InteractorYZ;
176         vtkSmartPointer<vtkContextView> ViewChart;
177         vtkSmartPointer<vtkTable> TableChart;
178         vtkSmartPointer<vtkMatrix4x4> RotationMatrix;
179         vtkSmartPointer<vtkTransform> TransformViewOrientation;        
180         vtkSmartPointer<vtkMatrix4x4> RotationMatrixInv;
181         vtkSmartPointer<vtkTransform> TransformViewOrientationInv;
182
183         int FlagInterpolation;
184         int FlagDisplayMesh;
185         int FlagDisplayMeshContourX;
186         int FlagDisplayMeshContourY;
187         int FlagDisplayMeshContourZ;
188         int FlagLoopEndToBegin;
189         int FlagLoopBeginToEnd;
190         int FlagPlay;
191         int FlagDisplayText;
192         int FlagHidePlan;
193         int FlagDisplayMeshContours;
194         int FlagLongAxis;
195         int FlagDisplayApexPoint;
196         int FlagDisplayBasalPoint;
197         int FlagDisplayLongAxis;
198         int FlagReslice;
199
200         int ViewButton;
201         int MeshRepresentation;
202         int MeshColor;
203         double ZoomLabel;
204         double ZoomMain;
205
206         void InstantiateQtVtkRenderers();
207         void InitPickers();
208         void InitWidgets();
209         void InitProperties();
210         void InitOrientationAxes();
211         void InitPlaneWidget();
212         void InitTexts();
213         void InitChar();
214         void SetCustomInteractorStyle();
215         vtkActor2D* AddFixedText(const char *text, float x, float y, float R,float G, float B, int Size);
216         void ForceXZView();
217         void UpdateClinicalIndices();
218         void SetInterfaceColors();
219         void CreateLongAxisActor();
220         void SetLongAxisView();
221         void ResetReslicing();
222         void ComputeRotationMatrix();
223         void UpdateViewer(int view, double zoom, vtkRenderer *ren);
224
225
226         /// overloaded resize handler
227         virtual void resizeEvent(QResizeEvent* event);
228
229 };
230
231 #endif
232