More tools should show a warning if cannot find a result.
--HG-- branch : develop
This commit is contained in:
parent
cc6c178b17
commit
e244d002cc
|
@ -133,7 +133,16 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(VToolCurveIntersectAxis
|
|||
const qreal angle = CheckFormula(initData.id, initData.formulaAngle, initData.data);
|
||||
const QSharedPointer<VAbstractCurve> curve = initData.data->GeometricObject<VAbstractCurve>(initData.curveId);
|
||||
|
||||
const QPointF fPoint = FindPoint(static_cast<QPointF>(*basePoint), angle, curve->GetPoints());
|
||||
QPointF fPoint;
|
||||
const bool success = FindPoint(static_cast<QPointF>(*basePoint), angle, curve->GetPoints(), &fPoint);
|
||||
|
||||
if (not success)
|
||||
{
|
||||
qWarning() << tr("Error calculating point '%1'. There is no intersection with curve '%2' and axis through "
|
||||
"point '%3' with angle %4°")
|
||||
.arg(initData.name, curve->name(), basePoint->name()).arg(angle);
|
||||
}
|
||||
|
||||
const qreal segLength = curve->GetLengthByPoint(fPoint);
|
||||
|
||||
VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my);
|
||||
|
@ -176,9 +185,11 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(VToolCurveIntersectAxis
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPointF VToolCurveIntersectAxis::FindPoint(const QPointF &point, qreal angle,
|
||||
const QVector<QPointF> &curvePoints)
|
||||
bool VToolCurveIntersectAxis::FindPoint(const QPointF &point, qreal angle, const QVector<QPointF> &curvePoints,
|
||||
QPointF *intersectionPoint)
|
||||
{
|
||||
SCASSERT(intersectionPoint != nullptr)
|
||||
|
||||
QRectF rec = QRectF(0, 0, INT_MAX, INT_MAX);
|
||||
rec.translate(-INT_MAX/2.0, -INT_MAX/2.0);
|
||||
|
||||
|
@ -189,7 +200,8 @@ QPointF VToolCurveIntersectAxis::FindPoint(const QPointF &point, qreal angle,
|
|||
{
|
||||
if (points.size() == 1)
|
||||
{
|
||||
return points.at(0);
|
||||
*intersectionPoint = points.at(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
QMap<qreal, int> forward;
|
||||
|
@ -216,15 +228,17 @@ QPointF VToolCurveIntersectAxis::FindPoint(const QPointF &point, qreal angle,
|
|||
// Closest point is not always want we need. First return point in forward direction if exists.
|
||||
if (not forward.isEmpty())
|
||||
{
|
||||
return points.at(forward.first());
|
||||
*intersectionPoint = points.at(forward.first());
|
||||
return true;
|
||||
}
|
||||
else if (not backward.isEmpty())
|
||||
{
|
||||
return points.at(backward.first());
|
||||
*intersectionPoint = points.at(backward.first());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return QPointF();
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -71,7 +71,8 @@ public:
|
|||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolCurveIntersectAxis *Create(VToolCurveIntersectAxisInitData &initData);
|
||||
|
||||
static QPointF FindPoint(const QPointF &point, qreal angle, const QVector<QPointF> &curvePoints);
|
||||
static bool FindPoint(const QPointF &point, qreal angle, const QVector<QPointF> &curvePoints,
|
||||
QPointF *intersectionPoint);
|
||||
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
|
|
|
@ -124,7 +124,15 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(VToolLineIntersectAxisIni
|
|||
const QSharedPointer<VPointF> secondPoint = initData.data->GeometricObject<VPointF>(initData.secondPointId);
|
||||
QLineF line(static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint));
|
||||
|
||||
QPointF fPoint = FindPoint(axis, line);
|
||||
QPointF fPoint;
|
||||
const bool success = FindPoint(axis, line, &fPoint);
|
||||
|
||||
if (not success)
|
||||
{
|
||||
qWarning() << tr("Error calculating point '%1'. Line (%2;%3) doesn't have intersection with axis through "
|
||||
"point '%4' and angle %5°")
|
||||
.arg(initData.name, firstPoint->name(), secondPoint->name(), basePoint->name()).arg(axis.angle());
|
||||
}
|
||||
|
||||
VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
@ -164,8 +172,10 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(VToolLineIntersectAxisIni
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPointF VToolLineIntersectAxis::FindPoint(const QLineF &axis, const QLineF &line)
|
||||
bool VToolLineIntersectAxis::FindPoint(const QLineF &axis, const QLineF &line, QPointF *intersectionPoint)
|
||||
{
|
||||
SCASSERT(intersectionPoint != nullptr)
|
||||
|
||||
QPointF fPoint;
|
||||
QLineF::IntersectType intersect = axis.intersect(line, &fPoint);
|
||||
if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection)
|
||||
|
@ -173,16 +183,17 @@ QPointF VToolLineIntersectAxis::FindPoint(const QLineF &axis, const QLineF &line
|
|||
if(VFuzzyComparePossibleNulls(axis.angle(), line.angle())
|
||||
|| VFuzzyComparePossibleNulls(qAbs(axis.angle() - line.angle()), 180))
|
||||
{
|
||||
return QPointF();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return fPoint;
|
||||
*intersectionPoint = fPoint;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return QPointF();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ public:
|
|||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolLineIntersectAxis *Create(VToolLineIntersectAxisInitData &initData);
|
||||
|
||||
static QPointF FindPoint(const QLineF &axis, const QLineF &line);
|
||||
static bool FindPoint(const QLineF &axis, const QLineF &line, QPointF *intersectionPoint);
|
||||
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
|
|
|
@ -112,8 +112,15 @@ VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(VToolPointFromA
|
|||
const VArc arc = *initData.data->GeometricObject<VArc>(initData.arcId);
|
||||
const VPointF tPoint = *initData.data->GeometricObject<VPointF>(initData.tangentPointId);
|
||||
|
||||
const QPointF point = VToolPointFromArcAndTangent::FindPoint(static_cast<QPointF>(tPoint), &arc,
|
||||
initData.crossPoint);
|
||||
QPointF point;
|
||||
const bool success = VToolPointFromArcAndTangent::FindPoint(static_cast<QPointF>(tPoint), &arc,
|
||||
initData.crossPoint, &point);
|
||||
|
||||
if (not success)
|
||||
{
|
||||
qWarning() << tr("Error calculating point '%1'. Tangent to arc '%2' from point '%3' cannot be found")
|
||||
.arg(initData.name, arc.name(), tPoint.name());
|
||||
}
|
||||
|
||||
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
@ -146,8 +153,11 @@ VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(VToolPointFromA
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPointF VToolPointFromArcAndTangent::FindPoint(const QPointF &p, const VArc *arc, const CrossCirclesPoint pType)
|
||||
bool VToolPointFromArcAndTangent::FindPoint(const QPointF &p, const VArc *arc, const CrossCirclesPoint pType,
|
||||
QPointF *intersectionPoint)
|
||||
{
|
||||
SCASSERT(intersectionPoint != nullptr)
|
||||
|
||||
QPointF p1, p2;
|
||||
const QPointF center = static_cast<QPointF>(arc->GetCenter());
|
||||
const qreal radius = arc->GetRadius();
|
||||
|
@ -180,26 +190,14 @@ QPointF VToolPointFromArcAndTangent::FindPoint(const QPointF &p, const VArc *arc
|
|||
switch(localRes)
|
||||
{
|
||||
case 2:
|
||||
if (pType == CrossCirclesPoint::FirstPoint)
|
||||
{
|
||||
return p1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return p2;
|
||||
}
|
||||
*intersectionPoint = (pType == CrossCirclesPoint::FirstPoint ? p1 : p2);
|
||||
return true;
|
||||
case 1:
|
||||
if (flagP1)
|
||||
{
|
||||
return p1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return p2;
|
||||
}
|
||||
*intersectionPoint = (flagP1 ? p1 : p2);
|
||||
return true;
|
||||
case 0:
|
||||
default:
|
||||
return QPointF();
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -207,18 +205,19 @@ QPointF VToolPointFromArcAndTangent::FindPoint(const QPointF &p, const VArc *arc
|
|||
case 1:
|
||||
if (arc->IsIntersectLine(r1Arc))
|
||||
{
|
||||
return p1;
|
||||
*intersectionPoint = p1;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return QPointF();
|
||||
return false;
|
||||
}
|
||||
case 3:
|
||||
case 0:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QPointF();
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
static VToolPointFromArcAndTangent *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolPointFromArcAndTangent *Create(VToolPointFromArcAndTangentInitData initData);
|
||||
static QPointF FindPoint(const QPointF &p, const VArc *arc, const CrossCirclesPoint pType);
|
||||
static bool FindPoint(const QPointF &p, const VArc *arc, const CrossCirclesPoint pType, QPointF *intersectionPoint);
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::PointFromArcAndTangent) };
|
||||
|
|
|
@ -117,9 +117,16 @@ VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(VToolPoin
|
|||
const VPointF cPoint = *initData.data->GeometricObject<VPointF>(initData.circleCenterId);
|
||||
const VPointF tPoint = *initData.data->GeometricObject<VPointF>(initData.tangentPointId);
|
||||
|
||||
const QPointF point = VToolPointFromCircleAndTangent::FindPoint(static_cast<QPointF>(tPoint),
|
||||
static_cast<QPointF>(cPoint), radius,
|
||||
initData.crossPoint);
|
||||
QPointF point;
|
||||
const bool success = VToolPointFromCircleAndTangent::FindPoint(static_cast<QPointF>(tPoint),
|
||||
static_cast<QPointF>(cPoint), radius,
|
||||
initData.crossPoint, &point);
|
||||
if (not success)
|
||||
{
|
||||
qWarning() << tr("Error calculating point '%1'. Tangent to circle with center '%2' and radius '%3' from "
|
||||
"point '%4' cannot be found")
|
||||
.arg(initData.name, cPoint.name()).arg(radius).arg(tPoint.name());
|
||||
}
|
||||
|
||||
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
@ -152,29 +159,26 @@ VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(VToolPoin
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPointF VToolPointFromCircleAndTangent::FindPoint(const QPointF &p, const QPointF ¢er, qreal radius,
|
||||
const CrossCirclesPoint crossPoint)
|
||||
bool VToolPointFromCircleAndTangent::FindPoint(const QPointF &p, const QPointF ¢er, qreal radius,
|
||||
const CrossCirclesPoint crossPoint, QPointF *intersectionPoint)
|
||||
{
|
||||
SCASSERT(intersectionPoint != nullptr)
|
||||
|
||||
QPointF p1, p2;
|
||||
const int res = VGObject::ContactPoints (p, center, radius, p1, p2);
|
||||
|
||||
switch(res)
|
||||
{
|
||||
case 2:
|
||||
if (crossPoint == CrossCirclesPoint::FirstPoint)
|
||||
{
|
||||
return p1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return p2;
|
||||
}
|
||||
*intersectionPoint = (crossPoint == CrossCirclesPoint::FirstPoint ? p1 : p2);
|
||||
return true;
|
||||
case 1:
|
||||
return p1;
|
||||
*intersectionPoint = p1;
|
||||
return true;
|
||||
case 3:
|
||||
case 0:
|
||||
default:
|
||||
return QPointF();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,8 @@ public:
|
|||
static VToolPointFromCircleAndTangent *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolPointFromCircleAndTangent *Create(VToolPointFromCircleAndTangentInitData &initData);
|
||||
static QPointF FindPoint(const QPointF &p, const QPointF ¢er, qreal radius, const CrossCirclesPoint crossPoint);
|
||||
static bool FindPoint(const QPointF &p, const QPointF ¢er, qreal radius, const CrossCirclesPoint crossPoint,
|
||||
QPointF *intersectionPoint);
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::PointFromCircleAndTangent) };
|
||||
|
|
|
@ -100,19 +100,23 @@ void VToolPointOfContact::setDialog()
|
|||
* @param center center arc point.
|
||||
* @param firstPoint first line point.
|
||||
* @param secondPoint second line point.
|
||||
* @return point intersection.
|
||||
* @param intersectionPoint point of intersection.
|
||||
* @return true if intersection exists.
|
||||
*/
|
||||
QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF ¢er, const QPointF &firstPoint,
|
||||
const QPointF &secondPoint)
|
||||
bool VToolPointOfContact::FindPoint(qreal radius, const QPointF ¢er, const QPointF &firstPoint,
|
||||
const QPointF &secondPoint, QPointF *intersectionPoint)
|
||||
{
|
||||
SCASSERT(intersectionPoint != nullptr)
|
||||
|
||||
QPointF p1, p2;
|
||||
qint32 res = VGObject::LineIntersectCircle(center, radius, QLineF(firstPoint, secondPoint), p1, p2);
|
||||
switch (res)
|
||||
{
|
||||
case 0:
|
||||
return QPointF();
|
||||
return false;
|
||||
case 1:
|
||||
return p1;
|
||||
*intersectionPoint = p1;
|
||||
return true;
|
||||
case 2:
|
||||
{
|
||||
const bool flagP1 = VGObject::IsPointOnLineSegment (p1, firstPoint, secondPoint);
|
||||
|
@ -123,22 +127,26 @@ QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF ¢e
|
|||
// We don't have options for choosing correct point. Use closest to segment first point.
|
||||
if (QLineF(firstPoint, p1).length() <= QLineF(firstPoint, p2).length())
|
||||
{
|
||||
return p1;
|
||||
*intersectionPoint = p1;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return p2;
|
||||
*intersectionPoint = p2;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // In this case we have one real and one theoretical intersection.
|
||||
if (flagP1)
|
||||
{
|
||||
return p1;
|
||||
*intersectionPoint = p1;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return p2;
|
||||
*intersectionPoint = p2;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -146,7 +154,7 @@ QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF ¢e
|
|||
qDebug() << "Unxpected value" << res;
|
||||
break;
|
||||
}
|
||||
return QPointF();
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -197,8 +205,17 @@ VToolPointOfContact* VToolPointOfContact::Create(VToolPointOfContactInitData &in
|
|||
|
||||
const qreal result = CheckFormula(initData.id, initData.radius, initData.data);
|
||||
|
||||
QPointF fPoint = VToolPointOfContact::FindPoint(qApp->toPixel(result), static_cast<QPointF>(*centerP),
|
||||
static_cast<QPointF>(*firstP), static_cast<QPointF>(*secondP));
|
||||
QPointF fPoint;
|
||||
const bool success = VToolPointOfContact::FindPoint(qApp->toPixel(result), static_cast<QPointF>(*centerP),
|
||||
static_cast<QPointF>(*firstP), static_cast<QPointF>(*secondP),
|
||||
&fPoint);
|
||||
|
||||
if (not success)
|
||||
{
|
||||
qWarning() << tr("Error calculating point '%1'. Circle with center '%2' and radius '%3' doesn't have "
|
||||
"intersection with line (%4;%5)")
|
||||
.arg(initData.name, centerP->name()).arg(result).arg(firstP->name(), secondP->name());
|
||||
}
|
||||
|
||||
VPointF *p = new VPointF(fPoint, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
|
|
@ -69,8 +69,8 @@ class VToolPointOfContact : public VToolSinglePoint
|
|||
Q_OBJECT
|
||||
public:
|
||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||
static QPointF FindPoint(const qreal &radius, const QPointF ¢er, const QPointF &firstPoint,
|
||||
const QPointF &secondPoint);
|
||||
static bool FindPoint(qreal radius, const QPointF ¢er, const QPointF &firstPoint,
|
||||
const QPointF &secondPoint, QPointF *intersectionPoint);
|
||||
static VToolPointOfContact* Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolPointOfContact* Create(VToolPointOfContactInitData &initData);
|
||||
|
|
|
@ -126,7 +126,7 @@ VToolTriangle* VToolTriangle::Create(QSharedPointer<DialogTool> dialog, VMainGra
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Create help create tool.
|
||||
* @brief Create helps to create the tool.
|
||||
* @param initData init data.
|
||||
* @return the created tool
|
||||
*/
|
||||
|
@ -137,8 +137,15 @@ VToolTriangle* VToolTriangle::Create(VToolTriangleInitData initData)
|
|||
const QSharedPointer<VPointF> firstPoint = initData.data->GeometricObject<VPointF>(initData.firstPointId);
|
||||
const QSharedPointer<VPointF> secondPoint = initData.data->GeometricObject<VPointF>(initData.secondPointId);
|
||||
|
||||
QPointF point = FindPoint(static_cast<QPointF>(*axisP1), static_cast<QPointF>(*axisP2),
|
||||
static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint));
|
||||
QPointF point;
|
||||
const bool success = FindPoint(static_cast<QPointF>(*axisP1), static_cast<QPointF>(*axisP2),
|
||||
static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint), &point);
|
||||
|
||||
if (not success)
|
||||
{
|
||||
qWarning() << tr("Error calculating point '%1'. Point of intersection cannot be finded")
|
||||
.arg(initData.name);
|
||||
}
|
||||
|
||||
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
@ -179,11 +186,14 @@ VToolTriangle* VToolTriangle::Create(VToolTriangleInitData initData)
|
|||
* @param axisP2 second axis point.
|
||||
* @param firstPoint first triangle point, what lies on the hypotenuse.
|
||||
* @param secondPoint second triangle point, what lies on the hypotenuse.
|
||||
* @return point intersection two foots right triangle.
|
||||
* @param intersectionPoint point intersection two foots right triangle
|
||||
* @return true if the intersection exists.
|
||||
*/
|
||||
QPointF VToolTriangle::FindPoint(const QPointF &axisP1, const QPointF &axisP2, const QPointF &firstPoint,
|
||||
const QPointF &secondPoint)
|
||||
bool VToolTriangle::FindPoint(const QPointF &axisP1, const QPointF &axisP2, const QPointF &firstPoint,
|
||||
const QPointF &secondPoint, QPointF *intersectionPoint)
|
||||
{
|
||||
SCASSERT(intersectionPoint != nullptr)
|
||||
|
||||
QLineF axis(axisP1, axisP2);
|
||||
QLineF hypotenuse(firstPoint, secondPoint);
|
||||
|
||||
|
@ -191,12 +201,12 @@ QPointF VToolTriangle::FindPoint(const QPointF &axisP1, const QPointF &axisP2, c
|
|||
QLineF::IntersectType intersect = axis.intersect(hypotenuse, &startPoint);
|
||||
if (intersect != QLineF::UnboundedIntersection && intersect != QLineF::BoundedIntersection)
|
||||
{
|
||||
return QPointF();
|
||||
return false;
|
||||
}
|
||||
if (VFuzzyComparePossibleNulls(axis.angle(), hypotenuse.angle())
|
||||
|| VFuzzyComparePossibleNulls(qAbs(axis.angle() - hypotenuse.angle()), 180))
|
||||
{
|
||||
return QPointF();
|
||||
return false;
|
||||
}
|
||||
|
||||
qreal step = 1;
|
||||
|
@ -214,10 +224,11 @@ QPointF VToolTriangle::FindPoint(const QPointF &axisP1, const QPointF &axisP2, c
|
|||
qint64 b = qFloor(QLineF(line.p2(), secondPoint).length());
|
||||
if (c*c <= (a*a + b*b))
|
||||
{
|
||||
return line.p2();
|
||||
*intersectionPoint = line.p2();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return QPointF();
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -72,8 +72,8 @@ public:
|
|||
static VToolTriangle *Create(QSharedPointer<DialogTool> dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data);
|
||||
static VToolTriangle *Create(VToolTriangleInitData initData);
|
||||
static QPointF FindPoint(const QPointF &axisP1, const QPointF &axisP2, const QPointF &firstPoint,
|
||||
const QPointF &secondPoint);
|
||||
static bool FindPoint(const QPointF &axisP1, const QPointF &axisP2, const QPointF &firstPoint,
|
||||
const QPointF &secondPoint, QPointF *intersectionPoint);
|
||||
static const QString ToolType;
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::Triangle)};
|
||||
|
|
|
@ -83,8 +83,8 @@ void VisToolCurveIntersectAxis::RefreshGeometry()
|
|||
DrawPoint(basePoint, static_cast<QPointF>(*first), mainColor);
|
||||
DrawLine(axisLine, axis, supportColor, Qt::DashLine);
|
||||
|
||||
QPointF p = VToolCurveIntersectAxis::FindPoint(static_cast<QPointF>(*first), axis.angle(),
|
||||
curve->GetPoints());
|
||||
QPointF p;
|
||||
VToolCurveIntersectAxis::FindPoint(static_cast<QPointF>(*first), axis.angle(), curve->GetPoints(), &p);
|
||||
QLineF axis_line(static_cast<QPointF>(*first), p);
|
||||
DrawLine(this, axis_line, mainColor, lineStyle);
|
||||
|
||||
|
|
|
@ -94,7 +94,8 @@ void VisToolLineIntersectAxis::RefreshGeometry()
|
|||
DrawPoint(basePoint, static_cast<QPointF>(*third), mainColor);
|
||||
DrawLine(axisLine, axis, supportColor, Qt::DashLine);
|
||||
|
||||
QPointF p = VToolLineIntersectAxis::FindPoint(axis, base_line);
|
||||
QPointF p;
|
||||
VToolLineIntersectAxis::FindPoint(axis, base_line, &p);
|
||||
QLineF axis_line(static_cast<QPointF>(*third), p);
|
||||
DrawLine(this, axis_line, mainColor, lineStyle);
|
||||
|
||||
|
|
|
@ -72,8 +72,8 @@ void VisToolPointFromArcAndTangent::RefreshGeometry()
|
|||
|
||||
FindRays(static_cast<QPointF>(*tan), arc.data());
|
||||
|
||||
const QPointF fPoint = VToolPointFromArcAndTangent::FindPoint(static_cast<QPointF>(*tan), arc.data(),
|
||||
crossPoint);
|
||||
QPointF fPoint;
|
||||
VToolPointFromArcAndTangent::FindPoint(static_cast<QPointF>(*tan), arc.data(), crossPoint, &fPoint);
|
||||
DrawPoint(point, fPoint, mainColor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,9 +74,9 @@ void VisToolPointFromCircleAndTangent::RefreshGeometry()
|
|||
|
||||
FindRays(static_cast<QPointF>(*tan), static_cast<QPointF>(*center), cRadius);
|
||||
|
||||
const QPointF fPoint = VToolPointFromCircleAndTangent::FindPoint(static_cast<QPointF>(*tan),
|
||||
static_cast<QPointF>(*center),
|
||||
cRadius, crossPoint);
|
||||
QPointF fPoint;
|
||||
VToolPointFromCircleAndTangent::FindPoint(static_cast<QPointF>(*tan), static_cast<QPointF>(*center),
|
||||
cRadius, crossPoint, &fPoint);
|
||||
DrawPoint(point, fPoint, mainColor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,9 +80,9 @@ void VisToolPointOfContact::RefreshGeometry()
|
|||
|
||||
if (not qFuzzyIsNull(radius))
|
||||
{
|
||||
QPointF fPoint = VToolPointOfContact::FindPoint(radius, static_cast<QPointF>(*third),
|
||||
static_cast<QPointF>(*first),
|
||||
static_cast<QPointF>(*second));
|
||||
QPointF fPoint;
|
||||
VToolPointOfContact::FindPoint(radius, static_cast<QPointF>(*third), static_cast<QPointF>(*first),
|
||||
static_cast<QPointF>(*second), &fPoint);
|
||||
DrawPoint(point, fPoint, mainColor);
|
||||
|
||||
circle->setRect(PointRect(radius));
|
||||
|
|
|
@ -91,9 +91,9 @@ void VisToolTriangle::RefreshGeometry()
|
|||
DrawLine(this, QLineF(static_cast<QPointF>(*third), Visualization::scenePos), supportColor,
|
||||
Qt::DashLine);
|
||||
|
||||
QPointF trPoint = VToolTriangle::FindPoint(static_cast<QPointF>(*first),
|
||||
static_cast<QPointF>(*second),
|
||||
static_cast<QPointF>(*third), Visualization::scenePos);
|
||||
QPointF trPoint;
|
||||
VToolTriangle::FindPoint(static_cast<QPointF>(*first), static_cast<QPointF>(*second),
|
||||
static_cast<QPointF>(*third), Visualization::scenePos, &trPoint);
|
||||
DrawPoint(point, trPoint, mainColor);
|
||||
|
||||
DrawLine(foot1, QLineF(static_cast<QPointF>(*third), trPoint), supportColor, Qt::DashLine);
|
||||
|
@ -107,10 +107,9 @@ void VisToolTriangle::RefreshGeometry()
|
|||
DrawLine(this, QLineF(static_cast<QPointF>(*third), static_cast<QPointF>(*forth)), supportColor,
|
||||
Qt::DashLine);
|
||||
|
||||
QPointF trPoint = VToolTriangle::FindPoint(static_cast<QPointF>(*first),
|
||||
static_cast<QPointF>(*second),
|
||||
static_cast<QPointF>(*third),
|
||||
static_cast<QPointF>(*forth));
|
||||
QPointF trPoint;
|
||||
VToolTriangle::FindPoint(static_cast<QPointF>(*first), static_cast<QPointF>(*second),
|
||||
static_cast<QPointF>(*third), static_cast<QPointF>(*forth), &trPoint);
|
||||
DrawPoint(point, trPoint, mainColor);
|
||||
|
||||
DrawLine(foot1, QLineF(static_cast<QPointF>(*third), trPoint), supportColor, Qt::DashLine);
|
||||
|
|
|
@ -235,7 +235,8 @@ void TST_FindPoint::TestLineIntersectAxis()
|
|||
QFETCH(QLineF, line);
|
||||
QFETCH(QPointF, point);
|
||||
|
||||
QPointF resultPoint = VToolLineIntersectAxis::FindPoint(axis, line);
|
||||
QPointF resultPoint;
|
||||
VToolLineIntersectAxis::FindPoint(axis, line, &resultPoint);
|
||||
QCOMPARE(point, resultPoint);
|
||||
}
|
||||
|
||||
|
@ -266,7 +267,8 @@ void TST_FindPoint::TestTriangle()
|
|||
QFETCH(QPointF, secondPoint);
|
||||
QFETCH(QPointF, point);
|
||||
|
||||
QPointF resultPoint = VToolTriangle::FindPoint(axisP1, axisP2, firstPoint, secondPoint);
|
||||
QPointF resultPoint;
|
||||
VToolTriangle::FindPoint(axisP1, axisP2, firstPoint, secondPoint, &resultPoint);
|
||||
QCOMPARE(point, resultPoint);
|
||||
}
|
||||
|
||||
|
@ -544,7 +546,8 @@ void TST_FindPoint::TestCurveIntersectAxis()
|
|||
QFETCH(QVector<QPointF>, curvePoints);
|
||||
QFETCH(QPointF, result);
|
||||
|
||||
const QPointF resultPoint = VToolCurveIntersectAxis::FindPoint(basePoint, angle, curvePoints);
|
||||
QPointF resultPoint;
|
||||
VToolCurveIntersectAxis::FindPoint(basePoint, angle, curvePoints, &resultPoint);
|
||||
|
||||
QCOMPARE(result, resultPoint);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user