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