diff --git a/.travis.yml b/.travis.yml index cca2f3f4..d0ca4015 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,21 +16,26 @@ matrix: apt: sources: - ubuntu-toolchain-r-test - packages: - - gcc-4.9 - - g++-4.9 - os: osx compiler: clang osx_image: xcode8 install: + # (Mac) Install CGAL - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew reinstall cgal; fi + + # (Linux) Prepare build environment - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository --yes ppa:beineri/opt-qt591-trusty; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install gcc-4.9 g++-4.9; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install libcgal-dev; fi + #- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install gcc-4.9 g++-4.9; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt install cmake; fi + + # (Linux) Install CGAL + # (Linux) First install a maybe old version CGAL to resolve dependencies + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install libcgal-dev; fi + + # (Linux) Build from source - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then wget https://github.com/CGAL/cgal/releases/download/releases/CGAL-4.11.1/CGAL-4.11.1.zip; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then unzip CGAL-4.11.1.zip; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cd CGAL-4.11.1; fi @@ -40,15 +45,22 @@ install: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo make install; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cd ../../; fi + + # (Mac) Install Qt5 - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew reinstall qt5; fi + + # (Linux) Install Qt5 - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install qt59base qt59tools --force-yes; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then source /opt/qt59/bin/qt59-env.sh; fi + + # Install Rust - wget -O installrust.sh https://sh.rustup.rs - sh installrust.sh -y - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH="$HOME/.cargo/bin:/usr/local/opt/qt/bin:$(brew --prefix)/bin:$PATH"; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export PATH="~/.cargo/bin:$PATH"; fi script: + # Build Meshlite - git clone https://github.com/huxingyi/meshlite.git || travis_terminate 1 - cd meshlite - cargo build --release @@ -56,22 +68,51 @@ script: - cp meshlite/include/meshlite.h thirdparty/meshlite/meshlite.h || travis_terminate 1 - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then cp meshlite/target/release/libmeshlite.dylib thirdparty/meshlite/libmeshlite.dylib || travis_terminate 1; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cp meshlite/target/release/libmeshlite.so thirdparty/meshlite/libmeshlite.so || travis_terminate 1; fi + + # Build Dust3D - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then qmake -config release || travis_terminate 1; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then qmake -config release || travis_terminate 1; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then make || travis_terminate 1; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make CXX="g++-4.9 -fext-numeric-literals" || travis_terminate 1; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make CXX="g++ -fext-numeric-literals" || travis_terminate 1; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/thirdparty/meshlite || travis_terminate 1; fi + + # (Mac) Prepare dmg - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then mv dust3d.app dust3d_unstable.app || travis_terminate 1; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mkdir -p dust3d_unstable/usr/share/metainfo || travis_terminate 1; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mkdir dust3d_unstable/usr/share/applications || travis_terminate 1; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mv ./dust3d dust3d_unstable/dust3d_unstable || travis_terminate 1; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mv ./ci/icon.png dust3d_unstable/icon.png || travis_terminate 1; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mv ./ci/org.dust3d.appdata.xml dust3d_unstable/usr/share/metainfo/org.dust3d.appdata.xml || travis_terminate 1; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cp ./ci/org.dust3d.desktop dust3d_unstable/usr/share/applications/org.dust3d.desktop || travis_terminate 1; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cp ./ci/org.dust3d.desktop dust3d_unstable/org.dust3d.desktop || travis_terminate 1; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then macdeployqt dust3d_unstable.app -dmg || travis_terminate 1; fi + + # (Linux) Prepare AppImage + # References: + # https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html + # https://packages.ubuntu.com/search?suite=trusty&arch=amd64&mode=exactfilename&searchon=contents&keywords=libstdc%2B%2B.so.6 + # https://github.com/darealshinji/AppImageKit-checkrt/issues/1 + # https://github.com/darealshinji/AppImageKit-checkrt/releases/download/continuous/AppRun-patched-x86_64 + # https://github.com/darealshinji/AppImageKit-checkrt/releases/download/continuous/exec-x86_64.so + # https://github.com/probonopd/audacity/blob/AppImage/.travis.yml + # https://discourse.appimage.org/t/im-a-big-fan-of-this-but-graphics-driver-libstdc-conflict/171 + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mkdir -p appdir/usr/share/metainfo || travis_terminate 1; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mkdir -p appdir/usr/share/applications || travis_terminate 1; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mkdir -p appdir/usr/bin || travis_terminate 1; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mkdir -p appdir/usr/optional/libstdc++ || travis_terminate 1; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ldd --version; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo ls /usr/lib/x86_64-linux-gnu/ | grep libstdc; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6 appdir/usr/optional/libstdc++/libstdc++.so.6 || travis_terminate 1; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cp ./ci/exec-x86_64.so appdir/usr/optional/exec.so || travis_terminate 1; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cp ./ci/icon.png appdir/icon.png || travis_terminate 1; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cp ./ci/dust3d.appdata.xml appdir/usr/share/metainfo/dust3d.appdata.xml || travis_terminate 1; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cp ./dust3d appdir/usr/bin/dust3d || travis_terminate 1; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cp ./ci/dust3d.desktop appdir/usr/share/applications/dust3d.desktop || travis_terminate 1; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then chmod a+x ./ci/linuxdeployqt.AppImage || travis_terminate 1; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./ci/linuxdeployqt.AppImage dust3d_unstable/dust3d_unstable -appimage -bundle-non-qt-libs -verbose=2 || travis_terminate 1; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mv ./Dust3D-x86_64.AppImage ./dust3d_unstable-x86_64.AppImage || travis_terminate 1;fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then unset QTDIR; unset QT_PLUGIN_PATH ; export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/thirdparty/meshlite; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./ci/linuxdeployqt.AppImage appdir/usr/share/applications/dust3d.desktop -bundle-non-qt-libs -verbose=2 || travis_terminate 1; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then rm appdir/AppRun || travis_terminate 1; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then cp ./ci/AppRun-patched-x86_64 appdir/AppRun || travis_terminate 1; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then chmod a+x appdir/AppRun || travis_terminate 1; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./ci/linuxdeployqt.AppImage --appimage-extract || travis_terminate 1; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export PATH=$(readlink -f ./squashfs-root/usr/bin):$PATH || travis_terminate 1; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./squashfs-root/usr/bin/appimagetool -g ./appdir/ dust3d_unstable-x86_64.AppImage || travis_terminate 1; fi + + # Distribute + - if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then echo "No distribution on pull request"; fi + - if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then travis_terminate 0; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sh ci/upload-github-release-asset.sh github_api_token=${my_auth_token} branch=$TRAVIS_BRANCH owner=huxingyi repo=dust3d tag=unstable filename=dust3d_unstable.dmg; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then bash ci/upload-github-release-asset.sh github_api_token=${my_auth_token} branch=$TRAVIS_BRANCH owner=huxingyi repo=dust3d tag=unstable filename=dust3d_unstable-x86_64.AppImage; fi diff --git a/ci/AppRun-patched-x86_64 b/ci/AppRun-patched-x86_64 new file mode 100644 index 00000000..46a97569 Binary files /dev/null and b/ci/AppRun-patched-x86_64 differ diff --git a/ci/org.dust3d.appdata.xml b/ci/dust3d.appdata.xml similarity index 96% rename from ci/org.dust3d.appdata.xml rename to ci/dust3d.appdata.xml index 072810a8..9c704e40 100644 --- a/ci/org.dust3d.appdata.xml +++ b/ci/dust3d.appdata.xml @@ -1,6 +1,6 @@ -​ org.dust3d.desktop +​ dust3d.desktopFSFAPMITDust3D diff --git a/ci/org.dust3d.desktop b/ci/dust3d.desktop similarity index 90% rename from ci/org.dust3d.desktop rename to ci/dust3d.desktop index 3bb100bc..f85028ab 100644 --- a/ci/org.dust3d.desktop +++ b/ci/dust3d.desktop @@ -2,5 +2,6 @@ Type=Application Name=Dust3D Icon=icon +Exec=dust3d Categories=Graphics; Comment=A quick 3D modeling tool diff --git a/ci/exec-x86_64.so b/ci/exec-x86_64.so new file mode 100644 index 00000000..44ba29c1 Binary files /dev/null and b/ci/exec-x86_64.so differ diff --git a/ci/upload-github-release-asset.sh b/ci/upload-github-release-asset.sh index 1b7cf2ce..b046f36d 100644 --- a/ci/upload-github-release-asset.sh +++ b/ci/upload-github-release-asset.sh @@ -83,7 +83,7 @@ GH_ASSET="https://uploads.github.com/repos/$owner/$repo/releases/$release_id/ass response=$(curl "$GITHUB_OAUTH_BASIC" --data-binary @"$filename" -H "Authorization: token $github_api_token" -H "Content-Type: application/octet-stream" $GH_ASSET) echo $response -founderr=$(echo "$response" | grep "errors" | wc -l) +founderr=$(echo "$response" | grep "errors\|Error" | wc -l) if [ "$founderr" -eq "0" ]; then echo "Upload success" else diff --git a/src/ccdikresolver.cpp b/src/ccdikresolver.cpp index a63a9b09..7b89421b 100644 --- a/src/ccdikresolver.cpp +++ b/src/ccdikresolver.cpp @@ -41,7 +41,7 @@ void CCDIKSolver::solveTo(const QVector3D &position) qDebug() << "Round:" << i << " distance2:" << distance2; if (distance2 <= m_distanceThreshold2) break; - if (lastDistance2 > 0 && abs(distance2 - lastDistance2) <= m_distanceCeaseThreshold2) + if (lastDistance2 > 0 && fabs(distance2 - lastDistance2) <= m_distanceCeaseThreshold2) break; lastDistance2 = distance2; iterate(); diff --git a/src/skeletondocumentwindow.cpp b/src/skeletondocumentwindow.cpp index dec265d4..d3dc446f 100644 --- a/src/skeletondocumentwindow.cpp +++ b/src/skeletondocumentwindow.cpp @@ -36,7 +36,7 @@ int SkeletonDocumentWindow::m_skeletonRenderWidgetInitialX = SkeletonDocumentWin int SkeletonDocumentWindow::m_skeletonRenderWidgetInitialY = SkeletonDocumentWindow::m_modelRenderWidgetInitialY; int SkeletonDocumentWindow::m_skeletonRenderWidgetInitialSize = SkeletonDocumentWindow::m_modelRenderWidgetInitialSize; -QPointer g_logBrowser; +LogBrowser *g_logBrowser = nullptr; std::set g_documentWindows; QTextBrowser *g_acknowlegementsWidget = nullptr; AboutWidget *g_aboutWidget = nullptr; @@ -84,45 +84,45 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : g_logBrowser = new LogBrowser; qInstallMessageHandler(&outputMessage); } - + g_documentWindows.insert(this); - + m_document = new SkeletonDocument; - + QVBoxLayout *toolButtonLayout = new QVBoxLayout; toolButtonLayout->setSpacing(0); toolButtonLayout->setContentsMargins(5, 10, 4, 0); - + QPushButton *undoButton = new QPushButton(QChar(fa::undo)); initAwesomeButton(undoButton); - + QPushButton *addButton = new QPushButton(QChar(fa::plus)); initAwesomeButton(addButton); - + QPushButton *selectButton = new QPushButton(QChar(fa::mousepointer)); initAwesomeButton(selectButton); - + QPushButton *dragButton = new QPushButton(QChar(fa::handrocko)); initAwesomeButton(dragButton); - + QPushButton *zoomInButton = new QPushButton(QChar(fa::searchplus)); initAwesomeButton(zoomInButton); - + QPushButton *zoomOutButton = new QPushButton(QChar(fa::searchminus)); initAwesomeButton(zoomOutButton); - + m_xlockButton = new QPushButton(QChar('X')); initLockButton(m_xlockButton); updateXlockButtonState(); - + m_ylockButton = new QPushButton(QChar('Y')); initLockButton(m_ylockButton); updateYlockButtonState(); - + m_zlockButton = new QPushButton(QChar('Z')); initLockButton(m_zlockButton); updateZlockButtonState(); - + toolButtonLayout->addWidget(undoButton); toolButtonLayout->addSpacing(10); toolButtonLayout->addWidget(addButton); @@ -134,16 +134,16 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : toolButtonLayout->addWidget(m_xlockButton); toolButtonLayout->addWidget(m_ylockButton); toolButtonLayout->addWidget(m_zlockButton); - + QLabel *verticalLogoLabel = new QLabel; QImage verticalLogoImage; verticalLogoImage.load(":/resources/dust3d_vertical.png"); verticalLogoLabel->setPixmap(QPixmap::fromImage(verticalLogoImage)); - + QHBoxLayout *logoLayout = new QHBoxLayout; logoLayout->addWidget(verticalLogoLabel); logoLayout->setContentsMargins(0, 0, 0, 0); - + QVBoxLayout *mainLeftLayout = new QVBoxLayout; mainLeftLayout->setSpacing(0); mainLeftLayout->setContentsMargins(0, 0, 0, 0); @@ -151,10 +151,10 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : mainLeftLayout->addStretch(); mainLeftLayout->addLayout(logoLayout); mainLeftLayout->addSpacing(10); - + SkeletonGraphicsWidget *graphicsWidget = new SkeletonGraphicsWidget(m_document); m_graphicsWidget = graphicsWidget; - + SkeletonGraphicsContainerWidget *containerWidget = new SkeletonGraphicsContainerWidget; containerWidget->setGraphicsWidget(graphicsWidget); QGridLayout *containerLayout = new QGridLayout; @@ -163,38 +163,38 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : containerLayout->addWidget(graphicsWidget); containerWidget->setLayout(containerLayout); containerWidget->setMinimumSize(400, 400); - + m_modelRenderWidget = new ModelWidget(containerWidget); 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); m_modelRenderWidget->setGraphicsFunctions(graphicsWidget); - + //m_skeletonRenderWidget = new ModelWidget(containerWidget); //m_skeletonRenderWidget->setMinimumSize(SkeletonDocumentWindow::m_skeletonRenderWidgetInitialSize, SkeletonDocumentWindow::m_skeletonRenderWidgetInitialSize); //m_skeletonRenderWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); //m_skeletonRenderWidget->move(SkeletonDocumentWindow::m_skeletonRenderWidgetInitialX, SkeletonDocumentWindow::m_skeletonRenderWidgetInitialY); //m_skeletonRenderWidget->setGraphicsFunctions(graphicsWidget); //m_skeletonRenderWidget->hide(); - + QDockWidget *partListDocker = new QDockWidget(QString(), this); partListDocker->setAllowedAreas(Qt::RightDockWidgetArea); - + SkeletonPartListWidget *partListWidget = new SkeletonPartListWidget(m_document, partListDocker); //partListWidget->setWindowFlags(Qt::Tool); //partListWidget->move(100, 200); //partListWidget->show(); - + partListDocker->setWidget(partListWidget); addDockWidget(Qt::RightDockWidgetArea, partListDocker); - + partListDocker->hide(); - + //QVBoxLayout *mainRightLayout = new QVBoxLayout; //mainRightLayout->setSpacing(0); //mainRightLayout->setContentsMargins(0, 0, 0, 0); //mainRightLayout->addWidget(partListWidget); - + QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->setSpacing(0); mainLayout->setContentsMargins(0, 0, 0, 0); @@ -202,164 +202,164 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : mainLayout->addWidget(containerWidget); mainLayout->addSpacing(3); //mainLayout->addLayout(mainRightLayout); - + QWidget *centralWidget = new QWidget; centralWidget->setLayout(mainLayout); - + setCentralWidget(centralWidget); setWindowTitle(tr("Dust3D")); - + m_fileMenu = menuBar()->addMenu(tr("File")); - + m_newWindowAction = new QAction(tr("New Window"), this); connect(m_newWindowAction, &QAction::triggered, this, &SkeletonDocumentWindow::newWindow, Qt::QueuedConnection); m_fileMenu->addAction(m_newWindowAction); - + m_newDocumentAction = new QAction(tr("New"), this); connect(m_newDocumentAction, &QAction::triggered, this, &SkeletonDocumentWindow::newDocument); m_fileMenu->addAction(m_newDocumentAction); - + m_openAction = new QAction(tr("Open..."), this); connect(m_openAction, &QAction::triggered, this, &SkeletonDocumentWindow::open, Qt::QueuedConnection); m_fileMenu->addAction(m_openAction); - + m_saveAction = new QAction(tr("Save"), this); connect(m_saveAction, &QAction::triggered, this, &SkeletonDocumentWindow::save, Qt::QueuedConnection); m_fileMenu->addAction(m_saveAction); - + m_saveAsAction = new QAction(tr("Save As..."), this); connect(m_saveAsAction, &QAction::triggered, this, &SkeletonDocumentWindow::saveAs, Qt::QueuedConnection); m_fileMenu->addAction(m_saveAsAction); - + m_saveAllAction = new QAction(tr("Save All"), this); connect(m_saveAllAction, &QAction::triggered, this, &SkeletonDocumentWindow::saveAll, Qt::QueuedConnection); m_fileMenu->addAction(m_saveAllAction); - + m_fileMenu->addSeparator(); - + m_exportMenu = m_fileMenu->addMenu(tr("Export")); - + m_exportModelAction = new QAction(tr("Wavefront (.obj)..."), this); connect(m_exportModelAction, &QAction::triggered, this, &SkeletonDocumentWindow::exportModelResult, Qt::QueuedConnection); m_exportMenu->addAction(m_exportModelAction); - + m_exportSkeletonAction = new QAction(tr("GL Transmission Format (.gltf)..."), this); connect(m_exportSkeletonAction, &QAction::triggered, this, &SkeletonDocumentWindow::showExportPreview, Qt::QueuedConnection); m_exportMenu->addAction(m_exportSkeletonAction); - + m_changeTurnaroundAction = new QAction(tr("Change Turnaround..."), this); connect(m_changeTurnaroundAction, &QAction::triggered, this, &SkeletonDocumentWindow::changeTurnaround, Qt::QueuedConnection); m_fileMenu->addAction(m_changeTurnaroundAction); - + connect(m_fileMenu, &QMenu::aboutToShow, [=]() { m_exportModelAction->setEnabled(m_graphicsWidget->hasItems()); m_exportSkeletonAction->setEnabled(m_graphicsWidget->hasItems()); }); - + m_editMenu = menuBar()->addMenu(tr("Edit")); - + m_addAction = new QAction(tr("Add..."), this); connect(m_addAction, &QAction::triggered, [=]() { m_document->setEditMode(SkeletonDocumentEditMode::Add); }); m_editMenu->addAction(m_addAction); - + m_undoAction = new QAction(tr("Undo"), this); connect(m_undoAction, &QAction::triggered, m_document, &SkeletonDocument::undo); m_editMenu->addAction(m_undoAction); - + m_redoAction = new QAction(tr("Redo"), this); connect(m_redoAction, &QAction::triggered, m_document, &SkeletonDocument::redo); m_editMenu->addAction(m_redoAction); - + m_deleteAction = new QAction(tr("Delete"), this); connect(m_deleteAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::deleteSelected); m_editMenu->addAction(m_deleteAction); - + m_breakAction = new QAction(tr("Break"), this); connect(m_breakAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::breakSelected); m_editMenu->addAction(m_breakAction); - + m_connectAction = new QAction(tr("Connect"), this); connect(m_connectAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::connectSelected); m_editMenu->addAction(m_connectAction); - + m_cutAction = new QAction(tr("Cut"), this); connect(m_cutAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::cut); m_editMenu->addAction(m_cutAction); - + m_copyAction = new QAction(tr("Copy"), this); connect(m_copyAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::copy); m_editMenu->addAction(m_copyAction); - + m_pasteAction = new QAction(tr("Paste"), this); connect(m_pasteAction, &QAction::triggered, m_document, &SkeletonDocument::paste); m_editMenu->addAction(m_pasteAction); - + m_flipHorizontallyAction = new QAction(tr("H Flip"), this); connect(m_flipHorizontallyAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::flipHorizontally); m_editMenu->addAction(m_flipHorizontallyAction); - + m_flipVerticallyAction = new QAction(tr("V Flip"), this); connect(m_flipVerticallyAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::flipVertically); m_editMenu->addAction(m_flipVerticallyAction); - + m_rotateClockwiseAction = new QAction(tr("Rotate 90D CW"), this); connect(m_rotateClockwiseAction, &QAction::triggered, [=] { m_graphicsWidget->rotateClockwise90Degree(); }); m_editMenu->addAction(m_rotateClockwiseAction); - + m_rotateCounterclockwiseAction = new QAction(tr("Rotate 90D CCW"), this); connect(m_rotateCounterclockwiseAction, &QAction::triggered, [=] { m_graphicsWidget->rotateCounterclockwise90Degree(); }); m_editMenu->addAction(m_rotateCounterclockwiseAction); - + m_switchXzAction = new QAction(tr("Switch XZ"), this); connect(m_switchXzAction, &QAction::triggered, [=] { m_graphicsWidget->switchSelectedXZ(); }); m_editMenu->addAction(m_switchXzAction); - + m_alignToMenu = new QMenu(tr("Align To")); - + m_alignToGlobalCenterAction = new QAction(tr("Global Center"), this); connect(m_alignToGlobalCenterAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::alignSelectedToGlobalCenter); m_alignToMenu->addAction(m_alignToGlobalCenterAction); - + m_alignToGlobalVerticalCenterAction = new QAction(tr("Global Vertical Center"), this); connect(m_alignToGlobalVerticalCenterAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::alignSelectedToGlobalVerticalCenter); m_alignToMenu->addAction(m_alignToGlobalVerticalCenterAction); - + m_alignToGlobalHorizontalCenterAction = new QAction(tr("Global Horizontal Center"), this); connect(m_alignToGlobalHorizontalCenterAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::alignSelectedToGlobalHorizontalCenter); m_alignToMenu->addAction(m_alignToGlobalHorizontalCenterAction); - + m_alignToLocalCenterAction = new QAction(tr("Local Center"), this); connect(m_alignToLocalCenterAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::alignSelectedToLocalCenter); m_alignToMenu->addAction(m_alignToLocalCenterAction); - + m_alignToLocalVerticalCenterAction = new QAction(tr("Local Vertical Center"), this); connect(m_alignToLocalVerticalCenterAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::alignSelectedToLocalVerticalCenter); m_alignToMenu->addAction(m_alignToLocalVerticalCenterAction); - + m_alignToLocalHorizontalCenterAction = new QAction(tr("Local Horizontal Center"), this); connect(m_alignToLocalHorizontalCenterAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::alignSelectedToLocalHorizontalCenter); m_alignToMenu->addAction(m_alignToLocalHorizontalCenterAction); - + m_editMenu->addMenu(m_alignToMenu); - + m_markAsMenu = new QMenu(tr("Mark As")); - + m_markAsNoneAction = new QAction(tr("None"), this); connect(m_markAsNoneAction, &QAction::triggered, [=]() { m_graphicsWidget->setSelectedNodesBoneMark(SkeletonBoneMark::None); }); m_markAsMenu->addAction(m_markAsNoneAction); - + m_markAsMenu->addSeparator(); - + for (int i = 0; i < SKELETON_BONE_MARK_TYPE_NUM; i++) { SkeletonBoneMark boneMark = (SkeletonBoneMark)(i + 1); m_markAsActions[i] = new QAction(MarkIconCreator::createIcon(boneMark), SkeletonBoneMarkToDispName(boneMark), this); @@ -368,21 +368,21 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : }); m_markAsMenu->addAction(m_markAsActions[i]); } - + m_editMenu->addMenu(m_markAsMenu); - + m_selectAllAction = new QAction(tr("Select All"), this); connect(m_selectAllAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::selectAll); m_editMenu->addAction(m_selectAllAction); - + m_selectPartAllAction = new QAction(tr("Select Part"), this); connect(m_selectPartAllAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::selectPartAll); m_editMenu->addAction(m_selectPartAllAction); - + m_unselectAllAction = new QAction(tr("Unselect All"), this); connect(m_unselectAllAction, &QAction::triggered, m_graphicsWidget, &SkeletonGraphicsWidget::unselectAll); m_editMenu->addAction(m_unselectAllAction); - + connect(m_editMenu, &QMenu::aboutToShow, [=]() { m_undoAction->setEnabled(m_document->undoable()); m_redoAction->setEnabled(m_document->redoable()); @@ -409,14 +409,14 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : m_selectPartAllAction->setEnabled(m_graphicsWidget->hasItems()); m_unselectAllAction->setEnabled(m_graphicsWidget->hasSelection()); }); - + m_viewMenu = menuBar()->addMenu(tr("View")); - + auto modelIsSitInVisibleArea = [](ModelWidget *modelWidget) { QRect parentRect = QRect(QPoint(0, 0), modelWidget->parentWidget()->size()); return parentRect.contains(modelWidget->geometry().center()); }; - + m_resetModelWidgetPosAction = new QAction(tr("Show Model"), this); connect(m_resetModelWidgetPosAction, &QAction::triggered, [=]() { if (!modelIsSitInVisibleArea(m_modelRenderWidget)) { @@ -424,95 +424,95 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : } }); m_viewMenu->addAction(m_resetModelWidgetPosAction); - + m_toggleWireframeAction = new QAction(tr("Toggle Wireframe"), this); connect(m_toggleWireframeAction, &QAction::triggered, [=]() { m_modelRenderWidget->toggleWireframe(); }); m_viewMenu->addAction(m_toggleWireframeAction); - + m_viewMenu->addSeparator(); - + m_showPartsListAction = new QAction(tr("Show Parts List"), this); connect(m_showPartsListAction, &QAction::triggered, [=]() { partListDocker->show(); }); m_viewMenu->addAction(m_showPartsListAction); - + m_viewMenu->addSeparator(); - + m_showAnimationPanelAction = new QAction(tr("Show Animation Panel"), this); connect(m_showAnimationPanelAction, &QAction::triggered, this, &SkeletonDocumentWindow::showAnimationPanel); m_viewMenu->addAction(m_showAnimationPanelAction); - + m_viewMenu->addSeparator(); - + m_showDebugDialogAction = new QAction(tr("Show Debug Dialog"), this); connect(m_showDebugDialogAction, &QAction::triggered, g_logBrowser, &LogBrowser::showDialog); m_viewMenu->addAction(m_showDebugDialogAction); - + connect(m_viewMenu, &QMenu::aboutToShow, [=]() { m_showPartsListAction->setEnabled(partListDocker->isHidden()); m_showAnimationPanelAction->setEnabled(nullptr == m_animationPanelWidget || m_animationPanelWidget->isHidden()); m_resetModelWidgetPosAction->setEnabled(!modelIsSitInVisibleArea(m_modelRenderWidget)); }); - + m_helpMenu = menuBar()->addMenu(tr("Help")); - + m_viewSourceAction = new QAction(tr("Fork me on GitHub"), this); connect(m_viewSourceAction, &QAction::triggered, this, &SkeletonDocumentWindow::viewSource); m_helpMenu->addAction(m_viewSourceAction); - + m_helpMenu->addSeparator(); - + m_seeReferenceGuideAction = new QAction(tr("Reference Guide"), this); connect(m_seeReferenceGuideAction, &QAction::triggered, this, &SkeletonDocumentWindow::seeReferenceGuide); m_helpMenu->addAction(m_seeReferenceGuideAction); - + m_helpMenu->addSeparator(); - + m_aboutAction = new QAction(tr("About"), this); connect(m_aboutAction, &QAction::triggered, this, &SkeletonDocumentWindow::about); m_helpMenu->addAction(m_aboutAction); - + m_reportIssuesAction = new QAction(tr("Report Issues"), this); connect(m_reportIssuesAction, &QAction::triggered, this, &SkeletonDocumentWindow::reportIssues); m_helpMenu->addAction(m_reportIssuesAction); - + m_seeAcknowlegementsAction = new QAction(tr("Acknowlegements"), this); connect(m_seeAcknowlegementsAction, &QAction::triggered, this, &SkeletonDocumentWindow::seeAcknowlegements); m_helpMenu->addAction(m_seeAcknowlegementsAction); - + connect(containerWidget, &SkeletonGraphicsContainerWidget::containerSizeChanged, graphicsWidget, &SkeletonGraphicsWidget::canvasResized); - + connect(m_document, &SkeletonDocument::turnaroundChanged, graphicsWidget, &SkeletonGraphicsWidget::turnaroundChanged); - + connect(undoButton, &QPushButton::clicked, [=]() { m_document->undo(); }); - + connect(addButton, &QPushButton::clicked, [=]() { m_document->setEditMode(SkeletonDocumentEditMode::Add); }); - + connect(selectButton, &QPushButton::clicked, [=]() { m_document->setEditMode(SkeletonDocumentEditMode::Select); }); - + connect(dragButton, &QPushButton::clicked, [=]() { m_document->setEditMode(SkeletonDocumentEditMode::Drag); }); - + connect(zoomInButton, &QPushButton::clicked, [=]() { m_document->setEditMode(SkeletonDocumentEditMode::ZoomIn); }); - + connect(zoomOutButton, &QPushButton::clicked, [=]() { m_document->setEditMode(SkeletonDocumentEditMode::ZoomOut); }); - + connect(m_xlockButton, &QPushButton::clicked, [=]() { m_document->setXlockState(!m_document->xlocked); }); @@ -522,7 +522,7 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : connect(m_zlockButton, &QPushButton::clicked, [=]() { m_document->setZlockState(!m_document->zlocked); }); - + m_partListDockerVisibleSwitchConnection = connect(m_document, &SkeletonDocument::skeletonChanged, [=]() { if (m_graphicsWidget->hasItems()) { if (partListDocker->isHidden()) @@ -530,11 +530,11 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : disconnect(m_partListDockerVisibleSwitchConnection); } }); - + connect(m_document, &SkeletonDocument::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); @@ -555,22 +555,22 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : 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::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::setXlockState, m_document, &SkeletonDocument::setXlockState); connect(graphicsWidget, &SkeletonGraphicsWidget::setYlockState, m_document, &SkeletonDocument::setYlockState); connect(graphicsWidget, &SkeletonGraphicsWidget::setZlockState, m_document, &SkeletonDocument::setZlockState); - + 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); @@ -588,7 +588,7 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : 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, &SkeletonDocument::partListChanged, partListWidget, &SkeletonPartListWidget::partListChanged); connect(m_document, &SkeletonDocument::partPreviewChanged, partListWidget, &SkeletonPartListWidget::partPreviewChanged); connect(m_document, &SkeletonDocument::partLockStateChanged, partListWidget, &SkeletonPartListWidget::partLockStateChanged); @@ -603,7 +603,7 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : connect(m_document, &SkeletonDocument::cleanup, partListWidget, &SkeletonPartListWidget::partListChanged); connect(m_document, &SkeletonDocument::partChecked, partListWidget, &SkeletonPartListWidget::partChecked); connect(m_document, &SkeletonDocument::partUnchecked, partListWidget, &SkeletonPartListWidget::partUnchecked); - + connect(m_document, &SkeletonDocument::skeletonChanged, m_document, &SkeletonDocument::generateMesh); connect(m_document, &SkeletonDocument::resultMeshChanged, [=]() { if ((m_exportPreviewWidget && m_exportPreviewWidget->isVisible()) || @@ -615,30 +615,30 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : connect(m_document, &SkeletonDocument::postProcessedResultChanged, m_document, &SkeletonDocument::generateTexture); connect(m_document, &SkeletonDocument::resultTextureChanged, m_document, &SkeletonDocument::bakeAmbientOcclusionTexture); connect(m_document, &SkeletonDocument::postProcessedResultChanged, m_document, &SkeletonDocument::generateAllAnimationClips); - + connect(m_document, &SkeletonDocument::resultMeshChanged, [=]() { m_modelRenderWidget->updateMesh(m_document->takeResultMesh()); }); //connect(m_document, &SkeletonDocument::resultSkeletonChanged, [=]() { // m_skeletonRenderWidget->updateMesh(m_document->takeResultSkeletonMesh()); //}); - + 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_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(this, &SkeletonDocumentWindow::initialized, m_document, &SkeletonDocument::uiReady); } @@ -656,7 +656,7 @@ void SkeletonDocumentWindow::closeEvent(QCloseEvent *event) event->accept(); return; } - + QMessageBox::StandardButton answer = QMessageBox::question(this, APP_NAME, tr("Do you really want to close while there are unsaved changes?"), @@ -769,7 +769,7 @@ void SkeletonDocumentWindow::initLockButton(QPushButton *button) font.setWeight(QFont::Light); font.setPixelSize(Theme::toolIconFontSize); font.setBold(false); - + button->setFont(font); button->setFixedSize(Theme::toolIconSize, Theme::toolIconSize); button->setStyleSheet("QPushButton {color: #f7d9c8}"); @@ -818,7 +818,7 @@ void SkeletonDocumentWindow::save() void SkeletonDocumentWindow::saveTo(const QString &saveAsFilename) { QString filename = saveAsFilename; - + if (filename.isEmpty()) { filename = QFileDialog::getSaveFileName(this, QString(), QString(), tr("Dust3D Document (*.ds3)")); @@ -826,11 +826,11 @@ void SkeletonDocumentWindow::saveTo(const QString &saveAsFilename) return; } } - + QApplication::setOverrideCursor(Qt::WaitCursor); - + Ds3FileWriter ds3Writer; - + QByteArray modelXml; QXmlStreamWriter stream(&modelXml); SkeletonSnapshot snapshot; @@ -838,7 +838,7 @@ void SkeletonDocumentWindow::saveTo(const QString &saveAsFilename) saveSkeletonToXmlStream(&snapshot, &stream); if (modelXml.size() > 0) ds3Writer.add("model.xml", "model", &modelXml); - + QByteArray imageByteArray; QBuffer pngBuffer(&imageByteArray); if (!m_document->turnaround.isNull()) { @@ -847,11 +847,11 @@ void SkeletonDocumentWindow::saveTo(const QString &saveAsFilename) if (imageByteArray.size() > 0) ds3Writer.add("canvas.png", "asset", &imageByteArray); } - + if (ds3Writer.save(filename)) { setCurrentFilename(filename); } - + QApplication::restoreOverrideCursor(); } @@ -865,12 +865,12 @@ void SkeletonDocumentWindow::open() if (answer != QMessageBox::Yes) return; } - + QString filename = QFileDialog::getOpenFileName(this, QString(), QString(), tr("Dust3D Document (*.ds3)")); if (filename.isEmpty()) return; - + QApplication::setOverrideCursor(Qt::WaitCursor); Ds3FileReader ds3Reader(filename); for (int i = 0; i < ds3Reader.items().size(); ++i) { @@ -893,7 +893,7 @@ void SkeletonDocumentWindow::open() } } QApplication::restoreOverrideCursor(); - + setCurrentFilename(filename); } @@ -1001,4 +1001,3 @@ void SkeletonDocumentWindow::updateZlockButtonState() else m_zlockButton->setStyleSheet("QPushButton {color: #aaebc4}"); } - diff --git a/thirdparty/json/json.hpp b/thirdparty/json/json.hpp index c9ef7581..3f074d18 100644 --- a/thirdparty/json/json.hpp +++ b/thirdparty/json/json.hpp @@ -124,7 +124,7 @@ using json = basic_json<>; #endif #elif defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40900 - #error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" + //#error "unsupported GCC version - see https://github.com/nlohmann/json#supported-compilers" #endif #endif