Refactoring. New parent VAbstractFloatItemData.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-02-23 13:26:12 +02:00
parent 1710e3cdb7
commit 3cfefbe698
7 changed files with 160 additions and 132 deletions

View File

@ -0,0 +1,63 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 23 2, 2017
**
** @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) 2017 Valentina project
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vabstractfloatitemdata.h"
//---------------------------------------------------------------------------------------------------------------------
VAbstractFloatItemData::VAbstractFloatItemData()
: m_ptPos(),
m_bVisible(false)
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractFloatItemData::~VAbstractFloatItemData()
{}
//---------------------------------------------------------------------------------------------------------------------
QPointF VAbstractFloatItemData::GetPos() const
{
return m_ptPos;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractFloatItemData::SetPos(const QPointF &ptPos)
{
m_ptPos = ptPos;
}
//---------------------------------------------------------------------------------------------------------------------
bool VAbstractFloatItemData::IsVisible() const
{
return m_bVisible;
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractFloatItemData::SetVisible(bool bVisible)
{
m_bVisible = bVisible;
}

View File

@ -0,0 +1,54 @@
/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 23 2, 2017
**
** @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) 2017 Valentina project
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VABSTRACTFLOATITEMDATA_H
#define VABSTRACTFLOATITEMDATA_H
#include <QPointF>
class VAbstractFloatItemData
{
public:
VAbstractFloatItemData();
virtual ~VAbstractFloatItemData();
// methods, which set and return values of different parameters
QPointF GetPos() const;
void SetPos(const QPointF& ptPos);
bool IsVisible() const;
void SetVisible(bool bVisible);
protected:
/** @brief m_ptPos position of label's top left corner */
QPointF m_ptPos;
/** @brief m_bVisible visibility flag */
bool m_bVisible;
};
#endif // VABSTRACTFLOATITEMDATA_H

View File

@ -31,80 +31,49 @@
#include "vgrainlinedata.h" #include "vgrainlinedata.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VGrainlineData::VGrainlineData() VGrainlineData::VGrainlineData()
:m_ptPos(0, 0), m_qsLength(), m_qsRotation(), m_bVisible(false), m_eArrowType(atBoth) : VAbstractFloatItemData(),
m_qsLength(),
m_dRotation(),
m_eArrowType(atBoth)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VGrainlineData::~VGrainlineData()
QPointF VGrainlineData::GetPos() const {}
{
return m_ptPos;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VGrainlineData::SetPos(const QPointF &ptPos)
{
m_ptPos = ptPos;
}
//---------------------------------------------------------------------------------------------------------------------
QString VGrainlineData::GetLength() const QString VGrainlineData::GetLength() const
{ {
return m_qsLength; return m_qsLength;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VGrainlineData::SetLength(const QString& qsLen) void VGrainlineData::SetLength(const QString& qsLen)
{ {
m_qsLength = qsLen; m_qsLength = qsLen;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VGrainlineData::GetRotation() const QString VGrainlineData::GetRotation() const
{ {
return m_qsRotation; return m_dRotation;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VGrainlineData::SetRotation(const QString& qsRot) void VGrainlineData::SetRotation(const QString& qsRot)
{ {
m_qsRotation = qsRot; m_dRotation = qsRot;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VGrainlineData::IsVisible() const
{
return m_bVisible;
}
//---------------------------------------------------------------------------------------------------------------------
void VGrainlineData::SetVisible(bool bVisible)
{
m_bVisible = bVisible;
}
//---------------------------------------------------------------------------------------------------------------------
VGrainlineData::ArrowType VGrainlineData::GetArrowType() const VGrainlineData::ArrowType VGrainlineData::GetArrowType() const
{ {
return m_eArrowType; return m_eArrowType;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VGrainlineData::SetArrowType(ArrowType eAT) void VGrainlineData::SetArrowType(ArrowType eAT)
{ {
m_eArrowType = eAT; m_eArrowType = eAT;
} }
//---------------------------------------------------------------------------------------------------------------------

View File

@ -29,15 +29,16 @@
#ifndef VGRAINLINEGEOMETRY_H #ifndef VGRAINLINEGEOMETRY_H
#define VGRAINLINEGEOMETRY_H #define VGRAINLINEGEOMETRY_H
#include <QtGlobal>
#include <QString> #include <QString>
#include <QPointF> #include <QPointF>
#include "vabstractfloatitemdata.h"
/** /**
* @brief The VGrainlineData class holds information about a grainline like * @brief The VGrainlineData class holds information about a grainline like
* position, size, rotation and visibility * position, size, rotation and visibility
*/ */
class VGrainlineData class VGrainlineData : public VAbstractFloatItemData
{ {
public: public:
// denotes the type of arrow for the grainline // denotes the type of arrow for the grainline
@ -49,39 +50,24 @@ public:
}; };
VGrainlineData(); VGrainlineData();
virtual ~VGrainlineData();
// methods, which set and return values of different parameters // methods, which set and return values of different parameters
QPointF GetPos() const;
void SetPos(const QPointF& ptPos);
QString GetLength() const; QString GetLength() const;
void SetLength(const QString& qsLen); void SetLength(const QString& qsLen);
QString GetRotation() const; QString GetRotation() const;
void SetRotation(const QString& qsRot); void SetRotation(const QString& qsRot);
bool IsVisible() const;
void SetVisible(bool bVisible);
ArrowType GetArrowType() const; ArrowType GetArrowType() const;
void SetArrowType(ArrowType eAT); void SetArrowType(ArrowType eAT);
private: private:
/** /** @brief m_dLength formula to calculate the length of grainline */
* @brief m_ptPos position of grainline's center
*/
QPointF m_ptPos;
/**
* @brief m_dLength formula to calculate the length of grainline
*/
QString m_qsLength; QString m_qsLength;
/** /** @brief m_dRotation formula to calculate the rotation of grainline in [degrees] */
* @brief m_dRotation formula to calculate the rotation of grainline in [degrees] QString m_dRotation;
*/ /** @brief m_eArrowType type of arrow on the grainline */
QString m_qsRotation;
/**
* @brief m_bVisible visibility flag
*/
bool m_bVisible;
/**
* @brief m_eArrowType type of arrow on the grainline
*/
ArrowType m_eArrowType; ArrowType m_eArrowType;
}; };

View File

@ -30,30 +30,17 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPatternLabelData::VPatternLabelData() VPatternLabelData::VPatternLabelData()
: m_ptPos(), : VAbstractFloatItemData(),
m_dLabelWidth(0), m_dLabelWidth(0),
m_dLabelHeight(0), m_dLabelHeight(0),
m_iFontSize(0), m_iFontSize(0),
m_dRotation(0), m_dRotation(0)
m_bVisible(true)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPatternLabelData::~VPatternLabelData() VPatternLabelData::~VPatternLabelData()
{} {}
//---------------------------------------------------------------------------------------------------------------------
QPointF VPatternLabelData::GetPos() const
{
return m_ptPos;
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternLabelData::SetPos(const QPointF& ptPos)
{
m_ptPos = ptPos;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VPatternLabelData::GetLabelWidth() const qreal VPatternLabelData::GetLabelWidth() const
{ {
@ -101,15 +88,3 @@ void VPatternLabelData::SetRotation(qreal dRot)
{ {
m_dRotation = dRot; m_dRotation = dRot;
} }
//---------------------------------------------------------------------------------------------------------------------
bool VPatternLabelData::IsVisible() const
{
return m_bVisible;
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternLabelData::SetVisible(bool bVal)
{
m_bVisible = bVal;
}

View File

@ -30,21 +30,19 @@
#define VPATTERNINFOGEOMETRY_H #define VPATTERNINFOGEOMETRY_H
#include <QPointF> #include <QPointF>
#include <QtGlobal>
#include "vabstractfloatitemdata.h"
/** /**
* @brief The VPatternLabelData class holds the information about pattern info label geometry * @brief The VPatternLabelData class holds the information about pattern info label geometry
*/ */
class VPatternLabelData class VPatternLabelData : public VAbstractFloatItemData
{ {
public: public:
VPatternLabelData(); VPatternLabelData();
virtual ~VPatternLabelData(); virtual ~VPatternLabelData();
// methods, which set up label parameters // methods, which set up label parameters
QPointF GetPos() const;
void SetPos(const QPointF& ptPos);
qreal GetLabelWidth() const; qreal GetLabelWidth() const;
void SetLabelWidth(qreal dLabelW); void SetLabelWidth(qreal dLabelW);
@ -57,34 +55,15 @@ public:
qreal GetRotation() const; qreal GetRotation() const;
void SetRotation(qreal dRot); void SetRotation(qreal dRot);
bool IsVisible() const;
void SetVisible(bool bVal);
protected: protected:
/** /** @brief m_dLabelWidth label width */
* @brief m_ptPos position of label's top left corner
*/
QPointF m_ptPos;
/**
* @brief m_dLabelWidth label width
*/
qreal m_dLabelWidth; qreal m_dLabelWidth;
/** /** @brief m_dLabelHeight label height */
* @brief m_dLabelHeight label height
*/
qreal m_dLabelHeight; qreal m_dLabelHeight;
/** /** @brief m_iFontSize label text base font size */
* @brief m_iFontSize label text base font size
*/
int m_iFontSize; int m_iFontSize;
/** /** @brief m_dRotation label rotation */
* @brief m_dRotation label rotation
*/
qreal m_dRotation; qreal m_dRotation;
/**
* @brief m_bVisible visibility flag
*/
bool m_bVisible;
}; };

View File

@ -24,7 +24,8 @@ SOURCES += \
$$PWD/vpiecepath.cpp \ $$PWD/vpiecepath.cpp \
$$PWD/floatItemData/vpiecelabeldata.cpp \ $$PWD/floatItemData/vpiecelabeldata.cpp \
$$PWD/floatItemData/vpatternlabeldata.cpp \ $$PWD/floatItemData/vpatternlabeldata.cpp \
$$PWD/floatItemData/vgrainlinedata.cpp $$PWD/floatItemData/vgrainlinedata.cpp \
$$PWD/floatItemData/vabstractfloatitemdata.cpp
win32-msvc*:SOURCES += $$PWD/stable.cpp win32-msvc*:SOURCES += $$PWD/stable.cpp
@ -65,4 +66,5 @@ HEADERS += \
$$PWD/vpiecepath_p.h \ $$PWD/vpiecepath_p.h \
$$PWD/floatItemData/vpiecelabeldata.h \ $$PWD/floatItemData/vpiecelabeldata.h \
$$PWD/floatItemData/vpatternlabeldata.h \ $$PWD/floatItemData/vpatternlabeldata.h \
$$PWD/floatItemData/vgrainlinedata.h $$PWD/floatItemData/vgrainlinedata.h \
$$PWD/floatItemData/vabstractfloatitemdata.h