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:complexType>
<xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute> <xs:attribute name="id" type="xs:unsignedInt" use="required"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></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="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="type" type="xs:string"></xs:attribute>
<xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute> <xs:attribute name="idTool" type="xs:unsignedInt"></xs:attribute>
</xs:complexType> </xs:complexType>
@ -150,8 +150,8 @@
<xs:complexType> <xs:complexType>
<xs:attribute name="nodeType" type="xs:string"></xs:attribute> <xs:attribute name="nodeType" type="xs:string"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute> <xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:unsignedInt"></xs:attribute> <xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:unsignedInt"></xs:attribute> <xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute> <xs:attribute name="type" type="xs:string"></xs:attribute>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
@ -179,8 +179,8 @@
<xs:complexType> <xs:complexType>
<xs:attribute name="nodeType" type="xs:string"></xs:attribute> <xs:attribute name="nodeType" type="xs:string"></xs:attribute>
<xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute> <xs:attribute name="idObject" type="xs:unsignedInt"></xs:attribute>
<xs:attribute name="mx" type="xs:unsignedInt"></xs:attribute> <xs:attribute name="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:unsignedInt"></xs:attribute> <xs:attribute name="my" type="xs:double"></xs:attribute>
<xs:attribute name="type" type="xs:string"></xs:attribute> <xs:attribute name="type" type="xs:string"></xs:attribute>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>

View File

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

View File

