diff --git a/src/app/geometry/geometry.pri b/src/app/geometry/geometry.pri index f26b6b320..d1ff3bd64 100644 --- a/src/app/geometry/geometry.pri +++ b/src/app/geometry/geometry.pri @@ -15,7 +15,8 @@ HEADERS += \ geometry/varc_p.h \ geometry/vspline_p.h \ geometry/vsplinepoint_p.h \ - geometry/vsplinepath_p.h + geometry/vsplinepath_p.h \ + geometry/vpointf_p.h SOURCES += \ geometry/vsplinepoint.cpp \ diff --git a/src/app/geometry/vpointf.cpp b/src/app/geometry/vpointf.cpp index 5140878ca..0a0088b46 100644 --- a/src/app/geometry/vpointf.cpp +++ b/src/app/geometry/vpointf.cpp @@ -27,9 +27,28 @@ *************************************************************************/ #include "vpointf.h" +#include "vpointf_p.h" #include #include +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VPointF creat empty point + */ +VPointF::VPointF() + :VGObject(GOType::Point, 0, Draw::Calculation), d(new VPointFData) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VPointF::VPointF(const VPointF &point) + :VGObject(point), d(point.d) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VPointF::VPointF(const QPointF &point) + :VGObject(VPointF()), d(new VPointFData(point)) +{} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief VPointF create new point @@ -40,7 +59,7 @@ * @param my offset name respect to y */ VPointF::VPointF(qreal x, qreal y, const QString &name, qreal mx, qreal my, quint32 idObject, const Draw &mode) - :VGObject(GOType::Point, idObject, mode), _mx(mx), _my(my), _x(x), _y(y) + :VGObject(GOType::Point, idObject, mode), d(new VPointFData(x, y, mx, my)) { setName(name); } @@ -54,28 +73,15 @@ VPointF::VPointF(qreal x, qreal y, const QString &name, qreal mx, qreal my, quin * @param my offset name respect to y */ VPointF::VPointF(const QPointF &point, const QString &name, qreal mx, qreal my, quint32 idObject, const Draw &mode) - :VGObject(GOType::Point, idObject, mode), _mx(mx), _my(my), _x(point.x()), _y(point.y()) + :VGObject(GOType::Point, idObject, mode), d(new VPointFData(point, mx, my)) { setName(name); } //--------------------------------------------------------------------------------------------------------------------- -/** - * @brief VPointF creat empty point - */ -VPointF::VPointF() :VGObject(GOType::Point, 0, Draw::Calculation), _mx(0), _my(0), _x(0), _y(0) +VPointF::~VPointF() {} -//--------------------------------------------------------------------------------------------------------------------- -VPointF::VPointF(const VPointF &point) :VGObject(point), _mx(point.mx()), _my(point.my()), _x(point.x()), _y(point.y()) -{} - -//--------------------------------------------------------------------------------------------------------------------- -VPointF::VPointF(const QPointF &point) :VGObject(VPointF()), _mx(0), _my(0), _x(point.x()), _y(point.y()) -{} - - - //--------------------------------------------------------------------------------------------------------------------- /** * @brief operator = assignment operator @@ -89,10 +95,7 @@ VPointF &VPointF::operator =(const VPointF &point) return *this; } VGObject::operator=(point); - _mx = point.mx(); - _my = point.my(); - _x = point.x(); - _y = point.y(); + d = point.d; return *this; } @@ -103,5 +106,85 @@ VPointF &VPointF::operator =(const VPointF &point) */ QPointF VPointF::toQPointF() const { - return QPointF(_x, _y); + return QPointF(d->_x, d->_y); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief mx return offset name respect to x + * @return offset + */ +qreal VPointF::mx() const +{ + return d->_mx; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief my return offset name respect to y + * @return offset + */ +qreal VPointF::my() const +{ + return d->_my; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setMx set offset name respect to x + * @param mx offset + */ +void VPointF::setMx(qreal mx) +{ + d->_mx = mx; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setMy set offset name respect to y + * @param my offset + */ +void VPointF::setMy(qreal my) +{ + d->_my = my; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief x return x coordinate + * @return value + */ +qreal VPointF::x() const +{ + return d->_x; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setX set x coordinate + * @param value x coordinate + */ +void VPointF::setX(const qreal &value) +{ + d->_x = value; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief y return y coordinate + * @return value + */ +qreal VPointF::y() const +{ + return d->_y; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setY set y coordinate + * @param value y coordinate + */ +void VPointF::setY(const qreal &value) +{ + d->_y = value; } diff --git a/src/app/geometry/vpointf.h b/src/app/geometry/vpointf.h index 56d92f7ec..78b437310 100644 --- a/src/app/geometry/vpointf.h +++ b/src/app/geometry/vpointf.h @@ -33,6 +33,7 @@ class QPointF; class QString; +class VPointFData; /** * @brief The VPointF class keep data of point. @@ -47,7 +48,7 @@ public: const Draw &mode = Draw::Calculation); VPointF (const QPointF &point, const QString &name, qreal mx, qreal my, quint32 idObject = 0, const Draw &mode = Draw::Calculation); - virtual ~VPointF(){} + virtual ~VPointF(); VPointF &operator=(const VPointF &point); qreal mx() const; qreal my() const; @@ -59,97 +60,7 @@ public: qreal y() const; void setY(const qreal &value); private: - /** @brief _mx offset name respect to x */ - qreal _mx; - - /** @brief _my offset name respect to y */ - qreal _my; - - /** @brief _x x coordinate */ - qreal _x; - - /** @brief _y y coordinate */ - qreal _y; + QSharedDataPointer d; }; -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief mx return offset name respect to x - * @return offset - */ -inline qreal VPointF::mx() const -{ - return _mx; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief my return offset name respect to y - * @return offset - */ -inline qreal VPointF::my() const -{ - return _my; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief setMx set offset name respect to x - * @param mx offset - */ -inline void VPointF::setMx(qreal mx) -{ - _mx = mx; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief setMy set offset name respect to y - * @param my offset - */ -inline void VPointF::setMy(qreal my) -{ - _my = my; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief x return x coordinate - * @return value - */ -inline qreal VPointF::x() const -{ - return _x; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief setX set x coordinate - * @param value x coordinate - */ -inline void VPointF::setX(const qreal &value) -{ - _x = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief y return y coordinate - * @return value - */ -inline qreal VPointF::y() const -{ - return _y; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief setY set y coordinate - * @param value y coordinate - */ -inline void VPointF::setY(const qreal &value) -{ - _y = value; -} - #endif // VPOINTF_H diff --git a/src/app/geometry/vpointf_p.h b/src/app/geometry/vpointf_p.h new file mode 100644 index 000000000..2dfe78301 --- /dev/null +++ b/src/app/geometry/vpointf_p.h @@ -0,0 +1,76 @@ +/************************************************************************ + ** + ** @file vpointf_p.h + ** @author Roman Telezhynskyi + ** @date 20 8, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef VPOINTF_P_H +#define VPOINTF_P_H + +#include +#include "../options.h" +#include + +class VPointFData : public QSharedData +{ +public: + + VPointFData() + : _mx(0), _my(0), _x(0), _y(0) + {} + + VPointFData(const VPointFData &point) + :QSharedData(point), _mx(point._mx), _my(point._my), _x(point._x), _y(point._y) + {} + + VPointFData(const QPointF &point) + :_mx(0), _my(0), _x(point.x()), _y(point.y()) + {} + + VPointFData(qreal x, qreal y, qreal mx, qreal my) + :_mx(mx), _my(my), _x(x), _y(y) + {} + + VPointFData(const QPointF &point, qreal mx, qreal my) + :_mx(mx), _my(my), _x(point.x()), _y(point.y()) + {} + + virtual ~VPointFData() {} + + /** @brief _mx offset name respect to x */ + qreal _mx; + + /** @brief _my offset name respect to y */ + qreal _my; + + /** @brief _x x coordinate */ + qreal _x; + + /** @brief _y y coordinate */ + qreal _y; +}; + + +#endif // VPOINTF_P_H