diff --git a/dust3d.pro b/dust3d.pro index 8ad59e0d..0e3ddfe4 100644 --- a/dust3d.pro +++ b/dust3d.pro @@ -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 diff --git a/src/bonedocument.cpp b/src/bonedocument.cpp new file mode 100644 index 00000000..965f206c --- /dev/null +++ b/src/bonedocument.cpp @@ -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 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(); +} diff --git a/src/bonedocument.h b/src/bonedocument.h new file mode 100644 index 00000000..51d78e15 --- /dev/null +++ b/src/bonedocument.h @@ -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 nodeIdSet) const; + void undo(void); + void redo(void); + void paste(void); + void updateTurnaround(const QImage &image); +}; + +#endif diff --git a/src/documentwindow.cpp b/src/documentwindow.cpp index f3c57306..829619e8 100644 --- a/src/documentwindow.cpp +++ b/src/documentwindow.cpp @@ -54,6 +54,7 @@ #include "statusbarlabel.h" #include "silhouetteimagegenerator.h" #include "flowlayout.h" +#include "bonedocument.h" int DocumentWindow::m_autoRecovered = false; @@ -206,6 +207,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); @@ -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; diff --git a/src/documentwindow.h b/src/documentwindow.h index c218299d..69ff8725 100644 --- a/src/documentwindow.h +++ b/src/documentwindow.h @@ -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;