Refactoring.

--HG--
branch : develop
This commit is contained in:
dismine 2014-06-25 17:14:02 +03:00
parent bc87f5ffbe
commit 881c203a8c
7 changed files with 47 additions and 47 deletions

View File

@ -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, &currentColor, &factor);
RefreshSpline(firstSpline, spl1id, SimpleSplinePoint::ForthPoint);
firstSpline = new VSimpleCurve(spl1id, &currentColor, &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, &currentColor, &factor);
RefreshSpline(secondSpline, spl2id, SimpleSplinePoint::FirstPoint);
secondSpline = new VSimpleCurve(spl2id, &currentColor, &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<const VPointF *>(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<const VSpline *>(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());
}

View File

@ -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

View File

@ -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, &currentColor, &factor);
RefreshSpline(firstSpline, splPath1id, SimpleSplinePoint::ForthPoint);
firstSpline = new VSimpleCurve(splPath1id, &currentColor, &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, &currentColor, &factor);
RefreshSpline(secondSpline, splPath2id, SimpleSplinePoint::FirstPoint);
secondSpline = new VSimpleCurve(splPath2id, &currentColor, &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<const VPointF *>(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<const VSplinePath *>(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());

View File

@ -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

View File

@ -1,6 +1,6 @@
/************************************************************************
**
** @file vsimplespline.cpp
** @file vsimplecurve.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 17 12, 2013
**
@ -26,7 +26,7 @@
**
*************************************************************************/
#include "vsimplespline.h"
#include "vsimplecurve.h"
#include "../widgets/vapplication.h"
#include <QGraphicsSceneMouseEvent>
#include <QPen>
@ -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)

View File

@ -1,6 +1,6 @@
/************************************************************************
**
** @file vsimplespline.h
** @file vsimplecurve.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 17 12, 2013
**
@ -26,21 +26,21 @@
**
*************************************************************************/
#ifndef VSIMPLESPLINE_H
#define VSIMPLESPLINE_H
#ifndef VSIMPLECURVE_H
#define VSIMPLECURVE_H
#include <QGraphicsPathItem>
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

View File

@ -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