Make part list more tidy

master
Jeremy Hu 2018-04-07 19:51:33 +08:00
parent af451bd5ab
commit 65b14200a5
9 changed files with 86 additions and 41 deletions

View File

@ -189,7 +189,8 @@ void MeshGenerator::process()
qDebug() << "m_requirePartPreviewMap.find:" << partIdIt;
if (m_requirePartPreviewMap.find(partIdIt) != m_requirePartPreviewMap.end()) {
ModelOfflineRender *render = m_partPreviewRenderMap[partIdIt];
render->updateMesh(new Mesh(meshliteContext, meshId));
int trimedMeshId = meshlite_trim(meshliteContext, meshId, 1);
render->updateMesh(new Mesh(meshliteContext, trimedMeshId));
QImage *image = new QImage(render->toImage(QSize(Theme::previewImageSize, Theme::previewImageSize)));
m_partPreviewMap[partIdIt] = image;
}
@ -211,7 +212,8 @@ void MeshGenerator::process()
QImage *image = new QImage(m_previewRender->toImage(QSize(Theme::previewImageSize, Theme::previewImageSize)));
m_preview = image;
}
m_mesh = new Mesh(meshliteContext, mergedMeshId);
int trimedMeshId = meshlite_trim(meshliteContext, mergedMeshId, 1);
m_mesh = new Mesh(meshliteContext, trimedMeshId);
}
if (m_previewRender) {

View File

@ -8,7 +8,8 @@ ModelMeshBinder::ModelMeshBinder() :
m_renderTriangleVertexCount(0),
m_renderEdgeVertexCount(0),
m_mesh(NULL),
m_meshUpdated(false)
m_meshUpdated(false),
m_showFrames(true)
{
}
@ -102,10 +103,12 @@ void ModelMeshBinder::paint()
m_meshUpdated = false;
}
}
if (m_renderEdgeVertexCount > 0) {
QOpenGLVertexArrayObject::Binder vaoBinder(&m_vaoEdge);
glDrawArrays(GL_LINES, 0, m_renderEdgeVertexCount);
if (m_showFrames) {
if (m_renderEdgeVertexCount > 0) {
QOpenGLVertexArrayObject::Binder vaoBinder(&m_vaoEdge);
glDrawArrays(GL_LINES, 0, m_renderEdgeVertexCount);
}
}
if (m_renderTriangleVertexCount > 0) {
QOpenGLVertexArrayObject::Binder vaoBinder(&m_vaoTriangle);
@ -120,3 +123,13 @@ void ModelMeshBinder::cleanup()
if (m_vboEdge.isCreated())
m_vboEdge.destroy();
}
void ModelMeshBinder::showFrames()
{
m_showFrames = true;
}
void ModelMeshBinder::hideFrames()
{
m_showFrames = false;
}

View File

@ -16,6 +16,8 @@ public:
void initialize();
void paint();
void cleanup();
void showFrames();
void hideFrames();
private:
QOpenGLVertexArrayObject m_vaoTriangle;
QOpenGLBuffer m_vboTriangle;
@ -26,6 +28,7 @@ private:
int m_renderTriangleVertexCount;
int m_renderEdgeVertexCount;
bool m_meshUpdated;
bool m_showFrames;
};
#endif

View File

@ -10,7 +10,14 @@ ModelOfflineRender::ModelOfflineRender(QScreen *targetScreen) :
{
create();
m_context = new QOpenGLContext();
m_context->setFormat(format());
QSurfaceFormat fmt = format();
fmt.setAlphaBufferSize(8);
fmt.setSamples(4);
setFormat(fmt);
m_context->setFormat(fmt);
m_context->create();
}
@ -41,6 +48,7 @@ QImage ModelOfflineRender::toImage(const QSize &size)
QOpenGLFramebufferObjectFormat format;
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
format.setSamples(16);
QOpenGLFramebufferObject *renderFbo = new QOpenGLFramebufferObject(size, format);
renderFbo->bind();
m_context->functions()->glViewport(0, 0, size.width(), size.height());
@ -56,6 +64,7 @@ QImage ModelOfflineRender::toImage(const QSize &size)
ModelShaderProgram *program = new ModelShaderProgram;
ModelMeshBinder meshBinder;
meshBinder.initialize();
meshBinder.hideFrames();
program->setUniformValue(program->lightPosLoc(), QVector3D(0, 0, 70));
@ -65,7 +74,7 @@ QImage ModelOfflineRender::toImage(const QSize &size)
glEnable(GL_LINE_SMOOTH);
camera.setToIdentity();
camera.translate(0, 0, -2.5);
camera.translate(0, 0, -2.1);
world.setToIdentity();
world.rotate(180.0f - (xRot / 16.0f), 1, 0, 0);

