working ver with QT
This commit is contained in:
57
particle-track-and-trace/src/QT/MainWindow.cpp
Normal file
57
particle-track-and-trace/src/QT/MainWindow.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "MainWindow.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <vtkDataSetReader.h>
|
||||
|
||||
MainWindow::MainWindow(QWidget* parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() { delete ui; }
|
||||
|
||||
void MainWindow::showAboutDialog()
|
||||
{
|
||||
QMessageBox::information(
|
||||
this, "About",
|
||||
"interactive particle in-fluid simulation program for surface level advection.");
|
||||
}
|
||||
|
||||
void MainWindow::showOpenFileDialog()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open file"), "",
|
||||
"VTK Files (*.vtk)");
|
||||
|
||||
// Open file
|
||||
QFile file(fileName);
|
||||
file.open(QIODevice::ReadOnly);
|
||||
|
||||
// Return on Cancel
|
||||
if (!file.exists())
|
||||
return;
|
||||
|
||||
openFile(fileName);
|
||||
}
|
||||
|
||||
void MainWindow::openFile(const QString& fileName)
|
||||
{
|
||||
ui->sceneWidget->removeDataSet();
|
||||
|
||||
// Create reader
|
||||
vtkSmartPointer<vtkDataSetReader> reader = vtkSmartPointer<vtkDataSetReader>::New();
|
||||
reader->SetFileName(fileName.toStdString().c_str());
|
||||
|
||||
// Read the file
|
||||
reader->Update();
|
||||
|
||||
// Add data set to 3D view
|
||||
vtkSmartPointer<vtkDataSet> dataSet = reader->GetOutput();
|
||||
if (dataSet != nullptr) {
|
||||
ui->sceneWidget->addDataSet(reader->GetOutput());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user