diff --git a/src/logbrowser.cpp b/src/logbrowser.cpp index c42efc84..7fdeb7d8 100644 --- a/src/logbrowser.cpp +++ b/src/logbrowser.cpp @@ -8,7 +8,7 @@ LogBrowser::LogBrowser(QObject *parent) : { qRegisterMetaType("QtMsgType"); m_browserDialog = new LogBrowserDialog; - connect(this, SIGNAL(sendMessage(QtMsgType,QString)), m_browserDialog, SLOT(outputMessage(QtMsgType,QString)), Qt::QueuedConnection); + connect(this, &LogBrowser::sendMessage, m_browserDialog, &LogBrowserDialog::outputMessage, Qt::QueuedConnection); } LogBrowser::~LogBrowser() @@ -33,8 +33,8 @@ bool LogBrowser::isDialogVisible() return m_browserDialog->isVisible(); } -void LogBrowser::outputMessage(QtMsgType type, const QString &msg) +void LogBrowser::outputMessage(QtMsgType type, const QString &msg, const QString &source, int line) { printf("%s\n", msg.toUtf8().constData()); - emit sendMessage( type, msg ); + emit sendMessage(type, msg, source, line); } diff --git a/src/logbrowser.h b/src/logbrowser.h index 407a152e..f408572c 100644 --- a/src/logbrowser.h +++ b/src/logbrowser.h @@ -13,13 +13,13 @@ public: ~LogBrowser(); public slots: - void outputMessage(QtMsgType type, const QString &msg); + void outputMessage(QtMsgType type, const QString &msg, const QString &source, int line); void showDialog(); void hideDialog(); bool isDialogVisible(); signals: - void sendMessage(QtMsgType type, const QString &msg); + void sendMessage(QtMsgType type, const QString &msg, const QString &source, int line); private: LogBrowserDialog *m_browserDialog; diff --git a/src/logbrowserdialog.cpp b/src/logbrowserdialog.cpp index a0911321..221e2bc0 100644 --- a/src/logbrowserdialog.cpp +++ b/src/logbrowserdialog.cpp @@ -49,27 +49,27 @@ LogBrowserDialog::~LogBrowserDialog() } -void LogBrowserDialog::outputMessage(QtMsgType type, const QString &msg) +void LogBrowserDialog::outputMessage(QtMsgType type, const QString &msg, const QString &source, int line) { switch (type) { case QtDebugMsg: - m_browser->append(tr("— DEBUG: %1").arg(msg)); + m_browser->append(tr("— DEBUG: %1 - %2:%3").arg(msg).arg(source).arg(QString::number(line))); break; case QtWarningMsg: - m_browser->append(tr("— WARNING: %1").arg(msg)); + m_browser->append(tr("— WARNING: %1 - %2:%3").arg(msg).arg(source).arg(QString::number(line))); break; case QtCriticalMsg: - m_browser->append(tr("— CRITICAL: %1").arg(msg)); + m_browser->append(tr("— CRITICAL: %1 - %2:%3").arg(msg).arg(source).arg(QString::number(line))); break; case QtInfoMsg: - m_browser->append(tr("— INFO: %1").arg(msg)); + m_browser->append(tr("— INFO: %1 - %2:%3").arg(msg).arg(source).arg(QString::number(line))); break; case QtFatalMsg: - m_browser->append(tr("— FATAL: %1").arg(msg)); + m_browser->append(tr("— FATAL: %1 - %2:%3").arg(msg).arg(source).arg(QString::number(line))); break; } } diff --git a/src/logbrowserdialog.h b/src/logbrowserdialog.h index 0d0e6ccb..14451809 100644 --- a/src/logbrowserdialog.h +++ b/src/logbrowserdialog.h @@ -14,7 +14,7 @@ public: ~LogBrowserDialog(); public slots: - void outputMessage(QtMsgType type, const QString &msg); + void outputMessage(QtMsgType type, const QString &msg, const QString &source, int line); protected slots: void save(); @@ -28,4 +28,4 @@ protected: QPushButton *m_saveButton; }; -#endif // DIALOG_H \ No newline at end of file +#endif // DIALOG_H diff --git a/src/modelmeshbinder.cpp b/src/modelmeshbinder.cpp index d164c8cd..9cc3633b 100644 --- a/src/modelmeshbinder.cpp +++ b/src/modelmeshbinder.cpp @@ -199,6 +199,8 @@ void ModelMeshBinder::cleanup() m_vboTriangle.destroy(); if (m_vboEdge.isCreated()) m_vboEdge.destroy(); + delete m_texture; + m_texture = nullptr; } void ModelMeshBinder::showWireframes() diff --git a/src/skeletondocument.cpp b/src/skeletondocument.cpp index 46bca9fb..1d11c1d5 100644 --- a/src/skeletondocument.cpp +++ b/src/skeletondocument.cpp @@ -687,6 +687,10 @@ void SkeletonDocument::addFromSnapshot(const SkeletonSnapshot &snapshot) originZ = originZit->second.toFloat(); } + std::set newAddedNodeIds; + std::set newAddedEdgeIds; + std::set newAddedPartIds; + std::map oldNewIdMap; for (const auto &partKv : snapshot.parts) { SkeletonPart part; @@ -711,6 +715,7 @@ void SkeletonDocument::addFromSnapshot(const SkeletonSnapshot &snapshot) if (deformWidthIt != partKv.second.end()) part.setDeformWidth(deformWidthIt->second.toFloat()); partMap[part.id] = part; + newAddedPartIds.insert(part.id); } for (const auto &nodeKv : snapshot.nodes) { if (nodeKv.second.find("radius") == nodeKv.second.end() || @@ -728,6 +733,7 @@ void SkeletonDocument::addFromSnapshot(const SkeletonSnapshot &snapshot) node.z = valueOfKeyInMapOrEmpty(nodeKv.second, "z").toFloat(); node.partId = oldNewIdMap[QUuid(valueOfKeyInMapOrEmpty(nodeKv.second, "partId"))]; nodeMap[node.id] = node; + newAddedNodeIds.insert(node.id); } for (const auto &edgeKv : snapshot.edges) { if (edgeKv.second.find("from") == edgeKv.second.end() || @@ -751,28 +757,45 @@ void SkeletonDocument::addFromSnapshot(const SkeletonSnapshot &snapshot) nodeMap[toId].edgeIds.push_back(edge.id); } edgeMap[edge.id] = edge; + newAddedEdgeIds.insert(edge.id); } for (const auto &nodeIt: nodeMap) { + if (newAddedNodeIds.find(nodeIt.first) == newAddedNodeIds.end()) + continue; partMap[nodeIt.second.partId].nodeIds.push_back(nodeIt.first); } for (const auto &partIdIt: snapshot.partIdList) { - partIds.push_back(oldNewIdMap[QUuid(partIdIt)]); + const auto partId = oldNewIdMap[QUuid(partIdIt)]; + if (newAddedPartIds.find(partId) == newAddedPartIds.end()) + continue; + partIds.push_back(partId); } - for (const auto &nodeIt: nodeMap) { - emit nodeAdded(nodeIt.first); + for (const auto &nodeIt: newAddedNodeIds) { + emit nodeAdded(nodeIt); } - for (const auto &edgeIt: edgeMap) { - emit edgeAdded(edgeIt.first); + for (const auto &edgeIt: newAddedEdgeIds) { + emit edgeAdded(edgeIt); } - for (const auto &partIt : partMap) { - emit partAdded(partIt.first); - emit partVisibleStateChanged(partIt.first); + for (const auto &partIt : newAddedPartIds) { + emit partAdded(partIt); } emit partListChanged(); emit originChanged(); emit skeletonChanged(); + + for (const auto &partIt : newAddedPartIds) { + emit partVisibleStateChanged(partIt); + } + + emit uncheckAll(); + for (const auto &nodeIt: newAddedNodeIds) { + emit checkNode(nodeIt); + } + for (const auto &edgeIt: newAddedEdgeIds) { + emit checkEdge(edgeIt); + } } void SkeletonDocument::reset() @@ -792,6 +815,7 @@ void SkeletonDocument::fromSnapshot(const SkeletonSnapshot &snapshot) { reset(); addFromSnapshot(snapshot); + emit uncheckAll(); } MeshLoader *SkeletonDocument::takeResultMesh() diff --git a/src/skeletondocument.h b/src/skeletondocument.h index b35d8088..8fd5812b 100644 --- a/src/skeletondocument.h +++ b/src/skeletondocument.h @@ -213,6 +213,9 @@ signals: void enableBackgroundBlur(); void disableBackgroundBlur(); void exportReady(); + void uncheckAll(); + void checkNode(QUuid nodeId); + void checkEdge(QUuid edgeId); public: // need initialize float originX; float originY; diff --git a/src/skeletondocumentwindow.cpp b/src/skeletondocumentwindow.cpp index fab57966..c43fbb5d 100644 --- a/src/skeletondocumentwindow.cpp +++ b/src/skeletondocumentwindow.cpp @@ -43,7 +43,7 @@ AboutWidget *g_aboutWidget = nullptr; void outputMessage(QtMsgType type, const QMessageLogContext &context, const QString &msg) { if (g_logBrowser) - g_logBrowser->outputMessage(type, msg); + g_logBrowser->outputMessage(type, msg, context.file, context.line); } void SkeletonDocumentWindow::showAcknowlegements() @@ -497,6 +497,9 @@ SkeletonDocumentWindow::SkeletonDocumentWindow() : connect(m_document, &SkeletonDocument::checkPart, graphicsWidget, &SkeletonGraphicsWidget::selectPartAllById); connect(m_document, &SkeletonDocument::enableBackgroundBlur, graphicsWidget, &SkeletonGraphicsWidget::enableBackgroundBlur); connect(m_document, &SkeletonDocument::disableBackgroundBlur, graphicsWidget, &SkeletonGraphicsWidget::disableBackgroundBlur); + connect(m_document, &SkeletonDocument::uncheckAll, graphicsWidget, &SkeletonGraphicsWidget::unselectAll); + connect(m_document, &SkeletonDocument::checkNode, graphicsWidget, &SkeletonGraphicsWidget::addSelectNode); + connect(m_document, &SkeletonDocument::checkEdge, graphicsWidget, &SkeletonGraphicsWidget::addSelectEdge); connect(m_document, &SkeletonDocument::partListChanged, partListWidget, &SkeletonPartListWidget::partListChanged); connect(m_document, &SkeletonDocument::partPreviewChanged, partListWidget, &SkeletonPartListWidget::partPreviewChanged); @@ -789,6 +792,7 @@ void SkeletonDocumentWindow::open() SkeletonSnapshot snapshot; loadSkeletonFromXmlStream(&snapshot, stream); m_document->fromSnapshot(snapshot); + m_document->saveSnapshot(); } else if (item.type == "asset") { if (item.name == "canvas.png") { QByteArray data; diff --git a/src/skeletongraphicswidget.cpp b/src/skeletongraphicswidget.cpp index fba1b995..21cfd976 100644 --- a/src/skeletongraphicswidget.cpp +++ b/src/skeletongraphicswidget.cpp @@ -1600,6 +1600,28 @@ void SkeletonGraphicsWidget::selectPartAllById(QUuid partId) hoverPart(QUuid()); } +void SkeletonGraphicsWidget::addSelectNode(QUuid nodeId) +{ + const auto &findResult = nodeItemMap.find(nodeId); + if (findResult == nodeItemMap.end()) { + qDebug() << "addSelectNode failed because of node id not exists:<<" << nodeId; + return; + } + addItemToRangeSelection(findResult->second.first); + hoverPart(QUuid()); +} + +void SkeletonGraphicsWidget::addSelectEdge(QUuid edgeId) +{ + const auto &findResult = edgeItemMap.find(edgeId); + if (findResult == edgeItemMap.end()) { + qDebug() << "addSelectEdge failed because of edge id not exists:<<" << edgeId; + return; + } + addItemToRangeSelection(findResult->second.first); + hoverPart(QUuid()); +} + void SkeletonGraphicsWidget::selectPartAll() { unselectAll(); diff --git a/src/skeletongraphicswidget.h b/src/skeletongraphicswidget.h index 8deae100..d39b303d 100644 --- a/src/skeletongraphicswidget.h +++ b/src/skeletongraphicswidget.h @@ -427,6 +427,8 @@ public slots: void originChanged(); void alignSelectedToCenter(); void selectPartAllById(QUuid partId); + void addSelectNode(QUuid nodeId); + void addSelectEdge(QUuid edgeId); void enableBackgroundBlur(); void disableBackgroundBlur(); private slots: diff --git a/src/skeletonpartlistwidget.cpp b/src/skeletonpartlistwidget.cpp index 38975c15..2d635882 100644 --- a/src/skeletonpartlistwidget.cpp +++ b/src/skeletonpartlistwidget.cpp @@ -754,7 +754,7 @@ void SkeletonPartListWidget::partUnchecked(QUuid partId) { auto item = m_itemMap.find(partId); if (item == m_itemMap.end()) { - qDebug() << "Part item not found:" << partId; + //qDebug() << "Part item not found:" << partId; return; } SkeletonPartWidget *widget = (SkeletonPartWidget *)itemWidget(item->second);