Refactoring tool classes.
--HG-- branch : develop
This commit is contained in:
parent
bf60cfec3b
commit
10133a7a13
|
@ -73,16 +73,7 @@ void VToolAlongLine::FullUpdateFromFile()
|
|||
{
|
||||
ReadAttributes();
|
||||
RefreshGeometry();
|
||||
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolAlongLine * visual = qobject_cast<VisToolAlongLine *>(vis);
|
||||
visual->setPoint1Id(basePointId);
|
||||
visual->setPoint2Id(secondPointId);
|
||||
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
SetVisualization();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -163,6 +154,21 @@ void VToolAlongLine::ReadToolAttributes(const QDomElement &domElement)
|
|||
secondPointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolAlongLine::SetVisualization()
|
||||
{
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolAlongLine *visual = qobject_cast<VisToolAlongLine *>(vis);
|
||||
SCASSERT(visual != nullptr)
|
||||
visual->setPoint1Id(basePointId);
|
||||
visual->setPoint2Id(secondPointId);
|
||||
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolAlongLine::GetSecondPointId() const
|
||||
{
|
||||
|
@ -188,23 +194,12 @@ void VToolAlongLine::ShowVisualization(bool show)
|
|||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
VisToolAlongLine *visual = new VisToolAlongLine(getData());
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
||||
scene->addItem(visual);
|
||||
|
||||
visual->setPoint1Id(basePointId);
|
||||
visual->setPoint2Id(secondPointId);
|
||||
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
vis = visual;
|
||||
AddVisualization<VisToolAlongLine>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
VisToolAlongLine * visual = qobject_cast<VisToolAlongLine *>(vis);
|
||||
if (visual != nullptr)
|
||||
if (VisToolAlongLine * visual = qobject_cast<VisToolAlongLine *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ protected:
|
|||
virtual void SaveDialog(QDomElement &domElement);
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement);
|
||||
virtual void SetVisualization();
|
||||
private:
|
||||
/** @brief secondPointId id second point of line. */
|
||||
quint32 secondPointId;
|
||||
|
|
|
@ -292,25 +292,12 @@ void VToolArc::ShowVisualization(bool show)
|
|||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
VisToolArc * visual = new VisToolArc(getData());
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
||||
scene->addItem(visual);
|
||||
|
||||
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
|
||||
|
||||
visual->setPoint1Id(arc->GetCenter().id());
|
||||
visual->setRadius(qApp->FormulaToUser(arc->GetFormulaRadius()));
|
||||
visual->setF1(qApp->FormulaToUser(arc->GetFormulaF1()));
|
||||
visual->setF2(qApp->FormulaToUser(arc->GetFormulaF2()));
|
||||
visual->RefreshGeometry();
|
||||
vis = visual;
|
||||
AddVisualization<VisToolArc>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
VisToolArc *visual = qobject_cast<VisToolArc *>(vis);
|
||||
if (visual != nullptr)
|
||||
if (VisToolArc *visual = qobject_cast<VisToolArc *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
|
@ -375,18 +362,13 @@ void VToolArc::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief RefreshGeometry refresh item on scene.
|
||||
*/
|
||||
void VToolArc::RefreshGeometry()
|
||||
void VToolArc::SetVisualization()
|
||||
{
|
||||
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor));
|
||||
this->setPath(ToolPath());
|
||||
|
||||
if (vis != nullptr)
|
||||
{
|
||||
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
|
||||
VisToolArc *visual = qobject_cast<VisToolArc *>(vis);
|
||||
SCASSERT(visual != nullptr)
|
||||
|
||||
visual->setPoint1Id(arc->GetCenter().id());
|
||||
visual->setRadius(qApp->FormulaToUser(arc->GetFormulaRadius()));
|
||||
|
@ -395,3 +377,15 @@ void VToolArc::RefreshGeometry()
|
|||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief RefreshGeometry refresh item on scene.
|
||||
*/
|
||||
void VToolArc::RefreshGeometry()
|
||||
{
|
||||
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor));
|
||||
this->setPath(ToolPath());
|
||||
|
||||
SetVisualization();
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ protected:
|
|||
virtual void RemoveReferens();
|
||||
virtual void SaveDialog(QDomElement &domElement);
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void SetVisualization();
|
||||
private:
|
||||
void RefreshGeometry();
|
||||
};
|
||||
|
|
|
@ -321,6 +321,23 @@ void VToolBisector::ReadToolAttributes(const QDomElement &domElement)
|
|||
thirdPointId = doc->GetParametrUInt(domElement, AttrThirdPoint, NULL_ID_STR);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolBisector::SetVisualization()
|
||||
{
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolBisector *visual = qobject_cast<VisToolBisector *>(vis);
|
||||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->setPoint1Id(firstPointId);
|
||||
visual->setPoint2Id(basePointId);
|
||||
visual->setPoint3Id(thirdPointId);
|
||||
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolBisector::GetThirdPointId() const
|
||||
{
|
||||
|
@ -346,24 +363,12 @@ void VToolBisector::ShowVisualization(bool show)
|
|||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
VisToolBisector * visual = new VisToolBisector(getData());
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
||||
scene->addItem(visual);
|
||||
|
||||
visual->setPoint1Id(firstPointId);
|
||||
visual->setPoint2Id(basePointId);
|
||||
visual->setPoint3Id(thirdPointId);
|
||||
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
vis = visual;
|
||||
AddVisualization<VisToolBisector>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
VisToolBisector *visual = qobject_cast<VisToolBisector *>(vis);
|
||||
if (visual != nullptr)
|
||||
if (VisToolBisector *visual = qobject_cast<VisToolBisector *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@ protected:
|
|||
virtual void SaveDialog(QDomElement &domElement);
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement);
|
||||
virtual void SetVisualization();
|
||||
private:
|
||||
/** @brief firstPointId id first point of angle. */
|
||||
quint32 firstPointId;
|
||||
|
|
|
@ -226,23 +226,12 @@ void VToolCurveIntersectAxis::ShowVisualization(bool show)
|
|||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
VisToolCurveIntersectAxis * visual = new VisToolCurveIntersectAxis(getData());
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
||||
scene->addItem(visual);
|
||||
|
||||
visual->setPoint1Id(curveId);
|
||||
visual->setAxisPointId(basePointId);
|
||||
visual->SetAngle(qApp->FormulaToUser(formulaAngle));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
vis = visual;
|
||||
AddVisualization<VisToolCurveIntersectAxis>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
VisToolCurveIntersectAxis *visual = qobject_cast<VisToolCurveIntersectAxis *>(vis);
|
||||
if (visual != nullptr)
|
||||
if (VisToolCurveIntersectAxis *visual = qobject_cast<VisToolCurveIntersectAxis *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
|
@ -320,3 +309,19 @@ void VToolCurveIntersectAxis::ReadToolAttributes(const QDomElement &domElement)
|
|||
curveId = doc->GetParametrUInt(domElement, AttrCurve, NULL_ID_STR);
|
||||
formulaAngle = doc->GetParametrString(domElement, AttrAngle, "");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCurveIntersectAxis::SetVisualization()
|
||||
{
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolCurveIntersectAxis *visual = qobject_cast<VisToolCurveIntersectAxis *>(vis);
|
||||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->setPoint1Id(curveId);
|
||||
visual->setAxisPointId(basePointId);
|
||||
visual->SetAngle(qApp->FormulaToUser(formulaAngle));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ protected:
|
|||
virtual void SaveDialog(QDomElement &domElement);
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement);
|
||||
virtual void SetVisualization();
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolCurveIntersectAxis)
|
||||
QString formulaAngle;
|
||||
|
|
|
@ -191,21 +191,12 @@ void VToolCutArc::ShowVisualization(bool show)
|
|||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
VisToolCutArc * visual = new VisToolCutArc(getData());
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
||||
scene->addItem(visual);
|
||||
|
||||
visual->setPoint1Id(curveCutId);
|
||||
visual->setLength(qApp->FormulaToUser(formula));
|
||||
visual->RefreshGeometry();
|
||||
vis = visual;
|
||||
AddVisualization<VisToolCutArc>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
VisToolCutArc *visual = qobject_cast<VisToolCutArc *>(vis);
|
||||
if (visual != nullptr)
|
||||
if (VisToolCutArc *visual = qobject_cast<VisToolCutArc *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
|
@ -226,14 +217,7 @@ void VToolCutArc::FullUpdateFromFile()
|
|||
{
|
||||
ReadAttributes();
|
||||
RefreshGeometry();
|
||||
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolCutArc *visual = qobject_cast<VisToolCutArc *>(vis);
|
||||
visual->setPoint1Id(curveCutId);
|
||||
visual->setLength(qApp->FormulaToUser(formula));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
SetVisualization();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -320,3 +304,17 @@ void VToolCutArc::ReadToolAttributes(const QDomElement &domElement)
|
|||
curveCutId = doc->GetParametrUInt(domElement, AttrArc, NULL_ID_STR);
|
||||
lineColor = doc->GetParametrString(domElement, AttrColor, ColorBlack);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCutArc::SetVisualization()
|
||||
{
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolCutArc *visual = qobject_cast<VisToolCutArc *>(vis);
|
||||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->setPoint1Id(curveCutId);
|
||||
visual->setLength(qApp->FormulaToUser(formula));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ protected:
|
|||
PathDirection direction = PathDirection::Hide);
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement);
|
||||
virtual void SetVisualization();
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolCutArc)
|
||||
};
|
||||
|
|
|
@ -201,21 +201,12 @@ void VToolCutSpline::ShowVisualization(bool show)
|
|||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
VisToolCutSpline * visual = new VisToolCutSpline(getData());
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
||||
scene->addItem(visual);
|
||||
|
||||
visual->setPoint1Id(curveCutId);
|
||||
visual->setLength(qApp->FormulaToUser(formula));
|
||||
visual->RefreshGeometry();
|
||||
vis = visual;
|
||||
AddVisualization<VisToolCutSpline>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
VisToolCutSpline * visual = qobject_cast<VisToolCutSpline *>(vis);
|
||||
if (visual != nullptr)
|
||||
if (VisToolCutSpline * visual = qobject_cast<VisToolCutSpline *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
|
@ -247,14 +238,7 @@ void VToolCutSpline::FullUpdateFromFile()
|
|||
{
|
||||
ReadAttributes();
|
||||
RefreshGeometry();
|
||||
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolCutSpline *visual = qobject_cast<VisToolCutSpline *>(vis);
|
||||
visual->setPoint1Id(curveCutId);
|
||||
visual->setLength(qApp->FormulaToUser(formula));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
SetVisualization();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -341,3 +325,17 @@ void VToolCutSpline::ReadToolAttributes(const QDomElement &domElement)
|
|||
curveCutId = doc->GetParametrUInt(domElement, AttrSpline, NULL_ID_STR);
|
||||
lineColor = doc->GetParametrString(domElement, AttrColor, ColorBlack);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCutSpline::SetVisualization()
|
||||
{
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolCutSpline *visual = qobject_cast<VisToolCutSpline *>(vis);
|
||||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->setPoint1Id(curveCutId);
|
||||
visual->setLength(qApp->FormulaToUser(formula));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ protected:
|
|||
PathDirection direction = PathDirection::Hide);
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement);
|
||||
virtual void SetVisualization();
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolCutSpline)
|
||||
};
|
||||
|
|
|
@ -245,21 +245,12 @@ void VToolCutSplinePath::ShowVisualization(bool show)
|
|||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
VisToolCutSplinePath *visual = new VisToolCutSplinePath(getData());
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
||||
scene->addItem(visual);
|
||||
|
||||
visual->setPoint1Id(curveCutId);
|
||||
visual->setLength(qApp->FormulaToUser(formula));
|
||||
visual->RefreshGeometry();
|
||||
vis = visual;
|
||||
AddVisualization<VisToolCutSplinePath>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
VisToolCutSplinePath *visual = qobject_cast<VisToolCutSplinePath *>(vis);
|
||||
if (visual != nullptr)
|
||||
if (VisToolCutSplinePath *visual = qobject_cast<VisToolCutSplinePath *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
|
@ -291,14 +282,7 @@ void VToolCutSplinePath::FullUpdateFromFile()
|
|||
{
|
||||
ReadAttributes();
|
||||
RefreshGeometry();
|
||||
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolCutSplinePath *visual = qobject_cast<VisToolCutSplinePath *>(vis);
|
||||
visual->setPoint1Id(curveCutId);
|
||||
visual->setLength(qApp->FormulaToUser(formula));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
SetVisualization();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -387,3 +371,17 @@ void VToolCutSplinePath::ReadToolAttributes(const QDomElement &domElement)
|
|||
curveCutId = doc->GetParametrUInt(domElement, AttrSplinePath, NULL_ID_STR);
|
||||
lineColor = doc->GetParametrString(domElement, AttrColor, ColorBlack);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCutSplinePath::SetVisualization()
|
||||
{
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolCutSplinePath *visual = qobject_cast<VisToolCutSplinePath *>(vis);
|
||||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->setPoint1Id(curveCutId);
|
||||
visual->setLength(qApp->FormulaToUser(formula));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ protected:
|
|||
PathDirection direction = PathDirection::Hide);
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement);
|
||||
virtual void SetVisualization();
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolCutSplinePath)
|
||||
};
|
||||
|
|
|
@ -189,16 +189,7 @@ void VToolEndLine::FullUpdateFromFile()
|
|||
{
|
||||
ReadAttributes();
|
||||
RefreshGeometry();
|
||||
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolEndLine *visual = qobject_cast<VisToolEndLine *>(vis);
|
||||
visual->setPoint1Id(basePointId);
|
||||
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||
visual->SetAngle(qApp->FormulaToUser(formulaAngle));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
SetVisualization();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -257,6 +248,22 @@ void VToolEndLine::ReadToolAttributes(const QDomElement &domElement)
|
|||
formulaAngle = doc->GetParametrString(domElement, AttrAngle, "");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolEndLine::SetVisualization()
|
||||
{
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolEndLine *visual = qobject_cast<VisToolEndLine *>(vis);
|
||||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->setPoint1Id(basePointId);
|
||||
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||
visual->SetAngle(qApp->FormulaToUser(formulaAngle));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VFormula VToolEndLine::GetFormulaAngle() const
|
||||
{
|
||||
|
@ -286,23 +293,12 @@ void VToolEndLine::ShowVisualization(bool show)
|
|||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
VisToolEndLine * visual = new VisToolEndLine(getData());
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
||||
scene->addItem(visual);
|
||||
|
||||
visual->setPoint1Id(basePointId);
|
||||
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||
visual->SetAngle(qApp->FormulaToUser(formulaAngle));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
vis = visual;
|
||||
AddVisualization<VisToolEndLine>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
VisToolEndLine *visual = qobject_cast<VisToolEndLine *>(vis);
|
||||
if (visual != nullptr)
|
||||
if (VisToolEndLine *visual = qobject_cast<VisToolEndLine *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ protected:
|
|||
virtual void SaveDialog(QDomElement &domElement);
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement);
|
||||
virtual void SetVisualization();
|
||||
private:
|
||||
QString formulaAngle;
|
||||
};
|
||||
|
|
|
@ -197,16 +197,7 @@ void VToolHeight::FullUpdateFromFile()
|
|||
{
|
||||
ReadAttributes();
|
||||
RefreshGeometry();
|
||||
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolHeight *visual = qobject_cast<VisToolHeight *>(vis);
|
||||
visual->setPoint1Id(basePointId);
|
||||
visual->setLineP1Id(p1LineId);
|
||||
visual->setLineP2Id(p2LineId);
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
SetVisualization();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -265,6 +256,22 @@ void VToolHeight::ReadToolAttributes(const QDomElement &domElement)
|
|||
p2LineId = doc->GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolHeight::SetVisualization()
|
||||
{
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolHeight *visual = qobject_cast<VisToolHeight *>(vis);
|
||||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->setPoint1Id(basePointId);
|
||||
visual->setLineP1Id(p1LineId);
|
||||
visual->setLineP2Id(p2LineId);
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolHeight::GetP2LineId() const
|
||||
{
|
||||
|
@ -290,23 +297,12 @@ void VToolHeight::ShowVisualization(bool show)
|
|||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
VisToolHeight * visual = new VisToolHeight(getData());
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
||||
scene->addItem(visual);
|
||||
|
||||
visual->setPoint1Id(basePointId);
|
||||
visual->setLineP1Id(p1LineId);
|
||||
visual->setLineP2Id(p2LineId);
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
vis = visual;
|
||||
AddVisualization<VisToolHeight>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
VisToolHeight *visual = qobject_cast<VisToolHeight *>(vis);
|
||||
if (visual != nullptr)
|
||||
if (VisToolHeight *visual = qobject_cast<VisToolHeight *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ protected:
|
|||
virtual void SaveDialog(QDomElement &domElement);
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement);
|
||||
virtual void SetVisualization();
|
||||
private:
|
||||
/** @brief p1LineId id first point of line. */
|
||||
quint32 p1LineId;
|
||||
|
|
|
@ -195,15 +195,7 @@ void VToolLine::FullUpdateFromFile()
|
|||
{
|
||||
ReadAttributes();
|
||||
RefreshGeometry();
|
||||
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolLine *visual = qobject_cast<VisToolLine *>(vis);
|
||||
visual->setPoint1Id(firstPoint);
|
||||
visual->setPoint2Id(secondPoint);
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
SetVisualization();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -402,6 +394,21 @@ void VToolLine::ReadToolAttributes(const QDomElement &domElement)
|
|||
lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolLine::SetVisualization()
|
||||
{
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolLine *visual = qobject_cast<VisToolLine *>(vis);
|
||||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->setPoint1Id(firstPoint);
|
||||
visual->setPoint2Id(secondPoint);
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolLine::GetSecondPoint() const
|
||||
{
|
||||
|
@ -427,22 +434,12 @@ void VToolLine::ShowVisualization(bool show)
|
|||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
VisToolLine * visual = new VisToolLine(getData());
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
||||
scene->addItem(visual);
|
||||
|
||||
visual->setPoint1Id(firstPoint);
|
||||
visual->setPoint2Id(secondPoint);
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
vis = visual;
|
||||
AddVisualization<VisToolLine>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
VisToolLine *visual = qobject_cast<VisToolLine *>(vis);
|
||||
if (visual != nullptr)
|
||||
if (VisToolLine *visual = qobject_cast<VisToolLine *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ protected:
|
|||
virtual void SaveDialog(QDomElement &domElement);
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement);
|
||||
virtual void SetVisualization();
|
||||
private:
|
||||
/** @brief firstPoint id first line point. */
|
||||
quint32 firstPoint;
|
||||
|
|
|
@ -195,16 +195,7 @@ void VToolLineIntersect::FullUpdateFromFile()
|
|||
{
|
||||
ReadAttributes();
|
||||
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
|
||||
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolLineIntersect *visual = qobject_cast<VisToolLineIntersect *>(vis);
|
||||
visual->setPoint1Id(p1Line1);
|
||||
visual->setLine1P2Id(p2Line1);
|
||||
visual->setLine2P1Id(p1Line2);
|
||||
visual->setLine2P2Id(p2Line2);
|
||||
vis->RefreshGeometry();
|
||||
}
|
||||
SetVisualization();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -283,6 +274,22 @@ void VToolLineIntersect::ReadToolAttributes(const QDomElement &domElement)
|
|||
p2Line2 = doc->GetParametrUInt(domElement, AttrP2Line2, NULL_ID_STR);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolLineIntersect::SetVisualization()
|
||||
{
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolLineIntersect *visual = qobject_cast<VisToolLineIntersect *>(vis);
|
||||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->setPoint1Id(p1Line1);
|
||||
visual->setLine1P2Id(p2Line1);
|
||||
visual->setLine2P1Id(p1Line2);
|
||||
visual->setLine2P2Id(p2Line2);
|
||||
vis->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolLineIntersect::GetP2Line2() const
|
||||
{
|
||||
|
@ -308,23 +315,12 @@ void VToolLineIntersect::ShowVisualization(bool show)
|
|||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
VisToolLineIntersect * visual = new VisToolLineIntersect(getData());
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
||||
scene->addItem(visual);
|
||||
|
||||
visual->setPoint1Id(p1Line1);
|
||||
visual->setLine1P2Id(p2Line1);
|
||||
visual->setLine2P1Id(p1Line2);
|
||||
visual->setLine2P2Id(p2Line2);
|
||||
visual->RefreshGeometry();
|
||||
vis = visual;
|
||||
AddVisualization<VisToolLineIntersect>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
VisToolLineIntersect *visual = qobject_cast<VisToolLineIntersect *>(vis);
|
||||
if (visual != nullptr)
|
||||
if (VisToolLineIntersect *visual = qobject_cast<VisToolLineIntersect *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ protected:
|
|||
virtual void SaveDialog(QDomElement &domElement);
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement);
|
||||
virtual void SetVisualization();
|
||||
private:
|
||||
/** @brief p1Line1 id first point first line. */
|
||||
quint32 p1Line1;
|
||||
|
|
|
@ -238,24 +238,12 @@ void VToolLineIntersectAxis::ShowVisualization(bool show)
|
|||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
VisToolLineIntersectAxis * visual = new VisToolLineIntersectAxis(getData());
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
||||
scene->addItem(visual);
|
||||
|
||||
visual->setPoint1Id(firstPointId);
|
||||
visual->setPoint2Id(secondPointId);
|
||||
visual->setAxisPointId(basePointId);
|
||||
visual->SetAngle(qApp->FormulaToUser(formulaAngle));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
vis = visual;
|
||||
AddVisualization<VisToolLineIntersectAxis>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
VisToolLineIntersectAxis *visual = qobject_cast<VisToolLineIntersectAxis *>(vis);
|
||||
if (visual != nullptr)
|
||||
if (VisToolLineIntersectAxis *visual = qobject_cast<VisToolLineIntersectAxis *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
|
@ -273,17 +261,7 @@ void VToolLineIntersectAxis::FullUpdateFromFile()
|
|||
{
|
||||
ReadAttributes();
|
||||
RefreshGeometry();
|
||||
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolLineIntersectAxis *visual = qobject_cast<VisToolLineIntersectAxis *>(vis);
|
||||
visual->setPoint1Id(firstPointId);
|
||||
visual->setPoint2Id(secondPointId);
|
||||
visual->setAxisPointId(basePointId);
|
||||
visual->SetAngle(qApp->FormulaToUser(formulaAngle));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
SetVisualization();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -337,3 +315,20 @@ void VToolLineIntersectAxis::ReadToolAttributes(const QDomElement &domElement)
|
|||
secondPointId = doc->GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
|
||||
formulaAngle = doc->GetParametrString(domElement, AttrAngle, "");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolLineIntersectAxis::SetVisualization()
|
||||
{
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolLineIntersectAxis *visual = qobject_cast<VisToolLineIntersectAxis *>(vis);
|
||||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->setPoint1Id(firstPointId);
|
||||
visual->setPoint2Id(secondPointId);
|
||||
visual->setAxisPointId(basePointId);
|
||||
visual->SetAngle(qApp->FormulaToUser(formulaAngle));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ protected:
|
|||
virtual void SaveDialog(QDomElement &domElement);
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement);
|
||||
virtual void SetVisualization();
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolLineIntersectAxis)
|
||||
QString formulaAngle;
|
||||
|
|
|
@ -205,17 +205,7 @@ void VToolNormal::FullUpdateFromFile()
|
|||
{
|
||||
ReadAttributes();
|
||||
RefreshGeometry();
|
||||
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolNormal *visual = qobject_cast<VisToolNormal *>(vis);
|
||||
visual->setPoint1Id(basePointId);
|
||||
visual->setPoint2Id(secondPointId);
|
||||
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||
visual->SetAngle(angle);
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
SetVisualization();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -298,6 +288,23 @@ void VToolNormal::ReadToolAttributes(const QDomElement &domElement)
|
|||
angle = doc->GetParametrDouble(domElement, AttrAngle, "0");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolNormal::SetVisualization()
|
||||
{
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolNormal *visual = qobject_cast<VisToolNormal *>(vis);
|
||||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->setPoint1Id(basePointId);
|
||||
visual->setPoint2Id(secondPointId);
|
||||
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||
visual->SetAngle(angle);
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolNormal::GetSecondPointId() const
|
||||
{
|
||||
|
@ -323,24 +330,12 @@ void VToolNormal::ShowVisualization(bool show)
|
|||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
VisToolNormal * visual = new VisToolNormal(getData());
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
||||
scene->addItem(visual);
|
||||
|
||||
visual->setPoint1Id(basePointId);
|
||||
visual->setPoint2Id(secondPointId);
|
||||
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||
visual->SetAngle(angle);
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
vis = visual;
|
||||
AddVisualization<VisToolNormal>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
VisToolNormal *visual = qobject_cast<VisToolNormal *>(vis);
|
||||
if (visual != nullptr)
|
||||
if (VisToolNormal *visual = qobject_cast<VisToolNormal *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ protected:
|
|||
virtual void SaveDialog(QDomElement &domElement);
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement);
|
||||
virtual void SetVisualization();
|
||||
private:
|
||||
/** @brief secondPointId id second line point. */
|
||||
quint32 secondPointId;
|
||||
|
|
|
@ -248,16 +248,7 @@ void VToolPointOfContact::FullUpdateFromFile()
|
|||
{
|
||||
ReadAttributes();
|
||||
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
|
||||
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolPointOfContact *visual = qobject_cast<VisToolPointOfContact *>(vis);
|
||||
visual->setPoint1Id(firstPointId);
|
||||
visual->setLineP2Id(secondPointId);
|
||||
visual->setRadiusId(center);
|
||||
visual->setRadius(qApp->FormulaToUser(arcRadius));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
SetVisualization();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -335,6 +326,22 @@ void VToolPointOfContact::ReadToolAttributes(const QDomElement &domElement)
|
|||
secondPointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfContact::SetVisualization()
|
||||
{
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolPointOfContact *visual = qobject_cast<VisToolPointOfContact *>(vis);
|
||||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->setPoint1Id(firstPointId);
|
||||
visual->setLineP2Id(secondPointId);
|
||||
visual->setRadiusId(center);
|
||||
visual->setRadius(qApp->FormulaToUser(arcRadius));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolPointOfContact::GetSecondPointId() const
|
||||
{
|
||||
|
@ -354,23 +361,12 @@ void VToolPointOfContact::ShowVisualization(bool show)
|
|||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
VisToolPointOfContact * visual = new VisToolPointOfContact(getData());
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
||||
scene->addItem(visual);
|
||||
|
||||
visual->setPoint1Id(firstPointId);
|
||||
visual->setLineP2Id(secondPointId);
|
||||
visual->setRadiusId(center);
|
||||
visual->setRadius(qApp->FormulaToUser(arcRadius));
|
||||
visual->RefreshGeometry();
|
||||
vis = visual;
|
||||
AddVisualization<VisToolPointOfContact>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
VisToolPointOfContact *visual = qobject_cast<VisToolPointOfContact *>(vis);
|
||||
if (visual != nullptr)
|
||||
if (VisToolPointOfContact *visual = qobject_cast<VisToolPointOfContact *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ protected:
|
|||
virtual void SaveDialog(QDomElement &domElement);
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement);
|
||||
virtual void SetVisualization();
|
||||
private:
|
||||
/** @brief radius string with formula radius arc. */
|
||||
QString arcRadius;
|
||||
|
|
|
@ -167,14 +167,7 @@ void VToolPointOfIntersection::FullUpdateFromFile()
|
|||
{
|
||||
ReadAttributes();
|
||||
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id));
|
||||
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolPointOfIntersection *visual = qobject_cast<VisToolPointOfIntersection *>(vis);
|
||||
visual->setPoint1Id(firstPointId);
|
||||
visual->setPoint2Id(secondPointId);
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
SetVisualization();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -234,6 +227,20 @@ void VToolPointOfIntersection::ReadToolAttributes(const QDomElement &domElement)
|
|||
secondPointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolPointOfIntersection::SetVisualization()
|
||||
{
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolPointOfIntersection *visual = qobject_cast<VisToolPointOfIntersection *>(vis);
|
||||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->setPoint1Id(firstPointId);
|
||||
visual->setPoint2Id(secondPointId);
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolPointOfIntersection::GetSecondPointId() const
|
||||
{
|
||||
|
@ -259,21 +266,12 @@ void VToolPointOfIntersection::ShowVisualization(bool show)
|
|||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
VisToolPointOfIntersection * visual = new VisToolPointOfIntersection(getData());
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
||||
scene->addItem(visual);
|
||||
|
||||
visual->setPoint1Id(firstPointId);
|
||||
visual->setPoint2Id(secondPointId);
|
||||
visual->RefreshGeometry();
|
||||
vis = visual;
|
||||
AddVisualization<VisToolPointOfIntersection>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
VisToolPointOfIntersection *visual = qobject_cast<VisToolPointOfIntersection *>(vis);
|
||||
if (visual != nullptr)
|
||||
if (VisToolPointOfIntersection *visual = qobject_cast<VisToolPointOfIntersection *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ protected:
|
|||
virtual void SaveDialog(QDomElement &domElement);
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement);
|
||||
virtual void SetVisualization();
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolPointOfIntersection)
|
||||
/** @brief firstPointId id first line point. */
|
||||
|
|
|
@ -231,17 +231,7 @@ void VToolShoulderPoint::FullUpdateFromFile()
|
|||
{
|
||||
ReadAttributes();
|
||||
RefreshGeometry();
|
||||
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolShoulderPoint *visual = qobject_cast<VisToolShoulderPoint *>(vis);
|
||||
visual->setPoint1Id(pShoulder);
|
||||
visual->setLineP1Id(basePointId);
|
||||
visual->setLineP2Id(p2Line);
|
||||
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
SetVisualization();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -325,6 +315,23 @@ void VToolShoulderPoint::ReadToolAttributes(const QDomElement &domElement)
|
|||
pShoulder = doc->GetParametrUInt(domElement, AttrPShoulder, NULL_ID_STR);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolShoulderPoint::SetVisualization()
|
||||
{
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolShoulderPoint *visual = qobject_cast<VisToolShoulderPoint *>(vis);
|
||||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->setPoint1Id(pShoulder);
|
||||
visual->setLineP1Id(basePointId);
|
||||
visual->setLineP2Id(p2Line);
|
||||
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// cppcheck-suppress unusedFunction
|
||||
quint32 VToolShoulderPoint::getPShoulder() const
|
||||
|
@ -352,24 +359,12 @@ void VToolShoulderPoint::ShowVisualization(bool show)
|
|||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
VisToolShoulderPoint * visual = new VisToolShoulderPoint(getData());
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
||||
scene->addItem(visual);
|
||||
|
||||
visual->setPoint1Id(pShoulder);
|
||||
visual->setLineP1Id(basePointId);
|
||||
visual->setLineP2Id(p2Line);
|
||||
visual->setLength(qApp->FormulaToUser(formulaLength));
|
||||
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
|
||||
visual->RefreshGeometry();
|
||||
vis = visual;
|
||||
AddVisualization<VisToolShoulderPoint>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
VisToolShoulderPoint *visual = qobject_cast<VisToolShoulderPoint *>(vis);
|
||||
if (visual != nullptr)
|
||||
if (VisToolShoulderPoint *visual = qobject_cast<VisToolShoulderPoint *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ protected:
|
|||
virtual void SaveDialog(QDomElement &domElement);
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement);
|
||||
virtual void SetVisualization();
|
||||
private:
|
||||
/** @brief p2Line id second line point. */
|
||||
quint32 p2Line;
|
||||
|
|
|
@ -69,6 +69,7 @@ protected:
|
|||
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement);
|
||||
virtual void SetVisualization() {}
|
||||
private:
|
||||
QString namePP;
|
||||
QString mPath;
|
||||
|
|
|
@ -236,26 +236,12 @@ void VToolSpline::ShowVisualization(bool show)
|
|||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
VisToolSpline *visual = new VisToolSpline(getData(), this);
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
||||
|
||||
const QSharedPointer<VSpline> spl = VAbstractTool::data.GeometricObject<VSpline>(id);
|
||||
visual->setPoint1Id(spl->GetP1().id());
|
||||
visual->setPoint4Id(spl->GetP4().id());
|
||||
visual->SetAngle1(spl->GetAngle1());
|
||||
visual->SetAngle2(spl->GetAngle2());
|
||||
visual->SetKAsm1(spl->GetKasm1());
|
||||
visual->SetKAsm2(spl->GetKasm2());
|
||||
visual->SetKCurve(spl->GetKcurve());
|
||||
visual->RefreshGeometry();
|
||||
vis = visual;
|
||||
AddVisualization<VisToolSpline>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
VisToolSpline *visual = qobject_cast<VisToolSpline *>(vis);
|
||||
if (visual != nullptr)
|
||||
if (VisToolSpline *visual = qobject_cast<VisToolSpline *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
|
@ -490,6 +476,26 @@ void VToolSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
VAbstractSpline::hoverLeaveEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolSpline::SetVisualization()
|
||||
{
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolSpline *visual = qobject_cast<VisToolSpline *>(vis);
|
||||
SCASSERT(visual != nullptr);
|
||||
|
||||
const QSharedPointer<VSpline> spl = VAbstractTool::data.GeometricObject<VSpline>(id);
|
||||
visual->setPoint1Id(spl->GetP1().id());
|
||||
visual->setPoint4Id(spl->GetP4().id());
|
||||
visual->SetAngle1(spl->GetAngle1());
|
||||
visual->SetAngle2(spl->GetAngle2());
|
||||
visual->SetKAsm1(spl->GetKasm1());
|
||||
visual->SetKAsm2(spl->GetKasm2());
|
||||
visual->SetKCurve(spl->GetKcurve());
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief RefreshGeometry refresh item on scene.
|
||||
|
@ -523,16 +529,5 @@ void VToolSpline::RefreshGeometry()
|
|||
controlPoints[0]->blockSignals(false);
|
||||
controlPoints[1]->blockSignals(false);
|
||||
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolSpline *visual = qobject_cast<VisToolSpline *>(vis);
|
||||
visual->setPoint1Id(spl->GetP1().id());
|
||||
visual->setPoint4Id(spl->GetP4().id());
|
||||
visual->SetAngle1(spl->GetAngle1());
|
||||
visual->SetAngle2(spl->GetAngle2());
|
||||
visual->SetKAsm1(spl->GetKasm1());
|
||||
visual->SetKAsm2(spl->GetKasm2());
|
||||
visual->SetKCurve(spl->GetKcurve());
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
SetVisualization();
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ protected:
|
|||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event);
|
||||
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
|
||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
||||
virtual void SetVisualization();
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolSpline)
|
||||
void RefreshGeometry ();
|
||||
|
|
|
@ -317,21 +317,12 @@ void VToolSplinePath::ShowVisualization(bool show)
|
|||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
VisToolSplinePath *visual = new VisToolSplinePath(getData(), this);
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
||||
|
||||
QSharedPointer<VSplinePath> splPath = VAbstractTool::data.GeometricObject<VSplinePath>(id);
|
||||
visual->setPath(*splPath.data());
|
||||
visual->setMode(Mode::Show);
|
||||
visual->RefreshGeometry();
|
||||
vis = visual;
|
||||
AddVisualization<VisToolSplinePath>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
VisToolSplinePath *visual = qobject_cast<VisToolSplinePath *>(vis);
|
||||
if (visual != nullptr)
|
||||
if (VisToolSplinePath *visual = qobject_cast<VisToolSplinePath *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
|
@ -563,6 +554,21 @@ void VToolSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
|||
VAbstractSpline::hoverLeaveEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolSplinePath::SetVisualization()
|
||||
{
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolSplinePath *visual = qobject_cast<VisToolSplinePath *>(vis);
|
||||
SCASSERT(visual != nullptr);
|
||||
|
||||
QSharedPointer<VSplinePath> splPath = VAbstractTool::data.GeometricObject<VSplinePath>(id);
|
||||
visual->setPath(*splPath.data());
|
||||
visual->setMode(Mode::Show);
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief RefreshGeometry refresh item on scene.
|
||||
|
@ -601,12 +607,5 @@ void VToolSplinePath::RefreshGeometry()
|
|||
controlPoints[j-1]->blockSignals(false);
|
||||
}
|
||||
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolSplinePath *visual = qobject_cast<VisToolSplinePath *>(vis);
|
||||
QSharedPointer<VSplinePath> splPath = VAbstractTool::data.GeometricObject<VSplinePath>(id);
|
||||
visual->setPath(*splPath.data());
|
||||
visual->setMode(Mode::Show);
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
SetVisualization();
|
||||
}
|
||||
|
|
|
@ -86,6 +86,7 @@ protected:
|
|||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event);
|
||||
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
|
||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
||||
virtual void SetVisualization();
|
||||
private:
|
||||
QPointF oldPosition;
|
||||
|
||||
|
|
|
@ -222,16 +222,7 @@ void VToolTriangle::FullUpdateFromFile()
|
|||
{
|
||||
ReadAttributes();
|
||||
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id));
|
||||
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolTriangle * visual = qobject_cast<VisToolTriangle *>(vis);
|
||||
visual->setPoint1Id(axisP1Id);
|
||||
visual->setPoint2Id(axisP2Id);
|
||||
visual->setHypotenuseP1Id(firstPointId);
|
||||
visual->setHypotenuseP2Id(secondPointId);
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
SetVisualization();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -299,6 +290,22 @@ void VToolTriangle::ReadToolAttributes(const QDomElement &domElement)
|
|||
secondPointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolTriangle::SetVisualization()
|
||||
{
|
||||
if (vis != nullptr)
|
||||
{
|
||||
VisToolTriangle * visual = qobject_cast<VisToolTriangle *>(vis);
|
||||
SCASSERT(visual != nullptr);
|
||||
|
||||
visual->setPoint1Id(axisP1Id);
|
||||
visual->setPoint2Id(axisP2Id);
|
||||
visual->setHypotenuseP1Id(firstPointId);
|
||||
visual->setHypotenuseP2Id(secondPointId);
|
||||
visual->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VToolTriangle::GetSecondPointId() const
|
||||
{
|
||||
|
@ -324,23 +331,12 @@ void VToolTriangle::ShowVisualization(bool show)
|
|||
{
|
||||
if (vis == nullptr)
|
||||
{
|
||||
VisToolTriangle * visual = new VisToolTriangle(getData());
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
||||
scene->addItem(visual);
|
||||
|
||||
visual->setPoint1Id(axisP1Id);
|
||||
visual->setPoint2Id(axisP2Id);
|
||||
visual->setHypotenuseP1Id(firstPointId);
|
||||
visual->setHypotenuseP2Id(secondPointId);
|
||||
visual->RefreshGeometry();
|
||||
vis = visual;
|
||||
AddVisualization<VisToolTriangle>();
|
||||
SetVisualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
VisToolTriangle * visual = qobject_cast<VisToolTriangle *>(vis);
|
||||
if (visual != nullptr)
|
||||
if (VisToolTriangle * visual = qobject_cast<VisToolTriangle *>(vis))
|
||||
{
|
||||
visual->show();
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@ protected:
|
|||
virtual void SaveDialog(QDomElement &domElement);
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement);
|
||||
virtual void SetVisualization();
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolTriangle)
|
||||
/** @brief axisP1Id id first axis point. */
|
||||
|
|
|
@ -63,6 +63,7 @@ protected:
|
|||
virtual void RemoveReferens();
|
||||
virtual void RestoreReferens();
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void SetVisualization() {}
|
||||
};
|
||||
|
||||
#endif // VABSTRACTNODE_H
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
|
||||
#include "vdatatool.h"
|
||||
#include "../xml/vpattern.h"
|
||||
#include "../core/vapplication.h"
|
||||
#include "../widgets/vmaingraphicsscene.h"
|
||||
#include "../visualization/visualization.h"
|
||||
|
||||
class QDomElement;
|
||||
class QLineF;
|
||||
|
@ -166,6 +169,20 @@ protected:
|
|||
static int ConfirmDeletion();
|
||||
void SaveOption(QSharedPointer<VGObject> &obj);
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)=0;
|
||||
|
||||
template <typename T>
|
||||
void AddVisualization()
|
||||
{
|
||||
T *visual = new T(getData());
|
||||
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
||||
SCASSERT(scene != nullptr)
|
||||
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
|
||||
scene->addItem(visual);
|
||||
|
||||
vis = visual;
|
||||
}
|
||||
|
||||
virtual void SetVisualization()=0;
|
||||
private:
|
||||
Q_DISABLE_COPY(VAbstractTool)
|
||||
};
|
||||
|
|
|
@ -99,6 +99,7 @@ protected:
|
|||
virtual void RemoveReferens();
|
||||
virtual void keyReleaseEvent(QKeyEvent * event);
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void SetVisualization() {}
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolDetail)
|
||||
/** @brief dialog dialog options. */
|
||||
|
|
|
@ -87,6 +87,7 @@ protected:
|
|||
virtual void AddToFile();
|
||||
virtual void RefreshDataInFile();
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
|
||||
virtual void SetVisualization() {}
|
||||
private:
|
||||
Q_DISABLE_COPY(VToolUnionDetails)
|
||||
/** @brief d1 first detail. */
|
||||
|
|
Loading…
Reference in New Issue
Block a user