@ -74,7 +74,7 @@ public:
*/ */
void setData(const VContainer &data); void setData(const VContainer &data);
template <typename T> template <typename T>
const T GeometricObject(quint32 id) const const T GeometricObject(const quint32 &id) const
{ {
VGObject *gObj = nullptr; VGObject *gObj = nullptr;
if (gObjects.contains(id)) if (gObjects.contains(id))
@ -84,11 +84,22 @@ public:
else else
{ {
throw VExceptionBadId(tr("Can't find object"), id); throw VExceptionBadId(tr("Can't find object"), id);
return nullptr;
} }
try
{
T obj = dynamic_cast<T>(gObj); T obj = dynamic_cast<T>(gObj);
Q_CHECK_PTR(obj); Q_CHECK_PTR(obj);
return obj; return obj;
} }
catch(const std::bad_alloc &)
{
throw VExceptionBadId(tr("Can't cast object"), id);
return nullptr;
}
return nullptr;
}
/** /**
* @brief GetGObject returns a point by id * @brief GetGObject returns a point by id

View File

@ -121,36 +121,45 @@ void DialogHistory::UpdateHistory()
void DialogHistory::FillTable() void DialogHistory::FillTable()
{ {
ui->tableWidget->clear(); ui->tableWidget->clear();
QVector<VToolRecord> *history = doc->getHistory(); const QVector<VToolRecord> *history = doc->getHistory();
Q_CHECK_PTR(history);
qint32 currentRow = -1; qint32 currentRow = -1;
qint32 count = 0; qint32 count = 0;
ui->tableWidget->setRowCount(history->size()); ui->tableWidget->setRowCount(history->size());
for (qint32 i = 0; i< history->size(); ++i) for (qint32 i = 0; i< history->size(); ++i)
{ {
VToolRecord tool = history->at(i); const VToolRecord tool = history->at(i);
if (tool.getNameDraw() != doc->GetNameActivDraw()) if (tool.getNameDraw() != doc->GetNameActivDraw())
{ {
continue; continue;
} }
const QString historyRecord = Record(tool);
if (historyRecord.isEmpty() ==false)
{
currentRow++; currentRow++;
{
QTableWidgetItem *item = new QTableWidgetItem(QString()); QTableWidgetItem *item = new QTableWidgetItem(QString());
Q_CHECK_PTR(item);
item->setTextAlignment(Qt::AlignHCenter); item->setTextAlignment(Qt::AlignHCenter);
item->setData(Qt::UserRole, tool.getId()); item->setData(Qt::UserRole, tool.getId());
ui->tableWidget->setItem(currentRow, 0, item); ui->tableWidget->setItem(currentRow, 0, item);
}
QString historyRecord = Record(tool); QTableWidgetItem *item = new QTableWidgetItem(historyRecord);
item = new QTableWidgetItem(historyRecord); Q_CHECK_PTR(item);
item->setFont(QFont("Times", 12, QFont::Bold)); item->setFont(QFont("Times", 12, QFont::Bold));
item->setFlags(item->flags() ^ Qt::ItemIsEditable); item->setFlags(item->flags() ^ Qt::ItemIsEditable);
ui->tableWidget->setItem(currentRow, 1, item); ui->tableWidget->setItem(currentRow, 1, item);
++count; ++count;
} }
}
ui->tableWidget->setRowCount(count); ui->tableWidget->setRowCount(count);
if (history->size()>0) if (history->size()>0)
{ {
cursorRow = currentRow; cursorRow = currentRow;
QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0); QTableWidgetItem *item = ui->tableWidget->item(cursorRow, 0);
Q_CHECK_PTR(item);
item->setIcon(QIcon("://icon/32x32/put_after.png")); item->setIcon(QIcon("://icon/32x32/put_after.png"));
} }
ui->tableWidget->resizeColumnsToContents(); ui->tableWidget->resizeColumnsToContents();
@ -160,17 +169,14 @@ void DialogHistory::FillTable()
QString DialogHistory::Record(const VToolRecord &tool) QString DialogHistory::Record(const VToolRecord &tool)
{ {
QString record = QString(); const QDomElement domElement = doc->elementById(QString().setNum(tool.getId()));
quint32 basePointId = 0; if (domElement.isElement() == false)
quint32 secondPointId = 0; {
quint32 firstPointId = 0; qWarning()<<"Can't find element by id"<<Q_FUNC_INFO;
quint32 thirdPointId = 0; return QString(tr("Can't create record."));
quint32 p1Line1 = 0; }
quint32 p2Line1 = 0; try
quint32 p1Line2 = 0; {
quint32 p2Line2 = 0;
quint32 center = 0;
QDomElement domElement;
switch ( tool.getTypeTool() ) switch ( tool.getTypeTool() )
{ {
case Tool::ArrowTool: case Tool::ArrowTool:
@ -178,286 +184,229 @@ QString DialogHistory::Record(const VToolRecord &tool)
break; break;
case Tool::SinglePointTool: case Tool::SinglePointTool:
{ {
QString name = data->GeometricObject<const VPointF *>(tool.getId())->name(); const QString name = data->GeometricObject<const VPointF *>(tool.getId())->name();
record = QString(tr("%1 - Base point")).arg(name); return QString(tr("%1 - Base point")).arg(name);
break;
} }
case Tool::EndLineTool: case Tool::EndLineTool:
{ {
domElement = doc->elementById(QString().setNum(tool.getId())); const quint32 basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0");
if (domElement.isElement()) const QString basePointIdName = data->GeometricObject<const VPointF *>(basePointId)->name();
{ const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0"); return QString(tr("%1_%2 - Line from point %1 to point %2")).arg(basePointIdName, toolIdName);
}
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: case Tool::LineTool:
{ {
domElement = doc->elementById(QString().setNum(tool.getId())); const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
if (domElement.isElement()) const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
{ const QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name();
firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); return QString(tr("%1_%2 - Line from point %1 to point %2")).arg(firstPointIdName, secondPointIdName);
}
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: case Tool::AlongLineTool:
{ {
domElement = doc->elementById(QString().setNum(tool.getId())); const quint32 basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
if (domElement.isElement()) const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
{ const QString basePointIdName = data->GeometricObject<const VPointF *>(basePointId)->name();
basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
} return QString(tr("%3 - Point along line %1_%2")).arg(basePointIdName, secondPointIdName, toolIdName);
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: case Tool::ShoulderPointTool:
{ {
QString name = data->GeometricObject<const VPointF *>(tool.getId())->name(); const QString name = data->GeometricObject<const VPointF *>(tool.getId())->name();
record = QString(tr("%1 - Point of shoulder")).arg(name); return QString(tr("%1 - Point of shoulder")).arg(name);
break;
} }
case Tool::NormalTool: case Tool::NormalTool:
{ {
domElement = doc->elementById(QString().setNum(tool.getId())); const quint32 basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
if (domElement.isElement()) const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
{ const QString basePointIdName = data->GeometricObject<const VPointF *>(basePointId)->name();
basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
} return QString(tr("%3 - normal to line %1_%2")).arg(basePointIdName, secondPointIdName, toolIdName);
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: case Tool::BisectorTool:
{ {
domElement = doc->elementById(QString().setNum(tool.getId())); const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
if (domElement.isElement()) const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
{ const quint32 thirdPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrThirdPoint, "0");
firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name();
secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
thirdPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrThirdPoint, "0"); const QString thirdPointIdName = data->GeometricObject<const VPointF *>(thirdPointId)->name();
} const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name(); return QString(tr("%4 - bisector of angle %1_%2_%3")).arg(firstPointIdName, secondPointIdName,
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); thirdPointIdName, toolIdName);
break;
} }
case Tool::LineIntersectTool: case Tool::LineIntersectTool:
{ {
domElement = doc->elementById(QString().setNum(tool.getId())); const quint32 p1Line1 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP1Line1, "0");
if (domElement.isElement()) const quint32 p2Line1 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP2Line1, "0");
{ const quint32 p1Line2 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP1Line2, "0");
p1Line1 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP1Line1, "0"); const quint32 p2Line2 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP2Line2, "0");
p2Line1 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP2Line1, "0"); const QString p1Line1Name = data->GeometricObject<const VPointF *>(p1Line1)->name();
p1Line2 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP1Line2, "0"); const QString p2Line1Name = data->GeometricObject<const VPointF *>(p2Line1)->name();
p2Line2 = doc->GetParametrUInt(domElement, VAbstractTool::AttrP2Line2, "0"); const QString p1Line2Name = data->GeometricObject<const VPointF *>(p1Line2)->name();
} const QString p2Line2Name = data->GeometricObject<const VPointF *>(p2Line2)->name();
QString p1Line1Name = data->GeometricObject<const VPointF *>(p1Line1)->name(); const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
QString p2Line1Name = data->GeometricObject<const VPointF *>(p2Line1)->name(); return QString(tr("%5 - intersection of lines %1_%2 and %3_%4")).arg(p1Line1Name, p2Line1Name,
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, p1Line2Name, p2Line2Name,
toolIdName); toolIdName);
break;
} }
case Tool::SplineTool: case Tool::SplineTool:
{ {
const VSpline *spl = data->GeometricObject<const VSpline *>(tool.getId()); const VSpline *spl = data->GeometricObject<const VSpline *>(tool.getId());
QString splP1Name = data->GeometricObject<const VSpline *>(spl->GetP1().id())->name(); Q_CHECK_PTR(spl);
QString splP4Name = data->GeometricObject<const VSpline *>(spl->GetP4().id())->name(); const QString splP1Name = data->GeometricObject<const VPointF *>(spl->GetP1().id())->name();
record = QString(tr("Curve %1_%2")).arg(splP1Name, splP4Name); const QString splP4Name = data->GeometricObject<const VPointF *>(spl->GetP4().id())->name();
return QString(tr("Curve %1_%2")).arg(splP1Name, splP4Name);
} }
break;
case Tool::ArcTool: case Tool::ArcTool:
{ {
const VArc *arc = data->GeometricObject<const VArc *>(tool.getId()); const VArc *arc = data->GeometricObject<const VArc *>(tool.getId());
QString arcCenterName = data->GeometricObject<const VArc *>(arc->GetCenter().id())->name(); Q_CHECK_PTR(arc);
record = QString(tr("Arc with center in point %1")).arg(arcCenterName); const QString arcCenterName = data->GeometricObject<const VArc *>(arc->GetCenter().id())->name();
return QString(tr("Arc with center in point %1")).arg(arcCenterName);
} }
break;
case Tool::SplinePathTool: case Tool::SplinePathTool:
{ {
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(tool.getId()); const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(tool.getId());
QVector<VSplinePoint> points = splPath->GetSplinePath(); Q_CHECK_PTR(splPath);
const QVector<VSplinePoint> points = splPath->GetSplinePath();
QString record;
if (points.size() != 0 ) if (points.size() != 0 )
{ {
QString pName = data->GeometricObject<const VPointF *>(points[0].P().id())->name(); const QString pName = data->GeometricObject<const VPointF *>(points.at(0).P().id())->name();
record = QString(tr("Curve point %1")).arg(pName); record = QString(tr("Curve point %1")).arg(pName);
for (qint32 i = 1; i< points.size(); ++i) if(points.size() > 1)
{ {
pName = data->GeometricObject<const VPointF *>(points[i].P().id())->name(); const QString pName = data->GeometricObject<const VPointF *>(points.last().P().id())->name();
QString name = QString("_%1").arg(pName); record.append(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;
} }
break;
case Tool::PointOfContact: case Tool::PointOfContact:
{ {
domElement = doc->elementById(QString().setNum(tool.getId())); const quint32 center = doc->GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0");
if (domElement.isElement()) const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
{ const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
center = doc->GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0"); const QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name();
firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const QString centerName = data->GeometricObject<const VPointF *>(center)->name();
secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
} const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name(); return QString(tr("%4 - point of contact of arc with the center in point %1 and line %2_%3")).arg(
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); centerName, firstPointIdName, secondPointIdName, toolIdName);
break;
} }
case Tool::Height: case Tool::Height:
{ {
quint32 p1LineId = 0; const quint32 basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0");
quint32 p2LineId = 0; const quint32 p1LineId = doc->GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0");
domElement = doc->elementById(QString().setNum(tool.getId())); const quint32 p2LineId = doc->GetParametrUInt(domElement, VAbstractTool::AttrP2Line, "0");
if (domElement.isElement()) const QString basePointIdName = data->GeometricObject<const VPointF *>(basePointId)->name();
{ const QString p1LineIdName = data->GeometricObject<const VPointF *>(p1LineId)->name();
basePointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, "0"); const QString p2LineIdName = data->GeometricObject<const VPointF *>(p2LineId)->name();
p1LineId = doc->GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0"); return QString(tr("Point of perpendicular from point %1 to line %2_%3")).arg(basePointIdName,
p2LineId = doc->GetParametrUInt(domElement, VAbstractTool::AttrP2Line, "0"); p1LineIdName,
} p2LineIdName);
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: case Tool::Triangle:
{ {
quint32 axisP1Id = 0; const quint32 axisP1Id = doc->GetParametrUInt(domElement, VAbstractTool::AttrAxisP1, "0");
quint32 axisP2Id = 0; const quint32 axisP2Id = doc->GetParametrUInt(domElement, VAbstractTool::AttrAxisP2, "0");
domElement = doc->elementById(QString().setNum(tool.getId())); const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
if (domElement.isElement()) const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
{ const QString axisP1IdName = data->GeometricObject<const VPointF *>(axisP1Id)->name();
axisP1Id = doc->GetParametrUInt(domElement, VAbstractTool::AttrAxisP1, "0"); const QString axisP2IdName = data->GeometricObject<const VPointF *>(axisP2Id)->name();
axisP2Id = doc->GetParametrUInt(domElement, VAbstractTool::AttrAxisP2, "0"); const QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name();
firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); return QString(tr("Triangle: axis %1_%2, points %3 and %4")).arg(axisP1IdName, axisP2IdName,
}
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); firstPointIdName, secondPointIdName);
break;
} }
case Tool::PointOfIntersection: case Tool::PointOfIntersection:
{ {
domElement = doc->elementById(QString().setNum(tool.getId())); const quint32 firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
if (domElement.isElement()) const quint32 secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
{ const QString firstPointIdName = data->GeometricObject<const VPointF *>(firstPointId)->name();
firstPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0"); const QString secondPointIdName = data->GeometricObject<const VPointF *>(secondPointId)->name();
secondPointId = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0"); const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
} return QString(tr("%1 - point of intersection %2 and %3")).arg(toolIdName, firstPointIdName,
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); secondPointIdName);
} }
break;
case Tool::CutArcTool: case Tool::CutArcTool:
{ {
quint32 arcId = 0; const quint32 arcId = doc->GetParametrUInt(domElement, VToolCutArc::AttrArc, "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); const VArc *arc = data->GeometricObject<const VArc *>(arcId);
QString arcCenterName = data->GeometricObject<const VArc *>(arc->GetCenter().id())->name(); Q_CHECK_PTR(arc);
QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name(); const QString arcCenterName = data->GeometricObject<const VArc *>(arc->GetCenter().id())->name();
record = QString(tr("%1 - cut arc with center %2")).arg(toolIdName, arcCenterName); const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
return QString(tr("%1 - cut arc with center %2")).arg(toolIdName, arcCenterName);
} }
break;
case Tool::CutSplineTool: case Tool::CutSplineTool:
{ {
quint32 splineId = 0; const quint32 splineId = doc->GetParametrUInt(domElement, VToolCutSpline::AttrSpline, "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); const VSpline *spl = data->GeometricObject<const VSpline *>(splineId);
QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name(); Q_CHECK_PTR(spl);
QString splP1Name = data->GeometricObject<const VPointF *>(spl->GetP1().id())->name(); const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
QString splP4Name = data->GeometricObject<const VPointF *>(spl->GetP4().id())->name(); const QString splP1Name = data->GeometricObject<const VPointF *>(spl->GetP1().id())->name();
record = QString(tr("%1 - cut curve %2_%3")).arg(toolIdName, splP1Name, splP4Name); const QString splP4Name = data->GeometricObject<const VPointF *>(spl->GetP4().id())->name();
return QString(tr("%1 - cut curve %2_%3")).arg(toolIdName, splP1Name, splP4Name);
} }
break;
case Tool::CutSplinePathTool: case Tool::CutSplinePathTool:
{ {
quint32 splinePathId = 0; const quint32 splinePathId = doc->GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, "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); const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(splinePathId);
QVector<VSplinePoint> points = splPath->GetSplinePath(); Q_CHECK_PTR(splPath);
const QVector<VSplinePoint> points = splPath->GetSplinePath();
QString record;
if (points.size() != 0 ) if (points.size() != 0 )
{ {
QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name(); const QString toolIdName = data->GeometricObject<const VPointF *>(tool.getId())->name();
QString pName = data->GeometricObject<const VPointF *>(points[0].P().id())->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); record = QString(tr("%1 - cut curve path %2")).arg(toolIdName, pName);
for (qint32 i = 1; i< points.size(); ++i) if (points.size() > 1)
{ {
pName = data->GeometricObject<const VPointF *>(points[i].P().id())->name(); const QString pName = data->GeometricObject<const VPointF *>(points.last().P().id())->name();
QString name = QString("_%1").arg(pName); const QString name = QString("_%1").arg(pName);
record.append(name); record.append(name);
} }
} }
else
{
qWarning()<<"Not enough points in splinepath"<<Q_FUNC_INFO;
return QString(tr("Can't create record."));
} }
break; 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. //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: case Tool::Detail:
Q_UNREACHABLE();
break; break;
case Tool::UnionDetails: case Tool::UnionDetails:
Q_UNREACHABLE();
break; break;
case Tool::NodeArc: case Tool::NodeArc:
Q_UNREACHABLE();
break; break;
case Tool::NodePoint: case Tool::NodePoint:
Q_UNREACHABLE();
break; break;
case Tool::NodeSpline: case Tool::NodeSpline:
Q_UNREACHABLE();
break; break;
case Tool::NodeSplinePath: case Tool::NodeSplinePath:
Q_UNREACHABLE();
break; break;
default: default:
qWarning()<<tr("Got wrong tool type. Ignore."); qWarning()<<tr("Got wrong tool type. Ignore.");
break; break;
} }
return record; }
catch (const VExceptionBadId &e)
{
qWarning()<<e.ErrorMessage()<<Q_FUNC_INFO;
return QString(tr("Can't create record."));
}
return QString();
} }
void DialogHistory::InitialTable() void DialogHistory::InitialTable()

View File

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