From 208d2a0166f34de8073cb57eba5be9fea09c1f5e Mon Sep 17 00:00:00 2001 From: Jeremy Hu Date: Thu, 25 Oct 2018 08:19:38 +0800 Subject: [PATCH] Cleanup Many source file name and data type are prefixed by "skeleton" before, now all are refactored. The class MeshResultContext represents the outcome of mesh generation before, now we have material, pose and animation, so we just rename it as Outcome. --- dust3d.pro | 39 +- src/aboutwidget.cpp | 2 +- src/aboutwidget.h | 4 +- src/advancesettingwidget.cpp | 6 +- src/advancesettingwidget.h | 10 +- src/ambientocclusionbaker.cpp | 10 +- src/ambientocclusionbaker.h | 10 +- src/anglesmooth.cpp | 2 +- src/anglesmooth.h | 4 +- src/animationclipplayer.h | 4 +- src/autorigger.cpp | 99 ++-- src/autorigger.h | 15 +- src/bonemark.cpp | 7 + src/bonemark.h | 117 +++++ src/ccdikresolver.cpp | 2 +- src/ccdikresolver.h | 4 +- src/{skeletondocument.cpp => document.cpp} | 487 +++++++++--------- src/{skeletondocument.h => document.h} | 182 +++---- ...ndocumentwindow.cpp => documentwindow.cpp} | 332 ++++++------ ...letondocumentwindow.h => documentwindow.h} | 12 +- src/ds3file.h | 4 +- src/exportpreviewwidget.cpp | 4 +- src/exportpreviewwidget.h | 10 +- src/fbxfile.cpp | 8 +- src/fbxfile.h | 10 +- src/floatnumberwidget.h | 4 +- src/flowlayout.h | 6 +- src/gltffile.cpp | 10 +- src/gltffile.h | 10 +- src/graphicscontainerwidget.h | 4 +- src/imageforever.h | 4 +- src/infolabel.h | 4 +- src/interpolationtype.h | 4 +- src/jointnodetree.cpp | 2 +- src/jointnodetree.h | 4 +- src/logbrowser.h | 4 +- src/logbrowserdialog.cpp | 2 +- src/logbrowserdialog.h | 4 +- src/main.cpp | 2 +- src/markiconcreator.cpp | 6 +- src/markiconcreator.h | 10 +- src/material.cpp | 4 +- src/material.h | 14 +- src/materialeditwidget.cpp | 16 +- src/materialeditwidget.h | 18 +- src/materiallistwidget.cpp | 16 +- src/materiallistwidget.h | 10 +- src/materialmanagewidget.cpp | 4 +- src/materialmanagewidget.h | 10 +- src/materialpreviewsgenerator.cpp | 12 +- src/materialpreviewsgenerator.h | 10 +- src/materialwidget.cpp | 10 +- src/materialwidget.h | 10 +- src/meshgenerator.cpp | 50 +- src/meshgenerator.h | 24 +- src/meshloader.cpp | 12 +- src/meshloader.h | 10 +- src/meshquadify.h | 4 +- src/meshresultpostprocessor.cpp | 22 +- src/meshresultpostprocessor.h | 12 +- src/meshsplitter.h | 4 +- src/meshutil.h | 4 +- src/meshweldseam.h | 4 +- src/modelmeshbinder.h | 4 +- src/modelshaderprogram.h | 4 +- src/modelwidget.cpp | 2 +- src/modelwidget.h | 4 +- src/motionclipwidget.cpp | 16 +- src/motionclipwidget.h | 14 +- src/motioneditwidget.cpp | 14 +- src/motioneditwidget.h | 16 +- src/motionlistwidget.cpp | 16 +- src/motionlistwidget.h | 10 +- src/motionmanagewidget.cpp | 8 +- src/motionmanagewidget.h | 10 +- src/motionsgenerator.cpp | 48 +- src/motionsgenerator.h | 20 +- src/motiontimelinewidget.cpp | 38 +- src/motiontimelinewidget.h | 18 +- src/motionwidget.cpp | 10 +- src/motionwidget.h | 10 +- src/{meshresultcontext.cpp => outcome.cpp} | 52 +- src/{meshresultcontext.h => outcome.h} | 68 +-- ...nparttreewidget.cpp => parttreewidget.cpp} | 138 ++--- ...letonparttreewidget.h => parttreewidget.h} | 12 +- ...{skeletonpartwidget.cpp => partwidget.cpp} | 120 ++--- src/{skeletonpartwidget.h => partwidget.h} | 12 +- src/poseeditwidget.cpp | 12 +- src/poseeditwidget.h | 10 +- src/poselistwidget.cpp | 16 +- src/poselistwidget.h | 10 +- src/posemanagewidget.cpp | 8 +- src/posemanagewidget.h | 10 +- src/posemeshcreator.cpp | 6 +- src/posemeshcreator.h | 10 +- src/posepreviewmanager.cpp | 4 +- src/posepreviewmanager.h | 8 +- src/posepreviewsgenerator.cpp | 8 +- src/posepreviewsgenerator.h | 10 +- src/poser.h | 6 +- src/posewidget.cpp | 10 +- src/posewidget.h | 10 +- src/positionmap.h | 4 +- src/qtlightmapper.h | 7 +- src/riggenerator.cpp | 42 +- src/riggenerator.h | 12 +- src/rigtype.h | 4 +- src/rigwidget.cpp | 2 +- src/rigwidget.h | 10 +- src/shortcuts.h | 4 +- src/skeletonbonemark.cpp | 9 - src/skeletonbonemark.h | 140 ----- src/skeletongraphicswidget.cpp | 194 +++---- src/skeletongraphicswidget.h | 20 +- src/skeletonikmover.h | 4 +- src/skeletonside.cpp | 4 + src/skeletonside.h | 28 + src/skeletonxml.h | 9 - src/skinnedmeshcreator.cpp | 20 +- src/skinnedmeshcreator.h | 10 +- src/{skeletonsnapshot.cpp => snapshot.cpp} | 6 +- src/{skeletonsnapshot.h => snapshot.h} | 6 +- src/{skeletonxml.cpp => snapshotxml.cpp} | 8 +- src/snapshotxml.h | 9 + src/spinnableawesomebutton.h | 4 +- src/tabwidget.h | 4 +- src/tetrapodposer.h | 4 +- src/texturegenerator.cpp | 30 +- src/texturegenerator.h | 14 +- src/texturetype.h | 4 +- src/theme.h | 4 +- src/turnaroundloader.h | 4 +- src/{dust3dutil.cpp => util.cpp} | 2 +- src/{dust3dutil.h => util.h} | 0 src/version.h | 4 +- 135 files changed, 1593 insertions(+), 1579 deletions(-) create mode 100644 src/bonemark.cpp create mode 100644 src/bonemark.h rename src/{skeletondocument.cpp => document.cpp} (85%) rename src/{skeletondocument.h => document.h} (84%) rename src/{skeletondocumentwindow.cpp => documentwindow.cpp} (75%) rename src/{skeletondocumentwindow.h => documentwindow.h} (95%) rename src/{meshresultcontext.cpp => outcome.cpp} (89%) rename src/{meshresultcontext.h => outcome.h} (66%) rename src/{skeletonparttreewidget.cpp => parttreewidget.cpp} (85%) rename src/{skeletonparttreewidget.h => parttreewidget.h} (92%) rename src/{skeletonpartwidget.cpp => partwidget.cpp} (77%) rename src/{skeletonpartwidget.h => partwidget.h} (91%) delete mode 100644 src/skeletonbonemark.cpp delete mode 100644 src/skeletonbonemark.h create mode 100644 src/skeletonside.cpp create mode 100644 src/skeletonside.h delete mode 100644 src/skeletonxml.h rename src/{skeletonsnapshot.cpp => snapshot.cpp} (92%) rename src/{skeletonsnapshot.h => snapshot.h} (93%) rename src/{skeletonxml.cpp => snapshotxml.cpp} (98%) create mode 100644 src/snapshotxml.h rename src/{dust3dutil.cpp => util.cpp} (99%) rename src/{dust3dutil.h => util.h} (100%) diff --git a/dust3d.pro b/dust3d.pro index 70c28268..03117592 100644 --- a/dust3d.pro +++ b/dust3d.pro @@ -48,20 +48,20 @@ HEADERS += src/modelmeshbinder.h SOURCES += src/modelwidget.cpp HEADERS += src/modelwidget.h -SOURCES += src/skeletondocument.cpp -HEADERS += src/skeletondocument.h +SOURCES += src/document.cpp +HEADERS += src/document.h -SOURCES += src/skeletondocumentwindow.cpp -HEADERS += src/skeletondocumentwindow.h +SOURCES += src/documentwindow.cpp +HEADERS += src/documentwindow.h SOURCES += src/skeletongraphicswidget.cpp HEADERS += src/skeletongraphicswidget.h -SOURCES += src/skeletonparttreewidget.cpp -HEADERS += src/skeletonparttreewidget.h +SOURCES += src/parttreewidget.cpp +HEADERS += src/parttreewidget.h -SOURCES += src/skeletonpartwidget.cpp -HEADERS += src/skeletonpartwidget.h +SOURCES += src/partwidget.cpp +HEADERS += src/partwidget.h SOURCES += src/aboutwidget.cpp HEADERS += src/aboutwidget.h @@ -69,17 +69,17 @@ HEADERS += src/aboutwidget.h SOURCES += src/meshgenerator.cpp HEADERS += src/meshgenerator.h -SOURCES += src/dust3dutil.cpp -HEADERS += src/dust3dutil.h +SOURCES += src/util.cpp +HEADERS += src/util.h SOURCES += src/turnaroundloader.cpp HEADERS += src/turnaroundloader.h -SOURCES += src/skeletonsnapshot.cpp -HEADERS += src/skeletonsnapshot.h +SOURCES += src/snapshot.cpp +HEADERS += src/snapshot.h -SOURCES += src/skeletonxml.cpp -HEADERS += src/skeletonxml.h +SOURCES += src/snapshotxml.cpp +HEADERS += src/snapshotxml.h SOURCES += src/ds3file.cpp HEADERS += src/ds3file.h @@ -99,8 +99,8 @@ HEADERS += src/meshutil.h SOURCES += src/texturegenerator.cpp HEADERS += src/texturegenerator.h -SOURCES += src/meshresultcontext.cpp -HEADERS += src/meshresultcontext.h +SOURCES += src/outcome.cpp +HEADERS += src/outcome.h SOURCES += src/meshresultpostprocessor.cpp HEADERS += src/meshresultpostprocessor.h @@ -146,8 +146,11 @@ HEADERS += src/rigwidget.h SOURCES += src/markiconcreator.cpp HEADERS += src/markiconcreator.h -SOURCES += src/skeletonbonemark.cpp -HEADERS += src/skeletonbonemark.h +SOURCES += src/bonemark.cpp +HEADERS += src/bonemark.h + +SOURCES += src/skeletonside.cpp +HEADERS += src/skeletonside.h SOURCES += src/meshsplitter.cpp HEADERS += src/meshsplitter.h diff --git a/src/aboutwidget.cpp b/src/aboutwidget.cpp index a7cb7c43..edc6e0c8 100644 --- a/src/aboutwidget.cpp +++ b/src/aboutwidget.cpp @@ -3,7 +3,7 @@ #include #include "aboutwidget.h" #include "version.h" -#include "dust3dutil.h" +#include "util.h" AboutWidget::AboutWidget() { diff --git a/src/aboutwidget.h b/src/aboutwidget.h index 5524f7f7..f5b47a81 100644 --- a/src/aboutwidget.h +++ b/src/aboutwidget.h @@ -1,5 +1,5 @@ -#ifndef ABOUT_WIDGET_H -#define ABOUT_WIDGET_H +#ifndef DUST3D_ABOUT_WIDGET_H +#define DUST3D_ABOUT_WIDGET_H #include class AboutWidget : public QDialog diff --git a/src/advancesettingwidget.cpp b/src/advancesettingwidget.cpp index 90dca994..95ac627f 100644 --- a/src/advancesettingwidget.cpp +++ b/src/advancesettingwidget.cpp @@ -1,9 +1,9 @@ #include #include #include "advancesettingwidget.h" -#include "dust3dutil.h" +#include "util.h" -AdvanceSettingWidget::AdvanceSettingWidget(const SkeletonDocument *document, QWidget *parent) : +AdvanceSettingWidget::AdvanceSettingWidget(const Document *document, QWidget *parent) : QDialog(parent), m_document(document) { @@ -18,5 +18,5 @@ AdvanceSettingWidget::AdvanceSettingWidget(const SkeletonDocument *document, QWi setLayout(formLayout); - connect(this, &AdvanceSettingWidget::enableWeld, document, &SkeletonDocument::enableWeld); + connect(this, &AdvanceSettingWidget::enableWeld, document, &Document::enableWeld); } diff --git a/src/advancesettingwidget.h b/src/advancesettingwidget.h index e9d3261a..48d3bd89 100644 --- a/src/advancesettingwidget.h +++ b/src/advancesettingwidget.h @@ -1,7 +1,7 @@ -#ifndef ADVANCE_SETTING_WIDGET_H -#define ADVANCE_SETTING_WIDGET_H +#ifndef DUST3D_ADVANCE_SETTING_WIDGET_H +#define DUST3D_ADVANCE_SETTING_WIDGET_H #include -#include "skeletondocument.h" +#include "document.h" class AdvanceSettingWidget : public QDialog { @@ -9,9 +9,9 @@ class AdvanceSettingWidget : public QDialog signals: void enableWeld(bool enabled); public: - AdvanceSettingWidget(const SkeletonDocument *document, QWidget *parent=nullptr); + AdvanceSettingWidget(const Document *document, QWidget *parent=nullptr); private: - const SkeletonDocument *m_document = nullptr; + const Document *m_document = nullptr; }; #endif diff --git a/src/ambientocclusionbaker.cpp b/src/ambientocclusionbaker.cpp index 1bfb6cff..94ea5de2 100644 --- a/src/ambientocclusionbaker.cpp +++ b/src/ambientocclusionbaker.cpp @@ -106,9 +106,9 @@ AmbientOcclusionBaker::~AmbientOcclusionBaker() delete m_resultMesh; } -void AmbientOcclusionBaker::setInputMesh(const MeshResultContext &meshResultContext) +void AmbientOcclusionBaker::setInputMesh(const Outcome &outcome) { - m_meshResultContext = meshResultContext; + m_outcome = outcome; } void AmbientOcclusionBaker::setBakeSize(int width, int height) @@ -141,7 +141,7 @@ void AmbientOcclusionBaker::process() mergeGuidePainter.drawImage(0, 0, *m_borderImage); mergeGuidePainter.end(); - m_resultMesh = new MeshLoader(m_meshResultContext); + m_resultMesh = new MeshLoader(m_outcome); m_resultMesh->setTextureImage(new QImage(*m_textureImage)); //m_resultMesh->setNormalMapImage(new QImage(*m_textureImage)); } @@ -153,7 +153,7 @@ void AmbientOcclusionBaker::process() void AmbientOcclusionBaker::bake() { #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) - if (m_meshResultContext.parts().empty()) + if (m_outcome.parts().empty()) return; m_context->makeCurrent(this); @@ -170,7 +170,7 @@ void AmbientOcclusionBaker::bake() std::vector vertices; std::vector indicies; std::vector normals; - for (const auto &part: m_meshResultContext.parts()) { + for (const auto &part: m_outcome.parts()) { int i = 0; int startIndex = vertices.size(); for (const auto &it: part.second.vertices) { diff --git a/src/ambientocclusionbaker.h b/src/ambientocclusionbaker.h index 9740411b..bad10ba3 100644 --- a/src/ambientocclusionbaker.h +++ b/src/ambientocclusionbaker.h @@ -1,5 +1,5 @@ -#ifndef AMBIENT_OCCLUSION_BAKER_H -#define AMBIENT_OCCLUSION_BAKER_H +#ifndef DUST3D_AMBIENT_OCCLUSION_BAKER_H +#define DUST3D_AMBIENT_OCCLUSION_BAKER_H #include #include #include @@ -7,7 +7,7 @@ #include #include #include "qtlightmapper.h" -#include "meshresultcontext.h" +#include "outcome.h" #include "meshloader.h" #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) @@ -24,7 +24,7 @@ public slots: public: AmbientOcclusionBaker(QScreen *targetScreen = Q_NULLPTR); ~AmbientOcclusionBaker(); - void setInputMesh(const MeshResultContext &meshResultContext); + void setInputMesh(const Outcome &outcome); void setBakeSize(int width, int height); void setColorImage(const QImage &colorImage); void setBorderImage(const QImage &borderImage); @@ -38,7 +38,7 @@ public: void setRenderThread(QThread *thread); private: QOpenGLContext *m_context; - MeshResultContext m_meshResultContext; + Outcome m_outcome; int m_bakeWidth; int m_bakeHeight; QImage *m_ambientOcclusionImage; diff --git a/src/anglesmooth.cpp b/src/anglesmooth.cpp index a5559639..9017d937 100644 --- a/src/anglesmooth.cpp +++ b/src/anglesmooth.cpp @@ -1,6 +1,6 @@ #include #include -#include "dust3dutil.h" +#include "util.h" #include "anglesmooth.h" void angleSmooth(const std::vector &vertices, diff --git a/src/anglesmooth.h b/src/anglesmooth.h index 6dceaaea..4f5e78be 100644 --- a/src/anglesmooth.h +++ b/src/anglesmooth.h @@ -1,5 +1,5 @@ -#ifndef ANGLE_SMOOTH_H -#define ANGLE_SMOOTH_H +#ifndef DUST3D_ANGLE_SMOOTH_H +#define DUST3D_ANGLE_SMOOTH_H #include #include diff --git a/src/animationclipplayer.h b/src/animationclipplayer.h index 2906ff5b..c2d4a57d 100644 --- a/src/animationclipplayer.h +++ b/src/animationclipplayer.h @@ -1,5 +1,5 @@ -#ifndef ANIMATION_PLAYER_H -#define ANIMATION_PLAYER_H +#ifndef DUST3D_ANIMATION_PLAYER_H +#define DUST3D_ANIMATION_PLAYER_H #include #include #include diff --git a/src/autorigger.cpp b/src/autorigger.cpp index 2eddfa46..7915cdee 100644 --- a/src/autorigger.cpp +++ b/src/autorigger.cpp @@ -1,7 +1,8 @@ #include #include #include "theme.h" -#include "skeletonbonemark.h" +#include "bonemark.h" +#include "skeletonside.h" #include "autorigger.h" AutoRigger::AutoRigger(const std::vector &verticesPositions, @@ -11,11 +12,11 @@ AutoRigger::AutoRigger(const std::vector &verticesPositions, { } -bool AutoRigger::isCutOffSplitter(SkeletonBoneMark boneMark) +bool AutoRigger::isCutOffSplitter(BoneMark boneMark) { - return boneMark == SkeletonBoneMark::Neck || - boneMark == SkeletonBoneMark::Shoulder || - boneMark == SkeletonBoneMark::Hip; + return boneMark == BoneMark::Neck || + boneMark == BoneMark::Shoulder || + boneMark == BoneMark::Hip; } bool AutoRigger::calculateBodyTriangles(std::set &bodyTriangles) @@ -41,7 +42,7 @@ bool AutoRigger::calculateBodyTriangles(std::set &bodyTria return true; } -bool AutoRigger::addMarkGroup(SkeletonBoneMark boneMark, SkeletonSide boneSide, QVector3D bonePosition, +bool AutoRigger::addMarkGroup(BoneMark boneMark, SkeletonSide boneSide, QVector3D bonePosition, const std::set &markTriangles) { m_marks.push_back(AutoRiggerMark()); @@ -55,9 +56,9 @@ bool AutoRigger::addMarkGroup(SkeletonBoneMark boneMark, SkeletonSide boneSide, if (isCutOffSplitter(mark.boneMark)) { if (!mark.split(m_inputTriangles)) { m_marksMap[std::make_pair(mark.boneMark, mark.boneSide)].push_back(m_marks.size() - 1); - m_errorMarkNames.push_back(SkeletonSideToDispName(mark.boneSide) + " " + SkeletonBoneMarkToDispName(mark.boneMark)); + m_errorMarkNames.push_back(SkeletonSideToDispName(mark.boneSide) + " " + BoneMarkToDispName(mark.boneMark)); m_messages.push_back(std::make_pair(QtCriticalMsg, - tr("Mark \"%1 %2\" couldn't cut off the mesh").arg(SkeletonSideToDispName(mark.boneSide)).arg(SkeletonBoneMarkToString(mark.boneMark)))); + tr("Mark \"%1 %2\" couldn't cut off the mesh").arg(SkeletonSideToDispName(mark.boneSide)).arg(BoneMarkToString(mark.boneMark)))); return false; } } @@ -85,26 +86,26 @@ bool AutoRigger::validate() { bool foundError = false; - std::vector> mustPresentedMarks; + std::vector> mustPresentedMarks; - mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Neck, SkeletonSide::None)); - mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Shoulder, SkeletonSide::Left)); - mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Elbow, SkeletonSide::Left)); - mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Wrist, SkeletonSide::Left)); - mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Shoulder, SkeletonSide::Right)); - mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Elbow, SkeletonSide::Right)); - mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Wrist, SkeletonSide::Right)); - mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Hip, SkeletonSide::Left)); - mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Knee, SkeletonSide::Left)); - mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Ankle, SkeletonSide::Left)); - mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Hip, SkeletonSide::Right)); - mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Knee, SkeletonSide::Right)); - mustPresentedMarks.push_back(std::make_pair(SkeletonBoneMark::Ankle, SkeletonSide::Right)); + mustPresentedMarks.push_back(std::make_pair(BoneMark::Neck, SkeletonSide::None)); + mustPresentedMarks.push_back(std::make_pair(BoneMark::Shoulder, SkeletonSide::Left)); + mustPresentedMarks.push_back(std::make_pair(BoneMark::Elbow, SkeletonSide::Left)); + mustPresentedMarks.push_back(std::make_pair(BoneMark::Wrist, SkeletonSide::Left)); + mustPresentedMarks.push_back(std::make_pair(BoneMark::Shoulder, SkeletonSide::Right)); + mustPresentedMarks.push_back(std::make_pair(BoneMark::Elbow, SkeletonSide::Right)); + mustPresentedMarks.push_back(std::make_pair(BoneMark::Wrist, SkeletonSide::Right)); + mustPresentedMarks.push_back(std::make_pair(BoneMark::Hip, SkeletonSide::Left)); + mustPresentedMarks.push_back(std::make_pair(BoneMark::Knee, SkeletonSide::Left)); + mustPresentedMarks.push_back(std::make_pair(BoneMark::Ankle, SkeletonSide::Left)); + mustPresentedMarks.push_back(std::make_pair(BoneMark::Hip, SkeletonSide::Right)); + mustPresentedMarks.push_back(std::make_pair(BoneMark::Knee, SkeletonSide::Right)); + mustPresentedMarks.push_back(std::make_pair(BoneMark::Ankle, SkeletonSide::Right)); for (const auto &pair: mustPresentedMarks) { if (m_marksMap.find(pair) == m_marksMap.end()) { foundError = true; - QString markDispName = SkeletonSideToDispName(pair.second) + " " + SkeletonBoneMarkToDispName(pair.first); + QString markDispName = SkeletonSideToDispName(pair.second) + " " + BoneMarkToDispName(pair.first); m_missingMarkNames.push_back(markDispName); m_messages.push_back(std::make_pair(QtCriticalMsg, tr("Couldn't find valid \"%1\" mark").arg(markDispName))); @@ -264,19 +265,19 @@ bool AutoRigger::rig() if (!calculateBodyTriangles(bodyTriangles)) return false; - auto neckIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Neck, SkeletonSide::None)); - auto leftShoulderIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Shoulder, SkeletonSide::Left)); - auto leftElbowIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Elbow, SkeletonSide::Left)); - auto leftWristIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Wrist, SkeletonSide::Left)); - auto rightShoulderIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Shoulder, SkeletonSide::Right)); - auto rightElbowIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Elbow, SkeletonSide::Right)); - auto rightWristIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Wrist, SkeletonSide::Right)); - auto leftHipIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Hip, SkeletonSide::Left)); - auto leftKneeIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Knee, SkeletonSide::Left)); - auto leftAnkleIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Ankle, SkeletonSide::Left)); - auto rightHipIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Hip, SkeletonSide::Right)); - auto rightKneeIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Knee, SkeletonSide::Right)); - auto rightAnkleIndicies = m_marksMap.find(std::make_pair(SkeletonBoneMark::Ankle, SkeletonSide::Right)); + auto neckIndicies = m_marksMap.find(std::make_pair(BoneMark::Neck, SkeletonSide::None)); + auto leftShoulderIndicies = m_marksMap.find(std::make_pair(BoneMark::Shoulder, SkeletonSide::Left)); + auto leftElbowIndicies = m_marksMap.find(std::make_pair(BoneMark::Elbow, SkeletonSide::Left)); + auto leftWristIndicies = m_marksMap.find(std::make_pair(BoneMark::Wrist, SkeletonSide::Left)); + auto rightShoulderIndicies = m_marksMap.find(std::make_pair(BoneMark::Shoulder, SkeletonSide::Right)); + auto rightElbowIndicies = m_marksMap.find(std::make_pair(BoneMark::Elbow, SkeletonSide::Right)); + auto rightWristIndicies = m_marksMap.find(std::make_pair(BoneMark::Wrist, SkeletonSide::Right)); + auto leftHipIndicies = m_marksMap.find(std::make_pair(BoneMark::Hip, SkeletonSide::Left)); + auto leftKneeIndicies = m_marksMap.find(std::make_pair(BoneMark::Knee, SkeletonSide::Left)); + auto leftAnkleIndicies = m_marksMap.find(std::make_pair(BoneMark::Ankle, SkeletonSide::Left)); + auto rightHipIndicies = m_marksMap.find(std::make_pair(BoneMark::Hip, SkeletonSide::Right)); + auto rightKneeIndicies = m_marksMap.find(std::make_pair(BoneMark::Knee, SkeletonSide::Right)); + auto rightAnkleIndicies = m_marksMap.find(std::make_pair(BoneMark::Ankle, SkeletonSide::Right)); // 1. Prepare all bones start and stop positions: @@ -625,7 +626,7 @@ bool AutoRigger::rig() leftUpperLegBone.name = "LeftUpperLeg"; leftUpperLegBone.headPosition = m_resultBones[boneIndexMap["LeftHip"]].tailPosition; leftUpperLegBone.tailPosition = leftLowerLegBoneStartPosition; - leftUpperLegBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Hip); + leftUpperLegBone.color = BoneMarkToColor(BoneMark::Hip); boneIndexMap[leftUpperLegBone.name] = leftUpperLegBone.index; m_resultBones[boneIndexMap["LeftHip"]].children.push_back(leftUpperLegBone.index); @@ -635,7 +636,7 @@ bool AutoRigger::rig() leftLowerLegBone.name = "LeftLowerLeg"; leftLowerLegBone.headPosition = m_resultBones[boneIndexMap["LeftUpperLeg"]].tailPosition; leftLowerLegBone.tailPosition = leftFootBoneStartPosition; - leftLowerLegBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Knee); + leftLowerLegBone.color = BoneMarkToColor(BoneMark::Knee); boneIndexMap[leftLowerLegBone.name] = leftLowerLegBone.index; m_resultBones[boneIndexMap["LeftUpperLeg"]].children.push_back(leftLowerLegBone.index); @@ -645,7 +646,7 @@ bool AutoRigger::rig() leftFootBone.name = "LeftFoot"; leftFootBone.headPosition = m_resultBones[boneIndexMap["LeftLowerLeg"]].tailPosition; leftFootBone.tailPosition = leftFootBoneStopPosition; - leftFootBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Ankle); + leftFootBone.color = BoneMarkToColor(BoneMark::Ankle); boneIndexMap[leftFootBone.name] = leftFootBone.index; m_resultBones[boneIndexMap["LeftLowerLeg"]].children.push_back(leftFootBone.index); @@ -664,7 +665,7 @@ bool AutoRigger::rig() rightUpperLegBone.name = "RightUpperLeg"; rightUpperLegBone.headPosition = m_resultBones[boneIndexMap["RightHip"]].tailPosition; rightUpperLegBone.tailPosition = rightLowerLegBoneStartPosition; - rightUpperLegBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Hip); + rightUpperLegBone.color = BoneMarkToColor(BoneMark::Hip); boneIndexMap[rightUpperLegBone.name] = rightUpperLegBone.index; m_resultBones[boneIndexMap["RightHip"]].children.push_back(rightUpperLegBone.index); @@ -674,7 +675,7 @@ bool AutoRigger::rig() rightLowerLegBone.name = "RightLowerLeg"; rightLowerLegBone.headPosition = m_resultBones[boneIndexMap["RightUpperLeg"]].tailPosition; rightLowerLegBone.tailPosition = rightFootBoneStartPosition; - rightLowerLegBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Knee); + rightLowerLegBone.color = BoneMarkToColor(BoneMark::Knee); boneIndexMap[rightLowerLegBone.name] = rightLowerLegBone.index; m_resultBones[boneIndexMap["RightUpperLeg"]].children.push_back(rightLowerLegBone.index); @@ -684,7 +685,7 @@ bool AutoRigger::rig() rightFootBone.name = "RightFoot"; rightFootBone.headPosition = m_resultBones[boneIndexMap["RightLowerLeg"]].tailPosition; rightFootBone.tailPosition = rightFootBoneStopPosition; - rightFootBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Ankle); + rightFootBone.color = BoneMarkToColor(BoneMark::Ankle); boneIndexMap[rightFootBone.name] = rightFootBone.index; m_resultBones[boneIndexMap["RightLowerLeg"]].children.push_back(rightFootBone.index); @@ -723,7 +724,7 @@ bool AutoRigger::rig() leftUpperArmBone.name = "LeftUpperArm"; leftUpperArmBone.headPosition = m_resultBones[boneIndexMap["LeftShoulder"]].tailPosition; leftUpperArmBone.tailPosition = leftLowerArmBoneStartPosition; - leftUpperArmBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Shoulder); + leftUpperArmBone.color = BoneMarkToColor(BoneMark::Shoulder); boneIndexMap[leftUpperArmBone.name] = leftUpperArmBone.index; m_resultBones[boneIndexMap["LeftShoulder"]].children.push_back(leftUpperArmBone.index); @@ -733,7 +734,7 @@ bool AutoRigger::rig() leftLowerArmBone.name = "LeftLowerArm"; leftLowerArmBone.headPosition = m_resultBones[boneIndexMap["LeftUpperArm"]].tailPosition; leftLowerArmBone.tailPosition = leftHandBoneStartPosition; - leftLowerArmBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Elbow); + leftLowerArmBone.color = BoneMarkToColor(BoneMark::Elbow); boneIndexMap[leftLowerArmBone.name] = leftLowerArmBone.index; m_resultBones[boneIndexMap["LeftUpperArm"]].children.push_back(leftLowerArmBone.index); @@ -743,7 +744,7 @@ bool AutoRigger::rig() leftHandBone.name = "LeftHand"; leftHandBone.headPosition = m_resultBones[boneIndexMap["LeftLowerArm"]].tailPosition; leftHandBone.tailPosition = leftHandBoneStopPosition; - leftHandBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Wrist); + leftHandBone.color = BoneMarkToColor(BoneMark::Wrist); boneIndexMap[leftHandBone.name] = leftHandBone.index; m_resultBones[boneIndexMap["LeftLowerArm"]].children.push_back(leftHandBone.index); @@ -762,7 +763,7 @@ bool AutoRigger::rig() rightUpperArmBone.name = "RightUpperArm"; rightUpperArmBone.headPosition = m_resultBones[boneIndexMap["RightShoulder"]].tailPosition; rightUpperArmBone.tailPosition = rightLowerArmBoneStartPosition; - rightUpperArmBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Shoulder); + rightUpperArmBone.color = BoneMarkToColor(BoneMark::Shoulder); boneIndexMap[rightUpperArmBone.name] = rightUpperArmBone.index; m_resultBones[boneIndexMap["RightShoulder"]].children.push_back(rightUpperArmBone.index); @@ -772,7 +773,7 @@ bool AutoRigger::rig() rightLowerArmBone.name = "RightLowerArm"; rightLowerArmBone.headPosition = m_resultBones[boneIndexMap["RightUpperArm"]].tailPosition; rightLowerArmBone.tailPosition = rightHandBoneStartPosition; - rightLowerArmBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Elbow); + rightLowerArmBone.color = BoneMarkToColor(BoneMark::Elbow); boneIndexMap[rightLowerArmBone.name] = rightLowerArmBone.index; m_resultBones[boneIndexMap["RightUpperArm"]].children.push_back(rightLowerArmBone.index); @@ -782,7 +783,7 @@ bool AutoRigger::rig() rightHandBone.name = "RightHand"; rightHandBone.headPosition = m_resultBones[boneIndexMap["RightLowerArm"]].tailPosition; rightHandBone.tailPosition = rightHandBoneStopPosition; - rightHandBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Wrist); + rightHandBone.color = BoneMarkToColor(BoneMark::Wrist); boneIndexMap[rightHandBone.name] = rightHandBone.index; m_resultBones[boneIndexMap["RightLowerArm"]].children.push_back(rightHandBone.index); @@ -792,7 +793,7 @@ bool AutoRigger::rig() neckBone.name = "Neck"; neckBone.headPosition = m_resultBones[boneIndexMap["Chest"]].tailPosition; neckBone.tailPosition = headBoneStartPosition; - neckBone.color = SkeletonBoneMarkToColor(SkeletonBoneMark::Neck); + neckBone.color = BoneMarkToColor(BoneMark::Neck); boneIndexMap[neckBone.name] = neckBone.index; m_resultBones[boneIndexMap["Chest"]].children.push_back(neckBone.index); diff --git a/src/autorigger.h b/src/autorigger.h index c57956eb..aa9c827c 100644 --- a/src/autorigger.h +++ b/src/autorigger.h @@ -1,18 +1,19 @@ -#ifndef AUTO_RIGGER_H -#define AUTO_RIGGER_H +#ifndef DUST3D_AUTO_RIGGER_H +#define DUST3D_AUTO_RIGGER_H #include #include #include #include #include #include "meshsplitter.h" -#include "skeletonbonemark.h" +#include "bonemark.h" #include "rigtype.h" +#include "skeletonside.h" class AutoRiggerMark { public: - SkeletonBoneMark boneMark; + BoneMark boneMark; SkeletonSide boneSide; QVector3D bonePosition; std::set markTriangles; @@ -89,7 +90,7 @@ class AutoRigger : public QObject public: AutoRigger(const std::vector &verticesPositions, const std::set &inputTriangles); - bool addMarkGroup(SkeletonBoneMark boneMark, SkeletonSide boneSide, QVector3D bonePosition, + bool addMarkGroup(BoneMark boneMark, SkeletonSide boneSide, QVector3D bonePosition, const std::set &markTriangles); const std::vector> &messages(); bool rig(); @@ -101,7 +102,7 @@ private: bool validate(); void addTrianglesToVertices(const std::set &triangles, std::set &vertices); bool calculateBodyTriangles(std::set &bodyTriangles); - bool isCutOffSplitter(SkeletonBoneMark boneMark); + bool isCutOffSplitter(BoneMark boneMark); void resolveBoundingBox(const std::set &vertices, QVector3D &xMin, QVector3D &xMax, QVector3D &yMin, QVector3D &yMax, QVector3D &zMin, QVector3D &zMax); QVector3D findMinX(const std::set &vertices); QVector3D findMaxX(const std::set &vertices); @@ -117,7 +118,7 @@ private: std::vector m_verticesPositions; std::set m_inputTriangles; std::vector m_marks; - std::map, std::vector> m_marksMap; + std::map, std::vector> m_marksMap; std::vector m_resultBones; std::map m_resultWeights; std::vector m_missingMarkNames; diff --git a/src/bonemark.cpp b/src/bonemark.cpp new file mode 100644 index 00000000..5cae2573 --- /dev/null +++ b/src/bonemark.cpp @@ -0,0 +1,7 @@ +#include +#include "bonemark.h" + +IMPL_BoneMarkToColor +IMPL_BoneMarkToString +IMPL_BoneMarkFromString +IMPL_BoneMarkToDispName diff --git a/src/bonemark.h b/src/bonemark.h new file mode 100644 index 00000000..c5d211e2 --- /dev/null +++ b/src/bonemark.h @@ -0,0 +1,117 @@ +#ifndef DUST3D_BONE_MARK_H +#define DUST3D_BONE_MARK_H +#include +#include + +enum class BoneMark +{ + None = 0, + Neck, + Shoulder, + Elbow, + Wrist, + Hip, + Knee, + Ankle, + Count +}; +#define BoneMarkHasSide(mark) ((mark) != BoneMark::Neck) +QColor BoneMarkToColor(BoneMark mark); +#define IMPL_BoneMarkToColor \ +QColor BoneMarkToColor(BoneMark mark) \ +{ \ + switch (mark) { \ + case BoneMark::Neck: \ + return QColor(0xfc, 0x0d, 0x1b); \ + case BoneMark::Shoulder: \ + return QColor(0xfd, 0x80, 0x23); \ + case BoneMark::Elbow: \ + return QColor(0x29, 0xfd, 0x2f); \ + case BoneMark::Wrist: \ + return QColor(0xff, 0xfd, 0x38); \ + case BoneMark::Hip: \ + return QColor(0x2c, 0xff, 0xfe); \ + case BoneMark::Knee: \ + return QColor(0x0b, 0x24, 0xfb); \ + case BoneMark::Ankle: \ + return QColor(0xfc, 0x28, 0xfc); \ + case BoneMark::None: \ + return Qt::transparent; \ + default: \ + return Qt::transparent; \ + } \ +} +const char *BoneMarkToString(BoneMark mark); +#define IMPL_BoneMarkToString \ +const char *BoneMarkToString(BoneMark mark) \ +{ \ + switch (mark) { \ + case BoneMark::Neck: \ + return "Neck"; \ + case BoneMark::Shoulder: \ + return "Shoulder"; \ + case BoneMark::Elbow: \ + return "Elbow"; \ + case BoneMark::Wrist: \ + return "Wrist"; \ + case BoneMark::Hip: \ + return "Hip"; \ + case BoneMark::Knee: \ + return "Knee"; \ + case BoneMark::Ankle: \ + return "Ankle"; \ + case BoneMark::None: \ + return "None"; \ + default: \ + return "None"; \ + } \ +} +BoneMark BoneMarkFromString(const char *markString); +#define IMPL_BoneMarkFromString \ +BoneMark BoneMarkFromString(const char *markString) \ +{ \ + QString mark = markString; \ + if (mark == "Neck") \ + return BoneMark::Neck; \ + if (mark == "Shoulder") \ + return BoneMark::Shoulder; \ + if (mark == "Elbow") \ + return BoneMark::Elbow; \ + if (mark == "Wrist") \ + return BoneMark::Wrist; \ + if (mark == "Hip") \ + return BoneMark::Hip; \ + if (mark == "Knee") \ + return BoneMark::Knee; \ + if (mark == "Ankle") \ + return BoneMark::Ankle; \ + return BoneMark::None; \ +} +QString BoneMarkToDispName(BoneMark mark); +#define IMPL_BoneMarkToDispName \ +QString BoneMarkToDispName(BoneMark mark) \ +{ \ + switch (mark) { \ + case BoneMark::Neck: \ + return QObject::tr("Neck"); \ + case BoneMark::Shoulder: \ + return QObject::tr("Shoulder (Arm Start)"); \ + case BoneMark::Elbow: \ + return QObject::tr("Elbow"); \ + case BoneMark::Wrist: \ + return QObject::tr("Wrist"); \ + case BoneMark::Hip: \ + return QObject::tr("Hip (Leg Start)"); \ + case BoneMark::Knee: \ + return QObject::tr("Knee"); \ + case BoneMark::Ankle: \ + return QObject::tr("Ankle"); \ + case BoneMark::None: \ + return QObject::tr("None"); \ + default: \ + return ""; \ + } \ +} + +#endif + diff --git a/src/ccdikresolver.cpp b/src/ccdikresolver.cpp index 2d9359bd..3cfa488d 100644 --- a/src/ccdikresolver.cpp +++ b/src/ccdikresolver.cpp @@ -3,7 +3,7 @@ #include #include #include "ccdikresolver.h" -#include "dust3dutil.h" +#include "util.h" CCDIKSolver::CCDIKSolver() : m_maxRound(4), diff --git a/src/ccdikresolver.h b/src/ccdikresolver.h index 0485aafb..e4807248 100644 --- a/src/ccdikresolver.h +++ b/src/ccdikresolver.h @@ -1,5 +1,5 @@ -#ifndef CCD_IK_SOLVER_H -#define CCD_IK_SOLVER_H +#ifndef DUST3D_CCD_IK_SOLVER_H +#define DUST3D_CCD_IK_SOLVER_H #include #include #include diff --git a/src/skeletondocument.cpp b/src/document.cpp similarity index 85% rename from src/skeletondocument.cpp rename to src/document.cpp index 91fdfe57..92040a34 100644 --- a/src/skeletondocument.cpp +++ b/src/document.cpp @@ -6,20 +6,21 @@ #include #include #include -#include "skeletondocument.h" -#include "dust3dutil.h" -#include "skeletonxml.h" +#include "document.h" +#include "util.h" +#include "snapshotxml.h" #include "materialpreviewsgenerator.h" #include "motionsgenerator.h" +#include "skeletonside.h" -unsigned long SkeletonDocument::m_maxSnapshot = 1000; +unsigned long Document::m_maxSnapshot = 1000; -SkeletonDocument::SkeletonDocument() : +Document::Document() : // public originX(0), originY(0), originZ(0), - editMode(SkeletonDocumentEditMode::Select), + editMode(DocumentEditMode::Select), xlocked(false), ylocked(false), zlocked(false), @@ -41,7 +42,7 @@ SkeletonDocument::SkeletonDocument() : m_textureGenerator(nullptr), m_isPostProcessResultObsolete(false), m_postProcessor(nullptr), - m_postProcessedResultContext(new MeshResultContext), + m_postProcessedResultContext(new Outcome), m_resultTextureMesh(nullptr), m_textureImageUpdateVersion(0), m_ambientOcclusionBaker(nullptr), @@ -54,7 +55,7 @@ SkeletonDocument::SkeletonDocument() : m_resultRigBones(nullptr), m_resultRigWeights(nullptr), m_isRigObsolete(false), - m_riggedResultContext(new MeshResultContext), + m_riggedResultContext(new Outcome), m_posePreviewsGenerator(nullptr), m_currentRigSucceed(false), m_materialPreviewsGenerator(nullptr), @@ -62,7 +63,7 @@ SkeletonDocument::SkeletonDocument() : { } -SkeletonDocument::~SkeletonDocument() +Document::~Document() { delete m_resultMesh; delete m_postProcessedResultContext; @@ -74,25 +75,25 @@ SkeletonDocument::~SkeletonDocument() delete m_resultRigWeightMesh; } -void SkeletonDocument::uiReady() +void Document::uiReady() { qDebug() << "uiReady"; emit editModeChanged(); } -void SkeletonDocument::SkeletonDocument::enableAllPositionRelatedLocks() +void Document::Document::enableAllPositionRelatedLocks() { m_allPositionRelatedLocksEnabled = true; } -void SkeletonDocument::SkeletonDocument::disableAllPositionRelatedLocks() +void Document::Document::disableAllPositionRelatedLocks() { m_allPositionRelatedLocksEnabled = false; } -void SkeletonDocument::breakEdge(QUuid edgeId) +void Document::breakEdge(QUuid edgeId) { - const SkeletonEdge *edge = findEdge(edgeId); + const Edge *edge = findEdge(edgeId); if (nullptr == edge) { qDebug() << "Find edge failed:" << edgeId; return; @@ -102,12 +103,12 @@ void SkeletonDocument::breakEdge(QUuid edgeId) } QUuid firstNodeId = edge->nodeIds[0]; QUuid secondNodeId = edge->nodeIds[1]; - const SkeletonNode *firstNode = findNode(firstNodeId); + const Node *firstNode = findNode(firstNodeId); if (nullptr == firstNode) { qDebug() << "Find node failed:" << firstNodeId; return; } - const SkeletonNode *secondNode = findNode(secondNodeId); + const Node *secondNode = findNode(secondNodeId); if (nullptr == secondNode) { qDebug() << "Find node failed:" << secondNodeId; return; @@ -125,16 +126,16 @@ void SkeletonDocument::breakEdge(QUuid edgeId) addEdge(middleNodeId, secondNodeId); } -void SkeletonDocument::removeEdge(QUuid edgeId) +void Document::removeEdge(QUuid edgeId) { - const SkeletonEdge *edge = findEdge(edgeId); + const Edge *edge = findEdge(edgeId); if (nullptr == edge) { qDebug() << "Find edge failed:" << edgeId; return; } if (isPartReadonly(edge->partId)) return; - const SkeletonPart *oldPart = findPart(edge->partId); + const Part *oldPart = findPart(edge->partId); if (nullptr == oldPart) { qDebug() << "Find part failed:" << edge->partId; return; @@ -145,7 +146,7 @@ void SkeletonDocument::removeEdge(QUuid edgeId) splitPartByEdge(&groups, edgeId); for (auto groupIt = groups.begin(); groupIt != groups.end(); groupIt++) { const auto newUuid = QUuid::createUuid(); - SkeletonPart &part = partMap[newUuid]; + Part &part = partMap[newUuid]; part.id = newUuid; part.copyAttributes(*oldPart); part.name = nextPartName; @@ -185,16 +186,16 @@ void SkeletonDocument::removeEdge(QUuid edgeId) emit skeletonChanged(); } -void SkeletonDocument::removeNode(QUuid nodeId) +void Document::removeNode(QUuid nodeId) { - const SkeletonNode *node = findNode(nodeId); + const Node *node = findNode(nodeId); if (nullptr == node) { qDebug() << "Find node failed:" << nodeId; return; } if (isPartReadonly(node->partId)) return; - const SkeletonPart *oldPart = findPart(node->partId); + const Part *oldPart = findPart(node->partId); if (nullptr == oldPart) { qDebug() << "Find part failed:" << node->partId; return; @@ -205,7 +206,7 @@ void SkeletonDocument::removeNode(QUuid nodeId) splitPartByNode(&groups, nodeId); for (auto groupIt = groups.begin(); groupIt != groups.end(); groupIt++) { const auto newUuid = QUuid::createUuid(); - SkeletonPart &part = partMap[newUuid]; + Part &part = partMap[newUuid]; part.id = newUuid; part.copyAttributes(*oldPart); part.name = nextPartName; @@ -252,19 +253,19 @@ void SkeletonDocument::removeNode(QUuid nodeId) emit skeletonChanged(); } -void SkeletonDocument::addNode(float x, float y, float z, float radius, QUuid fromNodeId) +void Document::addNode(float x, float y, float z, float radius, QUuid fromNodeId) { createNode(x, y, z, radius, fromNodeId); } -QUuid SkeletonDocument::createNode(float x, float y, float z, float radius, QUuid fromNodeId) +QUuid Document::createNode(float x, float y, float z, float radius, QUuid fromNodeId) { QUuid partId; - const SkeletonNode *fromNode = nullptr; + const Node *fromNode = nullptr; bool newPartAdded = false; if (fromNodeId.isNull()) { const auto newUuid = QUuid::createUuid(); - SkeletonPart &part = partMap[newUuid]; + Part &part = partMap[newUuid]; part.id = newUuid; partId = part.id; emit partAdded(partId); @@ -282,7 +283,7 @@ QUuid SkeletonDocument::createNode(float x, float y, float z, float radius, QUui if (part != partMap.end()) part->second.dirty = true; } - SkeletonNode node; + Node node; node.partId = partId; node.setRadius(radius); node.x = x; @@ -294,7 +295,7 @@ QUuid SkeletonDocument::createNode(float x, float y, float z, float radius, QUui emit nodeAdded(node.id); if (nullptr != fromNode) { - SkeletonEdge edge; + Edge edge; edge.partId = partId; edge.nodeIds.push_back(fromNode->id); edge.nodeIds.push_back(node.id); @@ -314,7 +315,7 @@ QUuid SkeletonDocument::createNode(float x, float y, float z, float radius, QUui return node.id; } -void SkeletonDocument::addPose(QString name, std::map> parameters) +void Document::addPose(QString name, std::map> parameters) { QUuid newPoseId = QUuid::createUuid(); auto &pose = poseMap[newPoseId]; @@ -332,7 +333,7 @@ void SkeletonDocument::addPose(QString name, std::map clips) +void Document::addMotion(QString name, std::vector clips) { QUuid newMotionId = QUuid::createUuid(); auto &motion = motionMap[newMotionId]; @@ -350,7 +351,7 @@ void SkeletonDocument::addMotion(QString name, std::vector c emit optionsChanged(); } -void SkeletonDocument::removeMotion(QUuid motionId) +void Document::removeMotion(QUuid motionId) { auto findMotionResult = motionMap.find(motionId); if (findMotionResult == motionMap.end()) { @@ -365,7 +366,7 @@ void SkeletonDocument::removeMotion(QUuid motionId) emit optionsChanged(); } -void SkeletonDocument::setMotionClips(QUuid motionId, std::vector clips) +void Document::setMotionClips(QUuid motionId, std::vector clips) { auto findMotionResult = motionMap.find(motionId); if (findMotionResult == motionMap.end()) { @@ -379,7 +380,7 @@ void SkeletonDocument::setMotionClips(QUuid motionId, std::vector> parameters) +void Document::setPoseParameters(QUuid poseId, std::map> parameters) { auto findPoseResult = poseMap.find(poseId); if (findPoseResult == poseMap.end()) { @@ -423,7 +424,7 @@ void SkeletonDocument::setPoseParameters(QUuid poseId, std::mappartId; edge.nodeIds.push_back(fromNode->id); edge.nodeIds.push_back(toNodeId); @@ -544,7 +545,7 @@ void SkeletonDocument::addEdge(QUuid fromNodeId, QUuid toNodeId) emit skeletonChanged(); } -const SkeletonNode *SkeletonDocument::findNode(QUuid nodeId) const +const Node *Document::findNode(QUuid nodeId) const { auto it = nodeMap.find(nodeId); if (it == nodeMap.end()) @@ -552,7 +553,7 @@ const SkeletonNode *SkeletonDocument::findNode(QUuid nodeId) const return &it->second; } -const SkeletonEdge *SkeletonDocument::findEdge(QUuid edgeId) const +const Edge *Document::findEdge(QUuid edgeId) const { auto it = edgeMap.find(edgeId); if (it == edgeMap.end()) @@ -560,7 +561,7 @@ const SkeletonEdge *SkeletonDocument::findEdge(QUuid edgeId) const return &it->second; } -const SkeletonPart *SkeletonDocument::findPart(QUuid partId) const +const Part *Document::findPart(QUuid partId) const { auto it = partMap.find(partId); if (it == partMap.end()) @@ -568,7 +569,7 @@ const SkeletonPart *SkeletonDocument::findPart(QUuid partId) const return &it->second; } -const SkeletonComponent *SkeletonDocument::findComponent(QUuid componentId) const +const Component *Document::findComponent(QUuid componentId) const { if (componentId.isNull()) return &rootComponent; @@ -578,7 +579,7 @@ const SkeletonComponent *SkeletonDocument::findComponent(QUuid componentId) cons return &it->second; } -const SkeletonPose *SkeletonDocument::findPose(QUuid poseId) const +const Pose *Document::findPose(QUuid poseId) const { auto it = poseMap.find(poseId); if (it == poseMap.end()) @@ -586,7 +587,7 @@ const SkeletonPose *SkeletonDocument::findPose(QUuid poseId) const return &it->second; } -const SkeletonMaterial *SkeletonDocument::findMaterial(QUuid materialId) const +const Material *Document::findMaterial(QUuid materialId) const { auto it = materialMap.find(materialId); if (it == materialMap.end()) @@ -594,7 +595,7 @@ const SkeletonMaterial *SkeletonDocument::findMaterial(QUuid materialId) const return &it->second; } -const SkeletonMotion *SkeletonDocument::findMotion(QUuid motionId) const +const Motion *Document::findMotion(QUuid motionId) const { auto it = motionMap.find(motionId); if (it == motionMap.end()) @@ -602,7 +603,7 @@ const SkeletonMotion *SkeletonDocument::findMotion(QUuid motionId) const return &it->second; } -void SkeletonDocument::scaleNodeByAddRadius(QUuid nodeId, float amount) +void Document::scaleNodeByAddRadius(QUuid nodeId, float amount) { auto it = nodeMap.find(nodeId); if (it == nodeMap.end()) { @@ -621,9 +622,9 @@ void SkeletonDocument::scaleNodeByAddRadius(QUuid nodeId, float amount) emit skeletonChanged(); } -bool SkeletonDocument::isPartReadonly(QUuid partId) const +bool Document::isPartReadonly(QUuid partId) const { - const SkeletonPart *part = findPart(partId); + const Part *part = findPart(partId); if (nullptr == part) { qDebug() << "Find part failed:" << partId; return true; @@ -631,7 +632,7 @@ bool SkeletonDocument::isPartReadonly(QUuid partId) const return part->locked || !part->visible; } -void SkeletonDocument::moveNodeBy(QUuid nodeId, float x, float y, float z) +void Document::moveNodeBy(QUuid nodeId, float x, float y, float z) { auto it = nodeMap.find(nodeId); if (it == nodeMap.end()) { @@ -662,7 +663,7 @@ void SkeletonDocument::moveNodeBy(QUuid nodeId, float x, float y, float z) emit skeletonChanged(); } -void SkeletonDocument::moveOriginBy(float x, float y, float z) +void Document::moveOriginBy(float x, float y, float z) { if (!(m_allPositionRelatedLocksEnabled && xlocked)) originX += x; @@ -675,7 +676,7 @@ void SkeletonDocument::moveOriginBy(float x, float y, float z) emit skeletonChanged(); } -void SkeletonDocument::setNodeOrigin(QUuid nodeId, float x, float y, float z) +void Document::setNodeOrigin(QUuid nodeId, float x, float y, float z) { auto it = nodeMap.find(nodeId); if (it == nodeMap.end()) { @@ -697,7 +698,7 @@ void SkeletonDocument::setNodeOrigin(QUuid nodeId, float x, float y, float z) emit skeletonChanged(); } -void SkeletonDocument::setNodeRadius(QUuid nodeId, float radius) +void Document::setNodeRadius(QUuid nodeId, float radius) { auto it = nodeMap.find(nodeId); if (it == nodeMap.end()) { @@ -715,7 +716,7 @@ void SkeletonDocument::setNodeRadius(QUuid nodeId, float radius) emit skeletonChanged(); } -void SkeletonDocument::switchNodeXZ(QUuid nodeId) +void Document::switchNodeXZ(QUuid nodeId) { auto it = nodeMap.find(nodeId); if (it == nodeMap.end()) { @@ -732,7 +733,7 @@ void SkeletonDocument::switchNodeXZ(QUuid nodeId) emit skeletonChanged(); } -void SkeletonDocument::setNodeBoneMark(QUuid nodeId, SkeletonBoneMark mark) +void Document::setNodeBoneMark(QUuid nodeId, BoneMark mark) { auto it = nodeMap.find(nodeId); if (it == nodeMap.end()) { @@ -751,13 +752,13 @@ void SkeletonDocument::setNodeBoneMark(QUuid nodeId, SkeletonBoneMark mark) emit skeletonChanged(); } -void SkeletonDocument::updateTurnaround(const QImage &image) +void Document::updateTurnaround(const QImage &image) { turnaround = image; emit turnaroundChanged(); } -void SkeletonDocument::setEditMode(SkeletonDocumentEditMode mode) +void Document::setEditMode(DocumentEditMode mode) { if (editMode == mode) return; @@ -766,11 +767,11 @@ void SkeletonDocument::setEditMode(SkeletonDocumentEditMode mode) emit editModeChanged(); } -void SkeletonDocument::joinNodeAndNeiborsToGroup(std::vector *group, QUuid nodeId, std::set *visitMap, QUuid noUseEdgeId) +void Document::joinNodeAndNeiborsToGroup(std::vector *group, QUuid nodeId, std::set *visitMap, QUuid noUseEdgeId) { if (nodeId.isNull() || visitMap->find(nodeId) != visitMap->end()) return; - const SkeletonNode *node = findNode(nodeId); + const Node *node = findNode(nodeId); if (nullptr == node) { qDebug() << "Find node failed:" << nodeId; return; @@ -780,7 +781,7 @@ void SkeletonDocument::joinNodeAndNeiborsToGroup(std::vector *group, QUui for (auto edgeIt = node->edgeIds.begin(); edgeIt != node->edgeIds.end(); edgeIt++) { if (noUseEdgeId == *edgeIt) continue; - const SkeletonEdge *edge = findEdge(*edgeIt); + const Edge *edge = findEdge(*edgeIt); if (nullptr == edge) { qDebug() << "Find edge failed:" << *edgeIt; continue; @@ -791,13 +792,13 @@ void SkeletonDocument::joinNodeAndNeiborsToGroup(std::vector *group, QUui } } -void SkeletonDocument::splitPartByNode(std::vector> *groups, QUuid nodeId) +void Document::splitPartByNode(std::vector> *groups, QUuid nodeId) { - const SkeletonNode *node = findNode(nodeId); + const Node *node = findNode(nodeId); std::set visitMap; for (auto edgeIt = node->edgeIds.begin(); edgeIt != node->edgeIds.end(); edgeIt++) { std::vector group; - const SkeletonEdge *edge = findEdge(*edgeIt); + const Edge *edge = findEdge(*edgeIt); if (nullptr == edge) { qDebug() << "Find edge failed:" << *edgeIt; continue; @@ -808,9 +809,9 @@ void SkeletonDocument::splitPartByNode(std::vector> *groups, } } -void SkeletonDocument::splitPartByEdge(std::vector> *groups, QUuid edgeId) +void Document::splitPartByEdge(std::vector> *groups, QUuid edgeId) { - const SkeletonEdge *edge = findEdge(edgeId); + const Edge *edge = findEdge(edgeId); if (nullptr == edge) { qDebug() << "Find edge failed:" << edgeId; return; @@ -824,7 +825,7 @@ void SkeletonDocument::splitPartByEdge(std::vector> *groups, } } -void SkeletonDocument::resetDirtyFlags() +void Document::resetDirtyFlags() { for (auto &part: partMap) { part.second.dirty = false; @@ -834,32 +835,32 @@ void SkeletonDocument::resetDirtyFlags() } } -void SkeletonDocument::markAllDirty() +void Document::markAllDirty() { for (auto &part: partMap) { part.second.dirty = true; } } -void SkeletonDocument::toSnapshot(SkeletonSnapshot *snapshot, const std::set &limitNodeIds, - SkeletonDocumentToSnapshotFor forWhat, +void Document::toSnapshot(Snapshot *snapshot, const std::set &limitNodeIds, + DocumentToSnapshotFor forWhat, const std::set &limitPoseIds, const std::set &limitMotionIds, const std::set &limitMaterialIds) const { - if (SkeletonDocumentToSnapshotFor::Document == forWhat || - SkeletonDocumentToSnapshotFor::Nodes == forWhat) { + if (DocumentToSnapshotFor::Document == forWhat || + DocumentToSnapshotFor::Nodes == forWhat) { std::set limitPartIds; std::set limitComponentIds; for (const auto &nodeId: limitNodeIds) { - const SkeletonNode *node = findNode(nodeId); + const Node *node = findNode(nodeId); if (!node) continue; - const SkeletonPart *part = findPart(node->partId); + const Part *part = findPart(node->partId); if (!part) continue; limitPartIds.insert(node->partId); - const SkeletonComponent *component = findComponent(part->componentId); + const Component *component = findComponent(part->componentId); while (component) { limitComponentIds.insert(component->id); if (component->id.isNull()) @@ -903,8 +904,8 @@ void SkeletonDocument::toSnapshot(SkeletonSnapshot *snapshot, const std::setnodes[node["id"]] = node; @@ -965,8 +966,8 @@ void SkeletonDocument::toSnapshot(SkeletonSnapshot *snapshot, const std::setrootComponent["children"] = children; } } - if (SkeletonDocumentToSnapshotFor::Document == forWhat || - SkeletonDocumentToSnapshotFor::Materials == forWhat) { + if (DocumentToSnapshotFor::Document == forWhat || + DocumentToSnapshotFor::Materials == forWhat) { for (const auto &materialId: materialIdList) { if (!limitMaterialIds.empty() && limitMaterialIds.find(materialId) == limitMaterialIds.end()) continue; @@ -997,8 +998,8 @@ void SkeletonDocument::toSnapshot(SkeletonSnapshot *snapshot, const std::setmaterials.push_back(std::make_pair(material, layers)); } } - if (SkeletonDocumentToSnapshotFor::Document == forWhat || - SkeletonDocumentToSnapshotFor::Poses == forWhat) { + if (DocumentToSnapshotFor::Document == forWhat || + DocumentToSnapshotFor::Poses == forWhat) { for (const auto &poseId: poseIdList) { if (!limitPoseIds.empty() && limitPoseIds.find(poseId) == limitPoseIds.end()) continue; @@ -1015,8 +1016,8 @@ void SkeletonDocument::toSnapshot(SkeletonSnapshot *snapshot, const std::setposes.push_back(std::make_pair(pose, poseIt.second.parameters)); } } - if (SkeletonDocumentToSnapshotFor::Document == forWhat || - SkeletonDocumentToSnapshotFor::Motions == forWhat) { + if (DocumentToSnapshotFor::Document == forWhat || + DocumentToSnapshotFor::Motions == forWhat) { for (const auto &motionId: motionIdList) { if (!limitMotionIds.empty() && limitMotionIds.find(motionId) == limitMotionIds.end()) continue; @@ -1041,7 +1042,7 @@ void SkeletonDocument::toSnapshot(SkeletonSnapshot *snapshot, const std::setmotions.push_back(std::make_pair(motion, clips)); } } - if (SkeletonDocumentToSnapshotFor::Document == forWhat) { + if (DocumentToSnapshotFor::Document == forWhat) { std::map canvas; canvas["originX"] = QString::number(originX); canvas["originY"] = QString::number(originY); @@ -1051,7 +1052,7 @@ void SkeletonDocument::toSnapshot(SkeletonSnapshot *snapshot, const std::setsecond.toString(); } } - SkeletonMotionClip clip(linkData, + MotionClip clip(linkData, valueOfKeyInMapOrEmpty(attributes, "linkDataType")); clip.duration = valueOfKeyInMapOrEmpty(attributes, "duration").toFloat(); newMotion.clips.push_back(clip); @@ -1325,7 +1326,7 @@ void SkeletonDocument::addFromSnapshot(const SkeletonSnapshot &snapshot, bool fr emit motionListChanged(); } -void SkeletonDocument::reset() +void Document::reset() { originX = 0.0; originY = 0.0; @@ -1341,20 +1342,20 @@ void SkeletonDocument::reset() poseIdList.clear(); motionMap.clear(); motionIdList.clear(); - rootComponent = SkeletonComponent(); + rootComponent = Component(); removeRigResults(); emit cleanup(); emit skeletonChanged(); } -void SkeletonDocument::fromSnapshot(const SkeletonSnapshot &snapshot) +void Document::fromSnapshot(const Snapshot &snapshot) { reset(); addFromSnapshot(snapshot, false); emit uncheckAll(); } -MeshLoader *SkeletonDocument::takeResultMesh() +MeshLoader *Document::takeResultMesh() { if (nullptr == m_resultMesh) return nullptr; @@ -1362,7 +1363,7 @@ MeshLoader *SkeletonDocument::takeResultMesh() return resultMesh; } -MeshLoader *SkeletonDocument::takeResultTextureMesh() +MeshLoader *Document::takeResultTextureMesh() { if (nullptr == m_resultTextureMesh) return nullptr; @@ -1370,7 +1371,7 @@ MeshLoader *SkeletonDocument::takeResultTextureMesh() return resultTextureMesh; } -MeshLoader *SkeletonDocument::takeResultRigWeightMesh() +MeshLoader *Document::takeResultRigWeightMesh() { if (nullptr == m_resultRigWeightMesh) return nullptr; @@ -1378,10 +1379,10 @@ MeshLoader *SkeletonDocument::takeResultRigWeightMesh() return resultMesh; } -void SkeletonDocument::meshReady() +void Document::meshReady() { MeshLoader *resultMesh = m_meshGenerator->takeResultMesh(); - MeshResultContext *meshResultContext = m_meshGenerator->takeMeshResultContext(); + Outcome *outcome = m_meshGenerator->takeMeshResultContext(); for (auto &partId: m_meshGenerator->generatedPreviewPartIds()) { auto part = partMap.find(partId); @@ -1396,7 +1397,7 @@ void SkeletonDocument::meshReady() m_resultMesh = resultMesh; delete m_currentMeshResultContext; - m_currentMeshResultContext = meshResultContext; + m_currentMeshResultContext = outcome; if (nullptr == m_resultMesh) { qDebug() << "Result mesh is null"; @@ -1417,17 +1418,17 @@ void SkeletonDocument::meshReady() } } -bool SkeletonDocument::isPostProcessResultObsolete() const +bool Document::isPostProcessResultObsolete() const { return m_isPostProcessResultObsolete; } -void SkeletonDocument::batchChangeBegin() +void Document::batchChangeBegin() { m_batchChangeRefCount++; } -void SkeletonDocument::batchChangeEnd() +void Document::batchChangeEnd() { m_batchChangeRefCount--; if (0 == m_batchChangeRefCount) { @@ -1437,25 +1438,25 @@ void SkeletonDocument::batchChangeEnd() } } -void SkeletonDocument::regenerateMesh() +void Document::regenerateMesh() { markAllDirty(); generateMesh(); } -void SkeletonDocument::toggleSmoothNormal() +void Document::toggleSmoothNormal() { m_smoothNormal = !m_smoothNormal; regenerateMesh(); } -void SkeletonDocument::enableWeld(bool enabled) +void Document::enableWeld(bool enabled) { weldEnabled = enabled; regenerateMesh(); } -void SkeletonDocument::generateMesh() +void Document::generateMesh() { if (nullptr != m_meshGenerator || m_batchChangeRefCount > 0) { m_isResultMeshObsolete = true; @@ -1470,7 +1471,7 @@ void SkeletonDocument::generateMesh() QThread *thread = new QThread; - SkeletonSnapshot *snapshot = new SkeletonSnapshot; + Snapshot *snapshot = new Snapshot; toSnapshot(snapshot); resetDirtyFlags(); m_meshGenerator = new MeshGenerator(snapshot); @@ -1484,14 +1485,14 @@ void SkeletonDocument::generateMesh() } m_meshGenerator->moveToThread(thread); connect(thread, &QThread::started, m_meshGenerator, &MeshGenerator::process); - connect(m_meshGenerator, &MeshGenerator::finished, this, &SkeletonDocument::meshReady); + connect(m_meshGenerator, &MeshGenerator::finished, this, &Document::meshReady); connect(m_meshGenerator, &MeshGenerator::finished, thread, &QThread::quit); connect(thread, &QThread::finished, thread, &QThread::deleteLater); emit meshGenerating(); thread->start(); } -void SkeletonDocument::generateTexture() +void Document::generateTexture() { if (nullptr != m_textureGenerator) { m_isTextureObsolete = true; @@ -1502,21 +1503,21 @@ void SkeletonDocument::generateTexture() m_isTextureObsolete = false; - SkeletonSnapshot *snapshot = new SkeletonSnapshot; + Snapshot *snapshot = new Snapshot; toSnapshot(snapshot); QThread *thread = new QThread; m_textureGenerator = new TextureGenerator(*m_postProcessedResultContext, snapshot); m_textureGenerator->moveToThread(thread); connect(thread, &QThread::started, m_textureGenerator, &TextureGenerator::process); - connect(m_textureGenerator, &TextureGenerator::finished, this, &SkeletonDocument::textureReady); + connect(m_textureGenerator, &TextureGenerator::finished, this, &Document::textureReady); connect(m_textureGenerator, &TextureGenerator::finished, thread, &QThread::quit); connect(thread, &QThread::finished, thread, &QThread::deleteLater); emit textureGenerating(); thread->start(); } -void SkeletonDocument::textureReady() +void Document::textureReady() { delete textureGuideImage; textureGuideImage = m_textureGenerator->takeResultTextureGuideImage(); @@ -1552,7 +1553,7 @@ void SkeletonDocument::textureReady() } } -void SkeletonDocument::bakeAmbientOcclusionTexture() +void Document::bakeAmbientOcclusionTexture() { if (nullptr != m_ambientOcclusionBaker) { return; @@ -1575,13 +1576,13 @@ void SkeletonDocument::bakeAmbientOcclusionTexture() m_ambientOcclusionBaker->setRenderThread(thread); m_ambientOcclusionBaker->moveToThread(thread); connect(thread, &QThread::started, m_ambientOcclusionBaker, &AmbientOcclusionBaker::process); - connect(m_ambientOcclusionBaker, &AmbientOcclusionBaker::finished, this, &SkeletonDocument::ambientOcclusionTextureReady); + connect(m_ambientOcclusionBaker, &AmbientOcclusionBaker::finished, this, &Document::ambientOcclusionTextureReady); connect(m_ambientOcclusionBaker, &AmbientOcclusionBaker::finished, thread, &QThread::quit); connect(thread, &QThread::finished, thread, &QThread::deleteLater); thread->start(); } -void SkeletonDocument::ambientOcclusionTextureReady() +void Document::ambientOcclusionTextureReady() { m_ambientOcclusionBakedImageUpdateVersion = m_ambientOcclusionBaker->getImageUpdateVersion(); @@ -1620,7 +1621,7 @@ void SkeletonDocument::ambientOcclusionTextureReady() } } -void SkeletonDocument::postProcess() +void Document::postProcess() { if (nullptr != m_postProcessor) { m_isPostProcessResultObsolete = true; @@ -1640,14 +1641,14 @@ void SkeletonDocument::postProcess() m_postProcessor = new MeshResultPostProcessor(*m_currentMeshResultContext); m_postProcessor->moveToThread(thread); connect(thread, &QThread::started, m_postProcessor, &MeshResultPostProcessor::process); - connect(m_postProcessor, &MeshResultPostProcessor::finished, this, &SkeletonDocument::postProcessedMeshResultReady); + connect(m_postProcessor, &MeshResultPostProcessor::finished, this, &Document::postProcessedMeshResultReady); connect(m_postProcessor, &MeshResultPostProcessor::finished, thread, &QThread::quit); connect(thread, &QThread::finished, thread, &QThread::deleteLater); emit postProcessing(); thread->start(); } -void SkeletonDocument::postProcessedMeshResultReady() +void Document::postProcessedMeshResultReady() { delete m_postProcessedResultContext; m_postProcessedResultContext = m_postProcessor->takePostProcessedResultContext(); @@ -1664,12 +1665,12 @@ void SkeletonDocument::postProcessedMeshResultReady() } } -const MeshResultContext &SkeletonDocument::currentPostProcessedResultContext() const +const Outcome &Document::currentPostProcessedResultContext() const { return *m_postProcessedResultContext; } -void SkeletonDocument::setPartLockState(QUuid partId, bool locked) +void Document::setPartLockState(QUuid partId, bool locked) { auto part = partMap.find(partId); if (part == partMap.end()) { @@ -1683,7 +1684,7 @@ void SkeletonDocument::setPartLockState(QUuid partId, bool locked) emit optionsChanged(); } -void SkeletonDocument::setPartVisibleState(QUuid partId, bool visible) +void Document::setPartVisibleState(QUuid partId, bool visible) { auto part = partMap.find(partId); if (part == partMap.end()) { @@ -1697,7 +1698,7 @@ void SkeletonDocument::setPartVisibleState(QUuid partId, bool visible) emit optionsChanged(); } -void SkeletonDocument::setComponentInverseState(QUuid componentId, bool inverse) +void Document::setComponentInverseState(QUuid componentId, bool inverse) { auto component = componentMap.find(componentId); if (component == componentMap.end()) { @@ -1712,7 +1713,7 @@ void SkeletonDocument::setComponentInverseState(QUuid componentId, bool inverse) emit skeletonChanged(); } -void SkeletonDocument::setComponentSmoothAll(QUuid componentId, float toSmoothAll) +void Document::setComponentSmoothAll(QUuid componentId, float toSmoothAll) { auto component = componentMap.find(componentId); if (component == componentMap.end()) { @@ -1725,7 +1726,7 @@ void SkeletonDocument::setComponentSmoothAll(QUuid componentId, float toSmoothAl emit skeletonChanged(); } -void SkeletonDocument::setComponentSmoothSeam(QUuid componentId, float toSmoothSeam) +void Document::setComponentSmoothSeam(QUuid componentId, float toSmoothSeam) { auto component = componentMap.find(componentId); if (component == componentMap.end()) { @@ -1738,7 +1739,7 @@ void SkeletonDocument::setComponentSmoothSeam(QUuid componentId, float toSmoothS emit skeletonChanged(); } -void SkeletonDocument::setPartSubdivState(QUuid partId, bool subdived) +void Document::setPartSubdivState(QUuid partId, bool subdived) { auto part = partMap.find(partId); if (part == partMap.end()) { @@ -1753,7 +1754,7 @@ void SkeletonDocument::setPartSubdivState(QUuid partId, bool subdived) emit skeletonChanged(); } -void SkeletonDocument::setPartDisableState(QUuid partId, bool disabled) +void Document::setPartDisableState(QUuid partId, bool disabled) { auto part = partMap.find(partId); if (part == partMap.end()) { @@ -1768,7 +1769,7 @@ void SkeletonDocument::setPartDisableState(QUuid partId, bool disabled) emit skeletonChanged(); } -const SkeletonComponent *SkeletonDocument::findComponentParent(QUuid componentId) const +const Component *Document::findComponentParent(QUuid componentId) const { auto component = componentMap.find(componentId); if (component == componentMap.end()) { @@ -1779,10 +1780,10 @@ const SkeletonComponent *SkeletonDocument::findComponentParent(QUuid componentId if (component->second.parentId.isNull()) return &rootComponent; - return (SkeletonComponent *)findComponent(component->second.parentId); + return (Component *)findComponent(component->second.parentId); } -QUuid SkeletonDocument::findComponentParentId(QUuid componentId) const +QUuid Document::findComponentParentId(QUuid componentId) const { auto component = componentMap.find(componentId); if (component == componentMap.end()) { @@ -1793,9 +1794,9 @@ QUuid SkeletonDocument::findComponentParentId(QUuid componentId) const return component->second.parentId; } -void SkeletonDocument::moveComponentUp(QUuid componentId) +void Document::moveComponentUp(QUuid componentId) { - SkeletonComponent *parent = (SkeletonComponent *)findComponentParent(componentId); + Component *parent = (Component *)findComponentParent(componentId); if (nullptr == parent) return; @@ -1807,9 +1808,9 @@ void SkeletonDocument::moveComponentUp(QUuid componentId) emit skeletonChanged(); } -void SkeletonDocument::moveComponentDown(QUuid componentId) +void Document::moveComponentDown(QUuid componentId) { - SkeletonComponent *parent = (SkeletonComponent *)findComponentParent(componentId); + Component *parent = (Component *)findComponentParent(componentId); if (nullptr == parent) return; @@ -1821,9 +1822,9 @@ void SkeletonDocument::moveComponentDown(QUuid componentId) emit skeletonChanged(); } -void SkeletonDocument::moveComponentToTop(QUuid componentId) +void Document::moveComponentToTop(QUuid componentId) { - SkeletonComponent *parent = (SkeletonComponent *)findComponentParent(componentId); + Component *parent = (Component *)findComponentParent(componentId); if (nullptr == parent) return; @@ -1835,9 +1836,9 @@ void SkeletonDocument::moveComponentToTop(QUuid componentId) emit skeletonChanged(); } -void SkeletonDocument::moveComponentToBottom(QUuid componentId) +void Document::moveComponentToBottom(QUuid componentId) { - SkeletonComponent *parent = (SkeletonComponent *)findComponentParent(componentId); + Component *parent = (Component *)findComponentParent(componentId); if (nullptr == parent) return; @@ -1849,7 +1850,7 @@ void SkeletonDocument::moveComponentToBottom(QUuid componentId) emit skeletonChanged(); } -void SkeletonDocument::renameComponent(QUuid componentId, QString name) +void Document::renameComponent(QUuid componentId, QString name) { auto component = componentMap.find(componentId); if (component == componentMap.end()) { @@ -1866,7 +1867,7 @@ void SkeletonDocument::renameComponent(QUuid componentId, QString name) emit optionsChanged(); } -void SkeletonDocument::setComponentExpandState(QUuid componentId, bool expanded) +void Document::setComponentExpandState(QUuid componentId, bool expanded) { auto component = componentMap.find(componentId); if (component == componentMap.end()) { @@ -1882,7 +1883,7 @@ void SkeletonDocument::setComponentExpandState(QUuid componentId, bool expanded) emit optionsChanged(); } -void SkeletonDocument::createNewComponentAndMoveThisIn(QUuid componentId) +void Document::createNewComponentAndMoveThisIn(QUuid componentId) { auto component = componentMap.find(componentId); if (component == componentMap.end()) { @@ -1890,9 +1891,9 @@ void SkeletonDocument::createNewComponentAndMoveThisIn(QUuid componentId) return; } - SkeletonComponent *oldParent = (SkeletonComponent *)findComponentParent(componentId); + Component *oldParent = (Component *)findComponentParent(componentId); - SkeletonComponent newParent(QUuid::createUuid()); + Component newParent(QUuid::createUuid()); newParent.name = tr("Group") + " " + QString::number(componentMap.size() - partMap.size() + 1); oldParent->replaceChild(componentId, newParent.id); @@ -1907,15 +1908,15 @@ void SkeletonDocument::createNewComponentAndMoveThisIn(QUuid componentId) emit optionsChanged(); } -void SkeletonDocument::createNewChildComponent(QUuid parentComponentId) +void Document::createNewChildComponent(QUuid parentComponentId) { - SkeletonComponent *parentComponent = (SkeletonComponent *)findComponent(parentComponentId); + Component *parentComponent = (Component *)findComponent(parentComponentId); if (!parentComponent->linkToPartId.isNull()) { parentComponentId = parentComponent->parentId; - parentComponent = (SkeletonComponent *)findComponent(parentComponentId); + parentComponent = (Component *)findComponent(parentComponentId); } - SkeletonComponent newComponent(QUuid::createUuid()); + Component newComponent(QUuid::createUuid()); newComponent.name = tr("Group") + " " + QString::number(componentMap.size() - partMap.size() + 1); parentComponent->addChild(newComponent.id); @@ -1928,7 +1929,7 @@ void SkeletonDocument::createNewChildComponent(QUuid parentComponentId) emit optionsChanged(); } -void SkeletonDocument::removePart(QUuid partId) +void Document::removePart(QUuid partId) { auto part = partMap.find(partId); if (part == partMap.end()) { @@ -1944,7 +1945,7 @@ void SkeletonDocument::removePart(QUuid partId) removePartDontCareComponent(partId); } -void SkeletonDocument::removePartDontCareComponent(QUuid partId) +void Document::removePartDontCareComponent(QUuid partId) { auto part = partMap.find(partId); if (part == partMap.end()) { @@ -1984,9 +1985,9 @@ void SkeletonDocument::removePartDontCareComponent(QUuid partId) emit partRemoved(partId); } -void SkeletonDocument::addPartToComponent(QUuid partId, QUuid componentId) +void Document::addPartToComponent(QUuid partId, QUuid componentId) { - SkeletonComponent child(QUuid::createUuid()); + Component child(QUuid::createUuid()); if (!componentId.isNull()) { auto parentComponent = componentMap.find(componentId); @@ -2009,13 +2010,13 @@ void SkeletonDocument::addPartToComponent(QUuid partId, QUuid componentId) emit componentAdded(child.id); } -void SkeletonDocument::removeComponent(QUuid componentId) +void Document::removeComponent(QUuid componentId) { removeComponentRecursively(componentId); emit skeletonChanged(); } -void SkeletonDocument::removeComponentRecursively(QUuid componentId) +void Document::removeComponentRecursively(QUuid componentId) { auto component = componentMap.find(componentId); if (component == componentMap.end()) { @@ -2049,10 +2050,10 @@ void SkeletonDocument::removeComponentRecursively(QUuid componentId) emit componentChildrenChanged(parentId); } -void SkeletonDocument::setCurrentCanvasComponentId(QUuid componentId) +void Document::setCurrentCanvasComponentId(QUuid componentId) { m_currentCanvasComponentId = componentId; - const SkeletonComponent *component = findComponent(m_currentCanvasComponentId); + const Component *component = findComponent(m_currentCanvasComponentId); if (nullptr == component) { //qDebug() << "Current component switch to nullptr componentId:" << componentId; m_currentCanvasComponentId = QUuid(); @@ -2068,9 +2069,9 @@ void SkeletonDocument::setCurrentCanvasComponentId(QUuid componentId) } } -void SkeletonDocument::addComponent(QUuid parentId) +void Document::addComponent(QUuid parentId) { - SkeletonComponent component(QUuid::createUuid()); + Component component(QUuid::createUuid()); if (!parentId.isNull()) { auto parentComponent = componentMap.find(parentId); @@ -2090,9 +2091,9 @@ void SkeletonDocument::addComponent(QUuid parentId) emit componentAdded(component.id); } -bool SkeletonDocument::isDescendantComponent(QUuid componentId, QUuid suspiciousId) +bool Document::isDescendantComponent(QUuid componentId, QUuid suspiciousId) { - const SkeletonComponent *loopComponent = findComponentParent(suspiciousId); + const Component *loopComponent = findComponentParent(suspiciousId); while (nullptr != loopComponent) { if (loopComponent->id == componentId) return true; @@ -2101,7 +2102,7 @@ bool SkeletonDocument::isDescendantComponent(QUuid componentId, QUuid suspicious return false; } -void SkeletonDocument::moveComponent(QUuid componentId, QUuid toParentId) +void Document::moveComponent(QUuid componentId, QUuid toParentId) { if (componentId == toParentId) return; @@ -2147,11 +2148,11 @@ void SkeletonDocument::moveComponent(QUuid componentId, QUuid toParentId) emit skeletonChanged(); } -void SkeletonDocument::settleOrigin() +void Document::settleOrigin() { if (originSettled()) return; - SkeletonSnapshot snapshot; + Snapshot snapshot; toSnapshot(&snapshot); QRectF mainProfile; QRectF sideProfile; @@ -2163,7 +2164,7 @@ void SkeletonDocument::settleOrigin() emit originChanged(); } -void SkeletonDocument::setPartXmirrorState(QUuid partId, bool mirrored) +void Document::setPartXmirrorState(QUuid partId, bool mirrored) { auto part = partMap.find(partId); if (part == partMap.end()) { @@ -2179,7 +2180,7 @@ void SkeletonDocument::setPartXmirrorState(QUuid partId, bool mirrored) emit skeletonChanged(); } -void SkeletonDocument::setPartZmirrorState(QUuid partId, bool mirrored) +void Document::setPartZmirrorState(QUuid partId, bool mirrored) { auto part = partMap.find(partId); if (part == partMap.end()) { @@ -2195,7 +2196,7 @@ void SkeletonDocument::setPartZmirrorState(QUuid partId, bool mirrored) emit skeletonChanged(); } -void SkeletonDocument::setPartDeformThickness(QUuid partId, float thickness) +void Document::setPartDeformThickness(QUuid partId, float thickness) { auto part = partMap.find(partId); if (part == partMap.end()) { @@ -2208,7 +2209,7 @@ void SkeletonDocument::setPartDeformThickness(QUuid partId, float thickness) emit skeletonChanged(); } -void SkeletonDocument::setPartDeformWidth(QUuid partId, float width) +void Document::setPartDeformWidth(QUuid partId, float width) { auto part = partMap.find(partId); if (part == partMap.end()) { @@ -2221,7 +2222,7 @@ void SkeletonDocument::setPartDeformWidth(QUuid partId, float width) emit skeletonChanged(); } -void SkeletonDocument::setPartMaterialId(QUuid partId, QUuid materialId) +void Document::setPartMaterialId(QUuid partId, QUuid materialId) { auto part = partMap.find(partId); if (part == partMap.end()) { @@ -2236,7 +2237,7 @@ void SkeletonDocument::setPartMaterialId(QUuid partId, QUuid materialId) emit textureChanged(); } -void SkeletonDocument::setPartRoundState(QUuid partId, bool rounded) +void Document::setPartRoundState(QUuid partId, bool rounded) { auto part = partMap.find(partId); if (part == partMap.end()) { @@ -2251,7 +2252,7 @@ void SkeletonDocument::setPartRoundState(QUuid partId, bool rounded) emit skeletonChanged(); } -void SkeletonDocument::setPartWrapState(QUuid partId, bool wrapped) +void Document::setPartWrapState(QUuid partId, bool wrapped) { auto part = partMap.find(partId); if (part == partMap.end()) { @@ -2266,7 +2267,7 @@ void SkeletonDocument::setPartWrapState(QUuid partId, bool wrapped) emit skeletonChanged(); } -void SkeletonDocument::setPartColorState(QUuid partId, bool hasColor, QColor color) +void Document::setPartColorState(QUuid partId, bool hasColor, QColor color) { auto part = partMap.find(partId); if (part == partMap.end()) { @@ -2282,17 +2283,17 @@ void SkeletonDocument::setPartColorState(QUuid partId, bool hasColor, QColor col emit skeletonChanged(); } -void SkeletonDocument::saveSnapshot() +void Document::saveSnapshot() { if (m_undoItems.size() + 1 > m_maxSnapshot) m_undoItems.pop_front(); - SkeletonHistoryItem item; + HistoryItem item; toSnapshot(&item.snapshot); m_undoItems.push_back(item); qDebug() << "Undo items:" << m_undoItems.size(); } -void SkeletonDocument::undo() +void Document::undo() { if (m_undoItems.empty()) return; @@ -2302,7 +2303,7 @@ void SkeletonDocument::undo() qDebug() << "Undo/Redo items:" << m_undoItems.size() << m_redoItems.size(); } -void SkeletonDocument::redo() +void Document::redo() { if (m_redoItems.empty()) return; @@ -2312,19 +2313,19 @@ void SkeletonDocument::redo() qDebug() << "Undo/Redo items:" << m_undoItems.size() << m_redoItems.size(); } -void SkeletonDocument::paste() +void Document::paste() { const QClipboard *clipboard = QApplication::clipboard(); const QMimeData *mimeData = clipboard->mimeData(); if (mimeData->hasText()) { QXmlStreamReader xmlStreamReader(mimeData->text()); - SkeletonSnapshot snapshot; + Snapshot snapshot; loadSkeletonFromXmlStream(&snapshot, xmlStreamReader); addFromSnapshot(snapshot, true); } } -bool SkeletonDocument::hasPastableNodesInClipboard() const +bool Document::hasPastableNodesInClipboard() const { const QClipboard *clipboard = QApplication::clipboard(); const QMimeData *mimeData = clipboard->mimeData(); @@ -2335,7 +2336,7 @@ bool SkeletonDocument::hasPastableNodesInClipboard() const return false; } -bool SkeletonDocument::hasPastableMaterialsInClipboard() const +bool Document::hasPastableMaterialsInClipboard() const { const QClipboard *clipboard = QApplication::clipboard(); const QMimeData *mimeData = clipboard->mimeData(); @@ -2346,7 +2347,7 @@ bool SkeletonDocument::hasPastableMaterialsInClipboard() const return false; } -bool SkeletonDocument::hasPastablePosesInClipboard() const +bool Document::hasPastablePosesInClipboard() const { const QClipboard *clipboard = QApplication::clipboard(); const QMimeData *mimeData = clipboard->mimeData(); @@ -2357,7 +2358,7 @@ bool SkeletonDocument::hasPastablePosesInClipboard() const return false; } -bool SkeletonDocument::hasPastableMotionsInClipboard() const +bool Document::hasPastableMotionsInClipboard() const { const QClipboard *clipboard = QApplication::clipboard(); const QMimeData *mimeData = clipboard->mimeData(); @@ -2368,19 +2369,19 @@ bool SkeletonDocument::hasPastableMotionsInClipboard() const return false; } -bool SkeletonDocument::undoable() const +bool Document::undoable() const { return !m_undoItems.empty(); } -bool SkeletonDocument::redoable() const +bool Document::redoable() const { return !m_redoItems.empty(); } -bool SkeletonDocument::isNodeEditable(QUuid nodeId) const +bool Document::isNodeEditable(QUuid nodeId) const { - const SkeletonNode *node = findNode(nodeId); + const Node *node = findNode(nodeId); if (!node) { qDebug() << "Node id not found:" << nodeId; return false; @@ -2388,9 +2389,9 @@ bool SkeletonDocument::isNodeEditable(QUuid nodeId) const return !isPartReadonly(node->partId); } -bool SkeletonDocument::isEdgeEditable(QUuid edgeId) const +bool Document::isEdgeEditable(QUuid edgeId) const { - const SkeletonEdge *edge = findEdge(edgeId); + const Edge *edge = findEdge(edgeId); if (!edge) { qDebug() << "Edge id not found:" << edgeId; return false; @@ -2398,7 +2399,7 @@ bool SkeletonDocument::isEdgeEditable(QUuid edgeId) const return !isPartReadonly(edge->partId); } -void SkeletonDocument::setXlockState(bool locked) +void Document::setXlockState(bool locked) { if (xlocked == locked) return; @@ -2406,7 +2407,7 @@ void SkeletonDocument::setXlockState(bool locked) emit xlockStateChanged(); } -void SkeletonDocument::setYlockState(bool locked) +void Document::setYlockState(bool locked) { if (ylocked == locked) return; @@ -2414,7 +2415,7 @@ void SkeletonDocument::setYlockState(bool locked) emit ylockStateChanged(); } -void SkeletonDocument::setZlockState(bool locked) +void Document::setZlockState(bool locked) { if (zlocked == locked) return; @@ -2422,7 +2423,7 @@ void SkeletonDocument::setZlockState(bool locked) emit zlockStateChanged(); } -void SkeletonDocument::setRadiusLockState(bool locked) +void Document::setRadiusLockState(bool locked) { if (radiusLocked == locked) return; @@ -2430,7 +2431,7 @@ void SkeletonDocument::setRadiusLockState(bool locked) emit radiusLockStateChanged(); } -bool SkeletonDocument::isExportReady() const +bool Document::isExportReady() const { if (m_isResultMeshObsolete || m_isTextureObsolete || @@ -2445,13 +2446,13 @@ bool SkeletonDocument::isExportReady() const return true; } -void SkeletonDocument::checkExportReadyState() +void Document::checkExportReadyState() { if (isExportReady()) emit exportReady(); } -void SkeletonDocument::findAllNeighbors(QUuid nodeId, std::set &neighbors) const +void Document::findAllNeighbors(QUuid nodeId, std::set &neighbors) const { const auto &node = findNode(nodeId); if (nullptr == node) { @@ -2477,14 +2478,14 @@ void SkeletonDocument::findAllNeighbors(QUuid nodeId, std::set &neighbors } } -void SkeletonDocument::setSharedContextWidget(QOpenGLWidget *sharedContextWidget) +void Document::setSharedContextWidget(QOpenGLWidget *sharedContextWidget) { m_sharedContextWidget = sharedContextWidget; } -void SkeletonDocument::collectComponentDescendantParts(QUuid componentId, std::vector &partIds) const +void Document::collectComponentDescendantParts(QUuid componentId, std::vector &partIds) const { - const SkeletonComponent *component = findComponent(componentId); + const Component *component = findComponent(componentId); if (nullptr == component) return; @@ -2498,9 +2499,9 @@ void SkeletonDocument::collectComponentDescendantParts(QUuid componentId, std::v } } -void SkeletonDocument::collectComponentDescendantComponents(QUuid componentId, std::vector &componentIds) const +void Document::collectComponentDescendantComponents(QUuid componentId, std::vector &componentIds) const { - const SkeletonComponent *component = findComponent(componentId); + const Component *component = findComponent(componentId); if (nullptr == component) return; @@ -2514,7 +2515,7 @@ void SkeletonDocument::collectComponentDescendantComponents(QUuid componentId, s } } -void SkeletonDocument::hideOtherComponents(QUuid componentId) +void Document::hideOtherComponents(QUuid componentId) { std::vector partIds; collectComponentDescendantParts(componentId, partIds); @@ -2529,7 +2530,7 @@ void SkeletonDocument::hideOtherComponents(QUuid componentId) } } -void SkeletonDocument::lockOtherComponents(QUuid componentId) +void Document::lockOtherComponents(QUuid componentId) { std::vector partIds; collectComponentDescendantParts(componentId, partIds); @@ -2544,21 +2545,21 @@ void SkeletonDocument::lockOtherComponents(QUuid componentId) } } -void SkeletonDocument::hideAllComponents() +void Document::hideAllComponents() { for (const auto &part: partMap) { setPartVisibleState(part.first, false); } } -void SkeletonDocument::showAllComponents() +void Document::showAllComponents() { for (const auto &part: partMap) { setPartVisibleState(part.first, true); } } -void SkeletonDocument::collapseAllComponents() +void Document::collapseAllComponents() { for (const auto &component: componentMap) { if (!component.second.linkToPartId.isNull()) @@ -2567,7 +2568,7 @@ void SkeletonDocument::collapseAllComponents() } } -void SkeletonDocument::expandAllComponents() +void Document::expandAllComponents() { for (const auto &component: componentMap) { if (!component.second.linkToPartId.isNull()) @@ -2576,21 +2577,21 @@ void SkeletonDocument::expandAllComponents() } } -void SkeletonDocument::lockAllComponents() +void Document::lockAllComponents() { for (const auto &part: partMap) { setPartLockState(part.first, true); } } -void SkeletonDocument::unlockAllComponents() +void Document::unlockAllComponents() { for (const auto &part: partMap) { setPartLockState(part.first, false); } } -void SkeletonDocument::hideDescendantComponents(QUuid componentId) +void Document::hideDescendantComponents(QUuid componentId) { std::vector partIds; collectComponentDescendantParts(componentId, partIds); @@ -2599,7 +2600,7 @@ void SkeletonDocument::hideDescendantComponents(QUuid componentId) } } -void SkeletonDocument::showDescendantComponents(QUuid componentId) +void Document::showDescendantComponents(QUuid componentId) { std::vector partIds; collectComponentDescendantParts(componentId, partIds); @@ -2608,7 +2609,7 @@ void SkeletonDocument::showDescendantComponents(QUuid componentId) } } -void SkeletonDocument::lockDescendantComponents(QUuid componentId) +void Document::lockDescendantComponents(QUuid componentId) { std::vector partIds; collectComponentDescendantParts(componentId, partIds); @@ -2617,7 +2618,7 @@ void SkeletonDocument::lockDescendantComponents(QUuid componentId) } } -void SkeletonDocument::unlockDescendantComponents(QUuid componentId) +void Document::unlockDescendantComponents(QUuid componentId) { std::vector partIds; collectComponentDescendantParts(componentId, partIds); @@ -2626,7 +2627,7 @@ void SkeletonDocument::unlockDescendantComponents(QUuid componentId) } } -void SkeletonDocument::generateRig() +void Document::generateRig() { if (nullptr != m_rigGenerator) { m_isRigObsolete = true; @@ -2646,13 +2647,13 @@ void SkeletonDocument::generateRig() m_rigGenerator = new RigGenerator(*m_currentMeshResultContext); m_rigGenerator->moveToThread(thread); connect(thread, &QThread::started, m_rigGenerator, &RigGenerator::process); - connect(m_rigGenerator, &RigGenerator::finished, this, &SkeletonDocument::rigReady); + connect(m_rigGenerator, &RigGenerator::finished, this, &Document::rigReady); connect(m_rigGenerator, &RigGenerator::finished, thread, &QThread::quit); connect(thread, &QThread::finished, thread, &QThread::deleteLater); thread->start(); } -void SkeletonDocument::rigReady() +void Document::rigReady() { m_currentRigSucceed = m_rigGenerator->isSucceed(); @@ -2671,7 +2672,7 @@ void SkeletonDocument::rigReady() delete m_riggedResultContext; m_riggedResultContext = m_rigGenerator->takeMeshResultContext(); if (nullptr == m_riggedResultContext) - m_riggedResultContext = new MeshResultContext; + m_riggedResultContext = new Outcome; delete m_rigGenerator; m_rigGenerator = nullptr; @@ -2687,17 +2688,17 @@ void SkeletonDocument::rigReady() } } -const std::vector *SkeletonDocument::resultRigBones() const +const std::vector *Document::resultRigBones() const { return m_resultRigBones; } -const std::map *SkeletonDocument::resultRigWeights() const +const std::map *Document::resultRigWeights() const { return m_resultRigWeights; } -void SkeletonDocument::removeRigResults() +void Document::removeRigResults() { delete m_resultRigBones; m_resultRigBones = nullptr; @@ -2716,7 +2717,7 @@ void SkeletonDocument::removeRigResults() emit resultRigChanged(); } -void SkeletonDocument::setRigType(RigType toRigType) +void Document::setRigType(RigType toRigType) { if (rigType == toRigType) return; @@ -2731,27 +2732,27 @@ void SkeletonDocument::setRigType(RigType toRigType) emit rigChanged(); } -const std::vector &SkeletonDocument::resultRigMissingMarkNames() const +const std::vector &Document::resultRigMissingMarkNames() const { return m_resultRigMissingMarkNames; } -const std::vector &SkeletonDocument::resultRigErrorMarkNames() const +const std::vector &Document::resultRigErrorMarkNames() const { return m_resultRigErrorMarkNames; } -const MeshResultContext &SkeletonDocument::currentRiggedResultContext() const +const Outcome &Document::currentRiggedResultContext() const { return *m_riggedResultContext; } -bool SkeletonDocument::currentRigSucceed() const +bool Document::currentRigSucceed() const { return m_currentRigSucceed; } -void SkeletonDocument::generateMotions() +void Document::generateMotions() { if (nullptr != m_motionsGenerator) { return; @@ -2789,13 +2790,13 @@ void SkeletonDocument::generateMotions() QThread *thread = new QThread; m_motionsGenerator->moveToThread(thread); connect(thread, &QThread::started, m_motionsGenerator, &MotionsGenerator::process); - connect(m_motionsGenerator, &MotionsGenerator::finished, this, &SkeletonDocument::motionsReady); + connect(m_motionsGenerator, &MotionsGenerator::finished, this, &Document::motionsReady); connect(m_motionsGenerator, &MotionsGenerator::finished, thread, &QThread::quit); connect(thread, &QThread::finished, thread, &QThread::deleteLater); thread->start(); } -void SkeletonDocument::motionsReady() +void Document::motionsReady() { for (auto &motionId: m_motionsGenerator->generatedMotionIds()) { auto motion = motionMap.find(motionId); @@ -2816,7 +2817,7 @@ void SkeletonDocument::motionsReady() generateMotions(); } -void SkeletonDocument::generatePosePreviews() +void Document::generatePosePreviews() { if (nullptr != m_posePreviewsGenerator) { return; @@ -2850,13 +2851,13 @@ void SkeletonDocument::generatePosePreviews() QThread *thread = new QThread; m_posePreviewsGenerator->moveToThread(thread); connect(thread, &QThread::started, m_posePreviewsGenerator, &PosePreviewsGenerator::process); - connect(m_posePreviewsGenerator, &PosePreviewsGenerator::finished, this, &SkeletonDocument::posePreviewsReady); + connect(m_posePreviewsGenerator, &PosePreviewsGenerator::finished, this, &Document::posePreviewsReady); connect(m_posePreviewsGenerator, &PosePreviewsGenerator::finished, thread, &QThread::quit); connect(thread, &QThread::finished, thread, &QThread::deleteLater); thread->start(); } -void SkeletonDocument::posePreviewsReady() +void Document::posePreviewsReady() { for (const auto &poseId: m_posePreviewsGenerator->generatedPreviewPoseIds()) { auto pose = poseMap.find(poseId); @@ -2875,7 +2876,7 @@ void SkeletonDocument::posePreviewsReady() generatePosePreviews(); } -void SkeletonDocument::addMaterial(QString name, std::vector layers) +void Document::addMaterial(QString name, std::vector layers) { QUuid newMaterialId = QUuid::createUuid(); auto &material = materialMap[newMaterialId]; @@ -2892,7 +2893,7 @@ void SkeletonDocument::addMaterial(QString name, std::vector layers) +void Document::setMaterialLayers(QUuid materialId, std::vector layers) { auto findMaterialResult = materialMap.find(materialId); if (findMaterialResult == materialMap.end()) { @@ -2921,7 +2922,7 @@ void SkeletonDocument::setMaterialLayers(QUuid materialId, std::vectormoveToThread(thread); connect(thread, &QThread::started, m_materialPreviewsGenerator, &MaterialPreviewsGenerator::process); - connect(m_materialPreviewsGenerator, &MaterialPreviewsGenerator::finished, this, &SkeletonDocument::materialPreviewsReady); + connect(m_materialPreviewsGenerator, &MaterialPreviewsGenerator::finished, this, &Document::materialPreviewsReady); connect(m_materialPreviewsGenerator, &MaterialPreviewsGenerator::finished, thread, &QThread::quit); connect(thread, &QThread::finished, thread, &QThread::deleteLater); thread->start(); } -void SkeletonDocument::materialPreviewsReady() +void Document::materialPreviewsReady() { for (const auto &materialId: m_materialPreviewsGenerator->generatedPreviewMaterialIds()) { auto material = materialMap.find(materialId); @@ -2988,7 +2989,7 @@ void SkeletonDocument::materialPreviewsReady() generateMaterialPreviews(); } -bool SkeletonDocument::isMeshGenerating() const +bool Document::isMeshGenerating() const { return nullptr != m_meshGenerator; } diff --git a/src/skeletondocument.h b/src/document.h similarity index 84% rename from src/skeletondocument.h rename to src/document.h index 217a5281..680f4af1 100644 --- a/src/skeletondocument.h +++ b/src/document.h @@ -1,5 +1,5 @@ -#ifndef SKELETON_DOCUMENT_H -#define SKELETON_DOCUMENT_H +#ifndef DUST3D_DOCUMENT_H +#define DUST3D_DOCUMENT_H #include #include #include @@ -10,14 +10,14 @@ #include #include #include -#include "skeletonsnapshot.h" +#include "snapshot.h" #include "meshloader.h" #include "meshgenerator.h" #include "theme.h" #include "texturegenerator.h" #include "meshresultpostprocessor.h" #include "ambientocclusionbaker.h" -#include "skeletonbonemark.h" +#include "bonemark.h" #include "riggenerator.h" #include "rigtype.h" #include "posepreviewsgenerator.h" @@ -28,15 +28,15 @@ class MaterialPreviewsGenerator; class MotionsGenerator; -class SkeletonNode +class Node { public: - SkeletonNode(const QUuid &withId=QUuid()) : + Node(const QUuid &withId=QUuid()) : x(0), y(0), z(0), radius(0), - boneMark(SkeletonBoneMark::None) + boneMark(BoneMark::None) { id = withId.isNull() ? QUuid::createUuid() : withId; } @@ -55,14 +55,14 @@ public: float y; float z; float radius; - SkeletonBoneMark boneMark; + BoneMark boneMark; std::vector edgeIds; }; -class SkeletonEdge +class Edge { public: - SkeletonEdge(const QUuid &withId=QUuid()) + Edge(const QUuid &withId=QUuid()) { id = withId.isNull() ? QUuid::createUuid() : withId; } @@ -78,10 +78,10 @@ public: } }; -class SkeletonPart +class Part { public: - ~SkeletonPart() + ~Part() { delete m_previewMesh; } @@ -103,7 +103,7 @@ public: bool dirty; bool wrapped; QUuid materialId; - SkeletonPart(const QUuid &withId=QUuid()) : + Part(const QUuid &withId=QUuid()) : visible(true), locked(false), subdived(false), @@ -156,7 +156,7 @@ public: { return visible && !disabled; } - void copyAttributes(const SkeletonPart &other) + void copyAttributes(const Part &other) { visible = other.visible; locked = other.locked; @@ -186,7 +186,7 @@ public: return new MeshLoader(*m_previewMesh); } private: - Q_DISABLE_COPY(SkeletonPart); + Q_DISABLE_COPY(Part); MeshLoader *m_previewMesh = nullptr; }; @@ -197,13 +197,13 @@ enum class SkeletonProfile Side }; -class SkeletonHistoryItem +class HistoryItem { public: - SkeletonSnapshot snapshot; + Snapshot snapshot; }; -enum class SkeletonDocumentEditMode +enum class DocumentEditMode { Add = 0, Select, @@ -212,13 +212,13 @@ enum class SkeletonDocumentEditMode ZoomOut }; -class SkeletonComponent +class Component { public: - SkeletonComponent() + Component() { } - SkeletonComponent(const QUuid &withId, const QString &linkData=QString(), const QString &linkDataType=QString()) + Component(const QUuid &withId, const QString &linkData=QString(), const QString &linkDataType=QString()) { id = withId.isNull() ? QUuid::createUuid() : withId; if (!linkData.isEmpty()) { @@ -359,13 +359,13 @@ private: std::set m_childrenIdSet; }; -class SkeletonPose +class Pose { public: - SkeletonPose() + Pose() { } - ~SkeletonPose() + ~Pose() { delete m_previewMesh; } @@ -385,76 +385,76 @@ public: return new MeshLoader(*m_previewMesh); } private: - Q_DISABLE_COPY(SkeletonPose); + Q_DISABLE_COPY(Pose); MeshLoader *m_previewMesh = nullptr; }; -enum class SkeletonMotionClipType +enum class MotionClipType { Pose, Interpolation, Motion }; -class SkeletonMotionClip +class MotionClip { public: - SkeletonMotionClip() + MotionClip() { } - SkeletonMotionClip(const QString &linkData, const QString &linkDataType) + MotionClip(const QString &linkData, const QString &linkDataType) { if ("poseId" == linkDataType) { - clipType = SkeletonMotionClipType::Pose; + clipType = MotionClipType::Pose; linkToId = QUuid(linkData); } else if ("InterpolationType" == linkDataType) { - clipType = SkeletonMotionClipType::Interpolation; + clipType = MotionClipType::Interpolation; interpolationType = InterpolationTypeFromString(linkData.toUtf8().constData()); } else if ("motionId" == linkDataType) { - clipType = SkeletonMotionClipType::Motion; + clipType = MotionClipType::Motion; linkToId = QUuid(linkData); } } QString linkDataType() const { - if (SkeletonMotionClipType::Pose == clipType) + if (MotionClipType::Pose == clipType) return "poseId"; - if (SkeletonMotionClipType::Interpolation == clipType) + if (MotionClipType::Interpolation == clipType) return "InterpolationType"; - if (SkeletonMotionClipType::Motion == clipType) + if (MotionClipType::Motion == clipType) return "motionId"; return "poseId"; } QString linkData() const { - if (SkeletonMotionClipType::Pose == clipType) + if (MotionClipType::Pose == clipType) return linkToId.toString(); - if (SkeletonMotionClipType::Interpolation == clipType) + if (MotionClipType::Interpolation == clipType) return InterpolationTypeToString(interpolationType); - if (SkeletonMotionClipType::Motion == clipType) + if (MotionClipType::Motion == clipType) return linkToId.toString(); return linkToId.toString(); } float duration = 0.0; - SkeletonMotionClipType clipType = SkeletonMotionClipType::Pose; + MotionClipType clipType = MotionClipType::Pose; QUuid linkToId; InterpolationType interpolationType; }; -class SkeletonMotion +class Motion { public: - SkeletonMotion() + Motion() { } - ~SkeletonMotion() + ~Motion() { releasePreviewMeshs(); } QUuid id; QString name; bool dirty = true; - std::vector clips; + std::vector clips; std::vector> jointNodeTrees; void updatePreviewMeshs(std::vector> &previewMeshs) { @@ -469,7 +469,7 @@ public: return new MeshLoader(*m_previewMeshs[0].second); } private: - Q_DISABLE_COPY(SkeletonMotion); + Q_DISABLE_COPY(Motion); void releasePreviewMeshs() { for (const auto &item: m_previewMeshs) { @@ -480,33 +480,33 @@ private: std::vector> m_previewMeshs; }; -class SkeletonMaterialMap +class MaterialMap { public: TextureType forWhat; QUuid imageId; }; -class SkeletonMaterialLayer +class MaterialLayer { public: - std::vector maps; + std::vector maps; }; -class SkeletonMaterial +class Material { public: - SkeletonMaterial() + Material() { } - ~SkeletonMaterial() + ~Material() { delete m_previewMesh; } QUuid id; QString name; bool dirty = true; - std::vector layers; + std::vector layers; void updatePreviewMesh(MeshLoader *previewMesh) { delete m_previewMesh; @@ -519,11 +519,11 @@ public: return new MeshLoader(*m_previewMesh); } private: - Q_DISABLE_COPY(SkeletonMaterial); + Q_DISABLE_COPY(Material); MeshLoader *m_previewMesh = nullptr; }; -enum class SkeletonDocumentToSnapshotFor +enum class DocumentToSnapshotFor { Document = 0, Nodes, @@ -532,7 +532,7 @@ enum class SkeletonDocumentToSnapshotFor Motions }; -class SkeletonDocument : public QObject +class Document : public QObject { Q_OBJECT signals: @@ -623,7 +623,7 @@ public: // need initialize float originX; float originY; float originZ; - SkeletonDocumentEditMode editMode; + DocumentEditMode editMode; bool xlocked; bool ylocked; bool zlocked; @@ -636,38 +636,38 @@ public: // need initialize RigType rigType; bool weldEnabled; public: - SkeletonDocument(); - ~SkeletonDocument(); - std::map partMap; - std::map nodeMap; - std::map edgeMap; - std::map componentMap; - std::map materialMap; + Document(); + ~Document(); + std::map partMap; + std::map nodeMap; + std::map edgeMap; + std::map componentMap; + std::map materialMap; std::vector materialIdList; - std::map poseMap; + std::map poseMap; std::vector poseIdList; - std::map motionMap; + std::map motionMap; std::vector motionIdList; - SkeletonComponent rootComponent; + Component rootComponent; QImage turnaround; QImage preview; - void toSnapshot(SkeletonSnapshot *snapshot, const std::set &limitNodeIds=std::set(), - SkeletonDocumentToSnapshotFor forWhat=SkeletonDocumentToSnapshotFor::Document, + void toSnapshot(Snapshot *snapshot, const std::set &limitNodeIds=std::set(), + DocumentToSnapshotFor forWhat=DocumentToSnapshotFor::Document, const std::set &limitPoseIds=std::set(), const std::set &limitMotionIds=std::set(), const std::set &limitMaterialIds=std::set()) const; - void fromSnapshot(const SkeletonSnapshot &snapshot); - void addFromSnapshot(const SkeletonSnapshot &snapshot, bool fromPaste=true); - const SkeletonNode *findNode(QUuid nodeId) const; - const SkeletonEdge *findEdge(QUuid edgeId) const; - const SkeletonPart *findPart(QUuid partId) const; - const SkeletonEdge *findEdgeByNodes(QUuid firstNodeId, QUuid secondNodeId) const; - const SkeletonComponent *findComponent(QUuid componentId) const; - const SkeletonComponent *findComponentParent(QUuid componentId) const; + void fromSnapshot(const Snapshot &snapshot); + void addFromSnapshot(const Snapshot &snapshot, bool fromPaste=true); + const Node *findNode(QUuid nodeId) const; + const Edge *findEdge(QUuid edgeId) const; + const Part *findPart(QUuid partId) const; + const Edge *findEdgeByNodes(QUuid firstNodeId, QUuid secondNodeId) const; + const Component *findComponent(QUuid componentId) const; + const Component *findComponentParent(QUuid componentId) const; QUuid findComponentParentId(QUuid componentId) const; - const SkeletonMaterial *findMaterial(QUuid materialId) const; - const SkeletonPose *findPose(QUuid poseId) const; - const SkeletonMotion *findMotion(QUuid motionId) const; + const Material *findMaterial(QUuid materialId) const; + const Pose *findPose(QUuid poseId) const; + const Motion *findMotion(QUuid motionId) const; MeshLoader *takeResultMesh(); MeshLoader *takeResultTextureMesh(); MeshLoader *takeResultRigWeightMesh(); @@ -684,7 +684,7 @@ public: bool isNodeEditable(QUuid nodeId) const; bool isEdgeEditable(QUuid edgeId) const; bool originSettled() const; - const MeshResultContext ¤tPostProcessedResultContext() const; + const Outcome ¤tPostProcessedResultContext() const; bool isExportReady() const; bool isPostProcessResultObsolete() const; void findAllNeighbors(QUuid nodeId, std::set &neighbors) const; @@ -692,7 +692,7 @@ public: void collectComponentDescendantComponents(QUuid componentId, std::vector &componentIds) const; const std::vector &resultRigMissingMarkNames() const; const std::vector &resultRigErrorMarkNames() const; - const MeshResultContext ¤tRiggedResultContext() const; + const Outcome ¤tRiggedResultContext() const; bool currentRigSucceed() const; bool isMeshGenerating() const; public slots: @@ -704,11 +704,11 @@ public slots: void moveNodeBy(QUuid nodeId, float x, float y, float z); void setNodeOrigin(QUuid nodeId, float x, float y, float z); void setNodeRadius(QUuid nodeId, float radius); - void setNodeBoneMark(QUuid nodeId, SkeletonBoneMark mark); + void setNodeBoneMark(QUuid nodeId, BoneMark mark); void switchNodeXZ(QUuid nodeId); void moveOriginBy(float x, float y, float z); void addEdge(QUuid fromNodeId, QUuid toNodeId); - void setEditMode(SkeletonDocumentEditMode mode); + void setEditMode(DocumentEditMode mode); void uiReady(); void generateMesh(); void regenerateMesh(); @@ -787,13 +787,13 @@ public slots: void removePose(QUuid poseId); void setPoseParameters(QUuid poseId, std::map> parameters); void renamePose(QUuid poseId, QString name); - void addMotion(QString name, std::vector clips); + void addMotion(QString name, std::vector clips); void removeMotion(QUuid motionId); - void setMotionClips(QUuid motionId, std::vector clips); + void setMotionClips(QUuid motionId, std::vector clips); void renameMotion(QUuid motionId, QString name); - void addMaterial(QString name, std::vector); + void addMaterial(QString name, std::vector); void removeMaterial(QUuid materialId); - void setMaterialLayers(QUuid materialId, std::vector layers); + void setMaterialLayers(QUuid materialId, std::vector layers); void renameMaterial(QUuid materialId, QString name); private: void splitPartByNode(std::vector> *groups, QUuid nodeId); @@ -815,12 +815,12 @@ private: // need initialize MeshGenerator *m_meshGenerator; MeshLoader *m_resultMesh; int m_batchChangeRefCount; - MeshResultContext *m_currentMeshResultContext; + Outcome *m_currentMeshResultContext; bool m_isTextureObsolete; TextureGenerator *m_textureGenerator; bool m_isPostProcessResultObsolete; MeshResultPostProcessor *m_postProcessor; - MeshResultContext *m_postProcessedResultContext; + Outcome *m_postProcessedResultContext; MeshLoader *m_resultTextureMesh; unsigned long long m_textureImageUpdateVersion; AmbientOcclusionBaker *m_ambientOcclusionBaker; @@ -834,15 +834,15 @@ private: // need initialize std::vector *m_resultRigBones; std::map *m_resultRigWeights; bool m_isRigObsolete; - MeshResultContext *m_riggedResultContext; + Outcome *m_riggedResultContext; PosePreviewsGenerator *m_posePreviewsGenerator; bool m_currentRigSucceed; MaterialPreviewsGenerator *m_materialPreviewsGenerator; MotionsGenerator *m_motionsGenerator; private: static unsigned long m_maxSnapshot; - std::deque m_undoItems; - std::deque m_redoItems; + std::deque m_undoItems; + std::deque m_redoItems; GeneratedCacheContext m_generatedCacheContext; std::vector m_resultRigMissingMarkNames; std::vector m_resultRigErrorMarkNames; diff --git a/src/skeletondocumentwindow.cpp b/src/documentwindow.cpp similarity index 75% rename from src/skeletondocumentwindow.cpp rename to src/documentwindow.cpp index 599fdeed..c655b426 100644 --- a/src/skeletondocumentwindow.cpp +++ b/src/documentwindow.cpp @@ -15,19 +15,19 @@ #include #include #include -#include "skeletondocumentwindow.h" +#include "documentwindow.h" #include "skeletongraphicswidget.h" #include "theme.h" #include "ds3file.h" -#include "skeletonsnapshot.h" -#include "skeletonxml.h" +#include "snapshot.h" +#include "snapshotxml.h" #include "logbrowser.h" -#include "dust3dutil.h" +#include "util.h" #include "aboutwidget.h" #include "version.h" #include "gltffile.h" #include "graphicscontainerwidget.h" -#include "skeletonparttreewidget.h" +#include "parttreewidget.h" #include "rigwidget.h" #include "markiconcreator.h" #include "motionmanagewidget.h" @@ -113,7 +113,7 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : g_documentWindows.insert(this); - m_document = new SkeletonDocument; + m_document = new Document; QVBoxLayout *toolButtonLayout = new QVBoxLayout; toolButtonLayout->setSpacing(0); @@ -158,19 +158,19 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : SpinnableAwesomeButton *regenerateButton = new SpinnableAwesomeButton(); regenerateButton->setAwesomeIcon(QChar(fa::recycle)); - connect(m_document, &SkeletonDocument::meshGenerating, this, [=]() { + connect(m_document, &Document::meshGenerating, this, [=]() { regenerateButton->showSpinner(true); }); - connect(m_document, &SkeletonDocument::postProcessing, this, [=]() { + connect(m_document, &Document::postProcessing, this, [=]() { regenerateButton->showSpinner(true); }); - connect(m_document, &SkeletonDocument::textureGenerating, this, [=]() { + connect(m_document, &Document::textureGenerating, this, [=]() { regenerateButton->showSpinner(true); }); - connect(m_document, &SkeletonDocument::resultTextureChanged, this, [=]() { + connect(m_document, &Document::resultTextureChanged, this, [=]() { regenerateButton->showSpinner(false); }); - connect(regenerateButton->button(), &QPushButton::clicked, m_document, &SkeletonDocument::regenerateMesh); + connect(regenerateButton->button(), &QPushButton::clicked, m_document, &Document::regenerateMesh); toolButtonLayout->addWidget(addButton); toolButtonLayout->addWidget(selectButton); @@ -231,7 +231,7 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : QDockWidget *partTreeDocker = new QDockWidget(tr("Parts"), this); partTreeDocker->setAllowedAreas(Qt::RightDockWidgetArea); - SkeletonPartTreeWidget *partTreeWidget = new SkeletonPartTreeWidget(m_document, partTreeDocker); + PartTreeWidget *partTreeWidget = new PartTreeWidget(m_document, partTreeDocker); partTreeDocker->setWidget(partTreeWidget); addDockWidget(Qt::RightDockWidgetArea, partTreeDocker); connect(partTreeDocker, &QDockWidget::topLevelChanged, [=](bool topLevel) { @@ -369,16 +369,16 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : m_addAction = new QAction(tr("Add..."), this); connect(m_addAction, &QAction::triggered, [=]() { - m_document->setEditMode(SkeletonDocumentEditMode::Add); + m_document->setEditMode(DocumentEditMode::Add); }); m_editMenu->addAction(m_addAction); m_undoAction = new QAction(tr("Undo"), this); - connect(m_undoAction, &QAction::triggered, m_document, &SkeletonDocument::undo); + connect(m_undoAction, &QAction::triggered, m_document, &Document::undo); m_editMenu->addAction(m_undoAction); m_redoAction = new QAction(tr("Redo"), this); - connect(m_redoAction, &QAction::triggered, m_document, &SkeletonDocument::redo); + connect(m_redoAction, &QAction::triggered, m_document, &Document::redo); m_editMenu->addAction(m_redoAction); m_deleteAction = new QAction(tr("Delete"), this); @@ -402,7 +402,7 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : m_editMenu->addAction(m_copyAction); m_pasteAction = new QAction(tr("Paste"), this); - connect(m_pasteAction, &QAction::triggered, m_document, &SkeletonDocument::paste); + connect(m_pasteAction, &QAction::triggered, m_document, &Document::paste); m_editMenu->addAction(m_pasteAction); m_flipHorizontallyAction = new QAction(tr("H Flip"), this); @@ -463,15 +463,15 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : m_markAsNoneAction = new QAction(tr("None"), this); connect(m_markAsNoneAction, &QAction::triggered, [=]() { - m_graphicsWidget->setSelectedNodesBoneMark(SkeletonBoneMark::None); + m_graphicsWidget->setSelectedNodesBoneMark(BoneMark::None); }); m_markAsMenu->addAction(m_markAsNoneAction); m_markAsMenu->addSeparator(); - for (int i = 0; i < (int)SkeletonBoneMark::Count - 1; i++) { - SkeletonBoneMark boneMark = (SkeletonBoneMark)(i + 1); - m_markAsActions[i] = new QAction(MarkIconCreator::createIcon(boneMark), SkeletonBoneMarkToDispName(boneMark), this); + for (int i = 0; i < (int)BoneMark::Count - 1; i++) { + BoneMark boneMark = (BoneMark)(i + 1); + m_markAsActions[i] = new QAction(MarkIconCreator::createIcon(boneMark), BoneMarkToDispName(boneMark), this); connect(m_markAsActions[i], &QAction::triggered, [=]() { m_graphicsWidget->setSelectedNodesBoneMark(boneMark); }); @@ -648,30 +648,30 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : connect(containerWidget, &GraphicsContainerWidget::containerSizeChanged, graphicsWidget, &SkeletonGraphicsWidget::canvasResized); - connect(m_document, &SkeletonDocument::turnaroundChanged, + connect(m_document, &Document::turnaroundChanged, graphicsWidget, &SkeletonGraphicsWidget::turnaroundChanged); connect(rotateCounterclockwiseButton, &QPushButton::clicked, graphicsWidget, &SkeletonGraphicsWidget::rotateAllMainProfileCounterclockwise90DegreeAlongOrigin); connect(rotateClockwiseButton, &QPushButton::clicked, graphicsWidget, &SkeletonGraphicsWidget::rotateAllMainProfileClockwise90DegreeAlongOrigin); connect(addButton, &QPushButton::clicked, [=]() { - m_document->setEditMode(SkeletonDocumentEditMode::Add); + m_document->setEditMode(DocumentEditMode::Add); }); connect(selectButton, &QPushButton::clicked, [=]() { - m_document->setEditMode(SkeletonDocumentEditMode::Select); + m_document->setEditMode(DocumentEditMode::Select); }); connect(dragButton, &QPushButton::clicked, [=]() { - m_document->setEditMode(SkeletonDocumentEditMode::Drag); + m_document->setEditMode(DocumentEditMode::Drag); }); connect(zoomInButton, &QPushButton::clicked, [=]() { - m_document->setEditMode(SkeletonDocumentEditMode::ZoomIn); + m_document->setEditMode(DocumentEditMode::ZoomIn); }); connect(zoomOutButton, &QPushButton::clicked, [=]() { - m_document->setEditMode(SkeletonDocumentEditMode::ZoomOut); + m_document->setEditMode(DocumentEditMode::ZoomOut); }); connect(m_xlockButton, &QPushButton::clicked, [=]() { @@ -687,7 +687,7 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : m_document->setRadiusLockState(!m_document->radiusLocked); }); - m_partListDockerVisibleSwitchConnection = connect(m_document, &SkeletonDocument::skeletonChanged, [=]() { + m_partListDockerVisibleSwitchConnection = connect(m_document, &Document::skeletonChanged, [=]() { if (m_graphicsWidget->hasItems()) { if (partTreeDocker->isHidden()) partTreeDocker->show(); @@ -695,123 +695,123 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : } }); - connect(m_document, &SkeletonDocument::editModeChanged, graphicsWidget, &SkeletonGraphicsWidget::editModeChanged); + connect(m_document, &Document::editModeChanged, graphicsWidget, &SkeletonGraphicsWidget::editModeChanged); connect(graphicsWidget, &SkeletonGraphicsWidget::zoomRenderedModelBy, m_modelRenderWidget, &ModelWidget::zoom); - connect(graphicsWidget, &SkeletonGraphicsWidget::addNode, m_document, &SkeletonDocument::addNode); - connect(graphicsWidget, &SkeletonGraphicsWidget::scaleNodeByAddRadius, m_document, &SkeletonDocument::scaleNodeByAddRadius); - connect(graphicsWidget, &SkeletonGraphicsWidget::moveNodeBy, m_document, &SkeletonDocument::moveNodeBy); - connect(graphicsWidget, &SkeletonGraphicsWidget::setNodeOrigin, m_document, &SkeletonDocument::setNodeOrigin); - connect(graphicsWidget, &SkeletonGraphicsWidget::setNodeBoneMark, m_document, &SkeletonDocument::setNodeBoneMark); - connect(graphicsWidget, &SkeletonGraphicsWidget::removeNode, m_document, &SkeletonDocument::removeNode); - connect(graphicsWidget, &SkeletonGraphicsWidget::setEditMode, m_document, &SkeletonDocument::setEditMode); - connect(graphicsWidget, &SkeletonGraphicsWidget::removeEdge, m_document, &SkeletonDocument::removeEdge); - connect(graphicsWidget, &SkeletonGraphicsWidget::addEdge, m_document, &SkeletonDocument::addEdge); - connect(graphicsWidget, &SkeletonGraphicsWidget::groupOperationAdded, m_document, &SkeletonDocument::saveSnapshot); - connect(graphicsWidget, &SkeletonGraphicsWidget::undo, m_document, &SkeletonDocument::undo); - connect(graphicsWidget, &SkeletonGraphicsWidget::redo, m_document, &SkeletonDocument::redo); - connect(graphicsWidget, &SkeletonGraphicsWidget::paste, m_document, &SkeletonDocument::paste); - connect(graphicsWidget, &SkeletonGraphicsWidget::batchChangeBegin, m_document, &SkeletonDocument::batchChangeBegin); - connect(graphicsWidget, &SkeletonGraphicsWidget::batchChangeEnd, m_document, &SkeletonDocument::batchChangeEnd); - connect(graphicsWidget, &SkeletonGraphicsWidget::breakEdge, m_document, &SkeletonDocument::breakEdge); - connect(graphicsWidget, &SkeletonGraphicsWidget::moveOriginBy, m_document, &SkeletonDocument::moveOriginBy); - connect(graphicsWidget, &SkeletonGraphicsWidget::partChecked, m_document, &SkeletonDocument::partChecked); - connect(graphicsWidget, &SkeletonGraphicsWidget::partUnchecked, m_document, &SkeletonDocument::partUnchecked); - connect(graphicsWidget, &SkeletonGraphicsWidget::switchNodeXZ, m_document, &SkeletonDocument::switchNodeXZ); + connect(graphicsWidget, &SkeletonGraphicsWidget::addNode, m_document, &Document::addNode); + connect(graphicsWidget, &SkeletonGraphicsWidget::scaleNodeByAddRadius, m_document, &Document::scaleNodeByAddRadius); + connect(graphicsWidget, &SkeletonGraphicsWidget::moveNodeBy, m_document, &Document::moveNodeBy); + connect(graphicsWidget, &SkeletonGraphicsWidget::setNodeOrigin, m_document, &Document::setNodeOrigin); + connect(graphicsWidget, &SkeletonGraphicsWidget::setNodeBoneMark, m_document, &Document::setNodeBoneMark); + connect(graphicsWidget, &SkeletonGraphicsWidget::removeNode, m_document, &Document::removeNode); + connect(graphicsWidget, &SkeletonGraphicsWidget::setEditMode, m_document, &Document::setEditMode); + connect(graphicsWidget, &SkeletonGraphicsWidget::removeEdge, m_document, &Document::removeEdge); + connect(graphicsWidget, &SkeletonGraphicsWidget::addEdge, m_document, &Document::addEdge); + connect(graphicsWidget, &SkeletonGraphicsWidget::groupOperationAdded, m_document, &Document::saveSnapshot); + connect(graphicsWidget, &SkeletonGraphicsWidget::undo, m_document, &Document::undo); + connect(graphicsWidget, &SkeletonGraphicsWidget::redo, m_document, &Document::redo); + connect(graphicsWidget, &SkeletonGraphicsWidget::paste, m_document, &Document::paste); + connect(graphicsWidget, &SkeletonGraphicsWidget::batchChangeBegin, m_document, &Document::batchChangeBegin); + connect(graphicsWidget, &SkeletonGraphicsWidget::batchChangeEnd, m_document, &Document::batchChangeEnd); + connect(graphicsWidget, &SkeletonGraphicsWidget::breakEdge, m_document, &Document::breakEdge); + connect(graphicsWidget, &SkeletonGraphicsWidget::moveOriginBy, m_document, &Document::moveOriginBy); + connect(graphicsWidget, &SkeletonGraphicsWidget::partChecked, m_document, &Document::partChecked); + connect(graphicsWidget, &SkeletonGraphicsWidget::partUnchecked, m_document, &Document::partUnchecked); + connect(graphicsWidget, &SkeletonGraphicsWidget::switchNodeXZ, m_document, &Document::switchNodeXZ); - connect(graphicsWidget, &SkeletonGraphicsWidget::setPartLockState, m_document, &SkeletonDocument::setPartLockState); - connect(graphicsWidget, &SkeletonGraphicsWidget::setPartVisibleState, m_document, &SkeletonDocument::setPartVisibleState); - connect(graphicsWidget, &SkeletonGraphicsWidget::setPartSubdivState, m_document, &SkeletonDocument::setPartSubdivState); - connect(graphicsWidget, &SkeletonGraphicsWidget::setPartDisableState, m_document, &SkeletonDocument::setPartDisableState); - connect(graphicsWidget, &SkeletonGraphicsWidget::setPartXmirrorState, m_document, &SkeletonDocument::setPartXmirrorState); - connect(graphicsWidget, &SkeletonGraphicsWidget::setPartRoundState, m_document, &SkeletonDocument::setPartRoundState); - connect(graphicsWidget, &SkeletonGraphicsWidget::setPartWrapState, m_document, &SkeletonDocument::setPartWrapState); + connect(graphicsWidget, &SkeletonGraphicsWidget::setPartLockState, m_document, &Document::setPartLockState); + connect(graphicsWidget, &SkeletonGraphicsWidget::setPartVisibleState, m_document, &Document::setPartVisibleState); + connect(graphicsWidget, &SkeletonGraphicsWidget::setPartSubdivState, m_document, &Document::setPartSubdivState); + connect(graphicsWidget, &SkeletonGraphicsWidget::setPartDisableState, m_document, &Document::setPartDisableState); + connect(graphicsWidget, &SkeletonGraphicsWidget::setPartXmirrorState, m_document, &Document::setPartXmirrorState); + connect(graphicsWidget, &SkeletonGraphicsWidget::setPartRoundState, m_document, &Document::setPartRoundState); + connect(graphicsWidget, &SkeletonGraphicsWidget::setPartWrapState, m_document, &Document::setPartWrapState); - connect(graphicsWidget, &SkeletonGraphicsWidget::setXlockState, m_document, &SkeletonDocument::setXlockState); - connect(graphicsWidget, &SkeletonGraphicsWidget::setYlockState, m_document, &SkeletonDocument::setYlockState); - connect(graphicsWidget, &SkeletonGraphicsWidget::setZlockState, m_document, &SkeletonDocument::setZlockState); + connect(graphicsWidget, &SkeletonGraphicsWidget::setXlockState, m_document, &Document::setXlockState); + connect(graphicsWidget, &SkeletonGraphicsWidget::setYlockState, m_document, &Document::setYlockState); + connect(graphicsWidget, &SkeletonGraphicsWidget::setZlockState, m_document, &Document::setZlockState); - connect(graphicsWidget, &SkeletonGraphicsWidget::enableAllPositionRelatedLocks, m_document, &SkeletonDocument::enableAllPositionRelatedLocks); - connect(graphicsWidget, &SkeletonGraphicsWidget::disableAllPositionRelatedLocks, m_document, &SkeletonDocument::disableAllPositionRelatedLocks); + connect(graphicsWidget, &SkeletonGraphicsWidget::enableAllPositionRelatedLocks, m_document, &Document::enableAllPositionRelatedLocks); + connect(graphicsWidget, &SkeletonGraphicsWidget::disableAllPositionRelatedLocks, m_document, &Document::disableAllPositionRelatedLocks); connect(graphicsWidget, &SkeletonGraphicsWidget::changeTurnaround, this, &SkeletonDocumentWindow::changeTurnaround); connect(graphicsWidget, &SkeletonGraphicsWidget::save, this, &SkeletonDocumentWindow::save); connect(graphicsWidget, &SkeletonGraphicsWidget::open, this, &SkeletonDocumentWindow::open); - connect(m_document, &SkeletonDocument::nodeAdded, graphicsWidget, &SkeletonGraphicsWidget::nodeAdded); - connect(m_document, &SkeletonDocument::nodeRemoved, graphicsWidget, &SkeletonGraphicsWidget::nodeRemoved); - connect(m_document, &SkeletonDocument::edgeAdded, graphicsWidget, &SkeletonGraphicsWidget::edgeAdded); - connect(m_document, &SkeletonDocument::edgeRemoved, graphicsWidget, &SkeletonGraphicsWidget::edgeRemoved); - connect(m_document, &SkeletonDocument::nodeRadiusChanged, graphicsWidget, &SkeletonGraphicsWidget::nodeRadiusChanged); - connect(m_document, &SkeletonDocument::nodeBoneMarkChanged, graphicsWidget, &SkeletonGraphicsWidget::nodeBoneMarkChanged); - connect(m_document, &SkeletonDocument::nodeOriginChanged, graphicsWidget, &SkeletonGraphicsWidget::nodeOriginChanged); - connect(m_document, &SkeletonDocument::partVisibleStateChanged, graphicsWidget, &SkeletonGraphicsWidget::partVisibleStateChanged); - connect(m_document, &SkeletonDocument::partDisableStateChanged, graphicsWidget, &SkeletonGraphicsWidget::partVisibleStateChanged); - connect(m_document, &SkeletonDocument::cleanup, graphicsWidget, &SkeletonGraphicsWidget::removeAllContent); - connect(m_document, &SkeletonDocument::originChanged, graphicsWidget, &SkeletonGraphicsWidget::originChanged); - connect(m_document, &SkeletonDocument::checkPart, graphicsWidget, &SkeletonGraphicsWidget::selectPartAllById); - connect(m_document, &SkeletonDocument::enableBackgroundBlur, graphicsWidget, &SkeletonGraphicsWidget::enableBackgroundBlur); - connect(m_document, &SkeletonDocument::disableBackgroundBlur, graphicsWidget, &SkeletonGraphicsWidget::disableBackgroundBlur); - connect(m_document, &SkeletonDocument::uncheckAll, graphicsWidget, &SkeletonGraphicsWidget::unselectAll); - connect(m_document, &SkeletonDocument::checkNode, graphicsWidget, &SkeletonGraphicsWidget::addSelectNode); - connect(m_document, &SkeletonDocument::checkEdge, graphicsWidget, &SkeletonGraphicsWidget::addSelectEdge); + connect(m_document, &Document::nodeAdded, graphicsWidget, &SkeletonGraphicsWidget::nodeAdded); + connect(m_document, &Document::nodeRemoved, graphicsWidget, &SkeletonGraphicsWidget::nodeRemoved); + connect(m_document, &Document::edgeAdded, graphicsWidget, &SkeletonGraphicsWidget::edgeAdded); + connect(m_document, &Document::edgeRemoved, graphicsWidget, &SkeletonGraphicsWidget::edgeRemoved); + connect(m_document, &Document::nodeRadiusChanged, graphicsWidget, &SkeletonGraphicsWidget::nodeRadiusChanged); + connect(m_document, &Document::nodeBoneMarkChanged, graphicsWidget, &SkeletonGraphicsWidget::nodeBoneMarkChanged); + connect(m_document, &Document::nodeOriginChanged, graphicsWidget, &SkeletonGraphicsWidget::nodeOriginChanged); + connect(m_document, &Document::partVisibleStateChanged, graphicsWidget, &SkeletonGraphicsWidget::partVisibleStateChanged); + connect(m_document, &Document::partDisableStateChanged, graphicsWidget, &SkeletonGraphicsWidget::partVisibleStateChanged); + connect(m_document, &Document::cleanup, graphicsWidget, &SkeletonGraphicsWidget::removeAllContent); + connect(m_document, &Document::originChanged, graphicsWidget, &SkeletonGraphicsWidget::originChanged); + connect(m_document, &Document::checkPart, graphicsWidget, &SkeletonGraphicsWidget::selectPartAllById); + connect(m_document, &Document::enableBackgroundBlur, graphicsWidget, &SkeletonGraphicsWidget::enableBackgroundBlur); + connect(m_document, &Document::disableBackgroundBlur, graphicsWidget, &SkeletonGraphicsWidget::disableBackgroundBlur); + connect(m_document, &Document::uncheckAll, graphicsWidget, &SkeletonGraphicsWidget::unselectAll); + connect(m_document, &Document::checkNode, graphicsWidget, &SkeletonGraphicsWidget::addSelectNode); + connect(m_document, &Document::checkEdge, graphicsWidget, &SkeletonGraphicsWidget::addSelectEdge); - connect(partTreeWidget, &SkeletonPartTreeWidget::currentComponentChanged, m_document, &SkeletonDocument::setCurrentCanvasComponentId); - connect(partTreeWidget, &SkeletonPartTreeWidget::moveComponentUp, m_document, &SkeletonDocument::moveComponentUp); - connect(partTreeWidget, &SkeletonPartTreeWidget::moveComponentDown, m_document, &SkeletonDocument::moveComponentDown); - connect(partTreeWidget, &SkeletonPartTreeWidget::moveComponentToTop, m_document, &SkeletonDocument::moveComponentToTop); - connect(partTreeWidget, &SkeletonPartTreeWidget::moveComponentToBottom, m_document, &SkeletonDocument::moveComponentToBottom); - connect(partTreeWidget, &SkeletonPartTreeWidget::checkPart, m_document, &SkeletonDocument::checkPart); - connect(partTreeWidget, &SkeletonPartTreeWidget::createNewComponentAndMoveThisIn, m_document, &SkeletonDocument::createNewComponentAndMoveThisIn); - connect(partTreeWidget, &SkeletonPartTreeWidget::createNewChildComponent, m_document, &SkeletonDocument::createNewChildComponent); - connect(partTreeWidget, &SkeletonPartTreeWidget::renameComponent, m_document, &SkeletonDocument::renameComponent); - connect(partTreeWidget, &SkeletonPartTreeWidget::setComponentExpandState, m_document, &SkeletonDocument::setComponentExpandState); - connect(partTreeWidget, &SkeletonPartTreeWidget::setComponentSmoothAll, m_document, &SkeletonDocument::setComponentSmoothAll); - connect(partTreeWidget, &SkeletonPartTreeWidget::setComponentSmoothSeam, m_document, &SkeletonDocument::setComponentSmoothSeam); - connect(partTreeWidget, &SkeletonPartTreeWidget::moveComponent, m_document, &SkeletonDocument::moveComponent); - connect(partTreeWidget, &SkeletonPartTreeWidget::removeComponent, m_document, &SkeletonDocument::removeComponent); - connect(partTreeWidget, &SkeletonPartTreeWidget::hideOtherComponents, m_document, &SkeletonDocument::hideOtherComponents); - connect(partTreeWidget, &SkeletonPartTreeWidget::lockOtherComponents, m_document, &SkeletonDocument::lockOtherComponents); - connect(partTreeWidget, &SkeletonPartTreeWidget::hideAllComponents, m_document, &SkeletonDocument::hideAllComponents); - connect(partTreeWidget, &SkeletonPartTreeWidget::showAllComponents, m_document, &SkeletonDocument::showAllComponents); - connect(partTreeWidget, &SkeletonPartTreeWidget::collapseAllComponents, m_document, &SkeletonDocument::collapseAllComponents); - connect(partTreeWidget, &SkeletonPartTreeWidget::expandAllComponents, m_document, &SkeletonDocument::expandAllComponents); - connect(partTreeWidget, &SkeletonPartTreeWidget::lockAllComponents, m_document, &SkeletonDocument::lockAllComponents); - connect(partTreeWidget, &SkeletonPartTreeWidget::unlockAllComponents, m_document, &SkeletonDocument::unlockAllComponents); - connect(partTreeWidget, &SkeletonPartTreeWidget::setPartLockState, m_document, &SkeletonDocument::setPartLockState); - connect(partTreeWidget, &SkeletonPartTreeWidget::setPartVisibleState, m_document, &SkeletonDocument::setPartVisibleState); - connect(partTreeWidget, &SkeletonPartTreeWidget::setComponentInverseState, m_document, &SkeletonDocument::setComponentInverseState); - connect(partTreeWidget, &SkeletonPartTreeWidget::hideDescendantComponents, m_document, &SkeletonDocument::hideDescendantComponents); - connect(partTreeWidget, &SkeletonPartTreeWidget::showDescendantComponents, m_document, &SkeletonDocument::showDescendantComponents); - connect(partTreeWidget, &SkeletonPartTreeWidget::lockDescendantComponents, m_document, &SkeletonDocument::lockDescendantComponents); - connect(partTreeWidget, &SkeletonPartTreeWidget::unlockDescendantComponents, m_document, &SkeletonDocument::unlockDescendantComponents); + connect(partTreeWidget, &PartTreeWidget::currentComponentChanged, m_document, &Document::setCurrentCanvasComponentId); + connect(partTreeWidget, &PartTreeWidget::moveComponentUp, m_document, &Document::moveComponentUp); + connect(partTreeWidget, &PartTreeWidget::moveComponentDown, m_document, &Document::moveComponentDown); + connect(partTreeWidget, &PartTreeWidget::moveComponentToTop, m_document, &Document::moveComponentToTop); + connect(partTreeWidget, &PartTreeWidget::moveComponentToBottom, m_document, &Document::moveComponentToBottom); + connect(partTreeWidget, &PartTreeWidget::checkPart, m_document, &Document::checkPart); + connect(partTreeWidget, &PartTreeWidget::createNewComponentAndMoveThisIn, m_document, &Document::createNewComponentAndMoveThisIn); + connect(partTreeWidget, &PartTreeWidget::createNewChildComponent, m_document, &Document::createNewChildComponent); + connect(partTreeWidget, &PartTreeWidget::renameComponent, m_document, &Document::renameComponent); + connect(partTreeWidget, &PartTreeWidget::setComponentExpandState, m_document, &Document::setComponentExpandState); + connect(partTreeWidget, &PartTreeWidget::setComponentSmoothAll, m_document, &Document::setComponentSmoothAll); + connect(partTreeWidget, &PartTreeWidget::setComponentSmoothSeam, m_document, &Document::setComponentSmoothSeam); + connect(partTreeWidget, &PartTreeWidget::moveComponent, m_document, &Document::moveComponent); + connect(partTreeWidget, &PartTreeWidget::removeComponent, m_document, &Document::removeComponent); + connect(partTreeWidget, &PartTreeWidget::hideOtherComponents, m_document, &Document::hideOtherComponents); + connect(partTreeWidget, &PartTreeWidget::lockOtherComponents, m_document, &Document::lockOtherComponents); + connect(partTreeWidget, &PartTreeWidget::hideAllComponents, m_document, &Document::hideAllComponents); + connect(partTreeWidget, &PartTreeWidget::showAllComponents, m_document, &Document::showAllComponents); + connect(partTreeWidget, &PartTreeWidget::collapseAllComponents, m_document, &Document::collapseAllComponents); + connect(partTreeWidget, &PartTreeWidget::expandAllComponents, m_document, &Document::expandAllComponents); + connect(partTreeWidget, &PartTreeWidget::lockAllComponents, m_document, &Document::lockAllComponents); + connect(partTreeWidget, &PartTreeWidget::unlockAllComponents, m_document, &Document::unlockAllComponents); + connect(partTreeWidget, &PartTreeWidget::setPartLockState, m_document, &Document::setPartLockState); + connect(partTreeWidget, &PartTreeWidget::setPartVisibleState, m_document, &Document::setPartVisibleState); + connect(partTreeWidget, &PartTreeWidget::setComponentInverseState, m_document, &Document::setComponentInverseState); + connect(partTreeWidget, &PartTreeWidget::hideDescendantComponents, m_document, &Document::hideDescendantComponents); + connect(partTreeWidget, &PartTreeWidget::showDescendantComponents, m_document, &Document::showDescendantComponents); + connect(partTreeWidget, &PartTreeWidget::lockDescendantComponents, m_document, &Document::lockDescendantComponents); + connect(partTreeWidget, &PartTreeWidget::unlockDescendantComponents, m_document, &Document::unlockDescendantComponents); - connect(partTreeWidget, &SkeletonPartTreeWidget::addPartToSelection, graphicsWidget, &SkeletonGraphicsWidget::addPartToSelection); + connect(partTreeWidget, &PartTreeWidget::addPartToSelection, graphicsWidget, &SkeletonGraphicsWidget::addPartToSelection); - connect(m_document, &SkeletonDocument::componentNameChanged, partTreeWidget, &SkeletonPartTreeWidget::componentNameChanged); - connect(m_document, &SkeletonDocument::componentChildrenChanged, partTreeWidget, &SkeletonPartTreeWidget::componentChildrenChanged); - connect(m_document, &SkeletonDocument::componentRemoved, partTreeWidget, &SkeletonPartTreeWidget::componentRemoved); - connect(m_document, &SkeletonDocument::componentAdded, partTreeWidget, &SkeletonPartTreeWidget::componentAdded); - connect(m_document, &SkeletonDocument::componentExpandStateChanged, partTreeWidget, &SkeletonPartTreeWidget::componentExpandStateChanged); - connect(m_document, &SkeletonDocument::partPreviewChanged, partTreeWidget, &SkeletonPartTreeWidget::partPreviewChanged); - connect(m_document, &SkeletonDocument::partLockStateChanged, partTreeWidget, &SkeletonPartTreeWidget::partLockStateChanged); - connect(m_document, &SkeletonDocument::partVisibleStateChanged, partTreeWidget, &SkeletonPartTreeWidget::partVisibleStateChanged); - connect(m_document, &SkeletonDocument::partSubdivStateChanged, partTreeWidget, &SkeletonPartTreeWidget::partSubdivStateChanged); - connect(m_document, &SkeletonDocument::partDisableStateChanged, partTreeWidget, &SkeletonPartTreeWidget::partDisableStateChanged); - connect(m_document, &SkeletonDocument::partXmirrorStateChanged, partTreeWidget, &SkeletonPartTreeWidget::partXmirrorStateChanged); - connect(m_document, &SkeletonDocument::partDeformThicknessChanged, partTreeWidget, &SkeletonPartTreeWidget::partDeformChanged); - connect(m_document, &SkeletonDocument::partDeformWidthChanged, partTreeWidget, &SkeletonPartTreeWidget::partDeformChanged); - connect(m_document, &SkeletonDocument::partRoundStateChanged, partTreeWidget, &SkeletonPartTreeWidget::partRoundStateChanged); - connect(m_document, &SkeletonDocument::partWrapStateChanged, partTreeWidget, &SkeletonPartTreeWidget::partWrapStateChanged); - connect(m_document, &SkeletonDocument::partColorStateChanged, partTreeWidget, &SkeletonPartTreeWidget::partColorStateChanged); - connect(m_document, &SkeletonDocument::partMaterialIdChanged, partTreeWidget, &SkeletonPartTreeWidget::partMaterialIdChanged); - connect(m_document, &SkeletonDocument::partRemoved, partTreeWidget, &SkeletonPartTreeWidget::partRemoved); - connect(m_document, &SkeletonDocument::cleanup, partTreeWidget, &SkeletonPartTreeWidget::removeAllContent); - connect(m_document, &SkeletonDocument::partChecked, partTreeWidget, &SkeletonPartTreeWidget::partChecked); - connect(m_document, &SkeletonDocument::partUnchecked, partTreeWidget, &SkeletonPartTreeWidget::partUnchecked); + connect(m_document, &Document::componentNameChanged, partTreeWidget, &PartTreeWidget::componentNameChanged); + connect(m_document, &Document::componentChildrenChanged, partTreeWidget, &PartTreeWidget::componentChildrenChanged); + connect(m_document, &Document::componentRemoved, partTreeWidget, &PartTreeWidget::componentRemoved); + connect(m_document, &Document::componentAdded, partTreeWidget, &PartTreeWidget::componentAdded); + connect(m_document, &Document::componentExpandStateChanged, partTreeWidget, &PartTreeWidget::componentExpandStateChanged); + connect(m_document, &Document::partPreviewChanged, partTreeWidget, &PartTreeWidget::partPreviewChanged); + connect(m_document, &Document::partLockStateChanged, partTreeWidget, &PartTreeWidget::partLockStateChanged); + connect(m_document, &Document::partVisibleStateChanged, partTreeWidget, &PartTreeWidget::partVisibleStateChanged); + connect(m_document, &Document::partSubdivStateChanged, partTreeWidget, &PartTreeWidget::partSubdivStateChanged); + connect(m_document, &Document::partDisableStateChanged, partTreeWidget, &PartTreeWidget::partDisableStateChanged); + connect(m_document, &Document::partXmirrorStateChanged, partTreeWidget, &PartTreeWidget::partXmirrorStateChanged); + connect(m_document, &Document::partDeformThicknessChanged, partTreeWidget, &PartTreeWidget::partDeformChanged); + connect(m_document, &Document::partDeformWidthChanged, partTreeWidget, &PartTreeWidget::partDeformChanged); + connect(m_document, &Document::partRoundStateChanged, partTreeWidget, &PartTreeWidget::partRoundStateChanged); + connect(m_document, &Document::partWrapStateChanged, partTreeWidget, &PartTreeWidget::partWrapStateChanged); + connect(m_document, &Document::partColorStateChanged, partTreeWidget, &PartTreeWidget::partColorStateChanged); + connect(m_document, &Document::partMaterialIdChanged, partTreeWidget, &PartTreeWidget::partMaterialIdChanged); + connect(m_document, &Document::partRemoved, partTreeWidget, &PartTreeWidget::partRemoved); + connect(m_document, &Document::cleanup, partTreeWidget, &PartTreeWidget::removeAllContent); + connect(m_document, &Document::partChecked, partTreeWidget, &PartTreeWidget::partChecked); + connect(m_document, &Document::partUnchecked, partTreeWidget, &PartTreeWidget::partUnchecked); - connect(m_document, &SkeletonDocument::skeletonChanged, m_document, &SkeletonDocument::generateMesh); + connect(m_document, &Document::skeletonChanged, m_document, &Document::generateMesh); //connect(m_document, &SkeletonDocument::resultMeshChanged, [=]() { // if ((m_exportPreviewWidget && m_exportPreviewWidget->isVisible())) { // m_document->postProcess(); @@ -822,76 +822,76 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : // m_document->generateTexture(); // } //}); - connect(m_document, &SkeletonDocument::textureChanged, m_document, &SkeletonDocument::generateTexture); - connect(m_document, &SkeletonDocument::resultMeshChanged, m_document, &SkeletonDocument::postProcess); - connect(m_document, &SkeletonDocument::resultMeshChanged, m_document, &SkeletonDocument::generateRig); - connect(m_document, &SkeletonDocument::rigChanged, m_document, &SkeletonDocument::generateRig); - connect(m_document, &SkeletonDocument::postProcessedResultChanged, m_document, &SkeletonDocument::generateTexture); + connect(m_document, &Document::textureChanged, m_document, &Document::generateTexture); + connect(m_document, &Document::resultMeshChanged, m_document, &Document::postProcess); + connect(m_document, &Document::resultMeshChanged, m_document, &Document::generateRig); + connect(m_document, &Document::rigChanged, m_document, &Document::generateRig); + connect(m_document, &Document::postProcessedResultChanged, m_document, &Document::generateTexture); //connect(m_document, &SkeletonDocument::resultTextureChanged, m_document, &SkeletonDocument::bakeAmbientOcclusionTexture); - connect(m_document, &SkeletonDocument::resultTextureChanged, [=]() { + connect(m_document, &Document::resultTextureChanged, [=]() { if (m_document->isMeshGenerating()) return; m_modelRenderWidget->updateMesh(m_document->takeResultTextureMesh()); }); - connect(m_document, &SkeletonDocument::resultMeshChanged, [=]() { + connect(m_document, &Document::resultMeshChanged, [=]() { m_modelRenderWidget->updateMesh(m_document->takeResultMesh()); }); - connect(m_document, &SkeletonDocument::posesChanged, m_document, &SkeletonDocument::generateMotions); - connect(m_document, &SkeletonDocument::motionsChanged, m_document, &SkeletonDocument::generateMotions); + connect(m_document, &Document::posesChanged, m_document, &Document::generateMotions); + connect(m_document, &Document::motionsChanged, m_document, &Document::generateMotions); connect(graphicsWidget, &SkeletonGraphicsWidget::cursorChanged, [=]() { m_modelRenderWidget->setCursor(graphicsWidget->cursor()); //m_skeletonRenderWidget->setCursor(graphicsWidget->cursor()); }); - connect(m_document, &SkeletonDocument::skeletonChanged, this, &SkeletonDocumentWindow::documentChanged); - connect(m_document, &SkeletonDocument::turnaroundChanged, this, &SkeletonDocumentWindow::documentChanged); - connect(m_document, &SkeletonDocument::optionsChanged, this, &SkeletonDocumentWindow::documentChanged); - connect(m_document, &SkeletonDocument::rigChanged, this, &SkeletonDocumentWindow::documentChanged); + connect(m_document, &Document::skeletonChanged, this, &SkeletonDocumentWindow::documentChanged); + connect(m_document, &Document::turnaroundChanged, this, &SkeletonDocumentWindow::documentChanged); + connect(m_document, &Document::optionsChanged, this, &SkeletonDocumentWindow::documentChanged); + connect(m_document, &Document::rigChanged, this, &SkeletonDocumentWindow::documentChanged); connect(m_modelRenderWidget, &ModelWidget::customContextMenuRequested, [=](const QPoint &pos) { graphicsWidget->showContextMenu(graphicsWidget->mapFromGlobal(m_modelRenderWidget->mapToGlobal(pos))); }); - connect(m_document, &SkeletonDocument::xlockStateChanged, this, &SkeletonDocumentWindow::updateXlockButtonState); - connect(m_document, &SkeletonDocument::ylockStateChanged, this, &SkeletonDocumentWindow::updateYlockButtonState); - connect(m_document, &SkeletonDocument::zlockStateChanged, this, &SkeletonDocumentWindow::updateZlockButtonState); - connect(m_document, &SkeletonDocument::radiusLockStateChanged, this, &SkeletonDocumentWindow::updateRadiusLockButtonState); + connect(m_document, &Document::xlockStateChanged, this, &SkeletonDocumentWindow::updateXlockButtonState); + connect(m_document, &Document::ylockStateChanged, this, &SkeletonDocumentWindow::updateYlockButtonState); + connect(m_document, &Document::zlockStateChanged, this, &SkeletonDocumentWindow::updateZlockButtonState); + connect(m_document, &Document::radiusLockStateChanged, this, &SkeletonDocumentWindow::updateRadiusLockButtonState); - connect(m_rigWidget, &RigWidget::setRigType, m_document, &SkeletonDocument::setRigType); + connect(m_rigWidget, &RigWidget::setRigType, m_document, &Document::setRigType); - connect(m_document, &SkeletonDocument::rigTypeChanged, m_rigWidget, &RigWidget::rigTypeChanged); - connect(m_document, &SkeletonDocument::resultRigChanged, m_rigWidget, &RigWidget::updateResultInfo); - connect(m_document, &SkeletonDocument::resultRigChanged, this, &SkeletonDocumentWindow::updateRigWeightRenderWidget); + connect(m_document, &Document::rigTypeChanged, m_rigWidget, &RigWidget::rigTypeChanged); + connect(m_document, &Document::resultRigChanged, m_rigWidget, &RigWidget::updateResultInfo); + connect(m_document, &Document::resultRigChanged, this, &SkeletonDocumentWindow::updateRigWeightRenderWidget); //connect(m_document, &SkeletonDocument::resultRigChanged, tetrapodPoseEditWidget, &TetrapodPoseEditWidget::updatePreview); - connect(m_document, &SkeletonDocument::poseAdded, this, [=](QUuid poseId) { + connect(m_document, &Document::poseAdded, this, [=](QUuid poseId) { Q_UNUSED(poseId); m_document->generatePosePreviews(); }); - connect(m_document, &SkeletonDocument::poseParametersChanged, this, [=](QUuid poseId) { + connect(m_document, &Document::poseParametersChanged, this, [=](QUuid poseId) { Q_UNUSED(poseId); m_document->generatePosePreviews(); }); - connect(m_document, &SkeletonDocument::resultRigChanged, m_document, &SkeletonDocument::generatePosePreviews); + connect(m_document, &Document::resultRigChanged, m_document, &Document::generatePosePreviews); - connect(m_document, &SkeletonDocument::resultRigChanged, m_document, &SkeletonDocument::generateMotions); + connect(m_document, &Document::resultRigChanged, m_document, &Document::generateMotions); - connect(m_document, &SkeletonDocument::materialAdded, this, [=](QUuid materialId) { + connect(m_document, &Document::materialAdded, this, [=](QUuid materialId) { Q_UNUSED(materialId); m_document->generateMaterialPreviews(); }); - connect(m_document, &SkeletonDocument::materialLayersChanged, this, [=](QUuid materialId) { + connect(m_document, &Document::materialLayersChanged, this, [=](QUuid materialId) { Q_UNUSED(materialId); m_document->generateMaterialPreviews(); }); initShortCuts(this, m_graphicsWidget); - connect(this, &SkeletonDocumentWindow::initialized, m_document, &SkeletonDocument::uiReady); + connect(this, &SkeletonDocumentWindow::initialized, m_document, &Document::uiReady); QTimer *timer = new QTimer(this); timer->setInterval(250); @@ -1092,7 +1092,7 @@ void SkeletonDocumentWindow::saveTo(const QString &saveAsFilename) QByteArray modelXml; QXmlStreamWriter stream(&modelXml); - SkeletonSnapshot snapshot; + Snapshot snapshot; m_document->toSnapshot(&snapshot); saveSkeletonToXmlStream(&snapshot, &stream); if (modelXml.size() > 0) @@ -1176,7 +1176,7 @@ void SkeletonDocumentWindow::open() QByteArray data; ds3Reader.loadItem(item.name, &data); QXmlStreamReader stream(data); - SkeletonSnapshot snapshot; + Snapshot snapshot; loadSkeletonFromXmlStream(&snapshot, stream); m_document->fromSnapshot(snapshot); m_document->saveSnapshot(); @@ -1223,13 +1223,13 @@ void SkeletonDocumentWindow::showExportPreview() { if (nullptr == m_exportPreviewWidget) { m_exportPreviewWidget = new ExportPreviewWidget(m_document, this); - connect(m_exportPreviewWidget, &ExportPreviewWidget::regenerate, m_document, &SkeletonDocument::regenerateMesh); + connect(m_exportPreviewWidget, &ExportPreviewWidget::regenerate, m_document, &Document::regenerateMesh); connect(m_exportPreviewWidget, &ExportPreviewWidget::saveAsGltf, this, &SkeletonDocumentWindow::exportGltfResult); connect(m_exportPreviewWidget, &ExportPreviewWidget::saveAsFbx, this, &SkeletonDocumentWindow::exportFbxResult); - connect(m_document, &SkeletonDocument::resultMeshChanged, m_exportPreviewWidget, &ExportPreviewWidget::checkSpinner); - connect(m_document, &SkeletonDocument::exportReady, m_exportPreviewWidget, &ExportPreviewWidget::checkSpinner); - connect(m_document, &SkeletonDocument::resultTextureChanged, m_exportPreviewWidget, &ExportPreviewWidget::updateTexturePreview); - connect(m_document, &SkeletonDocument::resultBakedTextureChanged, m_exportPreviewWidget, &ExportPreviewWidget::updateTexturePreview); + connect(m_document, &Document::resultMeshChanged, m_exportPreviewWidget, &ExportPreviewWidget::checkSpinner); + connect(m_document, &Document::exportReady, m_exportPreviewWidget, &ExportPreviewWidget::checkSpinner); + connect(m_document, &Document::resultTextureChanged, m_exportPreviewWidget, &ExportPreviewWidget::updateTexturePreview); + connect(m_document, &Document::resultBakedTextureChanged, m_exportPreviewWidget, &ExportPreviewWidget::updateTexturePreview); registerDialog(m_exportPreviewWidget); } m_exportPreviewWidget->show(); @@ -1248,7 +1248,7 @@ void SkeletonDocumentWindow::exportFbxResult() return; } QApplication::setOverrideCursor(Qt::WaitCursor); - MeshResultContext skeletonResult = m_document->currentPostProcessedResultContext(); + Outcome skeletonResult = m_document->currentPostProcessedResultContext(); FbxFileWriter fbxFileWriter(skeletonResult, m_document->resultRigBones(), m_document->resultRigWeights(), filename); fbxFileWriter.save(); QApplication::restoreOverrideCursor(); @@ -1266,7 +1266,7 @@ void SkeletonDocumentWindow::exportGltfResult() return; } QApplication::setOverrideCursor(Qt::WaitCursor); - MeshResultContext skeletonResult = m_document->currentPostProcessedResultContext(); + Outcome skeletonResult = m_document->currentPostProcessedResultContext(); GltfFileWriter gltfFileWriter(skeletonResult, m_document->resultRigBones(), m_document->resultRigWeights(), filename); gltfFileWriter.save(); if (m_document->textureImage) diff --git a/src/skeletondocumentwindow.h b/src/documentwindow.h similarity index 95% rename from src/skeletondocumentwindow.h rename to src/documentwindow.h index 2a5ea92b..a4cff61b 100644 --- a/src/skeletondocumentwindow.h +++ b/src/documentwindow.h @@ -1,5 +1,5 @@ -#ifndef SKELETON_DOCUMENT_WINDOW_H -#define SKELETON_DOCUMENT_WINDOW_H +#ifndef DUST3D_DOCUMENT_WINDOW_H +#define DUST3D_DOCUMENT_WINDOW_H #include #include #include @@ -7,11 +7,11 @@ #include #include #include -#include "skeletondocument.h" +#include "document.h" #include "modelwidget.h" #include "exportpreviewwidget.h" #include "rigwidget.h" -#include "skeletonbonemark.h" +#include "bonemark.h" #include "posemanagewidget.h" #include "advancesettingwidget.h" @@ -66,7 +66,7 @@ private: void setCurrentFilename(const QString &filename); void updateTitle(); private: - SkeletonDocument *m_document; + Document *m_document; bool m_firstShow; bool m_documentSaved; ExportPreviewWidget *m_exportPreviewWidget; @@ -124,7 +124,7 @@ private: QMenu *m_markAsMenu; QAction *m_markAsNoneAction; - QAction *m_markAsActions[(int)SkeletonBoneMark::Count - 1]; + QAction *m_markAsActions[(int)BoneMark::Count - 1]; QMenu *m_viewMenu; QAction *m_resetModelWidgetPosAction; diff --git a/src/ds3file.h b/src/ds3file.h index d9671573..d7aa61ab 100644 --- a/src/ds3file.h +++ b/src/ds3file.h @@ -1,5 +1,5 @@ -#ifndef DS3_FILE_H -#define DS3_FILE_H +#ifndef DUST3D_DS3_FILE_H +#define DUST3D_DS3_FILE_H #include #include #include diff --git a/src/exportpreviewwidget.cpp b/src/exportpreviewwidget.cpp index 082bf7b0..029c8026 100644 --- a/src/exportpreviewwidget.cpp +++ b/src/exportpreviewwidget.cpp @@ -7,9 +7,9 @@ #include "aboutwidget.h" #include "version.h" #include "theme.h" -#include "dust3dutil.h" +#include "util.h" -ExportPreviewWidget::ExportPreviewWidget(SkeletonDocument *document, QWidget *parent) : +ExportPreviewWidget::ExportPreviewWidget(Document *document, QWidget *parent) : QDialog(parent), m_document(document), m_previewLabel(nullptr), diff --git a/src/exportpreviewwidget.h b/src/exportpreviewwidget.h index 8742757b..08e3a709 100644 --- a/src/exportpreviewwidget.h +++ b/src/exportpreviewwidget.h @@ -1,5 +1,5 @@ -#ifndef EXPORT_PREVIEW_WIDGET_H -#define EXPORT_PREVIEW_WIDGET_H +#ifndef DUST3D_EXPORT_PREVIEW_WIDGET_H +#define DUST3D_EXPORT_PREVIEW_WIDGET_H #include #include #include @@ -7,7 +7,7 @@ #include #include "modelwidget.h" #include "waitingspinnerwidget.h" -#include "skeletondocument.h" +#include "document.h" class ExportPreviewWidget : public QDialog { @@ -17,7 +17,7 @@ signals: void saveAsGltf(); void saveAsFbx(); public: - ExportPreviewWidget(SkeletonDocument *document, QWidget *parent=nullptr); + ExportPreviewWidget(Document *document, QWidget *parent=nullptr); public slots: void checkSpinner(); void updateTexturePreview(); @@ -29,7 +29,7 @@ private: void initAwesomeButton(QPushButton *button); void updateTexturePreviewImage(const QImage &image); private: - SkeletonDocument *m_document; + Document *m_document; QLabel *m_previewLabel; QImage m_previewImage; ModelWidget *m_textureRenderWidget; diff --git a/src/fbxfile.cpp b/src/fbxfile.cpp index 931224e8..271cc55a 100644 --- a/src/fbxfile.cpp +++ b/src/fbxfile.cpp @@ -1470,7 +1470,7 @@ void FbxFileWriter::createDefinitions(size_t deformerCount) m_fbxDocument.nodes.push_back(definitions); } -FbxFileWriter::FbxFileWriter(MeshResultContext &resultContext, +FbxFileWriter::FbxFileWriter(Outcome &outcome, const std::vector *resultRigBones, const std::map *resultRigWeights, const QString &filename) : @@ -1495,13 +1495,13 @@ FbxFileWriter::FbxFileWriter(MeshResultContext &resultContext, geometry.addProperty(std::vector({'u','n','a','m','e','d','m','e','s','h',0,1,'G','e','o','m','e','t','r','y'}), 'S'); geometry.addProperty("Mesh"); std::vector positions; - for (const auto &vertex: resultContext.vertices) { + for (const auto &vertex: outcome.vertices) { positions.push_back((double)vertex.position.x()); positions.push_back((double)vertex.position.y()); positions.push_back((double)vertex.position.z()); } std::vector indicies; - for (const auto &triangle: resultContext.triangles) { + for (const auto &triangle: outcome.triangles) { indicies.push_back(triangle.indicies[0]); indicies.push_back(triangle.indicies[1]); indicies.push_back(triangle.indicies[2] ^ -1); @@ -1513,7 +1513,7 @@ FbxFileWriter::FbxFileWriter(MeshResultContext &resultContext, layerElementNormal.addPropertyNode("MappingInformationType", "ByPolygonVertex"); layerElementNormal.addPropertyNode("ReferenceInformationType", "Direct"); std::vector normals; - const auto &triangleVertexNormals = resultContext.interpolatedTriangleVertexNormals(); + const auto &triangleVertexNormals = outcome.interpolatedTriangleVertexNormals(); for (decltype(triangleVertexNormals.size()) i = 0; i < triangleVertexNormals.size(); ++i) { const auto &n = triangleVertexNormals[i]; normals.push_back((double)n.x()); diff --git a/src/fbxfile.h b/src/fbxfile.h index 7ca51423..901c155c 100644 --- a/src/fbxfile.h +++ b/src/fbxfile.h @@ -1,17 +1,17 @@ -#ifndef FBX_FILE_H -#define FBX_FILE_H +#ifndef DUST3D_FBX_FILE_H +#define DUST3D_FBX_FILE_H #include #include #include #include -#include "meshresultcontext.h" -#include "skeletondocument.h" +#include "outcome.h" +#include "document.h" class FbxFileWriter : public QObject { Q_OBJECT public: - FbxFileWriter(MeshResultContext &resultContext, + FbxFileWriter(Outcome &outcome, const std::vector *resultRigBones, const std::map *resultRigWeights, const QString &filename); diff --git a/src/floatnumberwidget.h b/src/floatnumberwidget.h index 066ea4be..1913bc26 100644 --- a/src/floatnumberwidget.h +++ b/src/floatnumberwidget.h @@ -1,5 +1,5 @@ -#ifndef FLOAT_NUMBER_WIDGET_H -#define FLOAT_NUMBER_WIDGET_H +#ifndef DUST3D_FLOAT_NUMBER_WIDGET_H +#define DUST3D_FLOAT_NUMBER_WIDGET_H #include QT_FORWARD_DECLARE_CLASS(QLabel) diff --git a/src/flowlayout.h b/src/flowlayout.h index 1b359766..b48dd90c 100644 --- a/src/flowlayout.h +++ b/src/flowlayout.h @@ -49,8 +49,8 @@ ****************************************************************************/ -#ifndef FLOWLAYOUT_H -#define FLOWLAYOUT_H +#ifndef DUST3D_FLOWLAYOUT_H +#define DUST3D_FLOWLAYOUT_H #include #include @@ -84,4 +84,4 @@ private: int m_vSpace; }; -#endif // FLOWLAYOUT_H \ No newline at end of file +#endif // FLOWLAYOUT_H diff --git a/src/gltffile.cpp b/src/gltffile.cpp index a8c91aaf..722a3309 100644 --- a/src/gltffile.cpp +++ b/src/gltffile.cpp @@ -6,7 +6,7 @@ #include #include "gltffile.h" #include "version.h" -#include "dust3dutil.h" +#include "util.h" #include "jointnodetree.h" #include "meshloader.h" @@ -21,7 +21,7 @@ bool GltfFileWriter::m_enableComment = true; -GltfFileWriter::GltfFileWriter(MeshResultContext &resultContext, +GltfFileWriter::GltfFileWriter(Outcome &outcome, const std::vector *resultRigBones, const std::map *resultRigWeights, const QString &filename) : @@ -129,12 +129,12 @@ GltfFileWriter::GltfFileWriter(MeshResultContext &resultContext, m_json["samplers"][0]["wrapS"] = 33648; m_json["samplers"][0]["wrapT"] = 33648; - const std::map *parts = &resultContext.parts(); + const std::map *parts = &outcome.parts(); std::map testParts; if (m_testOutputAsWhole) { - testParts[0].vertices = resultContext.vertices; - testParts[0].triangles = resultContext.triangles; + testParts[0].vertices = outcome.vertices; + testParts[0].triangles = outcome.triangles; m_outputNormal = false; m_outputUv = false; diff --git a/src/gltffile.h b/src/gltffile.h index 8ccafc7c..6772d427 100644 --- a/src/gltffile.h +++ b/src/gltffile.h @@ -1,20 +1,20 @@ -#ifndef GLTF_FILE_H -#define GLTF_FILE_H +#ifndef DUST3D_GLTF_FILE_H +#define DUST3D_GLTF_FILE_H #include #include #include #include #include #include -#include "meshresultcontext.h" +#include "outcome.h" #include "json.hpp" -#include "skeletondocument.h" +#include "document.h" class GltfFileWriter : public QObject { Q_OBJECT public: - GltfFileWriter(MeshResultContext &resultContext, + GltfFileWriter(Outcome &outcome, const std::vector *resultRigBones, const std::map *resultRigWeights, const QString &filename); diff --git a/src/graphicscontainerwidget.h b/src/graphicscontainerwidget.h index 7f5fe807..6c99147b 100644 --- a/src/graphicscontainerwidget.h +++ b/src/graphicscontainerwidget.h @@ -1,5 +1,5 @@ -#ifndef GRAPHICS_CONTAINER_WIDGET_H -#define GRAPHICS_CONTAINER_WIDGET_H +#ifndef DUST3D_GRAPHICS_CONTAINER_WIDGET_H +#define DUST3D_GRAPHICS_CONTAINER_WIDGET_H #include #include diff --git a/src/imageforever.h b/src/imageforever.h index dacf0d58..769f598c 100644 --- a/src/imageforever.h +++ b/src/imageforever.h @@ -1,5 +1,5 @@ -#ifndef IMAGE_FOREVER_H -#define IMAGE_FOREVER_H +#ifndef DUST3D_IMAGE_FOREVER_H +#define DUST3D_IMAGE_FOREVER_H #include #include diff --git a/src/infolabel.h b/src/infolabel.h index 760ce061..44e3c445 100644 --- a/src/infolabel.h +++ b/src/infolabel.h @@ -1,5 +1,5 @@ -#ifndef INFO_LABEL_H -#define INFO_LABEL_H +#ifndef DUST3D_INFO_LABEL_H +#define DUST3D_INFO_LABEL_H #include #include #include diff --git a/src/interpolationtype.h b/src/interpolationtype.h index b10180b1..6afd6497 100644 --- a/src/interpolationtype.h +++ b/src/interpolationtype.h @@ -1,5 +1,5 @@ -#ifndef INTERPOLATION_TYPE_H -#define INTERPOLATION_TYPE_H +#ifndef DUST3D_INTERPOLATION_TYPE_H +#define DUST3D_INTERPOLATION_TYPE_H #include #include diff --git a/src/jointnodetree.cpp b/src/jointnodetree.cpp index 383b47bf..c99fb8cc 100644 --- a/src/jointnodetree.cpp +++ b/src/jointnodetree.cpp @@ -1,5 +1,5 @@ #include "jointnodetree.h" -#include "dust3dutil.h" +#include "util.h" const std::vector &JointNodeTree::nodes() const { diff --git a/src/jointnodetree.h b/src/jointnodetree.h index b7484ac6..2751f195 100644 --- a/src/jointnodetree.h +++ b/src/jointnodetree.h @@ -1,5 +1,5 @@ -#ifndef JOINT_NODE_TREE_H -#define JOINT_NODE_TREE_H +#ifndef DUST3D_JOINT_NODE_TREE_H +#define DUST3D_JOINT_NODE_TREE_H #include #include #include diff --git a/src/logbrowser.h b/src/logbrowser.h index f408572c..6c9c9198 100644 --- a/src/logbrowser.h +++ b/src/logbrowser.h @@ -1,5 +1,5 @@ -#ifndef LOG_BROWSER_H -#define LOG_BROWSER_H +#ifndef DUST3D_LOG_BROWSER_H +#define DUST3D_LOG_BROWSER_H // Modified from https://wiki.qt.io/Browser_for_QDebug_output #include diff --git a/src/logbrowserdialog.cpp b/src/logbrowserdialog.cpp index ae2a1ca6..3eb92452 100644 --- a/src/logbrowserdialog.cpp +++ b/src/logbrowserdialog.cpp @@ -12,7 +12,7 @@ #include #include #include "version.h" -#include "dust3dutil.h" +#include "util.h" LogBrowserDialog::LogBrowserDialog(QWidget *parent) : QDialog(parent) diff --git a/src/logbrowserdialog.h b/src/logbrowserdialog.h index 14451809..3cfbc2dc 100644 --- a/src/logbrowserdialog.h +++ b/src/logbrowserdialog.h @@ -1,5 +1,5 @@ -#ifndef LOG_BROWSER_DIALOG_H -#define LOG_BROWSER_DIALOG_H +#ifndef DUST3D_LOG_BROWSER_DIALOG_H +#define DUST3D_LOG_BROWSER_DIALOG_H // Modified from https://wiki.qt.io/Browser_for_QDebug_output #include diff --git a/src/main.cpp b/src/main.cpp index 5d7ae1e4..1c89dfcd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,7 +5,7 @@ #include #include #include -#include "skeletondocumentwindow.h" +#include "documentwindow.h" #include "theme.h" #include "version.h" //#include "fbxdocument.h" diff --git a/src/markiconcreator.cpp b/src/markiconcreator.cpp index 6da92af4..82d5531e 100644 --- a/src/markiconcreator.cpp +++ b/src/markiconcreator.cpp @@ -3,15 +3,15 @@ #include "markiconcreator.h" #include "theme.h" -std::map MarkIconCreator::m_iconMap; +std::map MarkIconCreator::m_iconMap; int MarkIconCreator::m_iconSize = 40; -QIcon MarkIconCreator::createIcon(SkeletonBoneMark boneMark) +QIcon MarkIconCreator::createIcon(BoneMark boneMark) { if (m_iconMap.find(boneMark) == m_iconMap.end()) { QPixmap pixmap(MarkIconCreator::m_iconSize, MarkIconCreator::m_iconSize); pixmap.fill(Qt::transparent); - QColor color = SkeletonBoneMarkToColor(boneMark); + QColor color = BoneMarkToColor(boneMark); QPainter painter(&pixmap); painter.setBrush(QBrush(color)); painter.setPen(Qt::NoPen); diff --git a/src/markiconcreator.h b/src/markiconcreator.h index b7921e18..4b5fe949 100644 --- a/src/markiconcreator.h +++ b/src/markiconcreator.h @@ -1,15 +1,15 @@ -#ifndef MARK_ICON_CREATOR_H -#define MARK_ICON_CREATOR_H +#ifndef DUST3D_MARK_ICON_CREATOR_H +#define DUST3D_MARK_ICON_CREATOR_H #include #include -#include "skeletondocument.h" +#include "document.h" class MarkIconCreator { public: - static QIcon createIcon(SkeletonBoneMark boneMark); + static QIcon createIcon(BoneMark boneMark); private: - static std::map m_iconMap; + static std::map m_iconMap; static int m_iconSize; }; diff --git a/src/material.cpp b/src/material.cpp index 111e5975..dfb0fdf93 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -1,8 +1,8 @@ #include "material.h" #include "imageforever.h" -#include "dust3dutil.h" +#include "util.h" -void initializeMaterialTexturesFromSnapshot(const SkeletonSnapshot &snapshot, const QUuid &materialId, MaterialTextures &materialTextures) +void initializeMaterialTexturesFromSnapshot(const Snapshot &snapshot, const QUuid &materialId, MaterialTextures &materialTextures) { QString materialIdString = materialId.toString(); for (const auto &materialItem: snapshot.materials) { diff --git a/src/material.h b/src/material.h index 00590f2a..08f2d13b 100644 --- a/src/material.h +++ b/src/material.h @@ -1,21 +1,15 @@ -#ifndef MATERIAL_H -#define MATERIAL_H +#ifndef DUST3D_MATERIAL_H +#define DUST3D_MATERIAL_H #include #include #include "texturetype.h" -#include "skeletonsnapshot.h" - -struct Material -{ - QColor color; - QUuid materialId; -}; +#include "snapshot.h" struct MaterialTextures { const QImage *textureImages[(int)TextureType::Count - 1] = {nullptr}; }; -void initializeMaterialTexturesFromSnapshot(const SkeletonSnapshot &snapshot, const QUuid &materialId, MaterialTextures &materialTextures); +void initializeMaterialTexturesFromSnapshot(const Snapshot &snapshot, const QUuid &materialId, MaterialTextures &materialTextures); #endif diff --git a/src/materialeditwidget.cpp b/src/materialeditwidget.cpp index e76a0391..80400459 100644 --- a/src/materialeditwidget.cpp +++ b/src/materialeditwidget.cpp @@ -14,7 +14,7 @@ #include "floatnumberwidget.h" #include "version.h" #include "imageforever.h" -#include "dust3dutil.h" +#include "util.h" QPushButton *MaterialEditWidget::createMapButton() { @@ -38,7 +38,7 @@ QImage *MaterialEditWidget::pickImage() return image; } -MaterialEditWidget::MaterialEditWidget(const SkeletonDocument *document, QWidget *parent) : +MaterialEditWidget::MaterialEditWidget(const Document *document, QWidget *parent) : QDialog(parent), m_document(document) { @@ -60,7 +60,7 @@ MaterialEditWidget::MaterialEditWidget(const SkeletonDocument *document, QWidget for (int i = 1; i < (int)TextureType::Count; i++) { QVBoxLayout *textureManageLayout = new QVBoxLayout; - SkeletonMaterialMap item; + MaterialMap item; item.forWhat = (TextureType)i; m_layers[0].maps.push_back(item); @@ -141,9 +141,9 @@ MaterialEditWidget::MaterialEditWidget(const SkeletonDocument *document, QWidget m_unsaved = true; updateTitle(); }); - connect(this, &MaterialEditWidget::addMaterial, document, &SkeletonDocument::addMaterial); - connect(this, &MaterialEditWidget::renameMaterial, document, &SkeletonDocument::renameMaterial); - connect(this, &MaterialEditWidget::setMaterialLayers, document, &SkeletonDocument::setMaterialLayers); + connect(this, &MaterialEditWidget::addMaterial, document, &Document::addMaterial); + connect(this, &MaterialEditWidget::renameMaterial, document, &Document::renameMaterial); + connect(this, &MaterialEditWidget::setMaterialLayers, document, &Document::setMaterialLayers); updatePreview(); updateTitle(); @@ -253,7 +253,7 @@ void MaterialEditWidget::updateTitle() setWindowTitle(unifiedWindowTitle(tr("New") + (m_unsaved ? "*" : ""))); return; } - const SkeletonMaterial *material = m_document->findMaterial(m_materialId); + const Material *material = m_document->findMaterial(m_materialId); if (nullptr == material) { qDebug() << "Find material failed:" << m_materialId; return; @@ -267,7 +267,7 @@ void MaterialEditWidget::setEditMaterialName(QString name) updateTitle(); } -void MaterialEditWidget::setEditMaterialLayers(std::vector layers) +void MaterialEditWidget::setEditMaterialLayers(std::vector layers) { for (int i = 1; i < (int)TextureType::Count; i++) { m_layers[0].maps[i - 1].imageId = QUuid(); diff --git a/src/materialeditwidget.h b/src/materialeditwidget.h index 5bf96435..d1c25f9a 100644 --- a/src/materialeditwidget.h +++ b/src/materialeditwidget.h @@ -1,10 +1,10 @@ -#ifndef MATERIAL_EDIT_WIDGET_H -#define MATERIAL_EDIT_WIDGET_H +#ifndef DUST3D_MATERIAL_EDIT_WIDGET_H +#define DUST3D_MATERIAL_EDIT_WIDGET_H #include #include #include #include -#include "skeletondocument.h" +#include "document.h" #include "modelwidget.h" #include "materialpreviewsgenerator.h" @@ -18,19 +18,19 @@ class MaterialEditWidget : public QDialog { Q_OBJECT signals: - void addMaterial(QString name, std::vector layers); + void addMaterial(QString name, std::vector layers); void removeMaterial(QUuid materialId); - void setMaterialLayers(QUuid materialId, std::vector layers); + void setMaterialLayers(QUuid materialId, std::vector layers); void renameMaterial(QUuid materialId, QString name); void layersAdjusted(); public: - MaterialEditWidget(const SkeletonDocument *document, QWidget *parent=nullptr); + MaterialEditWidget(const Document *document, QWidget *parent=nullptr); ~MaterialEditWidget(); public slots: void updatePreview(); void setEditMaterialId(QUuid materialId); void setEditMaterialName(QString name); - void setEditMaterialLayers(std::vector layers); + void setEditMaterialLayers(std::vector layers); void updateTitle(); void save(); void clearUnsaveState(); @@ -43,7 +43,7 @@ private: void updateMapButtonBackground(QPushButton *button, const QImage *image); QPushButton *createMapButton(); QImage *pickImage(); - const SkeletonDocument *m_document = nullptr; + const Document *m_document = nullptr; MaterialPreviewsGenerator *m_materialPreviewsGenerator = nullptr; ModelWidget *m_previewWidget = nullptr; bool m_isPreviewDirty = false; @@ -51,7 +51,7 @@ private: QUuid m_materialId; bool m_unsaved = false; QLineEdit *m_nameEdit = nullptr; - std::vector m_layers; + std::vector m_layers; QPushButton *m_textureMapButtons[(int)TextureType::Count - 1] = {nullptr}; }; diff --git a/src/materiallistwidget.cpp b/src/materiallistwidget.cpp index 316bf3d9..a7028e5c 100644 --- a/src/materiallistwidget.cpp +++ b/src/materiallistwidget.cpp @@ -3,10 +3,10 @@ #include #include #include -#include "skeletonxml.h" +#include "snapshotxml.h" #include "materiallistwidget.h" -MaterialListWidget::MaterialListWidget(const SkeletonDocument *document, QWidget *parent) : +MaterialListWidget::MaterialListWidget(const Document *document, QWidget *parent) : QTreeWidget(parent), m_document(document) { @@ -27,10 +27,10 @@ MaterialListWidget::MaterialListWidget(const SkeletonDocument *document, QWidget setContentsMargins(0, 0, 0, 0); - connect(document, &SkeletonDocument::materialListChanged, this, &MaterialListWidget::reload); - connect(document, &SkeletonDocument::cleanup, this, &MaterialListWidget::removeAllContent); + connect(document, &Document::materialListChanged, this, &MaterialListWidget::reload); + connect(document, &Document::cleanup, this, &MaterialListWidget::removeAllContent); - connect(this, &MaterialListWidget::removeMaterial, document, &SkeletonDocument::removeMaterial); + connect(this, &MaterialListWidget::removeMaterial, document, &Document::removeMaterial); setContextMenuPolicy(Qt::CustomContextMenu); connect(this, &QTreeWidget::customContextMenuRequested, this, &MaterialListWidget::showContextMenu); @@ -200,7 +200,7 @@ void MaterialListWidget::showContextMenu(const QPoint &pos) QAction pasteAction(tr("Paste"), this); if (m_document->hasPastableMaterialsInClipboard()) { - connect(&pasteAction, &QAction::triggered, m_document, &SkeletonDocument::paste); + connect(&pasteAction, &QAction::triggered, m_document, &Document::paste); contextMenu.addAction(&pasteAction); } @@ -297,8 +297,8 @@ void MaterialListWidget::copy() std::set emptySet; - SkeletonSnapshot snapshot; - m_document->toSnapshot(&snapshot, emptySet, SkeletonDocumentToSnapshotFor::Materials, + Snapshot snapshot; + m_document->toSnapshot(&snapshot, emptySet, DocumentToSnapshotFor::Materials, emptySet, emptySet, limitMaterialIds); QString snapshotXml; QXmlStreamWriter xmlStreamWriter(&snapshotXml); diff --git a/src/materiallistwidget.h b/src/materiallistwidget.h index ed997f34..2fe312d1 100644 --- a/src/materiallistwidget.h +++ b/src/materiallistwidget.h @@ -1,9 +1,9 @@ -#ifndef MATERIAL_LIST_WIDGET_H -#define MATERIAL_LIST_WIDGET_H +#ifndef DUST3D_MATERIAL_LIST_WIDGET_H +#define DUST3D_MATERIAL_LIST_WIDGET_H #include #include #include -#include "skeletondocument.h" +#include "document.h" #include "materialwidget.h" class MaterialListWidget : public QTreeWidget @@ -15,7 +15,7 @@ signals: void cornerButtonClicked(QUuid materialId); void currentSelectedMaterialChanged(QUuid materialId); public: - MaterialListWidget(const SkeletonDocument *document, QWidget *parent=nullptr); + MaterialListWidget(const Document *document, QWidget *parent=nullptr); bool isMaterialSelected(QUuid materialId); void enableMultipleSelection(bool enabled); public slots: @@ -33,7 +33,7 @@ protected: private: int calculateColumnCount(); void updateMaterialSelectState(QUuid materialId, bool selected); - const SkeletonDocument *m_document = nullptr; + const Document *m_document = nullptr; std::map> m_itemMap; std::set m_selectedMaterialIds; QUuid m_currentSelectedMaterialId; diff --git a/src/materialmanagewidget.cpp b/src/materialmanagewidget.cpp index edef81e6..ea850ee1 100644 --- a/src/materialmanagewidget.cpp +++ b/src/materialmanagewidget.cpp @@ -6,7 +6,7 @@ #include "materialeditwidget.h" #include "infolabel.h" -MaterialManageWidget::MaterialManageWidget(const SkeletonDocument *document, QWidget *parent) : +MaterialManageWidget::MaterialManageWidget(const Document *document, QWidget *parent) : QWidget(parent), m_document(document) { @@ -47,7 +47,7 @@ void MaterialManageWidget::showMaterialDialog(QUuid materialId) MaterialEditWidget *materialEditWidget = new MaterialEditWidget(m_document); materialEditWidget->setAttribute(Qt::WA_DeleteOnClose); if (!materialId.isNull()) { - const SkeletonMaterial *material = m_document->findMaterial(materialId); + const Material *material = m_document->findMaterial(materialId); if (nullptr != material) { materialEditWidget->setEditMaterialId(materialId); materialEditWidget->setEditMaterialName(material->name); diff --git a/src/materialmanagewidget.h b/src/materialmanagewidget.h index 3899ba2a..9fed41d2 100644 --- a/src/materialmanagewidget.h +++ b/src/materialmanagewidget.h @@ -1,7 +1,7 @@ -#ifndef MATERIAL_MANAGE_WIDGET_H -#define MATERIAL_MANAGE_WIDGET_H +#ifndef DUST3D_MATERIAL_MANAGE_WIDGET_H +#define DUST3D_MATERIAL_MANAGE_WIDGET_H #include -#include "skeletondocument.h" +#include "document.h" #include "materiallistwidget.h" class MaterialManageWidget : public QWidget @@ -11,7 +11,7 @@ signals: void registerDialog(QWidget *widget); void unregisterDialog(QWidget *widget); public: - MaterialManageWidget(const SkeletonDocument *document, QWidget *parent=nullptr); + MaterialManageWidget(const Document *document, QWidget *parent=nullptr); MaterialListWidget *materialListWidget(); protected: virtual QSize sizeHint() const; @@ -19,7 +19,7 @@ public slots: void showAddMaterialDialog(); void showMaterialDialog(QUuid materialId); private: - const SkeletonDocument *m_document = nullptr; + const Document *m_document = nullptr; MaterialListWidget *m_materialListWidget = nullptr; }; diff --git a/src/materialpreviewsgenerator.cpp b/src/materialpreviewsgenerator.cpp index f9ff4ed5..7781ad83 100644 --- a/src/materialpreviewsgenerator.cpp +++ b/src/materialpreviewsgenerator.cpp @@ -2,7 +2,7 @@ #include #include "materialpreviewsgenerator.h" #include "meshgenerator.h" -#include "skeletonxml.h" +#include "snapshotxml.h" #include "ds3file.h" #include "texturegenerator.h" #include "imageforever.h" @@ -18,7 +18,7 @@ MaterialPreviewsGenerator::~MaterialPreviewsGenerator() } } -void MaterialPreviewsGenerator::addMaterial(QUuid materialId, const std::vector &layers) +void MaterialPreviewsGenerator::addMaterial(QUuid materialId, const std::vector &layers) { m_materials.push_back({materialId, layers}); } @@ -37,7 +37,7 @@ MeshLoader *MaterialPreviewsGenerator::takePreview(QUuid materialId) void MaterialPreviewsGenerator::generate() { - SkeletonSnapshot *snapshot = new SkeletonSnapshot; + Snapshot *snapshot = new Snapshot; std::vector partIds; Ds3FileReader ds3Reader(":/resources/material-demo-model.ds3"); @@ -65,12 +65,12 @@ void MaterialPreviewsGenerator::generate() partIds.push_back(QUuid(mirror.first)); } - MeshResultContext *meshResultContext = meshGenerator->takeMeshResultContext(); + Outcome *outcome = meshGenerator->takeMeshResultContext(); MeshLoader *resultMesh = meshGenerator->takeResultMesh(); for (const auto &material: m_materials) { - TextureGenerator *textureGenerator = new TextureGenerator(*meshResultContext); + TextureGenerator *textureGenerator = new TextureGenerator(*outcome); for (const auto &layer: material.second) { for (const auto &mapItem: layer.maps) { const QImage *image = ImageForever::get(mapItem.imageId); @@ -102,7 +102,7 @@ void MaterialPreviewsGenerator::generate() delete resultMesh; - delete meshResultContext; + delete outcome; delete meshGenerator; delete cacheContext; diff --git a/src/materialpreviewsgenerator.h b/src/materialpreviewsgenerator.h index 037d8941..ca3d4862 100644 --- a/src/materialpreviewsgenerator.h +++ b/src/materialpreviewsgenerator.h @@ -1,11 +1,11 @@ -#ifndef MATERIAL_PREVIEWS_GENERATOR_H -#define MATERIAL_PREVIEWS_GENERATOR_H +#ifndef DUST3D_MATERIAL_PREVIEWS_GENERATOR_H +#define DUST3D_MATERIAL_PREVIEWS_GENERATOR_H #include #include #include #include #include "meshloader.h" -#include "skeletondocument.h" +#include "document.h" class MaterialPreviewsGenerator : public QObject { @@ -13,7 +13,7 @@ class MaterialPreviewsGenerator : public QObject public: MaterialPreviewsGenerator(); ~MaterialPreviewsGenerator(); - void addMaterial(QUuid materialId, const std::vector &layers); + void addMaterial(QUuid materialId, const std::vector &layers); const std::set &generatedPreviewMaterialIds(); MeshLoader *takePreview(QUuid materialId); void generate(); @@ -22,7 +22,7 @@ signals: public slots: void process(); private: - std::vector>> m_materials; + std::vector>> m_materials; std::map m_previews; std::set m_generatedMaterialIds; }; diff --git a/src/materialwidget.cpp b/src/materialwidget.cpp index 95e9d212..dab825e0 100644 --- a/src/materialwidget.cpp +++ b/src/materialwidget.cpp @@ -1,7 +1,7 @@ #include #include "materialwidget.h" -MaterialWidget::MaterialWidget(const SkeletonDocument *document, QUuid materialId) : +MaterialWidget::MaterialWidget(const Document *document, QUuid materialId) : m_materialId(materialId), m_document(document) { @@ -31,8 +31,8 @@ MaterialWidget::MaterialWidget(const SkeletonDocument *document, QUuid materialI setFixedSize(Theme::materialPreviewImageSize, MaterialWidget::preferredHeight()); - connect(document, &SkeletonDocument::materialNameChanged, this, &MaterialWidget::updateName); - connect(document, &SkeletonDocument::materialPreviewChanged, this, &MaterialWidget::updatePreview); + connect(document, &Document::materialNameChanged, this, &MaterialWidget::updateName); + connect(document, &Document::materialPreviewChanged, this, &MaterialWidget::updatePreview); } void MaterialWidget::setCornerButtonVisible(bool visible) @@ -68,7 +68,7 @@ void MaterialWidget::reload() void MaterialWidget::updatePreview() { - const SkeletonMaterial *material = m_document->findMaterial(m_materialId); + const Material *material = m_document->findMaterial(m_materialId); if (!material) { qDebug() << "Material not found:" << m_materialId; return; @@ -79,7 +79,7 @@ void MaterialWidget::updatePreview() void MaterialWidget::updateName() { - const SkeletonMaterial *material = m_document->findMaterial(m_materialId); + const Material *material = m_document->findMaterial(m_materialId); if (!material) { qDebug() << "Material not found:" << m_materialId; return; diff --git a/src/materialwidget.h b/src/materialwidget.h index 85dbe0f6..63ec68af 100644 --- a/src/materialwidget.h +++ b/src/materialwidget.h @@ -1,9 +1,9 @@ -#ifndef MATERIAL_WIDGET_H -#define MATERIAL_WIDGET_H +#ifndef DUST3D_MATERIAL_WIDGET_H +#define DUST3D_MATERIAL_WIDGET_H #include #include #include -#include "skeletondocument.h" +#include "document.h" #include "modelwidget.h" class MaterialWidget : public QFrame @@ -13,7 +13,7 @@ signals: void modifyMaterial(QUuid materialId); void cornerButtonClicked(QUuid materialId); public: - MaterialWidget(const SkeletonDocument *document, QUuid materialId); + MaterialWidget(const Document *document, QUuid materialId); static int preferredHeight(); ModelWidget *previewWidget(); protected: @@ -27,7 +27,7 @@ public slots: void setCornerButtonVisible(bool visible); private: QUuid m_materialId; - const SkeletonDocument *m_document = nullptr; + const Document *m_document = nullptr; ModelWidget *m_previewWidget = nullptr; QLabel *m_nameLabel = nullptr; QPushButton *m_cornerButton = nullptr; diff --git a/src/meshgenerator.cpp b/src/meshgenerator.cpp index 6cdf961a..3817baea 100644 --- a/src/meshgenerator.cpp +++ b/src/meshgenerator.cpp @@ -3,8 +3,8 @@ #include #include #include "meshgenerator.h" -#include "dust3dutil.h" -#include "skeletondocument.h" +#include "util.h" +#include "document.h" #include "meshlite.h" #include "meshutil.h" #include "theme.h" @@ -32,10 +32,10 @@ void GeneratedCacheContext::updateComponentCombinableMesh(QString componentId, v cache = cloneCombinableMesh(mesh); } -MeshGenerator::MeshGenerator(SkeletonSnapshot *snapshot) : +MeshGenerator::MeshGenerator(Snapshot *snapshot) : m_snapshot(snapshot), m_mesh(nullptr), - m_meshResultContext(nullptr), + m_outcome(nullptr), m_sharedContextWidget(nullptr), m_cacheContext(nullptr), m_smoothNormal(true), @@ -50,7 +50,7 @@ MeshGenerator::~MeshGenerator() for (const auto &partPreviewMeshIt: m_partPreviewMeshMap) { delete partPreviewMeshIt.second; } - delete m_meshResultContext; + delete m_outcome; } void MeshGenerator::setSmoothNormal(bool smoothNormal) @@ -103,14 +103,14 @@ const std::set &MeshGenerator::generatedPreviewPartIds() return m_generatedPreviewPartIds; } -MeshResultContext *MeshGenerator::takeMeshResultContext() +Outcome *MeshGenerator::takeMeshResultContext() { - MeshResultContext *meshResultContext = m_meshResultContext; - m_meshResultContext = nullptr; - return meshResultContext; + Outcome *outcome = m_outcome; + m_outcome = nullptr; + return outcome; } -void MeshGenerator::loadVertexSources(void *meshliteContext, int meshId, QUuid partId, const std::map &bmeshToNodeIdMap, std::vector &bmeshVertices, +void MeshGenerator::loadVertexSources(void *meshliteContext, int meshId, QUuid partId, const std::map &bmeshToNodeIdMap, std::vector &bmeshVertices, std::vector> &bmeshQuads) { int vertexCount = meshlite_get_vertex_count(meshliteContext, meshId); @@ -122,7 +122,7 @@ void MeshGenerator::loadVertexSources(void *meshliteContext, int meshId, QUuid p Q_ASSERT(positionCount == sourceCount); std::vector verticesPositions; for (int i = 0, positionIndex = 0; i < positionCount; i++, positionIndex+=3) { - BmeshVertex vertex; + OutcomeNodeVertex vertex; vertex.partId = partId; auto findNodeId = bmeshToNodeIdMap.find(sourceBuffer[i]); if (findNodeId != bmeshToNodeIdMap.end()) @@ -168,10 +168,10 @@ void MeshGenerator::loadGeneratedPositionsToMeshResultContext(void *meshliteCont int positionCount = meshlite_get_vertex_position_array(meshliteContext, triangulatedMeshId, positionBuffer, positionBufferLen) / 3; std::map verticesMap; for (int i = 0, positionIndex = 0; i < positionCount; i++, positionIndex+=3) { - ResultVertex vertex; + OutcomeVertex vertex; vertex.position = QVector3D(positionBuffer[positionIndex + 0], positionBuffer[positionIndex + 1], positionBuffer[positionIndex + 2]); - verticesMap[i] = m_meshResultContext->vertices.size(); - m_meshResultContext->vertices.push_back(vertex); + verticesMap[i] = m_outcome->vertices.size(); + m_outcome->vertices.push_back(vertex); } int faceCount = meshlite_get_face_count(meshliteContext, triangulatedMeshId); int triangleIndexBufferLen = faceCount * 3; @@ -182,12 +182,12 @@ void MeshGenerator::loadGeneratedPositionsToMeshResultContext(void *meshliteCont int normalCount = meshlite_get_triangle_normal_array(meshliteContext, triangulatedMeshId, normalBuffer, triangleNormalBufferLen) / 3; Q_ASSERT(triangleCount == normalCount); for (int i = 0, triangleVertIndex = 0, normalIndex=0; i < triangleCount; i++, triangleVertIndex+=3, normalIndex += 3) { - ResultTriangle triangle; + OutcomeTriangle triangle; triangle.indicies[0] = verticesMap[triangleIndexBuffer[triangleVertIndex + 0]]; triangle.indicies[1] = verticesMap[triangleIndexBuffer[triangleVertIndex + 1]]; triangle.indicies[2] = verticesMap[triangleIndexBuffer[triangleVertIndex + 2]]; triangle.normal = QVector3D(normalBuffer[normalIndex + 0], normalBuffer[normalIndex + 1], normalBuffer[normalIndex + 2]); - m_meshResultContext->triangles.push_back(triangle); + m_outcome->triangles.push_back(triangle); } delete[] positionBuffer; delete[] triangleIndexBuffer; @@ -257,7 +257,7 @@ void *MeshGenerator::combinePartMesh(QString partId) if (!materialIdString.isEmpty()) materialId = QUuid(materialIdString); - Material partMaterial; + OutcomeMaterial partMaterial; partMaterial.color = partColor; partMaterial.materialId = materialId; @@ -291,12 +291,12 @@ void *MeshGenerator::combinePartMesh(QString partId) float z = (m_sideProfileMiddleX - valueOfKeyInMapOrEmpty(node, "z").toFloat()); int bmeshNodeId = meshlite_bmesh_add_node(m_meshliteContext, bmeshId, x, y, z, radius); - SkeletonBoneMark boneMark = SkeletonBoneMarkFromString(valueOfKeyInMapOrEmpty(node, "boneMark").toUtf8().constData()); + BoneMark boneMark = BoneMarkFromString(valueOfKeyInMapOrEmpty(node, "boneMark").toUtf8().constData()); nodeToBmeshIdMap[nodeId] = bmeshNodeId; bmeshToNodeIdMap[bmeshNodeId] = nodeId; - BmeshNode bmeshNode; + OutcomeNode bmeshNode; bmeshNode.partId = QUuid(partId); bmeshNode.origin = QVector3D(x, y, z); bmeshNode.radius = radius; @@ -305,7 +305,7 @@ void *MeshGenerator::combinePartMesh(QString partId) bmeshNode.material.color = partColor; bmeshNode.boneMark = boneMark; //if (SkeletonBoneMark::None != boneMark) - // bmeshNode.color = SkeletonBoneMarkToColor(boneMark); + // bmeshNode.color = BoneMarkToColor(boneMark); cacheBmeshNodes.push_back(bmeshNode); if (xMirrored) { bmeshNode.partId = mirroredPartId; @@ -560,7 +560,7 @@ void *MeshGenerator::combineComponentMesh(QString componentId, bool *inverse) for (size_t vertexIndex = 0; vertexIndex < positionsBeforeSmooth.size(); vertexIndex++) { const auto &oldPosition = positionsBeforeSmooth[vertexIndex]; const auto &smoothedPosition = positionsAfterSmooth[vertexIndex]; - BmeshVertex source; + OutcomeNodeVertex source; if (verticesSources.findPosition(oldPosition.x(), oldPosition.y(), oldPosition.z(), &source)) { verticesSources.removePosition(oldPosition.x(), oldPosition.y(), oldPosition.z()); source.position = smoothedPosition; @@ -591,7 +591,7 @@ void MeshGenerator::generate() m_meshliteContext = meshlite_create_context(); initMeshUtils(); - m_meshResultContext = new MeshResultContext; + m_outcome = new Outcome; bool needDeleteCacheContext = false; if (nullptr == m_cacheContext) { @@ -670,11 +670,11 @@ void MeshGenerator::generate() } for (const auto &verticesSourcesIt: m_cacheContext->componentVerticesSources[QUuid().toString()].map()) { - m_meshResultContext->bmeshVertices.push_back(verticesSourcesIt.second); + m_outcome->bmeshVertices.push_back(verticesSourcesIt.second); } for (const auto &bmeshNodes: m_cacheContext->partBmeshNodes) { - m_meshResultContext->bmeshNodes.insert(m_meshResultContext->bmeshNodes.end(), + m_outcome->bmeshNodes.insert(m_outcome->bmeshNodes.end(), bmeshNodes.second.begin(), bmeshNodes.second.end()); } @@ -714,7 +714,7 @@ void MeshGenerator::generate() if (resultMeshId > 0) { loadGeneratedPositionsToMeshResultContext(m_meshliteContext, triangulatedFinalMeshId); - m_mesh = new MeshLoader(m_meshliteContext, resultMeshId, triangulatedFinalMeshId, Theme::white, &m_meshResultContext->triangleMaterials(), m_smoothNormal); + m_mesh = new MeshLoader(m_meshliteContext, resultMeshId, triangulatedFinalMeshId, Theme::white, &m_outcome->triangleMaterials(), m_smoothNormal); } if (needDeleteCacheContext) { diff --git a/src/meshgenerator.h b/src/meshgenerator.h index 8e7e5d58..c635ac47 100644 --- a/src/meshgenerator.h +++ b/src/meshgenerator.h @@ -1,5 +1,5 @@ -#ifndef MESH_GENERATOR_H -#define MESH_GENERATOR_H +#ifndef DUST3D_MESH_GENERATOR_H +#define DUST3D_MESH_GENERATOR_H #include #include #include @@ -7,21 +7,21 @@ #include #include #include -#include "skeletonsnapshot.h" +#include "snapshot.h" #include "meshloader.h" -#include "meshresultcontext.h" +#include "outcome.h" #include "positionmap.h" class GeneratedCacheContext { public: ~GeneratedCacheContext(); - std::map> partBmeshVertices; - std::map> partBmeshNodes; + std::map> partBmeshVertices; + std::map> partBmeshNodes; std::map>> partBmeshQuads; std::map componentCombinableMeshs; std::map> componentPositions; - std::map> componentVerticesSources; + std::map> componentVerticesSources; std::map partMirrorIdMap; void updateComponentCombinableMesh(QString componentId, void *mesh); }; @@ -30,7 +30,7 @@ class MeshGenerator : public QObject { Q_OBJECT public: - MeshGenerator(SkeletonSnapshot *snapshot); + MeshGenerator(Snapshot *snapshot); ~MeshGenerator(); void setSharedContextWidget(QOpenGLWidget *widget); void addPartPreviewRequirement(const QUuid &partId); @@ -41,20 +41,20 @@ public: MeshLoader *takePartPreviewMesh(const QUuid &partId); const std::set &requirePreviewPartIds(); const std::set &generatedPreviewPartIds(); - MeshResultContext *takeMeshResultContext(); + Outcome *takeMeshResultContext(); void generate(); signals: void finished(); public slots: void process(); private: - SkeletonSnapshot *m_snapshot; + Snapshot *m_snapshot; MeshLoader *m_mesh; std::map m_partPreviewMeshMap; std::set m_requirePreviewPartIds; std::set m_generatedPreviewPartIds; QThread *m_thread; - MeshResultContext *m_meshResultContext; + Outcome *m_outcome; QOpenGLWidget *m_sharedContextWidget; void *m_meshliteContext; GeneratedCacheContext *m_cacheContext; @@ -71,7 +71,7 @@ private: static bool m_enableDebug; static PositionMap *m_forMakePositionKey; private: - void loadVertexSources(void *meshliteContext, int meshId, QUuid partId, const std::map &bmeshToNodeIdMap, std::vector &bmeshVertices, + void loadVertexSources(void *meshliteContext, int meshId, QUuid partId, const std::map &bmeshToNodeIdMap, std::vector &bmeshVertices, std::vector> &bmeshQuads); void loadGeneratedPositionsToMeshResultContext(void *meshliteContext, int triangulatedMeshId); void collectParts(); diff --git a/src/meshloader.cpp b/src/meshloader.cpp index 8d0bda91..ed1787ba 100644 --- a/src/meshloader.cpp +++ b/src/meshloader.cpp @@ -14,7 +14,7 @@ float MeshLoader::m_defaultMetalness = 0.0; float MeshLoader::m_defaultRoughness = 1.0; -MeshLoader::MeshLoader(void *meshlite, int meshId, int triangulatedMeshId, QColor defaultColor, const std::vector *triangleMaterials, bool smoothNormal) : +MeshLoader::MeshLoader(void *meshlite, int meshId, int triangulatedMeshId, QColor defaultColor, const std::vector *triangleMaterials, bool smoothNormal) : m_triangleVertices(nullptr), m_triangleVertexCount(0), m_edgeVertices(nullptr), @@ -233,26 +233,26 @@ MeshLoader::MeshLoader(Vertex *triangleVertices, int vertexNum) : { } -MeshLoader::MeshLoader(MeshResultContext &resultContext) : +MeshLoader::MeshLoader(Outcome &outcome) : m_triangleVertices(nullptr), m_triangleVertexCount(0), m_edgeVertices(nullptr), m_edgeVertexCount(0), m_textureImage(nullptr) { - for (const auto &part: resultContext.parts()) { + for (const auto &part: outcome.parts()) { m_triangleVertexCount += part.second.triangles.size() * 3; } m_triangleVertices = new Vertex[m_triangleVertexCount]; int destIndex = 0; - for (const auto &part: resultContext.parts()) { + for (const auto &part: outcome.parts()) { for (int x = 0; x < (int)part.second.triangles.size(); x++) { const auto &it = part.second.triangles[x]; for (auto i = 0; i < 3; i++) { int vertexIndex = it.indicies[i]; - const ResultVertex *srcVert = &part.second.vertices[vertexIndex]; + const OutcomeVertex *srcVert = &part.second.vertices[vertexIndex]; const QVector3D *srcNormal = &part.second.interpolatedTriangleVertexNormals[x * 3 + i]; - const ResultVertexUv *srcUv = &part.second.vertexUvs[vertexIndex]; + const OutcomeVertexUv *srcUv = &part.second.vertexUvs[vertexIndex]; //const Material *srcMaterial = &part.second.material; const QVector3D *srcTangent = &part.second.triangleTangents[x]; Vertex *dest = &m_triangleVertices[destIndex]; diff --git a/src/meshloader.h b/src/meshloader.h index 2aac5d95..0e07cc57 100644 --- a/src/meshloader.h +++ b/src/meshloader.h @@ -1,5 +1,5 @@ -#ifndef MESH_LOADER_H -#define MESH_LOADER_H +#ifndef DUST3D_MESH_LOADER_H +#define DUST3D_MESH_LOADER_H #include #include #include @@ -9,7 +9,7 @@ #include "positionmap.h" #include "theme.h" #include "qtlightmapper.h" -#include "meshresultcontext.h" +#include "outcome.h" #pragma pack(push) #pragma pack(1) @@ -43,8 +43,8 @@ struct TriangulatedFace class MeshLoader { public: - MeshLoader(void *meshlite, int meshId, int triangulatedMeshId=-1, QColor defaultColor=Theme::white, const std::vector *triangleMaterials=nullptr, bool smoothNormal=true); - MeshLoader(MeshResultContext &resultContext); + MeshLoader(void *meshlite, int meshId, int triangulatedMeshId=-1, QColor defaultColor=Theme::white, const std::vector *triangleMaterials=nullptr, bool smoothNormal=true); + MeshLoader(Outcome &outcome); MeshLoader(Vertex *triangleVertices, int vertexNum); MeshLoader(const MeshLoader &mesh); MeshLoader(); diff --git a/src/meshquadify.h b/src/meshquadify.h index b123f909..2d90c38d 100644 --- a/src/meshquadify.h +++ b/src/meshquadify.h @@ -1,5 +1,5 @@ -#ifndef MESH_QUADIFY_H -#define MESH_QUADIFY_H +#ifndef DUST3D_MESH_QUADIFY_H +#define DUST3D_MESH_QUADIFY_H #include #include "meshutil.h" #include "positionmap.h" diff --git a/src/meshresultpostprocessor.cpp b/src/meshresultpostprocessor.cpp index aab8e24e..e468ad5e 100644 --- a/src/meshresultpostprocessor.cpp +++ b/src/meshresultpostprocessor.cpp @@ -1,29 +1,29 @@ #include #include "meshresultpostprocessor.h" -MeshResultPostProcessor::MeshResultPostProcessor(const MeshResultContext &meshResultContext) +MeshResultPostProcessor::MeshResultPostProcessor(const Outcome &outcome) { - m_meshResultContext = new MeshResultContext; - *m_meshResultContext = meshResultContext; + m_outcome = new Outcome; + *m_outcome = outcome; } MeshResultPostProcessor::~MeshResultPostProcessor() { - delete m_meshResultContext; + delete m_outcome; } -MeshResultContext *MeshResultPostProcessor::takePostProcessedResultContext() +Outcome *MeshResultPostProcessor::takePostProcessedResultContext() { - MeshResultContext *resultContext = m_meshResultContext; - m_meshResultContext = nullptr; - return resultContext; + Outcome *outcome = m_outcome; + m_outcome = nullptr; + return outcome; } void MeshResultPostProcessor::process() { - if (!m_meshResultContext->bmeshNodes.empty()) { - (void)m_meshResultContext->triangleTangents(); - (void)m_meshResultContext->parts(); + if (!m_outcome->bmeshNodes.empty()) { + (void)m_outcome->triangleTangents(); + (void)m_outcome->parts(); } this->moveToThread(QGuiApplication::instance()->thread()); diff --git a/src/meshresultpostprocessor.h b/src/meshresultpostprocessor.h index 68730691..9d608f4d 100644 --- a/src/meshresultpostprocessor.h +++ b/src/meshresultpostprocessor.h @@ -1,21 +1,21 @@ -#ifndef MESH_RESULT_POST_PROCESSOR_H -#define MESH_RESULT_POST_PROCESSOR_H +#ifndef DUST3D_MESH_RESULT_POST_PROCESSOR_H +#define DUST3D_MESH_RESULT_POST_PROCESSOR_H #include -#include "meshresultcontext.h" +#include "outcome.h" class MeshResultPostProcessor : public QObject { Q_OBJECT public: - MeshResultPostProcessor(const MeshResultContext &meshResultContext); + MeshResultPostProcessor(const Outcome &outcome); ~MeshResultPostProcessor(); - MeshResultContext *takePostProcessedResultContext(); + Outcome *takePostProcessedResultContext(); signals: void finished(); public slots: void process(); private: - MeshResultContext *m_meshResultContext = nullptr; + Outcome *m_outcome = nullptr; }; #endif diff --git a/src/meshsplitter.h b/src/meshsplitter.h index 44157375..900bae56 100644 --- a/src/meshsplitter.h +++ b/src/meshsplitter.h @@ -1,5 +1,5 @@ -#ifndef MESH_SPLITTER_H -#define MESH_SPLITTER_H +#ifndef DUST3D_MESH_SPLITTER_H +#define DUST3D_MESH_SPLITTER_H #include class MeshSplitterTriangle diff --git a/src/meshutil.h b/src/meshutil.h index df3b1b6d..82252f3b 100644 --- a/src/meshutil.h +++ b/src/meshutil.h @@ -1,5 +1,5 @@ -#ifndef MESH_UTIL_H -#define MESH_UTIL_H +#ifndef DUST3D_MESH_UTIL_H +#define DUST3D_MESH_UTIL_H #include #include #include diff --git a/src/meshweldseam.h b/src/meshweldseam.h index ea7d9055..4e832144 100644 --- a/src/meshweldseam.h +++ b/src/meshweldseam.h @@ -1,5 +1,5 @@ -#ifndef MESH_WELD_SEAM_H -#define MESH_WELD_SEAM_H +#ifndef DUST3D_MESH_WELD_SEAM_H +#define DUST3D_MESH_WELD_SEAM_H #include "meshlite.h" #include "positionmap.h" #include diff --git a/src/modelmeshbinder.h b/src/modelmeshbinder.h index 975c9da5..b0c58326 100644 --- a/src/modelmeshbinder.h +++ b/src/modelmeshbinder.h @@ -1,5 +1,5 @@ -#ifndef MODEL_MESH_BINDER_H -#define MODEL_MESH_BINDER_H +#ifndef DUST3D_MODEL_MESH_BINDER_H +#define DUST3D_MODEL_MESH_BINDER_H #include #include #include diff --git a/src/modelshaderprogram.h b/src/modelshaderprogram.h index 62c31d93..f317be53 100644 --- a/src/modelshaderprogram.h +++ b/src/modelshaderprogram.h @@ -1,5 +1,5 @@ -#ifndef MODEL_SHADER_PROGRAM_H -#define MODEL_SHADER_PROGRAM_H +#ifndef DUST3D_MODEL_SHADER_PROGRAM_H +#define DUST3D_MODEL_SHADER_PROGRAM_H #include #include diff --git a/src/modelwidget.cpp b/src/modelwidget.cpp index 569a6157..0bf98312 100644 --- a/src/modelwidget.cpp +++ b/src/modelwidget.cpp @@ -4,7 +4,7 @@ #include #include #include "modelwidget.h" -#include "dust3dutil.h" +#include "util.h" // Modifed from http://doc.qt.io/qt-5/qtopengl-hellogl2-glwidget-cpp.html diff --git a/src/modelwidget.h b/src/modelwidget.h index 8dafd221..854c4b97 100644 --- a/src/modelwidget.h +++ b/src/modelwidget.h @@ -1,5 +1,5 @@ -#ifndef MODEL_WIDGET_H -#define MODEL_WIDGET_H +#ifndef DUST3D_MODEL_WIDGET_H +#define DUST3D_MODEL_WIDGET_H #include #include #include diff --git a/src/motionclipwidget.cpp b/src/motionclipwidget.cpp index f728da59..c1b672da 100644 --- a/src/motionclipwidget.cpp +++ b/src/motionclipwidget.cpp @@ -6,7 +6,7 @@ #include "posewidget.h" #include "motionwidget.h" -MotionClipWidget::MotionClipWidget(const SkeletonDocument *document, QWidget *parent) : +MotionClipWidget::MotionClipWidget(const Document *document, QWidget *parent) : QFrame(parent), m_document(document) { @@ -17,13 +17,13 @@ QSize MotionClipWidget::preferredSize() { int preferredWidth = 0; switch (m_clip.clipType) { - case SkeletonMotionClipType::Motion: + case MotionClipType::Motion: preferredWidth = Theme::motionPreviewImageSize; break; - case SkeletonMotionClipType::Pose: + case MotionClipType::Pose: preferredWidth = Theme::posePreviewImageSize; break; - case SkeletonMotionClipType::Interpolation: + case MotionClipType::Interpolation: preferredWidth = Theme::normalButtonSize; break; default: @@ -39,7 +39,7 @@ QSize MotionClipWidget::maxSize() return QSize(maxWidth, maxHeight); } -void MotionClipWidget::setClip(SkeletonMotionClip clip) +void MotionClipWidget::setClip(MotionClip clip) { m_clip = clip; reload(); @@ -60,21 +60,21 @@ void MotionClipWidget::reload() layout->addStretch(); switch (m_clip.clipType) { - case SkeletonMotionClipType::Motion: + case MotionClipType::Motion: { MotionWidget *motionWidget = new MotionWidget(m_document, m_clip.linkToId); motionWidget->reload(); layout->addWidget(motionWidget); } break; - case SkeletonMotionClipType::Pose: + case MotionClipType::Pose: { PoseWidget *poseWidget = new PoseWidget(m_document, m_clip.linkToId); poseWidget->reload(); layout->addWidget(poseWidget); } break; - case SkeletonMotionClipType::Interpolation: + case MotionClipType::Interpolation: { QHBoxLayout *interpolationButtonLayout = new QHBoxLayout; QPushButton *interpolationButton = new QPushButton(QChar(fa::arrowsh)); diff --git a/src/motionclipwidget.h b/src/motionclipwidget.h index 9409b2f5..592862a1 100644 --- a/src/motionclipwidget.h +++ b/src/motionclipwidget.h @@ -1,7 +1,7 @@ -#ifndef MOTION_CLIP_WIDGET_H -#define MOTION_CLIP_WIDGET_H +#ifndef DUST3D_MOTION_CLIP_WIDGET_H +#define DUST3D_MOTION_CLIP_WIDGET_H #include -#include "skeletondocument.h" +#include "document.h" class MotionClipWidget : public QFrame { @@ -10,18 +10,18 @@ signals: void modifyInterpolation(); public: - MotionClipWidget(const SkeletonDocument *document, QWidget *parent=nullptr); + MotionClipWidget(const Document *document, QWidget *parent=nullptr); QSize preferredSize(); static QSize maxSize(); public slots: - void setClip(SkeletonMotionClip clip); + void setClip(MotionClip clip); void reload(); void updateCheckedState(bool checked); private: - const SkeletonDocument *m_document = nullptr; - SkeletonMotionClip m_clip; + const Document *m_document = nullptr; + MotionClip m_clip; QWidget *m_reloadToWidget = nullptr; }; diff --git a/src/motioneditwidget.cpp b/src/motioneditwidget.cpp index 51de865f..c761ecc4 100644 --- a/src/motioneditwidget.cpp +++ b/src/motioneditwidget.cpp @@ -6,13 +6,13 @@ #include #include #include "motioneditwidget.h" -#include "dust3dutil.h" +#include "util.h" #include "poselistwidget.h" #include "motionlistwidget.h" #include "version.h" #include "tabwidget.h" -MotionEditWidget::MotionEditWidget(const SkeletonDocument *document, QWidget *parent) : +MotionEditWidget::MotionEditWidget(const Document *document, QWidget *parent) : QDialog(parent), m_document(document) { @@ -130,9 +130,9 @@ MotionEditWidget::MotionEditWidget(const SkeletonDocument *document, QWidget *pa setLayout(mainLayout); - connect(this, &MotionEditWidget::addMotion, m_document, &SkeletonDocument::addMotion); - connect(this, &MotionEditWidget::renameMotion, m_document, &SkeletonDocument::renameMotion); - connect(this, &MotionEditWidget::setMotionClips, m_document, &SkeletonDocument::setMotionClips); + connect(this, &MotionEditWidget::addMotion, m_document, &Document::addMotion); + connect(this, &MotionEditWidget::renameMotion, m_document, &Document::renameMotion); + connect(this, &MotionEditWidget::setMotionClips, m_document, &Document::setMotionClips); updateTitle(); } @@ -218,7 +218,7 @@ void MotionEditWidget::updateTitle() setWindowTitle(unifiedWindowTitle(tr("New") + (m_unsaved ? "*" : ""))); return; } - const SkeletonMotion *motion = m_document->findMotion(m_motionId); + const Motion *motion = m_document->findMotion(m_motionId); if (nullptr == motion) { qDebug() << "Find motion failed:" << m_motionId; return; @@ -226,7 +226,7 @@ void MotionEditWidget::updateTitle() setWindowTitle(unifiedWindowTitle(motion->name + (m_unsaved ? "*" : ""))); } -void MotionEditWidget::setEditMotionClips(std::vector clips) +void MotionEditWidget::setEditMotionClips(std::vector clips) { m_timelineWidget->setClips(clips); } diff --git a/src/motioneditwidget.h b/src/motioneditwidget.h index 7a097ef2..536c3a66 100644 --- a/src/motioneditwidget.h +++ b/src/motioneditwidget.h @@ -1,9 +1,9 @@ -#ifndef MOTION_EDIT_WIDGET_H -#define MOTION_EDIT_WIDGET_H +#ifndef DUST3D_MOTION_EDIT_WIDGET_H +#define DUST3D_MOTION_EDIT_WIDGET_H #include #include #include -#include "skeletondocument.h" +#include "document.h" #include "motiontimelinewidget.h" #include "modelwidget.h" #include "motionsgenerator.h" @@ -13,11 +13,11 @@ class MotionEditWidget : public QDialog { Q_OBJECT signals: - void addMotion(QString name, std::vector clips); - void setMotionClips(QUuid motionId, std::vector clips); + void addMotion(QString name, std::vector clips); + void setMotionClips(QUuid motionId, std::vector clips); void renameMotion(QUuid motionId, QString name); public: - MotionEditWidget(const SkeletonDocument *document, QWidget *parent=nullptr); + MotionEditWidget(const Document *document, QWidget *parent=nullptr); ~MotionEditWidget(); protected: void closeEvent(QCloseEvent *event) override; @@ -29,12 +29,12 @@ public slots: void clearUnsaveState(); void setEditMotionId(QUuid poseId); void setEditMotionName(QString name); - void setEditMotionClips(std::vector clips); + void setEditMotionClips(std::vector clips); void setUnsavedState(); void generatePreviews(); void previewsReady(); private: - const SkeletonDocument *m_document = nullptr; + const Document *m_document = nullptr; MotionTimelineWidget *m_timelineWidget = nullptr; ModelWidget *m_previewWidget = nullptr; QUuid m_motionId; diff --git a/src/motionlistwidget.cpp b/src/motionlistwidget.cpp index 97eef432..061b9279 100644 --- a/src/motionlistwidget.cpp +++ b/src/motionlistwidget.cpp @@ -3,10 +3,10 @@ #include #include #include -#include "skeletonxml.h" +#include "snapshotxml.h" #include "motionlistwidget.h" -MotionListWidget::MotionListWidget(const SkeletonDocument *document, QWidget *parent) : +MotionListWidget::MotionListWidget(const Document *document, QWidget *parent) : QTreeWidget(parent), m_document(document) { @@ -27,10 +27,10 @@ MotionListWidget::MotionListWidget(const SkeletonDocument *document, QWidget *pa setContentsMargins(0, 0, 0, 0); - connect(document, &SkeletonDocument::motionListChanged, this, &MotionListWidget::reload); - connect(document, &SkeletonDocument::cleanup, this, &MotionListWidget::removeAllContent); + connect(document, &Document::motionListChanged, this, &MotionListWidget::reload); + connect(document, &Document::cleanup, this, &MotionListWidget::removeAllContent); - connect(this, &MotionListWidget::removeMotion, document, &SkeletonDocument::removeMotion); + connect(this, &MotionListWidget::removeMotion, document, &Document::removeMotion); setContextMenuPolicy(Qt::CustomContextMenu); connect(this, &QTreeWidget::customContextMenuRequested, this, &MotionListWidget::showContextMenu); @@ -190,7 +190,7 @@ void MotionListWidget::showContextMenu(const QPoint &pos) QAction pasteAction(tr("Paste"), this); if (m_document->hasPastableMotionsInClipboard()) { - connect(&pasteAction, &QAction::triggered, m_document, &SkeletonDocument::paste); + connect(&pasteAction, &QAction::triggered, m_document, &Document::paste); contextMenu.addAction(&pasteAction); } @@ -287,8 +287,8 @@ void MotionListWidget::copy() std::set emptySet; - SkeletonSnapshot snapshot; - m_document->toSnapshot(&snapshot, emptySet, SkeletonDocumentToSnapshotFor::Motions, + Snapshot snapshot; + m_document->toSnapshot(&snapshot, emptySet, DocumentToSnapshotFor::Motions, emptySet, limitMotionIds); QString snapshotXml; QXmlStreamWriter xmlStreamWriter(&snapshotXml); diff --git a/src/motionlistwidget.h b/src/motionlistwidget.h index 6954064d..5b914b35 100644 --- a/src/motionlistwidget.h +++ b/src/motionlistwidget.h @@ -1,9 +1,9 @@ -#ifndef MOTION_LIST_WIDGET_H -#define MOTION_LIST_WIDGET_H +#ifndef DUST3D_MOTION_LIST_WIDGET_H +#define DUST3D_MOTION_LIST_WIDGET_H #include #include #include -#include "skeletondocument.h" +#include "document.h" #include "motionwidget.h" class MotionListWidget : public QTreeWidget @@ -14,7 +14,7 @@ signals: void modifyMotion(QUuid motionId); void cornerButtonClicked(QUuid motionId); public: - MotionListWidget(const SkeletonDocument *document, QWidget *parent=nullptr); + MotionListWidget(const Document *document, QWidget *parent=nullptr); bool isMotionSelected(QUuid motionId); public slots: void reload(); @@ -31,7 +31,7 @@ protected: private: int calculateColumnCount(); void updateMotionSelectState(QUuid motionId, bool selected); - const SkeletonDocument *m_document = nullptr; + const Document *m_document = nullptr; std::map> m_itemMap; std::set m_selectedMotionIds; QUuid m_currentSelectedMotionId; diff --git a/src/motionmanagewidget.cpp b/src/motionmanagewidget.cpp index 2fffd2ee..cff342ec 100644 --- a/src/motionmanagewidget.cpp +++ b/src/motionmanagewidget.cpp @@ -6,7 +6,7 @@ #include "theme.h" #include "infolabel.h" -MotionManageWidget::MotionManageWidget(const SkeletonDocument *document, QWidget *parent) : +MotionManageWidget::MotionManageWidget(const Document *document, QWidget *parent) : QWidget(parent), m_document(document) { @@ -35,8 +35,8 @@ MotionManageWidget::MotionManageWidget(const SkeletonDocument *document, QWidget } }; - connect(m_document, &SkeletonDocument::resultRigChanged, this, refreshInfoLabel); - connect(m_document, &SkeletonDocument::cleanup, this, refreshInfoLabel); + connect(m_document, &Document::resultRigChanged, this, refreshInfoLabel); + connect(m_document, &Document::cleanup, this, refreshInfoLabel); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(infoLabel); @@ -61,7 +61,7 @@ void MotionManageWidget::showMotionDialog(QUuid motionId) MotionEditWidget *motionEditWidget = new MotionEditWidget(m_document); motionEditWidget->setAttribute(Qt::WA_DeleteOnClose); if (!motionId.isNull()) { - const SkeletonMotion *motion = m_document->findMotion(motionId); + const Motion *motion = m_document->findMotion(motionId); if (nullptr != motion) { motionEditWidget->setEditMotionId(motionId); motionEditWidget->setEditMotionName(motion->name); diff --git a/src/motionmanagewidget.h b/src/motionmanagewidget.h index b752622e..e92a2a95 100644 --- a/src/motionmanagewidget.h +++ b/src/motionmanagewidget.h @@ -1,7 +1,7 @@ -#ifndef MOTION_MANAGE_WIDGET_H -#define MOTION_MANAGE_WIDGET_H +#ifndef DUST3D_MOTION_MANAGE_WIDGET_H +#define DUST3D_MOTION_MANAGE_WIDGET_H #include -#include "skeletondocument.h" +#include "document.h" #include "motionlistwidget.h" class MotionManageWidget : public QWidget @@ -11,14 +11,14 @@ signals: void registerDialog(QWidget *widget); void unregisterDialog(QWidget *widget); public: - MotionManageWidget(const SkeletonDocument *document, QWidget *parent=nullptr); + MotionManageWidget(const Document *document, QWidget *parent=nullptr); protected: virtual QSize sizeHint() const; public slots: void showAddMotionDialog(); void showMotionDialog(QUuid motionId); private: - const SkeletonDocument *m_document = nullptr; + const Document *m_document = nullptr; MotionListWidget *m_motionListWidget = nullptr; }; diff --git a/src/motionsgenerator.cpp b/src/motionsgenerator.cpp index e7cc14cd..76ae7ae3 100644 --- a/src/motionsgenerator.cpp +++ b/src/motionsgenerator.cpp @@ -7,10 +7,10 @@ MotionsGenerator::MotionsGenerator(const std::vector *rigBones, const std::map *rigWeights, - const MeshResultContext &meshResultContext) : + const Outcome &outcome) : m_rigBones(*rigBones), m_rigWeights(*rigWeights), - m_meshResultContext(meshResultContext) + m_outcome(outcome) { } @@ -29,7 +29,7 @@ void MotionsGenerator::addPoseToLibrary(const QUuid &poseId, const std::map &clips) +void MotionsGenerator::addMotionToLibrary(const QUuid &motionId, const std::vector &clips) { m_motions[motionId] = clips; } @@ -49,19 +49,19 @@ const std::set &MotionsGenerator::generatedMotionIds() return m_generatedMotionIds; } -std::vector *MotionsGenerator::findMotionClips(const QUuid &motionId) +std::vector *MotionsGenerator::findMotionClips(const QUuid &motionId) { auto findMotionResult = m_motions.find(motionId); if (findMotionResult == m_motions.end()) return nullptr; - std::vector &clips = findMotionResult->second; + std::vector &clips = findMotionResult->second; return &clips; } void MotionsGenerator::generatePreviewsForOutcomes(const std::vector> &outcomes, std::vector> &previews) { for (const auto &item: outcomes) { - PoseMeshCreator *poseMeshCreator = new PoseMeshCreator(item.second.nodes(), m_meshResultContext, m_rigWeights); + PoseMeshCreator *poseMeshCreator = new PoseMeshCreator(item.second.nodes(), m_outcome, m_rigWeights); poseMeshCreator->createMesh(); previews.push_back({item.first, poseMeshCreator->takeResultMesh()}); delete poseMeshCreator; @@ -70,7 +70,7 @@ void MotionsGenerator::generatePreviewsForOutcomes(const std::vector &visited) { - const std::vector *motionClips = findMotionClips(motionId); + const std::vector *motionClips = findMotionClips(motionId); if (!motionClips || motionClips->empty()) return 0; if (visited.find(motionId) != visited.end()) { @@ -80,11 +80,11 @@ float MotionsGenerator::calculateMotionDuration(const QUuid &motionId, std::set< float totalDuration = 0; visited.insert(motionId); for (const auto &clip: *motionClips) { - if (clip.clipType == SkeletonMotionClipType::Interpolation) + if (clip.clipType == MotionClipType::Interpolation) totalDuration += clip.duration; - else if (clip.clipType == SkeletonMotionClipType::Pose) + else if (clip.clipType == MotionClipType::Pose) totalDuration += clip.duration; - else if (clip.clipType == SkeletonMotionClipType::Motion) + else if (clip.clipType == MotionClipType::Motion) totalDuration += calculateMotionDuration(clip.linkToId, visited); } return totalDuration; @@ -99,14 +99,14 @@ void MotionsGenerator::generateMotion(const QUuid &motionId, std::set &vi visited.insert(motionId); - std::vector *motionClips = findMotionClips(motionId); + std::vector *motionClips = findMotionClips(motionId); if (!motionClips || motionClips->empty()) return; std::vector timePoints; float totalDuration = 0; for (auto &clip: *motionClips) { - if (clip.clipType == SkeletonMotionClipType::Motion) { + if (clip.clipType == MotionClipType::Motion) { std::set subVisited; clip.duration = calculateMotionDuration(clip.linkToId, subVisited); } @@ -131,8 +131,8 @@ void MotionsGenerator::generateMotion(const QUuid &motionId, std::set &vi break; } float clipLocalProgress = progress - timePoints[clipIndex]; - const SkeletonMotionClip &progressClip = (*motionClips)[clipIndex]; - if (SkeletonMotionClipType::Interpolation == progressClip.clipType) { + const MotionClip &progressClip = (*motionClips)[clipIndex]; + if (MotionClipType::Interpolation == progressClip.clipType) { if (clipIndex <= 0) { qDebug() << "Clip type is interpolation, but clip sit at begin"; break; @@ -156,7 +156,7 @@ void MotionsGenerator::generateMotion(const QUuid &motionId, std::set &vi lastProgress = progress; progress += interval; continue; - } else if (SkeletonMotionClipType::Pose == progressClip.clipType) { + } else if (MotionClipType::Pose == progressClip.clipType) { const JointNodeTree *beginJointNodeTree = findClipBeginJointNodeTree((*motionClips)[clipIndex]); if (nullptr == beginJointNodeTree) { qDebug() << "findClipBeginJointNodeTree failed"; @@ -166,7 +166,7 @@ void MotionsGenerator::generateMotion(const QUuid &motionId, std::set &vi lastProgress = progress; progress += interval; continue; - } else if (SkeletonMotionClipType::Motion == progressClip.clipType) { + } else if (MotionClipType::Motion == progressClip.clipType) { generateMotion(progressClip.linkToId, visited, outcomes); progress += progressClip.duration; continue; @@ -193,13 +193,13 @@ const JointNodeTree &MotionsGenerator::poseJointNodeTree(const QUuid &poseId) return insertResult.first->second; } -const JointNodeTree *MotionsGenerator::findClipBeginJointNodeTree(const SkeletonMotionClip &clip) +const JointNodeTree *MotionsGenerator::findClipBeginJointNodeTree(const MotionClip &clip) { - if (SkeletonMotionClipType::Pose == clip.clipType) { + if (MotionClipType::Pose == clip.clipType) { const JointNodeTree &jointNodeTree = poseJointNodeTree(clip.linkToId); return &jointNodeTree; - } else if (SkeletonMotionClipType::Motion == clip.clipType) { - const std::vector *motionClips = findMotionClips(clip.linkToId); + } else if (MotionClipType::Motion == clip.clipType) { + const std::vector *motionClips = findMotionClips(clip.linkToId); if (nullptr != motionClips && !motionClips->empty()) { return findClipBeginJointNodeTree((*motionClips)[0]); } @@ -208,13 +208,13 @@ const JointNodeTree *MotionsGenerator::findClipBeginJointNodeTree(const Skeleton return nullptr; } -const JointNodeTree *MotionsGenerator::findClipEndJointNodeTree(const SkeletonMotionClip &clip) +const JointNodeTree *MotionsGenerator::findClipEndJointNodeTree(const MotionClip &clip) { - if (SkeletonMotionClipType::Pose == clip.clipType) { + if (MotionClipType::Pose == clip.clipType) { const JointNodeTree &jointNodeTree = poseJointNodeTree(clip.linkToId); return &jointNodeTree; - } else if (SkeletonMotionClipType::Motion == clip.clipType) { - const std::vector *motionClips = findMotionClips(clip.linkToId); + } else if (MotionClipType::Motion == clip.clipType) { + const std::vector *motionClips = findMotionClips(clip.linkToId); if (nullptr != motionClips && !motionClips->empty()) { return findClipEndJointNodeTree((*motionClips)[motionClips->size() - 1]); } diff --git a/src/motionsgenerator.h b/src/motionsgenerator.h index df05061e..c6a416ec 100644 --- a/src/motionsgenerator.h +++ b/src/motionsgenerator.h @@ -1,5 +1,5 @@ -#ifndef MOTIONS_GENERATOR_H -#define MOTIONS_GENERATOR_H +#ifndef DUST3D_MOTIONS_GENERATOR_H +#define DUST3D_MOTIONS_GENERATOR_H #include #include #include @@ -7,7 +7,7 @@ #include "meshloader.h" #include "autorigger.h" #include "jointnodetree.h" -#include "skeletondocument.h" +#include "document.h" #include "tetrapodposer.h" class MotionsGenerator : public QObject @@ -16,10 +16,10 @@ class MotionsGenerator : public QObject public: MotionsGenerator(const std::vector *rigBones, const std::map *rigWeights, - const MeshResultContext &meshResultContext); + const Outcome &outcome); ~MotionsGenerator(); void addPoseToLibrary(const QUuid &poseId, const std::map> ¶meters); - void addMotionToLibrary(const QUuid &motionId, const std::vector &clips); + void addMotionToLibrary(const QUuid &motionId, const std::vector &clips); void addRequirement(const QUuid &motionId); std::vector> takeResultPreviewMeshs(const QUuid &motionId); std::vector> takeResultJointNodeTrees(const QUuid &motionId); @@ -36,17 +36,17 @@ private: void generateMotion(const QUuid &motionId, std::set &visited, std::vector> &outcomes); const JointNodeTree &poseJointNodeTree(const QUuid &poseId); JointNodeTree generateInterpolation(InterpolationType interpolationType, const JointNodeTree &first, const JointNodeTree &second, float progress); - const JointNodeTree *findClipBeginJointNodeTree(const SkeletonMotionClip &clip); - const JointNodeTree *findClipEndJointNodeTree(const SkeletonMotionClip &clip); - std::vector *findMotionClips(const QUuid &motionId); + const JointNodeTree *findClipBeginJointNodeTree(const MotionClip &clip); + const JointNodeTree *findClipEndJointNodeTree(const MotionClip &clip); + std::vector *findMotionClips(const QUuid &motionId); void generatePreviewsForOutcomes(const std::vector> &outcomes, std::vector> &previews); float calculateMotionDuration(const QUuid &motionId, std::set &visited); std::vector m_rigBones; std::map m_rigWeights; - MeshResultContext m_meshResultContext; + Outcome m_outcome; std::map>> m_poses; - std::map> m_motions; + std::map> m_motions; std::set m_requiredMotionIds; std::set m_generatedMotionIds; std::map>> m_resultPreviewMeshs; diff --git a/src/motiontimelinewidget.cpp b/src/motiontimelinewidget.cpp index b8774347..0430b21d 100644 --- a/src/motiontimelinewidget.cpp +++ b/src/motiontimelinewidget.cpp @@ -11,7 +11,7 @@ #include "posewidget.h" #include "motionwidget.h" -MotionTimelineWidget::MotionTimelineWidget(const SkeletonDocument *document, QWidget *parent) : +MotionTimelineWidget::MotionTimelineWidget(const Document *document, QWidget *parent) : QListWidget(parent), m_document(document) { @@ -39,12 +39,12 @@ QSize MotionTimelineWidget::sizeHint() const return QSize(0, MotionClipWidget::maxSize().height() + 4); } -const std::vector &MotionTimelineWidget::clips() +const std::vector &MotionTimelineWidget::clips() { return m_clips; } -void MotionTimelineWidget::setClips(std::vector clips) +void MotionTimelineWidget::setClips(std::vector clips) { m_clips = clips; if (m_currentSelectedIndex >= (int)m_clips.size()) @@ -54,38 +54,38 @@ void MotionTimelineWidget::setClips(std::vector clips) void MotionTimelineWidget::addPose(QUuid poseId) { - SkeletonMotionClip clip; + MotionClip clip; clip.linkToId = poseId; - clip.clipType = SkeletonMotionClipType::Pose; + clip.clipType = MotionClipType::Pose; clip.duration = 0; addClipAfterCurrentIndex(clip); emit clipsChanged(); reload(); } -void MotionTimelineWidget::addClipAfterCurrentIndex(const SkeletonMotionClip &clip) +void MotionTimelineWidget::addClipAfterCurrentIndex(const MotionClip &clip) { - SkeletonMotionClip interpolationClip; + MotionClip interpolationClip; bool needPrependInterpolationClip = false; int afterIndex = m_currentSelectedIndex; if (-1 == afterIndex) afterIndex = m_clips.size() - 1; if (-1 != afterIndex) { - if (m_clips[afterIndex].clipType == SkeletonMotionClipType::Interpolation) { + if (m_clips[afterIndex].clipType == MotionClipType::Interpolation) { --afterIndex; } } - if (clip.clipType == SkeletonMotionClipType::Interpolation) { + if (clip.clipType == MotionClipType::Interpolation) { if (m_clips.empty()) return; - if (m_clips[m_clips.size() - 1].clipType == SkeletonMotionClipType::Interpolation) + if (m_clips[m_clips.size() - 1].clipType == MotionClipType::Interpolation) return; } else { - if (!m_clips.empty() && m_clips[m_clips.size() - 1].clipType != SkeletonMotionClipType::Interpolation) { + if (!m_clips.empty() && m_clips[m_clips.size() - 1].clipType != MotionClipType::Interpolation) { interpolationClip.interpolationType = InterpolationType::EaseInOutCubic; - interpolationClip.clipType = SkeletonMotionClipType::Interpolation; + interpolationClip.clipType = MotionClipType::Interpolation; interpolationClip.duration = 1.0; needPrependInterpolationClip = true; } @@ -104,9 +104,9 @@ void MotionTimelineWidget::addClipAfterCurrentIndex(const SkeletonMotionClip &cl void MotionTimelineWidget::addMotion(QUuid motionId) { - SkeletonMotionClip clip; + MotionClip clip; clip.linkToId = motionId; - clip.clipType = SkeletonMotionClipType::Motion; + clip.clipType = MotionClipType::Motion; clip.duration = 0; addClipAfterCurrentIndex(clip); emit clipsChanged(); @@ -118,7 +118,7 @@ void MotionTimelineWidget::setClipInterpolationType(int index, InterpolationType if (index >= (int)m_clips.size()) return; - if (m_clips[index].clipType != SkeletonMotionClipType::Interpolation) + if (m_clips[index].clipType != MotionClipType::Interpolation) return; m_clips[index].interpolationType = type; @@ -130,7 +130,7 @@ void MotionTimelineWidget::setClipDuration(int index, float duration) if (index >= (int)m_clips.size()) return; - if (m_clips[index].clipType == SkeletonMotionClipType::Motion) + if (m_clips[index].clipType == MotionClipType::Motion) return; m_clips[index].duration = duration; @@ -284,7 +284,7 @@ void MotionTimelineWidget::showContextMenu(const QPoint &pos) QAction doubleDurationAction(tr("Double Duration"), this); if (-1 != m_currentSelectedIndex) { - if (m_clips[m_currentSelectedIndex].clipType == SkeletonMotionClipType::Interpolation) { + if (m_clips[m_currentSelectedIndex].clipType == MotionClipType::Interpolation) { connect(&doubleDurationAction, &QAction::triggered, [=]() { setClipDuration(m_currentSelectedIndex, m_clips[m_currentSelectedIndex].duration * 2); }); @@ -294,7 +294,7 @@ void MotionTimelineWidget::showContextMenu(const QPoint &pos) QAction halveDurationAction(tr("Halve Duration"), this); if (-1 != m_currentSelectedIndex) { - if (m_clips[m_currentSelectedIndex].clipType == SkeletonMotionClipType::Interpolation) { + if (m_clips[m_currentSelectedIndex].clipType == MotionClipType::Interpolation) { connect(&halveDurationAction, &QAction::triggered, [=]() { setClipDuration(m_currentSelectedIndex, m_clips[m_currentSelectedIndex].duration / 2); }); @@ -304,7 +304,7 @@ void MotionTimelineWidget::showContextMenu(const QPoint &pos) QAction deleteAction(tr("Delete"), this); if (-1 != m_currentSelectedIndex) { - if (m_clips[m_currentSelectedIndex].clipType != SkeletonMotionClipType::Interpolation) { + if (m_clips[m_currentSelectedIndex].clipType != MotionClipType::Interpolation) { connect(&deleteAction, &QAction::triggered, [=]() { removeClip(m_currentSelectedIndex); }); diff --git a/src/motiontimelinewidget.h b/src/motiontimelinewidget.h index 53658e84..6fe4b72f 100644 --- a/src/motiontimelinewidget.h +++ b/src/motiontimelinewidget.h @@ -1,9 +1,9 @@ -#ifndef MOTION_TIMELINE_WIDGET_H -#define MOTION_TIMELINE_WIDGET_H +#ifndef DUST3D_MOTION_TIMELINE_WIDGET_H +#define DUST3D_MOTION_TIMELINE_WIDGET_H #include #include #include -#include "skeletondocument.h" +#include "document.h" #include "interpolationtype.h" class MotionTimelineWidget : public QListWidget @@ -12,11 +12,11 @@ class MotionTimelineWidget : public QListWidget signals: void clipsChanged(); public: - MotionTimelineWidget(const SkeletonDocument *document, QWidget *parent=nullptr); - const std::vector &clips(); + MotionTimelineWidget(const Document *document, QWidget *parent=nullptr); + const std::vector &clips(); public slots: - void setClips(std::vector clips); + void setClips(std::vector clips); void addPose(QUuid poseId); void addMotion(QUuid motionId); void reload(); @@ -32,10 +32,10 @@ protected: QSize sizeHint() const override; private: - void addClipAfterCurrentIndex(const SkeletonMotionClip &clip); + void addClipAfterCurrentIndex(const MotionClip &clip); - std::vector m_clips; - const SkeletonDocument *m_document = nullptr; + std::vector m_clips; + const Document *m_document = nullptr; int m_currentSelectedIndex = -1; }; diff --git a/src/motionwidget.cpp b/src/motionwidget.cpp index ea2f3b0e..4959539c 100644 --- a/src/motionwidget.cpp +++ b/src/motionwidget.cpp @@ -1,7 +1,7 @@ #include #include "motionwidget.h" -MotionWidget::MotionWidget(const SkeletonDocument *document, QUuid motionId) : +MotionWidget::MotionWidget(const Document *document, QUuid motionId) : m_motionId(motionId), m_document(document) { @@ -31,12 +31,12 @@ MotionWidget::MotionWidget(const SkeletonDocument *document, QUuid motionId) : setFixedSize(Theme::motionPreviewImageSize, MotionWidget::preferredHeight()); - connect(document, &SkeletonDocument::motionNameChanged, this, [=](QUuid motionId) { + connect(document, &Document::motionNameChanged, this, [=](QUuid motionId) { if (motionId != m_motionId) return; updateName(); }); - connect(document, &SkeletonDocument::motionPreviewChanged, this, [=](QUuid motionId) { + connect(document, &Document::motionPreviewChanged, this, [=](QUuid motionId) { if (motionId != m_motionId) return; updatePreview(); @@ -76,7 +76,7 @@ void MotionWidget::reload() void MotionWidget::updatePreview() { - const SkeletonMotion *motion = m_document->findMotion(m_motionId); + const Motion *motion = m_document->findMotion(m_motionId); if (!motion) { qDebug() << "Motion not found:" << m_motionId; return; @@ -87,7 +87,7 @@ void MotionWidget::updatePreview() void MotionWidget::updateName() { - const SkeletonMotion *motion = m_document->findMotion(m_motionId); + const Motion *motion = m_document->findMotion(m_motionId); if (!motion) { qDebug() << "Motion not found:" << m_motionId; return; diff --git a/src/motionwidget.h b/src/motionwidget.h index 0eafeeb2..9674c47b 100644 --- a/src/motionwidget.h +++ b/src/motionwidget.h @@ -1,9 +1,9 @@ -#ifndef MOTION_WIDGET_H -#define MOTION_WIDGET_H +#ifndef DUST3D_MOTION_WIDGET_H +#define DUST3D_MOTION_WIDGET_H #include #include #include -#include "skeletondocument.h" +#include "document.h" #include "modelwidget.h" class MotionWidget : public QFrame @@ -13,7 +13,7 @@ signals: void modifyMotion(QUuid motionId); void cornerButtonClicked(QUuid motionId); public: - MotionWidget(const SkeletonDocument *document, QUuid motionId); + MotionWidget(const Document *document, QUuid motionId); static int preferredHeight(); ModelWidget *previewWidget(); protected: @@ -27,7 +27,7 @@ public slots: void setCornerButtonVisible(bool visible); private: QUuid m_motionId; - const SkeletonDocument *m_document = nullptr; + const Document *m_document = nullptr; ModelWidget *m_previewWidget = nullptr; QLabel *m_nameLabel = nullptr; QPushButton *m_cornerButton = nullptr; diff --git a/src/meshresultcontext.cpp b/src/outcome.cpp similarity index 89% rename from src/meshresultcontext.cpp rename to src/outcome.cpp index 4cdf2877..00edb71c 100644 --- a/src/meshresultcontext.cpp +++ b/src/outcome.cpp @@ -7,7 +7,7 @@ #include #include "texturegenerator.h" #include "theme.h" -#include "meshresultcontext.h" +#include "outcome.h" #include "positionmap.h" #include "anglesmooth.h" @@ -26,7 +26,7 @@ struct CandidateEdge float length; }; -MeshResultContext::MeshResultContext() : +Outcome::Outcome() : m_triangleSourceResolved(false), m_triangleMaterialResolved(false), m_triangleEdgeSourceMapResolved(false), @@ -38,7 +38,7 @@ MeshResultContext::MeshResultContext() : { } -const std::vector> &MeshResultContext::triangleSourceNodes() +const std::vector> &Outcome::triangleSourceNodes() { if (!m_triangleSourceResolved) { m_triangleSourceResolved = true; @@ -48,7 +48,7 @@ const std::vector> &MeshResultContext::triangleSourceNod return m_triangleSourceNodes; } -const std::map> &MeshResultContext::vertexSourceMap() +const std::map> &Outcome::vertexSourceMap() { if (!m_triangleSourceResolved) { m_triangleSourceResolved = true; @@ -58,7 +58,7 @@ const std::map> &MeshResultContext::vertexSourceMap return m_vertexSourceMap; } -const std::vector &MeshResultContext::triangleMaterials() +const std::vector &Outcome::triangleMaterials() { if (!m_triangleMaterialResolved) { calculateTriangleMaterials(m_triangleMaterials); @@ -67,7 +67,7 @@ const std::vector &MeshResultContext::triangleMaterials() return m_triangleMaterials; } -const std::map, std::pair> &MeshResultContext::triangleEdgeSourceMap() +const std::map, std::pair> &Outcome::triangleEdgeSourceMap() { if (!m_triangleEdgeSourceMapResolved) { calculateTriangleEdgeSourceMap(m_triangleEdgeSourceMap); @@ -76,7 +76,7 @@ const std::map, std::pair> &MeshResultContext: return m_triangleEdgeSourceMap; } -const std::map, BmeshNode *> &MeshResultContext::bmeshNodeMap() +const std::map, OutcomeNode *> &Outcome::bmeshNodeMap() { if (!m_bmeshNodeMapResolved) { calculateBmeshNodeMap(m_bmeshNodeMap); @@ -85,7 +85,7 @@ const std::map, BmeshNode *> &MeshResultContext::bmeshNo return m_bmeshNodeMap; } -void MeshResultContext::calculateTriangleSourceNodes(std::vector> &triangleSourceNodes, std::map> &vertexSourceMap) +void Outcome::calculateTriangleSourceNodes(std::vector> &triangleSourceNodes, std::map> &vertexSourceMap) { PositionMap> positionMap; std::map, HalfColorEdge> halfColorEdgeMap; @@ -95,7 +95,7 @@ void MeshResultContext::calculateTriangleSourceNodes(std::vector source; if (positionMap.findPosition(resultVertex->position.x(), resultVertex->position.y(), resultVertex->position.z(), &source)) { vertexSourceMap[x] = source; @@ -228,7 +228,7 @@ void MeshResultContext::calculateTriangleSourceNodes(std::vector> &vertexSourceMap) +void Outcome::calculateRemainingVertexSourceNodesAfterTriangleSourceNodesSolved(std::map> &vertexSourceMap) { std::map>> remainings; for (auto x = 0u; x < triangles.size(); x++) { @@ -259,9 +259,9 @@ void MeshResultContext::calculateRemainingVertexSourceNodesAfterTriangleSourceNo } } -void MeshResultContext::calculateTriangleMaterials(std::vector &triangleMaterials) +void Outcome::calculateTriangleMaterials(std::vector &triangleMaterials) { - std::map, Material> nodeMaterialMap; + std::map, OutcomeMaterial> nodeMaterialMap; for (const auto &it: bmeshNodes) { nodeMaterialMap[std::make_pair(it.partId, it.nodeId)] = it.material; } @@ -271,7 +271,7 @@ void MeshResultContext::calculateTriangleMaterials(std::vector &triang } } -void MeshResultContext::calculateTriangleEdgeSourceMap(std::map, std::pair> &triangleEdgeSourceMap) +void Outcome::calculateTriangleEdgeSourceMap(std::map, std::pair> &triangleEdgeSourceMap) { const std::vector> sourceNodes = triangleSourceNodes(); for (auto x = 0u; x < triangles.size(); x++) { @@ -284,20 +284,20 @@ void MeshResultContext::calculateTriangleEdgeSourceMap(std::map, BmeshNode *> &bmeshNodeMap) { +void Outcome::calculateBmeshNodeMap(std::map, OutcomeNode *> &bmeshNodeMap) { for (auto i = 0u; i < bmeshNodes.size(); i++) { - BmeshNode *bmeshNode = &bmeshNodes[i]; + OutcomeNode *bmeshNode = &bmeshNodes[i]; bmeshNodeMap[std::make_pair(bmeshNode->partId, bmeshNode->nodeId)] = bmeshNode; } } struct BmeshNodeDistWithWorldCenter { - BmeshNode *bmeshNode; + OutcomeNode *bmeshNode; float dist2; }; -const std::map &MeshResultContext::parts() +const std::map &Outcome::parts() { if (!m_resultPartsResolved) { calculateResultParts(m_resultParts); @@ -306,7 +306,7 @@ const std::map &MeshResultContext::parts() return m_resultParts; } -const std::vector &MeshResultContext::triangleUvs() +const std::vector &Outcome::triangleUvs() { if (!m_resultTriangleUvsResolved) { calculateResultTriangleUvs(m_resultTriangleUvs, m_seamVertices); @@ -315,7 +315,7 @@ const std::vector &MeshResultContext::triangleUvs() return m_resultTriangleUvs; } -void MeshResultContext::calculateResultParts(std::map &parts) +void Outcome::calculateResultParts(std::map &parts) { std::map, int> oldVertexToNewMap; for (auto x = 0u; x < triangles.size(); x++) { @@ -329,7 +329,7 @@ void MeshResultContext::calculateResultParts(std::map &parts) parts.insert(std::make_pair(sourceNode.first, newPart)); } auto &resultPart = parts[sourceNode.first]; - ResultTriangle newTriangle; + OutcomeTriangle newTriangle; newTriangle.normal = triangle.normal; for (auto i = 0u; i < 3; i++) { const auto &normal = interpolatedTriangleVertexNormals()[normalIndex++]; @@ -341,7 +341,7 @@ void MeshResultContext::calculateResultParts(std::map &parts) int newIndex = resultPart.vertices.size(); resultPart.verticesOldIndicies.push_back(triangle.indicies[i]); resultPart.vertices.push_back(vertices[triangle.indicies[i]]); - ResultVertexUv vertexUv; + OutcomeVertexUv vertexUv; vertexUv.uv[0] = triangleUvs()[x].uv[i][0]; vertexUv.uv[1] = triangleUvs()[x].uv[i][1]; resultPart.vertexUvs.push_back(vertexUv); @@ -359,7 +359,7 @@ void MeshResultContext::calculateResultParts(std::map &parts) } } -void MeshResultContext::calculateResultTriangleUvs(std::vector &uvs, std::set &seamVertices) +void Outcome::calculateResultTriangleUvs(std::vector &uvs, std::set &seamVertices) { simpleuv::Mesh inputMesh; const auto &choosenVertices = vertices; @@ -420,7 +420,7 @@ void MeshResultContext::calculateResultTriangleUvs(std::vector } } -void MeshResultContext::interpolateTriangleVertexNormals(std::vector &resultNormals) +void Outcome::interpolateTriangleVertexNormals(std::vector &resultNormals) { std::vector inputVerticies; std::vector> inputTriangles; @@ -435,7 +435,7 @@ void MeshResultContext::interpolateTriangleVertexNormals(std::vector angleSmooth(inputVerticies, inputTriangles, inputNormals, thresholdAngleDegrees, resultNormals); } -const std::vector &MeshResultContext::interpolatedTriangleVertexNormals() +const std::vector &Outcome::interpolatedTriangleVertexNormals() { if (!m_triangleVertexNormalsInterpolated) { m_triangleVertexNormalsInterpolated = true; @@ -444,7 +444,7 @@ const std::vector &MeshResultContext::interpolatedTriangleVertexNorma return m_interpolatedTriangleVertexNormals; } -const std::vector &MeshResultContext::triangleTangents() +const std::vector &Outcome::triangleTangents() { if (!m_triangleTangentsResolved) { m_triangleTangentsResolved = true; @@ -453,7 +453,7 @@ const std::vector &MeshResultContext::triangleTangents() return m_triangleTangents; } -void MeshResultContext::calculateTriangleTangents(std::vector &tangents) +void Outcome::calculateTriangleTangents(std::vector &tangents) { tangents.resize(triangles.size()); diff --git a/src/meshresultcontext.h b/src/outcome.h similarity index 66% rename from src/meshresultcontext.h rename to src/outcome.h index 8b7d83bc..6910d89a 100644 --- a/src/meshresultcontext.h +++ b/src/outcome.h @@ -1,84 +1,90 @@ -#ifndef MESH_RESULT_CONTEXT_H -#define MESH_RESULT_CONTEXT_H +#ifndef DUST3D_OUTCOME_H +#define DUST3D_OUTCOME_H #include #include #include #include #include #include "positionmap.h" -#include "skeletonbonemark.h" +#include "bonemark.h" #include "texturetype.h" #include "material.h" #define MAX_WEIGHT_NUM 4 -struct BmeshNode +struct OutcomeMaterial +{ + QColor color; + QUuid materialId; +}; + +struct OutcomeNode { QUuid partId; QUuid nodeId; QVector3D origin; float radius = 0; - Material material; + OutcomeMaterial material; QUuid mirrorFromPartId; - SkeletonBoneMark boneMark; + BoneMark boneMark; }; -struct BmeshVertex +struct OutcomeNodeVertex { QVector3D position; QUuid partId; QUuid nodeId; }; -struct ResultVertex +struct OutcomeVertex { QVector3D position; }; -struct ResultTriangle +struct OutcomeTriangle { int indicies[3] = {0, 0, 0}; QVector3D normal; }; -struct ResultTriangleUv +struct OutcomeTriangleUv { float uv[3][2] = {{0, 0}, {0, 0}, {0, 0}}; bool resolved = false; }; -struct ResultVertexUv +struct OutcomeVertexUv { float uv[2] = {0, 0}; }; struct ResultPart { - Material material; - std::vector vertices; + OutcomeMaterial material; + std::vector vertices; std::vector verticesOldIndicies; std::vector interpolatedTriangleVertexNormals; - std::vector triangles; - std::vector uvs; - std::vector vertexUvs; + std::vector triangles; + std::vector uvs; + std::vector vertexUvs; std::vector triangleTangents; }; -class MeshResultContext +class Outcome { public: - std::vector bmeshNodes; - std::vector bmeshVertices; - std::vector vertices; - std::vector triangles; - MeshResultContext(); + std::vector bmeshNodes; + std::vector bmeshVertices; + std::vector vertices; + std::vector triangles; + Outcome(); public: const std::vector> &triangleSourceNodes(); - const std::vector &triangleMaterials(); + const std::vector &triangleMaterials(); const std::map, std::pair> &triangleEdgeSourceMap(); - const std::map, BmeshNode *> &bmeshNodeMap(); + const std::map, OutcomeNode *> &bmeshNodeMap(); const std::map &parts(); - const std::vector &triangleUvs(); + const std::vector &triangleUvs(); const std::map> &vertexSourceMap(); const std::vector &interpolatedTriangleVertexNormals(); const std::vector &triangleTangents(); @@ -93,11 +99,11 @@ private: bool m_triangleTangentsResolved; private: std::vector> m_triangleSourceNodes; - std::vector m_triangleMaterials; + std::vector m_triangleMaterials; std::map, std::pair> m_triangleEdgeSourceMap; - std::map, BmeshNode *> m_bmeshNodeMap; + std::map, OutcomeNode *> m_bmeshNodeMap; std::map m_resultParts; - std::vector m_resultTriangleUvs; + std::vector m_resultTriangleUvs; std::set m_seamVertices; std::map> m_vertexSourceMap; std::map m_rearrangedVerticesToOldIndexMap; @@ -106,11 +112,11 @@ private: private: void calculateTriangleSourceNodes(std::vector> &triangleSourceNodes, std::map> &vertexSourceMap); void calculateRemainingVertexSourceNodesAfterTriangleSourceNodesSolved(std::map> &vertexSourceMap); - void calculateTriangleMaterials(std::vector &triangleMaterials); + void calculateTriangleMaterials(std::vector &triangleMaterials); void calculateTriangleEdgeSourceMap(std::map, std::pair> &triangleEdgeSourceMap); - void calculateBmeshNodeMap(std::map, BmeshNode *> &bmeshNodeMap); + void calculateBmeshNodeMap(std::map, OutcomeNode *> &bmeshNodeMap); void calculateResultParts(std::map &parts); - void calculateResultTriangleUvs(std::vector &uvs, std::set &seamVertices); + void calculateResultTriangleUvs(std::vector &uvs, std::set &seamVertices); void interpolateTriangleVertexNormals(std::vector &resultNormals); void calculateTriangleTangents(std::vector &tangents); }; diff --git a/src/skeletonparttreewidget.cpp b/src/parttreewidget.cpp similarity index 85% rename from src/skeletonparttreewidget.cpp rename to src/parttreewidget.cpp index a5418698..87f7319f 100644 --- a/src/skeletonparttreewidget.cpp +++ b/src/parttreewidget.cpp @@ -6,12 +6,12 @@ #include #include #include -#include "skeletonparttreewidget.h" -#include "skeletonpartwidget.h" +#include "parttreewidget.h" +#include "partwidget.h" #include "skeletongraphicswidget.h" #include "floatnumberwidget.h" -SkeletonPartTreeWidget::SkeletonPartTreeWidget(const SkeletonDocument *document, QWidget *parent) : +PartTreeWidget::PartTreeWidget(const Document *document, QWidget *parent) : QTreeWidget(parent), m_document(document) { @@ -56,13 +56,13 @@ SkeletonPartTreeWidget::SkeletonPartTreeWidget(const SkeletonDocument *document, gradient.setColorAt(1, Qt::transparent); m_hightlightedPartBackground = QBrush(gradient); - connect(this, &QTreeWidget::customContextMenuRequested, this, &SkeletonPartTreeWidget::showContextMenu); - connect(this, &QTreeWidget::itemChanged, this, &SkeletonPartTreeWidget::groupChanged); - connect(this, &QTreeWidget::itemExpanded, this, &SkeletonPartTreeWidget::groupExpanded); - connect(this, &QTreeWidget::itemCollapsed, this, &SkeletonPartTreeWidget::groupCollapsed); + connect(this, &QTreeWidget::customContextMenuRequested, this, &PartTreeWidget::showContextMenu); + connect(this, &QTreeWidget::itemChanged, this, &PartTreeWidget::groupChanged); + connect(this, &QTreeWidget::itemExpanded, this, &PartTreeWidget::groupExpanded); + connect(this, &QTreeWidget::itemCollapsed, this, &PartTreeWidget::groupCollapsed); } -void SkeletonPartTreeWidget::selectComponent(QUuid componentId, bool multiple) +void PartTreeWidget::selectComponent(QUuid componentId, bool multiple) { if (multiple) { if (!m_currentSelectedComponentId.isNull()) { @@ -103,9 +103,9 @@ void SkeletonPartTreeWidget::selectComponent(QUuid componentId, bool multiple) } } -void SkeletonPartTreeWidget::updateComponentSelectState(QUuid componentId, bool selected) +void PartTreeWidget::updateComponentSelectState(QUuid componentId, bool selected) { - const SkeletonComponent *component = m_document->findComponent(componentId); + const Component *component = m_document->findComponent(componentId); if (nullptr == component) { qDebug() << "Component not found:" << componentId; return; @@ -113,7 +113,7 @@ void SkeletonPartTreeWidget::updateComponentSelectState(QUuid componentId, bool if (!component->linkToPartId.isNull()) { auto item = m_partItemMap.find(component->linkToPartId); if (item != m_componentItemMap.end()) { - SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); + PartWidget *widget = (PartWidget *)itemWidget(item->second, 0); widget->updateCheckedState(selected); } return; @@ -130,7 +130,7 @@ void SkeletonPartTreeWidget::updateComponentSelectState(QUuid componentId, bool } } -void SkeletonPartTreeWidget::mousePressEvent(QMouseEvent *event) +void PartTreeWidget::mousePressEvent(QMouseEvent *event) { QModelIndex itemIndex = indexAt(event->pos()); QTreeView::mousePressEvent(event); @@ -141,7 +141,7 @@ void SkeletonPartTreeWidget::mousePressEvent(QMouseEvent *event) auto componentId = QUuid(item->data(0, Qt::UserRole).toString()); if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier)) { if (!m_shiftStartComponentId.isNull()) { - const SkeletonComponent *parent = m_document->findComponentParent(m_shiftStartComponentId); + const Component *parent = m_document->findComponentParent(m_shiftStartComponentId); if (parent) { if (!parent->childrenIds.empty()) { bool startAdd = false; @@ -190,11 +190,11 @@ void SkeletonPartTreeWidget::mousePressEvent(QMouseEvent *event) } } -void SkeletonPartTreeWidget::showContextMenu(const QPoint &pos) +void PartTreeWidget::showContextMenu(const QPoint &pos) { - const SkeletonComponent *component = nullptr; - const SkeletonPart *part = nullptr; - SkeletonPartWidget *partWidget = nullptr; + const Component *component = nullptr; + const Part *part = nullptr; + PartWidget *partWidget = nullptr; std::set unorderedComponentIds = m_selectedComponentIds; if (!m_currentSelectedComponentId.isNull()) @@ -238,7 +238,7 @@ void SkeletonPartTreeWidget::showContextMenu(const QPoint &pos) if (nullptr != part) { auto findItem = m_partItemMap.find(part->id); if (findItem != m_partItemMap.end()) { - partWidget = (SkeletonPartWidget *)itemWidget(findItem->second, 0); + partWidget = (PartWidget *)itemWidget(findItem->second, 0); } } if (nullptr != part && nullptr != partWidget) { @@ -500,7 +500,7 @@ void SkeletonPartTreeWidget::showContextMenu(const QPoint &pos) }); addChildGroupsFunc = [this, &groupsActions, &addChildGroupsFunc, &moveToMenu, &componentIds](QUuid currentId, int tabs) -> void { - const SkeletonComponent *current = m_document->findComponent(currentId); + const Component *current = m_document->findComponent(currentId); if (nullptr == current) return; if (!current->id.isNull() && current->linkDataType().isEmpty()) { @@ -535,11 +535,11 @@ void SkeletonPartTreeWidget::showContextMenu(const QPoint &pos) } } -QWidget *SkeletonPartTreeWidget::createSmoothMenuWidget(QUuid componentId) +QWidget *PartTreeWidget::createSmoothMenuWidget(QUuid componentId) { QWidget *popup = new QWidget; - const SkeletonComponent *component = m_document->findComponent(componentId); + const Component *component = m_document->findComponent(componentId); if (!component) { qDebug() << "Find component failed:" << componentId; return popup; @@ -607,7 +607,7 @@ QWidget *SkeletonPartTreeWidget::createSmoothMenuWidget(QUuid componentId) return popup; } -QTreeWidgetItem *SkeletonPartTreeWidget::findComponentItem(QUuid componentId) +QTreeWidgetItem *PartTreeWidget::findComponentItem(QUuid componentId) { auto findResult = m_componentItemMap.find(componentId); if (findResult == m_componentItemMap.end()) @@ -616,7 +616,7 @@ QTreeWidgetItem *SkeletonPartTreeWidget::findComponentItem(QUuid componentId) return findResult->second; } -void SkeletonPartTreeWidget::componentNameChanged(QUuid componentId) +void PartTreeWidget::componentNameChanged(QUuid componentId) { auto componentItem = m_componentItemMap.find(componentId); if (componentItem == m_componentItemMap.end()) { @@ -624,7 +624,7 @@ void SkeletonPartTreeWidget::componentNameChanged(QUuid componentId) return; } - const SkeletonComponent *component = m_document->findComponent(componentId); + const Component *component = m_document->findComponent(componentId); if (nullptr == component) { qDebug() << "Find component failed:" << componentId; return; @@ -633,7 +633,7 @@ void SkeletonPartTreeWidget::componentNameChanged(QUuid componentId) componentItem->second->setText(0, component->name); } -void SkeletonPartTreeWidget::componentExpandStateChanged(QUuid componentId) +void PartTreeWidget::componentExpandStateChanged(QUuid componentId) { auto componentItem = m_componentItemMap.find(componentId); if (componentItem == m_componentItemMap.end()) { @@ -641,7 +641,7 @@ void SkeletonPartTreeWidget::componentExpandStateChanged(QUuid componentId) return; } - const SkeletonComponent *component = m_document->findComponent(componentId); + const Component *component = m_document->findComponent(componentId); if (nullptr == component) { qDebug() << "Find component failed:" << componentId; return; @@ -650,14 +650,14 @@ void SkeletonPartTreeWidget::componentExpandStateChanged(QUuid componentId) componentItem->second->setExpanded(component->expanded); } -void SkeletonPartTreeWidget::addComponentChildrenToItem(QUuid componentId, QTreeWidgetItem *parentItem) +void PartTreeWidget::addComponentChildrenToItem(QUuid componentId, QTreeWidgetItem *parentItem) { - const SkeletonComponent *parentComponent = m_document->findComponent(componentId); + const Component *parentComponent = m_document->findComponent(componentId); if (nullptr == parentComponent) return; for (const auto &childId: parentComponent->childrenIds) { - const SkeletonComponent *component = m_document->findComponent(childId); + const Component *component = m_document->findComponent(childId); if (nullptr == component) continue; if (!component->linkToPartId.isNull()) { @@ -666,8 +666,8 @@ void SkeletonPartTreeWidget::addComponentChildrenToItem(QUuid componentId, QTree item->setData(0, Qt::UserRole, QVariant(component->id.toString())); item->setFlags(item->flags() & ~(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable)); QUuid partId = component->linkToPartId; - SkeletonPartWidget *widget = new SkeletonPartWidget(m_document, partId); - item->setSizeHint(0, SkeletonPartWidget::preferredSize()); + PartWidget *widget = new PartWidget(m_document, partId); + item->setSizeHint(0, PartWidget::preferredSize()); setItemWidget(item, 0, widget); widget->reload(); m_partItemMap[partId] = item; @@ -685,13 +685,13 @@ void SkeletonPartTreeWidget::addComponentChildrenToItem(QUuid componentId, QTree } } -void SkeletonPartTreeWidget::deleteItemChildren(QTreeWidgetItem *item) +void PartTreeWidget::deleteItemChildren(QTreeWidgetItem *item) { auto children = item->takeChildren(); while (!children.isEmpty()) { auto first = children.takeFirst(); auto componentId = QUuid(first->data(0, Qt::UserRole).toString()); - const SkeletonComponent *component = m_document->findComponent(componentId); + const Component *component = m_document->findComponent(componentId); if (nullptr != component) { m_componentItemMap.erase(componentId); if (!component->linkToPartId.isNull()) { @@ -703,7 +703,7 @@ void SkeletonPartTreeWidget::deleteItemChildren(QTreeWidgetItem *item) } } -void SkeletonPartTreeWidget::componentChildrenChanged(QUuid componentId) +void PartTreeWidget::componentChildrenChanged(QUuid componentId) { QTreeWidgetItem *parentItem = findComponentItem(componentId); if (nullptr == parentItem) { @@ -723,7 +723,7 @@ void SkeletonPartTreeWidget::componentChildrenChanged(QUuid componentId) } } -void SkeletonPartTreeWidget::removeAllContent() +void PartTreeWidget::removeAllContent() { qDeleteAll(invisibleRootItem()->takeChildren()); m_partItemMap.clear(); @@ -731,7 +731,7 @@ void SkeletonPartTreeWidget::removeAllContent() m_componentItemMap[QUuid()] = invisibleRootItem(); } -void SkeletonPartTreeWidget::componentRemoved(QUuid componentId) +void PartTreeWidget::componentRemoved(QUuid componentId) { auto componentItem = m_componentItemMap.find(componentId); if (componentItem == m_componentItemMap.end()) @@ -742,12 +742,12 @@ void SkeletonPartTreeWidget::componentRemoved(QUuid componentId) m_componentItemMap.erase(componentId); } -void SkeletonPartTreeWidget::componentAdded(QUuid componentId) +void PartTreeWidget::componentAdded(QUuid componentId) { // ignore } -void SkeletonPartTreeWidget::partRemoved(QUuid partId) +void PartTreeWidget::partRemoved(QUuid partId) { auto partItem = m_partItemMap.find(partId); if (partItem == m_partItemMap.end()) @@ -756,14 +756,14 @@ void SkeletonPartTreeWidget::partRemoved(QUuid partId) m_partItemMap.erase(partItem); } -void SkeletonPartTreeWidget::groupChanged(QTreeWidgetItem *item, int column) +void PartTreeWidget::groupChanged(QTreeWidgetItem *item, int column) { if (0 != column) return; auto componentId = QUuid(item->data(0, Qt::UserRole).toString()); - const SkeletonComponent *component = m_document->findComponent(componentId); + const Component *component = m_document->findComponent(componentId); if (nullptr == component) { qDebug() << "Find component failed:" << componentId; return; @@ -773,140 +773,140 @@ void SkeletonPartTreeWidget::groupChanged(QTreeWidgetItem *item, int column) emit renameComponent(componentId, item->text(0)); } -void SkeletonPartTreeWidget::groupExpanded(QTreeWidgetItem *item) +void PartTreeWidget::groupExpanded(QTreeWidgetItem *item) { QUuid componentId = QUuid(item->data(0, Qt::UserRole).toString()); emit setComponentExpandState(componentId, true); } -void SkeletonPartTreeWidget::groupCollapsed(QTreeWidgetItem *item) +void PartTreeWidget::groupCollapsed(QTreeWidgetItem *item) { QUuid componentId = QUuid(item->data(0, Qt::UserRole).toString()); emit setComponentExpandState(componentId, false); } -void SkeletonPartTreeWidget::partPreviewChanged(QUuid partId) +void PartTreeWidget::partPreviewChanged(QUuid partId) { auto item = m_partItemMap.find(partId); if (item == m_partItemMap.end()) { qDebug() << "Part item not found:" << partId; return; } - SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); + PartWidget *widget = (PartWidget *)itemWidget(item->second, 0); widget->updatePreview(); } -void SkeletonPartTreeWidget::partLockStateChanged(QUuid partId) +void PartTreeWidget::partLockStateChanged(QUuid partId) { auto item = m_partItemMap.find(partId); if (item == m_partItemMap.end()) { qDebug() << "Part item not found:" << partId; return; } - SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); + PartWidget *widget = (PartWidget *)itemWidget(item->second, 0); widget->updateLockButton(); } -void SkeletonPartTreeWidget::partVisibleStateChanged(QUuid partId) +void PartTreeWidget::partVisibleStateChanged(QUuid partId) { auto item = m_partItemMap.find(partId); if (item == m_partItemMap.end()) { qDebug() << "Part item not found:" << partId; return; } - SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); + PartWidget *widget = (PartWidget *)itemWidget(item->second, 0); widget->updateVisibleButton(); } -void SkeletonPartTreeWidget::partSubdivStateChanged(QUuid partId) +void PartTreeWidget::partSubdivStateChanged(QUuid partId) { auto item = m_partItemMap.find(partId); if (item == m_partItemMap.end()) { qDebug() << "Part item not found:" << partId; return; } - SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); + PartWidget *widget = (PartWidget *)itemWidget(item->second, 0); widget->updateSubdivButton(); } -void SkeletonPartTreeWidget::partDisableStateChanged(QUuid partId) +void PartTreeWidget::partDisableStateChanged(QUuid partId) { auto item = m_partItemMap.find(partId); if (item == m_partItemMap.end()) { qDebug() << "Part item not found:" << partId; return; } - SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); + PartWidget *widget = (PartWidget *)itemWidget(item->second, 0); widget->updateDisableButton(); } -void SkeletonPartTreeWidget::partXmirrorStateChanged(QUuid partId) +void PartTreeWidget::partXmirrorStateChanged(QUuid partId) { auto item = m_partItemMap.find(partId); if (item == m_partItemMap.end()) { qDebug() << "Part item not found:" << partId; return; } - SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); + PartWidget *widget = (PartWidget *)itemWidget(item->second, 0); widget->updateXmirrorButton(); } -void SkeletonPartTreeWidget::partDeformChanged(QUuid partId) +void PartTreeWidget::partDeformChanged(QUuid partId) { auto item = m_partItemMap.find(partId); if (item == m_partItemMap.end()) { qDebug() << "Part item not found:" << partId; return; } - SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); + PartWidget *widget = (PartWidget *)itemWidget(item->second, 0); widget->updateDeformButton(); } -void SkeletonPartTreeWidget::partRoundStateChanged(QUuid partId) +void PartTreeWidget::partRoundStateChanged(QUuid partId) { auto item = m_partItemMap.find(partId); if (item == m_partItemMap.end()) { qDebug() << "Part item not found:" << partId; return; } - SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); + PartWidget *widget = (PartWidget *)itemWidget(item->second, 0); widget->updateRoundButton(); } -void SkeletonPartTreeWidget::partWrapStateChanged(QUuid partId) +void PartTreeWidget::partWrapStateChanged(QUuid partId) { auto item = m_partItemMap.find(partId); if (item == m_partItemMap.end()) { qDebug() << "Part item not found:" << partId; return; } - SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); + PartWidget *widget = (PartWidget *)itemWidget(item->second, 0); widget->updateWrapButton(); } -void SkeletonPartTreeWidget::partColorStateChanged(QUuid partId) +void PartTreeWidget::partColorStateChanged(QUuid partId) { auto item = m_partItemMap.find(partId); if (item == m_partItemMap.end()) { qDebug() << "Part item not found:" << partId; return; } - SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); + PartWidget *widget = (PartWidget *)itemWidget(item->second, 0); widget->updateColorButton(); } -void SkeletonPartTreeWidget::partMaterialIdChanged(QUuid partId) +void PartTreeWidget::partMaterialIdChanged(QUuid partId) { auto item = m_partItemMap.find(partId); if (item == m_partItemMap.end()) { qDebug() << "Part item not found:" << partId; return; } - SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second, 0); + PartWidget *widget = (PartWidget *)itemWidget(item->second, 0); widget->updateColorButton(); } -void SkeletonPartTreeWidget::partChecked(QUuid partId) +void PartTreeWidget::partChecked(QUuid partId) { auto item = m_partItemMap.find(partId); if (item == m_partItemMap.end()) { @@ -916,7 +916,7 @@ void SkeletonPartTreeWidget::partChecked(QUuid partId) item->second->setBackground(0, m_hightlightedPartBackground); } -void SkeletonPartTreeWidget::partUnchecked(QUuid partId) +void PartTreeWidget::partUnchecked(QUuid partId) { auto item = m_partItemMap.find(partId); if (item == m_partItemMap.end()) { @@ -926,13 +926,13 @@ void SkeletonPartTreeWidget::partUnchecked(QUuid partId) item->second->setBackground(0, QBrush(Qt::transparent)); } -QSize SkeletonPartTreeWidget::sizeHint() const +QSize PartTreeWidget::sizeHint() const { - QSize size = SkeletonPartWidget::preferredSize(); + QSize size = PartWidget::preferredSize(); return QSize(size.width() * 1.35, size.height() * 5.5); } -bool SkeletonPartTreeWidget::isComponentSelected(QUuid componentId) +bool PartTreeWidget::isComponentSelected(QUuid componentId) { return (m_currentSelectedComponentId == componentId || m_selectedComponentIds.find(componentId) != m_selectedComponentIds.end()); diff --git a/src/skeletonparttreewidget.h b/src/parttreewidget.h similarity index 92% rename from src/skeletonparttreewidget.h rename to src/parttreewidget.h index 56b40179..54fef091 100644 --- a/src/skeletonparttreewidget.h +++ b/src/parttreewidget.h @@ -1,11 +1,11 @@ -#ifndef SKELETON_PART_TREE_WIDGET_H -#define SKELETON_PART_TREE_WIDGET_H +#ifndef DUST3D_PART_TREE_WIDGET_H +#define DUST3D_PART_TREE_WIDGET_H #include #include #include -#include "skeletondocument.h" +#include "document.h" -class SkeletonPartTreeWidget : public QTreeWidget +class PartTreeWidget : public QTreeWidget { Q_OBJECT signals: @@ -41,7 +41,7 @@ signals: void addPartToSelection(QUuid partId); void groupOperationAdded(); public: - SkeletonPartTreeWidget(const SkeletonDocument *document, QWidget *parent); + PartTreeWidget(const Document *document, QWidget *parent); QTreeWidgetItem *findComponentItem(QUuid componentId); public slots: void componentNameChanged(QUuid componentId); @@ -79,7 +79,7 @@ private: void updateComponentSelectState(QUuid componentId, bool selected); bool isComponentSelected(QUuid componentId); private: - const SkeletonDocument *m_document = nullptr; + const Document *m_document = nullptr; std::map m_partItemMap; std::map m_componentItemMap; QFont m_normalFont; diff --git a/src/skeletonpartwidget.cpp b/src/partwidget.cpp similarity index 77% rename from src/skeletonpartwidget.cpp rename to src/partwidget.cpp index 9c8a1322..c8f7676b 100644 --- a/src/skeletonpartwidget.cpp +++ b/src/partwidget.cpp @@ -6,13 +6,13 @@ #include #include #include -#include "skeletonpartwidget.h" +#include "partwidget.h" #include "theme.h" #include "floatnumberwidget.h" #include "materiallistwidget.h" #include "infolabel.h" -SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid partId) : +PartWidget::PartWidget(const Document *document, QUuid partId) : m_document(document), m_partId(partId) { @@ -124,25 +124,25 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p setLayout(mainLayout); - connect(this, &SkeletonPartWidget::setPartLockState, m_document, &SkeletonDocument::setPartLockState); - connect(this, &SkeletonPartWidget::setPartVisibleState, m_document, &SkeletonDocument::setPartVisibleState); - connect(this, &SkeletonPartWidget::setPartSubdivState, m_document, &SkeletonDocument::setPartSubdivState); - connect(this, &SkeletonPartWidget::setPartDisableState, m_document, &SkeletonDocument::setPartDisableState); - connect(this, &SkeletonPartWidget::setPartXmirrorState, m_document, &SkeletonDocument::setPartXmirrorState); - connect(this, &SkeletonPartWidget::setPartDeformThickness, m_document, &SkeletonDocument::setPartDeformThickness); - connect(this, &SkeletonPartWidget::setPartDeformWidth, m_document, &SkeletonDocument::setPartDeformWidth); - connect(this, &SkeletonPartWidget::setPartRoundState, m_document, &SkeletonDocument::setPartRoundState); - connect(this, &SkeletonPartWidget::setPartWrapState, m_document, &SkeletonDocument::setPartWrapState); - connect(this, &SkeletonPartWidget::setPartColorState, m_document, &SkeletonDocument::setPartColorState); - connect(this, &SkeletonPartWidget::setPartMaterialId, m_document, &SkeletonDocument::setPartMaterialId); - connect(this, &SkeletonPartWidget::checkPart, m_document, &SkeletonDocument::checkPart); - connect(this, &SkeletonPartWidget::enableBackgroundBlur, m_document, &SkeletonDocument::enableBackgroundBlur); - connect(this, &SkeletonPartWidget::disableBackgroundBlur, m_document, &SkeletonDocument::disableBackgroundBlur); + connect(this, &PartWidget::setPartLockState, m_document, &Document::setPartLockState); + connect(this, &PartWidget::setPartVisibleState, m_document, &Document::setPartVisibleState); + connect(this, &PartWidget::setPartSubdivState, m_document, &Document::setPartSubdivState); + connect(this, &PartWidget::setPartDisableState, m_document, &Document::setPartDisableState); + connect(this, &PartWidget::setPartXmirrorState, m_document, &Document::setPartXmirrorState); + connect(this, &PartWidget::setPartDeformThickness, m_document, &Document::setPartDeformThickness); + connect(this, &PartWidget::setPartDeformWidth, m_document, &Document::setPartDeformWidth); + connect(this, &PartWidget::setPartRoundState, m_document, &Document::setPartRoundState); + connect(this, &PartWidget::setPartWrapState, m_document, &Document::setPartWrapState); + connect(this, &PartWidget::setPartColorState, m_document, &Document::setPartColorState); + connect(this, &PartWidget::setPartMaterialId, m_document, &Document::setPartMaterialId); + connect(this, &PartWidget::checkPart, m_document, &Document::checkPart); + connect(this, &PartWidget::enableBackgroundBlur, m_document, &Document::enableBackgroundBlur); + connect(this, &PartWidget::disableBackgroundBlur, m_document, &Document::disableBackgroundBlur); - connect(this, &SkeletonPartWidget::groupOperationAdded, m_document, &SkeletonDocument::saveSnapshot); + connect(this, &PartWidget::groupOperationAdded, m_document, &Document::saveSnapshot); connect(m_lockButton, &QPushButton::clicked, [=]() { - const SkeletonPart *part = m_document->findPart(m_partId); + const Part *part = m_document->findPart(m_partId); if (!part) { qDebug() << "Part not found:" << m_partId; return; @@ -152,7 +152,7 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p }); connect(m_visibleButton, &QPushButton::clicked, [=]() { - const SkeletonPart *part = m_document->findPart(m_partId); + const Part *part = m_document->findPart(m_partId); if (!part) { qDebug() << "Part not found:" << m_partId; return; @@ -162,7 +162,7 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p }); connect(m_subdivButton, &QPushButton::clicked, [=]() { - const SkeletonPart *part = m_document->findPart(m_partId); + const Part *part = m_document->findPart(m_partId); if (!part) { qDebug() << "Part not found:" << m_partId; return; @@ -172,7 +172,7 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p }); connect(m_disableButton, &QPushButton::clicked, [=]() { - const SkeletonPart *part = m_document->findPart(m_partId); + const Part *part = m_document->findPart(m_partId); if (!part) { qDebug() << "Part not found:" << m_partId; return; @@ -182,7 +182,7 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p }); connect(m_xMirrorButton, &QPushButton::clicked, [=]() { - const SkeletonPart *part = m_document->findPart(m_partId); + const Part *part = m_document->findPart(m_partId); if (!part) { qDebug() << "Part not found:" << m_partId; return; @@ -192,7 +192,7 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p }); connect(m_deformButton, &QPushButton::clicked, [=]() { - const SkeletonPart *part = m_document->findPart(m_partId); + const Part *part = m_document->findPart(m_partId); if (!part) { qDebug() << "Part not found:" << m_partId; return; @@ -201,7 +201,7 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p }); connect(m_roundButton, &QPushButton::clicked, [=]() { - const SkeletonPart *part = m_document->findPart(m_partId); + const Part *part = m_document->findPart(m_partId); if (!part) { qDebug() << "Part not found:" << m_partId; return; @@ -211,7 +211,7 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p }); connect(m_colorButton, &QPushButton::clicked, [=]() { - const SkeletonPart *part = m_document->findPart(m_partId); + const Part *part = m_document->findPart(m_partId); if (!part) { qDebug() << "Part not found:" << m_partId; return; @@ -220,7 +220,7 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p }); connect(m_wrapButton, &QPushButton::clicked, [=]() { - const SkeletonPart *part = m_document->findPart(m_partId); + const Part *part = m_document->findPart(m_partId); if (!part) { qDebug() << "Part not found:" << m_partId; return; @@ -235,17 +235,17 @@ SkeletonPartWidget::SkeletonPartWidget(const SkeletonDocument *document, QUuid p updateAllButtons(); } -ModelWidget *SkeletonPartWidget::previewWidget() +ModelWidget *PartWidget::previewWidget() { return m_previewWidget; } -QSize SkeletonPartWidget::preferredSize() +QSize PartWidget::preferredSize() { return QSize(Theme::miniIconSize + Theme::partPreviewImageSize + Theme::miniIconSize * 4 + 5 + 2, Theme::partPreviewImageSize + 6); } -void SkeletonPartWidget::updateAllButtons() +void PartWidget::updateAllButtons() { updateVisibleButton(); updateLockButton(); @@ -258,7 +258,7 @@ void SkeletonPartWidget::updateAllButtons() updateWrapButton(); } -void SkeletonPartWidget::updateCheckedState(bool checked) +void PartWidget::updateCheckedState(bool checked) { if (checked) m_backgroundWidget->setStyleSheet("QWidget#background {border: 1px solid " + Theme::red.name() + ";}"); @@ -266,27 +266,27 @@ void SkeletonPartWidget::updateCheckedState(bool checked) m_backgroundWidget->setStyleSheet("QWidget#background {border: 1px solid transparent;}"); } -void SkeletonPartWidget::mouseDoubleClickEvent(QMouseEvent *event) +void PartWidget::mouseDoubleClickEvent(QMouseEvent *event) { QWidget::mouseDoubleClickEvent(event); emit checkPart(m_partId); } -void SkeletonPartWidget::initToolButtonWithoutFont(QPushButton *button) +void PartWidget::initToolButtonWithoutFont(QPushButton *button) { Theme::initAwesomeToolButtonWithoutFont(button); } -void SkeletonPartWidget::initToolButton(QPushButton *button) +void PartWidget::initToolButton(QPushButton *button) { Theme::initAwesomeToolButton(button); } -void SkeletonPartWidget::showColorSettingPopup(const QPoint &pos) +void PartWidget::showColorSettingPopup(const QPoint &pos) { QMenu popupMenu; - const SkeletonPart *part = m_document->findPart(m_partId); + const Part *part = m_document->findPart(m_partId); if (!part) { qDebug() << "Find part failed:" << m_partId; return; @@ -353,11 +353,11 @@ void SkeletonPartWidget::showColorSettingPopup(const QPoint &pos) popupMenu.exec(mapToGlobal(pos)); } -void SkeletonPartWidget::showDeformSettingPopup(const QPoint &pos) +void PartWidget::showDeformSettingPopup(const QPoint &pos) { QMenu popupMenu; - const SkeletonPart *part = m_document->findPart(m_partId); + const Part *part = m_document->findPart(m_partId); if (!part) { qDebug() << "Find part failed:" << m_partId; return; @@ -421,19 +421,19 @@ void SkeletonPartWidget::showDeformSettingPopup(const QPoint &pos) popupMenu.exec(mapToGlobal(pos)); } -void SkeletonPartWidget::initButton(QPushButton *button) +void PartWidget::initButton(QPushButton *button) { Theme::initAwesomeMiniButton(button); } -void SkeletonPartWidget::updateButton(QPushButton *button, QChar icon, bool highlighted) +void PartWidget::updateButton(QPushButton *button, QChar icon, bool highlighted) { Theme::updateAwesomeMiniButton(button, icon, highlighted); } -void SkeletonPartWidget::updatePreview() +void PartWidget::updatePreview() { - const SkeletonPart *part = m_document->findPart(m_partId); + const Part *part = m_document->findPart(m_partId); if (!part) { qDebug() << "Part not found:" << m_partId; return; @@ -443,9 +443,9 @@ void SkeletonPartWidget::updatePreview() m_previewWidget->updateMesh(previewMesh); } -void SkeletonPartWidget::updateLockButton() +void PartWidget::updateLockButton() { - const SkeletonPart *part = m_document->findPart(m_partId); + const Part *part = m_document->findPart(m_partId); if (!part) { qDebug() << "Part not found:" << m_partId; return; @@ -456,9 +456,9 @@ void SkeletonPartWidget::updateLockButton() updateButton(m_lockButton, QChar(fa::unlock), false); } -void SkeletonPartWidget::updateVisibleButton() +void PartWidget::updateVisibleButton() { - const SkeletonPart *part = m_document->findPart(m_partId); + const Part *part = m_document->findPart(m_partId); if (!part) { qDebug() << "Part not found:" << m_partId; return; @@ -469,9 +469,9 @@ void SkeletonPartWidget::updateVisibleButton() updateButton(m_visibleButton, QChar(fa::eyeslash), true); } -void SkeletonPartWidget::updateSubdivButton() +void PartWidget::updateSubdivButton() { - const SkeletonPart *part = m_document->findPart(m_partId); + const Part *part = m_document->findPart(m_partId); if (!part) { qDebug() << "Part not found:" << m_partId; return; @@ -482,9 +482,9 @@ void SkeletonPartWidget::updateSubdivButton() updateButton(m_subdivButton, QChar(fa::squareo), false); } -void SkeletonPartWidget::updateDisableButton() +void PartWidget::updateDisableButton() { - const SkeletonPart *part = m_document->findPart(m_partId); + const Part *part = m_document->findPart(m_partId); if (!part) { qDebug() << "Part not found:" << m_partId; return; @@ -495,9 +495,9 @@ void SkeletonPartWidget::updateDisableButton() updateButton(m_disableButton, QChar(fa::link), false); } -void SkeletonPartWidget::updateXmirrorButton() +void PartWidget::updateXmirrorButton() { - const SkeletonPart *part = m_document->findPart(m_partId); + const Part *part = m_document->findPart(m_partId); if (!part) { qDebug() << "Part not found:" << m_partId; return; @@ -508,9 +508,9 @@ void SkeletonPartWidget::updateXmirrorButton() updateButton(m_xMirrorButton, QChar(fa::balancescale), false); } -void SkeletonPartWidget::updateDeformButton() +void PartWidget::updateDeformButton() { - const SkeletonPart *part = m_document->findPart(m_partId); + const Part *part = m_document->findPart(m_partId); if (!part) { qDebug() << "Part not found:" << m_partId; return; @@ -521,9 +521,9 @@ void SkeletonPartWidget::updateDeformButton() updateButton(m_deformButton, QChar(fa::handlizardo), false); } -void SkeletonPartWidget::updateRoundButton() +void PartWidget::updateRoundButton() { - const SkeletonPart *part = m_document->findPart(m_partId); + const Part *part = m_document->findPart(m_partId); if (!part) { qDebug() << "Part not found:" << m_partId; return; @@ -534,9 +534,9 @@ void SkeletonPartWidget::updateRoundButton() updateButton(m_roundButton, QChar(fa::magnet), false); } -void SkeletonPartWidget::updateColorButton() +void PartWidget::updateColorButton() { - const SkeletonPart *part = m_document->findPart(m_partId); + const Part *part = m_document->findPart(m_partId); if (!part) { qDebug() << "Part not found:" << m_partId; return; @@ -547,9 +547,9 @@ void SkeletonPartWidget::updateColorButton() updateButton(m_colorButton, QChar(fa::eyedropper), false); } -void SkeletonPartWidget::updateWrapButton() +void PartWidget::updateWrapButton() { - const SkeletonPart *part = m_document->findPart(m_partId); + const Part *part = m_document->findPart(m_partId); if (!part) { qDebug() << "Part not found:" << m_partId; return; @@ -560,7 +560,7 @@ void SkeletonPartWidget::updateWrapButton() updateButton(m_wrapButton, QChar(fa::cube), false); } -void SkeletonPartWidget::reload() +void PartWidget::reload() { updatePreview(); updateAllButtons(); diff --git a/src/skeletonpartwidget.h b/src/partwidget.h similarity index 91% rename from src/skeletonpartwidget.h rename to src/partwidget.h index d5d2c63e..3641aa1c 100644 --- a/src/skeletonpartwidget.h +++ b/src/partwidget.h @@ -1,12 +1,12 @@ -#ifndef SKELETON_PART_WIDGET_H -#define SKELETON_PART_WIDGET_H +#ifndef DUST3D_PART_WIDGET_H +#define DUST3D_PART_WIDGET_H #include #include #include -#include "skeletondocument.h" +#include "document.h" #include "modelwidget.h" -class SkeletonPartWidget : public QWidget +class PartWidget : public QWidget { Q_OBJECT signals: @@ -31,7 +31,7 @@ signals: void enableBackgroundBlur(); void disableBackgroundBlur(); public: - SkeletonPartWidget(const SkeletonDocument *document, QUuid partId); + PartWidget(const Document *document, QUuid partId); void reload(); void updatePreview(); void updateLockButton(); @@ -53,7 +53,7 @@ public slots: void showDeformSettingPopup(const QPoint &pos); void showColorSettingPopup(const QPoint &pos); private: // need initialize - const SkeletonDocument *m_document; + const Document *m_document; QUuid m_partId; private: ModelWidget *m_previewWidget; diff --git a/src/poseeditwidget.cpp b/src/poseeditwidget.cpp index 5dee19ff..03477af6 100644 --- a/src/poseeditwidget.cpp +++ b/src/poseeditwidget.cpp @@ -11,7 +11,7 @@ #include "floatnumberwidget.h" #include "version.h" -PoseEditWidget::PoseEditWidget(const SkeletonDocument *document, QWidget *parent) : +PoseEditWidget::PoseEditWidget(const Document *document, QWidget *parent) : QDialog(parent), m_document(document) { @@ -125,15 +125,15 @@ PoseEditWidget::PoseEditWidget(const SkeletonDocument *document, QWidget *parent setLayout(mainLayout); - connect(m_document, &SkeletonDocument::resultRigChanged, this, &PoseEditWidget::updatePreview); + connect(m_document, &Document::resultRigChanged, this, &PoseEditWidget::updatePreview); connect(this, &PoseEditWidget::parametersAdjusted, this, &PoseEditWidget::updatePreview); connect(this, &PoseEditWidget::parametersAdjusted, [=]() { m_unsaved = true; updateTitle(); }); - connect(this, &PoseEditWidget::addPose, m_document, &SkeletonDocument::addPose); - connect(this, &PoseEditWidget::renamePose, m_document, &SkeletonDocument::renamePose); - connect(this, &PoseEditWidget::setPoseParameters, m_document, &SkeletonDocument::setPoseParameters); + connect(this, &PoseEditWidget::addPose, m_document, &Document::addPose); + connect(this, &PoseEditWidget::renamePose, m_document, &Document::renamePose); + connect(this, &PoseEditWidget::setPoseParameters, m_document, &Document::setPoseParameters); updatePreview(); updateTitle(); @@ -220,7 +220,7 @@ void PoseEditWidget::updateTitle() setWindowTitle(unifiedWindowTitle(tr("New") + (m_unsaved ? "*" : ""))); return; } - const SkeletonPose *pose = m_document->findPose(m_poseId); + const Pose *pose = m_document->findPose(m_poseId); if (nullptr == pose) { qDebug() << "Find pose failed:" << m_poseId; return; diff --git a/src/poseeditwidget.h b/src/poseeditwidget.h index 2b5f419d..069d3556 100644 --- a/src/poseeditwidget.h +++ b/src/poseeditwidget.h @@ -1,12 +1,12 @@ -#ifndef POSE_EDIT_WIDGET_H -#define POSE_EDIT_WIDGET_H +#ifndef DUST3D_POSE_EDIT_WIDGET_H +#define DUST3D_POSE_EDIT_WIDGET_H #include #include #include #include #include "posepreviewmanager.h" #include "tetrapodposer.h" -#include "skeletondocument.h" +#include "document.h" #include "modelwidget.h" enum class PopupWidgetType @@ -25,7 +25,7 @@ signals: void renamePose(QUuid poseId, QString name); void parametersAdjusted(); public: - PoseEditWidget(const SkeletonDocument *document, QWidget *parent=nullptr); + PoseEditWidget(const Document *document, QWidget *parent=nullptr); ~PoseEditWidget(); public slots: void updatePreview(); @@ -41,7 +41,7 @@ protected: void closeEvent(QCloseEvent *event) override; void reject() override; private: - const SkeletonDocument *m_document = nullptr; + const Document *m_document = nullptr; PosePreviewManager *m_posePreviewManager = nullptr; ModelWidget *m_previewWidget = nullptr; bool m_isPreviewDirty = false; diff --git a/src/poselistwidget.cpp b/src/poselistwidget.cpp index 32d65697..ee875954 100644 --- a/src/poselistwidget.cpp +++ b/src/poselistwidget.cpp @@ -3,10 +3,10 @@ #include #include #include -#include "skeletonxml.h" +#include "snapshotxml.h" #include "poselistwidget.h" -PoseListWidget::PoseListWidget(const SkeletonDocument *document, QWidget *parent) : +PoseListWidget::PoseListWidget(const Document *document, QWidget *parent) : QTreeWidget(parent), m_document(document) { @@ -27,10 +27,10 @@ PoseListWidget::PoseListWidget(const SkeletonDocument *document, QWidget *parent setContentsMargins(0, 0, 0, 0); - connect(document, &SkeletonDocument::poseListChanged, this, &PoseListWidget::reload); - connect(document, &SkeletonDocument::cleanup, this, &PoseListWidget::removeAllContent); + connect(document, &Document::poseListChanged, this, &PoseListWidget::reload); + connect(document, &Document::cleanup, this, &PoseListWidget::removeAllContent); - connect(this, &PoseListWidget::removePose, document, &SkeletonDocument::removePose); + connect(this, &PoseListWidget::removePose, document, &Document::removePose); setContextMenuPolicy(Qt::CustomContextMenu); connect(this, &QTreeWidget::customContextMenuRequested, this, &PoseListWidget::showContextMenu); @@ -190,7 +190,7 @@ void PoseListWidget::showContextMenu(const QPoint &pos) QAction pasteAction(tr("Paste"), this); if (m_document->hasPastablePosesInClipboard()) { - connect(&pasteAction, &QAction::triggered, m_document, &SkeletonDocument::paste); + connect(&pasteAction, &QAction::triggered, m_document, &Document::paste); contextMenu.addAction(&pasteAction); } @@ -287,8 +287,8 @@ void PoseListWidget::copy() std::set emptySet; - SkeletonSnapshot snapshot; - m_document->toSnapshot(&snapshot, emptySet, SkeletonDocumentToSnapshotFor::Poses, + Snapshot snapshot; + m_document->toSnapshot(&snapshot, emptySet, DocumentToSnapshotFor::Poses, limitPoseIds); QString snapshotXml; QXmlStreamWriter xmlStreamWriter(&snapshotXml); diff --git a/src/poselistwidget.h b/src/poselistwidget.h index 1e5750d3..d32d2504 100644 --- a/src/poselistwidget.h +++ b/src/poselistwidget.h @@ -1,9 +1,9 @@ -#ifndef POSE_LIST_WIDGET_H -#define POSE_LIST_WIDGET_H +#ifndef DUST3D_POSE_LIST_WIDGET_H +#define DUST3D_POSE_LIST_WIDGET_H #include #include #include -#include "skeletondocument.h" +#include "document.h" #include "posewidget.h" class PoseListWidget : public QTreeWidget @@ -14,7 +14,7 @@ signals: void modifyPose(QUuid poseId); void cornerButtonClicked(QUuid poseId); public: - PoseListWidget(const SkeletonDocument *document, QWidget *parent=nullptr); + PoseListWidget(const Document *document, QWidget *parent=nullptr); bool isPoseSelected(QUuid poseId); public slots: void reload(); @@ -31,7 +31,7 @@ protected: private: int calculateColumnCount(); void updatePoseSelectState(QUuid poseId, bool selected); - const SkeletonDocument *m_document = nullptr; + const Document *m_document = nullptr; std::map> m_itemMap; std::set m_selectedPoseIds; QUuid m_currentSelectedPoseId; diff --git a/src/posemanagewidget.cpp b/src/posemanagewidget.cpp index 70f9c801..e03f0627 100644 --- a/src/posemanagewidget.cpp +++ b/src/posemanagewidget.cpp @@ -6,7 +6,7 @@ #include "poseeditwidget.h" #include "infolabel.h" -PoseManageWidget::PoseManageWidget(const SkeletonDocument *document, QWidget *parent) : +PoseManageWidget::PoseManageWidget(const Document *document, QWidget *parent) : QWidget(parent), m_document(document) { @@ -35,8 +35,8 @@ PoseManageWidget::PoseManageWidget(const SkeletonDocument *document, QWidget *pa } }; - connect(m_document, &SkeletonDocument::resultRigChanged, this, refreshInfoLabel); - connect(m_document, &SkeletonDocument::cleanup, this, refreshInfoLabel); + connect(m_document, &Document::resultRigChanged, this, refreshInfoLabel); + connect(m_document, &Document::cleanup, this, refreshInfoLabel); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(infoLabel); @@ -66,7 +66,7 @@ void PoseManageWidget::showPoseDialog(QUuid poseId) PoseEditWidget *poseEditWidget = new PoseEditWidget(m_document); poseEditWidget->setAttribute(Qt::WA_DeleteOnClose); if (!poseId.isNull()) { - const SkeletonPose *pose = m_document->findPose(poseId); + const Pose *pose = m_document->findPose(poseId); if (nullptr != pose) { poseEditWidget->setEditPoseId(poseId); poseEditWidget->setEditPoseName(pose->name); diff --git a/src/posemanagewidget.h b/src/posemanagewidget.h index 2e27cffb..43246800 100644 --- a/src/posemanagewidget.h +++ b/src/posemanagewidget.h @@ -1,7 +1,7 @@ -#ifndef POSE_MANAGE_WIDGET_H -#define POSE_MANAGE_WIDGET_H +#ifndef DUST3D_POSE_MANAGE_WIDGET_H +#define DUST3D_POSE_MANAGE_WIDGET_H #include -#include "skeletondocument.h" +#include "document.h" #include "poselistwidget.h" class PoseManageWidget : public QWidget @@ -11,7 +11,7 @@ signals: void registerDialog(QWidget *widget); void unregisterDialog(QWidget *widget); public: - PoseManageWidget(const SkeletonDocument *document, QWidget *parent=nullptr); + PoseManageWidget(const Document *document, QWidget *parent=nullptr); PoseListWidget *poseListWidget(); protected: virtual QSize sizeHint() const; @@ -19,7 +19,7 @@ public slots: void showAddPoseDialog(); void showPoseDialog(QUuid poseId); private: - const SkeletonDocument *m_document = nullptr; + const Document *m_document = nullptr; PoseListWidget *m_poseListWidget = nullptr; }; diff --git a/src/posemeshcreator.cpp b/src/posemeshcreator.cpp index a22d99e0..91613514 100644 --- a/src/posemeshcreator.cpp +++ b/src/posemeshcreator.cpp @@ -3,10 +3,10 @@ #include "skinnedmeshcreator.h" PoseMeshCreator::PoseMeshCreator(const std::vector &resultNodes, - const MeshResultContext &meshResultContext, + const Outcome &outcome, const std::map &resultWeights) : m_resultNodes(resultNodes), - m_meshResultContext(meshResultContext), + m_outcome(outcome), m_resultWeights(resultWeights) { } @@ -25,7 +25,7 @@ MeshLoader *PoseMeshCreator::takeResultMesh() void PoseMeshCreator::createMesh() { - SkinnedMeshCreator skinnedMeshCreator(m_meshResultContext, m_resultWeights); + SkinnedMeshCreator skinnedMeshCreator(m_outcome, m_resultWeights); std::vector matricies; matricies.resize(m_resultNodes.size()); diff --git a/src/posemeshcreator.h b/src/posemeshcreator.h index e34f1799..0c36f3f2 100644 --- a/src/posemeshcreator.h +++ b/src/posemeshcreator.h @@ -1,9 +1,9 @@ -#ifndef POSE_MESH_CREATOR_H -#define POSE_MESH_CREATOR_H +#ifndef DUST3D_POSE_MESH_CREATOR_H +#define DUST3D_POSE_MESH_CREATOR_H #include #include "meshloader.h" #include "jointnodetree.h" -#include "meshresultcontext.h" +#include "outcome.h" class PoseMeshCreator : public QObject { @@ -12,7 +12,7 @@ signals: void finished(); public: PoseMeshCreator(const std::vector &resultNodes, - const MeshResultContext &meshResultContext, + const Outcome &outcome, const std::map &resultWeights); ~PoseMeshCreator(); void createMesh(); @@ -21,7 +21,7 @@ public slots: void process(); private: std::vector m_resultNodes; - MeshResultContext m_meshResultContext; + Outcome m_outcome; std::map m_resultWeights; MeshLoader *m_resultMesh = nullptr; }; diff --git a/src/posepreviewmanager.cpp b/src/posepreviewmanager.cpp index 15b5eade..c7a7bdc0 100644 --- a/src/posepreviewmanager.cpp +++ b/src/posepreviewmanager.cpp @@ -17,7 +17,7 @@ bool PosePreviewManager::isRendering() } bool PosePreviewManager::postUpdate(const Poser &poser, - const MeshResultContext &meshResultContext, + const Outcome &outcome, const std::map &resultWeights) { if (nullptr != m_poseMeshCreator) @@ -26,7 +26,7 @@ bool PosePreviewManager::postUpdate(const Poser &poser, qDebug() << "Pose mesh generating.."; QThread *thread = new QThread; - m_poseMeshCreator = new PoseMeshCreator(poser.resultNodes(), meshResultContext, resultWeights); + m_poseMeshCreator = new PoseMeshCreator(poser.resultNodes(), outcome, resultWeights); m_poseMeshCreator->moveToThread(thread); connect(thread, &QThread::started, m_poseMeshCreator, &PoseMeshCreator::process); connect(m_poseMeshCreator, &PoseMeshCreator::finished, this, &PosePreviewManager::poseMeshReady); diff --git a/src/posepreviewmanager.h b/src/posepreviewmanager.h index 46a96abf..acbaa7c5 100644 --- a/src/posepreviewmanager.h +++ b/src/posepreviewmanager.h @@ -1,7 +1,7 @@ -#ifndef POSE_PREVIEW_MANAGER_H -#define POSE_PREVIEW_MANAGER_H +#ifndef DUST3D_POSE_PREVIEW_MANAGER_H +#define DUST3D_POSE_PREVIEW_MANAGER_H #include -#include "skeletondocument.h" +#include "document.h" #include "poser.h" #include "posemeshcreator.h" #include "meshloader.h" @@ -14,7 +14,7 @@ public: ~PosePreviewManager(); bool isRendering(); bool postUpdate(const Poser &poser, - const MeshResultContext &meshResultContext, + const Outcome &outcome, const std::map &resultWeights); MeshLoader *takeResultPreviewMesh(); private slots: diff --git a/src/posepreviewsgenerator.cpp b/src/posepreviewsgenerator.cpp index bb9fa2ca..43f4c2e8 100644 --- a/src/posepreviewsgenerator.cpp +++ b/src/posepreviewsgenerator.cpp @@ -6,10 +6,10 @@ PosePreviewsGenerator::PosePreviewsGenerator(const std::vector *rigBones, const std::map *rigWeights, - const MeshResultContext &meshResultContext) : + const Outcome &outcome) : m_rigBones(*rigBones), m_rigWeights(*rigWeights), - m_meshResultContext(new MeshResultContext(meshResultContext)) + m_outcome(new Outcome(outcome)) { } @@ -18,7 +18,7 @@ PosePreviewsGenerator::~PosePreviewsGenerator() for (auto &item: m_previews) { delete item.second; } - delete m_meshResultContext; + delete m_outcome; } void PosePreviewsGenerator::addPose(QUuid poseId, const std::map> &pose) @@ -48,7 +48,7 @@ void PosePreviewsGenerator::process() poser->parameters() = pose.second; poser->commit(); - PoseMeshCreator *poseMeshCreator = new PoseMeshCreator(poser->resultNodes(), *m_meshResultContext, m_rigWeights); + PoseMeshCreator *poseMeshCreator = new PoseMeshCreator(poser->resultNodes(), *m_outcome, m_rigWeights); poseMeshCreator->createMesh(); m_previews[pose.first] = poseMeshCreator->takeResultMesh(); delete poseMeshCreator; diff --git a/src/posepreviewsgenerator.h b/src/posepreviewsgenerator.h index 9acc2796..386cdab1 100644 --- a/src/posepreviewsgenerator.h +++ b/src/posepreviewsgenerator.h @@ -1,12 +1,12 @@ -#ifndef POSE_PREVIEWS_GENERATOR_H -#define POSE_PREVIEWS_GENERATOR_H +#ifndef DUST3D_POSE_PREVIEWS_GENERATOR_H +#define DUST3D_POSE_PREVIEWS_GENERATOR_H #include #include #include #include #include "meshloader.h" #include "autorigger.h" -#include "meshresultcontext.h" +#include "outcome.h" class PosePreviewsGenerator : public QObject { @@ -14,7 +14,7 @@ class PosePreviewsGenerator : public QObject public: PosePreviewsGenerator(const std::vector *rigBones, const std::map *rigWeights, - const MeshResultContext &meshResultContext); + const Outcome &outcome); ~PosePreviewsGenerator(); void addPose(QUuid poseId, const std::map> &pose); const std::set &generatedPreviewPoseIds(); @@ -26,7 +26,7 @@ public slots: private: std::vector m_rigBones; std::map m_rigWeights; - MeshResultContext *m_meshResultContext = nullptr; + Outcome *m_outcome = nullptr; std::vector>>> m_poses; std::map m_previews; std::set m_generatedPoseIds; diff --git a/src/poser.h b/src/poser.h index 4e879847..54454f42 100644 --- a/src/poser.h +++ b/src/poser.h @@ -1,9 +1,9 @@ -#ifndef POSER_H -#define POSER_H +#ifndef DUST3D_POSER_H +#define DUST3D_POSER_H #include #include "autorigger.h" #include "jointnodetree.h" -#include "dust3dutil.h" +#include "util.h" class Poser : public QObject { diff --git a/src/posewidget.cpp b/src/posewidget.cpp index b81cb585..525a59ad 100644 --- a/src/posewidget.cpp +++ b/src/posewidget.cpp @@ -1,7 +1,7 @@ #include #include "posewidget.h" -PoseWidget::PoseWidget(const SkeletonDocument *document, QUuid poseId) : +PoseWidget::PoseWidget(const Document *document, QUuid poseId) : m_poseId(poseId), m_document(document) { @@ -31,12 +31,12 @@ PoseWidget::PoseWidget(const SkeletonDocument *document, QUuid poseId) : setFixedSize(Theme::posePreviewImageSize, PoseWidget::preferredHeight()); - connect(document, &SkeletonDocument::poseNameChanged, this, [=](QUuid poseId) { + connect(document, &Document::poseNameChanged, this, [=](QUuid poseId) { if (poseId != m_poseId) return; updateName(); }); - connect(document, &SkeletonDocument::posePreviewChanged, this, [=](QUuid poseId) { + connect(document, &Document::posePreviewChanged, this, [=](QUuid poseId) { if (poseId != m_poseId) return; updatePreview(); @@ -76,7 +76,7 @@ void PoseWidget::reload() void PoseWidget::updatePreview() { - const SkeletonPose *pose = m_document->findPose(m_poseId); + const Pose *pose = m_document->findPose(m_poseId); if (!pose) { qDebug() << "Pose not found:" << m_poseId; return; @@ -87,7 +87,7 @@ void PoseWidget::updatePreview() void PoseWidget::updateName() { - const SkeletonPose *pose = m_document->findPose(m_poseId); + const Pose *pose = m_document->findPose(m_poseId); if (!pose) { qDebug() << "Pose not found:" << m_poseId; return; diff --git a/src/posewidget.h b/src/posewidget.h index 526021e2..1299746a 100644 --- a/src/posewidget.h +++ b/src/posewidget.h @@ -1,9 +1,9 @@ -#ifndef POSE_WIDGET_H -#define POSE_WIDGET_H +#ifndef DUST3D_POSE_WIDGET_H +#define DUST3D_POSE_WIDGET_H #include #include #include -#include "skeletondocument.h" +#include "document.h" #include "modelwidget.h" class PoseWidget : public QFrame @@ -13,7 +13,7 @@ signals: void modifyPose(QUuid poseId); void cornerButtonClicked(QUuid poseId); public: - PoseWidget(const SkeletonDocument *document, QUuid poseId); + PoseWidget(const Document *document, QUuid poseId); static int preferredHeight(); ModelWidget *previewWidget(); protected: @@ -27,7 +27,7 @@ public slots: void setCornerButtonVisible(bool visible); private: QUuid m_poseId; - const SkeletonDocument *m_document = nullptr; + const Document *m_document = nullptr; ModelWidget *m_previewWidget = nullptr; QLabel *m_nameLabel = nullptr; QPushButton *m_cornerButton = nullptr; diff --git a/src/positionmap.h b/src/positionmap.h index e5a2d735..f1fbf718 100644 --- a/src/positionmap.h +++ b/src/positionmap.h @@ -1,5 +1,5 @@ -#ifndef POSITION_MAP_H -#define POSITION_MAP_H +#ifndef DUST3D_POSITION_MAP_H +#define DUST3D_POSITION_MAP_H #include struct PositionMapKey diff --git a/src/qtlightmapper.h b/src/qtlightmapper.h index ae594c0a..2678cdb7 100644 --- a/src/qtlightmapper.h +++ b/src/qtlightmapper.h @@ -1,3 +1,6 @@ +#ifndef DUST3D_QT_LIGHT_MAPPER_H +#define DUST3D_QT_LIGHT_MAPPER_H + // https://github.com/huxingyi/dust3d/blob/master/src/qtlightmapper.h // This qtlightmapper.h is modified from Andreas Mantler' lightmapper to better work with Qt's OpenGL, especially for QOpenGLFunctions. // The low version shader is modified from ppiecuch's answer: https://github.com/ands/lightmapper/issues/9 @@ -18,9 +21,6 @@ #include #if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) -#ifndef QT_LIGHTMAPPER_H -#define QT_LIGHTMAPPER_H - #ifdef __cplusplus #define LM_DEFAULT_VALUE(value) = value #else @@ -2091,3 +2091,4 @@ void QtLightMapper::destroyScene(scene_t *scene) #endif // LIGHTMAPPER_IMPLEMENTATION #endif + diff --git a/src/riggenerator.cpp b/src/riggenerator.cpp index 623a8800..f1e7cc31 100644 --- a/src/riggenerator.cpp +++ b/src/riggenerator.cpp @@ -4,25 +4,25 @@ #include "riggenerator.h" #include "autorigger.h" -RigGenerator::RigGenerator(const MeshResultContext &meshResultContext) : - m_meshResultContext(new MeshResultContext(meshResultContext)) +RigGenerator::RigGenerator(const Outcome &outcome) : + m_outcome(new Outcome(outcome)) { } RigGenerator::~RigGenerator() { - delete m_meshResultContext; + delete m_outcome; delete m_resultMesh; delete m_autoRigger; delete m_resultBones; delete m_resultWeights; } -MeshResultContext *RigGenerator::takeMeshResultContext() +Outcome *RigGenerator::takeMeshResultContext() { - MeshResultContext *resultContext = m_meshResultContext; - m_meshResultContext = nullptr; - return resultContext; + Outcome *outcome = m_outcome; + m_outcome = nullptr; + return outcome; } std::vector *RigGenerator::takeResultBones() @@ -69,21 +69,21 @@ void RigGenerator::process() std::vector inputVerticesPositions; std::set inputTriangles; - for (const auto &vertex: m_meshResultContext->vertices) { + for (const auto &vertex: m_outcome->vertices) { inputVerticesPositions.push_back(vertex.position); } - std::map, std::tuple>> marksMap; - for (size_t triangleIndex = 0; triangleIndex < m_meshResultContext->triangles.size(); triangleIndex++) { - const auto &sourceTriangle = m_meshResultContext->triangles[triangleIndex]; + std::map, std::tuple>> marksMap; + for (size_t triangleIndex = 0; triangleIndex < m_outcome->triangles.size(); triangleIndex++) { + const auto &sourceTriangle = m_outcome->triangles[triangleIndex]; MeshSplitterTriangle newTriangle; for (int i = 0; i < 3; i++) newTriangle.indicies[i] = sourceTriangle.indicies[i]; - auto findBmeshNodeResult = m_meshResultContext->bmeshNodeMap().find(m_meshResultContext->triangleSourceNodes()[triangleIndex]); - if (findBmeshNodeResult != m_meshResultContext->bmeshNodeMap().end()) { + auto findBmeshNodeResult = m_outcome->bmeshNodeMap().find(m_outcome->triangleSourceNodes()[triangleIndex]); + if (findBmeshNodeResult != m_outcome->bmeshNodeMap().end()) { const auto &bmeshNode = *findBmeshNodeResult->second; - if (bmeshNode.boneMark != SkeletonBoneMark::None) { + if (bmeshNode.boneMark != BoneMark::None) { SkeletonSide boneSide = SkeletonSide::None; - if (SkeletonBoneMarkHasSide(bmeshNode.boneMark)) { + if (BoneMarkHasSide(bmeshNode.boneMark)) { boneSide = bmeshNode.origin.x() > 0 ? SkeletonSide::Left : SkeletonSide::Right; } auto &marks = marksMap[std::make_pair(bmeshNode.boneMark, boneSide)]; @@ -115,7 +115,7 @@ void RigGenerator::process() // Blend vertices colors according to bone weights - std::vector inputVerticesColors(m_meshResultContext->vertices.size()); + std::vector inputVerticesColors(m_outcome->vertices.size()); if (m_isSucceed) { const auto &resultWeights = m_autoRigger->resultWeights(); const auto &resultBones = m_autoRigger->resultBones(); @@ -148,8 +148,8 @@ void RigGenerator::process() std::vector vertexNormalMap; vertexNormalMap.resize(inputVerticesPositions.size()); - for (size_t triangleIndex = 0; triangleIndex < m_meshResultContext->triangles.size(); triangleIndex++) { - const auto &sourceTriangle = m_meshResultContext->triangles[triangleIndex]; + for (size_t triangleIndex = 0; triangleIndex < m_outcome->triangles.size(); triangleIndex++) { + const auto &sourceTriangle = m_outcome->triangles[triangleIndex]; for (int i = 0; i < 3; i++) vertexNormalMap[sourceTriangle.indicies[i]] += sourceTriangle.normal; } @@ -158,10 +158,10 @@ void RigGenerator::process() // Create mesh for demo - Vertex *triangleVertices = new Vertex[m_meshResultContext->triangles.size() * 3]; + Vertex *triangleVertices = new Vertex[m_outcome->triangles.size() * 3]; int triangleVerticesNum = 0; - for (size_t triangleIndex = 0; triangleIndex < m_meshResultContext->triangles.size(); triangleIndex++) { - const auto &sourceTriangle = m_meshResultContext->triangles[triangleIndex]; + for (size_t triangleIndex = 0; triangleIndex < m_outcome->triangles.size(); triangleIndex++) { + const auto &sourceTriangle = m_outcome->triangles[triangleIndex]; for (int i = 0; i < 3; i++) { Vertex ¤tVertex = triangleVertices[triangleVerticesNum++]; const auto &sourcePosition = inputVerticesPositions[sourceTriangle.indicies[i]]; diff --git a/src/riggenerator.h b/src/riggenerator.h index 5aaeeadd..fa9fd9a2 100644 --- a/src/riggenerator.h +++ b/src/riggenerator.h @@ -1,9 +1,9 @@ -#ifndef RIG_GENERATOR_H -#define RIG_GENERATOR_H +#ifndef DUST3D_RIG_GENERATOR_H +#define DUST3D_RIG_GENERATOR_H #include #include #include -#include "meshresultcontext.h" +#include "outcome.h" #include "meshloader.h" #include "autorigger.h" @@ -11,21 +11,21 @@ class RigGenerator : public QObject { Q_OBJECT public: - RigGenerator(const MeshResultContext &meshResultContext); + RigGenerator(const Outcome &outcome); ~RigGenerator(); MeshLoader *takeResultMesh(); std::vector *takeResultBones(); std::map *takeResultWeights(); const std::vector &missingMarkNames(); const std::vector &errorMarkNames(); - MeshResultContext *takeMeshResultContext(); + Outcome *takeMeshResultContext(); bool isSucceed(); signals: void finished(); public slots: void process(); private: - MeshResultContext *m_meshResultContext = nullptr; + Outcome *m_outcome = nullptr; MeshLoader *m_resultMesh = nullptr; AutoRigger *m_autoRigger = nullptr; std::vector *m_resultBones = nullptr; diff --git a/src/rigtype.h b/src/rigtype.h index 13b70282..619a5668 100644 --- a/src/rigtype.h +++ b/src/rigtype.h @@ -1,5 +1,5 @@ -#ifndef RIG_TYPE_H -#define RIG_TYPE_H +#ifndef DUST3D_RIG_TYPE_H +#define DUST3D_RIG_TYPE_H #include enum class RigType diff --git a/src/rigwidget.cpp b/src/rigwidget.cpp index ae08e76d..3e02823b 100644 --- a/src/rigwidget.cpp +++ b/src/rigwidget.cpp @@ -6,7 +6,7 @@ #include "infolabel.h" #include "theme.h" -RigWidget::RigWidget(const SkeletonDocument *document, QWidget *parent) : +RigWidget::RigWidget(const Document *document, QWidget *parent) : QWidget(parent), m_document(document) { diff --git a/src/rigwidget.h b/src/rigwidget.h index 4cd40df4..4096daef 100644 --- a/src/rigwidget.h +++ b/src/rigwidget.h @@ -1,9 +1,9 @@ -#ifndef RIG_WIDGET_H -#define RIG_WIDGET_H +#ifndef DUST3D_RIG_WIDGET_H +#define DUST3D_RIG_WIDGET_H #include #include #include -#include "skeletondocument.h" +#include "document.h" #include "rigtype.h" #include "modelwidget.h" #include "infolabel.h" @@ -17,10 +17,10 @@ public slots: void rigTypeChanged(); void updateResultInfo(); public: - RigWidget(const SkeletonDocument *document, QWidget *parent=nullptr); + RigWidget(const Document *document, QWidget *parent=nullptr); ModelWidget *rigWeightRenderWidget(); private: - const SkeletonDocument *m_document = nullptr; + const Document *m_document = nullptr; QComboBox *m_rigTypeBox = nullptr; ModelWidget *m_rigWeightRenderWidget = nullptr; InfoLabel *m_missingMarksInfoLabel = nullptr; diff --git a/src/shortcuts.h b/src/shortcuts.h index 1bc3eefb..9e48ce1c 100644 --- a/src/shortcuts.h +++ b/src/shortcuts.h @@ -1,5 +1,5 @@ -#ifndef SHORTCUTS_H -#define SHORTCUTS_H +#ifndef DUST3D_SHORTCUTS_H +#define DUST3D_SHORTCUTS_H #include #include "skeletongraphicswidget.h" diff --git a/src/skeletonbonemark.cpp b/src/skeletonbonemark.cpp deleted file mode 100644 index 3b395e71..00000000 --- a/src/skeletonbonemark.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include "skeletonbonemark.h" - -IMPL_SkeletonSideToDispName - -IMPL_SkeletonBoneMarkToColor -IMPL_SkeletonBoneMarkToString -IMPL_SkeletonBoneMarkFromString -IMPL_SkeletonBoneMarkToDispName diff --git a/src/skeletonbonemark.h b/src/skeletonbonemark.h deleted file mode 100644 index 1fd38283..00000000 --- a/src/skeletonbonemark.h +++ /dev/null @@ -1,140 +0,0 @@ -#ifndef SKELETON_BONE_MARK_H -#define SKELETON_BONE_MARK_H -#include -#include - -enum class SkeletonSide -{ - None = 0, - Left, - Right -}; - -QString SkeletonSideToDispName(SkeletonSide side); -#define IMPL_SkeletonSideToDispName \ -QString SkeletonSideToDispName(SkeletonSide side) \ -{ \ - switch (side) { \ - case SkeletonSide::Left: \ - return QObject::tr("Left"); \ - case SkeletonSide::Right: \ - return QObject::tr("Right"); \ - case SkeletonSide::None: \ - return ""; \ - default: \ - return ""; \ - } \ -} - -enum class SkeletonBoneMark -{ - None = 0, - Neck, - Shoulder, - Elbow, - Wrist, - Hip, - Knee, - Ankle, - Count -}; -#define SkeletonBoneMarkHasSide(mark) ((mark) != SkeletonBoneMark::Neck) -QColor SkeletonBoneMarkToColor(SkeletonBoneMark mark); -#define IMPL_SkeletonBoneMarkToColor \ -QColor SkeletonBoneMarkToColor(SkeletonBoneMark mark) \ -{ \ - switch (mark) { \ - case SkeletonBoneMark::Neck: \ - return QColor(0xfc, 0x0d, 0x1b); \ - case SkeletonBoneMark::Shoulder: \ - return QColor(0xfd, 0x80, 0x23); \ - case SkeletonBoneMark::Elbow: \ - return QColor(0x29, 0xfd, 0x2f); \ - case SkeletonBoneMark::Wrist: \ - return QColor(0xff, 0xfd, 0x38); \ - case SkeletonBoneMark::Hip: \ - return QColor(0x2c, 0xff, 0xfe); \ - case SkeletonBoneMark::Knee: \ - return QColor(0x0b, 0x24, 0xfb); \ - case SkeletonBoneMark::Ankle: \ - return QColor(0xfc, 0x28, 0xfc); \ - case SkeletonBoneMark::None: \ - return Qt::transparent; \ - default: \ - return Qt::transparent; \ - } \ -} -const char *SkeletonBoneMarkToString(SkeletonBoneMark mark); -#define IMPL_SkeletonBoneMarkToString \ -const char *SkeletonBoneMarkToString(SkeletonBoneMark mark) \ -{ \ - switch (mark) { \ - case SkeletonBoneMark::Neck: \ - return "Neck"; \ - case SkeletonBoneMark::Shoulder: \ - return "Shoulder"; \ - case SkeletonBoneMark::Elbow: \ - return "Elbow"; \ - case SkeletonBoneMark::Wrist: \ - return "Wrist"; \ - case SkeletonBoneMark::Hip: \ - return "Hip"; \ - case SkeletonBoneMark::Knee: \ - return "Knee"; \ - case SkeletonBoneMark::Ankle: \ - return "Ankle"; \ - case SkeletonBoneMark::None: \ - return "None"; \ - default: \ - return "None"; \ - } \ -} -SkeletonBoneMark SkeletonBoneMarkFromString(const char *markString); -#define IMPL_SkeletonBoneMarkFromString \ -SkeletonBoneMark SkeletonBoneMarkFromString(const char *markString) \ -{ \ - QString mark = markString; \ - if (mark == "Neck") \ - return SkeletonBoneMark::Neck; \ - if (mark == "Shoulder") \ - return SkeletonBoneMark::Shoulder; \ - if (mark == "Elbow") \ - return SkeletonBoneMark::Elbow; \ - if (mark == "Wrist") \ - return SkeletonBoneMark::Wrist; \ - if (mark == "Hip") \ - return SkeletonBoneMark::Hip; \ - if (mark == "Knee") \ - return SkeletonBoneMark::Knee; \ - if (mark == "Ankle") \ - return SkeletonBoneMark::Ankle; \ - return SkeletonBoneMark::None; \ -} -QString SkeletonBoneMarkToDispName(SkeletonBoneMark mark); -#define IMPL_SkeletonBoneMarkToDispName \ -QString SkeletonBoneMarkToDispName(SkeletonBoneMark mark) \ -{ \ - switch (mark) { \ - case SkeletonBoneMark::Neck: \ - return QObject::tr("Neck"); \ - case SkeletonBoneMark::Shoulder: \ - return QObject::tr("Shoulder (Arm Start)"); \ - case SkeletonBoneMark::Elbow: \ - return QObject::tr("Elbow"); \ - case SkeletonBoneMark::Wrist: \ - return QObject::tr("Wrist"); \ - case SkeletonBoneMark::Hip: \ - return QObject::tr("Hip (Leg Start)"); \ - case SkeletonBoneMark::Knee: \ - return QObject::tr("Knee"); \ - case SkeletonBoneMark::Ankle: \ - return QObject::tr("Ankle"); \ - case SkeletonBoneMark::None: \ - return QObject::tr("None"); \ - default: \ - return ""; \ - } \ -} - -#endif - diff --git a/src/skeletongraphicswidget.cpp b/src/skeletongraphicswidget.cpp index 83901139..66d92966 100644 --- a/src/skeletongraphicswidget.cpp +++ b/src/skeletongraphicswidget.cpp @@ -11,11 +11,11 @@ #include #include "skeletongraphicswidget.h" #include "theme.h" -#include "dust3dutil.h" -#include "skeletonxml.h" +#include "util.h" +#include "snapshotxml.h" #include "markiconcreator.h" -SkeletonGraphicsWidget::SkeletonGraphicsWidget(const SkeletonDocument *document) : +SkeletonGraphicsWidget::SkeletonGraphicsWidget(const Document *document) : m_document(document), m_backgroundItem(nullptr), m_turnaroundChanged(false), @@ -45,7 +45,7 @@ SkeletonGraphicsWidget::SkeletonGraphicsWidget(const SkeletonDocument *document) m_eventForwardingToModelWidget(false), m_modelWidget(nullptr), m_inTempDragMode(false), - m_modeBeforeEnterTempDragMode(SkeletonDocumentEditMode::Select) + m_modeBeforeEnterTempDragMode(DocumentEditMode::Select) { setRenderHint(QPainter::Antialiasing, false); setBackgroundBrush(QBrush(QWidget::palette().color(QWidget::backgroundRole()), Qt::SolidPattern)); @@ -107,12 +107,12 @@ void SkeletonGraphicsWidget::disableBackgroundBlur() void SkeletonGraphicsWidget::showContextMenu(const QPoint &pos) { - if (SkeletonDocumentEditMode::Add == m_document->editMode) { - emit setEditMode(SkeletonDocumentEditMode::Select); + if (DocumentEditMode::Add == m_document->editMode) { + emit setEditMode(DocumentEditMode::Select); return; } - if (SkeletonDocumentEditMode::Select != m_document->editMode) { + if (DocumentEditMode::Select != m_document->editMode) { return; } @@ -120,19 +120,19 @@ void SkeletonGraphicsWidget::showContextMenu(const QPoint &pos) QAction addAction(tr("Add..."), this); connect(&addAction, &QAction::triggered, [=]() { - emit setEditMode(SkeletonDocumentEditMode::Add); + emit setEditMode(DocumentEditMode::Add); }); contextMenu.addAction(&addAction); QAction undoAction(tr("Undo"), this); if (m_document->undoable()) { - connect(&undoAction, &QAction::triggered, m_document, &SkeletonDocument::undo); + connect(&undoAction, &QAction::triggered, m_document, &Document::undo); contextMenu.addAction(&undoAction); } QAction redoAction(tr("Redo"), this); if (m_document->redoable()) { - connect(&redoAction, &QAction::triggered, m_document, &SkeletonDocument::redo); + connect(&redoAction, &QAction::triggered, m_document, &Document::redo); contextMenu.addAction(&redoAction); } @@ -168,7 +168,7 @@ void SkeletonGraphicsWidget::showContextMenu(const QPoint &pos) QAction pasteAction(tr("Paste"), this); if (m_document->hasPastableNodesInClipboard()) { - connect(&pasteAction, &QAction::triggered, m_document, &SkeletonDocument::paste); + connect(&pasteAction, &QAction::triggered, m_document, &Document::paste); contextMenu.addAction(&pasteAction); } @@ -235,23 +235,23 @@ void SkeletonGraphicsWidget::showContextMenu(const QPoint &pos) } QAction markAsNoneAction(tr("None"), this); - QAction *markAsActions[(int)SkeletonBoneMark::Count - 1]; - for (int i = 0; i < (int)SkeletonBoneMark::Count - 1; i++) { + QAction *markAsActions[(int)BoneMark::Count - 1]; + for (int i = 0; i < (int)BoneMark::Count - 1; i++) { markAsActions[i] = nullptr; } if (hasNodeSelection()) { QMenu *subMenu = contextMenu.addMenu(tr("Mark As")); connect(&markAsNoneAction, &QAction::triggered, [=]() { - setSelectedNodesBoneMark(SkeletonBoneMark::None); + setSelectedNodesBoneMark(BoneMark::None); }); subMenu->addAction(&markAsNoneAction); subMenu->addSeparator(); - for (int i = 0; i < (int)SkeletonBoneMark::Count - 1; i++) { - SkeletonBoneMark boneMark = (SkeletonBoneMark)(i + 1); - markAsActions[i] = new QAction(MarkIconCreator::createIcon(boneMark), SkeletonBoneMarkToDispName(boneMark), this); + for (int i = 0; i < (int)BoneMark::Count - 1; i++) { + BoneMark boneMark = (BoneMark)(i + 1); + markAsActions[i] = new QAction(MarkIconCreator::createIcon(boneMark), BoneMarkToDispName(boneMark), this); connect(markAsActions[i], &QAction::triggered, [=]() { setSelectedNodesBoneMark(boneMark); }); @@ -279,7 +279,7 @@ void SkeletonGraphicsWidget::showContextMenu(const QPoint &pos) contextMenu.exec(mapToGlobal(pos)); - for (int i = 0; i < (int)SkeletonBoneMark::Count - 1; i++) { + for (int i = 0; i < (int)BoneMark::Count - 1; i++) { delete markAsActions[i]; } } @@ -404,7 +404,7 @@ void SkeletonGraphicsWidget::alignSelectedToGlobal(bool alignToVerticalCenter, b return; emit batchChangeBegin(); for (const auto &nodeItem: nodeItems) { - const SkeletonNode *node = m_document->findNode(nodeItem->id()); + const Node *node = m_document->findNode(nodeItem->id()); if (!node) { qDebug() << "Find node id failed:" << nodeItem->id(); continue; @@ -530,25 +530,25 @@ void SkeletonGraphicsWidget::turnaroundImageReady() void SkeletonGraphicsWidget::updateCursor() { - if (SkeletonDocumentEditMode::Add != m_document->editMode) { + if (DocumentEditMode::Add != m_document->editMode) { m_cursorEdgeItem->hide(); m_cursorNodeItem->hide(); } switch (m_document->editMode) { - case SkeletonDocumentEditMode::Add: + case DocumentEditMode::Add: setCursor(QCursor(Theme::awesome()->icon(fa::plus).pixmap(Theme::toolIconFontSize, Theme::toolIconFontSize))); break; - case SkeletonDocumentEditMode::Select: + case DocumentEditMode::Select: setCursor(QCursor(Theme::awesome()->icon(fa::mousepointer).pixmap(Theme::toolIconFontSize, Theme::toolIconFontSize), Theme::toolIconFontSize / 5, 0)); break; - case SkeletonDocumentEditMode::Drag: + case DocumentEditMode::Drag: setCursor(QCursor(Theme::awesome()->icon(m_dragStarted ? fa::handrocko : fa::handpapero).pixmap(Theme::toolIconFontSize, Theme::toolIconFontSize))); break; - case SkeletonDocumentEditMode::ZoomIn: + case DocumentEditMode::ZoomIn: setCursor(QCursor(Theme::awesome()->icon(fa::searchplus).pixmap(Theme::toolIconFontSize, Theme::toolIconFontSize))); break; - case SkeletonDocumentEditMode::ZoomOut: + case DocumentEditMode::ZoomOut: setCursor(QCursor(Theme::awesome()->icon(fa::searchminus).pixmap(Theme::toolIconFontSize, Theme::toolIconFontSize))); break; } @@ -559,7 +559,7 @@ void SkeletonGraphicsWidget::updateCursor() void SkeletonGraphicsWidget::editModeChanged() { updateCursor(); - if (SkeletonDocumentEditMode::Add == m_document->editMode) { + if (DocumentEditMode::Add == m_document->editMode) { SkeletonGraphicsNodeItem *choosenNodeItem = nullptr; if (!m_rangeSelectionSet.empty()) { std::set nodeItems; @@ -648,7 +648,7 @@ bool SkeletonGraphicsWidget::mouseMove(QMouseEvent *event) return true; } - if (SkeletonDocumentEditMode::Select == m_document->editMode) { + if (DocumentEditMode::Select == m_document->editMode) { if (m_rangeSelectionStarted) { QPointF mouseScenePos = mouseEventScenePos(event); m_selectionItem->updateRange(m_rangeSelectionStartPos, mouseScenePos); @@ -659,8 +659,8 @@ bool SkeletonGraphicsWidget::mouseMove(QMouseEvent *event) } } - if (SkeletonDocumentEditMode::Select == m_document->editMode || - SkeletonDocumentEditMode::Add == m_document->editMode) { + if (DocumentEditMode::Select == m_document->editMode || + DocumentEditMode::Add == m_document->editMode) { // // > For overlapping nodes, you can make it a bit better by selecting the node center nearest the mouse, rather than simply checking against the wider circle. @@ -746,7 +746,7 @@ bool SkeletonGraphicsWidget::mouseMove(QMouseEvent *event) hoverPart(hoveredPartId); } - if (SkeletonDocumentEditMode::Add == m_document->editMode) { + if (DocumentEditMode::Add == m_document->editMode) { QPointF mouseScenePos = mouseEventScenePos(event); m_cursorNodeItem->setOrigin(mouseScenePos); if (!m_cursorNodeItem->isVisible()) { @@ -761,7 +761,7 @@ bool SkeletonGraphicsWidget::mouseMove(QMouseEvent *event) return true; } - if (SkeletonDocumentEditMode::Select == m_document->editMode) { + if (DocumentEditMode::Select == m_document->editMode) { if (m_moveStarted) { if (m_checkedOriginItem) { QPointF mouseScenePos = mouseEventScenePos(event); @@ -781,7 +781,7 @@ bool SkeletonGraphicsWidget::mouseMove(QMouseEvent *event) bool ikMoved = false; if (nodeItems.size() == 1) { auto &nodeItem = *nodeItems.begin(); - const SkeletonNode *node = m_document->findNode(nodeItem->id()); + const Node *node = m_document->findNode(nodeItem->id()); if (node->edgeIds.size() == 1) { const auto origin = nodeItem->origin(); byX = mouseScenePos.x() - origin.x(); @@ -1024,12 +1024,12 @@ bool SkeletonGraphicsWidget::wheel(QWheelEvent *event) if (fabs(delta) < 1) delta = delta < 0 ? -1.0 : 1.0; } - if (SkeletonDocumentEditMode::Add == m_document->editMode) { + if (DocumentEditMode::Add == m_document->editMode) { if (m_cursorNodeItem->isVisible()) { m_cursorNodeItem->setRadius(m_cursorNodeItem->radius() + delta); return true; } - } else if (SkeletonDocumentEditMode::Select == m_document->editMode) { + } else if (DocumentEditMode::Select == m_document->editMode) { if (!m_rangeSelectionSet.empty()) { if (QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) { scaleSelected(delta); @@ -1165,13 +1165,13 @@ QPointF SkeletonGraphicsWidget::mouseEventScenePos(QMouseEvent *event) bool SkeletonGraphicsWidget::mousePress(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { - if (SkeletonDocumentEditMode::ZoomIn == m_document->editMode) { + if (DocumentEditMode::ZoomIn == m_document->editMode) { ViewportAnchor lastAnchor = transformationAnchor(); setTransformationAnchor(QGraphicsView::AnchorUnderMouse); scale(1.5, 1.5); setTransformationAnchor(lastAnchor); return true; - } else if (SkeletonDocumentEditMode::ZoomOut == m_document->editMode) { + } else if (DocumentEditMode::ZoomOut == m_document->editMode) { ViewportAnchor lastAnchor = transformationAnchor(); setTransformationAnchor(QGraphicsView::AnchorUnderMouse); scale(0.5, 0.5); @@ -1181,13 +1181,13 @@ bool SkeletonGraphicsWidget::mousePress(QMouseEvent *event) setTransform(QTransform()); } return true; - } else if (SkeletonDocumentEditMode::Drag == m_document->editMode) { + } else if (DocumentEditMode::Drag == m_document->editMode) { if (!m_dragStarted) { m_lastGlobalPos = event->globalPos(); m_dragStarted = true; updateCursor(); } - } else if (SkeletonDocumentEditMode::Add == m_document->editMode) { + } else if (DocumentEditMode::Add == m_document->editMode) { if (m_cursorNodeItem->isVisible()) { if (m_addFromNodeItem) { if (m_hoveredNodeItem && m_addFromNodeItem && @@ -1226,7 +1226,7 @@ bool SkeletonGraphicsWidget::mousePress(QMouseEvent *event) emit groupOperationAdded(); return true; } - } else if (SkeletonDocumentEditMode::Select == m_document->editMode) { + } else if (DocumentEditMode::Select == m_document->editMode) { bool processed = false; if (m_hoveredOriginItem != m_checkedOriginItem) { if (m_checkedOriginItem) { @@ -1284,7 +1284,7 @@ bool SkeletonGraphicsWidget::mousePress(QMouseEvent *event) } if (event->button() == Qt::LeftButton) { - if (SkeletonDocumentEditMode::Select == m_document->editMode) { + if (DocumentEditMode::Select == m_document->editMode) { if (!m_rangeSelectionStarted) { m_rangeSelectionStartPos = mouseEventScenePos(event); m_rangeSelectionStarted = true; @@ -1398,10 +1398,10 @@ void SkeletonGraphicsWidget::shortcutDelete() void SkeletonGraphicsWidget::shortcutAddMode() { - if (SkeletonDocumentEditMode::Add == m_document->editMode) { - emit setEditMode(SkeletonDocumentEditMode::Select); + if (DocumentEditMode::Add == m_document->editMode) { + emit setEditMode(DocumentEditMode::Select); } else { - emit setEditMode(SkeletonDocumentEditMode::Add); + emit setEditMode(DocumentEditMode::Add); } } @@ -1452,12 +1452,12 @@ void SkeletonGraphicsWidget::shortcutSave() void SkeletonGraphicsWidget::shortcutSelectMode() { - emit setEditMode(SkeletonDocumentEditMode::Select); + emit setEditMode(DocumentEditMode::Select); } void SkeletonGraphicsWidget::shortcutDragMode() { - emit setEditMode(SkeletonDocumentEditMode::Drag); + emit setEditMode(DocumentEditMode::Drag); } void SkeletonGraphicsWidget::shortcutZoomRenderedModelByMinus10() @@ -1467,7 +1467,7 @@ void SkeletonGraphicsWidget::shortcutZoomRenderedModelByMinus10() void SkeletonGraphicsWidget::shortcutZoomSelectedByMinus1() { - if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) { + if (DocumentEditMode::Select == m_document->editMode && hasSelection()) { zoomSelected(-1); emit groupOperationAdded(); } @@ -1480,7 +1480,7 @@ void SkeletonGraphicsWidget::shortcutZoomRenderedModelBy10() void SkeletonGraphicsWidget::shortcutZoomSelectedBy1() { - if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) { + if (DocumentEditMode::Select == m_document->editMode && hasSelection()) { zoomSelected(1); emit groupOperationAdded(); } @@ -1488,7 +1488,7 @@ void SkeletonGraphicsWidget::shortcutZoomSelectedBy1() void SkeletonGraphicsWidget::shortcutRotateSelectedByMinus1() { - if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) { + if (DocumentEditMode::Select == m_document->editMode && hasSelection()) { rotateSelected(-1); emit groupOperationAdded(); } @@ -1496,7 +1496,7 @@ void SkeletonGraphicsWidget::shortcutRotateSelectedByMinus1() void SkeletonGraphicsWidget::shortcutRotateSelectedBy1() { - if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) { + if (DocumentEditMode::Select == m_document->editMode && hasSelection()) { rotateSelected(1); emit groupOperationAdded(); } @@ -1504,7 +1504,7 @@ void SkeletonGraphicsWidget::shortcutRotateSelectedBy1() void SkeletonGraphicsWidget::shortcutMoveSelectedToLeft() { - if (SkeletonDocumentEditMode::Select == m_document->editMode) { + if (DocumentEditMode::Select == m_document->editMode) { if (m_checkedOriginItem) { moveCheckedOrigin(-1, 0); emit groupOperationAdded(); @@ -1517,7 +1517,7 @@ void SkeletonGraphicsWidget::shortcutMoveSelectedToLeft() void SkeletonGraphicsWidget::shortcutMoveSelectedToRight() { - if (SkeletonDocumentEditMode::Select == m_document->editMode) { + if (DocumentEditMode::Select == m_document->editMode) { if (m_checkedOriginItem) { moveCheckedOrigin(1, 0); emit groupOperationAdded(); @@ -1530,7 +1530,7 @@ void SkeletonGraphicsWidget::shortcutMoveSelectedToRight() void SkeletonGraphicsWidget::shortcutMoveSelectedToUp() { - if (SkeletonDocumentEditMode::Select == m_document->editMode) { + if (DocumentEditMode::Select == m_document->editMode) { if (m_checkedOriginItem) { moveCheckedOrigin(0, -1); emit groupOperationAdded(); @@ -1543,7 +1543,7 @@ void SkeletonGraphicsWidget::shortcutMoveSelectedToUp() void SkeletonGraphicsWidget::shortcutMoveSelectedToDown() { - if (SkeletonDocumentEditMode::Select == m_document->editMode) { + if (DocumentEditMode::Select == m_document->editMode) { if (m_checkedOriginItem) { moveCheckedOrigin(0, 1); emit groupOperationAdded(); @@ -1556,7 +1556,7 @@ void SkeletonGraphicsWidget::shortcutMoveSelectedToDown() void SkeletonGraphicsWidget::shortcutScaleSelectedByMinus1() { - if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) { + if (DocumentEditMode::Select == m_document->editMode && hasSelection()) { scaleSelected(-1); emit groupOperationAdded(); } @@ -1564,7 +1564,7 @@ void SkeletonGraphicsWidget::shortcutScaleSelectedByMinus1() void SkeletonGraphicsWidget::shortcutScaleSelectedBy1() { - if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) { + if (DocumentEditMode::Select == m_document->editMode && hasSelection()) { scaleSelected(1); emit groupOperationAdded(); } @@ -1572,15 +1572,15 @@ void SkeletonGraphicsWidget::shortcutScaleSelectedBy1() void SkeletonGraphicsWidget::shortcutSwitchProfileOnSelected() { - if (SkeletonDocumentEditMode::Select == m_document->editMode && hasSelection()) { + if (DocumentEditMode::Select == m_document->editMode && hasSelection()) { switchProfileOnRangeSelection(); } } void SkeletonGraphicsWidget::shortcutShowOrHideSelectedPart() { - if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { - const SkeletonPart *part = m_document->findPart(m_lastCheckedPart); + if (DocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { + const Part *part = m_document->findPart(m_lastCheckedPart); bool partVisible = part && part->visible; emit setPartVisibleState(m_lastCheckedPart, !partVisible); emit groupOperationAdded(); @@ -1589,8 +1589,8 @@ void SkeletonGraphicsWidget::shortcutShowOrHideSelectedPart() void SkeletonGraphicsWidget::shortcutEnableOrDisableSelectedPart() { - if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { - const SkeletonPart *part = m_document->findPart(m_lastCheckedPart); + if (DocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { + const Part *part = m_document->findPart(m_lastCheckedPart); bool partDisabled = part && part->disabled; emit setPartDisableState(m_lastCheckedPart, !partDisabled); emit groupOperationAdded(); @@ -1599,8 +1599,8 @@ void SkeletonGraphicsWidget::shortcutEnableOrDisableSelectedPart() void SkeletonGraphicsWidget::shortcutLockOrUnlockSelectedPart() { - if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { - const SkeletonPart *part = m_document->findPart(m_lastCheckedPart); + if (DocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { + const Part *part = m_document->findPart(m_lastCheckedPart); bool partLocked = part && part->locked; emit setPartLockState(m_lastCheckedPart, !partLocked); emit groupOperationAdded(); @@ -1609,8 +1609,8 @@ void SkeletonGraphicsWidget::shortcutLockOrUnlockSelectedPart() void SkeletonGraphicsWidget::shortcutXmirrorOnOrOffSelectedPart() { - if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { - const SkeletonPart *part = m_document->findPart(m_lastCheckedPart); + if (DocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { + const Part *part = m_document->findPart(m_lastCheckedPart); bool partXmirrored = part && part->xMirrored; emit setPartXmirrorState(m_lastCheckedPart, !partXmirrored); emit groupOperationAdded(); @@ -1619,8 +1619,8 @@ void SkeletonGraphicsWidget::shortcutXmirrorOnOrOffSelectedPart() void SkeletonGraphicsWidget::shortcutSubdivedOrNotSelectedPart() { - if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { - const SkeletonPart *part = m_document->findPart(m_lastCheckedPart); + if (DocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { + const Part *part = m_document->findPart(m_lastCheckedPart); bool partSubdived = part && part->subdived; emit setPartSubdivState(m_lastCheckedPart, !partSubdived); emit groupOperationAdded(); @@ -1629,8 +1629,8 @@ void SkeletonGraphicsWidget::shortcutSubdivedOrNotSelectedPart() void SkeletonGraphicsWidget::shortcutRoundEndOrNotSelectedPart() { - if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { - const SkeletonPart *part = m_document->findPart(m_lastCheckedPart); + if (DocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { + const Part *part = m_document->findPart(m_lastCheckedPart); bool partRounded = part && part->rounded; emit setPartRoundState(m_lastCheckedPart, !partRounded); emit groupOperationAdded(); @@ -1639,8 +1639,8 @@ void SkeletonGraphicsWidget::shortcutRoundEndOrNotSelectedPart() void SkeletonGraphicsWidget::shortcutWrapOrNotSelectedPart() { - if (SkeletonDocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { - const SkeletonPart *part = m_document->findPart(m_lastCheckedPart); + if (DocumentEditMode::Select == m_document->editMode && !m_lastCheckedPart.isNull()) { + const Part *part = m_document->findPart(m_lastCheckedPart); bool partWrapped = part && part->wrapped; emit setPartWrapState(m_lastCheckedPart, !partWrapped); emit groupOperationAdded(); @@ -1650,13 +1650,13 @@ void SkeletonGraphicsWidget::shortcutWrapOrNotSelectedPart() bool SkeletonGraphicsWidget::keyPress(QKeyEvent *event) { if (event->key() == Qt::Key_Space) { - if (SkeletonDocumentEditMode::ZoomIn == m_document->editMode || - SkeletonDocumentEditMode::ZoomOut == m_document->editMode || - SkeletonDocumentEditMode::Select == m_document->editMode || - SkeletonDocumentEditMode::Add == m_document->editMode) { + if (DocumentEditMode::ZoomIn == m_document->editMode || + DocumentEditMode::ZoomOut == m_document->editMode || + DocumentEditMode::Select == m_document->editMode || + DocumentEditMode::Add == m_document->editMode) { m_inTempDragMode = true; m_modeBeforeEnterTempDragMode = m_document->editMode; - emit setEditMode(SkeletonDocumentEditMode::Drag); + emit setEditMode(DocumentEditMode::Drag); return true; } } @@ -1692,7 +1692,7 @@ void SkeletonGraphicsWidget::originChanged() void SkeletonGraphicsWidget::nodeAdded(QUuid nodeId) { - const SkeletonNode *node = m_document->findNode(nodeId); + const Node *node = m_document->findNode(nodeId); if (nullptr == node) { qDebug() << "New node added but node id not exist:" << nodeId; return; @@ -1701,7 +1701,7 @@ void SkeletonGraphicsWidget::nodeAdded(QUuid nodeId) qDebug() << "New node added but node item already exist:" << nodeId; return; } - QColor markColor = SkeletonBoneMarkToColor(node->boneMark); + QColor markColor = BoneMarkToColor(node->boneMark); SkeletonGraphicsNodeItem *mainProfileItem = new SkeletonGraphicsNodeItem(SkeletonProfile::Main); SkeletonGraphicsNodeItem *sideProfileItem = new SkeletonGraphicsNodeItem(SkeletonProfile::Side); mainProfileItem->setOrigin(scenePosFromUnified(QPointF(node->x, node->y))); @@ -1730,7 +1730,7 @@ void SkeletonGraphicsWidget::nodeAdded(QUuid nodeId) void SkeletonGraphicsWidget::edgeAdded(QUuid edgeId) { - const SkeletonEdge *edge = m_document->findEdge(edgeId); + const Edge *edge = m_document->findEdge(edgeId); if (nullptr == edge) { qDebug() << "New edge added but edge id not exist:" << edgeId; return; @@ -1810,7 +1810,7 @@ void SkeletonGraphicsWidget::edgeRemoved(QUuid edgeId) void SkeletonGraphicsWidget::nodeRadiusChanged(QUuid nodeId) { - const SkeletonNode *node = m_document->findNode(nodeId); + const Node *node = m_document->findNode(nodeId); if (nullptr == node) { qDebug() << "Node changed but node id not exist:" << nodeId; return; @@ -1827,7 +1827,7 @@ void SkeletonGraphicsWidget::nodeRadiusChanged(QUuid nodeId) void SkeletonGraphicsWidget::nodeBoneMarkChanged(QUuid nodeId) { - const SkeletonNode *node = m_document->findNode(nodeId); + const Node *node = m_document->findNode(nodeId); if (nullptr == node) { qDebug() << "Node changed but node id not exist:" << nodeId; return; @@ -1837,14 +1837,14 @@ void SkeletonGraphicsWidget::nodeBoneMarkChanged(QUuid nodeId) qDebug() << "Node not found:" << nodeId; return; } - QColor markColor = SkeletonBoneMarkToColor(node->boneMark); + QColor markColor = BoneMarkToColor(node->boneMark); it->second.first->setMarkColor(markColor); it->second.second->setMarkColor(markColor); } void SkeletonGraphicsWidget::nodeOriginChanged(QUuid nodeId) { - const SkeletonNode *node = m_document->findNode(nodeId); + const Node *node = m_document->findNode(nodeId); if (nullptr == node) { qDebug() << "Node changed but node id not exist:" << nodeId; return; @@ -1875,9 +1875,9 @@ void SkeletonGraphicsWidget::edgeChanged(QUuid edgeId) void SkeletonGraphicsWidget::partVisibleStateChanged(QUuid partId) { - const SkeletonPart *part = m_document->findPart(partId); + const Part *part = m_document->findPart(partId); for (const auto &nodeId: part->nodeIds) { - const SkeletonNode *node = m_document->findNode(nodeId); + const Node *node = m_document->findNode(nodeId); for (auto edgeIt = node->edgeIds.begin(); edgeIt != node->edgeIds.end(); edgeIt++) { auto edgeItemIt = edgeItemMap.find(*edgeIt); if (edgeItemIt == edgeItemMap.end()) { @@ -1931,7 +1931,7 @@ QUuid SkeletonGraphicsWidget::querySkeletonItemPartId(QGraphicsItem *item) { if (item->data(0) == "node") { SkeletonGraphicsNodeItem *nodeItem = (SkeletonGraphicsNodeItem *)item; - const SkeletonNode *node = m_document->findNode(nodeItem->id()); + const Node *node = m_document->findNode(nodeItem->id()); if (!node) { qDebug() << "Find node id failed:" << nodeItem->id(); return QUuid(); @@ -1939,7 +1939,7 @@ QUuid SkeletonGraphicsWidget::querySkeletonItemPartId(QGraphicsItem *item) return node->partId; } else if (item->data(0) == "edge") { SkeletonGraphicsEdgeItem *edgeItem = (SkeletonGraphicsEdgeItem *)item; - const SkeletonEdge *edge = m_document->findEdge(edgeItem->id()); + const Edge *edge = m_document->findEdge(edgeItem->id()); if (!edge) { qDebug() << "Find edge id failed:" << edgeItem->id(); return QUuid(); @@ -2081,7 +2081,7 @@ void SkeletonGraphicsWidget::selectPartAllById(QUuid partId) unselectAll(); for (const auto &it: nodeItemMap) { SkeletonGraphicsNodeItem *item = it.second.first; - const SkeletonNode *node = m_document->findNode(item->id()); + const Node *node = m_document->findNode(item->id()); if (!node) continue; if (node->partId != partId) @@ -2090,7 +2090,7 @@ void SkeletonGraphicsWidget::selectPartAllById(QUuid partId) } for (const auto &it: edgeItemMap) { SkeletonGraphicsEdgeItem *item = it.second.first; - const SkeletonEdge *edge = m_document->findEdge(item->id()); + const Edge *edge = m_document->findEdge(item->id()); if (!edge) continue; if (edge->partId != partId) @@ -2133,7 +2133,7 @@ void SkeletonGraphicsWidget::addPartToSelection(QUuid partId) QUuid choosenPartId = partId; for (const auto &it: nodeItemMap) { SkeletonGraphicsNodeItem *item = SkeletonProfile::Main == choosenProfile ? it.second.first : it.second.second; - const SkeletonNode *node = m_document->findNode(item->id()); + const Node *node = m_document->findNode(item->id()); if (!node) continue; if (choosenPartId.isNull()) { @@ -2145,7 +2145,7 @@ void SkeletonGraphicsWidget::addPartToSelection(QUuid partId) } for (const auto &it: edgeItemMap) { SkeletonGraphicsEdgeItem *item = SkeletonProfile::Main == choosenProfile ? it.second.first : it.second.second; - const SkeletonEdge *edge = m_document->findEdge(item->id()); + const Edge *edge = m_document->findEdge(item->id()); if (!edge) continue; if (choosenPartId.isNull()) { @@ -2164,18 +2164,18 @@ void SkeletonGraphicsWidget::selectPartAll() QUuid choosenPartId; if (m_hoveredNodeItem) { choosenProfile = m_hoveredNodeItem->profile(); - const SkeletonNode *node = m_document->findNode(m_hoveredNodeItem->id()); + const Node *node = m_document->findNode(m_hoveredNodeItem->id()); if (node) choosenPartId = node->partId; } else if (m_hoveredEdgeItem) { choosenProfile = m_hoveredEdgeItem->profile(); - const SkeletonEdge *edge = m_document->findEdge(m_hoveredEdgeItem->id()); + const Edge *edge = m_document->findEdge(m_hoveredEdgeItem->id()); if (edge) choosenPartId = edge->partId; } for (const auto &it: nodeItemMap) { SkeletonGraphicsNodeItem *item = SkeletonProfile::Main == choosenProfile ? it.second.first : it.second.second; - const SkeletonNode *node = m_document->findNode(item->id()); + const Node *node = m_document->findNode(item->id()); if (!node) continue; if (choosenPartId.isNull()) { @@ -2187,7 +2187,7 @@ void SkeletonGraphicsWidget::selectPartAll() } for (const auto &it: edgeItemMap) { SkeletonGraphicsEdgeItem *item = SkeletonProfile::Main == choosenProfile ? it.second.first : it.second.second; - const SkeletonEdge *edge = m_document->findEdge(item->id()); + const Edge *edge = m_document->findEdge(item->id()); if (!edge) continue; if (choosenPartId.isNull()) { @@ -2253,8 +2253,8 @@ void SkeletonGraphicsWidget::copy() readSkeletonNodeAndEdgeIdSetFromRangeSelection(&nodeIdSet, &edgeIdSet); if (nodeIdSet.empty()) return; - SkeletonSnapshot snapshot; - m_document->toSnapshot(&snapshot, nodeIdSet, SkeletonDocumentToSnapshotFor::Nodes); + Snapshot snapshot; + m_document->toSnapshot(&snapshot, nodeIdSet, DocumentToSnapshotFor::Nodes); QString snapshotXml; QXmlStreamWriter xmlStreamWriter(&snapshotXml); saveSkeletonToXmlStream(&snapshot, &xmlStreamWriter); @@ -2449,7 +2449,7 @@ void SkeletonGraphicsWidget::ikMove(QUuid endEffectorId, QVector3D target) thread->start(); } -void SkeletonGraphicsWidget::setSelectedNodesBoneMark(SkeletonBoneMark boneMark) +void SkeletonGraphicsWidget::setSelectedNodesBoneMark(BoneMark boneMark) { std::set nodeIdSet; std::set edgeIdSet; diff --git a/src/skeletongraphicswidget.h b/src/skeletongraphicswidget.h index 9ac2f396..9daf4ada 100644 --- a/src/skeletongraphicswidget.h +++ b/src/skeletongraphicswidget.h @@ -1,5 +1,5 @@ -#ifndef SKELETON_GRAPHICS_VIEW_H -#define SKELETON_GRAPHICS_VIEW_H +#ifndef DUST3D_SKELETON_GRAPHICS_VIEW_H +#define DUST3D_SKELETON_GRAPHICS_VIEW_H #include #include #include @@ -12,10 +12,10 @@ #include #include #include -#include "skeletondocument.h" +#include "document.h" #include "turnaroundloader.h" #include "theme.h" -#include "dust3dutil.h" +#include "util.h" #include "skeletonikmover.h" #include "modelwidget.h" @@ -345,7 +345,7 @@ signals: void scaleNodeByAddRadius(QUuid nodeId, float amount); void moveNodeBy(QUuid nodeId, float x, float y, float z); void removeNode(QUuid nodeId); - void setEditMode(SkeletonDocumentEditMode mode); + void setEditMode(DocumentEditMode mode); void removeEdge(QUuid edgeId); void addEdge(QUuid fromNodeId, QUuid toNodeId); void cursorChanged(); @@ -374,13 +374,13 @@ signals: void setYlockState(bool locked); void setZlockState(bool locked); void setNodeOrigin(QUuid nodeId, float x, float y, float z); - void setNodeBoneMark(QUuid nodeId, SkeletonBoneMark mark); + void setNodeBoneMark(QUuid nodeId, BoneMark mark); void zoomRenderedModelBy(float delta); void switchNodeXZ(QUuid nodeId); void enableAllPositionRelatedLocks(); void disableAllPositionRelatedLocks(); public: - SkeletonGraphicsWidget(const SkeletonDocument *document); + SkeletonGraphicsWidget(const Document *document); std::map> nodeItemMap; std::map> edgeItemMap; bool mouseMove(QMouseEvent *event); @@ -461,7 +461,7 @@ public slots: void disableBackgroundBlur(); void ikMove(QUuid endEffectorId, QVector3D target); void ikMoveReady(); - void setSelectedNodesBoneMark(SkeletonBoneMark boneMark); + void setSelectedNodesBoneMark(BoneMark boneMark); void timeToRemoveDeferredNodesAndEdges(); void switchSelectedXZ(); void shortcutDelete(); @@ -522,7 +522,7 @@ private: void rotateItems(const std::set &nodeItems, int degree, QVector2D center); void rotateAllSideProfile(int degree); private: //need initalize - const SkeletonDocument *m_document; + const Document *m_document; QGraphicsPixmapItem *m_backgroundItem; bool m_turnaroundChanged; TurnaroundLoader *m_turnaroundLoader; @@ -551,7 +551,7 @@ private: //need initalize bool m_eventForwardingToModelWidget; ModelWidget *m_modelWidget; bool m_inTempDragMode; - SkeletonDocumentEditMode m_modeBeforeEnterTempDragMode; + DocumentEditMode m_modeBeforeEnterTempDragMode; private: QVector3D m_ikMoveTarget; QUuid m_ikMoveEndEffectorId; diff --git a/src/skeletonikmover.h b/src/skeletonikmover.h index bcb5a207..7fc26ab4 100644 --- a/src/skeletonikmover.h +++ b/src/skeletonikmover.h @@ -1,5 +1,5 @@ -#ifndef SKELETON_IK_MOVER_H -#define SKELETON_IK_MOVER_H +#ifndef DUST3D_SKELETON_IK_MOVER_H +#define DUST3D_SKELETON_IK_MOVER_H #include #include #include diff --git a/src/skeletonside.cpp b/src/skeletonside.cpp new file mode 100644 index 00000000..908f60a7 --- /dev/null +++ b/src/skeletonside.cpp @@ -0,0 +1,4 @@ +#include +#include "skeletonside.h" + +IMPL_SkeletonSideToDispName diff --git a/src/skeletonside.h b/src/skeletonside.h new file mode 100644 index 00000000..344954c5 --- /dev/null +++ b/src/skeletonside.h @@ -0,0 +1,28 @@ +#ifndef DUST3D_SKELETON_SIDE_H +#define DUST3D_SKELETON_SIDE_H +#include + +enum class SkeletonSide +{ + None = 0, + Left, + Right +}; + +QString SkeletonSideToDispName(SkeletonSide side); +#define IMPL_SkeletonSideToDispName \ +QString SkeletonSideToDispName(SkeletonSide side) \ +{ \ + switch (side) { \ + case SkeletonSide::Left: \ + return QObject::tr("Left"); \ + case SkeletonSide::Right: \ + return QObject::tr("Right"); \ + case SkeletonSide::None: \ + return ""; \ + default: \ + return ""; \ + } \ +} + +#endif diff --git a/src/skeletonxml.h b/src/skeletonxml.h deleted file mode 100644 index 5c9ff78e..00000000 --- a/src/skeletonxml.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef SKELETON_XML_H -#define SKELETON_XML_H -#include -#include "skeletonsnapshot.h" - -void saveSkeletonToXmlStream(SkeletonSnapshot *snapshot, QXmlStreamWriter *writer); -void loadSkeletonFromXmlStream(SkeletonSnapshot *snapshot, QXmlStreamReader &reader); - -#endif diff --git a/src/skinnedmeshcreator.cpp b/src/skinnedmeshcreator.cpp index f7eb0566..9b021f65 100644 --- a/src/skinnedmeshcreator.cpp +++ b/src/skinnedmeshcreator.cpp @@ -1,17 +1,17 @@ #include "skinnedmeshcreator.h" -SkinnedMeshCreator::SkinnedMeshCreator(const MeshResultContext &meshResultContext, +SkinnedMeshCreator::SkinnedMeshCreator(const Outcome &outcome, const std::map &resultWeights) : - m_meshResultContext(meshResultContext), + m_outcome(outcome), m_resultWeights(resultWeights) { - for (const auto &vertex: m_meshResultContext.vertices) { + for (const auto &vertex: m_outcome.vertices) { m_verticesBindPositions.push_back(vertex.position); } - m_verticesBindNormals.resize(m_meshResultContext.vertices.size()); - for (size_t triangleIndex = 0; triangleIndex < m_meshResultContext.triangles.size(); triangleIndex++) { - const auto &sourceTriangle = m_meshResultContext.triangles[triangleIndex]; + m_verticesBindNormals.resize(m_outcome.vertices.size()); + for (size_t triangleIndex = 0; triangleIndex < m_outcome.triangles.size(); triangleIndex++) { + const auto &sourceTriangle = m_outcome.triangles[triangleIndex]; for (int i = 0; i < 3; i++) m_verticesBindNormals[sourceTriangle.indicies[i]] += sourceTriangle.normal; } @@ -41,11 +41,11 @@ MeshLoader *SkinnedMeshCreator::createMeshFromTransform(const std::vector #include #include #include "meshloader.h" -#include "meshresultcontext.h" +#include "outcome.h" #include "jointnodetree.h" class SkinnedMeshCreator { public: - SkinnedMeshCreator(const MeshResultContext &meshResultContext, + SkinnedMeshCreator(const Outcome &outcome, const std::map &resultWeights); MeshLoader *createMeshFromTransform(const std::vector &matricies); private: - MeshResultContext m_meshResultContext; + Outcome m_outcome; std::map m_resultWeights; std::vector m_verticesBindPositions; std::vector m_verticesBindNormals; diff --git a/src/skeletonsnapshot.cpp b/src/snapshot.cpp similarity index 92% rename from src/skeletonsnapshot.cpp rename to src/snapshot.cpp index 8d046392..68aa9cbd 100644 --- a/src/skeletonsnapshot.cpp +++ b/src/snapshot.cpp @@ -1,8 +1,8 @@ #include -#include "skeletonsnapshot.h" -#include "dust3dutil.h" +#include "snapshot.h" +#include "util.h" -void SkeletonSnapshot::resolveBoundingBox(QRectF *mainProfile, QRectF *sideProfile, const QString &partId) +void Snapshot::resolveBoundingBox(QRectF *mainProfile, QRectF *sideProfile, const QString &partId) { float left = 0; bool leftFirstTime = true; diff --git a/src/skeletonsnapshot.h b/src/snapshot.h similarity index 93% rename from src/skeletonsnapshot.h rename to src/snapshot.h index 6fbd8997..bc0b6ca7 100644 --- a/src/skeletonsnapshot.h +++ b/src/snapshot.h @@ -1,12 +1,12 @@ -#ifndef SKELETON_SNAPSHOT_H -#define SKELETON_SNAPSHOT_H +#ifndef DUST3D_SNAPSHOT_H +#define DUST3D_SNAPSHOT_H #include #include #include #include #include -class SkeletonSnapshot +class Snapshot { public: std::map canvas; diff --git a/src/skeletonxml.cpp b/src/snapshotxml.cpp similarity index 98% rename from src/skeletonxml.cpp rename to src/snapshotxml.cpp index 67357654..e227743b 100644 --- a/src/skeletonxml.cpp +++ b/src/snapshotxml.cpp @@ -1,9 +1,9 @@ #include #include #include -#include "skeletonxml.h" +#include "snapshotxml.h" -static void saveSkeletonComponent(SkeletonSnapshot *snapshot, QXmlStreamWriter *writer, const QString &componentId) +static void saveSkeletonComponent(Snapshot *snapshot, QXmlStreamWriter *writer, const QString &componentId) { const auto findComponent = snapshot->components.find(componentId); if (findComponent == snapshot->components.end()) @@ -31,7 +31,7 @@ static void saveSkeletonComponent(SkeletonSnapshot *snapshot, QXmlStreamWriter * writer->writeEndElement(); } -void saveSkeletonToXmlStream(SkeletonSnapshot *snapshot, QXmlStreamWriter *writer) +void saveSkeletonToXmlStream(Snapshot *snapshot, QXmlStreamWriter *writer) { writer->setAutoFormatting(true); writer->writeStartDocument(); @@ -182,7 +182,7 @@ void saveSkeletonToXmlStream(SkeletonSnapshot *snapshot, QXmlStreamWriter *write writer->writeEndDocument(); } -void loadSkeletonFromXmlStream(SkeletonSnapshot *snapshot, QXmlStreamReader &reader) +void loadSkeletonFromXmlStream(Snapshot *snapshot, QXmlStreamReader &reader) { std::stack componentStack; std::vector elementNameStack; diff --git a/src/snapshotxml.h b/src/snapshotxml.h new file mode 100644 index 00000000..155ec64f --- /dev/null +++ b/src/snapshotxml.h @@ -0,0 +1,9 @@ +#ifndef DUST3D_SNAPSHOT_XML_H +#define DUST3D_SNAPSHOT_XML_H +#include +#include "snapshot.h" + +void saveSkeletonToXmlStream(Snapshot *snapshot, QXmlStreamWriter *writer); +void loadSkeletonFromXmlStream(Snapshot *snapshot, QXmlStreamReader &reader); + +#endif diff --git a/src/spinnableawesomebutton.h b/src/spinnableawesomebutton.h index 6e665904..2171a6ca 100644 --- a/src/spinnableawesomebutton.h +++ b/src/spinnableawesomebutton.h @@ -1,5 +1,5 @@ -#ifndef SPINNABLE_AWESOME_BUTTON_H -#define SPINNABLE_AWESOME_BUTTON_H +#ifndef DUST3D_SPINNABLE_AWESOME_BUTTON_H +#define DUST3D_SPINNABLE_AWESOME_BUTTON_H #include #include #include "waitingspinnerwidget.h" diff --git a/src/tabwidget.h b/src/tabwidget.h index 2e8d7c2b..2514ceb9 100644 --- a/src/tabwidget.h +++ b/src/tabwidget.h @@ -1,5 +1,5 @@ -#ifndef TAB_WIDGET_H -#define TAB_WIDGET_H +#ifndef DUST3D_TAB_WIDGET_H +#define DUST3D_TAB_WIDGET_H #include #include #include diff --git a/src/tetrapodposer.h b/src/tetrapodposer.h index 18219615..e5cf65a4 100644 --- a/src/tetrapodposer.h +++ b/src/tetrapodposer.h @@ -1,5 +1,5 @@ -#ifndef TETRAPOD_POSER_H -#define TETRAPOD_POSER_H +#ifndef DUST3D_TETRAPOD_POSER_H +#define DUST3D_TETRAPOD_POSER_H #include "poser.h" class TetrapodPoser : public Poser diff --git a/src/texturegenerator.cpp b/src/texturegenerator.cpp index b8bf2e69..7505ff66 100644 --- a/src/texturegenerator.cpp +++ b/src/texturegenerator.cpp @@ -5,11 +5,11 @@ #include #include "texturegenerator.h" #include "theme.h" -#include "dust3dutil.h" +#include "util.h" int TextureGenerator::m_textureSize = 1024; -TextureGenerator::TextureGenerator(const MeshResultContext &meshResultContext, SkeletonSnapshot *snapshot) : +TextureGenerator::TextureGenerator(const Outcome &outcome, Snapshot *snapshot) : m_resultTextureGuideImage(nullptr), m_resultTextureImage(nullptr), m_resultTextureBorderImage(nullptr), @@ -22,13 +22,13 @@ TextureGenerator::TextureGenerator(const MeshResultContext &meshResultContext, S m_resultMesh(nullptr), m_snapshot(snapshot) { - m_resultContext = new MeshResultContext(); - *m_resultContext = meshResultContext; + m_outcome = new Outcome(); + *m_outcome = outcome; } TextureGenerator::~TextureGenerator() { - delete m_resultContext; + delete m_outcome; delete m_resultTextureGuideImage; delete m_resultTextureImage; delete m_resultTextureBorderImage; @@ -77,11 +77,11 @@ QImage *TextureGenerator::takeResultTextureNormalImage() return resultTextureNormalImage; } -MeshResultContext *TextureGenerator::takeResultContext() +Outcome *TextureGenerator::takeResultContext() { - MeshResultContext *resultContext = m_resultContext; + Outcome *outcome = m_outcome; m_resultTextureImage = nullptr; - return resultContext; + return outcome; } MeshLoader *TextureGenerator::takeResultMesh() @@ -148,7 +148,7 @@ void TextureGenerator::prepare() QUuid partId = QUuid(partIt.first); updatedMaterialIdMap.insert({partId, materialId}); } - for (const auto &bmeshNode: m_resultContext->bmeshNodes) { + for (const auto &bmeshNode: m_outcome->bmeshNodes) { for (size_t i = 0; i < (int)TextureType::Count - 1; ++i) { TextureType forWhat = (TextureType)(i + 1); MaterialTextures materialTextures; @@ -186,8 +186,8 @@ void TextureGenerator::generate() bool hasRoughnessMap = false; bool hasAmbientOcclusionMap = false; - const std::vector &triangleMaterials = m_resultContext->triangleMaterials(); - const std::vector &triangleUvs = m_resultContext->triangleUvs(); + const std::vector &triangleMaterials = m_outcome->triangleMaterials(); + const std::vector &triangleUvs = m_outcome->triangleUvs(); auto createImageBeginTime = countTimeConsumed.elapsed(); @@ -251,7 +251,7 @@ void TextureGenerator::generate() texturePainter.setPen(Qt::NoPen); for (auto i = 0u; i < triangleUvs.size(); i++) { QPainterPath path; - const ResultTriangleUv *uv = &triangleUvs[i]; + const OutcomeTriangleUv *uv = &triangleUvs[i]; float points[][2] = { {uv->uv[0][0] * TextureGenerator::m_textureSize, uv->uv[0][1] * TextureGenerator::m_textureSize}, {uv->uv[1][0] * TextureGenerator::m_textureSize, uv->uv[1][1] * TextureGenerator::m_textureSize}, @@ -262,7 +262,7 @@ void TextureGenerator::generate() path.lineTo(points[2][0], points[2][1]); path = expandedPainterPath(path); // Copy color texture if there is one - const std::pair source = m_resultContext->triangleSourceNodes()[i]; + const std::pair source = m_outcome->triangleSourceNodes()[i]; auto findColorTextureResult = m_partColorTextureMap.find(source.first); if (findColorTextureResult != m_partColorTextureMap.end()) { texturePainter.setClipping(true); @@ -315,7 +315,7 @@ void TextureGenerator::generate() textureBorderPainter.setPen(pen); auto paintBorderBeginTime = countTimeConsumed.elapsed(); for (auto i = 0u; i < triangleUvs.size(); i++) { - const ResultTriangleUv *uv = &triangleUvs[i]; + const OutcomeTriangleUv *uv = &triangleUvs[i]; for (auto j = 0; j < 3; j++) { int from = j; int to = (j + 1) % 3; @@ -366,7 +366,7 @@ void TextureGenerator::generate() mergeTextureGuidePainter.end(); auto createResultBeginTime = countTimeConsumed.elapsed(); - m_resultMesh = new MeshLoader(*m_resultContext); + m_resultMesh = new MeshLoader(*m_outcome); m_resultMesh->setTextureImage(new QImage(*m_resultTextureImage)); if (nullptr != m_resultTextureNormalImage) m_resultMesh->setNormalMapImage(new QImage(*m_resultTextureNormalImage)); diff --git a/src/texturegenerator.h b/src/texturegenerator.h index 801e803e..9effcfa5 100644 --- a/src/texturegenerator.h +++ b/src/texturegenerator.h @@ -1,23 +1,23 @@ -#ifndef TEXTURE_GENERATOR_H -#define TEXTURE_GENERATOR_H +#ifndef DUST3D_TEXTURE_GENERATOR_H +#define DUST3D_TEXTURE_GENERATOR_H #include #include #include -#include "meshresultcontext.h" +#include "outcome.h" #include "meshloader.h" class TextureGenerator : public QObject { Q_OBJECT public: - TextureGenerator(const MeshResultContext &meshResultContext, SkeletonSnapshot *snapshot=nullptr); + TextureGenerator(const Outcome &outcome, Snapshot *snapshot=nullptr); ~TextureGenerator(); QImage *takeResultTextureGuideImage(); QImage *takeResultTextureImage(); QImage *takeResultTextureBorderImage(); QImage *takeResultTextureColorImage(); QImage *takeResultTextureNormalImage(); - MeshResultContext *takeResultContext(); + Outcome *takeResultContext(); MeshLoader *takeResultMesh(); void addPartColorMap(QUuid partId, const QImage *image); void addPartNormalMap(QUuid partId, const QImage *image); @@ -35,7 +35,7 @@ private: void prepare(); QPainterPath expandedPainterPath(const QPainterPath &painterPath, int expandSize=7); private: - MeshResultContext *m_resultContext; + Outcome *m_outcome; QImage *m_resultTextureGuideImage; QImage *m_resultTextureImage; QImage *m_resultTextureBorderImage; @@ -51,7 +51,7 @@ private: std::map m_partMetalnessTextureMap; std::map m_partRoughnessTextureMap; std::map m_partAmbientOcclusionTextureMap; - SkeletonSnapshot *m_snapshot; + Snapshot *m_snapshot; }; #endif diff --git a/src/texturetype.h b/src/texturetype.h index 1883cafd..a6b543ca 100644 --- a/src/texturetype.h +++ b/src/texturetype.h @@ -1,5 +1,5 @@ -#ifndef TEXTURE_TYPE_H -#define TEXTURE_TYPE_H +#ifndef DUST3D_TEXTURE_TYPE_H +#define DUST3D_TEXTURE_TYPE_H #include #include #include diff --git a/src/theme.h b/src/theme.h index 7f9f1cc2..30351182 100644 --- a/src/theme.h +++ b/src/theme.h @@ -1,5 +1,5 @@ -#ifndef THEME_H -#define THEME_H +#ifndef DUST3D_THEME_H +#define DUST3D_THEME_H #include #include #include diff --git a/src/turnaroundloader.h b/src/turnaroundloader.h index dae0a6fd..b837d83e 100644 --- a/src/turnaroundloader.h +++ b/src/turnaroundloader.h @@ -1,5 +1,5 @@ -#ifndef TURNAROUND_LOADER_H -#define TURNAROUND_LOADER_H +#ifndef DUST3D_TURNAROUND_LOADER_H +#define DUST3D_TURNAROUND_LOADER_H #include #include #include diff --git a/src/dust3dutil.cpp b/src/util.cpp similarity index 99% rename from src/dust3dutil.cpp rename to src/util.cpp index 9806dbf8..59759dac 100644 --- a/src/dust3dutil.cpp +++ b/src/util.cpp @@ -1,5 +1,5 @@ #include -#include "dust3dutil.h" +#include "util.h" #include "version.h" QString valueOfKeyInMapOrEmpty(const std::map &map, const QString &key) diff --git a/src/dust3dutil.h b/src/util.h similarity index 100% rename from src/dust3dutil.h rename to src/util.h diff --git a/src/version.h b/src/version.h index b7365c34..e0f900a2 100644 --- a/src/version.h +++ b/src/version.h @@ -1,5 +1,5 @@ -#ifndef VERSION_H -#define VERSION_H +#ifndef DUST3D_VERSION_H +#define DUST3D_VERSION_H #define APP_COMPANY PROJECT_DEFINED_APP_COMPANY #define APP_NAME PROJECT_DEFINED_APP_NAME