Refactoring tool classes.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-05-23 14:40:43 +03:00
parent bf60cfec3b
commit 10133a7a13
43 changed files with 412 additions and 425 deletions

View File

@ -73,16 +73,7 @@ void VToolAlongLine::FullUpdateFromFile()
{ {
ReadAttributes(); ReadAttributes();
RefreshGeometry(); RefreshGeometry();
SetVisualization();
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();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -163,6 +154,21 @@ void VToolAlongLine::ReadToolAttributes(const QDomElement &domElement)
secondPointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR); 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 quint32 VToolAlongLine::GetSecondPointId() const
{ {
@ -188,23 +194,12 @@ void VToolAlongLine::ShowVisualization(bool show)
{ {
if (vis == nullptr) if (vis == nullptr)
{ {
VisToolAlongLine *visual = new VisToolAlongLine(getData()); AddVisualization<VisToolAlongLine>();
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene()); SetVisualization();
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;
} }
else else
{ {
VisToolAlongLine * visual = qobject_cast<VisToolAlongLine *>(vis); if (VisToolAlongLine * visual = qobject_cast<VisToolAlongLine *>(vis))
if (visual != nullptr)
{ {
visual->show(); visual->show();
} }

View File

@ -65,6 +65,7 @@ protected:
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement); virtual void ReadToolAttributes(const QDomElement &domElement);
virtual void SetVisualization();
private: private:
/** @brief secondPointId id second point of line. */ /** @brief secondPointId id second point of line. */
quint32 secondPointId; quint32 secondPointId;

View File

@ -292,25 +292,12 @@ void VToolArc::ShowVisualization(bool show)
{ {
if (vis == nullptr) if (vis == nullptr)
{ {
VisToolArc * visual = new VisToolArc(getData()); AddVisualization<VisToolArc>();
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene()); SetVisualization();
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;
} }
else else
{ {
VisToolArc *visual = qobject_cast<VisToolArc *>(vis); if (VisToolArc *visual = qobject_cast<VisToolArc *>(vis))
if (visual != nullptr)
{ {
visual->show(); visual->show();
} }
@ -375,18 +362,13 @@ void VToolArc::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** void VToolArc::SetVisualization()
* @brief RefreshGeometry refresh item on scene.
*/
void VToolArc::RefreshGeometry()
{ {
this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor));
this->setPath(ToolPath());
if (vis != nullptr) if (vis != nullptr)
{ {
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id); const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
VisToolArc *visual = qobject_cast<VisToolArc *>(vis); VisToolArc *visual = qobject_cast<VisToolArc *>(vis);
SCASSERT(visual != nullptr)
visual->setPoint1Id(arc->GetCenter().id()); visual->setPoint1Id(arc->GetCenter().id());
visual->setRadius(qApp->FormulaToUser(arc->GetFormulaRadius())); visual->setRadius(qApp->FormulaToUser(arc->GetFormulaRadius()));
@ -395,3 +377,15 @@ void VToolArc::RefreshGeometry()
visual->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();
}

View File

@ -71,6 +71,7 @@ protected:
virtual void RemoveReferens(); virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void SetVisualization();
private: private:
void RefreshGeometry(); void RefreshGeometry();
}; };

View File

@ -321,6 +321,23 @@ void VToolBisector::ReadToolAttributes(const QDomElement &domElement)
thirdPointId = doc->GetParametrUInt(domElement, AttrThirdPoint, NULL_ID_STR); 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 quint32 VToolBisector::GetThirdPointId() const
{ {
@ -346,24 +363,12 @@ void VToolBisector::ShowVisualization(bool show)
{ {
if (vis == nullptr) if (vis == nullptr)
{ {
VisToolBisector * visual = new VisToolBisector(getData()); AddVisualization<VisToolBisector>();
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene()); SetVisualization();
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;
} }
else else
{ {
VisToolBisector *visual = qobject_cast<VisToolBisector *>(vis); if (VisToolBisector *visual = qobject_cast<VisToolBisector *>(vis))
if (visual != nullptr)
{ {
visual->show(); visual->show();
} }

View File

@ -72,6 +72,7 @@ protected:
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement); virtual void ReadToolAttributes(const QDomElement &domElement);
virtual void SetVisualization();
private: private:
/** @brief firstPointId id first point of angle. */ /** @brief firstPointId id first point of angle. */
quint32 firstPointId; quint32 firstPointId;

View File

@ -226,23 +226,12 @@ void VToolCurveIntersectAxis::ShowVisualization(bool show)
{ {
if (vis == nullptr) if (vis == nullptr)
{ {
VisToolCurveIntersectAxis * visual = new VisToolCurveIntersectAxis(getData()); AddVisualization<VisToolCurveIntersectAxis>();
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene()); SetVisualization();
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;
} }
else else
{ {
VisToolCurveIntersectAxis *visual = qobject_cast<VisToolCurveIntersectAxis *>(vis); if (VisToolCurveIntersectAxis *visual = qobject_cast<VisToolCurveIntersectAxis *>(vis))
if (visual != nullptr)
{ {
visual->show(); visual->show();
} }
@ -320,3 +309,19 @@ void VToolCurveIntersectAxis::ReadToolAttributes(const QDomElement &domElement)
curveId = doc->GetParametrUInt(domElement, AttrCurve, NULL_ID_STR); curveId = doc->GetParametrUInt(domElement, AttrCurve, NULL_ID_STR);
formulaAngle = doc->GetParametrString(domElement, AttrAngle, ""); 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();
}
}

View File

@ -69,6 +69,7 @@ protected:
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement); virtual void ReadToolAttributes(const QDomElement &domElement);
virtual void SetVisualization();
private: private:
Q_DISABLE_COPY(VToolCurveIntersectAxis) Q_DISABLE_COPY(VToolCurveIntersectAxis)
QString formulaAngle; QString formulaAngle;

View File

@ -191,21 +191,12 @@ void VToolCutArc::ShowVisualization(bool show)
{ {
if (vis == nullptr) if (vis == nullptr)
{ {
VisToolCutArc * visual = new VisToolCutArc(getData()); AddVisualization<VisToolCutArc>();
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene()); SetVisualization();
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;
} }
else else
{ {
VisToolCutArc *visual = qobject_cast<VisToolCutArc *>(vis); if (VisToolCutArc *visual = qobject_cast<VisToolCutArc *>(vis))
if (visual != nullptr)
{ {
visual->show(); visual->show();
} }
@ -226,14 +217,7 @@ void VToolCutArc::FullUpdateFromFile()
{ {
ReadAttributes(); ReadAttributes();
RefreshGeometry(); RefreshGeometry();
SetVisualization();
if (vis != nullptr)
{
VisToolCutArc *visual = qobject_cast<VisToolCutArc *>(vis);
visual->setPoint1Id(curveCutId);
visual->setLength(qApp->FormulaToUser(formula));
visual->RefreshGeometry();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -320,3 +304,17 @@ void VToolCutArc::ReadToolAttributes(const QDomElement &domElement)
curveCutId = doc->GetParametrUInt(domElement, AttrArc, NULL_ID_STR); curveCutId = doc->GetParametrUInt(domElement, AttrArc, NULL_ID_STR);
lineColor = doc->GetParametrString(domElement, AttrColor, ColorBlack); 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();
}
}

View File

@ -61,6 +61,7 @@ protected:
PathDirection direction = PathDirection::Hide); PathDirection direction = PathDirection::Hide);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement); virtual void ReadToolAttributes(const QDomElement &domElement);
virtual void SetVisualization();
private: private:
Q_DISABLE_COPY(VToolCutArc) Q_DISABLE_COPY(VToolCutArc)
}; };

View File

@ -201,21 +201,12 @@ void VToolCutSpline::ShowVisualization(bool show)
{ {
if (vis == nullptr) if (vis == nullptr)
{ {
VisToolCutSpline * visual = new VisToolCutSpline(getData()); AddVisualization<VisToolCutSpline>();
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene()); SetVisualization();
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;
} }
else else
{ {
VisToolCutSpline * visual = qobject_cast<VisToolCutSpline *>(vis); if (VisToolCutSpline * visual = qobject_cast<VisToolCutSpline *>(vis))
if (visual != nullptr)
{ {
visual->show(); visual->show();
} }
@ -247,14 +238,7 @@ void VToolCutSpline::FullUpdateFromFile()
{ {
ReadAttributes(); ReadAttributes();
RefreshGeometry(); RefreshGeometry();
SetVisualization();
if (vis != nullptr)
{
VisToolCutSpline *visual = qobject_cast<VisToolCutSpline *>(vis);
visual->setPoint1Id(curveCutId);
visual->setLength(qApp->FormulaToUser(formula));
visual->RefreshGeometry();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -341,3 +325,17 @@ void VToolCutSpline::ReadToolAttributes(const QDomElement &domElement)
curveCutId = doc->GetParametrUInt(domElement, AttrSpline, NULL_ID_STR); curveCutId = doc->GetParametrUInt(domElement, AttrSpline, NULL_ID_STR);
lineColor = doc->GetParametrString(domElement, AttrColor, ColorBlack); 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();
}
}

View File

@ -63,6 +63,7 @@ protected:
PathDirection direction = PathDirection::Hide); PathDirection direction = PathDirection::Hide);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement); virtual void ReadToolAttributes(const QDomElement &domElement);
virtual void SetVisualization();
private: private:
Q_DISABLE_COPY(VToolCutSpline) Q_DISABLE_COPY(VToolCutSpline)
}; };

View File

@ -245,21 +245,12 @@ void VToolCutSplinePath::ShowVisualization(bool show)
{ {
if (vis == nullptr) if (vis == nullptr)
{ {
VisToolCutSplinePath *visual = new VisToolCutSplinePath(getData()); AddVisualization<VisToolCutSplinePath>();
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene()); SetVisualization();
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;
} }
else else
{ {
VisToolCutSplinePath *visual = qobject_cast<VisToolCutSplinePath *>(vis); if (VisToolCutSplinePath *visual = qobject_cast<VisToolCutSplinePath *>(vis))
if (visual != nullptr)
{ {
visual->show(); visual->show();
} }
@ -291,14 +282,7 @@ void VToolCutSplinePath::FullUpdateFromFile()
{ {
ReadAttributes(); ReadAttributes();
RefreshGeometry(); RefreshGeometry();
SetVisualization();
if (vis != nullptr)
{
VisToolCutSplinePath *visual = qobject_cast<VisToolCutSplinePath *>(vis);
visual->setPoint1Id(curveCutId);
visual->setLength(qApp->FormulaToUser(formula));
visual->RefreshGeometry();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -387,3 +371,17 @@ void VToolCutSplinePath::ReadToolAttributes(const QDomElement &domElement)
curveCutId = doc->GetParametrUInt(domElement, AttrSplinePath, NULL_ID_STR); curveCutId = doc->GetParametrUInt(domElement, AttrSplinePath, NULL_ID_STR);
lineColor = doc->GetParametrString(domElement, AttrColor, ColorBlack); 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();
}
}

View File

@ -64,6 +64,7 @@ protected:
PathDirection direction = PathDirection::Hide); PathDirection direction = PathDirection::Hide);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement); virtual void ReadToolAttributes(const QDomElement &domElement);
virtual void SetVisualization();
private: private:
Q_DISABLE_COPY(VToolCutSplinePath) Q_DISABLE_COPY(VToolCutSplinePath)
}; };

View File

@ -189,16 +189,7 @@ void VToolEndLine::FullUpdateFromFile()
{ {
ReadAttributes(); ReadAttributes();
RefreshGeometry(); RefreshGeometry();
SetVisualization();
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();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -257,6 +248,22 @@ void VToolEndLine::ReadToolAttributes(const QDomElement &domElement)
formulaAngle = doc->GetParametrString(domElement, AttrAngle, ""); 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 VFormula VToolEndLine::GetFormulaAngle() const
{ {
@ -286,23 +293,12 @@ void VToolEndLine::ShowVisualization(bool show)
{ {
if (vis == nullptr) if (vis == nullptr)
{ {
VisToolEndLine * visual = new VisToolEndLine(getData()); AddVisualization<VisToolEndLine>();
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene()); SetVisualization();
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;
} }
else else
{ {
VisToolEndLine *visual = qobject_cast<VisToolEndLine *>(vis); if (VisToolEndLine *visual = qobject_cast<VisToolEndLine *>(vis))
if (visual != nullptr)
{ {
visual->show(); visual->show();
} }

View File

@ -64,6 +64,7 @@ protected:
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement); virtual void ReadToolAttributes(const QDomElement &domElement);
virtual void SetVisualization();
private: private:
QString formulaAngle; QString formulaAngle;
}; };

View File

@ -197,16 +197,7 @@ void VToolHeight::FullUpdateFromFile()
{ {
ReadAttributes(); ReadAttributes();
RefreshGeometry(); RefreshGeometry();
SetVisualization();
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();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -265,6 +256,22 @@ void VToolHeight::ReadToolAttributes(const QDomElement &domElement)
p2LineId = doc->GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR); 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 quint32 VToolHeight::GetP2LineId() const
{ {
@ -290,23 +297,12 @@ void VToolHeight::ShowVisualization(bool show)
{ {
if (vis == nullptr) if (vis == nullptr)
{ {
VisToolHeight * visual = new VisToolHeight(getData()); AddVisualization<VisToolHeight>();
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene()); SetVisualization();
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;
} }
else else
{ {
VisToolHeight *visual = qobject_cast<VisToolHeight *>(vis); if (VisToolHeight *visual = qobject_cast<VisToolHeight *>(vis))
if (visual != nullptr)
{ {
visual->show(); visual->show();
} }

View File

@ -67,6 +67,7 @@ protected:
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement); virtual void ReadToolAttributes(const QDomElement &domElement);
virtual void SetVisualization();
private: private:
/** @brief p1LineId id first point of line. */ /** @brief p1LineId id first point of line. */
quint32 p1LineId; quint32 p1LineId;

View File

@ -195,15 +195,7 @@ void VToolLine::FullUpdateFromFile()
{ {
ReadAttributes(); ReadAttributes();
RefreshGeometry(); RefreshGeometry();
SetVisualization();
if (vis != nullptr)
{
VisToolLine *visual = qobject_cast<VisToolLine *>(vis);
visual->setPoint1Id(firstPoint);
visual->setPoint2Id(secondPoint);
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -402,6 +394,21 @@ void VToolLine::ReadToolAttributes(const QDomElement &domElement)
lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack); 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 quint32 VToolLine::GetSecondPoint() const
{ {
@ -427,22 +434,12 @@ void VToolLine::ShowVisualization(bool show)
{ {
if (vis == nullptr) if (vis == nullptr)
{ {
VisToolLine * visual = new VisToolLine(getData()); AddVisualization<VisToolLine>();
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene()); SetVisualization();
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;
} }
else else
{ {
VisToolLine *visual = qobject_cast<VisToolLine *>(vis); if (VisToolLine *visual = qobject_cast<VisToolLine *>(vis))
if (visual != nullptr)
{ {
visual->show(); visual->show();
} }

View File

@ -80,6 +80,7 @@ protected:
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement); virtual void ReadToolAttributes(const QDomElement &domElement);
virtual void SetVisualization();
private: private:
/** @brief firstPoint id first line point. */ /** @brief firstPoint id first line point. */
quint32 firstPoint; quint32 firstPoint;

View File

@ -195,16 +195,7 @@ void VToolLineIntersect::FullUpdateFromFile()
{ {
ReadAttributes(); ReadAttributes();
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id)); RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
SetVisualization();
if (vis != nullptr)
{
VisToolLineIntersect *visual = qobject_cast<VisToolLineIntersect *>(vis);
visual->setPoint1Id(p1Line1);
visual->setLine1P2Id(p2Line1);
visual->setLine2P1Id(p1Line2);
visual->setLine2P2Id(p2Line2);
vis->RefreshGeometry();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -283,6 +274,22 @@ void VToolLineIntersect::ReadToolAttributes(const QDomElement &domElement)
p2Line2 = doc->GetParametrUInt(domElement, AttrP2Line2, NULL_ID_STR); 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 quint32 VToolLineIntersect::GetP2Line2() const
{ {
@ -308,23 +315,12 @@ void VToolLineIntersect::ShowVisualization(bool show)
{ {
if (vis == nullptr) if (vis == nullptr)
{ {
VisToolLineIntersect * visual = new VisToolLineIntersect(getData()); AddVisualization<VisToolLineIntersect>();
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene()); SetVisualization();
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;
} }
else else
{ {
VisToolLineIntersect *visual = qobject_cast<VisToolLineIntersect *>(vis); if (VisToolLineIntersect *visual = qobject_cast<VisToolLineIntersect *>(vis))
if (visual != nullptr)
{ {
visual->show(); visual->show();
} }

View File

@ -73,6 +73,7 @@ protected:
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement); virtual void ReadToolAttributes(const QDomElement &domElement);
virtual void SetVisualization();
private: private:
/** @brief p1Line1 id first point first line. */ /** @brief p1Line1 id first point first line. */
quint32 p1Line1; quint32 p1Line1;

View File

@ -238,24 +238,12 @@ void VToolLineIntersectAxis::ShowVisualization(bool show)
{ {
if (vis == nullptr) if (vis == nullptr)
{ {
VisToolLineIntersectAxis * visual = new VisToolLineIntersectAxis(getData()); AddVisualization<VisToolLineIntersectAxis>();
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene()); SetVisualization();
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;
} }
else else
{ {
VisToolLineIntersectAxis *visual = qobject_cast<VisToolLineIntersectAxis *>(vis); if (VisToolLineIntersectAxis *visual = qobject_cast<VisToolLineIntersectAxis *>(vis))
if (visual != nullptr)
{ {
visual->show(); visual->show();
} }
@ -273,17 +261,7 @@ void VToolLineIntersectAxis::FullUpdateFromFile()
{ {
ReadAttributes(); ReadAttributes();
RefreshGeometry(); RefreshGeometry();
SetVisualization();
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();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -337,3 +315,20 @@ void VToolLineIntersectAxis::ReadToolAttributes(const QDomElement &domElement)
secondPointId = doc->GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR); secondPointId = doc->GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR);
formulaAngle = doc->GetParametrString(domElement, AttrAngle, ""); 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();
}
}

View File

@ -73,6 +73,7 @@ protected:
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement); virtual void ReadToolAttributes(const QDomElement &domElement);
virtual void SetVisualization();
private: private:
Q_DISABLE_COPY(VToolLineIntersectAxis) Q_DISABLE_COPY(VToolLineIntersectAxis)
QString formulaAngle; QString formulaAngle;

View File

@ -205,17 +205,7 @@ void VToolNormal::FullUpdateFromFile()
{ {
ReadAttributes(); ReadAttributes();
RefreshGeometry(); RefreshGeometry();
SetVisualization();
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();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -298,6 +288,23 @@ void VToolNormal::ReadToolAttributes(const QDomElement &domElement)
angle = doc->GetParametrDouble(domElement, AttrAngle, "0"); 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 quint32 VToolNormal::GetSecondPointId() const
{ {
@ -323,24 +330,12 @@ void VToolNormal::ShowVisualization(bool show)
{ {
if (vis == nullptr) if (vis == nullptr)
{ {
VisToolNormal * visual = new VisToolNormal(getData()); AddVisualization<VisToolNormal>();
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene()); SetVisualization();
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;
} }
else else
{ {
VisToolNormal *visual = qobject_cast<VisToolNormal *>(vis); if (VisToolNormal *visual = qobject_cast<VisToolNormal *>(vis))
if (visual != nullptr)
{ {
visual->show(); visual->show();
} }

View File

@ -67,6 +67,7 @@ protected:
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement); virtual void ReadToolAttributes(const QDomElement &domElement);
virtual void SetVisualization();
private: private:
/** @brief secondPointId id second line point. */ /** @brief secondPointId id second line point. */
quint32 secondPointId; quint32 secondPointId;

View File

@ -248,16 +248,7 @@ void VToolPointOfContact::FullUpdateFromFile()
{ {
ReadAttributes(); ReadAttributes();
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id)); RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
SetVisualization();
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();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -335,6 +326,22 @@ void VToolPointOfContact::ReadToolAttributes(const QDomElement &domElement)
secondPointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR); 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 quint32 VToolPointOfContact::GetSecondPointId() const
{ {
@ -354,23 +361,12 @@ void VToolPointOfContact::ShowVisualization(bool show)
{ {
if (vis == nullptr) if (vis == nullptr)
{ {
VisToolPointOfContact * visual = new VisToolPointOfContact(getData()); AddVisualization<VisToolPointOfContact>();
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene()); SetVisualization();
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;
} }
else else
{ {
VisToolPointOfContact *visual = qobject_cast<VisToolPointOfContact *>(vis); if (VisToolPointOfContact *visual = qobject_cast<VisToolPointOfContact *>(vis))
if (visual != nullptr)
{ {
visual->show(); visual->show();
} }

View File

@ -78,6 +78,7 @@ protected:
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement); virtual void ReadToolAttributes(const QDomElement &domElement);
virtual void SetVisualization();
private: private:
/** @brief radius string with formula radius arc. */ /** @brief radius string with formula radius arc. */
QString arcRadius; QString arcRadius;

View File

@ -167,14 +167,7 @@ void VToolPointOfIntersection::FullUpdateFromFile()
{ {
ReadAttributes(); ReadAttributes();
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id)); VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id));
SetVisualization();
if (vis != nullptr)
{
VisToolPointOfIntersection *visual = qobject_cast<VisToolPointOfIntersection *>(vis);
visual->setPoint1Id(firstPointId);
visual->setPoint2Id(secondPointId);
visual->RefreshGeometry();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -234,6 +227,20 @@ void VToolPointOfIntersection::ReadToolAttributes(const QDomElement &domElement)
secondPointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR); 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 quint32 VToolPointOfIntersection::GetSecondPointId() const
{ {
@ -259,21 +266,12 @@ void VToolPointOfIntersection::ShowVisualization(bool show)
{ {
if (vis == nullptr) if (vis == nullptr)
{ {
VisToolPointOfIntersection * visual = new VisToolPointOfIntersection(getData()); AddVisualization<VisToolPointOfIntersection>();
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene()); SetVisualization();
SCASSERT(scene != nullptr)
connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor);
scene->addItem(visual);
visual->setPoint1Id(firstPointId);
visual->setPoint2Id(secondPointId);
visual->RefreshGeometry();
vis = visual;
} }
else else
{ {
VisToolPointOfIntersection *visual = qobject_cast<VisToolPointOfIntersection *>(vis); if (VisToolPointOfIntersection *visual = qobject_cast<VisToolPointOfIntersection *>(vis))
if (visual != nullptr)
{ {
visual->show(); visual->show();
} }

View File

@ -67,6 +67,7 @@ protected:
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement); virtual void ReadToolAttributes(const QDomElement &domElement);
virtual void SetVisualization();
private: private:
Q_DISABLE_COPY(VToolPointOfIntersection) Q_DISABLE_COPY(VToolPointOfIntersection)
/** @brief firstPointId id first line point. */ /** @brief firstPointId id first line point. */

View File

@ -231,17 +231,7 @@ void VToolShoulderPoint::FullUpdateFromFile()
{ {
ReadAttributes(); ReadAttributes();
RefreshGeometry(); RefreshGeometry();
SetVisualization();
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();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -325,6 +315,23 @@ void VToolShoulderPoint::ReadToolAttributes(const QDomElement &domElement)
pShoulder = doc->GetParametrUInt(domElement, AttrPShoulder, NULL_ID_STR); 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 // cppcheck-suppress unusedFunction
quint32 VToolShoulderPoint::getPShoulder() const quint32 VToolShoulderPoint::getPShoulder() const
@ -352,24 +359,12 @@ void VToolShoulderPoint::ShowVisualization(bool show)
{ {
if (vis == nullptr) if (vis == nullptr)
{ {
VisToolShoulderPoint * visual = new VisToolShoulderPoint(getData()); AddVisualization<VisToolShoulderPoint>();
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene()); SetVisualization();
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;
} }
else else
{ {
VisToolShoulderPoint *visual = qobject_cast<VisToolShoulderPoint *>(vis); if (VisToolShoulderPoint *visual = qobject_cast<VisToolShoulderPoint *>(vis))
if (visual != nullptr)
{ {
visual->show(); visual->show();
} }

View File

@ -71,6 +71,7 @@ protected:
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement); virtual void ReadToolAttributes(const QDomElement &domElement);
virtual void SetVisualization();
private: private:
/** @brief p2Line id second line point. */ /** @brief p2Line id second line point. */
quint32 p2Line; quint32 p2Line;

View File

@ -69,6 +69,7 @@ protected:
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement); virtual void ReadToolAttributes(const QDomElement &domElement);
virtual void SetVisualization() {}
private: private:
QString namePP; QString namePP;
QString mPath; QString mPath;

View File

@ -236,26 +236,12 @@ void VToolSpline::ShowVisualization(bool show)
{ {
if (vis == nullptr) if (vis == nullptr)
{ {
VisToolSpline *visual = new VisToolSpline(getData(), this); AddVisualization<VisToolSpline>();
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene()); SetVisualization();
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;
} }
else else
{ {
VisToolSpline *visual = qobject_cast<VisToolSpline *>(vis); if (VisToolSpline *visual = qobject_cast<VisToolSpline *>(vis))
if (visual != nullptr)
{ {
visual->show(); visual->show();
} }
@ -490,6 +476,26 @@ void VToolSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
VAbstractSpline::hoverLeaveEvent(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. * @brief RefreshGeometry refresh item on scene.
@ -523,16 +529,5 @@ void VToolSpline::RefreshGeometry()
controlPoints[0]->blockSignals(false); controlPoints[0]->blockSignals(false);
controlPoints[1]->blockSignals(false); controlPoints[1]->blockSignals(false);
if (vis != nullptr) SetVisualization();
{
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();
}
} }

View File

@ -69,6 +69,7 @@ protected:
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event);
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual void SetVisualization();
private: private:
Q_DISABLE_COPY(VToolSpline) Q_DISABLE_COPY(VToolSpline)
void RefreshGeometry (); void RefreshGeometry ();

View File

@ -317,21 +317,12 @@ void VToolSplinePath::ShowVisualization(bool show)
{ {
if (vis == nullptr) if (vis == nullptr)
{ {
VisToolSplinePath *visual = new VisToolSplinePath(getData(), this); AddVisualization<VisToolSplinePath>();
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene()); SetVisualization();
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;
} }
else else
{ {
VisToolSplinePath *visual = qobject_cast<VisToolSplinePath *>(vis); if (VisToolSplinePath *visual = qobject_cast<VisToolSplinePath *>(vis))
if (visual != nullptr)
{ {
visual->show(); visual->show();
} }
@ -563,6 +554,21 @@ void VToolSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
VAbstractSpline::hoverLeaveEvent(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. * @brief RefreshGeometry refresh item on scene.
@ -601,12 +607,5 @@ void VToolSplinePath::RefreshGeometry()
controlPoints[j-1]->blockSignals(false); controlPoints[j-1]->blockSignals(false);
} }
if (vis != nullptr) SetVisualization();
{
VisToolSplinePath *visual = qobject_cast<VisToolSplinePath *>(vis);
QSharedPointer<VSplinePath> splPath = VAbstractTool::data.GeometricObject<VSplinePath>(id);
visual->setPath(*splPath.data());
visual->setMode(Mode::Show);
visual->RefreshGeometry();
}
} }

View File

@ -86,6 +86,7 @@ protected:
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event);
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual void SetVisualization();
private: private:
QPointF oldPosition; QPointF oldPosition;

View File

@ -222,16 +222,7 @@ void VToolTriangle::FullUpdateFromFile()
{ {
ReadAttributes(); ReadAttributes();
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id)); VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id));
SetVisualization();
if (vis != nullptr)
{
VisToolTriangle * visual = qobject_cast<VisToolTriangle *>(vis);
visual->setPoint1Id(axisP1Id);
visual->setPoint2Id(axisP2Id);
visual->setHypotenuseP1Id(firstPointId);
visual->setHypotenuseP2Id(secondPointId);
visual->RefreshGeometry();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -299,6 +290,22 @@ void VToolTriangle::ReadToolAttributes(const QDomElement &domElement)
secondPointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR); 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 quint32 VToolTriangle::GetSecondPointId() const
{ {
@ -324,23 +331,12 @@ void VToolTriangle::ShowVisualization(bool show)
{ {
if (vis == nullptr) if (vis == nullptr)
{ {
VisToolTriangle * visual = new VisToolTriangle(getData()); AddVisualization<VisToolTriangle>();
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene()); SetVisualization();
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;
} }
else else
{ {
VisToolTriangle * visual = qobject_cast<VisToolTriangle *>(vis); if (VisToolTriangle * visual = qobject_cast<VisToolTriangle *>(vis))
if (visual != nullptr)
{ {
visual->show(); visual->show();
} }

View File

@ -75,6 +75,7 @@ protected:
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement); virtual void ReadToolAttributes(const QDomElement &domElement);
virtual void SetVisualization();
private: private:
Q_DISABLE_COPY(VToolTriangle) Q_DISABLE_COPY(VToolTriangle)
/** @brief axisP1Id id first axis point. */ /** @brief axisP1Id id first axis point. */

View File

@ -63,6 +63,7 @@ protected:
virtual void RemoveReferens(); virtual void RemoveReferens();
virtual void RestoreReferens(); virtual void RestoreReferens();
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void SetVisualization() {}
}; };
#endif // VABSTRACTNODE_H #endif // VABSTRACTNODE_H

View File

@ -31,6 +31,9 @@
#include "vdatatool.h" #include "vdatatool.h"
#include "../xml/vpattern.h" #include "../xml/vpattern.h"
#include "../core/vapplication.h"
#include "../widgets/vmaingraphicsscene.h"
#include "../visualization/visualization.h"
class QDomElement; class QDomElement;
class QLineF; class QLineF;
@ -166,6 +169,20 @@ protected:
static int ConfirmDeletion(); static int ConfirmDeletion();
void SaveOption(QSharedPointer<VGObject> &obj); void SaveOption(QSharedPointer<VGObject> &obj);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)=0; 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: private:
Q_DISABLE_COPY(VAbstractTool) Q_DISABLE_COPY(VAbstractTool)
}; };

View File

@ -99,6 +99,7 @@ protected:
virtual void RemoveReferens(); virtual void RemoveReferens();
virtual void keyReleaseEvent(QKeyEvent * event); virtual void keyReleaseEvent(QKeyEvent * event);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void SetVisualization() {}
private: private:
Q_DISABLE_COPY(VToolDetail) Q_DISABLE_COPY(VToolDetail)
/** @brief dialog dialog options. */ /** @brief dialog dialog options. */

View File

@ -87,6 +87,7 @@ protected:
virtual void AddToFile(); virtual void AddToFile();
virtual void RefreshDataInFile(); virtual void RefreshDataInFile();
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void SetVisualization() {}
private: private:
Q_DISABLE_COPY(VToolUnionDetails) Q_DISABLE_COPY(VToolUnionDetails)
/** @brief d1 first detail. */ /** @brief d1 first detail. */