VideoVis  0.9
Generates a volume visualisation of a video
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
mainwindow.cpp
Go to the documentation of this file.
1 #include "mainwindow.h"
2 #include "ui_mainwindow.h"
3 
4 #include <QFileDialog>
5 #include <QMessageBox>
6 
7 MainWindow::MainWindow(QWidget *parent) : QDialog(parent), ui(new Ui::MainWindow)
8 {
9  ui->setupUi(this);
10 }
11 
13 {
14  delete ui;
15 }
16 
17 void MainWindow::on_frameSlider_valueChanged(int value)
18 {
19  ui->glWidget->setFrameOffset(value);
20 }
21 
22 void MainWindow::on_pushButton_LoadVideo_clicked()
23 {
24  QApplication::setOverrideCursor(Qt::WaitCursor);
25  VFLResult vr = ui->glWidget->loadVideoFile(ui->lineEdit_Settings_StartFrame->text().toInt(),
26  ui->lineEdit_Settings_StepSize->text().toInt(),
27  ui->lineEdit_Settings_EndFrame->text().toInt());
28 
29  if (vr != VFL_OK)
30  {
31  QMessageBox::critical(this, "Error", "Couldn't load video file!");
32  QApplication::restoreOverrideCursor();
33  }
34 
35  int frameCount = ui->glWidget->getFrameCount();
36  ui->labelSlider_1->setText(QString::number(frameCount));
37  ui->frameSlider->setRange(0, frameCount - 1);
38  ui->frameSlider->setEnabled(true);
39  ui->labelSlider_0->setEnabled(true);
40  ui->labelSlider_1->setEnabled(true);
41  ui->groupBox_Visualization->setEnabled(true);
42  QApplication::restoreOverrideCursor();
43 }
44 
45 void MainWindow::on_radioButton_Style_HorseShoe_toggled(bool checked)
46 {
47  if (checked)
48  {
49  ui->glWidget->setStyle(true);
50  ui->groupBox_BoxSize->setEnabled(false);
51  }
52  else
53  {
54  ui->glWidget->setStyle(false);
55  ui->groupBox_BoxSize->setEnabled(true);
56  }
57 
58 }
59 
60 void MainWindow::on_radioButton_Style_Block_toggled(bool checked)
61 {
62 
63 }
64 
65 
66 void MainWindow::on_lineEdit_StepSize_editingFinished()
67 {
68  float stepSize = ui->lineEdit_StepSize->text().toFloat();
69 
70  ui->glWidget->setStepSize(stepSize);
71 
72  if (stepSize >= 0.01)
73  ui->horizontalSlider_StepSize->setValue(1);
74  else
75  if (stepSize <= 0.0001)
76  ui->horizontalSlider_StepSize->setValue(100);
77  else
78  ui->horizontalSlider_StepSize->setValue(ceil(0.01 / stepSize - 0.5));
79 }
80 
81 void MainWindow::on_lineEdit_BoxSize_editingFinished()
82 {
83  int boxSize = ui->lineEdit_BoxSize->text().toInt();
84 
85  ui->horizontalSlider_BoxSize->setValue(boxSize);
86 }
87 
88 void MainWindow::on_horizontalSlider_StepSize_valueChanged(int value)
89 {
90  ui->lineEdit_StepSize->setText(QString::number(floor(pow(10.0, 3) / (float) value + 0.5) / pow(10.0, 5)));
91 }
92 
93 void MainWindow::on_horizontalSlider_StepSize_sliderReleased()
94 {
95  ui->glWidget->setStepSize(ui->lineEdit_StepSize->text().toFloat());
96 }
97 
98 void MainWindow::on_horizontalSlider_BoxSize_valueChanged(int value)
99 {
100  ui->lineEdit_BoxSize->setText(QString::number(value));
101  ui->glWidget->setBoxSize(value);
102 }
103 
104 void MainWindow::on_radioButton_Metric_None_toggled(bool checked)
105 {
106  if (checked)
107  {
108  QApplication::setOverrideCursor(Qt::WaitCursor);
109  ui->glWidget->setMetric(VV_METRIC_NONE);
110  QApplication::restoreOverrideCursor();
111  }
112 }
113 
114 void MainWindow::on_radioButton_Metric_YDIF_toggled(bool checked)
115 {
116  if (checked)
117  {
118  QApplication::setOverrideCursor(Qt::WaitCursor);
119  ui->glWidget->setMetric(VV_METRIC_YDIF);
120  QApplication::restoreOverrideCursor();
121  }
122 }
123 
124 void MainWindow::on_radioButton_Metric_YMSE_toggled(bool checked)
125 {
126  if (checked)
127  {
128  QApplication::setOverrideCursor(Qt::WaitCursor);
129  ui->glWidget->setMetric(VV_METRIC_YMSE);
130  QApplication::restoreOverrideCursor();
131  }
132 }
133 
134 void MainWindow::on_radioButton_Metric_YNDIF_toggled(bool checked)
135 {
136  if (checked)
137  {
138  QApplication::setOverrideCursor(Qt::WaitCursor);
139  ui->glWidget->setMetric(VV_METRIC_YNDIF);
140  QApplication::restoreOverrideCursor();
141  }
142 }
143 
144 void MainWindow::on_radioButton_Metric_YNMSE_toggled(bool checked)
145 {
146  if (checked)
147  {
148  QApplication::setOverrideCursor(Qt::WaitCursor);
149  ui->glWidget->setMetric(VV_METRIC_YNMSE);
150  QApplication::restoreOverrideCursor();
151  }
152 }
153 
154 void MainWindow::on_radioButton_Metric_IQDIF_toggled(bool checked)
155 {
156  if (checked)
157  {
158  QApplication::setOverrideCursor(Qt::WaitCursor);
159  ui->glWidget->setMetric(VV_METRIC_IQDIF);
160  QApplication::restoreOverrideCursor();
161  }
162 }
163 
164 void MainWindow::on_pushButton_SelectFile_clicked()
165 {
166  QString videoPath = QFileDialog::getOpenFileName(this, tr("Open Video File"), "", tr("Video files (*.avi *.wmv *.mpq *.mpeq *.mkv);;All files (*.*)"));
167 
168  if (videoPath.count() == 0)
169  return;
170 
171  int hRes = 0, vRes = 0;
172 
173  QApplication::setOverrideCursor(Qt::WaitCursor);
174 
175  if (VFL_OK != ui->glWidget->openVideoFile(videoPath, &hRes, &vRes))
176  {
177  QMessageBox::critical(this, "Error", "Couldn't open video file!");
178  QApplication::restoreOverrideCursor();
179  return;
180  }
181 
182  ui->label_Info_Path_Value->setText(videoPath);
183  ui->label_Info_HRes_Value->setText(QString::number(hRes));
184  ui->label_Info_VRes_Value->setText(QString::number(vRes));
185  ui->pushButton_LoadVideo->setEnabled(true);
186  QApplication::restoreOverrideCursor();
187 }
188 
189 void MainWindow::on_transferBox_valueChanged(float * value)
190 {
191  ui->glWidget->setTransferFunction((GLfloat *) value, 150);
192 }