2016-12-24 15:03:37 +00:00
|
|
|
#include "..\Header\MainWindow.h"
|
|
|
|
#include "..\Header\OglViewerWidget.h"
|
|
|
|
#include <QSurfaceFormat>
|
2016-12-31 15:18:35 +00:00
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QFileDialog>
|
2017-01-04 13:35:27 +00:00
|
|
|
#include <QFile>
|
|
|
|
#include <QPalette>
|
2017-01-05 10:31:36 +00:00
|
|
|
#include "..\Header\FileInterface.h"
|
2016-12-31 15:18:35 +00:00
|
|
|
|
|
|
|
#define WINDOW_NAME "Mesh Viewer"
|
2016-12-24 15:03:37 +00:00
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
|
|
: QMainWindow(parent)
|
|
|
|
, ui(new Ui::MainWindowClass)
|
2017-01-04 13:35:27 +00:00
|
|
|
, m_curSeverity(0)
|
2016-12-24 15:03:37 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
2016-12-31 15:18:35 +00:00
|
|
|
setWindowTitle(WINDOW_NAME);
|
|
|
|
setWindowIcon(QIcon(":/images/icon.ico"));
|
|
|
|
|
|
|
|
ui->mainToolBar->addAction("Open File", this, &MainWindow::openFile);
|
2017-01-04 13:35:27 +00:00
|
|
|
ui->mainToolBar->addAction("File Info", this, &MainWindow::aboutFile);
|
2016-12-31 15:18:35 +00:00
|
|
|
ui->mainToolBar->addAction("Help", this, &MainWindow::aboutTool);
|
|
|
|
|
2016-12-24 15:03:37 +00:00
|
|
|
QSurfaceFormat format;
|
|
|
|
format.setDepthBufferSize(24);
|
|
|
|
QSurfaceFormat::setDefaultFormat(format);
|
|
|
|
|
2016-12-31 11:31:38 +00:00
|
|
|
setCentralWidget(new OglViewerWidget(this));
|
2017-01-04 13:35:27 +00:00
|
|
|
|
|
|
|
ui->statusBar->showMessage("MeshViewer by Anakin", 0);
|
2016-12-24 15:03:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
|
|
|
delete ui;
|
2016-12-31 15:18:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::openFile()
|
|
|
|
{
|
2017-01-03 13:35:09 +00:00
|
|
|
QString fileName = QFileDialog::getOpenFileName(this, "Open File", "", "Mesh (*.msh)");
|
add exe icon,
signal-slot for openFile,
resetView on openFile,
cleanup when open a new file,
triangulate quad poly now correctly, more not working, bug from previous version,
next:
fix 5,6,.. triangulation,
triClothMan, IC Helmet, still buggy,
2017-01-02 11:21:32 +00:00
|
|
|
emit loadFile(fileName.toStdString().c_str());
|
2016-12-31 15:18:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::aboutFile()
|
|
|
|
{
|
|
|
|
QMessageBox* dialog = new QMessageBox(QMessageBox::Information,
|
|
|
|
WINDOW_NAME,
|
|
|
|
"When i find some time, i'll add some information about\nthe file in the detailed text",
|
|
|
|
QMessageBox::StandardButton::Close,
|
|
|
|
this,
|
|
|
|
Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
|
|
|
|
dialog->setDetailedText("This is the cool detailed text\n");
|
|
|
|
dialog->exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::aboutTool()
|
|
|
|
{
|
2017-01-04 13:35:27 +00:00
|
|
|
QFile file(":/files/about.txt");
|
|
|
|
file.open(QIODevice::ReadOnly);
|
|
|
|
QMessageBox* dialog = new QMessageBox(
|
|
|
|
QMessageBox::Question,
|
2016-12-31 15:18:35 +00:00
|
|
|
WINDOW_NAME,
|
2017-01-04 13:35:27 +00:00
|
|
|
QString(file.readAll()),
|
2016-12-31 15:18:35 +00:00
|
|
|
QMessageBox::StandardButton::Close,
|
|
|
|
this,
|
2017-01-04 13:35:27 +00:00
|
|
|
Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint
|
|
|
|
);
|
|
|
|
|
|
|
|
//dialog->setDetailedText(QString(file.readAll()));
|
|
|
|
file.close();
|
|
|
|
|
2016-12-31 15:18:35 +00:00
|
|
|
dialog->exec();
|
2017-01-04 13:35:27 +00:00
|
|
|
}
|
|
|
|
|
2017-01-05 13:46:01 +00:00
|
|
|
void MainWindow::printMessage(QString message, int severity)
|
2017-01-04 13:35:27 +00:00
|
|
|
{
|
|
|
|
if (severity < m_curSeverity)
|
|
|
|
return;
|
|
|
|
|
|
|
|
m_curSeverity = severity;
|
|
|
|
int time(0);
|
|
|
|
QPalette palette;
|
|
|
|
|
|
|
|
switch (severity)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
time = 3000;
|
|
|
|
palette.setColor(QPalette::WindowText, Qt::darkYellow);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
time = 3000;
|
|
|
|
palette.setColor(QPalette::WindowText, Qt::red);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
time = 2000;
|
|
|
|
palette.setColor(QPalette::WindowText, Qt::black);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->statusBar->setPalette(palette);
|
|
|
|
ui->statusBar->showMessage(message, time);
|
2016-12-24 15:03:37 +00:00
|
|
|
}
|