2018-04-07 08:44:39 +00:00
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QToolBar>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QTabWidget>
|
2018-04-10 07:59:20 +00:00
|
|
|
#include <QBuffer>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QMenuBar>
|
|
|
|
#include <QPointer>
|
|
|
|
#include <QApplication>
|
|
|
|
#include <set>
|
|
|
|
#include <QDesktopServices>
|
2018-05-10 09:16:22 +00:00
|
|
|
#include <QDockWidget>
|
2018-10-25 00:19:38 +00:00
|
|
|
#include "documentwindow.h"
|
2018-04-07 08:44:39 +00:00
|
|
|
#include "skeletongraphicswidget.h"
|
|
|
|
#include "theme.h"
|
2018-04-10 07:59:20 +00:00
|
|
|
#include "ds3file.h"
|
2018-10-25 00:19:38 +00:00
|
|
|
#include "snapshot.h"
|
|
|
|
#include "snapshotxml.h"
|
2018-04-10 07:59:20 +00:00
|
|
|
#include "logbrowser.h"
|
2018-10-25 00:19:38 +00:00
|
|
|
#include "util.h"
|
2018-04-10 07:59:20 +00:00
|
|
|
#include "aboutwidget.h"
|
2018-04-11 08:34:51 +00:00
|
|
|
#include "version.h"
|
2018-10-25 09:18:04 +00:00
|
|
|
#include "glbfile.h"
|
2018-08-27 08:50:40 +00:00
|
|
|
#include "graphicscontainerwidget.h"
|
2018-10-25 00:19:38 +00:00
|
|
|
#include "parttreewidget.h"
|
2018-09-14 09:45:05 +00:00
|
|
|
#include "rigwidget.h"
|
|
|
|
#include "markiconcreator.h"
|
2018-10-02 04:59:30 +00:00
|
|
|
#include "motionmanagewidget.h"
|
2018-10-09 02:19:12 +00:00
|
|
|
#include "materialmanagewidget.h"
|
|
|
|
#include "imageforever.h"
|
|
|
|
#include "spinnableawesomebutton.h"
|
2018-10-20 05:07:11 +00:00
|
|
|
#include "fbxfile.h"
|
2018-10-24 13:44:21 +00:00
|
|
|
#include "shortcuts.h"
|
2018-04-30 11:31:09 +00:00
|
|
|
|
|
|
|
int SkeletonDocumentWindow::m_modelRenderWidgetInitialX = 16;
|
|
|
|
int SkeletonDocumentWindow::m_modelRenderWidgetInitialY = 16;
|
|
|
|
int SkeletonDocumentWindow::m_modelRenderWidgetInitialSize = 128;
|
|
|
|
int SkeletonDocumentWindow::m_skeletonRenderWidgetInitialX = SkeletonDocumentWindow::m_modelRenderWidgetInitialX + SkeletonDocumentWindow::m_modelRenderWidgetInitialSize + 16;
|
|
|
|
int SkeletonDocumentWindow::m_skeletonRenderWidgetInitialY = SkeletonDocumentWindow::m_modelRenderWidgetInitialY;
|
|
|
|
int SkeletonDocumentWindow::m_skeletonRenderWidgetInitialSize = SkeletonDocumentWindow::m_modelRenderWidgetInitialSize;
|
2018-04-10 07:59:20 +00:00
|
|
|
|
2018-06-27 00:19:14 +00:00
|
|
|
LogBrowser *g_logBrowser = nullptr;
|
2018-04-10 07:59:20 +00:00
|
|
|
std::set<SkeletonDocumentWindow *> g_documentWindows;
|
|
|
|
QTextBrowser *g_acknowlegementsWidget = nullptr;
|
|
|
|
AboutWidget *g_aboutWidget = nullptr;
|
2018-08-27 08:50:40 +00:00
|
|
|
QTextBrowser *g_contributorsWidget = nullptr;
|
2018-04-10 07:59:20 +00:00
|
|
|
|
|
|
|
void outputMessage(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
|
|
|
{
|
|
|
|
if (g_logBrowser)
|
2018-05-12 10:07:46 +00:00
|
|
|
g_logBrowser->outputMessage(type, msg, context.file, context.line);
|
2018-04-10 07:59:20 +00:00
|
|
|
}
|
|
|
|
|
2018-05-07 16:08:19 +00:00
|
|
|
void SkeletonDocumentWindow::showAcknowlegements()
|
2018-04-10 07:59:20 +00:00
|
|
|
{
|
|
|
|
if (!g_acknowlegementsWidget) {
|
|
|
|
g_acknowlegementsWidget = new QTextBrowser;
|
2018-09-21 07:10:18 +00:00
|
|
|
g_acknowlegementsWidget->setWindowTitle(unifiedWindowTitle(tr("Acknowlegements")));
|
2018-04-10 07:59:20 +00:00
|
|
|
g_acknowlegementsWidget->setMinimumSize(QSize(400, 300));
|
|
|
|
QFile file(":/ACKNOWLEDGEMENTS.html");
|
|
|
|
file.open(QFile::ReadOnly | QFile::Text);
|
|
|
|
QTextStream stream(&file);
|
|
|
|
g_acknowlegementsWidget->setHtml(stream.readAll());
|
|
|
|
}
|
|
|
|
g_acknowlegementsWidget->show();
|
|
|
|
g_acknowlegementsWidget->activateWindow();
|
|
|
|
g_acknowlegementsWidget->raise();
|
|
|
|
}
|
|
|
|
|
2018-08-27 08:50:40 +00:00
|
|
|
void SkeletonDocumentWindow::showContributors()
|
|
|
|
{
|
|
|
|
if (!g_contributorsWidget) {
|
|
|
|
g_contributorsWidget = new QTextBrowser;
|
2018-09-21 07:10:18 +00:00
|
|
|
g_contributorsWidget->setWindowTitle(unifiedWindowTitle(tr("Contributors")));
|
2018-08-27 08:50:40 +00:00
|
|
|
g_contributorsWidget->setMinimumSize(QSize(400, 300));
|
|
|
|
QFile authors(":/AUTHORS");
|
|
|
|
authors.open(QFile::ReadOnly | QFile::Text);
|
|
|
|
QFile contributors(":/CONTRIBUTORS");
|
|
|
|
contributors.open(QFile::ReadOnly | QFile::Text);
|
|
|
|
g_contributorsWidget->setHtml("<h1>AUTHORS</h1><pre>" + authors.readAll() + "</pre><h1>CONTRIBUTORS</h1><pre>" + contributors.readAll() + "</pre>");
|
|
|
|
}
|
|
|
|
g_contributorsWidget->show();
|
|
|
|
g_contributorsWidget->activateWindow();
|
|
|
|
g_contributorsWidget->raise();
|
|
|
|
}
|
|
|
|
|
2018-05-07 16:08:19 +00:00
|
|
|
void SkeletonDocumentWindow::showAbout()
|
2018-04-10 07:59:20 +00:00
|
|
|
{
|
|
|
|
if (!g_aboutWidget) {
|
|
|
|
g_aboutWidget = new AboutWidget;
|
|
|
|
}
|
|
|
|
g_aboutWidget->show();
|
|
|
|
g_aboutWidget->activateWindow();
|
|
|
|
g_aboutWidget->raise();
|
|
|
|
}
|
2018-04-07 08:44:39 +00:00
|
|
|
|
|
|
|
SkeletonDocumentWindow::SkeletonDocumentWindow() :
|
|
|
|
m_document(nullptr),
|
2018-04-10 07:59:20 +00:00
|
|
|
m_firstShow(true),
|
2018-05-07 16:08:19 +00:00
|
|
|
m_documentSaved(true),
|
2018-09-22 10:31:02 +00:00
|
|
|
m_exportPreviewWidget(nullptr),
|
|
|
|
m_advanceSettingWidget(nullptr)
|
2018-04-07 08:44:39 +00:00
|
|
|
{
|
2018-04-10 07:59:20 +00:00
|
|
|
if (!g_logBrowser) {
|
|
|
|
g_logBrowser = new LogBrowser;
|
|
|
|
qInstallMessageHandler(&outputMessage);
|
|
|
|
}
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
g_documentWindows.insert(this);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
m_document = new Document;
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
QVBoxLayout *toolButtonLayout = new QVBoxLayout;
|
|
|
|
toolButtonLayout->setSpacing(0);
|
|
|
|
toolButtonLayout->setContentsMargins(5, 10, 4, 0);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
QPushButton *addButton = new QPushButton(QChar(fa::plus));
|
2018-08-27 08:50:40 +00:00
|
|
|
Theme::initAwesomeButton(addButton);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
QPushButton *selectButton = new QPushButton(QChar(fa::mousepointer));
|
2018-08-27 08:50:40 +00:00
|
|
|
Theme::initAwesomeButton(selectButton);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
QPushButton *dragButton = new QPushButton(QChar(fa::handrocko));
|
2018-08-27 08:50:40 +00:00
|
|
|
Theme::initAwesomeButton(dragButton);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
QPushButton *zoomInButton = new QPushButton(QChar(fa::searchplus));
|
2018-08-27 08:50:40 +00:00
|
|
|
Theme::initAwesomeButton(zoomInButton);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
QPushButton *zoomOutButton = new QPushButton(QChar(fa::searchminus));
|
2018-08-27 08:50:40 +00:00
|
|
|
Theme::initAwesomeButton(zoomOutButton);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-16 22:54:41 +00:00
|
|
|
m_xlockButton = new QPushButton(QChar('X'));
|
|
|
|
initLockButton(m_xlockButton);
|
|
|
|
updateXlockButtonState();
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-16 22:54:41 +00:00
|
|
|
m_ylockButton = new QPushButton(QChar('Y'));
|
|
|
|
initLockButton(m_ylockButton);
|
|
|
|
updateYlockButtonState();
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-16 22:54:41 +00:00
|
|
|
m_zlockButton = new QPushButton(QChar('Z'));
|
|
|
|
initLockButton(m_zlockButton);
|
|
|
|
updateZlockButtonState();
|
2018-09-03 07:05:05 +00:00
|
|
|
|
2018-09-08 04:20:31 +00:00
|
|
|
m_radiusLockButton = new QPushButton(QChar(fa::bullseye));
|
|
|
|
Theme::initAwesomeButton(m_radiusLockButton);
|
|
|
|
updateRadiusLockButtonState();
|
|
|
|
|
2018-09-03 07:05:05 +00:00
|
|
|
QPushButton *rotateCounterclockwiseButton = new QPushButton(QChar(fa::rotateleft));
|
|
|
|
Theme::initAwesomeButton(rotateCounterclockwiseButton);
|
|
|
|
|
|
|
|
QPushButton *rotateClockwiseButton = new QPushButton(QChar(fa::rotateright));
|
|
|
|
Theme::initAwesomeButton(rotateClockwiseButton);
|
2018-10-09 02:19:12 +00:00
|
|
|
|
|
|
|
SpinnableAwesomeButton *regenerateButton = new SpinnableAwesomeButton();
|
|
|
|
regenerateButton->setAwesomeIcon(QChar(fa::recycle));
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_document, &Document::meshGenerating, this, [=]() {
|
2018-10-09 02:19:12 +00:00
|
|
|
regenerateButton->showSpinner(true);
|
|
|
|
});
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_document, &Document::postProcessing, this, [=]() {
|
2018-10-09 02:19:12 +00:00
|
|
|
regenerateButton->showSpinner(true);
|
|
|
|
});
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_document, &Document::textureGenerating, this, [=]() {
|
2018-10-09 02:19:12 +00:00
|
|
|
regenerateButton->showSpinner(true);
|
|
|
|
});
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_document, &Document::resultTextureChanged, this, [=]() {
|
2018-10-09 02:19:12 +00:00
|
|
|
regenerateButton->showSpinner(false);
|
|
|
|
});
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(regenerateButton->button(), &QPushButton::clicked, m_document, &Document::regenerateMesh);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
toolButtonLayout->addWidget(addButton);
|
|
|
|
toolButtonLayout->addWidget(selectButton);
|
|
|
|
toolButtonLayout->addWidget(dragButton);
|
|
|
|
toolButtonLayout->addWidget(zoomInButton);
|
|
|
|
toolButtonLayout->addWidget(zoomOutButton);
|
2018-04-16 22:54:41 +00:00
|
|
|
toolButtonLayout->addSpacing(10);
|
|
|
|
toolButtonLayout->addWidget(m_xlockButton);
|
|
|
|
toolButtonLayout->addWidget(m_ylockButton);
|
|
|
|
toolButtonLayout->addWidget(m_zlockButton);
|
2018-09-08 04:20:31 +00:00
|
|
|
toolButtonLayout->addWidget(m_radiusLockButton);
|
2018-09-03 07:05:05 +00:00
|
|
|
toolButtonLayout->addSpacing(10);
|
|
|
|
toolButtonLayout->addWidget(rotateCounterclockwiseButton);
|
|
|
|
toolButtonLayout->addWidget(rotateClockwiseButton);
|
2018-10-15 15:02:31 +00:00
|
|
|
toolButtonLayout->addSpacing(10);
|
|
|
|
toolButtonLayout->addWidget(regenerateButton);
|
2018-10-09 02:19:12 +00:00
|
|
|
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
QLabel *verticalLogoLabel = new QLabel;
|
|
|
|
QImage verticalLogoImage;
|
2018-08-27 08:50:40 +00:00
|
|
|
verticalLogoImage.load(":/resources/dust3d-vertical.png");
|
2018-04-10 07:59:20 +00:00
|
|
|
verticalLogoLabel->setPixmap(QPixmap::fromImage(verticalLogoImage));
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
QHBoxLayout *logoLayout = new QHBoxLayout;
|
2018-04-10 07:59:20 +00:00
|
|
|
logoLayout->addWidget(verticalLogoLabel);
|
2018-04-07 08:44:39 +00:00
|
|
|
logoLayout->setContentsMargins(0, 0, 0, 0);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
QVBoxLayout *mainLeftLayout = new QVBoxLayout;
|
|
|
|
mainLeftLayout->setSpacing(0);
|
|
|
|
mainLeftLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
mainLeftLayout->addLayout(toolButtonLayout);
|
|
|
|
mainLeftLayout->addStretch();
|
|
|
|
mainLeftLayout->addLayout(logoLayout);
|
|
|
|
mainLeftLayout->addSpacing(10);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
SkeletonGraphicsWidget *graphicsWidget = new SkeletonGraphicsWidget(m_document);
|
2018-04-10 07:59:20 +00:00
|
|
|
m_graphicsWidget = graphicsWidget;
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-08-27 08:50:40 +00:00
|
|
|
GraphicsContainerWidget *containerWidget = new GraphicsContainerWidget;
|
2018-04-07 08:44:39 +00:00
|
|
|
containerWidget->setGraphicsWidget(graphicsWidget);
|
|
|
|
QGridLayout *containerLayout = new QGridLayout;
|
|
|
|
containerLayout->setSpacing(0);
|
|
|
|
containerLayout->setContentsMargins(1, 0, 0, 0);
|
|
|
|
containerLayout->addWidget(graphicsWidget);
|
|
|
|
containerWidget->setLayout(containerLayout);
|
|
|
|
containerWidget->setMinimumSize(400, 400);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-30 11:31:09 +00:00
|
|
|
m_modelRenderWidget = new ModelWidget(containerWidget);
|
2018-10-25 07:03:51 +00:00
|
|
|
m_modelRenderWidget->setAttribute(Qt::WA_TransparentForMouseEvents);
|
2018-04-30 11:31:09 +00:00
|
|
|
m_modelRenderWidget->setMinimumSize(SkeletonDocumentWindow::m_modelRenderWidgetInitialSize, SkeletonDocumentWindow::m_modelRenderWidgetInitialSize);
|
|
|
|
m_modelRenderWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
|
|
|
m_modelRenderWidget->move(SkeletonDocumentWindow::m_modelRenderWidgetInitialX, SkeletonDocumentWindow::m_modelRenderWidgetInitialY);
|
2018-10-24 08:54:18 +00:00
|
|
|
|
|
|
|
m_graphicsWidget->setModelWidget(m_modelRenderWidget);
|
2018-10-25 07:03:51 +00:00
|
|
|
containerWidget->setModelWidget(m_modelRenderWidget);
|
2018-08-27 08:50:40 +00:00
|
|
|
|
|
|
|
m_document->setSharedContextWidget(m_modelRenderWidget);
|
2018-09-01 00:47:10 +00:00
|
|
|
|
2018-09-14 09:45:05 +00:00
|
|
|
setTabPosition(Qt::RightDockWidgetArea, QTabWidget::East);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-09-14 09:45:05 +00:00
|
|
|
QDockWidget *partTreeDocker = new QDockWidget(tr("Parts"), this);
|
|
|
|
partTreeDocker->setAllowedAreas(Qt::RightDockWidgetArea);
|
2018-10-25 00:19:38 +00:00
|
|
|
PartTreeWidget *partTreeWidget = new PartTreeWidget(m_document, partTreeDocker);
|
2018-09-14 09:45:05 +00:00
|
|
|
partTreeDocker->setWidget(partTreeWidget);
|
|
|
|
addDockWidget(Qt::RightDockWidgetArea, partTreeDocker);
|
2018-09-18 14:23:28 +00:00
|
|
|
connect(partTreeDocker, &QDockWidget::topLevelChanged, [=](bool topLevel) {
|
|
|
|
Q_UNUSED(topLevel);
|
|
|
|
for (const auto &part: m_document->partMap)
|
|
|
|
partTreeWidget->partPreviewChanged(part.first);
|
|
|
|
});
|
2018-09-14 09:45:05 +00:00
|
|
|
|
2018-10-09 02:19:12 +00:00
|
|
|
QDockWidget *materialDocker = new QDockWidget(tr("Materials"), this);
|
|
|
|
materialDocker->setAllowedAreas(Qt::RightDockWidgetArea);
|
|
|
|
MaterialManageWidget *materialManageWidget = new MaterialManageWidget(m_document, materialDocker);
|
|
|
|
materialDocker->setWidget(materialManageWidget);
|
|
|
|
connect(materialManageWidget, &MaterialManageWidget::registerDialog, this, &SkeletonDocumentWindow::registerDialog);
|
|
|
|
connect(materialManageWidget, &MaterialManageWidget::unregisterDialog, this, &SkeletonDocumentWindow::unregisterDialog);
|
|
|
|
addDockWidget(Qt::RightDockWidgetArea, materialDocker);
|
|
|
|
connect(materialDocker, &QDockWidget::topLevelChanged, [=](bool topLevel) {
|
|
|
|
Q_UNUSED(topLevel);
|
|
|
|
for (const auto &material: m_document->materialMap)
|
|
|
|
emit m_document->materialPreviewChanged(material.first);
|
|
|
|
});
|
|
|
|
|
2018-09-14 09:45:05 +00:00
|
|
|
QDockWidget *rigDocker = new QDockWidget(tr("Rig"), this);
|
|
|
|
rigDocker->setAllowedAreas(Qt::RightDockWidgetArea);
|
2018-09-18 14:23:28 +00:00
|
|
|
m_rigWidget = new RigWidget(m_document, rigDocker);
|
|
|
|
rigDocker->setWidget(m_rigWidget);
|
2018-09-14 09:45:05 +00:00
|
|
|
addDockWidget(Qt::RightDockWidgetArea, rigDocker);
|
2018-09-18 14:23:28 +00:00
|
|
|
connect(rigDocker, &QDockWidget::topLevelChanged, [=](bool topLevel) {
|
|
|
|
Q_UNUSED(topLevel);
|
|
|
|
updateRigWeightRenderWidget();
|
|
|
|
});
|
2018-09-14 09:45:05 +00:00
|
|
|
|
2018-09-21 07:10:18 +00:00
|
|
|
QDockWidget *poseDocker = new QDockWidget(tr("Poses"), this);
|
|
|
|
poseDocker->setAllowedAreas(Qt::RightDockWidgetArea);
|
|
|
|
PoseManageWidget *poseManageWidget = new PoseManageWidget(m_document, poseDocker);
|
|
|
|
poseDocker->setWidget(poseManageWidget);
|
|
|
|
connect(poseManageWidget, &PoseManageWidget::registerDialog, this, &SkeletonDocumentWindow::registerDialog);
|
|
|
|
connect(poseManageWidget, &PoseManageWidget::unregisterDialog, this, &SkeletonDocumentWindow::unregisterDialog);
|
|
|
|
addDockWidget(Qt::RightDockWidgetArea, poseDocker);
|
|
|
|
connect(poseDocker, &QDockWidget::topLevelChanged, [=](bool topLevel) {
|
|
|
|
Q_UNUSED(topLevel);
|
|
|
|
for (const auto &pose: m_document->poseMap)
|
|
|
|
emit m_document->posePreviewChanged(pose.first);
|
|
|
|
});
|
2018-09-18 03:17:35 +00:00
|
|
|
|
2018-10-02 04:59:30 +00:00
|
|
|
QDockWidget *motionDocker = new QDockWidget(tr("Motions"), this);
|
|
|
|
motionDocker->setAllowedAreas(Qt::RightDockWidgetArea);
|
|
|
|
MotionManageWidget *motionManageWidget = new MotionManageWidget(m_document, motionDocker);
|
|
|
|
motionDocker->setWidget(motionManageWidget);
|
|
|
|
connect(motionManageWidget, &MotionManageWidget::registerDialog, this, &SkeletonDocumentWindow::registerDialog);
|
|
|
|
connect(motionManageWidget, &MotionManageWidget::unregisterDialog, this, &SkeletonDocumentWindow::unregisterDialog);
|
|
|
|
addDockWidget(Qt::RightDockWidgetArea, motionDocker);
|
|
|
|
|
2018-10-09 02:19:12 +00:00
|
|
|
tabifyDockWidget(partTreeDocker, materialDocker);
|
|
|
|
tabifyDockWidget(materialDocker, rigDocker);
|
2018-09-21 07:10:18 +00:00
|
|
|
tabifyDockWidget(rigDocker, poseDocker);
|
2018-10-02 04:59:30 +00:00
|
|
|
tabifyDockWidget(poseDocker, motionDocker);
|
2018-09-14 09:45:05 +00:00
|
|
|
|
|
|
|
partTreeDocker->raise();
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
QHBoxLayout *mainLayout = new QHBoxLayout;
|
|
|
|
mainLayout->setSpacing(0);
|
|
|
|
mainLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
mainLayout->addLayout(mainLeftLayout);
|
|
|
|
mainLayout->addWidget(containerWidget);
|
2018-05-10 09:16:22 +00:00
|
|
|
mainLayout->addSpacing(3);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
QWidget *centralWidget = new QWidget;
|
|
|
|
centralWidget->setLayout(mainLayout);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
setCentralWidget(centralWidget);
|
2018-08-27 08:50:40 +00:00
|
|
|
setWindowTitle(APP_NAME);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_fileMenu = menuBar()->addMenu(tr("File"));
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_newWindowAction = new QAction(tr("New Window"), this);
|
2018-04-17 13:13:32 +00:00
|
|
|
connect(m_newWindowAction, &QAction::triggered, this, &SkeletonDocumentWindow::newWindow, Qt::QueuedConnection);
|
2018-04-10 07:59:20 +00:00
|
|
|
m_fileMenu->addAction(m_newWindowAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_newDocumentAction = new QAction(tr("New"), this);
|
|
|
|
connect(m_newDocumentAction, &QAction::triggered, this, &SkeletonDocumentWindow::newDocument);
|
|
|
|
m_fileMenu->addAction(m_newDocumentAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_openAction = new QAction(tr("Open..."), this);
|
2018-04-17 13:13:32 +00:00
|
|
|
connect(m_openAction, &QAction::triggered, this, &SkeletonDocumentWindow::open, Qt::QueuedConnection);
|
2018-04-10 07:59:20 +00:00
|
|
|
m_fileMenu->addAction(m_openAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_saveAction = new QAction(tr("Save"), this);
|
2018-04-17 13:13:32 +00:00
|
|
|
connect(m_saveAction, &QAction::triggered, this, &SkeletonDocumentWindow::save, Qt::QueuedConnection);
|
2018-04-10 07:59:20 +00:00
|
|
|
m_fileMenu->addAction(m_saveAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_saveAsAction = new QAction(tr("Save As..."), this);
|
2018-04-17 13:13:32 +00:00
|
|
|
connect(m_saveAsAction, &QAction::triggered, this, &SkeletonDocumentWindow::saveAs, Qt::QueuedConnection);
|
2018-04-10 07:59:20 +00:00
|
|
|
m_fileMenu->addAction(m_saveAsAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_saveAllAction = new QAction(tr("Save All"), this);
|
2018-04-17 13:13:32 +00:00
|
|
|
connect(m_saveAllAction, &QAction::triggered, this, &SkeletonDocumentWindow::saveAll, Qt::QueuedConnection);
|
2018-04-10 07:59:20 +00:00
|
|
|
m_fileMenu->addAction(m_saveAllAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_fileMenu->addSeparator();
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-09-14 09:45:05 +00:00
|
|
|
//m_exportMenu = m_fileMenu->addMenu(tr("Export"));
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-09-14 09:45:05 +00:00
|
|
|
m_exportAction = new QAction(tr("Export..."), this);
|
|
|
|
connect(m_exportAction, &QAction::triggered, this, &SkeletonDocumentWindow::showExportPreview, Qt::QueuedConnection);
|
|
|
|
m_fileMenu->addAction(m_exportAction);
|
|
|
|
|
|
|
|
m_exportAsObjAction = new QAction(tr("Export as OBJ..."), this);
|
2018-09-05 03:14:36 +00:00
|
|
|
connect(m_exportAsObjAction, &QAction::triggered, this, &SkeletonDocumentWindow::exportObjResult, Qt::QueuedConnection);
|
2018-09-14 09:45:05 +00:00
|
|
|
m_fileMenu->addAction(m_exportAsObjAction);
|
2018-09-05 03:14:36 +00:00
|
|
|
|
2018-09-14 09:45:05 +00:00
|
|
|
//m_exportRenderedAsImageAction = new QAction(tr("Export as PNG..."), this);
|
|
|
|
//connect(m_exportRenderedAsImageAction, &QAction::triggered, this, &SkeletonDocumentWindow::exportRenderedResult, Qt::QueuedConnection);
|
|
|
|
//m_fileMenu->addAction(m_exportRenderedAsImageAction);
|
|
|
|
|
|
|
|
//m_exportAsObjPlusMaterialsAction = new QAction(tr("Wavefront (.obj + .mtl)..."), this);
|
|
|
|
//connect(m_exportAsObjPlusMaterialsAction, &QAction::triggered, this, &SkeletonDocumentWindow::exportObjPlusMaterialsResult, Qt::QueuedConnection);
|
|
|
|
//m_exportMenu->addAction(m_exportAsObjPlusMaterialsAction);
|
2018-08-27 08:50:40 +00:00
|
|
|
|
|
|
|
m_fileMenu->addSeparator();
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-08-27 08:50:40 +00:00
|
|
|
m_changeTurnaroundAction = new QAction(tr("Change Reference Sheet..."), this);
|
2018-04-17 13:13:32 +00:00
|
|
|
connect(m_changeTurnaroundAction, &QAction::triggered, this, &SkeletonDocumentWindow::changeTurnaround, Qt::QueuedConnection);
|
2018-04-10 07:59:20 +00:00
|
|
|
m_fileMenu->addAction(m_changeTurnaroundAction);
|
2018-08-27 08:50:40 +00:00
|
|
|
|
|
|
|
m_fileMenu->addSeparator();
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
connect(m_fileMenu, &QMenu::aboutToShow, [=]() {
|
2018-09-05 03:14:36 +00:00
|
|
|
m_exportAsObjAction->setEnabled(m_graphicsWidget->hasItems());
|
2018-09-14 09:45:05 +00:00
|
|
|
//m_exportAsObjPlusMaterialsAction->setEnabled(m_graphicsWidget->hasItems());
|
|
|
|
m_exportAction->setEnabled(m_graphicsWidget->hasItems());
|
|
|
|
//m_exportRenderedAsImageAction->setEnabled(m_graphicsWidget->hasItems());
|
2018-04-10 07:59:20 +00:00
|
|
|
});
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_editMenu = menuBar()->addMenu(tr("Edit"));
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_addAction = new QAction(tr("Add..."), this);
|
|
|
|
connect(m_addAction, &QAction::triggered, [=]() {
|
2018-10-25 00:19:38 +00:00
|
|
|
m_document->setEditMode(DocumentEditMode::Add);
|
2018-04-10 07:59:20 +00:00
|
|
|
});
|
|
|
|
m_editMenu->addAction(m_addAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_undoAction = new QAction(tr("Undo"), this);
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_undoAction, &QAction::triggered, m_document, &Document::undo);
|
2018-04-10 07:59:20 +00:00
|
|
|
m_editMenu->addAction(m_undoAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_redoAction = new QAction(tr("Redo"), this);
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_redoAction, &QAction::triggered, m_document, &Document::redo);
|
2018-04-10 07:59:20 +00:00
|
|
|
m_editMenu->addAction(m_redoAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_deleteAction = new QAction(tr("Delete"), this);
|
|
|
|
connect(m_deleteAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::deleteSelected);
|
|
|
|
m_editMenu->addAction(m_deleteAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-12 12:27:21 +00:00
|
|
|
m_breakAction = new QAction(tr("Break"), this);
|
|
|
|
connect(m_breakAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::breakSelected);
|
|
|
|
m_editMenu->addAction(m_breakAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-12 12:46:13 +00:00
|
|
|
m_connectAction = new QAction(tr("Connect"), this);
|
|
|
|
connect(m_connectAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::connectSelected);
|
|
|
|
m_editMenu->addAction(m_connectAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_cutAction = new QAction(tr("Cut"), this);
|
|
|
|
connect(m_cutAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::cut);
|
|
|
|
m_editMenu->addAction(m_cutAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_copyAction = new QAction(tr("Copy"), this);
|
|
|
|
connect(m_copyAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::copy);
|
|
|
|
m_editMenu->addAction(m_copyAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_pasteAction = new QAction(tr("Paste"), this);
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_pasteAction, &QAction::triggered, m_document, &Document::paste);
|
2018-04-10 07:59:20 +00:00
|
|
|
m_editMenu->addAction(m_pasteAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_flipHorizontallyAction = new QAction(tr("H Flip"), this);
|
|
|
|
connect(m_flipHorizontallyAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::flipHorizontally);
|
|
|
|
m_editMenu->addAction(m_flipHorizontallyAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_flipVerticallyAction = new QAction(tr("V Flip"), this);
|
|
|
|
connect(m_flipVerticallyAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::flipVertically);
|
|
|
|
m_editMenu->addAction(m_flipVerticallyAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-06-15 14:54:19 +00:00
|
|
|
m_rotateClockwiseAction = new QAction(tr("Rotate 90D CW"), this);
|
2018-06-15 09:58:46 +00:00
|
|
|
connect(m_rotateClockwiseAction, &QAction::triggered, [=] {
|
|
|
|
m_graphicsWidget->rotateClockwise90Degree();
|
|
|
|
});
|
|
|
|
m_editMenu->addAction(m_rotateClockwiseAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-06-15 14:54:19 +00:00
|
|
|
m_rotateCounterclockwiseAction = new QAction(tr("Rotate 90D CCW"), this);
|
2018-06-15 09:58:46 +00:00
|
|
|
connect(m_rotateCounterclockwiseAction, &QAction::triggered, [=] {
|
|
|
|
m_graphicsWidget->rotateCounterclockwise90Degree();
|
|
|
|
});
|
|
|
|
m_editMenu->addAction(m_rotateCounterclockwiseAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-06-21 08:24:18 +00:00
|
|
|
m_switchXzAction = new QAction(tr("Switch XZ"), this);
|
|
|
|
connect(m_switchXzAction, &QAction::triggered, [=] {
|
|
|
|
m_graphicsWidget->switchSelectedXZ();
|
|
|
|
});
|
|
|
|
m_editMenu->addAction(m_switchXzAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-06-02 09:34:48 +00:00
|
|
|
m_alignToMenu = new QMenu(tr("Align To"));
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-06-02 09:34:48 +00:00
|
|
|
m_alignToLocalCenterAction = new QAction(tr("Local Center"), this);
|
|
|
|
connect(m_alignToLocalCenterAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::alignSelectedToLocalCenter);
|
|
|
|
m_alignToMenu->addAction(m_alignToLocalCenterAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-06-02 09:34:48 +00:00
|
|
|
m_alignToLocalVerticalCenterAction = new QAction(tr("Local Vertical Center"), this);
|
|
|
|
connect(m_alignToLocalVerticalCenterAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::alignSelectedToLocalVerticalCenter);
|
|
|
|
m_alignToMenu->addAction(m_alignToLocalVerticalCenterAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-06-02 09:34:48 +00:00
|
|
|
m_alignToLocalHorizontalCenterAction = new QAction(tr("Local Horizontal Center"), this);
|
|
|
|
connect(m_alignToLocalHorizontalCenterAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::alignSelectedToLocalHorizontalCenter);
|
|
|
|
m_alignToMenu->addAction(m_alignToLocalHorizontalCenterAction);
|
2018-08-27 08:50:40 +00:00
|
|
|
|
|
|
|
m_alignToGlobalCenterAction = new QAction(tr("Global Center"), this);
|
|
|
|
connect(m_alignToGlobalCenterAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::alignSelectedToGlobalCenter);
|
|
|
|
m_alignToMenu->addAction(m_alignToGlobalCenterAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-08-27 08:50:40 +00:00
|
|
|
m_alignToGlobalVerticalCenterAction = new QAction(tr("Global Vertical Center"), this);
|
|
|
|
connect(m_alignToGlobalVerticalCenterAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::alignSelectedToGlobalVerticalCenter);
|
|
|
|
m_alignToMenu->addAction(m_alignToGlobalVerticalCenterAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-08-27 08:50:40 +00:00
|
|
|
m_alignToGlobalHorizontalCenterAction = new QAction(tr("Global Horizontal Center"), this);
|
|
|
|
connect(m_alignToGlobalHorizontalCenterAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::alignSelectedToGlobalHorizontalCenter);
|
|
|
|
m_alignToMenu->addAction(m_alignToGlobalHorizontalCenterAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-08-27 08:50:40 +00:00
|
|
|
m_editMenu->addMenu(m_alignToMenu);
|
2018-09-14 09:45:05 +00:00
|
|
|
|
|
|
|
m_markAsMenu = new QMenu(tr("Mark As"));
|
|
|
|
|
|
|
|
m_markAsNoneAction = new QAction(tr("None"), this);
|
|
|
|
connect(m_markAsNoneAction, &QAction::triggered, [=]() {
|
2018-10-25 00:19:38 +00:00
|
|
|
m_graphicsWidget->setSelectedNodesBoneMark(BoneMark::None);
|
2018-09-14 09:45:05 +00:00
|
|
|
});
|
|
|
|
m_markAsMenu->addAction(m_markAsNoneAction);
|
|
|
|
|
|
|
|
m_markAsMenu->addSeparator();
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
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);
|
2018-09-14 09:45:05 +00:00
|
|
|
connect(m_markAsActions[i], &QAction::triggered, [=]() {
|
|
|
|
m_graphicsWidget->setSelectedNodesBoneMark(boneMark);
|
|
|
|
});
|
|
|
|
m_markAsMenu->addAction(m_markAsActions[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_editMenu->addMenu(m_markAsMenu);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_selectAllAction = new QAction(tr("Select All"), this);
|
|
|
|
connect(m_selectAllAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::selectAll);
|
|
|
|
m_editMenu->addAction(m_selectAllAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_selectPartAllAction = new QAction(tr("Select Part"), this);
|
|
|
|
connect(m_selectPartAllAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::selectPartAll);
|
|
|
|
m_editMenu->addAction(m_selectPartAllAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_unselectAllAction = new QAction(tr("Unselect All"), this);
|
|
|
|
connect(m_unselectAllAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::unselectAll);
|
|
|
|
m_editMenu->addAction(m_unselectAllAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
connect(m_editMenu, &QMenu::aboutToShow, [=]() {
|
|
|
|
m_undoAction->setEnabled(m_document->undoable());
|
|
|
|
m_redoAction->setEnabled(m_document->redoable());
|
|
|
|
m_deleteAction->setEnabled(m_graphicsWidget->hasSelection());
|
2018-04-12 12:27:21 +00:00
|
|
|
m_breakAction->setEnabled(m_graphicsWidget->hasEdgeSelection());
|
2018-04-12 12:46:13 +00:00
|
|
|
m_connectAction->setEnabled(m_graphicsWidget->hasTwoDisconnectedNodesSelection());
|
2018-04-10 07:59:20 +00:00
|
|
|
m_cutAction->setEnabled(m_graphicsWidget->hasSelection());
|
|
|
|
m_copyAction->setEnabled(m_graphicsWidget->hasSelection());
|
2018-09-21 07:10:18 +00:00
|
|
|
m_pasteAction->setEnabled(m_document->hasPastableNodesInClipboard());
|
2018-04-10 07:59:20 +00:00
|
|
|
m_flipHorizontallyAction->setEnabled(m_graphicsWidget->hasMultipleSelection());
|
|
|
|
m_flipVerticallyAction->setEnabled(m_graphicsWidget->hasMultipleSelection());
|
2018-06-15 09:58:46 +00:00
|
|
|
m_rotateClockwiseAction->setEnabled(m_graphicsWidget->hasMultipleSelection());
|
|
|
|
m_rotateCounterclockwiseAction->setEnabled(m_graphicsWidget->hasMultipleSelection());
|
2018-06-21 08:24:18 +00:00
|
|
|
m_switchXzAction->setEnabled(m_graphicsWidget->hasSelection());
|
2018-06-02 09:34:48 +00:00
|
|
|
m_alignToGlobalCenterAction->setEnabled(m_graphicsWidget->hasSelection() && m_document->originSettled());
|
|
|
|
m_alignToGlobalVerticalCenterAction->setEnabled(m_graphicsWidget->hasSelection() && m_document->originSettled());
|
|
|
|
m_alignToGlobalHorizontalCenterAction->setEnabled(m_graphicsWidget->hasSelection() && m_document->originSettled());
|
|
|
|
m_alignToLocalCenterAction->setEnabled(m_graphicsWidget->hasMultipleSelection());
|
|
|
|
m_alignToLocalVerticalCenterAction->setEnabled(m_graphicsWidget->hasMultipleSelection());
|
|
|
|
m_alignToLocalHorizontalCenterAction->setEnabled(m_graphicsWidget->hasMultipleSelection());
|
|
|
|
m_alignToMenu->setEnabled((m_graphicsWidget->hasSelection() && m_document->originSettled()) || m_graphicsWidget->hasMultipleSelection());
|
2018-04-10 07:59:20 +00:00
|
|
|
m_selectAllAction->setEnabled(m_graphicsWidget->hasItems());
|
|
|
|
m_selectPartAllAction->setEnabled(m_graphicsWidget->hasItems());
|
|
|
|
m_unselectAllAction->setEnabled(m_graphicsWidget->hasSelection());
|
|
|
|
});
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_viewMenu = menuBar()->addMenu(tr("View"));
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-08-27 08:50:40 +00:00
|
|
|
auto isModelSitInVisibleArea = [](ModelWidget *modelWidget) {
|
2018-05-10 09:16:22 +00:00
|
|
|
QRect parentRect = QRect(QPoint(0, 0), modelWidget->parentWidget()->size());
|
|
|
|
return parentRect.contains(modelWidget->geometry().center());
|
|
|
|
};
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_resetModelWidgetPosAction = new QAction(tr("Show Model"), this);
|
|
|
|
connect(m_resetModelWidgetPosAction, &QAction::triggered, [=]() {
|
2018-08-27 08:50:40 +00:00
|
|
|
if (!isModelSitInVisibleArea(m_modelRenderWidget)) {
|
2018-04-30 11:31:09 +00:00
|
|
|
m_modelRenderWidget->move(SkeletonDocumentWindow::m_modelRenderWidgetInitialX, SkeletonDocumentWindow::m_modelRenderWidgetInitialY);
|
2018-04-10 07:59:20 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
m_viewMenu->addAction(m_resetModelWidgetPosAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-10-09 02:19:12 +00:00
|
|
|
//m_toggleWireframeAction = new QAction(tr("Toggle Wireframe"), this);
|
|
|
|
//connect(m_toggleWireframeAction, &QAction::triggered, [=]() {
|
|
|
|
// m_modelRenderWidget->toggleWireframe();
|
|
|
|
//});
|
|
|
|
//m_viewMenu->addAction(m_toggleWireframeAction);
|
2018-09-07 12:51:33 +00:00
|
|
|
|
2018-10-09 02:19:12 +00:00
|
|
|
//m_toggleSmoothNormalAction = new QAction(tr("Toggle Smooth Normal"), this);
|
|
|
|
//connect(m_toggleSmoothNormalAction, &QAction::triggered, [=]() {
|
|
|
|
// m_document->toggleSmoothNormal();
|
|
|
|
//});
|
|
|
|
//m_viewMenu->addAction(m_toggleSmoothNormalAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-05-10 09:16:22 +00:00
|
|
|
connect(m_viewMenu, &QMenu::aboutToShow, [=]() {
|
2018-08-27 08:50:40 +00:00
|
|
|
m_resetModelWidgetPosAction->setEnabled(!isModelSitInVisibleArea(m_modelRenderWidget));
|
2018-05-10 09:16:22 +00:00
|
|
|
});
|
2018-09-14 09:45:05 +00:00
|
|
|
|
|
|
|
m_windowMenu = menuBar()->addMenu(tr("Window"));
|
|
|
|
|
|
|
|
m_showPartsListAction = new QAction(tr("Parts"), this);
|
|
|
|
connect(m_showPartsListAction, &QAction::triggered, [=]() {
|
|
|
|
partTreeDocker->show();
|
|
|
|
partTreeDocker->raise();
|
|
|
|
});
|
|
|
|
m_windowMenu->addAction(m_showPartsListAction);
|
|
|
|
|
2018-10-09 02:19:12 +00:00
|
|
|
m_showMaterialsAction = new QAction(tr("Materials"), this);
|
|
|
|
connect(m_showMaterialsAction, &QAction::triggered, [=]() {
|
|
|
|
materialDocker->show();
|
|
|
|
materialDocker->raise();
|
|
|
|
});
|
|
|
|
m_windowMenu->addAction(m_showMaterialsAction);
|
|
|
|
|
2018-09-14 09:45:05 +00:00
|
|
|
m_showRigAction = new QAction(tr("Rig"), this);
|
|
|
|
connect(m_showRigAction, &QAction::triggered, [=]() {
|
|
|
|
rigDocker->show();
|
|
|
|
rigDocker->raise();
|
|
|
|
});
|
|
|
|
m_windowMenu->addAction(m_showRigAction);
|
|
|
|
|
2018-09-21 08:14:37 +00:00
|
|
|
m_showPosesAction = new QAction(tr("Poses"), this);
|
|
|
|
connect(m_showPosesAction, &QAction::triggered, [=]() {
|
|
|
|
poseDocker->show();
|
|
|
|
poseDocker->raise();
|
|
|
|
});
|
|
|
|
m_windowMenu->addAction(m_showPosesAction);
|
|
|
|
|
2018-10-02 04:59:30 +00:00
|
|
|
m_showMotionsAction = new QAction(tr("Motions"), this);
|
|
|
|
connect(m_showMotionsAction, &QAction::triggered, [=]() {
|
|
|
|
motionDocker->show();
|
|
|
|
motionDocker->raise();
|
|
|
|
});
|
|
|
|
m_windowMenu->addAction(m_showMotionsAction);
|
|
|
|
|
2018-09-21 07:10:18 +00:00
|
|
|
QMenu *dialogsMenu = m_windowMenu->addMenu(tr("Dialogs"));
|
|
|
|
connect(dialogsMenu, &QMenu::aboutToShow, [=]() {
|
|
|
|
dialogsMenu->clear();
|
|
|
|
if (this->m_dialogs.empty()) {
|
|
|
|
QAction *action = dialogsMenu->addAction(tr("None"));
|
|
|
|
action->setEnabled(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (const auto &dialog: this->m_dialogs) {
|
|
|
|
QAction *action = dialogsMenu->addAction(dialog->windowTitle());
|
|
|
|
connect(action, &QAction::triggered, [=]() {
|
|
|
|
dialog->show();
|
|
|
|
dialog->raise();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2018-09-18 03:17:35 +00:00
|
|
|
|
2018-09-14 09:45:05 +00:00
|
|
|
m_showDebugDialogAction = new QAction(tr("Debug"), this);
|
|
|
|
connect(m_showDebugDialogAction, &QAction::triggered, g_logBrowser, &LogBrowser::showDialog);
|
|
|
|
m_windowMenu->addAction(m_showDebugDialogAction);
|
2018-09-22 10:31:02 +00:00
|
|
|
|
|
|
|
m_showAdvanceSettingAction = new QAction(tr("Advance"), this);
|
|
|
|
connect(m_showAdvanceSettingAction, &QAction::triggered, this, &SkeletonDocumentWindow::showAdvanceSetting);
|
|
|
|
#ifndef NDEBUG
|
|
|
|
m_windowMenu->addAction(m_showAdvanceSettingAction);
|
|
|
|
#endif
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_helpMenu = menuBar()->addMenu(tr("Help"));
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_viewSourceAction = new QAction(tr("Fork me on GitHub"), this);
|
|
|
|
connect(m_viewSourceAction, &QAction::triggered, this, &SkeletonDocumentWindow::viewSource);
|
|
|
|
m_helpMenu->addAction(m_viewSourceAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_helpMenu->addSeparator();
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-18 13:18:10 +00:00
|
|
|
m_seeReferenceGuideAction = new QAction(tr("Reference Guide"), this);
|
|
|
|
connect(m_seeReferenceGuideAction, &QAction::triggered, this, &SkeletonDocumentWindow::seeReferenceGuide);
|
|
|
|
m_helpMenu->addAction(m_seeReferenceGuideAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-18 13:18:10 +00:00
|
|
|
m_helpMenu->addSeparator();
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_aboutAction = new QAction(tr("About"), this);
|
|
|
|
connect(m_aboutAction, &QAction::triggered, this, &SkeletonDocumentWindow::about);
|
|
|
|
m_helpMenu->addAction(m_aboutAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_reportIssuesAction = new QAction(tr("Report Issues"), this);
|
|
|
|
connect(m_reportIssuesAction, &QAction::triggered, this, &SkeletonDocumentWindow::reportIssues);
|
|
|
|
m_helpMenu->addAction(m_reportIssuesAction);
|
2018-08-27 08:50:40 +00:00
|
|
|
|
|
|
|
m_helpMenu->addSeparator();
|
|
|
|
|
|
|
|
m_seeContributorsAction = new QAction(tr("Contributors"), this);
|
|
|
|
connect(m_seeContributorsAction, &QAction::triggered, this, &SkeletonDocumentWindow::seeContributors);
|
|
|
|
m_helpMenu->addAction(m_seeContributorsAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
m_seeAcknowlegementsAction = new QAction(tr("Acknowlegements"), this);
|
|
|
|
connect(m_seeAcknowlegementsAction, &QAction::triggered, this, &SkeletonDocumentWindow::seeAcknowlegements);
|
|
|
|
m_helpMenu->addAction(m_seeAcknowlegementsAction);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-08-27 08:50:40 +00:00
|
|
|
connect(containerWidget, &GraphicsContainerWidget::containerSizeChanged,
|
2018-04-07 08:44:39 +00:00
|
|
|
graphicsWidget, &SkeletonGraphicsWidget::canvasResized);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_document, &Document::turnaroundChanged,
|
2018-04-07 08:44:39 +00:00
|
|
|
graphicsWidget, &SkeletonGraphicsWidget::turnaroundChanged);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-09-03 07:05:05 +00:00
|
|
|
connect(rotateCounterclockwiseButton, &QPushButton::clicked, graphicsWidget, &SkeletonGraphicsWidget::rotateAllMainProfileCounterclockwise90DegreeAlongOrigin);
|
|
|
|
connect(rotateClockwiseButton, &QPushButton::clicked, graphicsWidget, &SkeletonGraphicsWidget::rotateAllMainProfileClockwise90DegreeAlongOrigin);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
connect(addButton, &QPushButton::clicked, [=]() {
|
2018-10-25 00:19:38 +00:00
|
|
|
m_document->setEditMode(DocumentEditMode::Add);
|
2018-04-07 08:44:39 +00:00
|
|
|
});
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
connect(selectButton, &QPushButton::clicked, [=]() {
|
2018-10-25 00:19:38 +00:00
|
|
|
m_document->setEditMode(DocumentEditMode::Select);
|
2018-04-07 08:44:39 +00:00
|
|
|
});
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
connect(dragButton, &QPushButton::clicked, [=]() {
|
2018-10-25 00:19:38 +00:00
|
|
|
m_document->setEditMode(DocumentEditMode::Drag);
|
2018-04-07 08:44:39 +00:00
|
|
|
});
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
connect(zoomInButton, &QPushButton::clicked, [=]() {
|
2018-10-25 00:19:38 +00:00
|
|
|
m_document->setEditMode(DocumentEditMode::ZoomIn);
|
2018-04-07 08:44:39 +00:00
|
|
|
});
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
connect(zoomOutButton, &QPushButton::clicked, [=]() {
|
2018-10-25 00:19:38 +00:00
|
|
|
m_document->setEditMode(DocumentEditMode::ZoomOut);
|
2018-04-07 08:44:39 +00:00
|
|
|
});
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-16 22:54:41 +00:00
|
|
|
connect(m_xlockButton, &QPushButton::clicked, [=]() {
|
|
|
|
m_document->setXlockState(!m_document->xlocked);
|
|
|
|
});
|
|
|
|
connect(m_ylockButton, &QPushButton::clicked, [=]() {
|
|
|
|
m_document->setYlockState(!m_document->ylocked);
|
|
|
|
});
|
|
|
|
connect(m_zlockButton, &QPushButton::clicked, [=]() {
|
|
|
|
m_document->setZlockState(!m_document->zlocked);
|
|
|
|
});
|
2018-09-08 04:20:31 +00:00
|
|
|
connect(m_radiusLockButton, &QPushButton::clicked, [=]() {
|
|
|
|
m_document->setRadiusLockState(!m_document->radiusLocked);
|
|
|
|
});
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
m_partListDockerVisibleSwitchConnection = connect(m_document, &Document::skeletonChanged, [=]() {
|
2018-05-10 09:16:22 +00:00
|
|
|
if (m_graphicsWidget->hasItems()) {
|
2018-09-14 09:45:05 +00:00
|
|
|
if (partTreeDocker->isHidden())
|
|
|
|
partTreeDocker->show();
|
2018-05-10 09:16:22 +00:00
|
|
|
disconnect(m_partListDockerVisibleSwitchConnection);
|
2018-05-07 16:08:19 +00:00
|
|
|
}
|
|
|
|
});
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_document, &Document::editModeChanged, graphicsWidget, &SkeletonGraphicsWidget::editModeChanged);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-05-24 07:08:57 +00:00
|
|
|
connect(graphicsWidget, &SkeletonGraphicsWidget::zoomRenderedModelBy, m_modelRenderWidget, &ModelWidget::zoom);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
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, &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, &Document::setXlockState);
|
|
|
|
connect(graphicsWidget, &SkeletonGraphicsWidget::setYlockState, m_document, &Document::setYlockState);
|
|
|
|
connect(graphicsWidget, &SkeletonGraphicsWidget::setZlockState, m_document, &Document::setZlockState);
|
2018-09-03 07:05:05 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(graphicsWidget, &SkeletonGraphicsWidget::enableAllPositionRelatedLocks, m_document, &Document::enableAllPositionRelatedLocks);
|
|
|
|
connect(graphicsWidget, &SkeletonGraphicsWidget::disableAllPositionRelatedLocks, m_document, &Document::disableAllPositionRelatedLocks);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
connect(graphicsWidget, &SkeletonGraphicsWidget::changeTurnaround, this, &SkeletonDocumentWindow::changeTurnaround);
|
|
|
|
connect(graphicsWidget, &SkeletonGraphicsWidget::save, this, &SkeletonDocumentWindow::save);
|
|
|
|
connect(graphicsWidget, &SkeletonGraphicsWidget::open, this, &SkeletonDocumentWindow::open);
|
2018-10-25 06:27:59 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
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);
|
2018-08-27 08:50:40 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
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);
|
2018-08-27 08:50:40 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(partTreeWidget, &PartTreeWidget::addPartToSelection, graphicsWidget, &SkeletonGraphicsWidget::addPartToSelection);
|
2018-09-01 02:17:26 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
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, &Document::skeletonChanged, m_document, &Document::generateMesh);
|
2018-10-15 15:02:31 +00:00
|
|
|
//connect(m_document, &SkeletonDocument::resultMeshChanged, [=]() {
|
|
|
|
// if ((m_exportPreviewWidget && m_exportPreviewWidget->isVisible())) {
|
|
|
|
// m_document->postProcess();
|
|
|
|
// }
|
|
|
|
//});
|
|
|
|
//connect(m_document, &SkeletonDocument::textureChanged, [=]() {
|
|
|
|
// if ((m_exportPreviewWidget && m_exportPreviewWidget->isVisible())) {
|
|
|
|
// m_document->generateTexture();
|
|
|
|
// }
|
|
|
|
//});
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_document, &Document::textureChanged, m_document, &Document::generateTexture);
|
|
|
|
connect(m_document, &Document::resultMeshChanged, m_document, &Document::postProcess);
|
2018-10-26 23:04:45 +00:00
|
|
|
connect(m_document, &Document::postProcessedResultChanged, m_document, &Document::generateRig);
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_document, &Document::rigChanged, m_document, &Document::generateRig);
|
|
|
|
connect(m_document, &Document::postProcessedResultChanged, m_document, &Document::generateTexture);
|
2018-10-09 02:19:12 +00:00
|
|
|
//connect(m_document, &SkeletonDocument::resultTextureChanged, m_document, &SkeletonDocument::bakeAmbientOcclusionTexture);
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_document, &Document::resultTextureChanged, [=]() {
|
2018-10-15 15:02:31 +00:00
|
|
|
if (m_document->isMeshGenerating())
|
|
|
|
return;
|
|
|
|
m_modelRenderWidget->updateMesh(m_document->takeResultTextureMesh());
|
|
|
|
});
|
2018-10-09 02:19:12 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_document, &Document::resultMeshChanged, [=]() {
|
2018-04-30 11:31:09 +00:00
|
|
|
m_modelRenderWidget->updateMesh(m_document->takeResultMesh());
|
|
|
|
});
|
2018-10-23 14:57:47 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_document, &Document::posesChanged, m_document, &Document::generateMotions);
|
|
|
|
connect(m_document, &Document::motionsChanged, m_document, &Document::generateMotions);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
connect(graphicsWidget, &SkeletonGraphicsWidget::cursorChanged, [=]() {
|
2018-04-30 11:31:09 +00:00
|
|
|
m_modelRenderWidget->setCursor(graphicsWidget->cursor());
|
2018-05-10 09:16:22 +00:00
|
|
|
//m_skeletonRenderWidget->setCursor(graphicsWidget->cursor());
|
2018-04-07 08:44:39 +00:00
|
|
|
});
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
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);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-30 11:31:09 +00:00
|
|
|
connect(m_modelRenderWidget, &ModelWidget::customContextMenuRequested, [=](const QPoint &pos) {
|
|
|
|
graphicsWidget->showContextMenu(graphicsWidget->mapFromGlobal(m_modelRenderWidget->mapToGlobal(pos)));
|
2018-04-11 15:06:30 +00:00
|
|
|
});
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
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);
|
2018-09-14 09:45:05 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_rigWidget, &RigWidget::setRigType, m_document, &Document::setRigType);
|
2018-09-14 09:45:05 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
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);
|
2018-09-18 03:17:35 +00:00
|
|
|
|
|
|
|
//connect(m_document, &SkeletonDocument::resultRigChanged, tetrapodPoseEditWidget, &TetrapodPoseEditWidget::updatePreview);
|
2018-09-21 07:10:18 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_document, &Document::poseAdded, this, [=](QUuid poseId) {
|
2018-09-21 07:10:18 +00:00
|
|
|
Q_UNUSED(poseId);
|
|
|
|
m_document->generatePosePreviews();
|
|
|
|
});
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_document, &Document::poseParametersChanged, this, [=](QUuid poseId) {
|
2018-09-21 07:10:18 +00:00
|
|
|
Q_UNUSED(poseId);
|
|
|
|
m_document->generatePosePreviews();
|
|
|
|
});
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_document, &Document::resultRigChanged, m_document, &Document::generatePosePreviews);
|
2018-10-09 02:19:12 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_document, &Document::resultRigChanged, m_document, &Document::generateMotions);
|
2018-10-23 14:57:47 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_document, &Document::materialAdded, this, [=](QUuid materialId) {
|
2018-10-09 02:19:12 +00:00
|
|
|
Q_UNUSED(materialId);
|
|
|
|
m_document->generateMaterialPreviews();
|
|
|
|
});
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_document, &Document::materialLayersChanged, this, [=](QUuid materialId) {
|
2018-10-09 02:19:12 +00:00
|
|
|
Q_UNUSED(materialId);
|
|
|
|
m_document->generateMaterialPreviews();
|
|
|
|
});
|
2018-10-24 13:44:21 +00:00
|
|
|
|
|
|
|
initShortCuts(this, m_graphicsWidget);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(this, &SkeletonDocumentWindow::initialized, m_document, &Document::uiReady);
|
2018-09-01 00:47:10 +00:00
|
|
|
|
|
|
|
QTimer *timer = new QTimer(this);
|
2018-09-14 09:45:05 +00:00
|
|
|
timer->setInterval(250);
|
2018-09-01 00:47:10 +00:00
|
|
|
connect(timer, &QTimer::timeout, [=] {
|
|
|
|
QWidget *focusedWidget = QApplication::focusWidget();
|
|
|
|
//qDebug() << (focusedWidget ? ("Focused on:" + QString(focusedWidget->metaObject()->className()) + " title:" + focusedWidget->windowTitle()) : "No Focus") << " isActive:" << isActiveWindow();
|
|
|
|
if (nullptr == focusedWidget && isActiveWindow())
|
|
|
|
graphicsWidget->setFocus();
|
|
|
|
});
|
|
|
|
timer->start();
|
2018-04-07 08:44:39 +00:00
|
|
|
}
|
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
SkeletonDocumentWindow *SkeletonDocumentWindow::createDocumentWindow()
|
|
|
|
{
|
|
|
|
SkeletonDocumentWindow *documentWindow = new SkeletonDocumentWindow();
|
|
|
|
documentWindow->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
documentWindow->showMaximized();
|
|
|
|
return documentWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkeletonDocumentWindow::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
|
|
|
if (m_documentSaved) {
|
|
|
|
event->accept();
|
|
|
|
return;
|
|
|
|
}
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
QMessageBox::StandardButton answer = QMessageBox::question(this,
|
|
|
|
APP_NAME,
|
|
|
|
tr("Do you really want to close while there are unsaved changes?"),
|
|
|
|
QMessageBox::Yes | QMessageBox::No);
|
|
|
|
if (answer == QMessageBox::Yes)
|
|
|
|
event->accept();
|
|
|
|
else
|
|
|
|
event->ignore();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkeletonDocumentWindow::setCurrentFilename(const QString &filename)
|
|
|
|
{
|
|
|
|
m_currentFilename = filename;
|
|
|
|
m_documentSaved = true;
|
|
|
|
updateTitle();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkeletonDocumentWindow::updateTitle()
|
|
|
|
{
|
|
|
|
QString appName = APP_NAME;
|
|
|
|
QString appVer = APP_HUMAN_VER;
|
|
|
|
setWindowTitle(QString("%1 %2 %3%4").arg(appName).arg(appVer).arg(m_currentFilename).arg(m_documentSaved ? "" : "*"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkeletonDocumentWindow::documentChanged()
|
|
|
|
{
|
|
|
|
if (m_documentSaved) {
|
|
|
|
m_documentSaved = false;
|
|
|
|
updateTitle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkeletonDocumentWindow::newWindow()
|
|
|
|
{
|
|
|
|
SkeletonDocumentWindow::createDocumentWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkeletonDocumentWindow::newDocument()
|
|
|
|
{
|
|
|
|
if (!m_documentSaved) {
|
|
|
|
QMessageBox::StandardButton answer = QMessageBox::question(this,
|
|
|
|
APP_NAME,
|
|
|
|
tr("Do you really want to create new document and lose the unsaved changes?"),
|
|
|
|
QMessageBox::Yes | QMessageBox::No);
|
|
|
|
if (answer != QMessageBox::Yes)
|
|
|
|
return;
|
|
|
|
}
|
2018-10-25 06:27:59 +00:00
|
|
|
m_document->clearHistories();
|
2018-04-10 07:59:20 +00:00
|
|
|
m_document->reset();
|
2018-10-25 06:27:59 +00:00
|
|
|
m_document->saveSnapshot();
|
2018-04-10 07:59:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SkeletonDocumentWindow::saveAs()
|
|
|
|
{
|
|
|
|
QString filename = QFileDialog::getSaveFileName(this, QString(), QString(),
|
|
|
|
tr("Dust3D Document (*.ds3)"));
|
|
|
|
if (filename.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
saveTo(filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkeletonDocumentWindow::saveAll()
|
|
|
|
{
|
|
|
|
for (auto &window: g_documentWindows) {
|
|
|
|
window->save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkeletonDocumentWindow::viewSource()
|
|
|
|
{
|
|
|
|
QString url = APP_REPOSITORY_URL;
|
|
|
|
qDebug() << "viewSource:" << url;
|
|
|
|
QDesktopServices::openUrl(QUrl(url));
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkeletonDocumentWindow::about()
|
|
|
|
{
|
|
|
|
SkeletonDocumentWindow::showAbout();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkeletonDocumentWindow::reportIssues()
|
|
|
|
{
|
|
|
|
QString url = APP_ISSUES_URL;
|
|
|
|
qDebug() << "reportIssues:" << url;
|
|
|
|
QDesktopServices::openUrl(QUrl(url));
|
|
|
|
}
|
|
|
|
|
2018-04-18 13:18:10 +00:00
|
|
|
void SkeletonDocumentWindow::seeReferenceGuide()
|
|
|
|
{
|
|
|
|
QString url = APP_REFERENCE_GUIDE_URL;
|
|
|
|
qDebug() << "referenceGuide:" << url;
|
|
|
|
QDesktopServices::openUrl(QUrl(url));
|
|
|
|
}
|
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
void SkeletonDocumentWindow::seeAcknowlegements()
|
|
|
|
{
|
|
|
|
SkeletonDocumentWindow::showAcknowlegements();
|
|
|
|
}
|
|
|
|
|
2018-08-27 08:50:40 +00:00
|
|
|
void SkeletonDocumentWindow::seeContributors()
|
2018-04-08 08:05:12 +00:00
|
|
|
{
|
2018-08-27 08:50:40 +00:00
|
|
|
SkeletonDocumentWindow::showContributors();
|
2018-04-08 08:05:12 +00:00
|
|
|
}
|
|
|
|
|
2018-04-16 22:54:41 +00:00
|
|
|
void SkeletonDocumentWindow::initLockButton(QPushButton *button)
|
|
|
|
{
|
|
|
|
QFont font;
|
|
|
|
font.setWeight(QFont::Light);
|
|
|
|
font.setPixelSize(Theme::toolIconFontSize);
|
|
|
|
font.setBold(false);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-16 22:54:41 +00:00
|
|
|
button->setFont(font);
|
|
|
|
button->setFixedSize(Theme::toolIconSize, Theme::toolIconSize);
|
|
|
|
button->setStyleSheet("QPushButton {color: #f7d9c8}");
|
|
|
|
button->setFocusPolicy(Qt::NoFocus);
|
|
|
|
}
|
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
SkeletonDocumentWindow::~SkeletonDocumentWindow()
|
|
|
|
{
|
2018-04-10 07:59:20 +00:00
|
|
|
g_documentWindows.erase(this);
|
2018-04-07 08:44:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SkeletonDocumentWindow::showEvent(QShowEvent *event)
|
|
|
|
{
|
|
|
|
QMainWindow::showEvent(event);
|
|
|
|
if (m_firstShow) {
|
|
|
|
m_firstShow = false;
|
2018-04-10 07:59:20 +00:00
|
|
|
updateTitle();
|
|
|
|
m_document->saveSnapshot();
|
|
|
|
m_graphicsWidget->setFocus();
|
2018-04-07 08:44:39 +00:00
|
|
|
emit initialized();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-13 01:42:19 +00:00
|
|
|
void SkeletonDocumentWindow::mousePressEvent(QMouseEvent *event)
|
|
|
|
{
|
|
|
|
QMainWindow::mousePressEvent(event);
|
|
|
|
}
|
|
|
|
|
2018-04-07 08:44:39 +00:00
|
|
|
void SkeletonDocumentWindow::changeTurnaround()
|
|
|
|
{
|
2018-04-10 07:59:20 +00:00
|
|
|
QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(),
|
2018-04-07 08:44:39 +00:00
|
|
|
tr("Image Files (*.png *.jpg *.bmp)")).trimmed();
|
|
|
|
if (fileName.isEmpty())
|
|
|
|
return;
|
|
|
|
QImage image;
|
|
|
|
if (!image.load(fileName))
|
|
|
|
return;
|
|
|
|
m_document->updateTurnaround(image);
|
|
|
|
}
|
2018-04-10 07:59:20 +00:00
|
|
|
|
|
|
|
void SkeletonDocumentWindow::save()
|
|
|
|
{
|
|
|
|
saveTo(m_currentFilename);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkeletonDocumentWindow::saveTo(const QString &saveAsFilename)
|
|
|
|
{
|
|
|
|
QString filename = saveAsFilename;
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
if (filename.isEmpty()) {
|
|
|
|
filename = QFileDialog::getSaveFileName(this, QString(), QString(),
|
|
|
|
tr("Dust3D Document (*.ds3)"));
|
|
|
|
if (filename.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
Ds3FileWriter ds3Writer;
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
QByteArray modelXml;
|
|
|
|
QXmlStreamWriter stream(&modelXml);
|
2018-10-25 00:19:38 +00:00
|
|
|
Snapshot snapshot;
|
2018-04-10 07:59:20 +00:00
|
|
|
m_document->toSnapshot(&snapshot);
|
|
|
|
saveSkeletonToXmlStream(&snapshot, &stream);
|
|
|
|
if (modelXml.size() > 0)
|
|
|
|
ds3Writer.add("model.xml", "model", &modelXml);
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
QByteArray imageByteArray;
|
|
|
|
QBuffer pngBuffer(&imageByteArray);
|
|
|
|
if (!m_document->turnaround.isNull()) {
|
|
|
|
pngBuffer.open(QIODevice::WriteOnly);
|
|
|
|
m_document->turnaround.save(&pngBuffer, "PNG");
|
|
|
|
if (imageByteArray.size() > 0)
|
|
|
|
ds3Writer.add("canvas.png", "asset", &imageByteArray);
|
|
|
|
}
|
2018-10-09 02:19:12 +00:00
|
|
|
|
|
|
|
for (auto &material: snapshot.materials) {
|
|
|
|
for (auto &layer: material.second) {
|
|
|
|
for (auto &mapItem: layer.second) {
|
|
|
|
auto findImageIdString = mapItem.find("linkData");
|
|
|
|
if (findImageIdString == mapItem.end())
|
|
|
|
continue;
|
|
|
|
QUuid imageId = QUuid(findImageIdString->second);
|
|
|
|
const QImage *image = ImageForever::get(imageId);
|
|
|
|
if (nullptr == image)
|
|
|
|
continue;
|
|
|
|
QByteArray imageByteArray;
|
|
|
|
QBuffer pngBuffer(&imageByteArray);
|
|
|
|
pngBuffer.open(QIODevice::WriteOnly);
|
|
|
|
image->save(&pngBuffer, "PNG");
|
|
|
|
if (imageByteArray.size() > 0)
|
|
|
|
ds3Writer.add("images/" + imageId.toString() + ".png", "asset", &imageByteArray);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
if (ds3Writer.save(filename)) {
|
|
|
|
setCurrentFilename(filename);
|
|
|
|
}
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
QApplication::restoreOverrideCursor();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkeletonDocumentWindow::open()
|
|
|
|
{
|
|
|
|
if (!m_documentSaved) {
|
|
|
|
QMessageBox::StandardButton answer = QMessageBox::question(this,
|
|
|
|
APP_NAME,
|
|
|
|
tr("Do you really want to open another file and lose the unsaved changes?"),
|
|
|
|
QMessageBox::Yes | QMessageBox::No);
|
|
|
|
if (answer != QMessageBox::Yes)
|
|
|
|
return;
|
|
|
|
}
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
QString filename = QFileDialog::getOpenFileName(this, QString(), QString(),
|
|
|
|
tr("Dust3D Document (*.ds3)"));
|
|
|
|
if (filename.isEmpty())
|
|
|
|
return;
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
|
|
|
Ds3FileReader ds3Reader(filename);
|
2018-10-09 02:19:12 +00:00
|
|
|
|
2018-10-25 06:27:59 +00:00
|
|
|
m_document->clearHistories();
|
|
|
|
m_document->reset();
|
|
|
|
m_document->saveSnapshot();
|
|
|
|
|
2018-10-09 02:19:12 +00:00
|
|
|
for (int i = 0; i < ds3Reader.items().size(); ++i) {
|
|
|
|
Ds3ReaderItem item = ds3Reader.items().at(i);
|
|
|
|
if (item.type == "asset") {
|
|
|
|
if (item.name.startsWith("images/")) {
|
|
|
|
QString filename = item.name.split("/")[1];
|
|
|
|
QString imageIdString = filename.split(".")[0];
|
|
|
|
QUuid imageId = QUuid(imageIdString);
|
|
|
|
if (!imageId.isNull()) {
|
|
|
|
QByteArray data;
|
|
|
|
ds3Reader.loadItem(item.name, &data);
|
|
|
|
QImage image = QImage::fromData(data, "PNG");
|
|
|
|
(void)ImageForever::add(&image, imageId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
for (int i = 0; i < ds3Reader.items().size(); ++i) {
|
|
|
|
Ds3ReaderItem item = ds3Reader.items().at(i);
|
|
|
|
if (item.type == "model") {
|
|
|
|
QByteArray data;
|
|
|
|
ds3Reader.loadItem(item.name, &data);
|
|
|
|
QXmlStreamReader stream(data);
|
2018-10-25 00:19:38 +00:00
|
|
|
Snapshot snapshot;
|
2018-04-10 07:59:20 +00:00
|
|
|
loadSkeletonFromXmlStream(&snapshot, stream);
|
|
|
|
m_document->fromSnapshot(snapshot);
|
2018-05-12 10:07:46 +00:00
|
|
|
m_document->saveSnapshot();
|
2018-04-10 07:59:20 +00:00
|
|
|
} else if (item.type == "asset") {
|
|
|
|
if (item.name == "canvas.png") {
|
|
|
|
QByteArray data;
|
|
|
|
ds3Reader.loadItem(item.name, &data);
|
|
|
|
QImage image = QImage::fromData(data, "PNG");
|
|
|
|
m_document->updateTurnaround(image);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
QApplication::restoreOverrideCursor();
|
2018-06-27 00:19:14 +00:00
|
|
|
|
2018-04-10 07:59:20 +00:00
|
|
|
setCurrentFilename(filename);
|
|
|
|
}
|
|
|
|
|
2018-09-22 10:31:02 +00:00
|
|
|
void SkeletonDocumentWindow::showAdvanceSetting()
|
|
|
|
{
|
|
|
|
if (nullptr == m_advanceSettingWidget) {
|
|
|
|
m_advanceSettingWidget = new AdvanceSettingWidget(m_document, this);
|
|
|
|
}
|
|
|
|
m_advanceSettingWidget->show();
|
|
|
|
m_advanceSettingWidget->raise();
|
|
|
|
}
|
|
|
|
|
2018-09-05 03:14:36 +00:00
|
|
|
void SkeletonDocumentWindow::exportObjResult()
|
2018-04-10 07:59:20 +00:00
|
|
|
{
|
|
|
|
QString filename = QFileDialog::getSaveFileName(this, QString(), QString(),
|
|
|
|
tr("Wavefront (*.obj)"));
|
|
|
|
if (filename.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
2018-10-09 02:19:12 +00:00
|
|
|
MeshLoader *resultMesh = m_document->takeResultMesh();
|
|
|
|
if (nullptr != resultMesh) {
|
|
|
|
resultMesh->exportAsObj(filename);
|
|
|
|
delete resultMesh;
|
2018-09-05 03:14:36 +00:00
|
|
|
}
|
|
|
|
QApplication::restoreOverrideCursor();
|
|
|
|
}
|
|
|
|
|
2018-05-10 09:16:22 +00:00
|
|
|
void SkeletonDocumentWindow::showExportPreview()
|
2018-04-26 02:23:22 +00:00
|
|
|
{
|
2018-05-10 09:16:22 +00:00
|
|
|
if (nullptr == m_exportPreviewWidget) {
|
|
|
|
m_exportPreviewWidget = new ExportPreviewWidget(m_document, this);
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_exportPreviewWidget, &ExportPreviewWidget::regenerate, m_document, &Document::regenerateMesh);
|
2018-10-25 09:18:04 +00:00
|
|
|
connect(m_exportPreviewWidget, &ExportPreviewWidget::saveAsGlb, this, &SkeletonDocumentWindow::exportGlbResult);
|
2018-10-20 05:07:11 +00:00
|
|
|
connect(m_exportPreviewWidget, &ExportPreviewWidget::saveAsFbx, this, &SkeletonDocumentWindow::exportFbxResult);
|
2018-10-25 00:19:38 +00:00
|
|
|
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);
|
2018-09-21 07:10:18 +00:00
|
|
|
registerDialog(m_exportPreviewWidget);
|
2018-04-26 02:23:22 +00:00
|
|
|
}
|
2018-05-10 09:16:22 +00:00
|
|
|
m_exportPreviewWidget->show();
|
2018-09-22 10:31:02 +00:00
|
|
|
m_exportPreviewWidget->raise();
|
2018-05-10 09:16:22 +00:00
|
|
|
}
|
|
|
|
|
2018-10-20 05:07:11 +00:00
|
|
|
void SkeletonDocumentWindow::exportFbxResult()
|
|
|
|
{
|
|
|
|
QString filename = QFileDialog::getSaveFileName(this, QString(), QString(),
|
|
|
|
tr("Autodesk FBX (.fbx)"));
|
|
|
|
if (filename.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!m_document->isExportReady()) {
|
|
|
|
qDebug() << "Export but document is not export ready";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
2018-10-26 23:04:45 +00:00
|
|
|
Outcome skeletonResult = m_document->currentPostProcessedOutcome();
|
2018-10-21 23:29:01 +00:00
|
|
|
FbxFileWriter fbxFileWriter(skeletonResult, m_document->resultRigBones(), m_document->resultRigWeights(), filename);
|
2018-10-20 05:07:11 +00:00
|
|
|
fbxFileWriter.save();
|
|
|
|
QApplication::restoreOverrideCursor();
|
|
|
|
}
|
|
|
|
|
2018-10-25 09:18:04 +00:00
|
|
|
void SkeletonDocumentWindow::exportGlbResult()
|
2018-05-10 09:16:22 +00:00
|
|
|
{
|
2018-04-30 11:31:09 +00:00
|
|
|
QString filename = QFileDialog::getSaveFileName(this, QString(), QString(),
|
2018-10-25 09:18:04 +00:00
|
|
|
tr("glTF Binary Format (.glb)"));
|
2018-04-30 11:31:09 +00:00
|
|
|
if (filename.isEmpty()) {
|
|
|
|
return;
|
2018-04-26 02:23:22 +00:00
|
|
|
}
|
2018-09-14 09:45:05 +00:00
|
|
|
if (!m_document->isExportReady()) {
|
|
|
|
qDebug() << "Export but document is not export ready";
|
|
|
|
return;
|
|
|
|
}
|
2018-04-30 11:31:09 +00:00
|
|
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
2018-10-26 23:04:45 +00:00
|
|
|
Outcome skeletonResult = m_document->currentPostProcessedOutcome();
|
2018-10-27 02:29:51 +00:00
|
|
|
std::vector<std::pair<QString, std::vector<std::pair<float, JointNodeTree>>>> exportMotions;
|
|
|
|
for (const auto &motionId: m_document->motionIdList) {
|
|
|
|
const Motion *motion = m_document->findMotion(motionId);
|
|
|
|
if (nullptr == motion)
|
|
|
|
continue;
|
|
|
|
exportMotions.push_back({motion->name, motion->jointNodeTrees});
|
|
|
|
}
|
2018-10-25 09:18:04 +00:00
|
|
|
GlbFileWriter glbFileWriter(skeletonResult, m_document->resultRigBones(), m_document->resultRigWeights(), filename,
|
2018-10-27 02:29:51 +00:00
|
|
|
m_document->textureImage, exportMotions.empty() ? nullptr : &exportMotions);
|
2018-10-25 09:18:04 +00:00
|
|
|
glbFileWriter.save();
|
2018-04-30 11:31:09 +00:00
|
|
|
QApplication::restoreOverrideCursor();
|
2018-04-26 02:23:22 +00:00
|
|
|
}
|
|
|
|
|
2018-04-16 22:54:41 +00:00
|
|
|
void SkeletonDocumentWindow::updateXlockButtonState()
|
|
|
|
{
|
|
|
|
if (m_document->xlocked)
|
|
|
|
m_xlockButton->setStyleSheet("QPushButton {color: #252525}");
|
|
|
|
else
|
|
|
|
m_xlockButton->setStyleSheet("QPushButton {color: #fc6621}");
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkeletonDocumentWindow::updateYlockButtonState()
|
|
|
|
{
|
|
|
|
if (m_document->ylocked)
|
|
|
|
m_ylockButton->setStyleSheet("QPushButton {color: #252525}");
|
|
|
|
else
|
|
|
|
m_ylockButton->setStyleSheet("QPushButton {color: #2a5aac}");
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkeletonDocumentWindow::updateZlockButtonState()
|
|
|
|
{
|
|
|
|
if (m_document->zlocked)
|
|
|
|
m_zlockButton->setStyleSheet("QPushButton {color: #252525}");
|
|
|
|
else
|
|
|
|
m_zlockButton->setStyleSheet("QPushButton {color: #aaebc4}");
|
|
|
|
}
|
2018-09-08 04:20:31 +00:00
|
|
|
|
|
|
|
void SkeletonDocumentWindow::updateRadiusLockButtonState()
|
|
|
|
{
|
|
|
|
if (m_document->radiusLocked)
|
|
|
|
m_radiusLockButton->setStyleSheet("QPushButton {color: #252525}");
|
|
|
|
else
|
|
|
|
m_radiusLockButton->setStyleSheet("QPushButton {color: " + Theme::white.name() + "}");
|
|
|
|
}
|
2018-09-18 14:23:28 +00:00
|
|
|
|
|
|
|
void SkeletonDocumentWindow::updateRigWeightRenderWidget()
|
|
|
|
{
|
|
|
|
MeshLoader *resultRigWeightMesh = m_document->takeResultRigWeightMesh();
|
|
|
|
if (nullptr == resultRigWeightMesh) {
|
|
|
|
m_rigWidget->rigWeightRenderWidget()->hide();
|
|
|
|
} else {
|
|
|
|
m_rigWidget->rigWeightRenderWidget()->updateMesh(resultRigWeightMesh);
|
|
|
|
m_rigWidget->rigWeightRenderWidget()->show();
|
|
|
|
m_rigWidget->rigWeightRenderWidget()->update();
|
|
|
|
}
|
|
|
|
}
|
2018-09-21 07:10:18 +00:00
|
|
|
|
|
|
|
void SkeletonDocumentWindow::registerDialog(QWidget *widget)
|
|
|
|
{
|
|
|
|
m_dialogs.push_back(widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SkeletonDocumentWindow::unregisterDialog(QWidget *widget)
|
|
|
|
{
|
|
|
|
m_dialogs.erase(std::remove(m_dialogs.begin(), m_dialogs.end(), widget), m_dialogs.end());
|
|
|
|
}
|