some buttons added

This commit is contained in:
Anakin 2017-01-05 16:04:51 +01:00
parent 44e36b8b0d
commit b58b7c47e5
5 changed files with 66 additions and 6 deletions

View File

@ -14,6 +14,8 @@ public:
private: private:
Ui::MainWindowClass* ui; Ui::MainWindowClass* ui;
int m_curSeverity; int m_curSeverity;
void setupWidgets();
private slots: private slots:
void openFile(); void openFile();

View File

@ -57,5 +57,8 @@ private:
private slots: private slots:
void resetView(); void resetView();
public slots:
void changeDirection(int direction);
}; };

View File

@ -126,7 +126,7 @@ void GeometryEngine::loadTexture(const char* filePath, const char* fileName)
img = loadTga((std::string(filePath) + std::string(fileName)).c_str(), loadSuccess); img = loadTga((std::string(filePath) + std::string(fileName)).c_str(), loadSuccess);
//TODO: emit if not successfull //TODO: emit if not successfull
if (!loadSuccess) if (loadSuccess)
{ {
QString msg = "WARNING: texture not found or corrupted: "; QString msg = "WARNING: texture not found or corrupted: ";
msg += QString(fileName); msg += QString(fileName);

View File

@ -5,6 +5,8 @@
#include <QFileDialog> #include <QFileDialog>
#include <QFile> #include <QFile>
#include <QPalette> #include <QPalette>
#include <QAction>
#include <QSignalMapper>
#include "..\Header\FileInterface.h" #include "..\Header\FileInterface.h"
#define WINDOW_NAME "Mesh Viewer" #define WINDOW_NAME "Mesh Viewer"
@ -19,15 +21,11 @@ MainWindow::MainWindow(QWidget *parent)
setWindowTitle(WINDOW_NAME); setWindowTitle(WINDOW_NAME);
setWindowIcon(QIcon(":/images/icon.ico")); setWindowIcon(QIcon(":/images/icon.ico"));
ui->mainToolBar->addAction("Open File", this, &MainWindow::openFile);
ui->mainToolBar->addAction("File Info", this, &MainWindow::aboutFile);
ui->mainToolBar->addAction("Help", this, &MainWindow::aboutTool);
QSurfaceFormat format; QSurfaceFormat format;
format.setDepthBufferSize(24); format.setDepthBufferSize(24);
QSurfaceFormat::setDefaultFormat(format); QSurfaceFormat::setDefaultFormat(format);
setCentralWidget(new OglViewerWidget(this)); setupWidgets();
ui->statusBar->showMessage("MeshViewer by Anakin", 0); ui->statusBar->showMessage("MeshViewer by Anakin", 0);
} }
@ -43,6 +41,54 @@ void MainWindow::openFile()
emit loadFile(fileName.toStdString().c_str()); emit loadFile(fileName.toStdString().c_str());
} }
void MainWindow::setupWidgets()
{
OglViewerWidget* viewer = new OglViewerWidget(this);
setCentralWidget(viewer);
QAction *openFile = new QAction("Open file", this);
connect(openFile, &QAction::triggered, this, &MainWindow::openFile);
ui->mainToolBar->addAction(openFile);
QSignalMapper* signalMapper = new QSignalMapper(this);
QAction *x = new QAction("X", this);
x->setCheckable(true);
x->setChecked(true);
ui->mainToolBar->addAction(x);
QAction *y = new QAction("Y", this);
y->setCheckable(true);
y->setChecked(true);
ui->mainToolBar->addAction(y);
QAction *z = new QAction("Z", this);
z->setCheckable(true);
z->setChecked(true);
ui->mainToolBar->addAction(z);
connect(x, SIGNAL(triggered()), signalMapper, SLOT(map()));
connect(y, SIGNAL(triggered()), signalMapper, SLOT(map()));
connect(z, SIGNAL(triggered()), signalMapper, SLOT(map()));
signalMapper->setMapping(x, 1);
signalMapper->setMapping(y, 2);
signalMapper->setMapping(z, 3);
connect(signalMapper, SIGNAL(mapped(int)), viewer, SLOT(changeDirection(int)));
QAction *fileInfo = new QAction("File info", this);
connect(fileInfo, &QAction::triggered, this, &MainWindow::aboutFile);
ui->mainToolBar->addAction(fileInfo);
QAction *help = new QAction("Help", this);
connect(help, &QAction::triggered, this, &MainWindow::aboutTool);
ui->mainToolBar->addAction(help);
}
void MainWindow::aboutFile() void MainWindow::aboutFile()
{ {
QMessageBox* dialog = new QMessageBox(QMessageBox::Information, QMessageBox* dialog = new QMessageBox(QMessageBox::Information,

View File

@ -211,3 +211,12 @@ void OglViewerWidget::resetView()
m_translation = { 0.0, 0.0, DEFAULT_Z_DISTANCE }; m_translation = { 0.0, 0.0, DEFAULT_Z_DISTANCE };
update(); update();
} }
/////////////////////////////////////////////////////////////////////////
// public slots
void OglViewerWidget::changeDirection(int direction)
{
}