Be pendantic about notch errors.
--HG-- branch : release
This commit is contained in:
parent
ac3b8a2726
commit
10a20b08b8
|
@ -32,6 +32,7 @@
|
||||||
#include "../ifc/exception/vexceptionconversionerror.h"
|
#include "../ifc/exception/vexceptionconversionerror.h"
|
||||||
#include "../ifc/exception/vexceptionemptyparameter.h"
|
#include "../ifc/exception/vexceptionemptyparameter.h"
|
||||||
#include "../ifc/exception/vexceptionwrongid.h"
|
#include "../ifc/exception/vexceptionwrongid.h"
|
||||||
|
#include "../ifc/exception/vexceptioninvalidnotch.h"
|
||||||
#include "../vwidgets/vmaingraphicsview.h"
|
#include "../vwidgets/vmaingraphicsview.h"
|
||||||
#include "../version.h"
|
#include "../version.h"
|
||||||
#include "../vmisc/logging.h"
|
#include "../vmisc/logging.h"
|
||||||
|
@ -366,6 +367,12 @@ bool VApplication::notify(QObject *receiver, QEvent *event)
|
||||||
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||||
exit(V_EX_DATAERR);
|
exit(V_EX_DATAERR);
|
||||||
}
|
}
|
||||||
|
catch(const VExceptionInvalidNotch &e)
|
||||||
|
{
|
||||||
|
qCCritical(vApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Invalid notch.")),
|
||||||
|
qUtf8Printable(e.ErrorMessage()), qUtf8Printable(e.DetailedInformation()));
|
||||||
|
exit(V_EX_DATAERR);
|
||||||
|
}
|
||||||
catch (const VException &e)
|
catch (const VException &e)
|
||||||
{
|
{
|
||||||
qCCritical(vApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Something's wrong!!")),
|
qCCritical(vApp, "%s\n\n%s\n\n%s", qUtf8Printable(tr("Something's wrong!!")),
|
||||||
|
|
|
@ -8,7 +8,8 @@ HEADERS += \
|
||||||
$$PWD/vexceptionbadid.h \
|
$$PWD/vexceptionbadid.h \
|
||||||
$$PWD/vexception.h \
|
$$PWD/vexception.h \
|
||||||
$$PWD/vexceptionwrongid.h \
|
$$PWD/vexceptionwrongid.h \
|
||||||
$$PWD/vexceptionundo.h
|
$$PWD/vexceptionundo.h \
|
||||||
|
$$PWD/vexceptioninvalidnotch.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/vexceptionobjecterror.cpp \
|
$$PWD/vexceptionobjecterror.cpp \
|
||||||
|
@ -17,4 +18,5 @@ SOURCES += \
|
||||||
$$PWD/vexceptionbadid.cpp \
|
$$PWD/vexceptionbadid.cpp \
|
||||||
$$PWD/vexception.cpp \
|
$$PWD/vexception.cpp \
|
||||||
$$PWD/vexceptionwrongid.cpp \
|
$$PWD/vexceptionwrongid.cpp \
|
||||||
$$PWD/vexceptionundo.cpp
|
$$PWD/vexceptionundo.cpp \
|
||||||
|
$$PWD/vexceptioninvalidnotch.cpp
|
||||||
|
|
49
src/libs/ifc/exception/vexceptioninvalidnotch.cpp
Normal file
49
src/libs/ifc/exception/vexceptioninvalidnotch.cpp
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vexceptioninvalidnotch.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 28 9, 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) 2018 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 "vexceptioninvalidnotch.h"
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VExceptionInvalidNotch::VExceptionInvalidNotch(const QString &error)
|
||||||
|
:VException(error)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VExceptionInvalidNotch::VExceptionInvalidNotch(const VExceptionInvalidNotch &e)
|
||||||
|
:VException(e)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VExceptionInvalidNotch &VExceptionInvalidNotch::operator=(const VExceptionInvalidNotch &e)
|
||||||
|
{
|
||||||
|
if ( &e == this )
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
VException::operator=(e);
|
||||||
|
return *this;
|
||||||
|
}
|
42
src/libs/ifc/exception/vexceptioninvalidnotch.h
Normal file
42
src/libs/ifc/exception/vexceptioninvalidnotch.h
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vexceptioninvalidnotch.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 28 9, 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) 2018 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 VEXCEPTIONINVALIDNOTCH_H
|
||||||
|
#define VEXCEPTIONINVALIDNOTCH_H
|
||||||
|
|
||||||
|
#include "vexception.h"
|
||||||
|
|
||||||
|
class VExceptionInvalidNotch : public VException
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit VExceptionInvalidNotch(const QString &error);
|
||||||
|
VExceptionInvalidNotch(const VExceptionInvalidNotch &e);
|
||||||
|
VExceptionInvalidNotch &operator=(const VExceptionInvalidNotch &e);
|
||||||
|
virtual ~VExceptionInvalidNotch() V_NOEXCEPT_EXPR (true) Q_DECL_EQ_DEFAULT;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VEXCEPTIONINVALIDNOTCH_H
|
|
@ -33,6 +33,7 @@
|
||||||
#include "../vgeometry/vplacelabelitem.h"
|
#include "../vgeometry/vplacelabelitem.h"
|
||||||
#include "vcontainer.h"
|
#include "vcontainer.h"
|
||||||
#include "../vmisc/vabstractapplication.h"
|
#include "../vmisc/vabstractapplication.h"
|
||||||
|
#include "../ifc/exception/vexceptioninvalidnotch.h"
|
||||||
|
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -1250,19 +1251,28 @@ QVector<QLineF> VPiece::CreatePassmark(const QVector<VPieceNode> &path, int prev
|
||||||
VSAPoint passmarkSAPoint;
|
VSAPoint passmarkSAPoint;
|
||||||
if (not GetPassmarkSAPoint(path, passmarkIndex, data, passmarkSAPoint))
|
if (not GetPassmarkSAPoint(path, passmarkIndex, data, passmarkSAPoint))
|
||||||
{
|
{
|
||||||
return QVector<QLineF>(); // Something wrong
|
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'.")
|
||||||
|
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
|
||||||
|
qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg;
|
||||||
|
return QVector<QLineF>();
|
||||||
}
|
}
|
||||||
|
|
||||||
VSAPoint previousSAPoint;
|
VSAPoint previousSAPoint;
|
||||||
if (not GetPassmarkPreviousSAPoints(path, previousIndex, passmarkSAPoint, data,
|
if (not GetPassmarkPreviousSAPoints(path, previousIndex, passmarkSAPoint, data,
|
||||||
previousSAPoint))
|
previousSAPoint))
|
||||||
{
|
{
|
||||||
|
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'.")
|
||||||
|
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
|
||||||
|
qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg;
|
||||||
return QVector<QLineF>(); // Something wrong
|
return QVector<QLineF>(); // Something wrong
|
||||||
}
|
}
|
||||||
|
|
||||||
VSAPoint nextSAPoint;
|
VSAPoint nextSAPoint;
|
||||||
if (not GetPassmarkNextSAPoints(path, nextIndex, passmarkSAPoint, data, nextSAPoint))
|
if (not GetPassmarkNextSAPoints(path, nextIndex, passmarkSAPoint, data, nextSAPoint))
|
||||||
{
|
{
|
||||||
|
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'.")
|
||||||
|
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
|
||||||
|
qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg;
|
||||||
return QVector<QLineF>(); // Something wrong
|
return QVector<QLineF>(); // Something wrong
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1298,18 +1308,28 @@ QVector<QLineF> VPiece::SAPassmark(const QVector<VPieceNode> &path, VSAPoint &pr
|
||||||
{
|
{
|
||||||
if (seamAllowance.size() < 2)
|
if (seamAllowance.size() < 2)
|
||||||
{
|
{
|
||||||
|
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Seam allowance is "
|
||||||
|
"empty.").arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
|
||||||
|
qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg;
|
||||||
return QVector<QLineF>(); // Something wrong
|
return QVector<QLineF>(); // Something wrong
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF seamPassmarkSAPoint;
|
QPointF seamPassmarkSAPoint;
|
||||||
if (not GetSeamPassmarkSAPoint(previousSAPoint, passmarkSAPoint, nextSAPoint, data, seamPassmarkSAPoint))
|
if (not GetSeamPassmarkSAPoint(previousSAPoint, passmarkSAPoint, nextSAPoint, data, seamPassmarkSAPoint))
|
||||||
{
|
{
|
||||||
|
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Cannot find "
|
||||||
|
"position for a notch.")
|
||||||
|
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
|
||||||
|
qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg;
|
||||||
return QVector<QLineF>(); // Something wrong
|
return QVector<QLineF>(); // Something wrong
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not FixNotchPoint(seamAllowance, passmarkSAPoint, &seamPassmarkSAPoint))
|
if (not FixNotchPoint(seamAllowance, passmarkSAPoint, &seamPassmarkSAPoint))
|
||||||
{
|
{
|
||||||
// Show warning
|
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Unable to fix a "
|
||||||
|
"notch position.")
|
||||||
|
.arg(VPiecePath::NodeName(path, passmarkIndex, data), GetName());
|
||||||
|
qApp->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : qWarning() << errorMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
const qreal width = ToPixel(GetSAWidth(), *data->GetPatternUnit());
|
const qreal width = ToPixel(GetSAWidth(), *data->GetPatternUnit());
|
||||||
|
|
|
@ -660,6 +660,12 @@ QVector<quint32> VPiecePath::MissingNodes(const VPiecePath &path) const
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VPiecePath::NodeName(int nodeIndex, const VContainer *data) const
|
||||||
|
{
|
||||||
|
return NodeName(d->m_nodes, nodeIndex, data);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
int VPiecePath::indexOfNode(quint32 id) const
|
int VPiecePath::indexOfNode(quint32 id) const
|
||||||
{
|
{
|
||||||
|
@ -1178,3 +1184,22 @@ QVector<VSAPoint> VPiecePath::CurveSeamAllowanceSegment(const VContainer *data,
|
||||||
|
|
||||||
return pointsEkv;
|
return pointsEkv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString VPiecePath::NodeName(const QVector<VPieceNode> &nodes, int nodeIndex, const VContainer *data)
|
||||||
|
{
|
||||||
|
if (not nodes.isEmpty() && (nodeIndex < 0 || nodeIndex >= nodes.size()))
|
||||||
|
{
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QSharedPointer<VGObject> obj = data->GetGObject(nodes.at(nodeIndex).GetId());
|
||||||
|
return obj->name();
|
||||||
|
}
|
||||||
|
catch (VExceptionBadId) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
|
@ -103,6 +103,8 @@ public:
|
||||||
QList<quint32> Dependencies() const;
|
QList<quint32> Dependencies() const;
|
||||||
QVector<quint32> MissingNodes(const VPiecePath &path) const;
|
QVector<quint32> MissingNodes(const VPiecePath &path) const;
|
||||||
|
|
||||||
|
QString NodeName(int nodeIndex, const VContainer *data) const;
|
||||||
|
|
||||||
int indexOfNode(quint32 id) const;
|
int indexOfNode(quint32 id) const;
|
||||||
void NodeOnEdge(quint32 index, VPieceNode &p1, VPieceNode &p2) const;
|
void NodeOnEdge(quint32 index, VPieceNode &p1, VPieceNode &p2) const;
|
||||||
bool Contains(quint32 id) const;
|
bool Contains(quint32 id) const;
|
||||||
|
@ -135,6 +137,8 @@ public:
|
||||||
const QSharedPointer<VAbstractCurve> &curve,
|
const QSharedPointer<VAbstractCurve> &curve,
|
||||||
int i, bool reverse, qreal width);
|
int i, bool reverse, qreal width);
|
||||||
|
|
||||||
|
static QString NodeName(const QVector<VPieceNode> &nodes, int nodeIndex, const VContainer *data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSharedDataPointer<VPiecePathData> d;
|
QSharedDataPointer<VPiecePathData> d;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user