From 881c203a8c711480f1d387223d94e01cb5eba870 Mon Sep 17 00:00:00 2001 From: dismine Date: Wed, 25 Jun 2014 17:14:02 +0300 Subject: [PATCH] Refactoring. --HG-- branch : develop --- src/app/tools/drawTools/vtoolcutspline.cpp | 20 +++++++++---------- src/app/tools/drawTools/vtoolcutspline.h | 8 ++++---- .../tools/drawTools/vtoolcutsplinepath.cpp | 20 +++++++++---------- src/app/tools/drawTools/vtoolcutsplinepath.h | 8 ++++---- .../{vsimplespline.cpp => vsimplecurve.cpp} | 14 ++++++------- .../{vsimplespline.h => vsimplecurve.h} | 16 +++++++-------- src/app/widgets/widgets.pri | 8 ++++---- 7 files changed, 47 insertions(+), 47 deletions(-) rename src/app/widgets/{vsimplespline.cpp => vsimplecurve.cpp} (89%) rename src/app/widgets/{vsimplespline.h => vsimplecurve.h} (84%) diff --git a/src/app/tools/drawTools/vtoolcutspline.cpp b/src/app/tools/drawTools/vtoolcutspline.cpp index c62d88bcc..abb7ffdc7 100644 --- a/src/app/tools/drawTools/vtoolcutspline.cpp +++ b/src/app/tools/drawTools/vtoolcutspline.cpp @@ -57,15 +57,15 @@ VToolCutSpline::VToolCutSpline(VPattern *doc, VContainer *data, const quint32 &i Q_ASSERT_X(spl1id > 0, Q_FUNC_INFO, "spl1id <= 0"); Q_ASSERT_X(spl2id > 0, Q_FUNC_INFO, "spl2id <= 0"); - firstSpline = new VSimpleSpline(spl1id, ¤tColor, &factor); - RefreshSpline(firstSpline, spl1id, SimpleSplinePoint::ForthPoint); + firstSpline = new VSimpleCurve(spl1id, ¤tColor, &factor); + RefreshSpline(firstSpline, spl1id, SimpleCurvePoint::ForthPoint); firstSpline->setParentItem(this); - connect(firstSpline, &VSimpleSpline::Choosed, this, &VToolCutSpline::SplineChoosed); + connect(firstSpline, &VSimpleCurve::Choosed, this, &VToolCutSpline::SplineChoosed); - secondSpline = new VSimpleSpline(spl2id, ¤tColor, &factor); - RefreshSpline(secondSpline, spl2id, SimpleSplinePoint::FirstPoint); + secondSpline = new VSimpleCurve(spl2id, ¤tColor, &factor); + RefreshSpline(secondSpline, spl2id, SimpleCurvePoint::FirstPoint); secondSpline->setParentItem(this); - connect(secondSpline, &VSimpleSpline::Choosed, this, &VToolCutSpline::SplineChoosed); + connect(secondSpline, &VSimpleCurve::Choosed, this, &VToolCutSpline::SplineChoosed); if (typeCreation == Source::FromGui) { @@ -303,8 +303,8 @@ void VToolCutSpline::RefreshDataInFile() */ void VToolCutSpline::RefreshGeometry() { - RefreshSpline(firstSpline, spl1id, SimpleSplinePoint::ForthPoint); - RefreshSpline(secondSpline, spl2id, SimpleSplinePoint::FirstPoint); + RefreshSpline(firstSpline, spl1id, SimpleCurvePoint::ForthPoint); + RefreshSpline(secondSpline, spl2id, SimpleCurvePoint::FirstPoint); VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); } @@ -338,13 +338,13 @@ void VToolCutSpline::SaveDialog(QDomElement &domElement) * @param splid spline id. * @param tr spline type. */ -void VToolCutSpline::RefreshSpline(VSimpleSpline *spline, quint32 splid, SimpleSplinePoint tr) +void VToolCutSpline::RefreshSpline(VSimpleCurve *spline, quint32 splid, SimpleCurvePoint tr) { const VSpline *spl = VAbstractTool::data.GeometricObject(splid); QPainterPath path; path.addPath(spl->GetPath()); path.setFillRule( Qt::WindingFill ); - if (tr == SimpleSplinePoint::FirstPoint) + if (tr == SimpleCurvePoint::FirstPoint) { path.translate(-spl->GetP1().toQPointF().x(), -spl->GetP1().toQPointF().y()); } diff --git a/src/app/tools/drawTools/vtoolcutspline.h b/src/app/tools/drawTools/vtoolcutspline.h index 350ed6a35..019ae6e21 100644 --- a/src/app/tools/drawTools/vtoolcutspline.h +++ b/src/app/tools/drawTools/vtoolcutspline.h @@ -30,7 +30,7 @@ #define VTOOLCUTSPLINE_H #include "vtoolpoint.h" -#include "../../widgets/vsimplespline.h" +#include "../../widgets/vsimplecurve.h" /** * @brief The VToolCutSpline class for tool CutSpline. This tool find point on spline and cut spline on two. @@ -72,10 +72,10 @@ private: quint32 splineId; /** @brief firstSpline first spline after cutting. */ - VSimpleSpline *firstSpline; + VSimpleCurve *firstSpline; /** @brief secondSpline second spline after cutting. */ - VSimpleSpline *secondSpline; + VSimpleCurve *secondSpline; /** @brief spl1id id first spline after cutting. */ const quint32 spl1id; @@ -83,7 +83,7 @@ private: /** @brief spl2id id second spline after cutting. */ const quint32 spl2id; - void RefreshSpline(VSimpleSpline *spline, quint32 splid, SimpleSplinePoint tr); + void RefreshSpline(VSimpleCurve *spline, quint32 splid, SimpleCurvePoint tr); }; #endif // VTOOLCUTSPLINE_H diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.cpp b/src/app/tools/drawTools/vtoolcutsplinepath.cpp index 601c72d11..f47b0938f 100644 --- a/src/app/tools/drawTools/vtoolcutsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolcutsplinepath.cpp @@ -60,15 +60,15 @@ VToolCutSplinePath::VToolCutSplinePath(VPattern *doc, VContainer *data, const qu Q_ASSERT_X(splPath1id > 0, Q_FUNC_INFO, "spl1id <= 0"); Q_ASSERT_X(splPath2id > 0, Q_FUNC_INFO, "spl2id <= 0"); - firstSpline = new VSimpleSpline(splPath1id, ¤tColor, &factor); - RefreshSpline(firstSpline, splPath1id, SimpleSplinePoint::ForthPoint); + firstSpline = new VSimpleCurve(splPath1id, ¤tColor, &factor); + RefreshSpline(firstSpline, splPath1id, SimpleCurvePoint::ForthPoint); firstSpline->setParentItem(this); - connect(firstSpline, &VSimpleSpline::Choosed, this, &VToolCutSplinePath::SplineChoosed); + connect(firstSpline, &VSimpleCurve::Choosed, this, &VToolCutSplinePath::SplineChoosed); - secondSpline = new VSimpleSpline(splPath2id, ¤tColor, &factor); - RefreshSpline(secondSpline, splPath2id, SimpleSplinePoint::FirstPoint); + secondSpline = new VSimpleCurve(splPath2id, ¤tColor, &factor); + RefreshSpline(secondSpline, splPath2id, SimpleCurvePoint::FirstPoint); secondSpline->setParentItem(this); - connect(secondSpline, &VSimpleSpline::Choosed, this, &VToolCutSplinePath::SplineChoosed); + connect(secondSpline, &VSimpleCurve::Choosed, this, &VToolCutSplinePath::SplineChoosed); if (typeCreation == Source::FromGui) { @@ -358,8 +358,8 @@ void VToolCutSplinePath::RefreshDataInFile() */ void VToolCutSplinePath::RefreshGeometry() { - RefreshSpline(firstSpline, splPath1id, SimpleSplinePoint::ForthPoint); - RefreshSpline(secondSpline, splPath2id, SimpleSplinePoint::FirstPoint); + RefreshSpline(firstSpline, splPath1id, SimpleCurvePoint::ForthPoint); + RefreshSpline(secondSpline, splPath2id, SimpleCurvePoint::FirstPoint); VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); } @@ -393,13 +393,13 @@ void VToolCutSplinePath::SaveDialog(QDomElement &domElement) * @param splPathid splinePath id. * @param tr splineType type. */ -void VToolCutSplinePath::RefreshSpline(VSimpleSpline *spline, quint32 splPathid, SimpleSplinePoint tr) +void VToolCutSplinePath::RefreshSpline(VSimpleCurve *spline, quint32 splPathid, SimpleCurvePoint tr) { const VSplinePath *splPath = VAbstractTool::data.GeometricObject(splPathid); QPainterPath path; path.addPath(splPath->GetPath()); path.setFillRule( Qt::WindingFill ); - if (tr == SimpleSplinePoint::FirstPoint) + if (tr == SimpleCurvePoint::FirstPoint) { VSpline spl = splPath->GetSpline(1); path.translate(-spl.GetP1().toQPointF().x(), -spl.GetP1().toQPointF().y()); diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.h b/src/app/tools/drawTools/vtoolcutsplinepath.h index 72f1c17c5..daf8f1d90 100644 --- a/src/app/tools/drawTools/vtoolcutsplinepath.h +++ b/src/app/tools/drawTools/vtoolcutsplinepath.h @@ -30,7 +30,7 @@ #define VTOOLCUTSPLINEPATH_H #include "vtoolpoint.h" -#include "../../widgets/vsimplespline.h" +#include "../../widgets/vsimplecurve.h" /** * @brief The VToolCutSplinePath class for tool CutSplinePath. This tool find point on splinePath and cut splinePath on @@ -73,10 +73,10 @@ private: quint32 splinePathId; /** @brief firstSpline first splinePath after cutting. */ - VSimpleSpline *firstSpline; + VSimpleCurve *firstSpline; /** @brief secondSpline second splinePath after cutting. */ - VSimpleSpline *secondSpline; + VSimpleCurve *secondSpline; /** @brief splPath1id id first splinePath after cutting. */ const quint32 splPath1id; @@ -84,7 +84,7 @@ private: /** @brief splPath2id id second splinePath after cutting. */ const quint32 splPath2id; - void RefreshSpline(VSimpleSpline *spline, quint32 splPathid, SimpleSplinePoint tr); + void RefreshSpline(VSimpleCurve *spline, quint32 splPathid, SimpleCurvePoint tr); }; #endif // VTOOLCUTSPLINEPATH_H diff --git a/src/app/widgets/vsimplespline.cpp b/src/app/widgets/vsimplecurve.cpp similarity index 89% rename from src/app/widgets/vsimplespline.cpp rename to src/app/widgets/vsimplecurve.cpp index fec2cf76f..d7cebe5ba 100644 --- a/src/app/widgets/vsimplespline.cpp +++ b/src/app/widgets/vsimplecurve.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vsimplespline.cpp + ** @file vsimplecurve.cpp ** @author Roman Telezhynskyi ** @date 17 12, 2013 ** @@ -26,7 +26,7 @@ ** *************************************************************************/ -#include "vsimplespline.h" +#include "vsimplecurve.h" #include "../widgets/vapplication.h" #include #include @@ -39,7 +39,7 @@ * @param currentColor current color. * @param parent parent object. */ -VSimpleSpline::VSimpleSpline(quint32 id, Qt::GlobalColor *currentColor, qreal *factor, QObject *parent) +VSimpleCurve::VSimpleCurve(quint32 id, Qt::GlobalColor *currentColor, qreal *factor, QObject *parent) :QObject(parent), QGraphicsPathItem(), id (id), factor(factor), currentColor(currentColor) { if (factor == nullptr) @@ -55,7 +55,7 @@ VSimpleSpline::VSimpleSpline(quint32 id, Qt::GlobalColor *currentColor, qreal *f } //--------------------------------------------------------------------------------------------------------------------- -void VSimpleSpline::ChangedActivDraw(const bool &flag) +void VSimpleCurve::ChangedActivDraw(const bool &flag) { setFlag(QGraphicsItem::ItemIsSelectable, flag); setAcceptHoverEvents(flag); @@ -67,7 +67,7 @@ void VSimpleSpline::ChangedActivDraw(const bool &flag) * @brief mouseReleaseEvent handle mouse release events. * @param event mouse release event. */ -void VSimpleSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +void VSimpleCurve::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton) { @@ -81,7 +81,7 @@ void VSimpleSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) * @brief hoverMoveEvent handle hover move events. * @param event hover move event. */ -void VSimpleSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) +void VSimpleCurve::hoverMoveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); if (factor == nullptr) @@ -99,7 +99,7 @@ void VSimpleSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event) * @brief hoverLeaveEvent handle hover leave events. * @param event hover leave event. */ -void VSimpleSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +void VSimpleCurve::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); if (factor == nullptr) diff --git a/src/app/widgets/vsimplespline.h b/src/app/widgets/vsimplecurve.h similarity index 84% rename from src/app/widgets/vsimplespline.h rename to src/app/widgets/vsimplecurve.h index f66243336..2d1012fb0 100644 --- a/src/app/widgets/vsimplespline.h +++ b/src/app/widgets/vsimplecurve.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file vsimplespline.h + ** @file vsimplecurve.h ** @author Roman Telezhynskyi ** @date 17 12, 2013 ** @@ -26,21 +26,21 @@ ** *************************************************************************/ -#ifndef VSIMPLESPLINE_H -#define VSIMPLESPLINE_H +#ifndef VSIMPLECURVE_H +#define VSIMPLECURVE_H #include -enum class SimpleSplinePoint : char { FirstPoint, ForthPoint }; +enum class SimpleCurvePoint : char { FirstPoint, ForthPoint }; /** * @brief The VSimpleSpline class for simple spline. This object used when we cut spline and want show peaces. */ -class VSimpleSpline : public QObject, public QGraphicsPathItem +class VSimpleCurve : public QObject, public QGraphicsPathItem { Q_OBJECT public: - VSimpleSpline(quint32 id, Qt::GlobalColor *currentColor, qreal *factor = nullptr, QObject *parent = 0); + VSimpleCurve(quint32 id, Qt::GlobalColor *currentColor, qreal *factor = nullptr, QObject *parent = 0); void ChangedActivDraw(const bool &flag); signals: /** @@ -53,7 +53,7 @@ protected: virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); private: - Q_DISABLE_COPY(VSimpleSpline) + Q_DISABLE_COPY(VSimpleCurve) /** @brief id spline id. */ quint32 id; @@ -64,4 +64,4 @@ private: Qt::GlobalColor *currentColor; }; -#endif // VSIMPLESPLINE_H +#endif // VSIMPLECURVE_H diff --git a/src/app/widgets/widgets.pri b/src/app/widgets/widgets.pri index 9f65f5621..50d963761 100644 --- a/src/app/widgets/widgets.pri +++ b/src/app/widgets/widgets.pri @@ -7,12 +7,12 @@ HEADERS += \ widgets/vcontrolpointspline.h \ widgets/vapplication.h \ widgets/doubledelegate.h \ - widgets/vsimplespline.h \ widgets/vsimplesplinepath.h \ widgets/vsimplearc.h \ widgets/textdelegate.h \ widgets/vtranslation.h \ - widgets/undoevent.h + widgets/undoevent.h \ + widgets/vsimplecurve.h SOURCES += \ widgets/vtablegraphicsview.cpp \ @@ -23,9 +23,9 @@ SOURCES += \ widgets/vcontrolpointspline.cpp \ widgets/vapplication.cpp \ widgets/doubledelegate.cpp \ - widgets/vsimplespline.cpp \ widgets/vsimplesplinepath.cpp \ widgets/vsimplearc.cpp \ widgets/textdelegate.cpp \ widgets/vtranslation.cpp \ - widgets/undoevent.cpp + widgets/undoevent.cpp \ + widgets/vsimplecurve.cpp