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"
//---------------------------------------------------------------------------------------------------------------------
VGrainlineData::VGrainlineData()
:m_ptPos(0, 0), m_qsLength(), m_qsRotation(), m_bVisible(false), m_eArrowType(atBoth)
: VAbstractFloatItemData(),
m_qsLength(),
m_dRotation(),
m_eArrowType(atBoth)
{}
//---------------------------------------------------------------------------------------------------------------------
QPointF VGrainlineData::GetPos() const
{
return m_ptPos;
}
VGrainlineData::~VGrainlineData()
{}
//---------------------------------------------------------------------------------------------------------------------
void VGrainlineData::SetPos(const QPointF &ptPos)
{
m_ptPos = ptPos;
}
//---------------------------------------------------------------------------------------------------------------------
QString VGrainlineData::GetLength() const
{
return m_qsLength;
}
//---------------------------------------------------------------------------------------------------------------------
void VGrainlineData::SetLength(const QString& qsLen)
{
m_qsLength = qsLen;
}
//---------------------------------------------------------------------------------------------------------------------
QString VGrainlineData::GetRotation() const
{
return m_qsRotation;
return m_dRotation;
}
//---------------------------------------------------------------------------------------------------------------------
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
{
return m_eArrowType;
}
//---------------------------------------------------------------------------------------------------------------------
void VGrainlineData::SetArrowType(ArrowType eAT)
{
m_eArrowType = eAT;
}
//---------------------------------------------------------------------------------------------------------------------

View File

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

View File

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

View File

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