Add bone document

master
huxingyi 2020-12-16 23:41:21 +09:30
parent 2495969f87
commit fac30fc6a4
5 changed files with 128 additions and 1 deletions

View File

@ -535,6 +535,9 @@ HEADERS += src/statusbarlabel.h
SOURCES += src/silhouetteimagegenerator.cpp
HEADERS += src/silhouetteimagegenerator.h
SOURCES += src/bonedocument.cpp
HEADERS += src/bonedocument.h
SOURCES += src/main.cpp
HEADERS += src/version.h

62
src/bonedocument.cpp Normal file
View File

@ -0,0 +1,62 @@
#include "bonedocument.h"
BoneDocument::BoneDocument()
{
}
bool BoneDocument::undoable(void) const
{
return false;
}
bool BoneDocument::redoable(void) const
{
return false;
}
bool BoneDocument::hasPastableNodesInClipboard(void) const
{
return false;
}
bool BoneDocument::originSettled(void) const
{
return false;
}
bool BoneDocument::isNodeEditable(QUuid) const
{
return false;
}
bool BoneDocument::isEdgeEditable(QUuid) const
{
return false;
}
void BoneDocument::copyNodes(std::set<QUuid> nodeIdSet) const
{
// TODO:
}
void BoneDocument::undo(void)
{
// TODO:
}
void BoneDocument::redo(void)
{
// TODO:
}
void BoneDocument::paste(void)
{
// TODO:
}
void BoneDocument::updateTurnaround(const QImage &image)
{
turnaround = image;
emit turnaroundChanged();
}

25
src/bonedocument.h Normal file
View File

@ -0,0 +1,25 @@
#ifndef DUST3D_BONE_DOCUMENT_H
#define DUST3D_BONE_DOCUMENT_H
#include "skeletondocument.h"
class BoneDocument : public SkeletonDocument
{
Q_OBJECT
signals:
void turnaroundChanged();
public:
BoneDocument();
bool undoable(void) const;
bool redoable(void) const;
bool hasPastableNodesInClipboard(void) const;
bool originSettled(void) const;
bool isNodeEditable(QUuid) const;
bool isEdgeEditable(QUuid) const;
void copyNodes(std::set<QUuid> nodeIdSet) const;
void undo(void);
void redo(void);
void paste(void);
void updateTurnaround(const QImage &image);
};
#endif

View File

