11 #include <QMessageBox> 16 : QMainWindow(parent),
volume(0)
18 mainWindow =
new Ui::MainWindow();
19 mainWindow->setupUi(
this);
21 connect(mainWindow->actionOpen, SIGNAL(triggered()),
this, SLOT(
openFileAction()));
22 connect(mainWindow->actionClose, SIGNAL(triggered()),
this, SLOT(
closeAction()));
30 void MainWindow::on_renderButton_clicked()
34 mainWindow->AlphaCompositingOpenGLWidget->setRegion(regionSeperator,regionColor1,regionColor2);
35 mainWindow->HuePreservingOpenGLWidget->setRegion(regionSeperator,regionColor1,regionColor2);
38 std::vector<glm::vec3> vertices = { glm::vec3(-1.0f, -1.0f, 0.0f), glm::vec3(1.0f, -1.0f, 0.0f), glm::vec3(-1.0f, 1.0f, 0.0f),glm::vec3(1.0f, 1.0f, 0.0f) };
39 std::vector<unsigned int> indices = { 0, 1, 2, 1, 3, 2};
41 mainWindow->AlphaCompositingOpenGLWidget->setShader(
"shader/passthrough.vert",
"shader/alpha.frag");
42 mainWindow->AlphaCompositingOpenGLWidget->setRenderObject(data);
43 mainWindow->AlphaCompositingOpenGLWidget->setOrientation(mainWindow->orientationBox->currentIndex());
44 mainWindow->AlphaCompositingOpenGLWidget->update();
45 mainWindow->HuePreservingOpenGLWidget->setShader(
"shader/passthrough.vert",
"shader/hue.frag");
46 mainWindow->HuePreservingOpenGLWidget->setRenderObject(data);
47 mainWindow->HuePreservingOpenGLWidget->setOrientation(mainWindow->orientationBox->currentIndex());
48 mainWindow->HuePreservingOpenGLWidget->update();
53 msgBox.setText(
"Please select a data set to render!");
60 QString filename = QFileDialog::getOpenFileName(
this,
"Data File", 0, tr(
"Data Files (*.dat *.gri *.csv)"));
62 if (!filename.isEmpty()){
63 string fn = filename.toStdString();
65 mainWindow->progressBar->setEnabled(
true);
66 mainWindow->labelTop->setText(
"Loading data ...");
69 if (fn.substr(fn.find_last_of(
".") + 1) ==
"dat"){
71 success = volume->
loadFromFile(filename,mainWindow->progressBar);
74 mainWindow->progressBar->setEnabled(
false);
78 if (tex->isCreated()) {
80 mainWindow->AlphaCompositingOpenGLWidget->setVolumeTexture(tex);
81 mainWindow->HuePreservingOpenGLWidget->setVolumeTexture(tex);
86 mainWindow->labelTop->setText(
"File LOADED [" + filename +
"]");
90 mainWindow->labelTop->setText(
"ERROR loading file " + filename +
"!");
91 mainWindow->progressBar->setValue(0);
101 void MainWindow::on_color1Button_clicked()
103 QColor
color = QColorDialog::getColor(Qt::red,
this,
"Choose a color for region 1");
105 QString qss = QString(
"background-color: %1").arg(
color.name());
106 mainWindow->color1Button->setStyleSheet(qss);
107 regionColor1 =
color;
112 void MainWindow::on_color2Button_clicked()
114 QColor
color = QColorDialog::getColor(Qt::red,
this,
"Choose a color for region 2");
116 QString qss = QString(
"background-color: %1").arg(
color.name());
117 mainWindow->color2Button->setStyleSheet(qss);
118 regionColor2 =
color;
123 void MainWindow::on_region1Slider_valueChanged()
125 float val = mainWindow->region1Slider->value();
126 QString
string =
"[0,";
127 string.append(QString::number(val/100));
129 mainWindow->region1RangeLabel->setText(
string);
132 string.append(QString::number(val/100));
133 string.append(
",1]");
134 mainWindow->region2RangeLabel->setText(
string);
135 regionSeperator = val/100;
138 void MainWindow::on_region1Slider_sliderReleased(){
142 void MainWindow::updateBothViews(){
143 mainWindow->AlphaCompositingOpenGLWidget->setRegion(regionSeperator,regionColor1,regionColor2);
144 mainWindow->HuePreservingOpenGLWidget->setRegion(regionSeperator,regionColor1,regionColor2);
145 mainWindow->AlphaCompositingOpenGLWidget->update();
146 mainWindow->HuePreservingOpenGLWidget->update();
149 void MainWindow::on_orientationBox_currentIndexChanged(
int index)
151 mainWindow->AlphaCompositingOpenGLWidget->setOrientation(index);
152 mainWindow->HuePreservingOpenGLWidget->setOrientation(index);
Modified volume loader class from Vis 1.
void closeAction()
closeAction terminates the program whenever the "Close" option in the drop down menu is selected...
QOpenGLTexture * generate3DTex()
generate3DTex transforms the loaded volume data set into a 3D texture which can be sampled in the gls...
bool loadFromFile(QString filename, QProgressBar *progressBar)
void openFileAction()
openFileAction opens a file-chooser dialogue whenever the "Open..." option in the drop down menu is s...
MainWindow(QWidget *parent=0)
Helper struct for passing renderable data in the application.