add wireframe paint option,

write file information on the screen,
bug fixes
This commit is contained in:
Anakin
2017-01-16 14:24:30 +01:00
parent 454ed45fa1
commit 86dfe32145
7 changed files with 45 additions and 7 deletions

View File

@@ -127,7 +127,7 @@ void GeometryEngine::loadFile(QString filePath)
}
}
void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program)
void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program, bool wireframe)
{
if (!m_arrayBuf.isCreated() || !m_indexBuf.isCreated())
return;
@@ -178,7 +178,7 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program)
bool tmp_transparent(false);
// bind the correct texture
if (it.textureIndex < m_materials->size())
if (it.textureIndex < m_materials->size() && m_materials->at(it.textureIndex).texture != Q_NULLPTR)
{
m_materials->at(it.textureIndex).texture->bind();
tmp_transparent = m_materials->at(it.textureIndex).transparent;
@@ -195,7 +195,7 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program)
program->setUniformValue("b_transparent", tmp_transparent);
// Draw cube geometry using indices from VBO 1
glDrawElements(GL_TRIANGLES, it.size, GL_UNSIGNED_INT, (void*)(it.offset * sizeof(GLuint)));
glDrawElements(wireframe? GL_LINES : GL_TRIANGLES, it.size, GL_UNSIGNED_INT, (void*)(it.offset * sizeof(GLuint)));
}
}

View File

@@ -8,6 +8,8 @@
#include <QSignalMapper>
#include <QFile>
#include <QSizePolicy>
#include <QFont>
#include <QResizeEvent>
#include "..\Header\FileInterface.h"
#define WINDOW_NAME "Mesh Viewer"
@@ -16,6 +18,7 @@ MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindowClass)
, m_curSeverity(0)
, m_output(new QLabel(this))
{
ui->setupUi(this);
@@ -36,6 +39,7 @@ MainWindow::MainWindow(QWidget *parent)
MainWindow::~MainWindow()
{
delete ui;
delete m_output;
}
void MainWindow::openFile()
@@ -89,6 +93,14 @@ void MainWindow::setupWidgets()
ui->mainToolBar->addSeparator();
QAction *wireframe = new QAction(QIcon(":/images/toolbar/wireframe.png"), "Wireframe", this);
wireframe->setCheckable(true);
wireframe->setChecked(false);
connect(wireframe, &QAction::triggered, viewer, &OglViewerWidget::toggleWireframe);
ui->mainToolBar->addAction(wireframe);
ui->mainToolBar->addSeparator();
QAction *fileInfo = new QAction(QIcon(":/images/toolbar/info.png"), "File info", this);
connect(fileInfo, &QAction::triggered, this, &MainWindow::aboutFile);
ui->mainToolBar->addAction(fileInfo);
@@ -97,6 +109,11 @@ void MainWindow::setupWidgets()
connect(help, &QAction::triggered, this, &MainWindow::aboutTool);
ui->mainToolBar->addAction(help);
m_output->setObjectName("output");
m_output->setStyleSheet("QLabel#output{color : white; min-width: 400px; min-height: 50px;}");
m_output->setAlignment(Qt::AlignTop);
m_output->setText("Name: -\nMaterials: -\nVertice: -\nTriangle: -");
m_output->raise();
}
@@ -143,6 +160,11 @@ void MainWindow::takeScreenShot()
viewer->grab().save(destination);
}
void MainWindow::resizeEvent(QResizeEvent * e)
{
m_output->move(40, e->size().height() - 80);
}
void MainWindow::setFileInfo(QString name, QVector<Material>* materials, int vertices, int triangle)
{
m_fileInfo = QByteArray("Filename: ");
@@ -165,6 +187,8 @@ void MainWindow::setFileInfo(QString name, QVector<Material>* materials, int ver
m_fileInfo += it.name;
m_fileInfo += "\n";
}
m_output->setText(m_fileInfo.left(m_fileInfo.indexOf("<detail>")));
}
void MainWindow::printMessage(QString message, int severity)

View File

@@ -226,7 +226,7 @@ void OglViewerWidget::paintGL()
m_program.setUniformValue("vp_matrix", m_projection * view);
// Draw cube geometry
m_dataEngine->drawGeometry(&m_program);
m_dataEngine->drawGeometry(&m_program, m_wireframe);
}
@@ -293,3 +293,9 @@ void OglViewerWidget::changeDirection(int direction)
break;
}
}
void OglViewerWidget::toggleWireframe()
{
m_wireframe = 1 - m_wireframe;
update();
}