@ -54,6 +54,7 @@
#include "statusbarlabel.h"
#include "silhouetteimagegenerator.h"
#include "flowlayout.h"
#include "bonedocument.h"
int DocumentWindow::m_autoRecovered = false;
@ -207,6 +208,11 @@ DocumentWindow::DocumentWindow() :
SkeletonGraphicsWidget *shapeGraphicsWidget = new SkeletonGraphicsWidget(m_document);
m_shapeGraphicsWidget = shapeGraphicsWidget;
m_boneDocument = new BoneDocument;
SkeletonGraphicsWidget *boneGraphicsWidget = new SkeletonGraphicsWidget(m_boneDocument);
m_boneGraphicsWidget = boneGraphicsWidget;
QVBoxLayout *toolButtonLayout = new QVBoxLayout;
toolButtonLayout->setSpacing(0);
toolButtonLayout->setContentsMargins(5, 10, 4, 0);
@ -323,8 +329,18 @@ DocumentWindow::DocumentWindow() :
shapeGraphicsLayout->addWidget(shapeGraphicsWidget);
shapeWidget->setLayout(shapeGraphicsLayout);
QWidget *boneWidget = new QWidget;
QGridLayout *boneGraphicsLayout = new QGridLayout;
boneGraphicsLayout->setSpacing(0);
boneGraphicsLayout->setContentsMargins(0, 0, 0, 0);
boneGraphicsLayout->addWidget(boneGraphicsWidget);
boneWidget->setLayout(boneGraphicsLayout);
QStackedWidget *canvasStackedWidget = new QStackedWidget;
canvasStackedWidget->addWidget(boneWidget);
canvasStackedWidget->addWidget(shapeWidget);
canvasStackedWidget->setCurrentIndex(1);
GraphicsContainerWidget *containerWidget = new GraphicsContainerWidget;
containerWidget->setGraphicsWidget(shapeGraphicsWidget);
@ -338,6 +354,17 @@ DocumentWindow::DocumentWindow() :
containerWidget->setAutoFillBackground(true);
containerWidget->setPalette(Theme::statusBarActivePalette);
auto setGraphicsIndex = [=](int index) {
canvasStackedWidget->setCurrentIndex(index);
if (0 == index) {
containerWidget->setGraphicsWidget(boneGraphicsWidget);
boneGraphicsWidget->canvasResized();
} else if (1 == index) {
containerWidget->setGraphicsWidget(shapeGraphicsWidget);
shapeGraphicsWidget->canvasResized();
}
};
m_graphicsContainerWidget = containerWidget;
m_modelRenderWidget = new ModelWidget(containerWidget);
@ -386,6 +413,7 @@ DocumentWindow::DocumentWindow() :
connect(m_modelRenderWidget, &ModelWidget::renderParametersChanged, this, &DocumentWindow::delayedGenerateNormalAndDepthMaps);
m_shapeGraphicsWidget->setModelWidget(m_modelRenderWidget);
m_boneGraphicsWidget->setModelWidget(m_modelRenderWidget);
containerWidget->setModelWidget(m_modelRenderWidget);
setTabPosition(Qt::RightDockWidgetArea, QTabWidget::East);
@ -519,11 +547,13 @@ DocumentWindow::DocumentWindow() :
connect(boneLabel, &StatusBarLabel::clicked, this, [=]() {
boneLabel->setSelected(true);
shapeLabel->setSelected(false);
setGraphicsIndex(0);
updateGraphicsViewEditTarget(GraphicsViewEditTarget::Bone);
});
connect(shapeLabel, &StatusBarLabel::clicked, this, [=]() {
shapeLabel->setSelected(true);
boneLabel->setSelected(false);
setGraphicsIndex(1);
updateGraphicsViewEditTarget(GraphicsViewEditTarget::Shape);
});
@ -808,9 +838,13 @@ DocumentWindow::DocumentWindow() :
connect(containerWidget, &GraphicsContainerWidget::containerSizeChanged,
shapeGraphicsWidget, &SkeletonGraphicsWidget::canvasResized);
connect(containerWidget, &GraphicsContainerWidget::containerSizeChanged,
boneGraphicsWidget, &SkeletonGraphicsWidget::canvasResized);
connect(m_document, &Document::turnaroundChanged,
shapeGraphicsWidget, &SkeletonGraphicsWidget::turnaroundChanged);
connect(m_boneDocument, &BoneDocument::turnaroundChanged,
boneGraphicsWidget, &SkeletonGraphicsWidget::turnaroundChanged);
connect(addButton, &QPushButton::clicked, [=]() {
m_document->setEditMode(SkeletonDocumentEditMode::Add);
@ -2411,7 +2445,7 @@ void DocumentWindow::silhouetteImageReady()
{
QImage *image = m_silhouetteImageGenerator->takeResultImage();
if (nullptr != image)
image->save("test.png");
m_boneDocument->updateTurnaround(*image);
delete image;
delete m_silhouetteImageGenerator;

View File

@ -25,6 +25,7 @@ class SkeletonGraphicsWidget;
class PartTreeWidget;
class SpinnableAwesomeButton;
class SilhouetteImageGenerator;
class BoneDocument;
class DocumentWindow : public QMainWindow
{
@ -123,6 +124,7 @@ private:
void createPartSnapshotForFillMesh(const QUuid &fillMeshFileId, Snapshot *snapshot);
private:
Document *m_document;
BoneDocument *m_boneDocument;
bool m_firstShow;
bool m_documentSaved;
PreferencesWidget *m_preferencesWidget;
@ -136,6 +138,7 @@ private:
ModelWidget *m_modelRenderWidget;
SkeletonGraphicsWidget *m_shapeGraphicsWidget;
SkeletonGraphicsWidget *m_boneGraphicsWidget;
RigWidget *m_rigWidget;
GraphicsContainerWidget *m_graphicsContainerWidget;