Refactoring.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-03-13 16:22:15 +02:00
parent 2201ca9ec0
commit a91112faee
2 changed files with 9 additions and 53 deletions

View File

@ -230,56 +230,40 @@ QString DialogHistory::Record(const VToolRecord &tool)
Q_UNREACHABLE(); //-V501 Q_UNREACHABLE(); //-V501
break; break;
case Tool::BasePoint: case Tool::BasePoint:
{
return QString(tr("%1 - Base point")).arg(PointName(tool.getId())); return QString(tr("%1 - Base point")).arg(PointName(tool.getId()));
}
case Tool::EndLine: case Tool::EndLine:
{
return QString(tr("%1_%2 - Line from point %1 to point %2")) return QString(tr("%1_%2 - Line from point %1 to point %2"))
.arg(PointName(AttrUInt(domElem, AttrBasePoint))) .arg(PointName(AttrUInt(domElem, AttrBasePoint)))
.arg(PointName(tool.getId())); .arg(PointName(tool.getId()));
}
case Tool::Line: case Tool::Line:
{
return QString(tr("%1_%2 - Line from point %1 to point %2")) return QString(tr("%1_%2 - Line from point %1 to point %2"))
.arg(PointName(AttrUInt(domElem, AttrFirstPoint))) .arg(PointName(AttrUInt(domElem, AttrFirstPoint)))
.arg(PointName(AttrUInt(domElem, AttrSecondPoint))); .arg(PointName(AttrUInt(domElem, AttrSecondPoint)));
}
case Tool::AlongLine: case Tool::AlongLine:
{
return QString(tr("%3 - Point along line %1_%2")) return QString(tr("%3 - Point along line %1_%2"))
.arg(PointName(AttrUInt(domElem, AttrFirstPoint))) .arg(PointName(AttrUInt(domElem, AttrFirstPoint)))
.arg(PointName(AttrUInt(domElem, AttrSecondPoint))) .arg(PointName(AttrUInt(domElem, AttrSecondPoint)))
.arg(PointName(tool.getId())); .arg(PointName(tool.getId()));
}
case Tool::ShoulderPoint: case Tool::ShoulderPoint:
{
return QString(tr("%1 - Point of shoulder")).arg(PointName(tool.getId())); return QString(tr("%1 - Point of shoulder")).arg(PointName(tool.getId()));
}
case Tool::Normal: case Tool::Normal:
{
return QString(tr("%3 - normal to line %1_%2")) return QString(tr("%3 - normal to line %1_%2"))
.arg(PointName(AttrUInt(domElem, AttrFirstPoint))) .arg(PointName(AttrUInt(domElem, AttrFirstPoint)))
.arg(PointName(AttrUInt(domElem, AttrSecondPoint))) .arg(PointName(AttrUInt(domElem, AttrSecondPoint)))
.arg(PointName(tool.getId())); .arg(PointName(tool.getId()));
}
case Tool::Bisector: case Tool::Bisector:
{
return QString(tr("%4 - bisector of angle %1_%2_%3")) return QString(tr("%4 - bisector of angle %1_%2_%3"))
.arg(PointName(AttrUInt(domElem, AttrFirstPoint))) .arg(PointName(AttrUInt(domElem, AttrFirstPoint)))
.arg(PointName(AttrUInt(domElem, AttrSecondPoint))) .arg(PointName(AttrUInt(domElem, AttrSecondPoint)))
.arg(PointName(AttrUInt(domElem, AttrThirdPoint))) .arg(PointName(AttrUInt(domElem, AttrThirdPoint)))
.arg(PointName(tool.getId())); .arg(PointName(tool.getId()));
}
case Tool::LineIntersect: case Tool::LineIntersect:
{
return QString(tr("%5 - intersection of lines %1_%2 and %3_%4")) return QString(tr("%5 - intersection of lines %1_%2 and %3_%4"))
.arg(PointName(AttrUInt(domElem, AttrP1Line1))) .arg(PointName(AttrUInt(domElem, AttrP1Line1)))
.arg(PointName(AttrUInt(domElem, AttrP2Line1))) .arg(PointName(AttrUInt(domElem, AttrP2Line1)))
.arg(PointName(AttrUInt(domElem, AttrP1Line2))) .arg(PointName(AttrUInt(domElem, AttrP1Line2)))
.arg(PointName(AttrUInt(domElem, AttrP2Line2))) .arg(PointName(AttrUInt(domElem, AttrP2Line2)))
.arg(PointName(tool.getId())); .arg(PointName(tool.getId()));
}
case Tool::Spline: case Tool::Spline:
{ {
const QSharedPointer<VSpline> spl = data->GeometricObject<VSpline>(tool.getId()); const QSharedPointer<VSpline> spl = data->GeometricObject<VSpline>(tool.getId());
@ -329,35 +313,27 @@ QString DialogHistory::Record(const VToolRecord &tool)
return record; return record;
} }
case Tool::PointOfContact: case Tool::PointOfContact:
{
return QString(tr("%4 - point of contact of arc with the center in point %1 and line %2_%3")) return QString(tr("%4 - point of contact of arc with the center in point %1 and line %2_%3"))
.arg(PointName(AttrUInt(domElem, AttrCenter))) .arg(PointName(AttrUInt(domElem, AttrCenter)))
.arg(PointName(AttrUInt(domElem, AttrFirstPoint))) .arg(PointName(AttrUInt(domElem, AttrFirstPoint)))
.arg(PointName(AttrUInt(domElem, AttrSecondPoint))) .arg(PointName(AttrUInt(domElem, AttrSecondPoint)))
.arg(PointName(tool.getId())); .arg(PointName(tool.getId()));
}
case Tool::Height: case Tool::Height:
{
return QString(tr("Point of perpendicular from point %1 to line %2_%3")) return QString(tr("Point of perpendicular from point %1 to line %2_%3"))
.arg(PointName(AttrUInt(domElem, AttrBasePoint))) .arg(PointName(AttrUInt(domElem, AttrBasePoint)))
.arg(PointName(AttrUInt(domElem, AttrP1Line))) .arg(PointName(AttrUInt(domElem, AttrP1Line)))
.arg(PointName(AttrUInt(domElem, AttrP2Line))); .arg(PointName(AttrUInt(domElem, AttrP2Line)));
}
case Tool::Triangle: case Tool::Triangle:
{
return QString(tr("Triangle: axis %1_%2, points %3 and %4")) return QString(tr("Triangle: axis %1_%2, points %3 and %4"))
.arg(PointName(AttrUInt(domElem, AttrAxisP1))) .arg(PointName(AttrUInt(domElem, AttrAxisP1)))
.arg(PointName(AttrUInt(domElem, AttrAxisP2))) .arg(PointName(AttrUInt(domElem, AttrAxisP2)))
.arg(PointName(AttrUInt(domElem, AttrFirstPoint))) .arg(PointName(AttrUInt(domElem, AttrFirstPoint)))
.arg(PointName(AttrUInt(domElem, AttrSecondPoint))); .arg(PointName(AttrUInt(domElem, AttrSecondPoint)));
}
case Tool::PointOfIntersection: case Tool::PointOfIntersection:
{
return QString(tr("%1 - point of intersection %2 and %3")) return QString(tr("%1 - point of intersection %2 and %3"))
.arg(PointName(tool.getId())) .arg(PointName(tool.getId()))
.arg(PointName(AttrUInt(domElem, AttrFirstPoint))) .arg(PointName(AttrUInt(domElem, AttrFirstPoint)))
.arg(PointName(AttrUInt(domElem, AttrSecondPoint))); .arg(PointName(AttrUInt(domElem, AttrSecondPoint)));
}
case Tool::CutArc: case Tool::CutArc:
{ {
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(AttrUInt(domElem, AttrArc)); const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(AttrUInt(domElem, AttrArc));
@ -401,58 +377,37 @@ QString DialogHistory::Record(const VToolRecord &tool)
return record; return record;
} }
case Tool::LineIntersectAxis: case Tool::LineIntersectAxis:
{
return QString(tr("%1 - point of intersection line %2_%3 and axis through point %4")) return QString(tr("%1 - point of intersection line %2_%3 and axis through point %4"))
.arg(PointName(tool.getId())) .arg(PointName(tool.getId()))
.arg(PointName(AttrUInt(domElem, AttrP1Line))) .arg(PointName(AttrUInt(domElem, AttrP1Line)))
.arg(PointName(AttrUInt(domElem, AttrP2Line))) .arg(PointName(AttrUInt(domElem, AttrP2Line)))
.arg(PointName(AttrUInt(domElem, AttrBasePoint))); .arg(PointName(AttrUInt(domElem, AttrBasePoint)));
}
case Tool::CurveIntersectAxis: case Tool::CurveIntersectAxis:
{
return QString(tr("%1 - point of intersection curve and axis through point %2")) return QString(tr("%1 - point of intersection curve and axis through point %2"))
.arg(PointName(tool.getId())) .arg(PointName(tool.getId()))
.arg(PointName(AttrUInt(domElem, AttrBasePoint))); .arg(PointName(AttrUInt(domElem, AttrBasePoint)));
}
case Tool::PointOfIntersectionArcs: case Tool::PointOfIntersectionArcs:
{
return QString(tr("%1 - point of arcs intersection")).arg(PointName(tool.getId())); return QString(tr("%1 - point of arcs intersection")).arg(PointName(tool.getId()));
}
case Tool::PointOfIntersectionCircles: case Tool::PointOfIntersectionCircles:
{
return QString(tr("%1 - point of circles intersection")).arg(PointName(tool.getId())); return QString(tr("%1 - point of circles intersection")).arg(PointName(tool.getId()));
}
case Tool::PointOfIntersectionCurves: case Tool::PointOfIntersectionCurves:
{
return QString(tr("%1 - point of curves intersection")).arg(PointName(tool.getId())); return QString(tr("%1 - point of curves intersection")).arg(PointName(tool.getId()));
}
case Tool::PointFromCircleAndTangent: case Tool::PointFromCircleAndTangent:
{
return QString(tr("%1 - point from circle and tangent")).arg(PointName(tool.getId())); return QString(tr("%1 - point from circle and tangent")).arg(PointName(tool.getId()));
}
case Tool::PointFromArcAndTangent: case Tool::PointFromArcAndTangent:
{
return QString(tr("%1 - point from arc and tangent")).arg(PointName(tool.getId())); return QString(tr("%1 - point from arc and tangent")).arg(PointName(tool.getId()));
}
case Tool::TrueDarts: case Tool::TrueDarts:
{
return QString(tr("Correction the dart %1_%2_%3")) return QString(tr("Correction the dart %1_%2_%3"))
.arg(PointName(AttrUInt(domElem, AttrDartP1))) .arg(PointName(AttrUInt(domElem, AttrDartP1)))
.arg(PointName(AttrUInt(domElem, AttrDartP2))) .arg(PointName(AttrUInt(domElem, AttrDartP2)))
.arg(PointName(AttrUInt(domElem, AttrDartP2))); .arg(PointName(AttrUInt(domElem, AttrDartP2)));
}
//Because "history" not only show history of pattern, but help restore current data for each pattern's //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. //piece, we need add record about details and nodes, but don't show them.
case Tool::Detail: case Tool::Detail:
break;
case Tool::UnionDetails: case Tool::UnionDetails:
break;
case Tool::NodeArc: case Tool::NodeArc:
break;
case Tool::NodePoint: case Tool::NodePoint:
break;
case Tool::NodeSpline: case Tool::NodeSpline:
break;
case Tool::NodeSplinePath: case Tool::NodeSplinePath:
break; break;
} }

