Unfortunately we can't throw template. QGrapthisItem class is not reachable in

this case.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-03-19 10:38:29 +02:00
parent 19265e1f93
commit 30ece7e856
2 changed files with 60 additions and 2 deletions

View File

@ -3115,35 +3115,91 @@ QRectF VPattern::ActiveDrawBoundingRect() const
Q_UNREACHABLE(); Q_UNREACHABLE();
break; break;
case Tool::BasePoint: case Tool::BasePoint:
rec = ToolBoundingRect<VToolBasePoint>(rec, tool.getId());
break;
case Tool::EndLine: case Tool::EndLine:
rec = ToolBoundingRect<VToolEndLine>(rec, tool.getId());
break;
case Tool::Line: case Tool::Line:
rec = ToolBoundingRect<VToolLine>(rec, tool.getId());
break;
case Tool::AlongLine: case Tool::AlongLine:
rec = ToolBoundingRect<VToolAlongLine>(rec, tool.getId());
break;
case Tool::ShoulderPoint: case Tool::ShoulderPoint:
rec = ToolBoundingRect<VToolShoulderPoint>(rec, tool.getId());
break;
case Tool::Normal: case Tool::Normal:
rec = ToolBoundingRect<VToolNormal>(rec, tool.getId());
break;
case Tool::Bisector: case Tool::Bisector:
rec = ToolBoundingRect<VToolBisector>(rec, tool.getId());
break;
case Tool::LineIntersect: case Tool::LineIntersect:
rec = ToolBoundingRect<VToolLineIntersect>(rec, tool.getId());
break;
case Tool::Spline: case Tool::Spline:
rec = ToolBoundingRect<VToolSpline>(rec, tool.getId());
break;
case Tool::CubicBezier: case Tool::CubicBezier:
rec = ToolBoundingRect<VToolCubicBezier>(rec, tool.getId());
break;
case Tool::Arc: case Tool::Arc:
rec = ToolBoundingRect<VToolArc>(rec, tool.getId());
break;
case Tool::SplinePath: case Tool::SplinePath:
rec = ToolBoundingRect<VToolSplinePath>(rec, tool.getId());
break;
case Tool::CubicBezierPath: case Tool::CubicBezierPath:
rec = ToolBoundingRect<VToolCubicBezierPath>(rec, tool.getId());
break;
case Tool::PointOfContact: case Tool::PointOfContact:
rec = ToolBoundingRect<VToolPointOfContact>(rec, tool.getId());
break;
case Tool::Height: case Tool::Height:
rec = ToolBoundingRect<VToolHeight>(rec, tool.getId());
break;
case Tool::Triangle: case Tool::Triangle:
rec = ToolBoundingRect<VToolTriangle>(rec, tool.getId());
break;
case Tool::PointOfIntersection: case Tool::PointOfIntersection:
rec = ToolBoundingRect<VToolPointOfIntersection>(rec, tool.getId());
break;
case Tool::CutArc: case Tool::CutArc:
rec = ToolBoundingRect<VToolCutArc>(rec, tool.getId());
break;
case Tool::CutSpline: case Tool::CutSpline:
rec = ToolBoundingRect<VToolCutSpline>(rec, tool.getId());
break;
case Tool::CutSplinePath: case Tool::CutSplinePath:
rec = ToolBoundingRect<VToolCutSplinePath>(rec, tool.getId());
break;
case Tool::ArcWithLength: case Tool::ArcWithLength:
rec = ToolBoundingRect<VToolArcWithLength>(rec, tool.getId());
break;
case Tool::LineIntersectAxis: case Tool::LineIntersectAxis:
rec = ToolBoundingRect<VToolLineIntersectAxis>(rec, tool.getId());
break;
case Tool::PointOfIntersectionArcs: case Tool::PointOfIntersectionArcs:
rec = ToolBoundingRect<VToolPointOfIntersectionArcs>(rec, tool.getId());
break;
case Tool::PointOfIntersectionCircles: case Tool::PointOfIntersectionCircles:
rec = ToolBoundingRect<VToolPointOfIntersectionCircles>(rec, tool.getId());
break;
case Tool::PointOfIntersectionCurves: case Tool::PointOfIntersectionCurves:
rec = ToolBoundingRect<VToolPointOfIntersectionCurves>(rec, tool.getId());
break;
case Tool::CurveIntersectAxis: case Tool::CurveIntersectAxis:
rec = ToolBoundingRect<VToolCurveIntersectAxis>(rec, tool.getId());
break;
case Tool::PointFromCircleAndTangent: case Tool::PointFromCircleAndTangent:
rec = ToolBoundingRect<VToolPointFromCircleAndTangent>(rec, tool.getId());
break;
case Tool::PointFromArcAndTangent: case Tool::PointFromArcAndTangent:
rec = ToolBoundingRect<VToolPointFromArcAndTangent>(rec, tool.getId());
break;
case Tool::TrueDarts: case Tool::TrueDarts:
rec = ToolBoundingRect(rec, tool.getId()); rec = ToolBoundingRect<VToolTrueDarts>(rec, tool.getId());
break; break;
//These tools are not accesseble in Draw mode, but still 'history' contains them. //These tools are not accesseble in Draw mode, but still 'history' contains them.
case Tool::Detail: case Tool::Detail:
@ -3164,12 +3220,13 @@ QRectF VPattern::ActiveDrawBoundingRect() const
#endif #endif
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
template <typename T>
QRectF VPattern::ToolBoundingRect(const QRectF &rec, const quint32 &id) const QRectF VPattern::ToolBoundingRect(const QRectF &rec, const quint32 &id) const
{ {
QRectF recTool = rec; QRectF recTool = rec;
if (tools.contains(id)) if (tools.contains(id))
{ {
const QGraphicsItem *vTool = qobject_cast<QGraphicsItem *>(tools.value(id)); const T *vTool = qobject_cast<T *>(tools.value(id));
SCASSERT(vTool != nullptr); SCASSERT(vTool != nullptr);
QRectF childrenRect = vTool->childrenBoundingRect(); QRectF childrenRect = vTool->childrenBoundingRect();

View File

@ -135,6 +135,7 @@ private:
void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, qreal &mx, qreal &my); void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, qreal &mx, qreal &my);
void SplinesCommonAttributes(const QDomElement &domElement, quint32 &id, quint32 &idObject, void SplinesCommonAttributes(const QDomElement &domElement, quint32 &id, quint32 &idObject,
quint32 &idTool); quint32 &idTool);
template <typename T>
QRectF ToolBoundingRect(const QRectF &rec, const quint32 &id) const; QRectF ToolBoundingRect(const QRectF &rec, const quint32 &id) const;
void ParseCurrentPP(); void ParseCurrentPP();
QString GetLabelBase(quint32 index)const; QString GetLabelBase(quint32 index)const;