View File

@ -125,7 +125,7 @@ void ModelWidget::initializeGL()
// Our camera never changes in this example.
m_camera.setToIdentity();
m_camera.translate(0, 0, -3.5);
m_camera.translate(0, 0, -2.1);
// Light position is fixed.
m_program->setUniformValue(m_program->lightPosLoc(), QVector3D(0, 0, 70));

View File

@ -103,35 +103,38 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
m_modelWidget->setGraphicsFunctions(graphicsWidget);
SkeletonPartListWidget *partListWidget = new SkeletonPartListWidget(m_document);
partListWidget->setMaximumWidth(Theme::previewImageSize);
QTabWidget *firstTabWidget = new QTabWidget;
firstTabWidget->setFont(Theme::awesome()->font(Theme::toolIconFontSize * 3 / 4));
firstTabWidget->setMaximumWidth(200);
firstTabWidget->addTab(partListWidget, QChar(fa::puzzlepiece));
firstTabWidget->addTab(new QWidget, QChar(fa::history));
firstTabWidget->addTab(new QWidget, QChar(fa::wrench));
//QTabWidget *firstTabWidget = new QTabWidget;
//firstTabWidget->setFont(Theme::awesome()->font(Theme::toolIconFontSize * 3 / 4));
//firstTabWidget->setMaximumWidth(200);
//firstTabWidget->addTab(partListWidget, QChar(fa::puzzlepiece));
//firstTabWidget->addTab(new QWidget, QChar(fa::history));
//firstTabWidget->addTab(new QWidget, QChar(fa::wrench));
SkeletonEdgePropertyWidget *edgePropertyWidget = new SkeletonEdgePropertyWidget(m_document);
SkeletonNodePropertyWidget *nodePropertyWidget = new SkeletonNodePropertyWidget(m_document);
//SkeletonEdgePropertyWidget *edgePropertyWidget = new SkeletonEdgePropertyWidget(m_document);
//SkeletonNodePropertyWidget *nodePropertyWidget = new SkeletonNodePropertyWidget(m_document);
QVBoxLayout *propertyLayout = new QVBoxLayout;
propertyLayout->addWidget(edgePropertyWidget);
propertyLayout->addWidget(nodePropertyWidget);
//QVBoxLayout *propertyLayout = new QVBoxLayout;
//propertyLayout->addWidget(edgePropertyWidget);
//propertyLayout->addWidget(nodePropertyWidget);
QWidget *propertyWidget = new QWidget;
propertyWidget->setLayout(propertyLayout);
//QWidget *propertyWidget = new QWidget;
//propertyWidget->setLayout(propertyLayout);
QTabWidget *secondTabWidget = new QTabWidget;
secondTabWidget->setFont(Theme::awesome()->font(Theme::toolIconFontSize * 3 / 4));
secondTabWidget->setMaximumWidth(200);
secondTabWidget->setMaximumHeight(90);
secondTabWidget->addTab(propertyWidget, QChar(fa::adjust));
//QTabWidget *secondTabWidget = new QTabWidget;
//secondTabWidget->setFont(Theme::awesome()->font(Theme::toolIconFontSize * 3 / 4));
//secondTabWidget->setMaximumWidth(200);
//secondTabWidget->setMaximumHeight(90);
//secondTabWidget->addTab(propertyWidget, QChar(fa::adjust));
QVBoxLayout *mainRightLayout = new QVBoxLayout;
mainRightLayout->setSpacing(0);
mainRightLayout->setContentsMargins(5, 5, 5, 5);
mainRightLayout->addWidget(firstTabWidget);
mainRightLayout->addWidget(secondTabWidget);
//mainRightLayout->setContentsMargins(5, 5, 5, 5);
mainRightLayout->setContentsMargins(0, 0, 0, 0);
mainRightLayout->addWidget(partListWidget);
//mainRightLayout->addWidget(firstTabWidget);
//mainRightLayout->addWidget(secondTabWidget);
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->setSpacing(0);
@ -194,6 +197,7 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
connect(m_document, &SkeletonDocument::partListChanged, partListWidget, &SkeletonPartListWidget::partListChanged);
connect(m_document, &SkeletonDocument::partPreviewChanged, partListWidget, &SkeletonPartListWidget::partPreviewChanged);
/*
connect(graphicsWidget, &SkeletonGraphicsWidget::checkEdge, edgePropertyWidget, &SkeletonEdgePropertyWidget::showProperties);
connect(graphicsWidget, &SkeletonGraphicsWidget::uncheckEdge, [=](QUuid edgeId) {
edgePropertyWidget->hide();
@ -215,6 +219,7 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
}
});
connect(nodePropertyWidget, &SkeletonNodePropertyWidget::setNodeRootMarkMode, m_document, &SkeletonDocument::setNodeRootMarkMode);
*/
connect(m_document, &SkeletonDocument::skeletonChanged, m_document, &SkeletonDocument::generateMesh);