View File

@ -3028,6 +3028,11 @@ void VPattern::ToolsCommonAttributes(const QDomElement &domElement, quint32 &id)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
#if defined(Q_CC_GNU)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-default"
#endif
QRectF VPattern::ActiveDrawBoundingRect() const QRectF VPattern::ActiveDrawBoundingRect() const
{ {
// This check helps to find missed tools in the switch // This check helps to find missed tools in the switch
@ -3138,26 +3143,22 @@ QRectF VPattern::ActiveDrawBoundingRect() const
//Because "history" not only show history of pattern, but help restore current data for each pattern's //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. //piece, we need add record about details and nodes, but don't show them.
case Tool::Detail: case Tool::Detail:
break;
case Tool::UnionDetails: case Tool::UnionDetails:
break;
case Tool::NodeArc: case Tool::NodeArc:
break;
case Tool::NodePoint: case Tool::NodePoint:
break;
case Tool::NodeSpline: case Tool::NodeSpline:
break;
case Tool::NodeSplinePath: case Tool::NodeSplinePath:
break; break;
default:
qDebug()<<"Got wrong tool type. Ignore.";
break;
} }
} }
} }
return rec; return rec;
} }
#if defined(Q_CC_GNU)
#pragma GCC diagnostic pop
#endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <typename T> template <typename T>
QRectF VPattern::ToolBoundingRect(const QRectF &rec, const quint32 &id) const QRectF VPattern::ToolBoundingRect(const QRectF &rec, const quint32 &id) const