1 #include "qtvtkviewer.h"
3 #include "vtkImageMapToColors.h"
5 QtVTKViewer::QtVTKViewer(QWidget* parent)
10 vtkRenderer* renderer = vtkRenderer::New();
11 this->GetRenderWindow()->AddRenderer(renderer);
12 this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->SetBackground(1,1,1);
14 SuperImagePlaneWidget::initialize(this->GetRenderWindow()->GetInteractor());
16 this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->ResetCamera();
30 void QtVTKViewer::mouseMoveEvent(QMouseEvent* event){
33 QVTKWidget::mouseMoveEvent(event);
36 y = this->size().height() - event->pos().y();
39 std::cout<<"X= "<<x<<" Y= "<<y<<std::endl;
43 this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->SetDisplayPoint(x, y, 0);
44 this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->DisplayToWorld();
45 this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetWorldPoint(_rayorigin);
47 std::cout<<"X= "<<x<<" Y= "<<y<<std::endl;
48 std::cout<<"X= "<<_rayorigin[0]<<" Y= "<<_rayorigin[1]<<" Z= "<<_rayorigin[2]<<" R= "<<_rayorigin[3]<<std::endl;
57 void QtVTKViewer::mousePressEvent(QMouseEvent* event){
58 QVTKWidget::mousePressEvent(event);
59 vtkImagePlaneWidget * temp = 0;
60 if(_xwidget->GetCursorDataStatus()==1){
62 }else if(_ywidget->GetCursorDataStatus()==1){
64 }else if(_zwidget->GetCursorDataStatus()==1){
69 _imageindex[0]=temp->GetCurrentCursorPosition()[0];
70 _imageindex[1]=temp->GetCurrentCursorPosition()[1];
71 _imageindex[2]=temp->GetCurrentCursorPosition()[2];
73 std::cout<<"X= "<<_imageindex[0]<<" Y= "<<_imageindex[1]<<" Z= "<<_imageindex[2]<<std::endl;
78 void QtVTKViewer::SetOutputFormatToRGBA(){
79 _xwidget->GetColorMap()->SetOutputFormatToRGBA();
80 _ywidget->GetColorMap()->SetOutputFormatToRGBA();
81 _zwidget->GetColorMap()->SetOutputFormatToRGBA();