Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
C-Fu
OpenGL
Commits
86dfe321
Commit
86dfe321
authored
Jan 16, 2017
by
Anakin
Browse files
add wireframe paint option,
write file information on the screen, bug fixes
parent
454ed45f
Changes
7
Hide whitespace changes
Inline
Side-by-side
QtMeshViewer/Header/GeometryEngine.h
View file @
86dfe321
...
...
@@ -33,7 +33,7 @@ private:
public
slots
:
void
loadFile
(
QString
filePath
);
void
drawGeometry
(
QOpenGLShaderProgram
*
program
);
void
drawGeometry
(
QOpenGLShaderProgram
*
program
,
bool
wireframe
);
signals:
void
requestResetView
();
...
...
QtMeshViewer/Header/MainWindow.h
View file @
86dfe321
#pragma once
#include
<QtWidgets/QMainWindow>
#include
<qwidget.h>
#include
<QByteArray>
#include
<QStringList>
#include
<QLabel>
#include
"ui_MainWindow.h"
struct
Material
;
...
...
@@ -20,7 +22,7 @@ private:
int
m_curSeverity
;
void
setupWidgets
();
QByteArray
m_fileInfo
;
QLabel
*
m_output
;
private:
void
openFile
();
...
...
@@ -28,6 +30,9 @@ private:
void
aboutTool
();
void
takeScreenShot
();
protected:
virtual
void
resizeEvent
(
QResizeEvent
*
e
)
Q_DECL_OVERRIDE
;
public
slots
:
void
printMessage
(
QString
message
,
int
severity
);
void
setFileInfo
(
QString
name
,
QVector
<
Material
>*
materials
,
int
vertices
,
int
triangle
);
...
...
QtMeshViewer/Header/OglViewerWidget.h
View file @
86dfe321
...
...
@@ -44,6 +44,8 @@ private:
QVector3D
m_translation
;
QQuaternion
m_rotation
;
bool
m_wireframe
=
false
;
protected:
void
mousePressEvent
(
QMouseEvent
*
e
)
Q_DECL_OVERRIDE
;
void
mouseReleaseEvent
(
QMouseEvent
*
e
)
Q_DECL_OVERRIDE
;
...
...
@@ -66,5 +68,6 @@ private slots:
public
slots
:
void
changeDirection
(
int
direction
);
void
toggleWireframe
();
};
QtMeshViewer/Resources/Resources.qrc
View file @
86dfe321
...
...
@@ -8,7 +8,6 @@
</qresource>
<qresource prefix="/files">
<file>about.txt</file>
<file>stylesheet.txt</file>
</qresource>
<qresource prefix="/images/toolbar">
<file>placeholder.png</file>
...
...
@@ -19,5 +18,6 @@
<file>Y.png</file>
<file>Z.png</file>
<file>screenshot.png</file>
<file>wireframe.png</file>
</qresource>
</RCC>
QtMeshViewer/Source/GeometryEngine.cpp
View file @
86dfe321
...
...
@@ -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
)));
}
}
QtMeshViewer/Source/MainWindow.cpp
View file @
86dfe321
...
...
@@ -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: -
\n
Materials: -
\n
Vertice: -
\n
Triangle: -"
);
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
)
...
...
QtMeshViewer/Source/OglViewerWidget.cpp
View file @
86dfe321
...
...
@@ -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
();
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment