Make part list more tidy
parent
af451bd5ab
commit
65b14200a5
|
@ -189,7 +189,8 @@ void MeshGenerator::process()
|
||||||
qDebug() << "m_requirePartPreviewMap.find:" << partIdIt;
|
qDebug() << "m_requirePartPreviewMap.find:" << partIdIt;
|
||||||
if (m_requirePartPreviewMap.find(partIdIt) != m_requirePartPreviewMap.end()) {
|
if (m_requirePartPreviewMap.find(partIdIt) != m_requirePartPreviewMap.end()) {
|
||||||
ModelOfflineRender *render = m_partPreviewRenderMap[partIdIt];
|
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)));
|
QImage *image = new QImage(render->toImage(QSize(Theme::previewImageSize, Theme::previewImageSize)));
|
||||||
m_partPreviewMap[partIdIt] = image;
|
m_partPreviewMap[partIdIt] = image;
|
||||||
}
|
}
|
||||||
|
@ -211,7 +212,8 @@ void MeshGenerator::process()
|
||||||
QImage *image = new QImage(m_previewRender->toImage(QSize(Theme::previewImageSize, Theme::previewImageSize)));
|
QImage *image = new QImage(m_previewRender->toImage(QSize(Theme::previewImageSize, Theme::previewImageSize)));
|
||||||
m_preview = image;
|
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) {
|
if (m_previewRender) {
|
||||||
|
|
|
@ -8,7 +8,8 @@ ModelMeshBinder::ModelMeshBinder() :
|
||||||
m_renderTriangleVertexCount(0),
|
m_renderTriangleVertexCount(0),
|
||||||
m_renderEdgeVertexCount(0),
|
m_renderEdgeVertexCount(0),
|
||||||
m_mesh(NULL),
|
m_mesh(NULL),
|
||||||
m_meshUpdated(false)
|
m_meshUpdated(false),
|
||||||
|
m_showFrames(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,10 +104,12 @@ void ModelMeshBinder::paint()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_showFrames) {
|
||||||
if (m_renderEdgeVertexCount > 0) {
|
if (m_renderEdgeVertexCount > 0) {
|
||||||
QOpenGLVertexArrayObject::Binder vaoBinder(&m_vaoEdge);
|
QOpenGLVertexArrayObject::Binder vaoBinder(&m_vaoEdge);
|
||||||
glDrawArrays(GL_LINES, 0, m_renderEdgeVertexCount);
|
glDrawArrays(GL_LINES, 0, m_renderEdgeVertexCount);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (m_renderTriangleVertexCount > 0) {
|
if (m_renderTriangleVertexCount > 0) {
|
||||||
QOpenGLVertexArrayObject::Binder vaoBinder(&m_vaoTriangle);
|
QOpenGLVertexArrayObject::Binder vaoBinder(&m_vaoTriangle);
|
||||||
glDrawArrays(GL_TRIANGLES, 0, m_renderTriangleVertexCount);
|
glDrawArrays(GL_TRIANGLES, 0, m_renderTriangleVertexCount);
|
||||||
|
@ -120,3 +123,13 @@ void ModelMeshBinder::cleanup()
|
||||||
if (m_vboEdge.isCreated())
|
if (m_vboEdge.isCreated())
|
||||||
m_vboEdge.destroy();
|
m_vboEdge.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModelMeshBinder::showFrames()
|
||||||
|
{
|
||||||
|
m_showFrames = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ModelMeshBinder::hideFrames()
|
||||||
|
{
|
||||||
|
m_showFrames = false;
|
||||||
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@ public:
|
||||||
void initialize();
|
void initialize();
|
||||||
void paint();
|
void paint();
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
void showFrames();
|
||||||
|
void hideFrames();
|
||||||
private:
|
private:
|
||||||
QOpenGLVertexArrayObject m_vaoTriangle;
|
QOpenGLVertexArrayObject m_vaoTriangle;
|
||||||
QOpenGLBuffer m_vboTriangle;
|
QOpenGLBuffer m_vboTriangle;
|
||||||
|
@ -26,6 +28,7 @@ private:
|
||||||
int m_renderTriangleVertexCount;
|
int m_renderTriangleVertexCount;
|
||||||
int m_renderEdgeVertexCount;
|
int m_renderEdgeVertexCount;
|
||||||
bool m_meshUpdated;
|
bool m_meshUpdated;
|
||||||
|
bool m_showFrames;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -10,7 +10,14 @@ ModelOfflineRender::ModelOfflineRender(QScreen *targetScreen) :
|
||||||
{
|
{
|
||||||
create();
|
create();
|
||||||
m_context = new QOpenGLContext();
|
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();
|
m_context->create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +48,7 @@ QImage ModelOfflineRender::toImage(const QSize &size)
|
||||||
|
|
||||||
QOpenGLFramebufferObjectFormat format;
|
QOpenGLFramebufferObjectFormat format;
|
||||||
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
|
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
|
||||||
|
format.setSamples(16);
|
||||||
QOpenGLFramebufferObject *renderFbo = new QOpenGLFramebufferObject(size, format);
|
QOpenGLFramebufferObject *renderFbo = new QOpenGLFramebufferObject(size, format);
|
||||||
renderFbo->bind();
|
renderFbo->bind();
|
||||||
m_context->functions()->glViewport(0, 0, size.width(), size.height());
|
m_context->functions()->glViewport(0, 0, size.width(), size.height());
|
||||||
|
@ -56,6 +64,7 @@ QImage ModelOfflineRender::toImage(const QSize &size)
|
||||||
ModelShaderProgram *program = new ModelShaderProgram;
|
ModelShaderProgram *program = new ModelShaderProgram;
|
||||||
ModelMeshBinder meshBinder;
|
ModelMeshBinder meshBinder;
|
||||||
meshBinder.initialize();
|
meshBinder.initialize();
|
||||||
|
meshBinder.hideFrames();
|
||||||
|
|
||||||
program->setUniformValue(program->lightPosLoc(), QVector3D(0, 0, 70));
|
program->setUniformValue(program->lightPosLoc(), QVector3D(0, 0, 70));
|
||||||
|
|
||||||
|
@ -65,7 +74,7 @@ QImage ModelOfflineRender::toImage(const QSize &size)
|
||||||
glEnable(GL_LINE_SMOOTH);
|
glEnable(GL_LINE_SMOOTH);
|
||||||
|
|
||||||
camera.setToIdentity();
|
camera.setToIdentity();
|
||||||
camera.translate(0, 0, -2.5);
|
camera.translate(0, 0, -2.1);
|
||||||
|
|
||||||
world.setToIdentity();
|
world.setToIdentity();
|
||||||
world.rotate(180.0f - (xRot / 16.0f), 1, 0, 0);
|
world.rotate(180.0f - (xRot / 16.0f), 1, 0, 0);
|
||||||
|
|
|
@ -125,7 +125,7 @@ void ModelWidget::initializeGL()
|
||||||
|
|
||||||
// Our camera never changes in this example.
|
// Our camera never changes in this example.
|
||||||
m_camera.setToIdentity();
|
m_camera.setToIdentity();
|
||||||
m_camera.translate(0, 0, -3.5);
|
m_camera.translate(0, 0, -2.1);
|
||||||
|
|
||||||
// Light position is fixed.
|
// Light position is fixed.
|
||||||
m_program->setUniformValue(m_program->lightPosLoc(), QVector3D(0, 0, 70));
|
m_program->setUniformValue(m_program->lightPosLoc(), QVector3D(0, 0, 70));
|
||||||
|
|
|
@ -103,35 +103,38 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
|
||||||
m_modelWidget->setGraphicsFunctions(graphicsWidget);
|
m_modelWidget->setGraphicsFunctions(graphicsWidget);
|
||||||
|
|
||||||
SkeletonPartListWidget *partListWidget = new SkeletonPartListWidget(m_document);
|
SkeletonPartListWidget *partListWidget = new SkeletonPartListWidget(m_document);
|
||||||
|
partListWidget->setMaximumWidth(Theme::previewImageSize);
|
||||||
|
|
||||||
QTabWidget *firstTabWidget = new QTabWidget;
|
//QTabWidget *firstTabWidget = new QTabWidget;
|
||||||
firstTabWidget->setFont(Theme::awesome()->font(Theme::toolIconFontSize * 3 / 4));
|
//firstTabWidget->setFont(Theme::awesome()->font(Theme::toolIconFontSize * 3 / 4));
|
||||||
firstTabWidget->setMaximumWidth(200);
|
//firstTabWidget->setMaximumWidth(200);
|
||||||
firstTabWidget->addTab(partListWidget, QChar(fa::puzzlepiece));
|
//firstTabWidget->addTab(partListWidget, QChar(fa::puzzlepiece));
|
||||||
firstTabWidget->addTab(new QWidget, QChar(fa::history));
|
//firstTabWidget->addTab(new QWidget, QChar(fa::history));
|
||||||
firstTabWidget->addTab(new QWidget, QChar(fa::wrench));
|
//firstTabWidget->addTab(new QWidget, QChar(fa::wrench));
|
||||||
|
|
||||||
SkeletonEdgePropertyWidget *edgePropertyWidget = new SkeletonEdgePropertyWidget(m_document);
|
//SkeletonEdgePropertyWidget *edgePropertyWidget = new SkeletonEdgePropertyWidget(m_document);
|
||||||
SkeletonNodePropertyWidget *nodePropertyWidget = new SkeletonNodePropertyWidget(m_document);
|
//SkeletonNodePropertyWidget *nodePropertyWidget = new SkeletonNodePropertyWidget(m_document);
|
||||||
|
|
||||||
QVBoxLayout *propertyLayout = new QVBoxLayout;
|
//QVBoxLayout *propertyLayout = new QVBoxLayout;
|
||||||
propertyLayout->addWidget(edgePropertyWidget);
|
//propertyLayout->addWidget(edgePropertyWidget);
|
||||||
propertyLayout->addWidget(nodePropertyWidget);
|
//propertyLayout->addWidget(nodePropertyWidget);
|
||||||
|
|
||||||
QWidget *propertyWidget = new QWidget;
|
//QWidget *propertyWidget = new QWidget;
|
||||||
propertyWidget->setLayout(propertyLayout);
|
//propertyWidget->setLayout(propertyLayout);
|
||||||
|
|
||||||
QTabWidget *secondTabWidget = new QTabWidget;
|
//QTabWidget *secondTabWidget = new QTabWidget;
|
||||||
secondTabWidget->setFont(Theme::awesome()->font(Theme::toolIconFontSize * 3 / 4));
|
//secondTabWidget->setFont(Theme::awesome()->font(Theme::toolIconFontSize * 3 / 4));
|
||||||
secondTabWidget->setMaximumWidth(200);
|
//secondTabWidget->setMaximumWidth(200);
|
||||||
secondTabWidget->setMaximumHeight(90);
|
//secondTabWidget->setMaximumHeight(90);
|
||||||
secondTabWidget->addTab(propertyWidget, QChar(fa::adjust));
|
//secondTabWidget->addTab(propertyWidget, QChar(fa::adjust));
|
||||||
|
|
||||||
QVBoxLayout *mainRightLayout = new QVBoxLayout;
|
QVBoxLayout *mainRightLayout = new QVBoxLayout;
|
||||||
mainRightLayout->setSpacing(0);
|
mainRightLayout->setSpacing(0);
|
||||||
mainRightLayout->setContentsMargins(5, 5, 5, 5);
|
//mainRightLayout->setContentsMargins(5, 5, 5, 5);
|
||||||
mainRightLayout->addWidget(firstTabWidget);
|
mainRightLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
mainRightLayout->addWidget(secondTabWidget);
|
mainRightLayout->addWidget(partListWidget);
|
||||||
|
//mainRightLayout->addWidget(firstTabWidget);
|
||||||
|
//mainRightLayout->addWidget(secondTabWidget);
|
||||||
|
|
||||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||||
mainLayout->setSpacing(0);
|
mainLayout->setSpacing(0);
|
||||||
|
@ -194,6 +197,7 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
|
||||||
connect(m_document, &SkeletonDocument::partListChanged, partListWidget, &SkeletonPartListWidget::partListChanged);
|
connect(m_document, &SkeletonDocument::partListChanged, partListWidget, &SkeletonPartListWidget::partListChanged);
|
||||||
connect(m_document, &SkeletonDocument::partPreviewChanged, partListWidget, &SkeletonPartListWidget::partPreviewChanged);
|
connect(m_document, &SkeletonDocument::partPreviewChanged, partListWidget, &SkeletonPartListWidget::partPreviewChanged);
|
||||||
|
|
||||||
|
/*
|
||||||
connect(graphicsWidget, &SkeletonGraphicsWidget::checkEdge, edgePropertyWidget, &SkeletonEdgePropertyWidget::showProperties);
|
connect(graphicsWidget, &SkeletonGraphicsWidget::checkEdge, edgePropertyWidget, &SkeletonEdgePropertyWidget::showProperties);
|
||||||
connect(graphicsWidget, &SkeletonGraphicsWidget::uncheckEdge, [=](QUuid edgeId) {
|
connect(graphicsWidget, &SkeletonGraphicsWidget::uncheckEdge, [=](QUuid edgeId) {
|
||||||
edgePropertyWidget->hide();
|
edgePropertyWidget->hide();
|
||||||
|
@ -215,6 +219,7 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() :
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(nodePropertyWidget, &SkeletonNodePropertyWidget::setNodeRootMarkMode, m_document, &SkeletonDocument::setNodeRootMarkMode);
|
connect(nodePropertyWidget, &SkeletonNodePropertyWidget::setNodeRootMarkMode, m_document, &SkeletonDocument::setNodeRootMarkMode);
|
||||||
|
*/
|
||||||
|
|
||||||
connect(m_document, &SkeletonDocument::skeletonChanged, m_document, &SkeletonDocument::generateMesh);
|
connect(m_document, &SkeletonDocument::skeletonChanged, m_document, &SkeletonDocument::generateMesh);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <QGridLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QHBoxLayout>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "skeletonpartlistwidget.h"
|
#include "skeletonpartlistwidget.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
|
@ -8,18 +9,24 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p
|
||||||
m_partId(partId)
|
m_partId(partId)
|
||||||
{
|
{
|
||||||
m_visibleButton = new QPushButton(QChar(fa::eye));
|
m_visibleButton = new QPushButton(QChar(fa::eye));
|
||||||
//m_visibleButton->setStyleSheet("QPushButton {border: none; background: none;}");
|
m_visibleButton->setStyleSheet("QPushButton {border: none; background: none; color: #cccccc;}");
|
||||||
m_visibleButton->setFont(Theme::awesome()->font(Theme::toolIconFontSize * 2 / 3));
|
m_visibleButton->setFont(Theme::awesome()->font(Theme::miniIconFontSize));
|
||||||
m_visibleButton->setFixedSize(Theme::toolIconSize * 2 / 3, Theme::toolIconSize * 2 / 3);
|
m_visibleButton->setFixedSize(Theme::miniIconSize, Theme::miniIconSize);
|
||||||
|
|
||||||
m_previewLabel = new QLabel;
|
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;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addWidget(m_visibleButton, 0, 0);
|
mainLayout->setSpacing(0);
|
||||||
mainLayout->addWidget(m_previewLabel, 0, 1);
|
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
//mainLayout->addWidget(m_nameLabel, 0, 2);
|
mainLayout->addLayout(miniToolLayout);
|
||||||
|
mainLayout->addWidget(m_previewLabel);
|
||||||
|
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
}
|
}
|
||||||
|
@ -45,6 +52,8 @@ SkeletonPartListWidget::SkeletonPartListWidget(const SkeletonDocument *document)
|
||||||
{
|
{
|
||||||
setSelectionMode(QAbstractItemView::NoSelection);
|
setSelectionMode(QAbstractItemView::NoSelection);
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
setSpacing(1);
|
||||||
|
setContentsMargins(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonPartListWidget::partChanged(QUuid partId)
|
void SkeletonPartListWidget::partChanged(QUuid partId)
|
||||||
|
|
|
@ -27,7 +27,9 @@ int Theme::skeletonNodeBorderSize = 0;
|
||||||
int Theme::skeletonEdgeWidth = 0;
|
int Theme::skeletonEdgeWidth = 0;
|
||||||
int Theme::toolIconFontSize = 16;
|
int Theme::toolIconFontSize = 16;
|
||||||
int Theme::toolIconSize = 24;
|
int Theme::toolIconSize = 24;
|
||||||
int Theme::previewImageSize = 64;
|
int Theme::previewImageSize = 48;
|
||||||
|
int Theme::miniIconFontSize = 8;
|
||||||
|
int Theme::miniIconSize = 12;
|
||||||
|
|
||||||
QtAwesome *Theme::awesome()
|
QtAwesome *Theme::awesome()
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,6 +27,8 @@ public:
|
||||||
static int toolIconFontSize;
|
static int toolIconFontSize;
|
||||||
static int toolIconSize;
|
static int toolIconSize;
|
||||||
static int previewImageSize;
|
static int previewImageSize;
|
||||||
|
static int miniIconFontSize;
|
||||||
|
static int miniIconSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue