]> Creatis software - creaMaracasVisu.git/blob - lib/GUI/Qt/SurfaceRenderer/qtsurfacerendererpanel.cxx
addition of files
[creaMaracasVisu.git] / lib / GUI / Qt / SurfaceRenderer / qtsurfacerendererpanel.cxx
1 #include "qtsurfacerendererpanel.h"
2 #include "ui_qtsurfacerendererpanel.h"
3
4 #include "qfiledialog.h"
5
6 #include "qcolordialog.h"
7 #include "qmessagebox.h"
8
9 #include "Color.xpm"
10 #include "Save.xpm"
11
12 QtSurfaceRendererPanel::QtSurfaceRendererPanel(QWidget *parent) :
13     QWidget(parent),
14     ui(new Ui::QtSurfaceRendererPanel)
15 {
16     ui->setupUi(this);
17
18
19     this->ui->pushButtonColorChooser->setIcon(QIcon(Color_xpm));
20     this->ui->pushButtonSave->setIcon(QIcon(Save_xpm));
21 }
22
23 QtSurfaceRendererPanel::~QtSurfaceRendererPanel()
24 {
25     delete ui;
26 }
27 void QtSurfaceRendererPanel::SetImageData(vtkImageData* img){
28     this->addPropMHD(0, img, "");
29     this->enableBoundingBox(0, false);
30
31     double *range  =img->GetScalarRange();
32
33     this->ui->horizontalSliderMinIso->setRange(range[0], range[1] - 1);
34
35     this->ui->horizontalSliderMaxIso->setRange(range[0] + 1, range[1]);
36 }
37
38 void QtSurfaceRendererPanel::on_OpacitySlider_valueChanged(int value)
39 {
40     try{
41
42         this->ui->lineEditOpacity->setText(QString::number(value));
43
44
45         this->changeOpacity(0, value);
46     }catch(char * e){
47         cout<<e<<endl;
48         QMessageBox::critical(this, tr("Volume Rendering"), tr(e), QMessageBox::Ok);
49     }
50 }
51
52 void QtSurfaceRendererPanel::on_pushButtonColorChooser_clicked()
53 {
54     QColorDialog* qcolor = new QColorDialog(this);
55
56
57
58     if(qcolor->exec()){
59
60         QColor color = qcolor->selectedColor();
61
62         int r = 0, g = 0, b = 0;
63         color.getRgb(&r, &g, &b);
64
65         try{
66
67             this->changeColor(0, r/255.0, g/255.0 ,b/255.0);
68         }catch(char * e){
69             cout<<e<<endl;
70             QMessageBox::critical(this, tr("Surface Rendering"), tr(e), QMessageBox::Ok);
71         }
72     }
73
74
75 }
76
77 void QtSurfaceRendererPanel::on_checkBox_clicked(bool checked)
78 {
79     this->addRemoveActor(0, checked);
80 }
81
82 void QtSurfaceRendererPanel::on_horizontalSliderMaxIso_valueChanged(int value)
83 {
84
85     this->ui->lineEditMaxIso->setText(QString::number(value));
86 }
87
88 void QtSurfaceRendererPanel::on_horizontalSliderMinIso_valueChanged(int value)
89 {
90     this->ui->lineEditMinIso->setText(QString::number(value));
91 }
92
93 void QtSurfaceRendererPanel::on_horizontalSliderMaxIso_sliderReleased()
94 {
95     onIsoValueChanged();
96 }
97
98 void QtSurfaceRendererPanel::on_horizontalSliderMinIso_sliderReleased()
99 {
100     onIsoValueChanged();
101 }
102
103 void QtSurfaceRendererPanel::onIsoValueChanged(){
104     this->changeIsoValue(0, this->ui->horizontalSliderMinIso->value(), this->ui->horizontalSliderMaxIso->value());
105 }
106
107 void QtSurfaceRendererPanel::on_pushButtonSave_clicked()
108 {
109     QString filename = QFileDialog::getSaveFileName(this,
110                                                     tr("Save STL File"),
111                                                     QDir::currentPath(),
112                                                     tr("STL files (*.stl);") );
113
114     if( !filename.isNull() ){
115         filename.append(".stl");
116         this->saveProp3DSTL(0, filename.toStdString().c_str());
117     }
118
119 }
120
121 void QtSurfaceRendererPanel::on_checkBoxBoundingBox_clicked(bool checked)
122 {
123     this->enableBoundingBox(0, checked);
124
125 }