Replace VDetail by VPiece.
--HG-- branch : feature
This commit is contained in:
parent
ded6a9e76c
commit
26c76bbc71
|
@ -2268,10 +2268,10 @@ void MainWindow::ActionLayout(bool checked)
|
|||
ui->actionDetails->setChecked(false);
|
||||
ui->actionLayout->setChecked(true);
|
||||
|
||||
QHash<quint32, VDetail> details;
|
||||
QHash<quint32, VPiece> details;
|
||||
if(not qApp->getOpeningPattern())
|
||||
{
|
||||
const QHash<quint32, VDetail> *allDetails = pattern->DataDetails();
|
||||
const QHash<quint32, VPiece> *allDetails = pattern->DataPieces();
|
||||
if (allDetails->count() == 0)
|
||||
{
|
||||
QMessageBox::information(this, tr("Layout mode"), tr("You can't use now the Layout mode. "
|
||||
|
@ -2282,7 +2282,7 @@ void MainWindow::ActionLayout(bool checked)
|
|||
}
|
||||
else
|
||||
{
|
||||
QHash<quint32, VDetail>::const_iterator i = allDetails->constBegin();
|
||||
QHash<quint32, VPiece>::const_iterator i = allDetails->constBegin();
|
||||
while (i != allDetails->constEnd())
|
||||
{
|
||||
if (i.value().IsInLayout())
|
||||
|
@ -4388,7 +4388,7 @@ void MainWindow::ZoomFirstShow()
|
|||
VMainGraphicsView::NewSceneRect(sceneDraw, ui->view);
|
||||
VMainGraphicsView::NewSceneRect(sceneDetails, ui->view);
|
||||
|
||||
if (pattern->DataDetails()->size() > 0)
|
||||
if (pattern->DataPieces()->size() > 0)
|
||||
{
|
||||
ActionDetails(true);
|
||||
ui->view->ZoomFitBest();
|
||||
|
@ -4405,7 +4405,7 @@ void MainWindow::DoExport(const VCommandLinePtr &expParams)
|
|||
{
|
||||
auto settings = expParams->DefaultGenerator();
|
||||
|
||||
const QHash<quint32, VDetail> *details = pattern->DataDetails();
|
||||
const QHash<quint32, VPiece> *details = pattern->DataPieces();
|
||||
if(not qApp->getOpeningPattern())
|
||||
{
|
||||
if (details->count() == 0)
|
||||
|
|
|
@ -463,7 +463,7 @@ void MainWindowsNoGUI::PrintTiled()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash<quint32, VDetail> *details)
|
||||
void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash<quint32, VPiece> *details)
|
||||
{
|
||||
listDetails.clear();
|
||||
SCASSERT(details != nullptr)
|
||||
|
@ -472,18 +472,18 @@ void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash<quint32, VDetail> *de
|
|||
return;
|
||||
}
|
||||
|
||||
QHash<quint32, VDetail>::const_iterator i = details->constBegin();
|
||||
QHash<quint32, VPiece>::const_iterator i = details->constBegin();
|
||||
while (i != details->constEnd())
|
||||
{
|
||||
VLayoutDetail det = VLayoutDetail();
|
||||
const VDetail d = i.value();
|
||||
det.SetCountourPoints(d.ContourPoints(pattern));
|
||||
det.SetSeamAllowencePoints(d.SeamAllowancePoints(pattern), d.getSeamAllowance(), d.getClosed());
|
||||
det.setName(d.getName());
|
||||
const VPiece d = i.value();
|
||||
det.SetCountourPoints(d.MainPathPoints(pattern));
|
||||
det.SetSeamAllowencePoints(d.SeamAllowancePoints(pattern), d.IsSeamAllowance(), false);
|
||||
det.setName(d.GetName());
|
||||
const VPatternPieceData& data = d.GetPatternPieceData();
|
||||
if (data.IsVisible() == true)
|
||||
{
|
||||
det.SetDetail(d.getName(), data, qApp->font());
|
||||
det.SetDetail(d.GetName(), data, qApp->font());
|
||||
}
|
||||
const VPatternInfoGeometry& geom = d.GetPatternInfo();
|
||||
if (geom.IsVisible() == true)
|
||||
|
@ -501,9 +501,9 @@ void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash<quint32, VDetail> *de
|
|||
{
|
||||
det.SetGrainline(grainlineGeom, *pattern);
|
||||
}
|
||||
det.setWidth(qApp->toPixel(d.getWidth()));
|
||||
det.setWidth(qApp->toPixel(d.GetSAWidth()));
|
||||
det.CreateTextItems();
|
||||
det.setForbidFlipping(d.getForbidFlipping());
|
||||
det.setForbidFlipping(d.IsForbidFlipping());
|
||||
|
||||
listDetails.append(det);
|
||||
++i;
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include <QMainWindow>
|
||||
#include <QPrinter>
|
||||
|
||||
#include "../vpatterndb/vdetail.h"
|
||||
#include "../vlayout/vlayoutdetail.h"
|
||||
#include "xml/vpattern.h"
|
||||
#include "dialogs/dialogsavelayout.h"
|
||||
|
@ -90,7 +89,7 @@ protected:
|
|||
QMarginsF margins;
|
||||
QSizeF paperSize;
|
||||
|
||||
void PrepareDetailsForLayout(const QHash<quint32, VDetail> *details);
|
||||
void PrepareDetailsForLayout(const QHash<quint32, VPiece> *details);
|
||||
void ExportLayout(const DialogSaveLayout &dialog);
|
||||
|
||||
void InitTempLayoutScene();
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "../vpatterndb/vpatterninfogeometry.h"
|
||||
#include "../vpatterndb/vgrainlinegeometry.h"
|
||||
#include "../vpatterndb/vpiecepath.h"
|
||||
#include "../vpatterndb/vnodedetail.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QUndoStack>
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
class VDataTool;
|
||||
class VMainGraphicsScene;
|
||||
class VNodeDetail;
|
||||
|
||||
/**
|
||||
* @brief The VPattern class working with pattern file.
|
||||
|
|
|
@ -150,24 +150,6 @@ const val VContainer::GetObject(const QHash<key, val> &obj, key id) const
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetDetail return detail by id
|
||||
* @param id id of detail
|
||||
* @return detail
|
||||
*/
|
||||
const VDetail VContainer::GetDetail(quint32 id) const
|
||||
{
|
||||
if (d->details->contains(id))
|
||||
{
|
||||
return d->details->value(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw VExceptionBadId(tr("Can't find object"), id);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VPiece VContainer::GetPiece(quint32 id) const
|
||||
{
|
||||
|
@ -208,19 +190,6 @@ quint32 VContainer::AddGObject(VGObject *obj)
|
|||
return AddObject(d->gObjects, pointer);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief AddDetail add new detail to container
|
||||
* @param detail new detail
|
||||
* @return return id of new detail in container
|
||||
*/
|
||||
quint32 VContainer::AddDetail(const VDetail &detail)
|
||||
{
|
||||
const quint32 id = getNextId();
|
||||
d->details->insert(id, detail);
|
||||
return id;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
quint32 VContainer::AddPiece(const VPiece &detail)
|
||||
{
|
||||
|
@ -304,7 +273,6 @@ void VContainer::Clear()
|
|||
qCDebug(vCon, "Clearing container data.");
|
||||
_id = NULL_ID;
|
||||
|
||||
d->details->clear();
|
||||
d->pieces->clear();
|
||||
d->piecePaths->clear();
|
||||
ClearVariables();
|
||||
|
@ -318,7 +286,6 @@ void VContainer::ClearForFullParse()
|
|||
qCDebug(vCon, "Clearing container data for full parse.");
|
||||
_id = NULL_ID;
|
||||
|
||||
d->details->clear();
|
||||
d->pieces->clear();
|
||||
d->piecePaths->clear();
|
||||
ClearVariables(VarType::Increment);
|
||||
|
@ -556,19 +523,6 @@ void VContainer::UpdateGObject(quint32 id, VGObject* obj)
|
|||
uniqueNames.insert(obj->name());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief UpdateDetail update detail by id
|
||||
* @param id id of existing detail
|
||||
* @param detail detail
|
||||
*/
|
||||
void VContainer::UpdateDetail(quint32 id, const VDetail &detail)
|
||||
{
|
||||
Q_ASSERT_X(id != NULL_ID, Q_FUNC_INFO, "id == 0"); //-V654 //-V712
|
||||
d->details->insert(id, detail);
|
||||
UpdateId(id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VContainer::UpdatePiece(quint32 id, const VPiece &detail)
|
||||
{
|
||||
|
@ -734,13 +688,6 @@ const QMap<QString, QSharedPointer<T> > VContainer::DataVar(const VarType &type)
|
|||
return map;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// cppcheck-suppress unusedFunction
|
||||
void VContainer::ClearDetails()
|
||||
{
|
||||
d->details->clear();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VContainer::ClearUniqueNames()
|
||||
{
|
||||
|
@ -809,16 +756,6 @@ const QHash<quint32, QSharedPointer<VGObject> > *VContainer::DataGObjects() cons
|
|||
return &d->gObjects;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief data container with dataDetails return container of details
|
||||
* @return pointer on container of details
|
||||
*/
|
||||
const QHash<quint32, VDetail> *VContainer::DataDetails() const
|
||||
{
|
||||
return d->details.data();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
const QHash<quint32, VPiece> *VContainer::DataPieces() const
|
||||
{
|
||||
|
|
|
@ -53,7 +53,6 @@
|
|||
#include "../vmisc/diagnostic.h"
|
||||
#include "variables.h"
|
||||
#include "variables/vinternalvariable.h"
|
||||
#include "vdetail.h"
|
||||
#include "vpiece.h"
|
||||
#include "vpiecepath.h"
|
||||
#include "vtranslatevars.h"
|
||||
|
@ -83,7 +82,6 @@ public:
|
|||
VContainerData(const VTranslateVars *trVars, const Unit *patternUnit)
|
||||
: gObjects(QHash<quint32, QSharedPointer<VGObject> >()),
|
||||
variables(QHash<QString, QSharedPointer<VInternalVariable> > ()),
|
||||
details(QSharedPointer<QHash<quint32, VDetail>>(new QHash<quint32, VDetail>())),
|
||||
pieces(QSharedPointer<QHash<quint32, VPiece>>(new QHash<quint32, VPiece>())),
|
||||
piecePaths(QSharedPointer<QHash<quint32, VPiecePath>>(new QHash<quint32, VPiecePath>())),
|
||||
trVars(trVars),
|
||||
|
@ -94,7 +92,6 @@ public:
|
|||
: QSharedData(data),
|
||||
gObjects(data.gObjects),
|
||||
variables(data.variables),
|
||||
details(data.details),
|
||||
pieces(data.pieces),
|
||||
piecePaths(data.piecePaths),
|
||||
trVars(data.trVars),
|
||||
|
@ -112,10 +109,7 @@ public:
|
|||
* @brief variables container for measurements, increments, lines lengths, lines angles, arcs lengths, curve lengths
|
||||
*/
|
||||
QHash<QString, QSharedPointer<VInternalVariable>> variables;
|
||||
/**
|
||||
* @brief details container of details
|
||||
*/
|
||||
QSharedPointer<QHash<quint32, VDetail>> details;
|
||||
|
||||
QSharedPointer<QHash<quint32, VPiece>> pieces;
|
||||
QSharedPointer<QHash<quint32, VPiecePath>> piecePaths;
|
||||
|
||||
|
@ -144,7 +138,6 @@ public:
|
|||
const QSharedPointer<T> GeometricObject(const quint32 &id) const;
|
||||
const QSharedPointer<VGObject> GetGObject(quint32 id) const;
|
||||
static const QSharedPointer<VGObject> GetFakeGObject(quint32 id);
|
||||
const VDetail GetDetail(quint32 id) const;
|
||||
VPiece GetPiece(quint32 id) const;
|
||||
VPiecePath GetPiecePath(quint32 id) const;
|
||||
qreal GetTableValue(const QString& name, MeasurementsType patternType) const;
|
||||
|
@ -155,7 +148,6 @@ public:
|
|||
static void UpdateId(quint32 newId);
|
||||
|
||||
quint32 AddGObject(VGObject *obj);
|
||||
quint32 AddDetail(const VDetail &detail);
|
||||
quint32 AddPiece(const VPiece &detail);
|
||||
quint32 AddPiecePath(const VPiecePath &path);
|
||||
void AddLine(const quint32 &firstPointId, const quint32 &secondPointId);
|
||||
|
@ -171,7 +163,6 @@ public:
|
|||
void RemovePiece(quint32 id);
|
||||
|
||||
void UpdateGObject(quint32 id, VGObject* obj);
|
||||
void UpdateDetail(quint32 id, const VDetail &detail);
|
||||
void UpdatePiece(quint32 id, const VPiece &detail);
|
||||
void UpdatePiecePath(quint32 id, const VPiecePath &path);
|
||||
|
||||
|
@ -180,7 +171,6 @@ public:
|
|||
void ClearGObjects();
|
||||
void ClearCalculationGObjects();
|
||||
void ClearVariables(const VarType &type = VarType::Unknown);
|
||||
void ClearDetails();
|
||||
static void ClearUniqueNames();
|
||||
|
||||
static void SetSize(qreal size);
|
||||
|
@ -195,7 +185,6 @@ public:
|
|||
void RemoveIncrement(const QString& name);
|
||||
|
||||
const QHash<quint32, QSharedPointer<VGObject> > *DataGObjects() const;
|
||||
const QHash<quint32, VDetail> *DataDetails() const;
|
||||
const QHash<quint32, VPiece> *DataPieces() const;
|
||||
const QHash<QString, QSharedPointer<VInternalVariable>> *DataVariables() const;
|
||||
|
||||
|
|
|
@ -1,814 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vdetail.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date November 15, 2013
|
||||
**
|
||||
** @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) 2013-2015 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 "vdetail.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QMessageLogger>
|
||||
#include <QPainterPath>
|
||||
#include <QSet>
|
||||
#include <QSharedPointer>
|
||||
#include <QString>
|
||||
#include <Qt>
|
||||
#include <QtDebug>
|
||||
#include <new>
|
||||
|
||||
#include "../vmisc/def.h"
|
||||
#include "../vgeometry/vabstractcurve.h"
|
||||
#include "../vgeometry/vgobject.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../vlayout/vlayoutdef.h"
|
||||
#include "vcontainer.h"
|
||||
#include "vdetail_p.h"
|
||||
#include "vnodedetail.h"
|
||||
#include "vpatternpiecedata.h"
|
||||
#include "vgrainlinegeometry.h"
|
||||
|
||||
class QPointF;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VDetail default contructor. Create empty detail.
|
||||
*/
|
||||
VDetail::VDetail()
|
||||
:VAbstractDetail(), d(new VDetailData)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VDetail constructor.
|
||||
* @param name detail name.
|
||||
* @param nodes list of nodes.
|
||||
*/
|
||||
VDetail::VDetail(const QString &name, const QVector<VNodeDetail> &nodes)
|
||||
:VAbstractDetail(name), d(new VDetailData(nodes))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VDetail copy constructor.
|
||||
* @param detail detail.
|
||||
*/
|
||||
VDetail::VDetail(const VDetail &detail)
|
||||
:VAbstractDetail(detail), d (detail.d)
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief operator = assignment operator.
|
||||
* @param detail detail.
|
||||
* @return new detail.
|
||||
*/
|
||||
VDetail &VDetail::operator =(const VDetail &detail)
|
||||
{
|
||||
if ( &detail == this )
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
VAbstractDetail::operator=(detail);
|
||||
d = detail.d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VDetail::~VDetail()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Clear detail full clear.
|
||||
*/
|
||||
void VDetail::Clear()
|
||||
{
|
||||
d->nodes.clear();
|
||||
d->mx = 0;
|
||||
d->my = 0;
|
||||
GetPatternPieceData().Clear();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief ClearNodes clear list of nodes.
|
||||
*/
|
||||
void VDetail::ClearNodes()
|
||||
{
|
||||
d->nodes.clear();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Containes check if detail containe this id.
|
||||
* @param id object id.
|
||||
* @return true if containe.
|
||||
*/
|
||||
bool VDetail::Containes(const quint32 &id) const
|
||||
{
|
||||
for (int i = 0; i < d->nodes.size(); ++i)
|
||||
{
|
||||
VNodeDetail node = d->nodes.at(i);
|
||||
if (node.getId() == id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief operator [] find node by index in list.
|
||||
* @param indx index node in list.
|
||||
* @return node
|
||||
*/
|
||||
VNodeDetail &VDetail::operator [](int indx)
|
||||
{
|
||||
return d->nodes[indx];
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief at find node by index in list.
|
||||
* @param indx index node in list.
|
||||
* @return const node.
|
||||
*/
|
||||
const VNodeDetail &VDetail::at(int indx) const
|
||||
{
|
||||
return d->nodes.at(indx);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief indexOfNode return index in list node using id object.
|
||||
* @param id object (arc, point, spline, splinePath) id.
|
||||
* @return index in list or -1 id can't find.
|
||||
*/
|
||||
int VDetail::indexOfNode(const quint32 &id) const
|
||||
{
|
||||
return indexOfNode(d->nodes, id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief id return id detail in list data.
|
||||
* @return id.
|
||||
*/
|
||||
quint32 VDetail::id() const
|
||||
{
|
||||
return d->_id;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief setId set id detail in list data.
|
||||
* @param id detail id.
|
||||
*/
|
||||
void VDetail::setId(const quint32 &id)
|
||||
{
|
||||
d->_id = id;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VDetail::IsInLayout() const
|
||||
{
|
||||
return d->inLayout;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VDetail::SetInLayout(bool inLayout)
|
||||
{
|
||||
d->inLayout = inLayout;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief OnEdge checks if two poins located on the edge. Edge is line between two points. If between two points
|
||||
* located arcs or splines ignore this.
|
||||
* @param p1 id first point.
|
||||
* @param p2 id second point.
|
||||
* @return true - on edge, false - no.
|
||||
*/
|
||||
bool VDetail::OnEdge(const quint32 &p1, const quint32 &p2) const
|
||||
{
|
||||
QVector<VNodeDetail> list = listNodePoint();
|
||||
if (list.size() < 2)
|
||||
{
|
||||
qDebug()<<"Not enough points.";
|
||||
return false;
|
||||
}
|
||||
int i = indexOfNode(list, p1);
|
||||
int j1 = 0, j2 = 0;
|
||||
|
||||
if (i == list.size() - 1)
|
||||
{
|
||||
j1 = i-1;
|
||||
j2 = 0;
|
||||
}
|
||||
else if (i == 0)
|
||||
{
|
||||
j1 = list.size() - 1;
|
||||
j2 = i + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
j1 = i - 1;
|
||||
j2 = i + 1;
|
||||
}
|
||||
|
||||
if (list.at(j1).getId() == p2 || list.at(j2).getId() == p2)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Edge return edge index in detail. Edge is line between two points. If between two points
|
||||
* located arcs or splines ignore this.
|
||||
* @param p1 id first point.
|
||||
* @param p2 id second point.
|
||||
* @return edge index or -1 if points don't located on edge
|
||||
*/
|
||||
int VDetail::Edge(const quint32 &p1, const quint32 &p2) const
|
||||
{
|
||||
if (OnEdge(p1, p2) == false)
|
||||
{
|
||||
qDebug()<<"Points don't on edge.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
QVector<VNodeDetail> list = listNodePoint();
|
||||
int i = indexOfNode(list, p1);
|
||||
int j = indexOfNode(list, p2);
|
||||
|
||||
int min = qMin(i, j);
|
||||
|
||||
if (min == 0 && (i == list.size() - 1 || j == list.size() - 1))
|
||||
{
|
||||
return list.size() - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return min;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief NodeOnEdge return nodes located on edge with index.
|
||||
* @param index index of edge.
|
||||
* @param p1 first node.
|
||||
* @param p2 second node.
|
||||
*/
|
||||
void VDetail::NodeOnEdge(const quint32 &index, VNodeDetail &p1, VNodeDetail &p2) const
|
||||
{
|
||||
QVector<VNodeDetail> list = listNodePoint();
|
||||
if (index > static_cast<quint32>(list.size()))
|
||||
{
|
||||
qDebug()<<"Wrong edge index index ="<<index;
|
||||
return;
|
||||
}
|
||||
p1 = list.at(static_cast<int>(index));
|
||||
if (index + 1 > static_cast<quint32>(list.size()) - 1)
|
||||
{
|
||||
p2 = list.at(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
p2 = list.at(static_cast<int>(index+1));
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief RemoveEdge return detail without edge with index.
|
||||
* @param index idex of edge.
|
||||
* @return detail without edge with index.
|
||||
*/
|
||||
VDetail VDetail::RemoveEdge(const quint32 &index) const
|
||||
{
|
||||
VDetail det(*this);
|
||||
det.ClearNodes();
|
||||
|
||||
// Edge can be only segment. We ignore all curves inside segments.
|
||||
const quint32 edges = static_cast<quint32>(listNodePoint().size());
|
||||
quint32 k = 0;
|
||||
for (quint32 i=0; i<edges; ++i)
|
||||
{
|
||||
if (i == index)
|
||||
{
|
||||
det.append(this->at(static_cast<int>(k)));
|
||||
++k;
|
||||
}
|
||||
else
|
||||
{
|
||||
VNodeDetail p1;
|
||||
VNodeDetail p2;
|
||||
this->NodeOnEdge(i, p1, p2);
|
||||
const int j1 = this->indexOfNode(p1.getId());
|
||||
int j2 = this->indexOfNode(p2.getId());
|
||||
if (j2 == 0)
|
||||
{
|
||||
j2 = this->CountNode();
|
||||
}
|
||||
for (int j=j1; j<j2; ++j)
|
||||
{// Add "segment" except last point. Inside can be curves too.
|
||||
det.append(this->at(j));
|
||||
++k;
|
||||
}
|
||||
}
|
||||
}
|
||||
return det;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Missing find missing nodes in detail. When we deleted object in detail and return this detail need
|
||||
* understand, what nodes need make invisible.
|
||||
* @param det changed detail.
|
||||
* @return list with missing nodes.
|
||||
*/
|
||||
QVector<VNodeDetail> VDetail::Missing(const VDetail &det) const
|
||||
{
|
||||
if (d->nodes.size() == det.CountNode()) //-V807
|
||||
{
|
||||
return QVector<VNodeDetail>();
|
||||
}
|
||||
|
||||
QSet<quint32> set1;
|
||||
for (qint32 i = 0; i < d->nodes.size(); ++i)
|
||||
{
|
||||
set1.insert(d->nodes.at(i).getId());
|
||||
}
|
||||
|
||||
QSet<quint32> set2;
|
||||
for (qint32 j = 0; j < det.CountNode(); ++j)
|
||||
{
|
||||
set2.insert(det.at(j).getId());
|
||||
}
|
||||
|
||||
const QList<quint32> set3 = set1.subtract(set2).toList();
|
||||
QVector<VNodeDetail> nodes;
|
||||
for (qint32 i = 0; i < set3.size(); ++i)
|
||||
{
|
||||
const int index = indexOfNode(d->nodes, set3.at(i));
|
||||
if (index != -1)
|
||||
{
|
||||
nodes.append(d->nodes.at(index));
|
||||
}
|
||||
}
|
||||
|
||||
return nodes;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> VDetail::ContourPoints(const VContainer *data) const
|
||||
{
|
||||
QVector<QPointF> points;
|
||||
for (int i = 0; i< CountNode(); ++i)
|
||||
{
|
||||
switch (at(i).getTypeTool())
|
||||
{
|
||||
case (Tool::NodePoint):
|
||||
{
|
||||
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(at(i).getId());
|
||||
points.append(*point);
|
||||
}
|
||||
break;
|
||||
case (Tool::NodeArc):
|
||||
case (Tool::NodeElArc):
|
||||
case (Tool::NodeSpline):
|
||||
case (Tool::NodeSplinePath):
|
||||
{
|
||||
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(at(i).getId());
|
||||
|
||||
const QPointF begin = StartSegment(data, i, at(i).getReverse());
|
||||
const QPointF end = EndSegment(data, i, at(i).getReverse());
|
||||
|
||||
points << curve->GetSegmentPoints(begin, end, at(i).getReverse());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
qDebug()<<"Get wrong tool type. Ignore."<< static_cast<char>(at(i).getTypeTool());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
points = CheckLoops(CorrectEquidistantPoints(points));//A path can contains loops
|
||||
return points;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> VDetail::SeamAllowancePoints(const VContainer *data) const
|
||||
{
|
||||
QVector<QPointF> pointsEkv;
|
||||
if (getSeamAllowance() == false)
|
||||
{
|
||||
return pointsEkv;
|
||||
}
|
||||
|
||||
for (int i = 0; i< CountNode(); ++i)
|
||||
{
|
||||
switch (at(i).getTypeTool())
|
||||
{
|
||||
case (Tool::NodePoint):
|
||||
{
|
||||
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(at(i).getId());
|
||||
QPointF pEkv = *point;
|
||||
pEkv.setX(pEkv.x()+at(i).getMx());
|
||||
pEkv.setY(pEkv.y()+at(i).getMy());
|
||||
pointsEkv.append(pEkv);
|
||||
}
|
||||
break;
|
||||
case (Tool::NodeArc):
|
||||
case (Tool::NodeElArc):
|
||||
case (Tool::NodeSpline):
|
||||
case (Tool::NodeSplinePath):
|
||||
{
|
||||
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(at(i).getId());
|
||||
|
||||
const QPointF begin = StartSegment(data, i, at(i).getReverse());
|
||||
const QPointF end = EndSegment(data, i, at(i).getReverse());
|
||||
|
||||
const QVector<QPointF> nodePoints = curve->GetSegmentPoints(begin, end, at(i).getReverse());
|
||||
pointsEkv << biasPoints(nodePoints, at(i).getMx(), at(i).getMy());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
qDebug()<<"Get wrong tool type. Ignore."<< static_cast<char>(at(i).getTypeTool());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pointsEkv = CheckLoops(CorrectEquidistantPoints(pointsEkv));//A path can contains loops
|
||||
|
||||
if (getClosed() == true)
|
||||
{
|
||||
pointsEkv = Equidistant(pointsEkv, EquidistantType::CloseEquidistant, ToPixel(getWidth(),
|
||||
*data->GetPatternUnit()));
|
||||
}
|
||||
else
|
||||
{
|
||||
pointsEkv = Equidistant(pointsEkv, EquidistantType::OpenEquidistant, ToPixel(getWidth(),
|
||||
*data->GetPatternUnit()));
|
||||
}
|
||||
return pointsEkv;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPainterPath VDetail::ContourPath(const VContainer *data) const
|
||||
{
|
||||
const QVector<QPointF> points = ContourPoints(data);
|
||||
QPainterPath path;
|
||||
|
||||
// contour
|
||||
path.moveTo(points[0]);
|
||||
for (qint32 i = 1; i < points.count(); ++i)
|
||||
{
|
||||
path.lineTo(points.at(i));
|
||||
}
|
||||
path.lineTo(points.at(0));
|
||||
path.setFillRule(Qt::WindingFill);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPainterPath VDetail::SeamAllowancePath(const VContainer *data) const
|
||||
{
|
||||
const QVector<QPointF> pointsEkv = SeamAllowancePoints(data);
|
||||
QPainterPath ekv;
|
||||
|
||||
// seam allowence
|
||||
if (getSeamAllowance())
|
||||
{
|
||||
if (not pointsEkv.isEmpty())
|
||||
{
|
||||
ekv.moveTo(pointsEkv.at(0));
|
||||
for (qint32 i = 1; i < pointsEkv.count(); ++i)
|
||||
{
|
||||
ekv.lineTo(pointsEkv.at(i));
|
||||
}
|
||||
|
||||
ekv.setFillRule(Qt::WindingFill);
|
||||
}
|
||||
}
|
||||
|
||||
return ekv;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief listNodePoint return list nodes only with points.
|
||||
* @return list points node.
|
||||
*/
|
||||
QVector<VNodeDetail> VDetail::listNodePoint() const
|
||||
{
|
||||
QVector<VNodeDetail> list;
|
||||
for (int i = 0; i < d->nodes.size(); ++i) //-V807
|
||||
{
|
||||
if (d->nodes.at(i).getTypeTool() == Tool::NodePoint)
|
||||
{
|
||||
list.append(d->nodes.at(i));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VDetail::SetPatternPieceData(const VPatternPieceData &data)
|
||||
{
|
||||
d->m_ppData = data;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Returns full access to the pattern piece data object
|
||||
* @return pattern piece data object
|
||||
*/
|
||||
VPatternPieceData& VDetail::GetPatternPieceData()
|
||||
{
|
||||
return d->m_ppData;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Returns the read only reference to the pattern piece data object
|
||||
* @return pattern piece data object
|
||||
*/
|
||||
const VPatternPieceData& VDetail::GetPatternPieceData() const
|
||||
{
|
||||
return d->m_ppData;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VDetail::SetPatternInfo(const VPatternInfoGeometry &info)
|
||||
{
|
||||
d->m_piPatternInfo = info;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Returns full access to the pattern info geometry object
|
||||
* @return pattern info geometry object
|
||||
*/
|
||||
VPatternInfoGeometry& VDetail::GetPatternInfo()
|
||||
{
|
||||
return d->m_piPatternInfo;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief Returns the read only reference to the pattern info geometry object
|
||||
* @return pattern info geometry object
|
||||
*/
|
||||
const VPatternInfoGeometry& VDetail::GetPatternInfo() const
|
||||
{
|
||||
return d->m_piPatternInfo;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @brief VDetail::GetGrainlineGeometry full access to the grainline geometry object
|
||||
* @return reference to grainline geometry object
|
||||
*/
|
||||
VGrainlineGeometry& VDetail::GetGrainlineGeometry()
|
||||
{
|
||||
return d->m_glGrainline;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @brief VDetail::GetGrainlineGeometry returns the read-only reference to the grainline geometry object
|
||||
* @return reference to grainline geometry object
|
||||
*/
|
||||
const VGrainlineGeometry& VDetail::GetGrainlineGeometry() const
|
||||
{
|
||||
return d->m_glGrainline;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief indexOfNode return index in list node using id object.
|
||||
* @param list list nodes detail.
|
||||
* @param id object (arc, point, spline, splinePath) id.
|
||||
* @return index in list or -1 id can't find.
|
||||
*/
|
||||
int VDetail::indexOfNode(const QVector<VNodeDetail> &list, const quint32 &id)
|
||||
{
|
||||
for (int i = 0; i < list.size(); ++i)
|
||||
{
|
||||
if (list.at(i).getId() == id)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
qDebug()<<"Can't find node.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPointF VDetail::StartSegment(const VContainer *data, const int &i, bool reverse) const
|
||||
{
|
||||
if (i < 0 && i > CountNode()-1)
|
||||
{
|
||||
return QPointF();
|
||||
}
|
||||
|
||||
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(at(i).getId());
|
||||
|
||||
QVector<QPointF> points = curve->GetPoints();
|
||||
if (reverse)
|
||||
{
|
||||
points = VGObject::GetReversePoints(points);
|
||||
}
|
||||
|
||||
QPointF begin = points.first();
|
||||
if (CountNode() > 1)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
if (at(CountNode()-1).getTypeTool() == Tool::NodePoint)
|
||||
{
|
||||
begin = *data->GeometricObject<VPointF>(at(CountNode()-1).getId());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (at(i-1).getTypeTool() == Tool::NodePoint)
|
||||
{
|
||||
begin = *data->GeometricObject<VPointF>(at(i-1).getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return begin;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPointF VDetail::EndSegment(const VContainer *data, const int &i, bool reverse) const
|
||||
{
|
||||
if (i < 0 && i > CountNode()-1)
|
||||
{
|
||||
return QPointF();
|
||||
}
|
||||
|
||||
const QSharedPointer<VAbstractCurve> curve = data->GeometricObject<VAbstractCurve>(at(i).getId());
|
||||
|
||||
QVector<QPointF> points = curve->GetPoints();
|
||||
if (reverse)
|
||||
{
|
||||
points = VGObject::GetReversePoints(points);
|
||||
}
|
||||
|
||||
QPointF end = points.last();
|
||||
if (CountNode() > 2)
|
||||
{
|
||||
if (i == CountNode() - 1)
|
||||
{
|
||||
if (at(0).getTypeTool() == Tool::NodePoint)
|
||||
{
|
||||
end = *data->GeometricObject<VPointF>(at(0).getId());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (at(i+1).getTypeTool() == Tool::NodePoint)
|
||||
{
|
||||
end = *data->GeometricObject<VPointF>(at(i+1).getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return end;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief biasPoints bias point.
|
||||
* @param points vector of points.
|
||||
* @param mx offset respect to x.
|
||||
* @param my offset respect to y.
|
||||
* @return new vector biased points.
|
||||
*/
|
||||
QVector<QPointF> VDetail::biasPoints(const QVector<QPointF> &points, const qreal &mx, const qreal &my)
|
||||
{
|
||||
QVector<QPointF> p;
|
||||
for (qint32 i = 0; i < points.size(); ++i)
|
||||
{
|
||||
QPointF point = points.at(i);
|
||||
point.setX(point.x() + mx);
|
||||
point.setY(point.y() + my);
|
||||
p.append(point);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief append append in the end of list node.
|
||||
* @param node new node.
|
||||
*/
|
||||
void VDetail::append(const VNodeDetail &node)
|
||||
{
|
||||
d->nodes.append(node);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief CountNode return count nodes.
|
||||
* @return count.
|
||||
*/
|
||||
qint32 VDetail::CountNode() const
|
||||
{
|
||||
return d->nodes.size();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief getMx return bias for X axis.
|
||||
* @return x bias.
|
||||
*/
|
||||
qreal VDetail::getMx() const
|
||||
{
|
||||
return d->mx;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief setMx set bias for X axis.
|
||||
* @param value new x bias.
|
||||
*/
|
||||
void VDetail::setMx(const qreal &value)
|
||||
{
|
||||
d->mx = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief getMy get bias for y axis.
|
||||
* @return y axis.
|
||||
*/
|
||||
qreal VDetail::getMy() const
|
||||
{
|
||||
return d->my;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief setMy set bias for y axis.
|
||||
* @param value new y bias.
|
||||
*/
|
||||
void VDetail::setMy(const qreal &value)
|
||||
{
|
||||
d->my = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief getNodes return list of nodes.
|
||||
* @return list of nodes.
|
||||
*/
|
||||
QVector<VNodeDetail> VDetail::getNodes() const
|
||||
{
|
||||
return d->nodes;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief setNodes set list of nodes
|
||||
* @param value list of nodes
|
||||
*/
|
||||
// cppcheck-suppress unusedFunction
|
||||
void VDetail::setNodes(const QVector<VNodeDetail> &value)
|
||||
{
|
||||
d->nodes = value;
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vdetail.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date November 15, 2013
|
||||
**
|
||||
** @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) 2013-2015 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 VDETAIL_H
|
||||
#define VDETAIL_H
|
||||
|
||||
#include <qcompilerdetection.h>
|
||||
#include <QPointF>
|
||||
#include <QSharedDataPointer>
|
||||
#include <QString>
|
||||
#include <QTypeInfo>
|
||||
#include <QVector>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "../vlayout/vabstractdetail.h"
|
||||
#include "vnodedetail.h"
|
||||
|
||||
class QPainterPath;
|
||||
class QPointF;
|
||||
class VContainer;
|
||||
class VDetailData;
|
||||
class VNodeDetail;
|
||||
class VPatternInfoGeometry;
|
||||
class VPatternPieceData;
|
||||
class VGrainlineGeometry;
|
||||
|
||||
/**
|
||||
* @brief The VDetail class for path of object (points, arcs, splines).
|
||||
*/
|
||||
class VDetail :public VAbstractDetail
|
||||
{
|
||||
public:
|
||||
VDetail();
|
||||
VDetail(const QString &name, const QVector<VNodeDetail> &nodes);
|
||||
VDetail(const VDetail &detail);
|
||||
VDetail &operator=(const VDetail &detail);
|
||||
virtual ~VDetail() Q_DECL_OVERRIDE;
|
||||
|
||||
void append(const VNodeDetail &node);
|
||||
void Clear();
|
||||
void ClearNodes();
|
||||
qint32 CountNode() const;
|
||||
bool Containes(const quint32 &id)const;
|
||||
VNodeDetail & operator[](int indx);
|
||||
const VNodeDetail & at ( int indx ) const;
|
||||
|
||||
qreal getMx() const;
|
||||
void setMx(const qreal &value);
|
||||
|
||||
qreal getMy() const;
|
||||
void setMy(const qreal &value);
|
||||
|
||||
quint32 id() const;
|
||||
void setId(const quint32 &id);
|
||||
|
||||
bool IsInLayout() const;
|
||||
void SetInLayout(bool inLayout);
|
||||
|
||||
QVector<VNodeDetail> getNodes() const;
|
||||
void setNodes(const QVector<VNodeDetail> &value);
|
||||
|
||||
int indexOfNode(const quint32 &id) const;
|
||||
bool OnEdge(const quint32 &p1, const quint32 &p2)const;
|
||||
int Edge(const quint32 &p1, const quint32 &p2)const;
|
||||
void NodeOnEdge(const quint32 &index, VNodeDetail &p1, VNodeDetail &p2)const;
|
||||
VDetail RemoveEdge(const quint32 &index) const;
|
||||
|
||||
QVector<VNodeDetail> Missing(const VDetail &det) const;
|
||||
|
||||
QVector<QPointF> ContourPoints(const VContainer *data) const;
|
||||
QVector<QPointF> SeamAllowancePoints(const VContainer *data) const;
|
||||
|
||||
QPainterPath ContourPath(const VContainer *data) const;
|
||||
QPainterPath SeamAllowancePath(const VContainer *data) const;
|
||||
QVector<VNodeDetail> listNodePoint()const;
|
||||
|
||||
void SetPatternPieceData(const VPatternPieceData &data);
|
||||
VPatternPieceData& GetPatternPieceData();
|
||||
const VPatternPieceData& GetPatternPieceData() const;
|
||||
|
||||
void SetPatternInfo(const VPatternInfoGeometry &info);
|
||||
VPatternInfoGeometry& GetPatternInfo();
|
||||
const VPatternInfoGeometry& GetPatternInfo() const;
|
||||
VGrainlineGeometry& GetGrainlineGeometry();
|
||||
const VGrainlineGeometry& GetGrainlineGeometry() const;
|
||||
|
||||
private:
|
||||
QSharedDataPointer<VDetailData> d;
|
||||
|
||||
static int indexOfNode(const QVector<VNodeDetail> &list, const quint32 &id);
|
||||
|
||||
QPointF StartSegment(const VContainer *data, const int &i, bool reverse) const;
|
||||
QPointF EndSegment(const VContainer *data, const int &i, bool reverse) const;
|
||||
|
||||
static QVector<QPointF> biasPoints(const QVector<QPointF> &points, const qreal &mx, const qreal &my);
|
||||
};
|
||||
|
||||
Q_DECLARE_TYPEINFO(VDetail, Q_MOVABLE_TYPE);
|
||||
|
||||
#endif // VDETAIL_H
|
|
@ -1,91 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vdetail_p.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @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) 2013-2015 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 VDETAIL_P_H
|
||||
#define VDETAIL_P_H
|
||||
|
||||
#include <QSharedData>
|
||||
#include "vnodedetail.h"
|
||||
#include "vpatternpiecedata.h"
|
||||
#include "vpatterninfogeometry.h"
|
||||
#include "vgrainlinegeometry.h"
|
||||
#include "../ifc/ifcdef.h"
|
||||
#include "../vmisc/diagnostic.h"
|
||||
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_GCC("-Weffc++")
|
||||
|
||||
class VDetailData : public QSharedData
|
||||
{
|
||||
public:
|
||||
VDetailData()
|
||||
:_id(NULL_ID), nodes(QVector<VNodeDetail>()), mx(0), my(0), inLayout(true)
|
||||
{}
|
||||
|
||||
explicit VDetailData(const QVector<VNodeDetail> &nodes)
|
||||
:_id(NULL_ID), nodes(nodes), mx(0), my(0), inLayout(true)
|
||||
{}
|
||||
|
||||
VDetailData(const VDetailData &detail)
|
||||
:QSharedData(detail), _id(NULL_ID), nodes(detail.nodes), mx(detail.mx), my(detail.my),
|
||||
m_ppData(detail.m_ppData), m_piPatternInfo(detail.m_piPatternInfo),
|
||||
m_glGrainline(detail.m_glGrainline), inLayout(detail.inLayout)
|
||||
{}
|
||||
|
||||
~VDetailData() {}
|
||||
|
||||
/** @brief _id id detail. */
|
||||
quint32 _id;
|
||||
|
||||
/** @brief nodes list detail nodes. */
|
||||
QVector<VNodeDetail> nodes;
|
||||
|
||||
/** @brief mx bias x axis. */
|
||||
qreal mx;
|
||||
|
||||
/** @brief my bias y axis. */
|
||||
qreal my;
|
||||
|
||||
/** @brief Pattern piece data */
|
||||
VPatternPieceData m_ppData;
|
||||
/** @brief Pattern info coordinates */
|
||||
VPatternInfoGeometry m_piPatternInfo;
|
||||
/**
|
||||
* @brief m_glGrainline grainline geometry object
|
||||
*/
|
||||
VGrainlineGeometry m_glGrainline;
|
||||
|
||||
bool inLayout;
|
||||
|
||||
private:
|
||||
VDetailData &operator=(const VDetailData &) Q_DECL_EQ_DELETE;
|
||||
};
|
||||
|
||||
QT_WARNING_POP
|
||||
|
||||
#endif // VDETAIL_P_H
|
|
@ -4,7 +4,6 @@
|
|||
SOURCES += \
|
||||
$$PWD/vcontainer.cpp \
|
||||
$$PWD/calculator.cpp \
|
||||
$$PWD/vdetail.cpp \
|
||||
$$PWD/vnodedetail.cpp \
|
||||
$$PWD/vtranslatevars.cpp \
|
||||
$$PWD/variables/varcradius.cpp \
|
||||
|
@ -34,8 +33,6 @@ HEADERS += \
|
|||
$$PWD/stable.h \
|
||||
$$PWD/calculator.h \
|
||||
$$PWD/variables.h \
|
||||
$$PWD/vdetail.h \
|
||||
$$PWD/vdetail_p.h \
|
||||
$$PWD/vnodedetail.h \
|
||||
$$PWD/vnodedetail_p.h \
|
||||
$$PWD/vtranslatevars.h \
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
|
||||
#include "tst_vdetail.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "../vpatterndb/vpiece.h"
|
||||
#include "../vpatterndb/vpiecenode.h"
|
||||
#include "../vpatterndb/vpiecepath.h"
|
||||
#include "../vgeometry/vsplinepath.h"
|
||||
|
||||
#include <QtTest>
|
||||
|
@ -86,15 +89,17 @@ void TST_VDetail::ClearLoop()
|
|||
data->UpdateGObject(310, new VPointF(802.08718110236236, 1653.9337322834645, "Н5", 5.0000125984251973,
|
||||
9.9999874015748045));
|
||||
|
||||
VDetail detail;
|
||||
detail.setSeamAllowance(true);
|
||||
detail.setWidth(7);
|
||||
detail.setClosed(false);
|
||||
detail.append(VNodeDetail(304, Tool::NodePoint, NodeDetail::Contour));
|
||||
detail.append(VNodeDetail(307, Tool::NodePoint, NodeDetail::Contour));
|
||||
detail.append(VNodeDetail(308, Tool::NodeSplinePath, NodeDetail::Contour));
|
||||
detail.append(VNodeDetail(309, Tool::NodePoint, NodeDetail::Contour));
|
||||
detail.append(VNodeDetail(310, Tool::NodePoint, NodeDetail::Contour));
|
||||
VPiece detail;
|
||||
detail.SetSeamAllowance(true);
|
||||
detail.SetSAWidth(7);
|
||||
detail.GetPath().Append(VPieceNode(304, Tool::NodePoint));
|
||||
detail.GetPath().Append(VPieceNode(307, Tool::NodePoint));
|
||||
detail.GetPath().Append(VPieceNode(308, Tool::NodeSplinePath));
|
||||
detail.GetPath().Append(VPieceNode(309, Tool::NodePoint));
|
||||
detail.GetPath().Append(VPieceNode(310, Tool::NodePoint));
|
||||
// Closed
|
||||
detail.GetPath()[0].SetFormulaSABefore("0");
|
||||
detail.GetPath()[detail.GetPath().CountNodes()-1].SetFormulaSAAfter("0");
|
||||
|
||||
const QVector<QPointF> pointsEkv = detail.SeamAllowancePoints(data);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user