]> Creatis software - creaMaracasVisu.git/blob - lib/GUI/Qt/Viewers/qtvtkviewer.cpp
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / GUI / Qt / Viewers / qtvtkviewer.cpp
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 #include "qtvtkviewer.h"
27
28 #include "vtkImageMapToColors.h"
29
30 QtVTKViewer::QtVTKViewer(QWidget* parent)
31     : QVTKWidget(parent)
32 {
33
34
35     vtkRenderer* renderer = vtkRenderer::New();
36     this->GetRenderWindow()->AddRenderer(renderer);
37     this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->SetBackground(1,1,1);
38
39     SuperImagePlaneWidget::initialize(this->GetRenderWindow()->GetInteractor());
40
41     this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->ResetCamera();    
42
43
44     _rayorigin[0] = 0;
45     _rayorigin[1] = 0;
46     _rayorigin[2] = 0;
47     _rayorigin[3] = 0;
48
49     _imageindex[0] = 0;
50     _imageindex[1] = 0;
51     _imageindex[2] = 0;
52
53 }
54
55 void QtVTKViewer::mouseMoveEvent(QMouseEvent* event){
56     int x=0, y=0;
57
58     QVTKWidget::mouseMoveEvent(event);
59
60     x = event->pos().x();
61     y = this->size().height() - event->pos().y();
62
63 #ifdef debug
64     std::cout<<"X= "<<x<<" Y= "<<y<<std::endl;
65 #endif
66
67
68     this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->SetDisplayPoint(x, y, 0);
69     this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->DisplayToWorld();
70     this->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->GetWorldPoint(_rayorigin);
71 #ifdef debug
72     std::cout<<"X= "<<x<<" Y= "<<y<<std::endl;
73     std::cout<<"X= "<<_rayorigin[0]<<" Y= "<<_rayorigin[1]<<" Z= "<<_rayorigin[2]<<" R= "<<_rayorigin[3]<<std::endl;
74 #endif
75
76
77
78
79
80 }
81
82 void QtVTKViewer::mousePressEvent(QMouseEvent* event){
83     QVTKWidget::mousePressEvent(event);
84     vtkImagePlaneWidget * temp = 0;
85     if(_xwidget->GetCursorDataStatus()==1){
86         temp = _xwidget;
87     }else if(_ywidget->GetCursorDataStatus()==1){
88         temp = _ywidget;
89     }else if(_zwidget->GetCursorDataStatus()==1){
90         temp = _zwidget;
91     }
92
93     if(temp){
94         _imageindex[0]=temp->GetCurrentCursorPosition()[0];
95         _imageindex[1]=temp->GetCurrentCursorPosition()[1];
96         _imageindex[2]=temp->GetCurrentCursorPosition()[2];
97 #ifdef debug
98          std::cout<<"X= "<<_imageindex[0]<<" Y= "<<_imageindex[1]<<" Z= "<<_imageindex[2]<<std::endl;
99 #endif
100     }
101 }
102
103 void QtVTKViewer::SetOutputFormatToRGBA(){
104     _xwidget->GetColorMap()->SetOutputFormatToRGBA();
105     _ywidget->GetColorMap()->SetOutputFormatToRGBA();
106     _zwidget->GetColorMap()->SetOutputFormatToRGBA();
107 }