Refactoring dialog history.

--HG--
branch : feature
This commit is contained in:
dismine 2014-03-02 20:32:54 +02:00
parent 3e98a84308
commit 084061fbd5
5 changed files with 285 additions and 325 deletions

View File

@ -115,9 +115,9 @@
<xs:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:string"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="typeObject" type="xs:string"></xs:attribute>
<xs:attribute name="my" type="xs:string"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
</xs:complexType>
@ -150,8 +150,8 @@
<xs:complexType>
<xs:attribute name="nodeType" type="xs:string"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="my" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>
@ -179,8 +179,8 @@
<xs:complexType>
<xs:attribute name="nodeType" type="xs:string"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="my" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute>
</xs:complexType>
</xs:element>

View File

@ -53,7 +53,7 @@
<!--<scye_depth name="" value="0.0" gui_text="" description="Номер размерного признака "/>-->
<shoulder_and_arm_length name="Дрзап" value="0.0" gui_text="Длина руки до запястья" description="Номер размерного признака 68"/>
<underarm_length name="Взу" value="0.0" gui_text="Высота заднего угла подмышечной впадины" description="Номер размерного признака 11"/>
<cervical_to_wrist_length name="" value="0.0" gui_text="" description="Номер размерного признака "/>
<cervicale_to_wrist_length name="" value="0.0" gui_text="" description="Номер размерного признака "/>
<shoulder_to_elbow_length name="" value="0.0" gui_text="" description="Номер размерного признака "/>
<arm_length name="" value="0.0" gui_text="" description="Номер размерного признака "/>
</arm>
@ -74,12 +74,12 @@
<foot>
<foot_width name="" value="0.0" gui_text="" description="Номер размерного признака "/>
<foot_length name="" value="0.0" gui_text="" description="Номер размерного признака "/>
<foot_girth name="" value="0.0" gui_text="" description="Номер размерного признака "/>
<foot_width name="" value="0.0" gui_text="" description="Номер размерного признака "/>
</foot>
<heights>
<height name="" value="0.0" gui_text="" description="Номер размерного признака "/>
<cervical_height name="" value="0.0" gui_text="" description="Номер размерного признака "/>
<cervical_to_knee_height name="" value="0.0" gui_text="" description="Номер размерного признака "/>
<cervicale_height name="" value="0.0" gui_text="" description="Номер размерного признака "/>
<cervicale_to_knee_height name="" value="0.0" gui_text="" description="Номер размерного признака "/>
<waist_height name="" value="0.0" gui_text="" description="Номер размерного признака "/>
<high_hip_height name="" value="0.0" gui_text="" description="Номер размерного признака "/>
<hip_height name="" value="0.0" gui_text="" description="Номер размерного признака "/>

View File

