Refactoring.
--HG-- branch : develop
This commit is contained in:
parent
bc87f5ffbe
commit
881c203a8c
|
@ -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(spl1id > 0, Q_FUNC_INFO, "spl1id <= 0");
|
||||||
Q_ASSERT_X(spl2id > 0, Q_FUNC_INFO, "spl2id <= 0");
|
Q_ASSERT_X(spl2id > 0, Q_FUNC_INFO, "spl2id <= 0");
|
||||||
|
|
||||||
firstSpline = new VSimpleSpline(spl1id, ¤tColor, &factor);
|
firstSpline = new VSimpleCurve(spl1id, ¤tColor, &factor);
|
||||||
RefreshSpline(firstSpline, spl1id, SimpleSplinePoint::ForthPoint);
|
RefreshSpline(firstSpline, spl1id, SimpleCurvePoint::ForthPoint);
|
||||||
firstSpline->setParentItem(this);
|
firstSpline->setParentItem(this);
|
||||||
connect(firstSpline, &VSimpleSpline::Choosed, this, &VToolCutSpline::SplineChoosed);
|
connect(firstSpline, &VSimpleCurve::Choosed, this, &VToolCutSpline::SplineChoosed);
|
||||||
|
|
||||||
secondSpline = new VSimpleSpline(spl2id, ¤tColor, &factor);
|
secondSpline = new VSimpleCurve(spl2id, ¤tColor, &factor);
|
||||||
RefreshSpline(secondSpline, spl2id, SimpleSplinePoint::FirstPoint);
|
RefreshSpline(secondSpline, spl2id, SimpleCurvePoint::FirstPoint);
|
||||||
secondSpline->setParentItem(this);
|
secondSpline->setParentItem(this);
|
||||||
connect(secondSpline, &VSimpleSpline::Choosed, this, &VToolCutSpline::SplineChoosed);
|
connect(secondSpline, &VSimpleCurve::Choosed, this, &VToolCutSpline::SplineChoosed);
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
|
@ -303,8 +303,8 @@ void VToolCutSpline::RefreshDataInFile()
|
||||||
*/
|
*/
|
||||||
void VToolCutSpline::RefreshGeometry()
|
void VToolCutSpline::RefreshGeometry()
|
||||||
{
|
{
|
||||||
RefreshSpline(firstSpline, spl1id, SimpleSplinePoint::ForthPoint);
|
RefreshSpline(firstSpline, spl1id, SimpleCurvePoint::ForthPoint);
|
||||||
RefreshSpline(secondSpline, spl2id, SimpleSplinePoint::FirstPoint);
|
RefreshSpline(secondSpline, spl2id, SimpleCurvePoint::FirstPoint);
|
||||||
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<const VPointF *>(id));
|
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<const VPointF *>(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,13 +338,13 @@ void VToolCutSpline::SaveDialog(QDomElement &domElement)
|
||||||
* @param splid spline id.
|
* @param splid spline id.
|
||||||
* @param tr spline type.
|
* @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);
|
const VSpline *spl = VAbstractTool::data.GeometricObject<const VSpline *>(splid);
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
path.addPath(spl->GetPath());
|
path.addPath(spl->GetPath());
|
||||||
path.setFillRule( Qt::WindingFill );
|
path.setFillRule( Qt::WindingFill );
|
||||||
if (tr == SimpleSplinePoint::FirstPoint)
|
if (tr == SimpleCurvePoint::FirstPoint)
|
||||||
{
|
{
|
||||||
path.translate(-spl->GetP1().toQPointF().x(), -spl->GetP1().toQPointF().y());
|
path.translate(-spl->GetP1().toQPointF().x(), -spl->GetP1().toQPointF().y());
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#define VTOOLCUTSPLINE_H
|
#define VTOOLCUTSPLINE_H
|
||||||
|
|
||||||
#include "vtoolpoint.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.
|
* @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;
|
quint32 splineId;
|
||||||
|
|
||||||
/** @brief firstSpline first spline after cutting. */
|
/** @brief firstSpline first spline after cutting. */
|
||||||
VSimpleSpline *firstSpline;
|
VSimpleCurve *firstSpline;
|
||||||
|
|
||||||
/** @brief secondSpline second spline after cutting. */
|
/** @brief secondSpline second spline after cutting. */
|
||||||
VSimpleSpline *secondSpline;
|
VSimpleCurve *secondSpline;
|
||||||
|
|
||||||
/** @brief spl1id id first spline after cutting. */
|
/** @brief spl1id id first spline after cutting. */
|
||||||
const quint32 spl1id;
|
const quint32 spl1id;
|
||||||
|
@ -83,7 +83,7 @@ private:
|
||||||
/** @brief spl2id id second spline after cutting. */
|
/** @brief spl2id id second spline after cutting. */
|
||||||
const quint32 spl2id;
|
const quint32 spl2id;
|
||||||
|
|
||||||
void RefreshSpline(VSimpleSpline *spline, quint32 splid, SimpleSplinePoint tr);
|
void RefreshSpline(VSimpleCurve *spline, quint32 splid, SimpleCurvePoint tr);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLCUTSPLINE_H
|
#endif // VTOOLCUTSPLINE_H
|
||||||
|
|
|
@ -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(splPath1id > 0, Q_FUNC_INFO, "spl1id <= 0");
|
||||||
Q_ASSERT_X(splPath2id > 0, Q_FUNC_INFO, "spl2id <= 0");
|
Q_ASSERT_X(splPath2id > 0, Q_FUNC_INFO, "spl2id <= 0");
|
||||||
|
|
||||||
firstSpline = new VSimpleSpline(splPath1id, ¤tColor, &factor);
|
firstSpline = new VSimpleCurve(splPath1id, ¤tColor, &factor);
|
||||||
RefreshSpline(firstSpline, splPath1id, SimpleSplinePoint::ForthPoint);
|
RefreshSpline(firstSpline, splPath1id, SimpleCurvePoint::ForthPoint);
|
||||||
firstSpline->setParentItem(this);
|
firstSpline->setParentItem(this);
|
||||||
connect(firstSpline, &VSimpleSpline::Choosed, this, &VToolCutSplinePath::SplineChoosed);
|
connect(firstSpline, &VSimpleCurve::Choosed, this, &VToolCutSplinePath::SplineChoosed);
|
||||||
|
|
||||||
secondSpline = new VSimpleSpline(splPath2id, ¤tColor, &factor);
|
secondSpline = new VSimpleCurve(splPath2id, ¤tColor, &factor);
|
||||||
RefreshSpline(secondSpline, splPath2id, SimpleSplinePoint::FirstPoint);
|
RefreshSpline(secondSpline, splPath2id, SimpleCurvePoint::FirstPoint);
|
||||||
secondSpline->setParentItem(this);
|
secondSpline->setParentItem(this);
|
||||||
connect(secondSpline, &VSimpleSpline::Choosed, this, &VToolCutSplinePath::SplineChoosed);
|
connect(secondSpline, &VSimpleCurve::Choosed, this, &VToolCutSplinePath::SplineChoosed);
|
||||||
|
|
||||||
if (typeCreation == Source::FromGui)
|
if (typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
|
@ -358,8 +358,8 @@ void VToolCutSplinePath::RefreshDataInFile()
|
||||||
*/
|
*/
|
||||||
void VToolCutSplinePath::RefreshGeometry()
|
void VToolCutSplinePath::RefreshGeometry()
|
||||||
{
|
{
|
||||||
RefreshSpline(firstSpline, splPath1id, SimpleSplinePoint::ForthPoint);
|
RefreshSpline(firstSpline, splPath1id, SimpleCurvePoint::ForthPoint);
|
||||||
RefreshSpline(secondSpline, splPath2id, SimpleSplinePoint::FirstPoint);
|
RefreshSpline(secondSpline, splPath2id, SimpleCurvePoint::FirstPoint);
|
||||||
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<const VPointF *>(id));
|
VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<const VPointF *>(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,13 +393,13 @@ void VToolCutSplinePath::SaveDialog(QDomElement &domElement)
|
||||||
* @param splPathid splinePath id.
|
* @param splPathid splinePath id.
|
||||||
* @param tr splineType type.
|
* @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);
|
const VSplinePath *splPath = VAbstractTool::data.GeometricObject<const VSplinePath *>(splPathid);
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
path.addPath(splPath->GetPath());
|
path.addPath(splPath->GetPath());
|
||||||
path.setFillRule( Qt::WindingFill );
|
path.setFillRule( Qt::WindingFill );
|
||||||
if (tr == SimpleSplinePoint::FirstPoint)
|
if (tr == SimpleCurvePoint::FirstPoint)
|
||||||
{
|
{
|
||||||
VSpline spl = splPath->GetSpline(1);
|
VSpline spl = splPath->GetSpline(1);
|
||||||
path.translate(-spl.GetP1().toQPointF().x(), -spl.GetP1().toQPointF().y());
|
path.translate(-spl.GetP1().toQPointF().x(), -spl.GetP1().toQPointF().y());
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#define VTOOLCUTSPLINEPATH_H
|
#define VTOOLCUTSPLINEPATH_H
|
||||||
|
|
||||||
#include "vtoolpoint.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
|
* @brief The VToolCutSplinePath class for tool CutSplinePath. This tool find point on splinePath and cut splinePath on
|
||||||
|
@ -73,10 +73,10 @@ private:
|
||||||
quint32 splinePathId;
|
quint32 splinePathId;
|
||||||
|
|
||||||
/** @brief firstSpline first splinePath after cutting. */
|
/** @brief firstSpline first splinePath after cutting. */
|
||||||
VSimpleSpline *firstSpline;
|
VSimpleCurve *firstSpline;
|
||||||
|
|
||||||
/** @brief secondSpline second splinePath after cutting. */
|
/** @brief secondSpline second splinePath after cutting. */
|
||||||
VSimpleSpline *secondSpline;
|
VSimpleCurve *secondSpline;
|
||||||
|
|
||||||
/** @brief splPath1id id first splinePath after cutting. */
|
/** @brief splPath1id id first splinePath after cutting. */
|
||||||
const quint32 splPath1id;
|
const quint32 splPath1id;
|
||||||
|
@ -84,7 +84,7 @@ private:
|
||||||
/** @brief splPath2id id second splinePath after cutting. */
|
/** @brief splPath2id id second splinePath after cutting. */
|
||||||
const quint32 splPath2id;
|
const quint32 splPath2id;
|
||||||
|
|
||||||
void RefreshSpline(VSimpleSpline *spline, quint32 splPathid, SimpleSplinePoint tr);
|
void RefreshSpline(VSimpleCurve *spline, quint32 splPathid, SimpleCurvePoint tr);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLCUTSPLINEPATH_H
|
#endif // VTOOLCUTSPLINEPATH_H
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vsimplespline.cpp
|
** @file vsimplecurve.cpp
|
||||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
** @date 17 12, 2013
|
** @date 17 12, 2013
|
||||||
**
|
**
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "vsimplespline.h"
|
#include "vsimplecurve.h"
|
||||||
#include "../widgets/vapplication.h"
|
#include "../widgets/vapplication.h"
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QPen>
|
#include <QPen>
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
* @param currentColor current color.
|
* @param currentColor current color.
|
||||||
* @param parent parent object.
|
* @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)
|
:QObject(parent), QGraphicsPathItem(), id (id), factor(factor), currentColor(currentColor)
|
||||||
{
|
{
|
||||||
if (factor == nullptr)
|
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);
|
setFlag(QGraphicsItem::ItemIsSelectable, flag);
|
||||||
setAcceptHoverEvents(flag);
|
setAcceptHoverEvents(flag);
|
||||||
|
@ -67,7 +67,7 @@ void VSimpleSpline::ChangedActivDraw(const bool &flag)
|
||||||
* @brief mouseReleaseEvent handle mouse release events.
|
* @brief mouseReleaseEvent handle mouse release events.
|
||||||
* @param event mouse release event.
|
* @param event mouse release event.
|
||||||
*/
|
*/
|
||||||
void VSimpleSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void VSimpleCurve::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton)
|
if (event->button() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
|
@ -81,7 +81,7 @@ void VSimpleSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
* @brief hoverMoveEvent handle hover move events.
|
* @brief hoverMoveEvent handle hover move events.
|
||||||
* @param event hover move event.
|
* @param event hover move event.
|
||||||
*/
|
*/
|
||||||
void VSimpleSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
void VSimpleCurve::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
if (factor == nullptr)
|
if (factor == nullptr)
|
||||||
|
@ -99,7 +99,7 @@ void VSimpleSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
* @brief hoverLeaveEvent handle hover leave events.
|
* @brief hoverLeaveEvent handle hover leave events.
|
||||||
* @param event hover leave event.
|
* @param event hover leave event.
|
||||||
*/
|
*/
|
||||||
void VSimpleSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
void VSimpleCurve::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
if (factor == nullptr)
|
if (factor == nullptr)
|
|
@ -1,6 +1,6 @@
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
**
|
**
|
||||||
** @file vsimplespline.h
|
** @file vsimplecurve.h
|
||||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
** @date 17 12, 2013
|
** @date 17 12, 2013
|
||||||
**
|
**
|
||||||
|
@ -26,21 +26,21 @@
|
||||||
**
|
**
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#ifndef VSIMPLESPLINE_H
|
#ifndef VSIMPLECURVE_H
|
||||||
#define VSIMPLESPLINE_H
|
#define VSIMPLECURVE_H
|
||||||
|
|
||||||
#include <QGraphicsPathItem>
|
#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.
|
* @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
|
Q_OBJECT
|
||||||
public:
|
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);
|
void ChangedActivDraw(const bool &flag);
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +53,7 @@ protected:
|
||||||
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
|
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
|
||||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VSimpleSpline)
|
Q_DISABLE_COPY(VSimpleCurve)
|
||||||
/** @brief id spline id. */
|
/** @brief id spline id. */
|
||||||
quint32 id;
|
quint32 id;
|
||||||
|
|
||||||
|
@ -64,4 +64,4 @@ private:
|
||||||
Qt::GlobalColor *currentColor;
|
Qt::GlobalColor *currentColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VSIMPLESPLINE_H
|
#endif // VSIMPLECURVE_H
|
|
@ -7,12 +7,12 @@ HEADERS += \
|
||||||
widgets/vcontrolpointspline.h \
|
widgets/vcontrolpointspline.h \
|
||||||
widgets/vapplication.h \
|
widgets/vapplication.h \
|
||||||
widgets/doubledelegate.h \
|
widgets/doubledelegate.h \
|
||||||
widgets/vsimplespline.h \
|
|
||||||
widgets/vsimplesplinepath.h \
|
widgets/vsimplesplinepath.h \
|
||||||
widgets/vsimplearc.h \
|
widgets/vsimplearc.h \
|
||||||
widgets/textdelegate.h \
|
widgets/textdelegate.h \
|
||||||
widgets/vtranslation.h \
|
widgets/vtranslation.h \
|
||||||
widgets/undoevent.h
|
widgets/undoevent.h \
|
||||||
|
widgets/vsimplecurve.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
widgets/vtablegraphicsview.cpp \
|
widgets/vtablegraphicsview.cpp \
|
||||||
|
@ -23,9 +23,9 @@ SOURCES += \
|
||||||
widgets/vcontrolpointspline.cpp \
|
widgets/vcontrolpointspline.cpp \
|
||||||
widgets/vapplication.cpp \
|
widgets/vapplication.cpp \
|
||||||
widgets/doubledelegate.cpp \
|
widgets/doubledelegate.cpp \
|
||||||
widgets/vsimplespline.cpp \
|
|
||||||
widgets/vsimplesplinepath.cpp \
|
widgets/vsimplesplinepath.cpp \
|
||||||
widgets/vsimplearc.cpp \
|
widgets/vsimplearc.cpp \
|
||||||
widgets/textdelegate.cpp \
|
widgets/textdelegate.cpp \
|
||||||
widgets/vtranslation.cpp \
|
widgets/vtranslation.cpp \
|
||||||
widgets/undoevent.cpp
|
widgets/undoevent.cpp \
|
||||||
|
widgets/vsimplecurve.cpp
|
||||||
|
|
Loading…
Reference in New Issue
Block a user