From 084061fbd57938aeff8444265e07d5d971783898 Mon Sep 17 00:00:00 2001 From: dismine Date: Sun, 2 Mar 2014 20:32:54 +0200 Subject: [PATCH] Refactoring dialog history. --HG-- branch : feature --- share/resources/schema/pattern.xsd | 12 +- share/tables/individual/indivindual_ru.vit | 8 +- src/container/vcontainer.h | 19 +- src/dialogs/app/dialoghistory.cpp | 567 ++++++++++----------- src/mainwindow.cpp | 4 +- 5 files changed, 285 insertions(+), 325 deletions(-) diff --git a/share/resources/schema/pattern.xsd b/share/resources/schema/pattern.xsd index d1a1fe300..78a444e41 100644 --- a/share/resources/schema/pattern.xsd +++ b/share/resources/schema/pattern.xsd @@ -115,9 +115,9 @@ - + - + @@ -150,8 +150,8 @@ - - + + @@ -179,8 +179,8 @@ - - + + diff --git a/share/tables/individual/indivindual_ru.vit b/share/tables/individual/indivindual_ru.vit index 3f6192a39..0b2e1b5fc 100644 --- a/share/tables/individual/indivindual_ru.vit +++ b/share/tables/individual/indivindual_ru.vit @@ -53,7 +53,7 @@ - + @@ -74,12 +74,12 @@ - + - - + + diff --git a/src/container/vcontainer.h b/src/container/vcontainer.h index eee7edbda..e640f22d0 100644 --- a/src/container/vcontainer.h +++ b/src/container/vcontainer.h @@ -74,7 +74,7 @@ public: */ void setData(const VContainer &data); template - const T GeometricObject(quint32 id) const + const T GeometricObject(const quint32 &id) const { VGObject *gObj = nullptr; if (gObjects.contains(id)) @@ -84,10 +84,21 @@ public: else { throw VExceptionBadId(tr("Can't find object"), id); + return nullptr; } - T obj = dynamic_cast(gObj); - Q_CHECK_PTR(obj); - return obj; + + try + { + T obj = dynamic_cast(gObj); + Q_CHECK_PTR(obj); + return obj; + } + catch(const std::bad_alloc &) + { + throw VExceptionBadId(tr("Can't cast object"), id); + return nullptr; + } + return nullptr; } /** diff --git a/src/dialogs/app/dialoghistory.cpp b/src/dialogs/app/dialoghistory.cpp index 756cf7982..ad0155a5b 100644 --- a/src/dialogs/app/dialoghistory.cpp +++ b/src/dialogs/app/dialoghistory.cpp @@ -121,36 +121,45 @@ void DialogHistory::UpdateHistory() void DialogHistory::FillTable() { ui->tableWidget->clear(); - QVector *history = doc->getHistory(); + const QVector *history = doc->getHistory(); + Q_CHECK_PTR(history); qint32 currentRow = -1; qint32 count = 0; ui->tableWidget->setRowCount(history->size()); for (qint32 i = 0; i< history->size(); ++i) { - VToolRecord tool = history->at(i); + const VToolRecord tool = history->at(i); if (tool.getNameDraw() != doc->GetNameActivDraw()) { continue; } - currentRow++; + const QString historyRecord = Record(tool); + if (historyRecord.isEmpty() ==false) + { + currentRow++; - QTableWidgetItem *item = new QTableWidgetItem(QString()); - item->setTextAlignment(Qt::AlignHCenter); - item->setData(Qt::UserRole, tool.getId()); - ui->tableWidget->setItem(currentRow, 0, item); + { + QTableWidgetItem *item = new QTableWidgetItem(QString()); + Q_CHECK_PTR(item); + item->setTextAlignment(Qt::AlignHCenter); + item->setData(Qt::UserRole, tool.getId()); + ui->tableWidget->setItem(currentRow, 0, item); + } - QString historyRecord = Record(tool); - item = new QTableWidgetItem(historyRecord); - item->setFont(QFont("Times", 12, QFont::Bold)); - item->setFlags(item->flags() ^ Qt::ItemIsEditable); - ui->tableWidget->setItem(currentRow, 1, item); - ++count; + QTableWidgetItem *item = new QTableWidgetItem(historyRecord); + Q_CHECK_PTR(item); + item->setFont(QFont("Times", 12, QFont::Bold)); + item->setFlags(item->flags() ^ Qt::ItemIsEditable); + ui->tableWidget->setItem(currentRow, 1, item); + ++count; + } } ui->tableWidget->setRowCount(count); if (history->size()>0) { cursorRow = currentRow; QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0); + Q_CHECK_PTR(item); item->setIcon(QIcon("://icon/32x32/put_after.png")); } ui->tableWidget->resizeColumnsToContents(); @@ -160,304 +169,244 @@ void DialogHistory::FillTable() QString DialogHistory::Record(const VToolRecord &tool) { - QString record = QString(); - quint32 basePointId = 0; - quint32 secondPointId = 0; - quint32 firstPointId = 0; - quint32 thirdPointId = 0; - quint32 p1Line1 = 0; - quint32 p2Line1 = 0; - quint32 p1Line2 = 0; - quint32 p2Line2 = 0; - quint32 center = 0; - QDomElement domElement; - switch ( tool.getTypeTool() ) + const QDomElement domElement = doc->elementById(QString().setNum(tool.getId())); + if (domElement.isElement() == false) { - case Tool::ArrowTool: - Q_UNREACHABLE(); - break; - case Tool::SinglePointTool: - { - QString name = data->GeometricObject(tool.getId())->name(); - record = QString(tr("%1 - Base point")).arg(name); - break; - } - case Tool::EndLineTool: - { - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0"); - } - QString basePointIdName = data->GeometricObject(basePointId)->name(); - QString toolIdName = data->GeometricObject(tool.getId())->name(); - record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(basePointIdName, toolIdName); - break; - } - case Tool::LineTool: - { - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); - secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); - } - QString firstPointIdName = data->GeometricObject(firstPointId)->name(); - QString secondPointIdName = data->GeometricObject(secondPointId)->name(); - record = QString(tr("%1_%2 - Line from point %1 to point %2")).arg(firstPointIdName, secondPointIdName); - break; - } - case Tool::AlongLineTool: - { - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); - secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); - } - QString basePointIdName = data->GeometricObject(basePointId)->name(); - QString secondPointIdName = data->GeometricObject(secondPointId)->name(); - QString toolIdName = data->GeometricObject(tool.getId())->name(); - record = QString(tr("%3 - Point along line %1_%2")).arg(basePointIdName, secondPointIdName, toolIdName); - break; - } - case Tool::ShoulderPointTool: - { - QString name = data->GeometricObject(tool.getId())->name(); - record = QString(tr("%1 - Point of shoulder")).arg(name); - break; - } - case Tool::NormalTool: - { - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); - secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); - } - QString basePointIdName = data->GeometricObject(basePointId)->name(); - QString secondPointIdName = data->GeometricObject(secondPointId)->name(); - QString toolIdName = data->GeometricObject(tool.getId())->name(); - record = QString(tr("%3 - normal to line %1_%2")).arg(basePointIdName, secondPointIdName, toolIdName); - break; - } - case Tool::BisectorTool: - { - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); - secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); - thirdPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrThirdPoint, "0"); - } - QString firstPointIdName = data->GeometricObject(firstPointId)->name(); - QString basePointIdName = data->GeometricObject(basePointId)->name(); - QString thirdPointIdName = data->GeometricObject(thirdPointId)->name(); - QString toolIdName = data->GeometricObject(tool.getId())->name(); - record = QString(tr("%4 - bisector of angle %1_%2_%3")).arg(firstPointIdName, basePointIdName, - thirdPointIdName, toolIdName); - break; - } - case Tool::LineIntersectTool: - { - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - p1Line1 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP1Line1, "0"); - p2Line1 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP2Line1, "0"); - p1Line2 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP1Line2, "0"); - p2Line2 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP2Line2, "0"); - } - QString p1Line1Name = data->GeometricObject(p1Line1)->name(); - QString p2Line1Name = data->GeometricObject(p2Line1)->name(); - QString p1Line2Name = data->GeometricObject(p1Line2)->name(); - QString p2Line2Name = data->GeometricObject(p2Line2)->name(); - QString toolIdName = data->GeometricObject(tool.getId())->name(); - record = QString(tr("%5 - intersection of lines %1_%2 and %3_%4")).arg(p1Line1Name, p2Line1Name, - p1Line2Name, p2Line2Name, - toolIdName); - break; - } - case Tool::SplineTool: - { - const VSpline *spl = data->GeometricObject(tool.getId()); - QString splP1Name = data->GeometricObject(spl->GetP1().id())->name(); - QString splP4Name = data->GeometricObject(spl->GetP4().id())->name(); - record = QString(tr("Curve %1_%2")).arg(splP1Name, splP4Name); - } - break; - case Tool::ArcTool: - { - const VArc *arc = data->GeometricObject(tool.getId()); - QString arcCenterName = data->GeometricObject(arc->GetCenter().id())->name(); - record = QString(tr("Arc with center in point %1")).arg(arcCenterName); - } - break; - case Tool::SplinePathTool: - { - const VSplinePath *splPath = data->GeometricObject(tool.getId()); - QVector points = splPath->GetSplinePath(); - if (points.size() != 0 ) - { - QString pName = data->GeometricObject(points[0].P().id())->name(); - record = QString(tr("Curve point %1")).arg(pName); - for (qint32 i = 1; i< points.size(); ++i) - { - pName = data->GeometricObject(points[i].P().id())->name(); - QString name = QString("_%1").arg(pName); - record.append(name); - } - } - } - break; - case Tool::PointOfContact: - { - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - center = doc->GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0"); - firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); - secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); - } - QString firstPointIdName = data->GeometricObject(firstPointId)->name(); - QString centerName = data->GeometricObject(center)->name(); - QString secondPointIdName = data->GeometricObject(secondPointId)->name(); - QString toolIdName = data->GeometricObject(tool.getId())->name(); - record = QString(tr("%4 - point of contact of arc with the center in point %1 and line %2_%3")).arg( - centerName, firstPointIdName, secondPointIdName, toolIdName); - break; - } - case Tool::Height: - { - quint32 p1LineId = 0; - quint32 p2LineId = 0; - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0"); - p1LineId = doc->GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0"); - p2LineId = doc->GetParametrUInt(domElement, VAbstractTool::AttrP2Line, "0"); - } - QString basePointIdName = data->GeometricObject(basePointId)->name(); - QString p1LineIdName = data->GeometricObject(p1LineId)->name(); - QString p2LineIdName = data->GeometricObject(p2LineId)->name(); - record = QString(tr("Point of perpendicular from point %1 to line %2_%3")).arg( basePointIdName, - p1LineIdName, p2LineIdName); - break; - } - case Tool::Triangle: - { - quint32 axisP1Id = 0; - quint32 axisP2Id = 0; - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - axisP1Id = doc->GetParametrUInt(domElement, VAbstractTool::AttrAxisP1, "0"); - axisP2Id = doc->GetParametrUInt(domElement, VAbstractTool::AttrAxisP2, "0"); - firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); - secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); - } - QString axisP1IdName = data->GeometricObject(axisP1Id)->name(); - QString axisP2IdName = data->GeometricObject(axisP2Id)->name(); - QString firstPointIdName = data->GeometricObject(firstPointId)->name(); - QString secondPointIdName = data->GeometricObject(secondPointId)->name(); - record = QString(tr("Triangle: axis %1_%2, points %3 and %4")).arg( axisP1IdName, axisP2IdName, - firstPointIdName, secondPointIdName); - break; - } - case Tool::PointOfIntersection: - { - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); - secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); - } - QString firstPointIdName = data->GeometricObject(firstPointId)->name(); - QString secondPointIdName = data->GeometricObject(secondPointId)->name(); - QString toolIdName = data->GeometricObject(tool.getId())->name(); - record = QString(tr("%1 - point of intersection %2 and %3")).arg(toolIdName, firstPointIdName, - secondPointIdName); - } - break; - case Tool::CutArcTool: - { - quint32 arcId = 0; - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - arcId = doc->GetParametrUInt(domElement, VToolCutArc::AttrArc, "0"); - } - const VArc *arc = data->GeometricObject(arcId); - QString arcCenterName = data->GeometricObject(arc->GetCenter().id())->name(); - QString toolIdName = data->GeometricObject(tool.getId())->name(); - record = QString(tr("%1 - cut arc with center %2")).arg(toolIdName, arcCenterName); - } - break; - case Tool::CutSplineTool: - { - quint32 splineId = 0; - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - splineId = doc->GetParametrUInt(domElement, VToolCutSpline::AttrSpline, "0"); - } - const VSpline *spl = data->GeometricObject(splineId); - QString toolIdName = data->GeometricObject(tool.getId())->name(); - QString splP1Name = data->GeometricObject(spl->GetP1().id())->name(); - QString splP4Name = data->GeometricObject(spl->GetP4().id())->name(); - record = QString(tr("%1 - cut curve %2_%3")).arg(toolIdName, splP1Name, splP4Name); - } - break; - case Tool::CutSplinePathTool: - { - quint32 splinePathId = 0; - domElement = doc->elementById(QString().setNum(tool.getId())); - if (domElement.isElement()) - { - splinePathId = doc->GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, "0"); - } - const VSplinePath *splPath = data->GeometricObject(splinePathId); - QVector points = splPath->GetSplinePath(); - if (points.size() != 0 ) - { - QString toolIdName = data->GeometricObject(tool.getId())->name(); - QString pName = data->GeometricObject(points[0].P().id())->name(); - record = QString(tr("%1 - cut curve path %2")).arg(toolIdName, pName); - for (qint32 i = 1; i< points.size(); ++i) - { - pName = data->GeometricObject(points[i].P().id())->name(); - QString name = QString("_%1").arg(pName); - record.append(name); - } - } - } - break; - //Because "history" not only show history of pattern, but help restore current data for each pattern's piece, we - //need add record about details and nodes, but don't show them. - case Tool::Detail: - Q_UNREACHABLE(); - break; - case Tool::UnionDetails: - Q_UNREACHABLE(); - break; - case Tool::NodeArc: - Q_UNREACHABLE(); - break; - case Tool::NodePoint: - Q_UNREACHABLE(); - break; - case Tool::NodeSpline: - Q_UNREACHABLE(); - break; - case Tool::NodeSplinePath: - Q_UNREACHABLE(); - break; - default: - qWarning()<GeometricObject(tool.getId())->name(); + return QString(tr("%1 - Base point")).arg(name); + } + case Tool::EndLineTool: + { + const quint32 basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0"); + const QString basePointIdName = data->GeometricObject(basePointId)->name(); + const QString toolIdName = data->GeometricObject(tool.getId())->name(); + return QString(tr("%1_%2 - Line from point %1 to point %2")).arg(basePointIdName, toolIdName); + } + case Tool::LineTool: + { + const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); + const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); + const QString firstPointIdName = data->GeometricObject(firstPointId)->name(); + const QString secondPointIdName = data->GeometricObject(secondPointId)->name(); + return QString(tr("%1_%2 - Line from point %1 to point %2")).arg(firstPointIdName, secondPointIdName); + } + case Tool::AlongLineTool: + { + const quint32 basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); + const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); + const QString basePointIdName = data->GeometricObject(basePointId)->name(); + const QString secondPointIdName = data->GeometricObject(secondPointId)->name(); + const QString toolIdName = data->GeometricObject(tool.getId())->name(); + return QString(tr("%3 - Point along line %1_%2")).arg(basePointIdName, secondPointIdName, toolIdName); + } + case Tool::ShoulderPointTool: + { + const QString name = data->GeometricObject(tool.getId())->name(); + return QString(tr("%1 - Point of shoulder")).arg(name); + } + case Tool::NormalTool: + { + const quint32 basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); + const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); + const QString basePointIdName = data->GeometricObject(basePointId)->name(); + const QString secondPointIdName = data->GeometricObject(secondPointId)->name(); + const QString toolIdName = data->GeometricObject(tool.getId())->name(); + return QString(tr("%3 - normal to line %1_%2")).arg(basePointIdName, secondPointIdName, toolIdName); + } + case Tool::BisectorTool: + { + const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); + const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); + const quint32 thirdPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrThirdPoint, "0"); + const QString firstPointIdName = data->GeometricObject(firstPointId)->name(); + const QString secondPointIdName = data->GeometricObject(secondPointId)->name(); + const QString thirdPointIdName = data->GeometricObject(thirdPointId)->name(); + const QString toolIdName = data->GeometricObject(tool.getId())->name(); + return QString(tr("%4 - bisector of angle %1_%2_%3")).arg(firstPointIdName, secondPointIdName, + thirdPointIdName, toolIdName); + } + case Tool::LineIntersectTool: + { + const quint32 p1Line1 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP1Line1, "0"); + const quint32 p2Line1 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP2Line1, "0"); + const quint32 p1Line2 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP1Line2, "0"); + const quint32 p2Line2 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP2Line2, "0"); + const QString p1Line1Name = data->GeometricObject(p1Line1)->name(); + const QString p2Line1Name = data->GeometricObject(p2Line1)->name(); + const QString p1Line2Name = data->GeometricObject(p1Line2)->name(); + const QString p2Line2Name = data->GeometricObject(p2Line2)->name(); + const QString toolIdName = data->GeometricObject(tool.getId())->name(); + return QString(tr("%5 - intersection of lines %1_%2 and %3_%4")).arg(p1Line1Name, p2Line1Name, + p1Line2Name, p2Line2Name, + toolIdName); + } + case Tool::SplineTool: + { + const VSpline *spl = data->GeometricObject(tool.getId()); + Q_CHECK_PTR(spl); + const QString splP1Name = data->GeometricObject(spl->GetP1().id())->name(); + const QString splP4Name = data->GeometricObject(spl->GetP4().id())->name(); + return QString(tr("Curve %1_%2")).arg(splP1Name, splP4Name); + } + case Tool::ArcTool: + { + const VArc *arc = data->GeometricObject(tool.getId()); + Q_CHECK_PTR(arc); + const QString arcCenterName = data->GeometricObject(arc->GetCenter().id())->name(); + return QString(tr("Arc with center in point %1")).arg(arcCenterName); + } + case Tool::SplinePathTool: + { + const VSplinePath *splPath = data->GeometricObject(tool.getId()); + Q_CHECK_PTR(splPath); + const QVector points = splPath->GetSplinePath(); + QString record; + if (points.size() != 0 ) + { + const QString pName = data->GeometricObject(points.at(0).P().id())->name(); + record = QString(tr("Curve point %1")).arg(pName); + if(points.size() > 1) + { + const QString pName = data->GeometricObject(points.last().P().id())->name(); + record.append(QString("_%1").arg(pName)); + } + } + else + { + qWarning()<<"Not enough points in splinepath"<GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0"); + const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); + const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); + const QString firstPointIdName = data->GeometricObject(firstPointId)->name(); + const QString centerName = data->GeometricObject(center)->name(); + const QString secondPointIdName = data->GeometricObject(secondPointId)->name(); + const QString toolIdName = data->GeometricObject(tool.getId())->name(); + return QString(tr("%4 - point of contact of arc with the center in point %1 and line %2_%3")).arg( + centerName, firstPointIdName, secondPointIdName, toolIdName); + } + case Tool::Height: + { + const quint32 basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0"); + const quint32 p1LineId = doc->GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0"); + const quint32 p2LineId = doc->GetParametrUInt(domElement, VAbstractTool::AttrP2Line, "0"); + const QString basePointIdName = data->GeometricObject(basePointId)->name(); + const QString p1LineIdName = data->GeometricObject(p1LineId)->name(); + const QString p2LineIdName = data->GeometricObject(p2LineId)->name(); + return QString(tr("Point of perpendicular from point %1 to line %2_%3")).arg(basePointIdName, + p1LineIdName, + p2LineIdName); + } + case Tool::Triangle: + { + const quint32 axisP1Id = doc->GetParametrUInt(domElement, VAbstractTool::AttrAxisP1, "0"); + const quint32 axisP2Id = doc->GetParametrUInt(domElement, VAbstractTool::AttrAxisP2, "0"); + const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); + const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); + const QString axisP1IdName = data->GeometricObject(axisP1Id)->name(); + const QString axisP2IdName = data->GeometricObject(axisP2Id)->name(); + const QString firstPointIdName = data->GeometricObject(firstPointId)->name(); + const QString secondPointIdName = data->GeometricObject(secondPointId)->name(); + return QString(tr("Triangle: axis %1_%2, points %3 and %4")).arg(axisP1IdName, axisP2IdName, + firstPointIdName, secondPointIdName); + } + case Tool::PointOfIntersection: + { + const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); + const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); + const QString firstPointIdName = data->GeometricObject(firstPointId)->name(); + const QString secondPointIdName = data->GeometricObject(secondPointId)->name(); + const QString toolIdName = data->GeometricObject(tool.getId())->name(); + return QString(tr("%1 - point of intersection %2 and %3")).arg(toolIdName, firstPointIdName, + secondPointIdName); + } + case Tool::CutArcTool: + { + const quint32 arcId = doc->GetParametrUInt(domElement, VToolCutArc::AttrArc, "0"); + const VArc *arc = data->GeometricObject(arcId); + Q_CHECK_PTR(arc); + const QString arcCenterName = data->GeometricObject(arc->GetCenter().id())->name(); + const QString toolIdName = data->GeometricObject(tool.getId())->name(); + return QString(tr("%1 - cut arc with center %2")).arg(toolIdName, arcCenterName); + } + case Tool::CutSplineTool: + { + const quint32 splineId = doc->GetParametrUInt(domElement, VToolCutSpline::AttrSpline, "0"); + const VSpline *spl = data->GeometricObject(splineId); + Q_CHECK_PTR(spl); + const QString toolIdName = data->GeometricObject(tool.getId())->name(); + const QString splP1Name = data->GeometricObject(spl->GetP1().id())->name(); + const QString splP4Name = data->GeometricObject(spl->GetP4().id())->name(); + return QString(tr("%1 - cut curve %2_%3")).arg(toolIdName, splP1Name, splP4Name); + } + case Tool::CutSplinePathTool: + { + const quint32 splinePathId = doc->GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, "0"); + const VSplinePath *splPath = data->GeometricObject(splinePathId); + Q_CHECK_PTR(splPath); + const QVector points = splPath->GetSplinePath(); + QString record; + if (points.size() != 0 ) + { + const QString toolIdName = data->GeometricObject(tool.getId())->name(); + const QString pName = data->GeometricObject(points.at(0).P().id())->name(); + record = QString(tr("%1 - cut curve path %2")).arg(toolIdName, pName); + if (points.size() > 1) + { + const QString pName = data->GeometricObject(points.last().P().id())->name(); + const QString name = QString("_%1").arg(pName); + record.append(name); + } + } + else + { + qWarning()<<"Not enough points in splinepath"<setWindowFlags(Qt::Window); - connect(dialogHistory, &DialogHistory::DialogClosed, this, - &MainWindow::ClosedActionHistory); + connect(dialogHistory, &DialogHistory::DialogClosed, this, &MainWindow::ClosedActionHistory); dialogHistory->show(); } else