]> Creatis software - creaMaracasVisu.git/blob - lib/GUI/Qt/Viewers/qtvtkviewer.cpp
changes in qt for volume rendering with gpu support, if you are working with volume...
[creaMaracasVisu.git] / lib / GUI / Qt / Viewers / qtvtkviewer.cpp
1 #include "qtvtkviewer.h"
2
3 #include "vtkImageMapToColors.h"
4
5 QtVTKViewer::QtVTKViewer(QWidget* parent)
6     : QVTKWidget(parent)
7 {
8
9
10     this->GetRenderWindow()->AddRenderer(vtkRenderer::New());
11     this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->SetBackground(1,1,1);
12
13     SuperImagePlaneWidget::initialize(this->GetRenderWindow()->GetInteractor());
14
15     this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->ResetCamera();    
16
17
18     _rayorigin[0] = 0;
19     _rayorigin[1] = 0;
20     _rayorigin[2] = 0;
21     _rayorigin[3] = 0;
22
23     _imageindex[0] = 0;
24     _imageindex[1] = 0;
25     _imageindex[2] = 0;
26
27 }
28
29 void QtVTKViewer::mouseMoveEvent(QMouseEvent* event){
30     int x=0, y=0;
31
32     QVTKWidget::mouseMoveEvent(event);
33
34     x = event->pos().x();
35     y = this->size().height() - event->pos().y();
36
37 #ifdef debug
38     std::cout<<"X= "<<x<<" Y= "<<y<<std::endl;
39 #endif
40
41
42     this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->SetDisplayPoint(x, y, 0);
43     this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->DisplayToWorld();
44     this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetWorldPoint(_rayorigin);
45 #ifdef debug
46     std::cout<<"X= "<<x<<" Y= "<<y<<std::endl;
47     std::cout<<"X= "<<_rayorigin[0]<<" Y= "<<_rayorigin[1]<<" Z= "<<_rayorigin[2]<<" R= "<<_rayorigin[3]<<std::endl;
48 #endif
49
50
51
52
53
54 }
55
56 void QtVTKViewer::mousePressEvent(QMouseEvent* event){
57     QVTKWidget::mousePressEvent(event);
58     vtkImagePlaneWidget * temp = 0;
59     if(_xwidget->GetCursorDataStatus()==1){
60         temp = _xwidget;
61     }else if(_ywidget->GetCursorDataStatus()==1){
62         temp = _ywidget;
63     }else if(_zwidget->GetCursorDataStatus()==1){
64         temp = _zwidget;
65     }
66
67     if(temp){
68         _imageindex[0]=temp->GetCurrentCursorPosition()[0];
69         _imageindex[1]=temp->GetCurrentCursorPosition()[1];
70         _imageindex[2]=temp->GetCurrentCursorPosition()[2];
71 #ifdef debug
72          std::cout<<"X= "<<_imageindex[0]<<" Y= "<<_imageindex[1]<<" Z= "<<_imageindex[2]<<std::endl;
73 #endif
74     }
75 }
76
77 void QtVTKViewer::SetOutputFormatToRGBA(){
78     _xwidget->GetColorMap()->SetOutputFormatToRGBA();
79     _ywidget->GetColorMap()->SetOutputFormatToRGBA();
80     _zwidget->GetColorMap()->SetOutputFormatToRGBA();
81 }