1 #include "qtsurfacerendererpanel.h"
2 #include "ui_qtsurfacerendererpanel.h"
4 #include "qfiledialog.h"
6 #include "qcolordialog.h"
7 #include "qmessagebox.h"
11 #include "OpenImage.xpm"
13 QtSurfaceRendererPanel::QtSurfaceRendererPanel(QWidget *parent) :
15 ui(new Ui::QtSurfaceRendererPanel)
20 this->ui->pushButtonColorChooser->setIcon(QIcon(Color_xpm));
21 //this->ui->pushButtonSave->setIcon(QIcon(Save_xpm));
22 this->ui->pushButtonOpen->setIcon(QIcon(OpenImage_xpm));
24 this->ui->comboBoxSave->addItem(QIcon(Save_xpm), QString(""));
25 this->ui->comboBoxSave->addItem(QString("Save surface"));
26 this->ui->comboBoxSave->addItem(QString("Export image stencil"));
30 QtSurfaceRendererPanel::~QtSurfaceRendererPanel()
34 void QtSurfaceRendererPanel::setImageData(vtkImageData* img){
35 double *range =img->GetScalarRange();
37 this->ui->horizontalSliderMinIso->setRange(range[0], range[1]);
39 this->ui->horizontalSliderMaxIso->setRange(range[0], range[1]);
41 wxMaracasSurfaceRenderingManager::setImageData(img);
45 void QtSurfaceRendererPanel::on_OpacitySlider_valueChanged(int value)
49 this->ui->lineEditOpacity->setText(QString::number(value));
52 this->changeOpacity(0, value);
55 QMessageBox::critical(this, tr("Volume Rendering"), tr(e), QMessageBox::Ok);
59 void QtSurfaceRendererPanel::on_pushButtonColorChooser_clicked()
61 QColorDialog* qcolor = new QColorDialog(this);
67 QColor color = qcolor->selectedColor();
69 int r = 0, g = 0, b = 0;
70 color.getRgb(&r, &g, &b);
74 this->changeColor(0, r/255.0, g/255.0 ,b/255.0);
77 QMessageBox::critical(this, tr("Surface Rendering"), tr(e), QMessageBox::Ok);
84 void QtSurfaceRendererPanel::on_checkBox_clicked(bool checked)
86 if(!this->addRemoveActor(0, checked)){
87 this->ui->checkBox->setChecked(false);
89 this->ui->checkBoxBoundingBox->setCheckState(Qt::Unchecked);
90 this->on_checkBoxBoundingBox_clicked(false);
94 void QtSurfaceRendererPanel::on_horizontalSliderMaxIso_valueChanged(int value)
97 this->ui->lineEditMaxIso->setText(QString::number(value));
100 void QtSurfaceRendererPanel::on_horizontalSliderMinIso_valueChanged(int value)
102 this->ui->lineEditMinIso->setText(QString::number(value));
105 void QtSurfaceRendererPanel::on_horizontalSliderMaxIso_sliderReleased()
110 void QtSurfaceRendererPanel::on_horizontalSliderMinIso_sliderReleased()
115 void QtSurfaceRendererPanel::onIsoValueChanged(){
117 this->changeIsoValue(0, this->ui->horizontalSliderMinIso->value(), this->ui->horizontalSliderMaxIso->value());
120 /*void QtSurfaceRendererPanel::on_pushButtonSave_clicked()
122 QString filename = QFileDialog::getSaveFileName(this,
123 tr("Save Mesh File"),
125 tr("Mesh files (*.stl *.ply *.vtk)") );
127 if( !filename.isNull() ){
128 //filename.append(".stl");
129 this->saveProp3DSTL(0, filename.toStdString().c_str());
134 void QtSurfaceRendererPanel::on_checkBoxBoundingBox_clicked(bool checked)
136 this->enableBoundingBox(0, checked);
140 void QtSurfaceRendererPanel::on_pushButtonOpen_clicked(bool checked)
145 void QtSurfaceRendererPanel::on_pushButtonOpen_clicked()
147 QString filename = QFileDialog::getOpenFileName(this, tr("Load Mesh File"), QDir::currentPath(), tr("Mesh files (*.stl *.ply *.vtk)"));
149 if(!filename.isNull()){
150 this->loadProp3DSTL(filename.toStdString().c_str());
151 this->ui->checkBox->setCheckState(Qt::Checked);
155 void QtSurfaceRendererPanel::on_comboBoxSave_activated(int index)
158 QString filename = QFileDialog::getSaveFileName(this,
159 tr("Save Mesh File"),
161 tr("Mesh files (*.stl *.ply *.vtk)") );
163 if( !filename.isNull() ){
164 //filename.append(".stl");
165 this->saveProp3DSTL(0, filename.toStdString().c_str());
167 }else if(index == 2){
169 QString filename = QFileDialog::getSaveFileName(this,
170 tr("Save Image File"),
172 tr("Meta Image file (*.mhd)") );
174 if( !filename.isNull() ){
176 this->exportImageStencil(0, filename.toStdString().c_str());
179 this->ui->comboBoxSave->setCurrentIndex(0);