1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
26 #include "qtsurfacerendererpanel.h"
27 #include "ui_qtsurfacerendererpanel.h"
29 #include "qfiledialog.h"
31 #include "qcolordialog.h"
32 #include "qmessagebox.h"
36 #include "OpenImage.xpm"
38 QtSurfaceRendererPanel::QtSurfaceRendererPanel(QWidget *parent) :
40 ui(new Ui::QtSurfaceRendererPanel)
45 this->ui->pushButtonColorChooser->setIcon(QIcon(Color_xpm));
46 //this->ui->pushButtonSave->setIcon(QIcon(Save_xpm));
47 this->ui->pushButtonOpen->setIcon(QIcon(OpenImage_xpm));
49 this->ui->comboBoxSave->addItem(QIcon(Save_xpm), QString(""));
50 this->ui->comboBoxSave->addItem(QString("Save surface"));
51 this->ui->comboBoxSave->addItem(QString("Export image stencil"));
55 QtSurfaceRendererPanel::~QtSurfaceRendererPanel()
59 void QtSurfaceRendererPanel::setImageData(vtkImageData* img){
60 double *range =img->GetScalarRange();
62 this->ui->horizontalSliderMinIso->setRange(range[0], range[1]);
64 this->ui->horizontalSliderMaxIso->setRange(range[0], range[1]);
66 wxMaracasSurfaceRenderingManager::setImageData(img);
70 void QtSurfaceRendererPanel::on_OpacitySlider_valueChanged(int value)
74 this->ui->lineEditOpacity->setText(QString::number(value));
77 this->changeOpacity(0, value);
80 QMessageBox::critical(this, tr("Volume Rendering"), tr(e), QMessageBox::Ok);
84 void QtSurfaceRendererPanel::on_pushButtonColorChooser_clicked()
86 QColorDialog* qcolor = new QColorDialog(this);
92 QColor color = qcolor->selectedColor();
94 int r = 0, g = 0, b = 0;
95 color.getRgb(&r, &g, &b);
99 this->changeColor(0, r/255.0, g/255.0 ,b/255.0);
102 QMessageBox::critical(this, tr("Surface Rendering"), tr(e), QMessageBox::Ok);
109 void QtSurfaceRendererPanel::on_checkBox_clicked(bool checked)
111 if(!this->addRemoveActor(0, checked)){
112 this->ui->checkBox->setChecked(false);
114 this->ui->checkBoxBoundingBox->setCheckState(Qt::Unchecked);
115 this->on_checkBoxBoundingBox_clicked(false);
119 void QtSurfaceRendererPanel::on_horizontalSliderMaxIso_valueChanged(int value)
122 this->ui->lineEditMaxIso->setText(QString::number(value));
125 void QtSurfaceRendererPanel::on_horizontalSliderMinIso_valueChanged(int value)
127 this->ui->lineEditMinIso->setText(QString::number(value));
130 void QtSurfaceRendererPanel::on_horizontalSliderMaxIso_sliderReleased()
135 void QtSurfaceRendererPanel::on_horizontalSliderMinIso_sliderReleased()
140 void QtSurfaceRendererPanel::onIsoValueChanged(){
142 this->changeIsoValue(0, this->ui->horizontalSliderMinIso->value(), this->ui->horizontalSliderMaxIso->value());
145 /*void QtSurfaceRendererPanel::on_pushButtonSave_clicked()
147 QString filename = QFileDialog::getSaveFileName(this,
148 tr("Save Mesh File"),
150 tr("Mesh files (*.stl *.ply *.vtk)") );
152 if( !filename.isNull() ){
153 //filename.append(".stl");
154 this->saveProp3DSTL(0, filename.toStdString().c_str());
159 void QtSurfaceRendererPanel::on_checkBoxBoundingBox_clicked(bool checked)
161 this->enableBoundingBox(0, checked);
165 void QtSurfaceRendererPanel::on_pushButtonOpen_clicked(bool checked)
170 void QtSurfaceRendererPanel::on_pushButtonOpen_clicked()
172 QString filename = QFileDialog::getOpenFileName(this, tr("Load Mesh File"), QDir::currentPath(), tr("Mesh files (*.stl *.ply *.vtk)"));
174 if(!filename.isNull()){
175 this->loadProp3DSTL(filename.toStdString().c_str());
176 this->ui->checkBox->setCheckState(Qt::Checked);
180 void QtSurfaceRendererPanel::on_comboBoxSave_activated(int index)
183 QString filename = QFileDialog::getSaveFileName(this,
184 tr("Save Mesh File"),
186 tr("Mesh files (*.stl *.ply *.vtk)") );
188 if( !filename.isNull() ){
189 //filename.append(".stl");
190 this->saveProp3DSTL(0, filename.toStdString().c_str());
192 }else if(index == 2){
194 QString filename = QFileDialog::getSaveFileName(this,
195 tr("Save Image File"),
197 tr("Meta Image file (*.mhd)") );
199 if( !filename.isNull() ){
201 this->exportImageStencil(0, filename.toStdString().c_str());
204 this->ui->comboBoxSave->setCurrentIndex(0);