Fixed issue #43.

--HG--
branch : feature
This commit is contained in:
dismine 2014-05-30 14:50:41 +03:00
parent 7c2c355889
commit 54dfd9457e
27 changed files with 188 additions and 141 deletions

View File

@ -164,27 +164,25 @@ void VToolAlongLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPatt
DialogAlongLine *dialogTool = qobject_cast<DialogAlongLine*>(dialog);
Q_CHECK_PTR(dialogTool);
QString formula = dialogTool->getFormula();
quint32 firstPointId = dialogTool->getFirstPointId();
quint32 secondPointId = dialogTool->getSecondPointId();
QString typeLine = dialogTool->getTypeLine();
QString pointName = dialogTool->getPointName();
const quint32 firstPointId = dialogTool->getFirstPointId();
const quint32 secondPointId = dialogTool->getSecondPointId();
const QString typeLine = dialogTool->getTypeLine();
const QString pointName = dialogTool->getPointName();
Create(0, pointName, typeLine, formula, firstPointId, secondPointId, 5, 10, scene, doc, data,
Document::FullParse, Valentina::FromGui);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolAlongLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine,
const QString &formula, const quint32 &firstPointId, const quint32 &secondPointId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation)
void VToolAlongLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine, QString &formula,
const quint32 &firstPointId, const quint32 &secondPointId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document::Documents &parse, const Valentina::Sources &typeCreation)
{
const VPointF *firstPoint = data->GeometricObject<const VPointF *>(firstPointId);
const VPointF *secondPoint = data->GeometricObject<const VPointF *>(secondPointId);
QLineF line = QLineF(firstPoint->toQPointF(), secondPoint->toQPointF());
Calculator cal(data);
const qreal result = cal.EvalFormula(formula);
line.setLength(qApp->toPixel(result));
line.setLength(qApp->toPixel(CheckFormula(formula, data)));
quint32 id = _id;
if (typeCreation == Valentina::FromGui)

View File

@ -81,7 +81,7 @@ public:
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static void Create(const quint32 _id, const QString &pointName, const QString &typeLine, const QString &formula,
static void Create(const quint32 _id, const QString &pointName, const QString &typeLine, QString &formula,
const quint32 &firstPointId, const quint32 &secondPointId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document::Documents &parse, const Valentina::Sources &typeCreation);

View File

@ -73,13 +73,12 @@ void VToolArc::setDialog()
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data)
void VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data)
{
Q_CHECK_PTR(dialog);
DialogArc *dialogTool = qobject_cast<DialogArc*>(dialog);
Q_CHECK_PTR(dialogTool);
quint32 center = dialogTool->GetCenter();
const quint32 center = dialogTool->GetCenter();
QString radius = dialogTool->GetRadius();
QString f1 = dialogTool->GetF1();
QString f2 = dialogTool->GetF2();
@ -87,19 +86,16 @@ void VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *d
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArc::Create(const quint32 _id, const quint32 &center, const QString &radius, const QString &f1,
const QString &f2, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document::Documents &parse, const Valentina::Sources &typeCreation)
void VToolArc::Create(const quint32 _id, const quint32 &center, QString &radius, QString &f1, QString &f2,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse,
const Valentina::Sources &typeCreation)
{
qreal calcRadius = 0, calcF1 = 0, calcF2 = 0;
Calculator cal(data);
calcRadius = qApp->toPixel(CheckFormula(radius, data));
qreal result = cal.EvalFormula(radius);
calcRadius = qApp->toPixel(result);
calcF1 = cal.EvalFormula(f1);
calcF2 = cal.EvalFormula(f2);
calcF1 = CheckFormula(f1, data);
calcF2 = CheckFormula(f2, data);
VPointF c = *data->GeometricObject<const VPointF *>(center);
VArc *arc = new VArc(c, calcRadius, radius, calcF1, f1, calcF2, f2 );

View File

@ -75,9 +75,9 @@ public:
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static void Create(const quint32 _id, const quint32 &center, const QString &radius, const QString &f1,
const QString &f2, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document::Documents &parse, const Valentina::Sources &typeCreation);
static void Create(const quint32 _id, const quint32 &center, QString &radius, QString &f1, QString &f2,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document::Documents &parse,
const Valentina::Sources &typeCreation);
static const QString TagName;
static const QString ToolType;
public slots:

View File

@ -94,17 +94,17 @@ void VToolBisector::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPatte
DialogBisector *dialogTool = qobject_cast<DialogBisector*>(dialog);
Q_CHECK_PTR(dialogTool);
QString formula = dialogTool->getFormula();
quint32 firstPointId = dialogTool->getFirstPointId();
quint32 secondPointId = dialogTool->getSecondPointId();
quint32 thirdPointId = dialogTool->getThirdPointId();
QString typeLine = dialogTool->getTypeLine();
QString pointName = dialogTool->getPointName();
const quint32 firstPointId = dialogTool->getFirstPointId();
const quint32 secondPointId = dialogTool->getSecondPointId();
const quint32 thirdPointId = dialogTool->getThirdPointId();
const QString typeLine = dialogTool->getTypeLine();
const QString pointName = dialogTool->getPointName();
Create(0, formula, firstPointId, secondPointId, thirdPointId, typeLine, pointName, 5, 10, scene, doc, data,
Document::FullParse, Valentina::FromGui);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolBisector::Create(const quint32 _id, const QString &formula, const quint32 &firstPointId,
void VToolBisector::Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine,
const QString &pointName, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
@ -114,8 +114,7 @@ void VToolBisector::Create(const quint32 _id, const QString &formula, const quin
const VPointF *secondPoint = data->GeometricObject<const VPointF *>(secondPointId);
const VPointF *thirdPoint = data->GeometricObject<const VPointF *>(thirdPointId);
Calculator cal(data);
const qreal result = cal.EvalFormula(formula);
const qreal result = CheckFormula(formula, data);
QPointF fPoint = VToolBisector::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(),
thirdPoint->toQPointF(), qApp->toPixel(result));

View File

@ -93,7 +93,7 @@ public:
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static void Create(const quint32 _id, const QString &formula, const quint32 &firstPointId,
static void Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine,
const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document::Documents &parse,

View File

@ -83,21 +83,20 @@ void VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern
Q_CHECK_PTR(dialog);
DialogCutArc *dialogTool = qobject_cast<DialogCutArc*>(dialog);
Q_CHECK_PTR(dialogTool);
QString pointName = dialogTool->getPointName();
const QString pointName = dialogTool->getPointName();
QString formula = dialogTool->getFormula();
quint32 arcId = dialogTool->getArcId();
const quint32 arcId = dialogTool->getArcId();
Create(0, pointName, formula, arcId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolCutArc::Create(const quint32 _id, const QString &pointName, const QString &formula, const quint32 &arcId,
void VToolCutArc::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation)
{
const VArc *arc = data->GeometricObject<const VArc *>(arcId);
Calculator cal(data);
const qreal result = cal.EvalFormula(formula);
const qreal result = CheckFormula(formula, data);
VArc arc1;
VArc arc2;

View File

@ -80,7 +80,7 @@ public:
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static void Create(const quint32 _id, const QString &pointName, const QString &formula, const quint32 &arcId,
static void Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation);
static const QString ToolType;

View File

@ -83,22 +83,20 @@ void VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
Q_CHECK_PTR(dialog);
DialogCutSpline *dialogTool = qobject_cast<DialogCutSpline*>(dialog);
Q_CHECK_PTR(dialogTool);
QString pointName = dialogTool->getPointName();
const QString pointName = dialogTool->getPointName();
QString formula = dialogTool->getFormula();
quint32 splineId = dialogTool->getSplineId();
const quint32 splineId = dialogTool->getSplineId();
Create(0, pointName, formula, splineId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolCutSpline::Create(const quint32 _id, const QString &pointName,
const QString &formula, const quint32 &splineId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document::Documents &parse, const Valentina::Sources &typeCreation)
void VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splineId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation)
{
const VSpline *spl = data->GeometricObject<const VSpline *>(splineId);
Calculator cal(data);
const qreal result = cal.EvalFormula(formula);
const qreal result = CheckFormula(formula, data);
QPointF spl1p2, spl1p3, spl2p2, spl2p3;
QPointF point = spl->CutSpline(qApp->toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3);

View File

@ -78,9 +78,8 @@ public:
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static void Create(const quint32 _id, const QString &pointName,
const QString &formula, const quint32 &splineId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
static void Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splineId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document::Documents &parse, const Valentina::Sources &typeCreation);
static const QString ToolType;
static const QString AttrSpline;

View File

@ -83,14 +83,14 @@ void VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, V
Q_CHECK_PTR(dialog);
DialogCutSplinePath *dialogTool = qobject_cast<DialogCutSplinePath*>(dialog);
Q_CHECK_PTR(dialogTool);
QString pointName = dialogTool->getPointName();
const QString pointName = dialogTool->getPointName();
QString formula = dialogTool->getFormula();
quint32 splinePathId = dialogTool->getSplinePathId();
const quint32 splinePathId = dialogTool->getSplinePathId();
Create(0, pointName, formula, splinePathId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, const QString &formula,
void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QString &formula,
const quint32 &splinePathId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document::Documents &parse, const Valentina::Sources &typeCreation)
@ -98,8 +98,7 @@ void VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, con
const VSplinePath *splPath = data->GeometricObject<const VSplinePath *>(splinePathId);
Q_CHECK_PTR(splPath);
Calculator cal(data);
const qreal result = cal.EvalFormula(formula);
const qreal result = CheckFormula(formula, data);
quint32 id = _id;
QPointF spl1p2, spl1p3, spl2p2, spl2p3;

View File

@ -81,10 +81,9 @@ public:
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static void Create(const quint32 _id, const QString &pointName, const QString &formula,
const quint32 &splinePathId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document::Documents &parse,
const Valentina::Sources &typeCreation);
static void Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splinePathId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document::Documents &parse, const Valentina::Sources &typeCreation);
static const QString ToolType;
static const QString AttrSplinePath;
public slots:

View File

@ -72,11 +72,11 @@ void VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPatter
Q_CHECK_PTR(dialog);
DialogEndLine *dialogTool = qobject_cast<DialogEndLine*>(dialog);
Q_CHECK_PTR(dialogTool);
QString pointName = dialogTool->getPointName();
QString typeLine = dialogTool->getTypeLine();
const QString pointName = dialogTool->getPointName();
const QString typeLine = dialogTool->getTypeLine();
QString formula = dialogTool->getFormula();
qreal angle = dialogTool->getAngle();
quint32 basePointId = dialogTool->getBasePointId();
const qreal angle = dialogTool->getAngle();
const quint32 basePointId = dialogTool->getBasePointId();
Create(0, pointName, typeLine, formula, angle, basePointId, 5, 10, scene, doc, data, Document::FullParse,
Valentina::FromGui);
}
@ -90,9 +90,7 @@ void VToolEndLine::Create(const quint32 _id, const QString &pointName, const QSt
const VPointF *basePoint = data->GeometricObject<const VPointF *>(basePointId);
QLineF line = QLineF(basePoint->toQPointF(), QPointF(basePoint->x()+100, basePoint->y()));
qreal result = CheckFormula(formula, data);
line.setLength(qApp->toPixel(result));
line.setLength(qApp->toPixel(CheckFormula(formula, data)));
line.setAngle(angle);
quint32 id = _id;
if (typeCreation == Valentina::FromGui)

View File

@ -70,11 +70,11 @@ void VToolHeight::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern
DialogHeight *dialogTool = qobject_cast<DialogHeight*>(dialog);
Q_CHECK_PTR(dialogTool);
disconnect(doc, &VPattern::FullUpdateFromFile, dialogTool, &DialogHeight::UpdateList);
QString pointName = dialogTool->getPointName();
QString typeLine = dialogTool->getTypeLine();
quint32 basePointId = dialogTool->getBasePointId();
quint32 p1LineId = dialogTool->getP1LineId();
quint32 p2LineId = dialogTool->getP2LineId();
const QString pointName = dialogTool->getPointName();
const QString typeLine = dialogTool->getTypeLine();
const quint32 basePointId = dialogTool->getBasePointId();
const quint32 p1LineId = dialogTool->getP1LineId();
const quint32 p2LineId = dialogTool->getP2LineId();
Create(0, pointName, typeLine, basePointId, p1LineId, p2LineId, 5, 10, scene, doc, data,
Document::FullParse, Valentina::FromGui);
}

View File

@ -76,9 +76,9 @@ void VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *
Q_CHECK_PTR(dialog);
DialogLine *dialogTool = qobject_cast<DialogLine*>(dialog);
Q_CHECK_PTR(dialogTool);
quint32 firstPoint = dialogTool->getFirstPoint();
quint32 secondPoint = dialogTool->getSecondPoint();
QString typeLine = dialogTool->getTypeLine();
const quint32 firstPoint = dialogTool->getFirstPoint();
const quint32 secondPoint = dialogTool->getSecondPoint();
const QString typeLine = dialogTool->getTypeLine();
Create(0, firstPoint, secondPoint, typeLine, scene, doc, data, Document::FullParse, Valentina::FromGui);
}

View File

@ -70,11 +70,11 @@ void VToolLineIntersect::Create(DialogTool *dialog, VMainGraphicsScene *scene, V
Q_CHECK_PTR(dialog);
DialogLineIntersect *dialogTool = qobject_cast<DialogLineIntersect*>(dialog);
Q_CHECK_PTR(dialogTool);
quint32 p1Line1Id = dialogTool->getP1Line1();
quint32 p2Line1Id = dialogTool->getP2Line1();
quint32 p1Line2Id = dialogTool->getP1Line2();
quint32 p2Line2Id = dialogTool->getP2Line2();
QString pointName = dialogTool->getPointName();
const quint32 p1Line1Id = dialogTool->getP1Line1();
const quint32 p2Line1Id = dialogTool->getP2Line1();
const quint32 p1Line2Id = dialogTool->getP1Line2();
const quint32 p2Line2Id = dialogTool->getP2Line2();
const QString pointName = dialogTool->getPointName();
Create(0, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, pointName, 5, 10, scene, doc, data,
Document::FullParse, Valentina::FromGui);
}

View File

@ -72,17 +72,17 @@ void VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern
DialogNormal *dialogTool = qobject_cast<DialogNormal*>(dialog);
Q_CHECK_PTR(dialogTool);
QString formula = dialogTool->getFormula();
quint32 firstPointId = dialogTool->getFirstPointId();
quint32 secondPointId = dialogTool->getSecondPointId();
QString typeLine = dialogTool->getTypeLine();
QString pointName = dialogTool->getPointName();
qreal angle = dialogTool->getAngle();
const quint32 firstPointId = dialogTool->getFirstPointId();
const quint32 secondPointId = dialogTool->getSecondPointId();
const QString typeLine = dialogTool->getTypeLine();
const QString pointName = dialogTool->getPointName();
const qreal angle = dialogTool->getAngle();
Create(0, formula, firstPointId, secondPointId, typeLine, pointName, angle, 5, 10, scene, doc, data,
Document::FullParse, Valentina::FromGui);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolNormal::Create(const quint32 _id, const QString &formula, const quint32 &firstPointId,
void VToolNormal::Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
const quint32 &secondPointId, const QString &typeLine, const QString &pointName,
const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document::Documents &parse,
@ -91,8 +91,7 @@ void VToolNormal::Create(const quint32 _id, const QString &formula, const quint3
const VPointF *firstPoint = data->GeometricObject<const VPointF *>(firstPointId);
const VPointF *secondPoint = data->GeometricObject<const VPointF *>(secondPointId);
Calculator cal(data);
const qreal result = cal.EvalFormula(formula);
const qreal result = CheckFormula(formula, data);
QPointF fPoint = VToolNormal::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(),
qApp->toPixel(result), angle);

View File

@ -84,7 +84,7 @@ public:
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static void Create(const quint32 _id, const QString &formula, const quint32 &firstPointId,
static void Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
const quint32 &secondPointId, const QString &typeLine, const QString &pointName,
const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VPattern *doc, VContainer *data, const Document::Documents &parse,

View File

@ -98,27 +98,25 @@ void VToolPointOfContact::Create(DialogTool *dialog, VMainGraphicsScene *scene,
DialogPointOfContact *dialogTool = qobject_cast<DialogPointOfContact*>(dialog);
Q_CHECK_PTR(dialogTool);
QString radius = dialogTool->getRadius();
quint32 center = dialogTool->getCenter();
quint32 firstPointId = dialogTool->getFirstPoint();
quint32 secondPointId = dialogTool->getSecondPoint();
QString pointName = dialogTool->getPointName();
const quint32 center = dialogTool->getCenter();
const quint32 firstPointId = dialogTool->getFirstPoint();
const quint32 secondPointId = dialogTool->getSecondPoint();
const QString pointName = dialogTool->getPointName();
Create(0, radius, center, firstPointId, secondPointId, pointName, 5, 10, scene, doc, data,
Document::FullParse, Valentina::FromGui);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolPointOfContact::Create(const quint32 _id, const QString &radius, const quint32 &center,
const quint32 &firstPointId, const quint32 &secondPointId,
const QString &pointName, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
void VToolPointOfContact::Create(const quint32 _id, QString &radius, const quint32 &center, const quint32 &firstPointId,
const quint32 &secondPointId, const QString &pointName, const qreal &mx,
const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document::Documents &parse, const Valentina::Sources &typeCreation)
{
const VPointF *centerP = data->GeometricObject<const VPointF *>(center);
const VPointF *firstP = data->GeometricObject<const VPointF *>(firstPointId);
const VPointF *secondP = data->GeometricObject<const VPointF *>(secondPointId);
Calculator cal(data);
const qreal result = cal.EvalFormula(radius);
const qreal result = CheckFormula(radius, data);
QPointF fPoint = VToolPointOfContact::FindPoint(qApp->toPixel(result), centerP->toQPointF(),
firstP->toQPointF(), secondP->toQPointF());

View File

@ -91,7 +91,7 @@ public:
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static void Create(const quint32 _id, const QString &arcRadius, const quint32 &center,
static void Create(const quint32 _id, QString &arcRadius, const quint32 &center,
const quint32 &firstPointId, const quint32 &secondPointId, const QString &pointName,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document::Documents &parse, const Valentina::Sources &typeCreation);

View File

@ -67,9 +67,9 @@ void VToolPointOfIntersection::Create(DialogTool *dialog, VMainGraphicsScene *sc
Q_CHECK_PTR(dialog);
DialogPointOfIntersection *dialogTool = qobject_cast<DialogPointOfIntersection*>(dialog);
Q_CHECK_PTR(dialogTool);
quint32 firstPointId = dialogTool->getFirstPointId();
quint32 secondPointId = dialogTool->getSecondPointId();
QString pointName = dialogTool->getPointName();
const quint32 firstPointId = dialogTool->getFirstPointId();
const quint32 secondPointId = dialogTool->getSecondPointId();
const QString pointName = dialogTool->getPointName();
Create(0, pointName, firstPointId, secondPointId, 5, 10, scene, doc, data, Document::FullParse, Valentina::FromGui);
}

View File

@ -100,17 +100,17 @@ void VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphicsScene *scene, V
DialogShoulderPoint *dialogTool = qobject_cast<DialogShoulderPoint*>(dialog);
Q_CHECK_PTR(dialogTool);
QString formula = dialogTool->getFormula();
quint32 p1Line = dialogTool->getP1Line();
quint32 p2Line = dialogTool->getP2Line();
quint32 pShoulder = dialogTool->getPShoulder();
QString typeLine = dialogTool->getTypeLine();
QString pointName = dialogTool->getPointName();
const quint32 p1Line = dialogTool->getP1Line();
const quint32 p2Line = dialogTool->getP2Line();
const quint32 pShoulder = dialogTool->getPShoulder();
const QString typeLine = dialogTool->getTypeLine();
const QString pointName = dialogTool->getPointName();
Create(0, formula, p1Line, p2Line, pShoulder, typeLine, pointName, 5, 10, scene, doc, data,
Document::FullParse, Valentina::FromGui);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolShoulderPoint::Create(const quint32 _id, const QString &formula, const quint32 &p1Line,
void VToolShoulderPoint::Create(const quint32 _id, QString &formula, const quint32 &p1Line,
const quint32 &p2Line, const quint32 &pShoulder, const QString &typeLine,
const QString &pointName, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
@ -120,8 +120,7 @@ void VToolShoulderPoint::Create(const quint32 _id, const QString &formula, const
const VPointF *secondPoint = data->GeometricObject<const VPointF *>(p2Line);
const VPointF *shoulderPoint = data->GeometricObject<const VPointF *>(pShoulder);
Calculator cal(data);
const qreal result = cal.EvalFormula(formula);
const qreal result = CheckFormula(formula, data);
QPointF fPoint = VToolShoulderPoint::FindPoint(firstPoint->toQPointF(), secondPoint->toQPointF(),
shoulderPoint->toQPointF(), qApp->toPixel(result));

View File

@ -94,7 +94,7 @@ public:
* @param parse parser file mode.
* @param typeCreation way we create this tool.
*/
static void Create(const quint32 _id, const QString &formula, const quint32 &p1Line, const quint32 &p2Line,
static void Create(const quint32 _id, QString &formula, const quint32 &p1Line, const quint32 &p2Line,
const quint32 &pShoulder, const QString &typeLine, const QString &pointName, const qreal &mx,
const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document::Documents &parse, const Valentina::Sources &typeCreation);

View File

@ -95,13 +95,13 @@ void VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern
Q_CHECK_PTR(dialog);
DialogSpline *dialogTool = qobject_cast<DialogSpline*>(dialog);
Q_CHECK_PTR(dialogTool);
quint32 p1 = dialogTool->getP1();
quint32 p4 = dialogTool->getP4();
qreal kAsm1 = dialogTool->getKAsm1();
qreal kAsm2 = dialogTool->getKAsm2();
qreal angle1 = dialogTool->getAngle1();
qreal angle2 = dialogTool->getAngle2();
qreal kCurve = dialogTool->getKCurve();
const quint32 p1 = dialogTool->getP1();
const quint32 p4 = dialogTool->getP4();
const qreal kAsm1 = dialogTool->getKAsm1();
const qreal kAsm2 = dialogTool->getKAsm2();
const qreal angle1 = dialogTool->getAngle1();
const qreal angle2 = dialogTool->getAngle2();
const qreal kCurve = dialogTool->getKCurve();
Create(0, p1, p4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, doc, data, Document::FullParse,
Valentina::FromGui);
}

View File

@ -70,11 +70,11 @@ void VToolTriangle::Create(DialogTool *dialog, VMainGraphicsScene *scene,
Q_CHECK_PTR(dialog);
DialogTriangle *dialogTool = qobject_cast<DialogTriangle*>(dialog);
Q_CHECK_PTR(dialogTool);
quint32 axisP1Id = dialogTool->getAxisP1Id();
quint32 axisP2Id = dialogTool->getAxisP2Id();
quint32 firstPointId = dialogTool->getFirstPointId();
quint32 secondPointId = dialogTool->getSecondPointId();
QString pointName = dialogTool->getPointName();
const quint32 axisP1Id = dialogTool->getAxisP1Id();
const quint32 axisP2Id = dialogTool->getAxisP2Id();
const quint32 firstPointId = dialogTool->getFirstPointId();
const quint32 secondPointId = dialogTool->getSecondPointId();
const QString pointName = dialogTool->getPointName();
Create(0, pointName, axisP1Id, axisP2Id, firstPointId, secondPointId, 5, 10, scene, doc, data,
Document::FullParse, Valentina::FromGui);
}

View File

@ -845,7 +845,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != formula)
{
SetAttribute(domElement, VToolEndLine::AttrLength, f);
SetAttribute(domElement, VAbstractTool::AttrLength, f);
haveLiteChange();
}
}
@ -874,11 +874,18 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
VAbstractTool::TypeLineLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
QString f = formula;//need for saving fixed formula;
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
VToolAlongLine::Create(id, name, typeLine, formula, firstPointId, secondPointId, mx, my, scene, this,
VToolAlongLine::Create(id, name, typeLine, f, firstPointId, secondPointId, mx, my, scene, this,
data, parse, Valentina::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != formula)
{
SetAttribute(domElement, VAbstractTool::AttrLength, f);
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
@ -905,12 +912,19 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
VAbstractTool::TypeLineLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
QString f = formula;//need for saving fixed formula;
const quint32 p1Line = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, "0");
const quint32 p2Line = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, "0");
const quint32 pShoulder = GetParametrUInt(domElement, VAbstractTool::AttrPShoulder, "0");
VToolShoulderPoint::Create(id, formula, p1Line, p2Line, pShoulder, typeLine, name, mx, my, scene, this,
VToolShoulderPoint::Create(id, f, p1Line, p2Line, pShoulder, typeLine, name, mx, my, scene, this,
data, parse, Valentina::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != formula)
{
SetAttribute(domElement, VAbstractTool::AttrLength, f);
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
@ -937,12 +951,19 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
VAbstractTool::TypeLineLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
QString f = formula;//need for saving fixed formula;
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
const qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0");
VToolNormal::Create(id, formula, firstPointId, secondPointId, typeLine, name, angle, mx, my, scene,
VToolNormal::Create(id, f, firstPointId, secondPointId, typeLine, name, angle, mx, my, scene,
this, data, parse, Valentina::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != formula)
{
SetAttribute(domElement, VAbstractTool::AttrLength, f);
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
@ -969,12 +990,19 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine,
VAbstractTool::TypeLineLine);
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0");
QString f = formula;//need for saving fixed formula;
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
const quint32 thirdPointId = GetParametrUInt(domElement, VAbstractTool::AttrThirdPoint, "0");
VToolBisector::Create(id, formula, firstPointId, secondPointId, thirdPointId,
VToolBisector::Create(id, f, firstPointId, secondPointId, thirdPointId,
typeLine, name, mx, my, scene, this, data, parse, Valentina::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != formula)
{
SetAttribute(domElement, VAbstractTool::AttrLength, f);
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
@ -1021,12 +1049,19 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "0");
QString f = radius;//need for saving fixed formula;
const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0");
const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, "0");
const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, "0");
VToolPointOfContact::Create(id, radius, center, firstPointId, secondPointId, name, mx, my, scene, this,
VToolPointOfContact::Create(id, f, center, firstPointId, secondPointId, name, mx, my, scene, this,
data, parse, Valentina::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != radius)
{
SetAttribute(domElement, VAbstractTool::AttrRadius, f);
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
@ -1136,10 +1171,16 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
QString f = formula;//need for saving fixed formula;
const quint32 splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, "0");
VToolCutSpline::Create(id, name, formula, splineId, mx, my, scene, this, data, parse,
Valentina::FromFile);
VToolCutSpline::Create(id, name, f, splineId, mx, my, scene, this, data, parse, Valentina::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != formula)
{
SetAttribute(domElement, VAbstractTool::AttrLength, f);
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
@ -1164,10 +1205,17 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
QString f = formula;//need for saving fixed formula;
const quint32 splinePathId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, "0");
VToolCutSplinePath::Create(id, name, formula, splinePathId, mx, my,
scene, this, data, parse, Valentina::FromFile);
VToolCutSplinePath::Create(id, name, f, splinePathId, mx, my, scene, this, data, parse,
Valentina::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != formula)
{
SetAttribute(domElement, VAbstractTool::AttrLength, f);
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
@ -1192,9 +1240,16 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem
const qreal mx = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "10.0"));
const qreal my = qApp->toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "15.0"));
const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0");
QString f = formula;//need for saving fixed formula;
const quint32 arcId = GetParametrUInt(domElement, VToolCutArc::AttrArc, "0");
VToolCutArc::Create(id, name, formula, arcId, mx, my, scene, this, data, parse, Valentina::FromFile);
VToolCutArc::Create(id, name, f, arcId, mx, my, scene, this, data, parse, Valentina::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (f != formula)
{
SetAttribute(domElement, VAbstractTool::AttrLength, f);
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
@ -1364,8 +1419,8 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement &
}
//---------------------------------------------------------------------------------------------------------------------
void VPattern::ParseArcElement(VMainGraphicsScene *scene, const QDomElement &domElement,
const Document::Documents &parse, const QString &type)
void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document::Documents &parse,
const QString &type)
{
Q_CHECK_PTR(scene);
Q_ASSERT_X(domElement.isNull() == false, Q_FUNC_INFO, "domElement is null");
@ -1381,10 +1436,21 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, const QDomElement &dom
const quint32 id = GetParametrId(domElement);
const quint32 center = GetParametrUInt(domElement, VAbstractTool::AttrCenter, "0");
const QString radius = GetParametrString(domElement, VAbstractTool::AttrRadius, "10");
QString r = radius;//need for saving fixed formula;
const QString f1 = GetParametrString(domElement, VAbstractTool::AttrAngle1, "180");
QString f1Fix = f1;//need for saving fixed formula;
const QString f2 = GetParametrString(domElement, VAbstractTool::AttrAngle2, "270");
QString f2Fix = f2;//need for saving fixed formula;
VToolArc::Create(id, center, radius, f1, f2, scene, this, data, parse, Valentina::FromFile);
VToolArc::Create(id, center, r, f1Fix, f2Fix, scene, this, data, parse, Valentina::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (r != radius || f1Fix != f1 || f2Fix != f2)
{
SetAttribute(domElement, VAbstractTool::AttrRadius, r);
SetAttribute(domElement, VAbstractTool::AttrAngle1, f1Fix);
SetAttribute(domElement, VAbstractTool::AttrAngle2, f2Fix);
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{

View File

@ -363,7 +363,7 @@ private:
* @param type type of spline.
* @param mode draw mode.
*/
void ParseArcElement(VMainGraphicsScene *scene, const QDomElement& domElement,
void ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElement,
const Document::Documents &parse, const QString& type);
/**
* @brief ParseToolsElement parse tools tag.