Fixed issue #914. Filtering custom seam allowance paths prevent including more
than one. (grafted from 07fec74fad050330a1161776e27bb6c877354a59) --HG-- branch : develop
This commit is contained in:
parent
5bed94c31b
commit
6403941406
|
@ -10,6 +10,7 @@
|
|||
- [#909] Valentina produces wrong united path.
|
||||
- [#912] Labels in inactive state return to initial color.
|
||||
- [#913] Unable to save changes for piece path if it doesn't contain a point.
|
||||
- [#914] Filtering custom seam allowance paths prevent including more than one.
|
||||
|
||||
# Version 0.6.1 October 23, 2018
|
||||
- [#885] Regression. Broken support for multi size measurements.
|
||||
|
|
|
@ -55,6 +55,8 @@ int main(int argc, char *argv[])
|
|||
|
||||
// Need to internally move a node inside a piece main path
|
||||
qRegisterMetaTypeStreamOperators<VPieceNode>("VPieceNode");
|
||||
// Need to internally move a node inside a custom seam allowance path
|
||||
qRegisterMetaTypeStreamOperators<CustomSARecord>("CustomSARecord");
|
||||
|
||||
#ifndef Q_OS_MAC // supports natively
|
||||
InitHighDpiScaling(argc, argv);
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include <QGlobalStatic>
|
||||
|
||||
#include "vabstractapplication.h"
|
||||
#include "vdatastreamenum.h"
|
||||
|
||||
const qreal defCurveApproximationScale = 0.5;
|
||||
const qreal minCurveApproximationScale = 0.1;
|
||||
|
@ -844,3 +845,26 @@ void InitLanguages(QComboBox *combobox)
|
|||
combobox->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
// Friend functions
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDataStream &operator<<(QDataStream &out, const CustomSARecord &record)
|
||||
{
|
||||
out << record.startPoint;
|
||||
out << record.path;
|
||||
out << record.endPoint;
|
||||
out << record.reverse;
|
||||
out << record.includeType;
|
||||
return out;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDataStream &operator>>(QDataStream &in, CustomSARecord &record)
|
||||
{
|
||||
in >> record.startPoint;
|
||||
in >> record.path;
|
||||
in >> record.endPoint;
|
||||
in >> record.reverse;
|
||||
in >> record.includeType;
|
||||
return in;
|
||||
}
|
||||
|
|
|
@ -483,6 +483,9 @@ struct CustomSARecord
|
|||
includeType(PiecePathIncludeType::AsCustomSA)
|
||||
{}
|
||||
|
||||
friend QDataStream& operator<<(QDataStream& out, const CustomSARecord& record);
|
||||
friend QDataStream& operator>>(QDataStream& in, CustomSARecord& record);
|
||||
|
||||
quint32 startPoint;
|
||||
quint32 path;
|
||||
quint32 endPoint;
|
||||
|
|
59
src/libs/vmisc/vdatastreamenum.h
Normal file
59
src/libs/vmisc/vdatastreamenum.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vdatastreamenum.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 21 12, 2018
|
||||
**
|
||||
** @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) 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 DATASTREAM_ENUM_H
|
||||
#define DATASTREAM_ENUM_H
|
||||
|
||||
#include <QDataStream>
|
||||
#include <type_traits>
|
||||
|
||||
// (de)serialize enums into QDataStream
|
||||
|
||||
//a function that can serialize any enum into QDataStream
|
||||
//it stores the enum in a qint64
|
||||
template<typename Enum,
|
||||
typename = typename std::enable_if<std::is_enum<Enum>::value>::type>
|
||||
QDataStream& operator<<(QDataStream& stream, const Enum& e)
|
||||
{
|
||||
stream << static_cast<qint64>(e);
|
||||
return stream;
|
||||
}
|
||||
|
||||
//a function that can deserialize any enum from QDataStream
|
||||
//it reads the enum as if it was stored in qint64
|
||||
template<typename Enum,
|
||||
typename = typename std::enable_if<std::is_enum<Enum>::value>::type>
|
||||
QDataStream& operator>>(QDataStream& stream, Enum& e)
|
||||
{
|
||||
qint64 v;
|
||||
stream >> v;
|
||||
e = static_cast<Enum>(v);
|
||||
return stream;
|
||||
}
|
||||
|
||||
#endif // DATASTREAM_ENUM_H
|
|
@ -39,7 +39,8 @@ HEADERS += \
|
|||
$$PWD/backport/qoverload.h \
|
||||
$$PWD/testvapplication.h \
|
||||
$$PWD/literals.h \
|
||||
$$PWD/qt_dispatch/qt_dispatch.h
|
||||
$$PWD/qt_dispatch/qt_dispatch.h \
|
||||
$$PWD/vdatastreamenum.h
|
||||
|
||||
# Qt's versions
|
||||
# 5.2.0, 5.2.1
|
||||
|
|
|
@ -1014,48 +1014,35 @@ QVector<CustomSARecord> VPiece::FilterRecords(QVector<CustomSARecord> records) c
|
|||
return records;
|
||||
}
|
||||
|
||||
// cppcheck-suppress variableScope
|
||||
bool foundFilter = false;// Need in case "filter" will stay empty.
|
||||
CustomSARecord filter;
|
||||
int startIndex = d->m_path.CountNodes()-1;
|
||||
|
||||
for (int i = 0; i < records.size(); ++i)
|
||||
QVector<VPieceNode> path = d->m_path.GetNodes();
|
||||
QVector<CustomSARecord> filteredRecords;
|
||||
for (auto record : qAsConst(records))
|
||||
{
|
||||
const int indexStartPoint = d->m_path.indexOfNode(records.at(i).startPoint);
|
||||
if (indexStartPoint < startIndex)
|
||||
const int indexStartPoint = VPiecePath::indexOfNode(path, record.startPoint);
|
||||
const int indexEndPoint = VPiecePath::indexOfNode(path, record.endPoint);
|
||||
|
||||
if (indexStartPoint == -1 || indexEndPoint == -1)
|
||||
{
|
||||
startIndex = i;
|
||||
filter = records.at(i);
|
||||
// cppcheck-suppress unreadVariable
|
||||
foundFilter = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (not foundFilter)
|
||||
{
|
||||
return records; // return as is
|
||||
}
|
||||
|
||||
records.remove(startIndex);
|
||||
|
||||
QVector<CustomSARecord> secondRound;
|
||||
secondRound.reserve(records.size());
|
||||
for (auto &record : records)
|
||||
{
|
||||
const int indexStartPoint = d->m_path.indexOfNode(record.startPoint);
|
||||
const int indexEndPoint = d->m_path.indexOfNode(filter.endPoint);
|
||||
if (indexStartPoint > indexEndPoint)
|
||||
QVector<VPieceNode> midBefore;
|
||||
QVector<VPieceNode> midAfter;
|
||||
if (indexStartPoint <= indexEndPoint)
|
||||
{
|
||||
secondRound.append(record);
|
||||
midBefore = path.mid(0, indexStartPoint+1);
|
||||
midAfter = path.mid(indexEndPoint, path.size() - midBefore.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
midBefore = path.mid(indexEndPoint, indexStartPoint+1);
|
||||
}
|
||||
|
||||
path = midBefore + midAfter;
|
||||
filteredRecords.append(record);
|
||||
}
|
||||
|
||||
QVector<CustomSARecord> filtered;
|
||||
filtered.append(filter);
|
||||
|
||||
filtered += FilterRecords(secondRound);
|
||||
|
||||
return filtered;
|
||||
return filteredRecords;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <QDataStream>
|
||||
#include "../ifc/ifcdef.h"
|
||||
#include "../vmisc/diagnostic.h"
|
||||
#include "../vmisc/vdatastreamenum.h"
|
||||
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_GCC("-Weffc++")
|
||||
|
@ -143,15 +144,15 @@ private:
|
|||
QDataStream &operator<<(QDataStream &out, const VPieceNodeData &p)
|
||||
{
|
||||
out << p.m_id
|
||||
<< static_cast<int>(p.m_typeTool)
|
||||
<< p.m_typeTool
|
||||
<< p.m_reverse
|
||||
<< p.m_excluded
|
||||
<< p.m_isPassmark
|
||||
<< p.m_formulaWidthBefore
|
||||
<< p.m_formulaWidthAfter
|
||||
<< static_cast<int>(p.m_angleType)
|
||||
<< static_cast<int>(p.m_passmarkLineType)
|
||||
<< static_cast<int>(p.m_passmarkAngleType)
|
||||
<< p.m_angleType
|
||||
<< p.m_passmarkLineType
|
||||
<< p.m_passmarkAngleType
|
||||
<< p.m_isShowSecondPassmark;
|
||||
return out;
|
||||
}
|
||||
|
@ -159,28 +160,17 @@ QDataStream &operator<<(QDataStream &out, const VPieceNodeData &p)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QDataStream &operator>>(QDataStream &in, VPieceNodeData &p)
|
||||
{
|
||||
int typeTool = 0;
|
||||
int angleType = 0;
|
||||
int passmarkLineType = 0;
|
||||
int passmarkAngleType = 0;
|
||||
|
||||
in >> p.m_id
|
||||
>> typeTool
|
||||
>> p.m_typeTool
|
||||
>> p.m_reverse
|
||||
>> p.m_excluded
|
||||
>> p.m_isPassmark
|
||||
>> p.m_formulaWidthBefore
|
||||
>> p.m_formulaWidthAfter
|
||||
>> angleType
|
||||
>> passmarkLineType
|
||||
>> passmarkAngleType
|
||||
>> p.m_angleType
|
||||
>> p.m_passmarkLineType
|
||||
>> p.m_passmarkAngleType
|
||||
>> p.m_isShowSecondPassmark;
|
||||
|
||||
p.m_typeTool = static_cast<Tool>(typeTool);
|
||||
p.m_angleType = static_cast<PieceNodeAngle>(angleType);
|
||||
p.m_passmarkLineType = static_cast<PassmarkLineType>(passmarkLineType);
|
||||
p.m_passmarkAngleType = static_cast<PassmarkAngleType>(passmarkAngleType);
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
|
|
|
@ -1015,6 +1015,9 @@
|
|||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::InternalMove</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in New Issue
Block a user