/************************************************************************ ** ** @file vlayoutdetail.cpp ** @author Roman Telezhynskyi ** @date 2 1, 2015 ** ** @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) 2015 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 . ** *************************************************************************/ #include "vlayoutdetail.h" #include "vlayoutdetail_p.h" //--------------------------------------------------------------------------------------------------------------------- VLayoutDetail::VLayoutDetail() :VAbstractDetail(), d(new VLayoutDetailData) {} //--------------------------------------------------------------------------------------------------------------------- VLayoutDetail::VLayoutDetail(const VLayoutDetail &detail) :VAbstractDetail(detail), d (detail.d) {} //--------------------------------------------------------------------------------------------------------------------- VLayoutDetail &VLayoutDetail::operator=(const VLayoutDetail &detail) { if ( &detail == this ) { return *this; } VAbstractDetail::operator=(detail); d = detail.d; return *this; } //--------------------------------------------------------------------------------------------------------------------- VLayoutDetail::~VLayoutDetail() {} //--------------------------------------------------------------------------------------------------------------------- QVector VLayoutDetail::GetContour() const { return d->contour; } //--------------------------------------------------------------------------------------------------------------------- void VLayoutDetail::SetCountour(const QVector &points) { d->contour = points; } //--------------------------------------------------------------------------------------------------------------------- QVector VLayoutDetail::GetSeamAllowencePoints() const { return d->seamAllowence; } //--------------------------------------------------------------------------------------------------------------------- void VLayoutDetail::SetSeamAllowencePoints(const QVector &points) { d->seamAllowence = points; } //--------------------------------------------------------------------------------------------------------------------- QVector VLayoutDetail::GetLayoutAllowence() const { return Map(d->layoutAllowence); } //--------------------------------------------------------------------------------------------------------------------- QMatrix VLayoutDetail::GetMatrix() const { return d->matrix; } //--------------------------------------------------------------------------------------------------------------------- void VLayoutDetail::SetMatrix(const QMatrix &matrix) { d->matrix = matrix; } //--------------------------------------------------------------------------------------------------------------------- qreal VLayoutDetail::GetLayoutWidth() const { return d->layoutWidth; } //--------------------------------------------------------------------------------------------------------------------- void VLayoutDetail::SetLayoutWidth(const qreal &value) { d->layoutWidth = value; } //--------------------------------------------------------------------------------------------------------------------- void VLayoutDetail::translate(qreal dx, qreal dy) { const QMatrix m = d->matrix.translate(dx, dy); d->matrix = m; } //--------------------------------------------------------------------------------------------------------------------- void VLayoutDetail::rotate(qreal degrees) { const QMatrix m = d->matrix.rotate(degrees); d->matrix = m; } //--------------------------------------------------------------------------------------------------------------------- int VLayoutDetail::EdgesCount() const { return d->layoutAllowence.count()-1; } //--------------------------------------------------------------------------------------------------------------------- QLineF VLayoutDetail::Edge(int i) const { if (i < 1 || i > EdgesCount()) { // Doesn't exist such edge return QLineF(); } const QLineF line(d->layoutAllowence.at(i-1), d->layoutAllowence.at(i)); return line; } //--------------------------------------------------------------------------------------------------------------------- void VLayoutDetail::SetLayoutAllowence() { if (d->layoutWidth > 0) { if (getSeamAllowance()) { d->layoutAllowence = Equidistant(d->seamAllowence, EquidistantType::CloseEquidistant, d->layoutWidth); } else { d->layoutAllowence = Equidistant(d->contour, EquidistantType::CloseEquidistant, d->layoutWidth); } } else { d->layoutAllowence.clear(); } } //--------------------------------------------------------------------------------------------------------------------- QVector VLayoutDetail::Map(const QVector &points) const { QVector p; for (int i = 0; i < points.size(); ++i) { p.append(d->matrix.map(points.at(i))); } return p; }