@ -74,7 +74,7 @@ public:
*/
void setData(const VContainer &data);
template <typename T>
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<T>(gObj);
Q_CHECK_PTR(obj);
return obj;
try
{
T obj = dynamic_cast<T>(gObj);
Q_CHECK_PTR(obj);
return obj;
}
catch(const std::bad_alloc &)
{
throw VExceptionBadId(tr("Can't cast object"), id);
return nullptr;
}
return nullptr;
}
/**

View File

@ -121,36 +121,45 @@ void DialogHistory::UpdateHistory()
void DialogHistory::FillTable()
{
ui->tableWidget->clear();
QVector<VToolRecord> *history = doc->getHistory();
const QVector<VToolRecord> *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<const VPointF *>(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<const VPointF *>(basePointId)->name();
QString toolIdName = data->GeometricObject<const VPointF *>(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<const VPointF *>(firstPointId)->name();
QString secondPointIdName = data->GeometricObject<const VPointF *>(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<const VPointF *>(basePointId)->name();
QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
record = QString(tr("%3 - Point along line %1_%2")).arg(basePointIdName, secondPointIdName, toolIdName);
break;
}
case Tool::ShoulderPointTool:
{
QString name = data->GeometricObject<const VPointF *>(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<const VPointF *>(basePointId)->name();
QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
QString toolIdName = data->GeometricObject<const VPointF *>(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<const VPointF *>(firstPointId)->name();
QString basePointIdName = data->GeometricObject<const VPointF *>(basePointId)->name();
QString thirdPointIdName = data->GeometricObject<const VPointF *>(thirdPointId)->name();
QString toolIdName = data->GeometricObject<const VPointF *>(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<const VPointF *>(p1Line1)->name();
QString p2Line1Name = data->GeometricObject<const VPointF *>(p2Line1)->name();
QString p1Line2Name = data->GeometricObject<const VPointF *>(p1Line2)->name();
QString p2Line2Name = data->GeometricObject<const VPointF *>(p2Line2)->name();
QString toolIdName = data->GeometricObject<const VPointF *>(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<const VSpline *>(tool.getId());
QString splP1Name = data->GeometricObject<const VSpline *>(spl->GetP1().id())->name();
QString splP4Name = data->GeometricObject<const VSpline *>(spl->GetP4().id())->name();
record = QString(tr("Curve %1_%2")).arg(splP1Name, splP4Name);
}
break;
case Tool::ArcTool:
{
const VArc *arc = data->GeometricObject<const VArc *>(tool.getId());
QString arcCenterName = data->GeometricObject<const VArc *>(arc->GetCenter().id())->name();
record = QString(tr("Arc with center in point %1")).arg(arcCenterName);
}
break;
case Tool::SplinePathTool:
{
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(tool.getId());
QVector<VSplinePoint> points = splPath->GetSplinePath();
if (points.size() != 0 )
{
QString pName = data->GeometricObject<const VPointF *>(points[0].P().id())->name();
record = QString(tr("Curve point %1")).arg(pName);
for (qint32 i = 1; i< points.size(); ++i)
{
pName = data->GeometricObject<const VPointF *>(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<const VPointF *>(firstPointId)->name();
QString centerName = data->GeometricObject<const VPointF *>(center)->name();
QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
QString toolIdName = data->GeometricObject<const VPointF *>(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<const VPointF *>(basePointId)->name();
QString p1LineIdName = data->GeometricObject<const VPointF *>(p1LineId)->name();
QString p2LineIdName = data->GeometricObject<const VPointF *>(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<const VPointF *>(axisP1Id)->name();
QString axisP2IdName = data->GeometricObject<const VPointF *>(axisP2Id)->name();
QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name();
QString secondPointIdName = data->GeometricObject<const VPointF *>(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<const VPointF *>(firstPointId)->name();
QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
QString toolIdName = data->GeometricObject<const VPointF *>(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<const VArc *>(arcId);
QString arcCenterName = data->GeometricObject<const VArc *>(arc->GetCenter().id())->name();
QString toolIdName = data->GeometricObject<const VPointF *>(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<const VSpline *>(splineId);
QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
QString splP1Name = data->GeometricObject<const VPointF *>(spl->GetP1().id())->name();
QString splP4Name = data->GeometricObject<const VPointF *>(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<const VSplinePath *>(splinePathId);
QVector<VSplinePoint> points = splPath->GetSplinePath();
if (points.size() != 0 )
{
QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
QString pName = data->GeometricObject<const VPointF *>(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<const VPointF *>(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()<<tr("Got wrong tool type. Ignore.");
break;
qWarning()<<"Can't find element by id"<<Q_FUNC_INFO;
return QString(tr("Can't create record."));
}
return record;
try
{
switch ( tool.getTypeTool() )
{
case Tool::ArrowTool:
Q_UNREACHABLE();
break;
case Tool::SinglePointTool:
{
const QString name = data->GeometricObject<const VPointF *>(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<const VPointF *>(basePointId)->name();
const QString toolIdName = data->GeometricObject<const VPointF *>(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<const VPointF *>(firstPointId)->name();
const QString secondPointIdName = data->GeometricObject<const VPointF *>(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<const VPointF *>(basePointId)->name();
const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
return QString(tr("%3 - Point along line %1_%2")).arg(basePointIdName, secondPointIdName, toolIdName);
}
case Tool::ShoulderPointTool:
{
const QString name = data->GeometricObject<const VPointF *>(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<const VPointF *>(basePointId)->name();
const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
const QString toolIdName = data->GeometricObject<const VPointF *>(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<const VPointF *>(firstPointId)->name();
const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
const QString thirdPointIdName = data->GeometricObject<const VPointF *>(thirdPointId)->name();
const QString toolIdName = data->GeometricObject<const VPointF *>(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<const VPointF *>(p1Line1)->name();
const QString p2Line1Name = data->GeometricObject<const VPointF *>(p2Line1)->name();
const QString p1Line2Name = data->GeometricObject<const VPointF *>(p1Line2)->name();
const QString p2Line2Name = data->GeometricObject<const VPointF *>(p2Line2)->name();
const QString toolIdName = data->GeometricObject<const VPointF *>(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<const VSpline *>(tool.getId());
Q_CHECK_PTR(spl);
const QString splP1Name = data->GeometricObject<const VPointF *>(spl->GetP1().id())->name();
const QString splP4Name = data->GeometricObject<const VPointF *>(spl->GetP4().id())->name();
return QString(tr("Curve %1_%2")).arg(splP1Name, splP4Name);
}
case Tool::ArcTool:
{
const VArc *arc = data->GeometricObject<const VArc *>(tool.getId());
Q_CHECK_PTR(arc);
const QString arcCenterName = data->GeometricObject<const VArc *>(arc->GetCenter().id())->name();
return QString(tr("Arc with center in point %1")).arg(arcCenterName);
}
case Tool::SplinePathTool:
{
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(tool.getId());
Q_CHECK_PTR(splPath);
const QVector<VSplinePoint> points = splPath->GetSplinePath();
QString record;
if (points.size() != 0 )
{
const QString pName = data->GeometricObject<const VPointF *>(points.at(0).P().id())->name();
record = QString(tr("Curve point %1")).arg(pName);
if(points.size() > 1)
{
const QString pName = data->GeometricObject<const VPointF *>(points.last().P().id())->name();
record.append(QString("_%1").arg(pName));
}
}
else
{
qWarning()<<"Not enough points in splinepath"<<Q_FUNC_INFO;
return QString(tr("Can't create record."));
}
return record;
}
case Tool::PointOfContact:
{
const quint32 center = doc->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<const VPointF *>(firstPointId)->name();
const QString centerName = data->GeometricObject<const VPointF *>(center)->name();
const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
const QString toolIdName = data->GeometricObject<const VPointF *>(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<const VPointF *>(basePointId)->name();
const QString p1LineIdName = data->GeometricObject<const VPointF *>(p1LineId)->name();
const QString p2LineIdName = data->GeometricObject<const VPointF *>(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<const VPointF *>(axisP1Id)->name();
const QString axisP2IdName = data->GeometricObject<const VPointF *>(axisP2Id)->name();
const QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name();
const QString secondPointIdName = data->GeometricObject<const VPointF *>(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<const VPointF *>(firstPointId)->name();
const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
const QString toolIdName = data->GeometricObject<const VPointF *>(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<const VArc *>(arcId);
Q_CHECK_PTR(arc);
const QString arcCenterName = data->GeometricObject<const VArc *>(arc->GetCenter().id())->name();
const QString toolIdName = data->GeometricObject<const VPointF *>(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<const VSpline *>(splineId);
Q_CHECK_PTR(spl);
const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
const QString splP1Name = data->GeometricObject<const VPointF *>(spl->GetP1().id())->name();
const QString splP4Name = data->GeometricObject<const VPointF *>(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<const VSplinePath *>(splinePathId);
Q_CHECK_PTR(splPath);
const QVector<VSplinePoint> points = splPath->GetSplinePath();
QString record;
if (points.size() != 0 )
{
const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
const QString pName = data->GeometricObject<const VPointF *>(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<const VPointF *>(points.last().P().id())->name();
const QString name = QString("_%1").arg(pName);
record.append(name);
}
}
else
{
qWarning()<<"Not enough points in splinepath"<<Q_FUNC_INFO;
return QString(tr("Can't create record."));
}
return record;
}
//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:
break;
case Tool::UnionDetails:
break;
case Tool::NodeArc:
break;
case Tool::NodePoint:
break;
case Tool::NodeSpline:
break;
case Tool::NodeSplinePath:
break;
default:
qWarning()<<tr("Got wrong tool type. Ignore.");
break;
}
}
catch (const VExceptionBadId &e)
{
qWarning()<<e.ErrorMessage()<<Q_FUNC_INFO;
return QString(tr("Can't create record."));
}
return QString();
}
void DialogHistory::InitialTable()

View File

@ -1039,9 +1039,9 @@ void MainWindow::ActionHistory(bool checked)
if (checked)
{
dialogHistory = new DialogHistory(pattern, doc, this);
Q_CHECK_PTR(dialogHistory);
dialogHistory->setWindowFlags(Qt::Window);
connect(dialogHistory, &DialogHistory::DialogClosed, this,
&MainWindow::ClosedActionHistory);
connect(dialogHistory, &DialogHistory::DialogClosed, this, &MainWindow::ClosedActionHistory);
dialogHistory->show();
}
else