View File

@ -1,4 +1,5 @@
#include <QGridLayout>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QDebug>
#include "skeletonpartlistwidget.h"
#include "theme.h"
@ -8,18 +9,24 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p
m_partId(partId)
{
m_visibleButton = new QPushButton(QChar(fa::eye));
//m_visibleButton->setStyleSheet("QPushButton {border: none; background: none;}");
m_visibleButton->setFont(Theme::awesome()->font(Theme::toolIconFontSize * 2 / 3));
m_visibleButton->setFixedSize(Theme::toolIconSize * 2 / 3, Theme::toolIconSize * 2 / 3);
m_visibleButton->setStyleSheet("QPushButton {border: none; background: none; color: #cccccc;}");
m_visibleButton->setFont(Theme::awesome()->font(Theme::miniIconFontSize));
m_visibleButton->setFixedSize(Theme::miniIconSize, Theme::miniIconSize);
m_previewLabel = new QLabel;
//m_nameLabel = new QLabel;
QHBoxLayout *miniToolLayout = new QHBoxLayout;
miniToolLayout->setSpacing(0);
miniToolLayout->setContentsMargins(0, 0, 0, 0);
miniToolLayout->addSpacing(3);
miniToolLayout->addWidget(m_visibleButton);
miniToolLayout->addStretch();
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(m_visibleButton, 0, 0);
mainLayout->addWidget(m_previewLabel, 0, 1);
//mainLayout->addWidget(m_nameLabel, 0, 2);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setSpacing(0);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->addLayout(miniToolLayout);
mainLayout->addWidget(m_previewLabel);
setLayout(mainLayout);
}
@ -45,6 +52,8 @@ SkeletonPartListWidget::SkeletonPartListWidget(const SkeletonDocument *document)
{
setSelectionMode(QAbstractItemView::NoSelection);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setSpacing(1);
setContentsMargins(0, 0, 0, 0);
}
void SkeletonPartListWidget::partChanged(QUuid partId)

View File

@ -27,7 +27,9 @@ int Theme::skeletonNodeBorderSize = 0;
int Theme::skeletonEdgeWidth = 0;
int Theme::toolIconFontSize = 16;
int Theme::toolIconSize = 24;
int Theme::previewImageSize = 64;
int Theme::previewImageSize = 48;
int Theme::miniIconFontSize = 8;
int Theme::miniIconSize = 12;
QtAwesome *Theme::awesome()
{

View File

@ -27,6 +27,8 @@ public:
static int toolIconFontSize;
static int toolIconSize;
static int previewImageSize;
static int miniIconFontSize;
static int miniIconSize;
};
#endif