valentina/src/libs/vlayout/vlayoutpiecepath.cpp

144 lines
4.9 KiB
C++
Raw Normal View History

/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 8 2, 2017
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2017 Valentina project
** <https://gitlab.com/smart-pattern/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 "vlayoutpiecepath.h"
#include "vlayoutpiecepath_p.h"
#include <QPainterPath>
// Friend functions
//---------------------------------------------------------------------------------------------------------------------
QDataStream &operator<<(QDataStream &dataStream, const VLayoutPiecePath &path)
{
dataStream << *path.d;
return dataStream;
}
//---------------------------------------------------------------------------------------------------------------------
QDataStream &operator>>(QDataStream &dataStream, VLayoutPiecePath &path)
{
dataStream >> *path.d;
return dataStream;
}
//---------------------------------------------------------------------------------------------------------------------
VLayoutPiecePath::VLayoutPiecePath()
: d(new VLayoutPiecePathData)
{
}
//---------------------------------------------------------------------------------------------------------------------
2022-10-28 15:16:02 +02:00
VLayoutPiecePath::VLayoutPiecePath(const QVector<VLayoutPoint> &points)
: d(new VLayoutPiecePathData(points))
{
}
//---------------------------------------------------------------------------------------------------------------------
VLayoutPiecePath::VLayoutPiecePath(const VLayoutPiecePath &path)
: d(path.d)
{
}
//---------------------------------------------------------------------------------------------------------------------
VLayoutPiecePath &VLayoutPiecePath::operator=(const VLayoutPiecePath &path)
{
if ( &path == this )
{
return *this;
}
d = path.d;
return *this;
}
#ifdef Q_COMPILER_RVALUE_REFS
//---------------------------------------------------------------------------------------------------------------------
2022-08-12 17:50:13 +02:00
VLayoutPiecePath::VLayoutPiecePath(VLayoutPiecePath &&path) Q_DECL_NOTHROW
: d(std::move(path.d))
{}
//---------------------------------------------------------------------------------------------------------------------
VLayoutPiecePath &VLayoutPiecePath::operator=(VLayoutPiecePath &&path) Q_DECL_NOTHROW
{
std::swap(d, path.d);
return *this;
}
#endif
//---------------------------------------------------------------------------------------------------------------------
VLayoutPiecePath::~VLayoutPiecePath()
{
}
//---------------------------------------------------------------------------------------------------------------------
QPainterPath VLayoutPiecePath::GetPainterPath() const
{
QPainterPath path;
if (not d->m_points.isEmpty())
{
2022-10-28 15:16:02 +02:00
path.addPolygon(QPolygonF(CastTo<QPointF>(d->m_points)));
path.setFillRule(Qt::WindingFill);
}
return path;
}
//---------------------------------------------------------------------------------------------------------------------
2022-10-28 15:16:02 +02:00
QVector<VLayoutPoint> VLayoutPiecePath::Points() const
{
return d->m_points;
}
//---------------------------------------------------------------------------------------------------------------------
2022-10-28 15:16:02 +02:00
void VLayoutPiecePath::SetPoints(const QVector<VLayoutPoint> &points)
{
d->m_points = points;
}
//---------------------------------------------------------------------------------------------------------------------
Qt::PenStyle VLayoutPiecePath::PenStyle() const
{
return d->m_penStyle;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiecePath::SetPenStyle(const Qt::PenStyle &penStyle)
{
d->m_penStyle = penStyle;
}
//---------------------------------------------------------------------------------------------------------------------
bool VLayoutPiecePath::IsCutPath() const
{
return d->m_cut;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutPiecePath::SetCutPath(bool cut)
{
d->m_cut = cut;
}