Fix a crash. ref #984.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-11-07 18:07:07 +02:00
parent f1c95e9046
commit f8ca985ad7
12 changed files with 252 additions and 165 deletions

View File

@ -33,6 +33,10 @@
#include <QSharedPointer> #include <QSharedPointer>
#include "../vpatterndb/variables/vinternalvariable.h" #include "../vpatterndb/variables/vinternalvariable.h"
#include "../vpatterndb/variables/vcurvelength.h"
#include "../vmisc/typedef.h"
#include "../ifc/exception/vexceptionbadid.h"
#include "../vpatterndb/vcontainer.h"
class QPlainTextEdit; class QPlainTextEdit;
class QPushButton; class QPushButton;
@ -43,7 +47,6 @@ class QLabel;
class QWidget; class QWidget;
class QColor; class QColor;
class QLineEdit; class QLineEdit;
class VContainer;
class QListWidget; class QListWidget;
class VPieceNode; class VPieceNode;
@ -85,4 +88,32 @@ bool EachPointLabelIsUnique(QListWidget *listWidget);
QString DialogWarningIcon(); QString DialogWarningIcon();
QFont NodeFont(QFont font, bool nodeExcluded = false); QFont NodeFont(QFont font, bool nodeExcluded = false);
template <typename T>
void CurrentCurveLength(vidtype curveId, VContainer *data);
//---------------------------------------------------------------------------------------------------------------------
template<typename T>
void CurrentCurveLength(vidtype curveId, VContainer *data)
{
SCASSERT(data != nullptr)
VCurveLength *length = nullptr;
try
{
const QSharedPointer<T> curve = data->GeometricObject<T>(curveId);
length = new VCurveLength(curveId, curveId, curve.data(), *data->GetPatternUnit());
}
catch (const VExceptionBadId &)
{
QScopedPointer<T> curve(new T());
length = new VCurveLength(NULL_ID, NULL_ID, curve.data(), *data->GetPatternUnit());
}
SCASSERT(length != nullptr)
length->SetName(currentLength);
data->AddVariable(currentLength, length);
}
#endif // DIALOGTOOLBOX_H #endif // DIALOGTOOLBOX_H

View File

@ -261,11 +261,22 @@ void DialogAlongLine::closeEvent(QCloseEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogAlongLine::SetCurrentLength() void DialogAlongLine::SetCurrentLength()
{ {
const QSharedPointer<VPointF> p1 = data->GeometricObject<VPointF>(GetFirstPointId()); VLengthLine *length = nullptr;
const QSharedPointer<VPointF> p2 = data->GeometricObject<VPointF>(GetSecondPointId()); try
{
const QSharedPointer<VPointF> p1 = data->GeometricObject<VPointF>(GetFirstPointId());
const QSharedPointer<VPointF> p2 = data->GeometricObject<VPointF>(GetSecondPointId());
VLengthLine *length = new VLengthLine(p1.data(), GetFirstPointId(), p2.data(), length = new VLengthLine(p1.data(), GetFirstPointId(), p2.data(), GetSecondPointId(), *data->GetPatternUnit());
GetSecondPointId(), *data->GetPatternUnit()); }
catch (const VExceptionBadId &)
{
QScopedPointer<VPointF> p1(new VPointF());
QScopedPointer<VPointF> p2(new VPointF());
length = new VLengthLine(p1.data(), GetFirstPointId(), p2.data(), GetSecondPointId(), *data->GetPatternUnit());
}
SCASSERT(length != nullptr)
length->SetName(currentLength); length->SetName(currentLength);
VContainer *locData = const_cast<VContainer *> (data); VContainer *locData = const_cast<VContainer *> (data);

View File

@ -194,14 +194,22 @@ void DialogCubicBezier::PointNameChanged()
} }
else else
{ {
VCubicBezier spline(*GetP1(), *GetP2(), *GetP3(), *GetP4()); try
if (not data->IsUnique(spline.name()))
{ {
newDuplicate = static_cast<qint32>(DNumber(spline.name())); VCubicBezier spline(*GetP1(), *GetP2(), *GetP3(), *GetP4());
spline.SetDuplicate(static_cast<quint32>(newDuplicate));
if (not data->IsUnique(spline.name()))
{
newDuplicate = static_cast<qint32>(DNumber(spline.name()));
spline.SetDuplicate(static_cast<quint32>(newDuplicate));
}
ui->lineEditSplineName->setText(qApp->TrVars()->VarToUser(spline.name()));
}
catch (const VExceptionBadId &)
{
flagError = false;
color = errorColor;
} }
ui->lineEditSplineName->setText(qApp->TrVars()->VarToUser(spline.name()));
} }
} }
ChangeColor(ui->labelName, color); ChangeColor(ui->labelName, color);

View File

@ -219,45 +219,57 @@ void DialogCubicBezierPath::PointChanged(int row)
void DialogCubicBezierPath::currentPointChanged(int index) void DialogCubicBezierPath::currentPointChanged(int index)
{ {
const quint32 id = qvariant_cast<quint32>(ui->comboBoxPoint->itemData(index)); const quint32 id = qvariant_cast<quint32>(ui->comboBoxPoint->itemData(index));
QListWidgetItem *item = ui->listWidget->item( ui->listWidget->currentRow() );
const auto point = data->GeometricObject<VPointF>(id);
DataPoint(*point);
item->setData(Qt::UserRole, QVariant::fromValue(*point));
QColor color; QColor color;
if (not IsPathValid())
try
{
QListWidgetItem *item = ui->listWidget->item( ui->listWidget->currentRow() );
const auto point = data->GeometricObject<VPointF>(id);
DataPoint(*point);
item->setData(Qt::UserRole, QVariant::fromValue(*point));
if (not IsPathValid())
{
flagError = false;
color = errorColor;
ui->lineEditSplPathName->setText(tr("Invalid spline path"));
}
else
{
flagError = true;
color = OkColor(this);
auto first = qvariant_cast<VPointF>(ui->listWidget->item(0)->data(Qt::UserRole));
auto last = qvariant_cast<VPointF>(ui->listWidget->item(ui->listWidget->count()-1)->data(Qt::UserRole));
if (first.id() == path.at(0).id() && last.id() == path.at(path.CountPoints()-1).id())
{
newDuplicate = -1;
ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(path.name()));
}
else
{
VCubicBezierPath newPath = ExtractPath();
if (not data->IsUnique(newPath.name()))
{
newDuplicate = static_cast<qint32>(DNumber(newPath.name()));
newPath.SetDuplicate(static_cast<quint32>(newDuplicate));
}
ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(newPath.name()));
}
}
}
catch (const VExceptionBadId &)
{ {
flagError = false; flagError = false;
color = errorColor; color = errorColor;
ui->lineEditSplPathName->setText(tr("Invalid spline path")); ui->lineEditSplPathName->setText(tr("Cannot find point with id %1").arg(id));
} }
else
{
flagError = true;
color = OkColor(this);
auto first = qvariant_cast<VPointF>(ui->listWidget->item(0)->data(Qt::UserRole));
auto last = qvariant_cast<VPointF>(ui->listWidget->item(ui->listWidget->count()-1)->data(Qt::UserRole));
if (first.id() == path.at(0).id() && last.id() == path.at(path.CountPoints()-1).id())
{
newDuplicate = -1;
ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(path.name()));
}
else
{
VCubicBezierPath newPath = ExtractPath();
if (not data->IsUnique(newPath.name()))
{
newDuplicate = static_cast<qint32>(DNumber(newPath.name()));
newPath.SetDuplicate(static_cast<quint32>(newDuplicate));
}
ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(newPath.name()));
}
}
ChangeColor(ui->labelName, color); ChangeColor(ui->labelName, color);
ChangeColor(ui->labelPoint, color); ChangeColor(ui->labelPoint, color);
CheckState(); CheckState();

View File

@ -38,7 +38,6 @@
#include "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/vtranslatevars.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/variables/vcurvelength.h"
#include "../../visualization/path/vistoolcutarc.h" #include "../../visualization/path/vistoolcutarc.h"
#include "../../visualization/visualization.h" #include "../../visualization/visualization.h"
#include "../ifc/xml/vabstractpattern.h" #include "../ifc/xml/vabstractpattern.h"
@ -196,14 +195,7 @@ void DialogCutArc::closeEvent(QCloseEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCutArc::ArcChanged() void DialogCutArc::ArcChanged()
{ {
vidtype arcId = getArcId(); CurrentCurveLength<VArc>(getArcId(), const_cast<VContainer *> (data));
const QSharedPointer<VAbstractCurve> arc = data->GeometricObject<VArc>(arcId);
VCurveLength *length = new VCurveLength(arcId, arcId, arc.data(), *data->GetPatternUnit());
length->SetName(currentLength);
VContainer *locData = const_cast<VContainer *> (data);
locData->AddVariable(currentLength, length);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -38,7 +38,6 @@
#include "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/vtranslatevars.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/variables/vcurvelength.h"
#include "../../visualization/path/vistoolcutspline.h" #include "../../visualization/path/vistoolcutspline.h"
#include "../../visualization/visualization.h" #include "../../visualization/visualization.h"
#include "../ifc/xml/vabstractpattern.h" #include "../ifc/xml/vabstractpattern.h"
@ -203,14 +202,7 @@ void DialogCutSpline::closeEvent(QCloseEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCutSpline::SplineChanged() void DialogCutSpline::SplineChanged()
{ {
vidtype splId = getSplineId(); CurrentCurveLength<VSpline>(getSplineId(), const_cast<VContainer *> (data));
const QSharedPointer<VSpline> spl = data->GeometricObject<VSpline>(splId);
VCurveLength *length = new VCurveLength(splId, splId, spl.data(), *data->GetPatternUnit());
length->SetName(currentLength);
VContainer *locData = const_cast<VContainer *> (data);
locData->AddVariable(currentLength, length);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -38,7 +38,6 @@
#include "../vpatterndb/vtranslatevars.h" #include "../vpatterndb/vtranslatevars.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/variables/vcurvelength.h"
#include "../../visualization/path/vistoolcutsplinepath.h" #include "../../visualization/path/vistoolcutsplinepath.h"
#include "../../visualization/visualization.h" #include "../../visualization/visualization.h"
#include "../ifc/xml/vabstractpattern.h" #include "../ifc/xml/vabstractpattern.h"
@ -203,14 +202,7 @@ void DialogCutSplinePath::closeEvent(QCloseEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCutSplinePath::SplinePathChanged() void DialogCutSplinePath::SplinePathChanged()
{ {
vidtype splPathId = getSplinePathId(); CurrentCurveLength<VSplinePath>(getSplinePathId(), const_cast<VContainer *> (data));
const QSharedPointer<VSplinePath> splPath = data->GeometricObject<VSplinePath>(splPathId);
VCurveLength *length = new VCurveLength(splPathId, splPathId, splPath.data(), *data->GetPatternUnit());
length->SetName(currentLength);
VContainer *locData = const_cast<VContainer *> (data);
locData->AddVariable(currentLength, length);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -268,21 +268,31 @@ void DialogHeight::PointNameChanged()
set.insert(p1LineId); set.insert(p1LineId);
set.insert(p2LineId); set.insert(p2LineId);
const QPointF basePoint = static_cast<QPointF>(*data->GeometricObject<VPointF>(basePointId));
const QPointF p1Line = static_cast<QPointF>(*data->GeometricObject<VPointF>(p1LineId));
const QPointF p2Line = static_cast<QPointF>(*data->GeometricObject<VPointF>(p2LineId));
QColor color; QColor color;
if (set.size() != 3 || VGObject::ClosestPoint(QLineF(p1Line, p2Line), basePoint) == QPointF())
try
{
const QPointF basePoint = static_cast<QPointF>(*data->GeometricObject<VPointF>(basePointId));
const QPointF p1Line = static_cast<QPointF>(*data->GeometricObject<VPointF>(p1LineId));
const QPointF p2Line = static_cast<QPointF>(*data->GeometricObject<VPointF>(p2LineId));
if (set.size() != 3 || VGObject::ClosestPoint(QLineF(p1Line, p2Line), basePoint) == QPointF())
{
flagError = false;
color = errorColor;
}
else
{
flagError = true;
color = OkColor(this);
}
}
catch (const VExceptionBadId &)
{ {
flagError = false; flagError = false;
color = errorColor; color = errorColor;
} }
else
{
flagError = true;
color = OkColor(this);
}
ChangeColor(ui->labelBasePoint, color); ChangeColor(ui->labelBasePoint, color);
ChangeColor(ui->labelFirstLinePoint, color); ChangeColor(ui->labelFirstLinePoint, color);
ChangeColor(ui->labelSecondLinePoint, color); ChangeColor(ui->labelSecondLinePoint, color);

View File

@ -216,38 +216,49 @@ void DialogLineIntersect::PointChanged()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersect::PointNameChanged() void DialogLineIntersect::PointNameChanged()
{ {
QSet<quint32> set;
const quint32 p1Line1Id = getCurrentObjectId(ui->comboBoxP1Line1);
const quint32 p2Line1Id = getCurrentObjectId(ui->comboBoxP2Line1);
const quint32 p1Line2Id = getCurrentObjectId(ui->comboBoxP1Line2);
const quint32 p2Line2Id = getCurrentObjectId(ui->comboBoxP2Line2);
set.insert(p1Line1Id);
set.insert(p2Line1Id);
set.insert(p1Line2Id);
set.insert(p2Line2Id);
const QSharedPointer<VPointF> p1Line1 = data->GeometricObject<VPointF>(p1Line1Id);
const QSharedPointer<VPointF> p2Line1 = data->GeometricObject<VPointF>(p2Line1Id);
const QSharedPointer<VPointF> p1Line2 = data->GeometricObject<VPointF>(p1Line2Id);
const QSharedPointer<VPointF> p2Line2 = data->GeometricObject<VPointF>(p2Line2Id);
QLineF line1(static_cast<QPointF>(*p1Line1), static_cast<QPointF>(*p2Line1));
QLineF line2(static_cast<QPointF>(*p1Line2), static_cast<QPointF>(*p2Line2));
QPointF fPoint;
QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
QColor color; QColor color;
if (set.size() < 3 || intersect == QLineF::NoIntersection)
try
{
QSet<quint32> set;
const quint32 p1Line1Id = getCurrentObjectId(ui->comboBoxP1Line1);
const quint32 p2Line1Id = getCurrentObjectId(ui->comboBoxP2Line1);
const quint32 p1Line2Id = getCurrentObjectId(ui->comboBoxP1Line2);
const quint32 p2Line2Id = getCurrentObjectId(ui->comboBoxP2Line2);
set.insert(p1Line1Id);
set.insert(p2Line1Id);
set.insert(p1Line2Id);
set.insert(p2Line2Id);
const QSharedPointer<VPointF> p1Line1 = data->GeometricObject<VPointF>(p1Line1Id);
const QSharedPointer<VPointF> p2Line1 = data->GeometricObject<VPointF>(p2Line1Id);
const QSharedPointer<VPointF> p1Line2 = data->GeometricObject<VPointF>(p1Line2Id);
const QSharedPointer<VPointF> p2Line2 = data->GeometricObject<VPointF>(p2Line2Id);
QLineF line1(static_cast<QPointF>(*p1Line1), static_cast<QPointF>(*p2Line1));
QLineF line2(static_cast<QPointF>(*p1Line2), static_cast<QPointF>(*p2Line2));
QPointF fPoint;
QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
if (set.size() < 3 || intersect == QLineF::NoIntersection)
{
flagError = false;
color = errorColor;
}
else
{
flagError = true;
color = OkColor(this);
}
}
catch (const VExceptionBadId &)
{ {
flagError = false; flagError = false;
color = errorColor; color = errorColor;
} }
else
{
flagError = true;
color = OkColor(this);
}
ChangeColor(ui->labelP1Line1, color); ChangeColor(ui->labelP1Line1, color);
ChangeColor(ui->labelP2Line1, color); ChangeColor(ui->labelP2Line1, color);
ChangeColor(ui->labelP1Line2, color); ChangeColor(ui->labelP1Line2, color);
@ -268,20 +279,20 @@ void DialogLineIntersect::ShowVisualization()
*/ */
bool DialogLineIntersect::CheckIntersecion() bool DialogLineIntersect::CheckIntersecion()
{ {
const QSharedPointer<VPointF> p1L1 = data->GeometricObject<VPointF>(GetP1Line1()); try
const QSharedPointer<VPointF> p2L1 = data->GeometricObject<VPointF>(GetP2Line1());
const QSharedPointer<VPointF> p1L2 = data->GeometricObject<VPointF>(GetP1Line2());
const QSharedPointer<VPointF> p2L2 = data->GeometricObject<VPointF>(GetP2Line2());
QLineF line1(static_cast<QPointF>(*p1L1), static_cast<QPointF>(*p2L1));
QLineF line2(static_cast<QPointF>(*p1L2), static_cast<QPointF>(*p2L2));
QPointF fPoint;
QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection)
{ {
return true; const QSharedPointer<VPointF> p1L1 = data->GeometricObject<VPointF>(GetP1Line1());
const QSharedPointer<VPointF> p2L1 = data->GeometricObject<VPointF>(GetP2Line1());
const QSharedPointer<VPointF> p1L2 = data->GeometricObject<VPointF>(GetP1Line2());
const QSharedPointer<VPointF> p2L2 = data->GeometricObject<VPointF>(GetP2Line2());
QLineF line1(static_cast<QPointF>(*p1L1), static_cast<QPointF>(*p2L1));
QLineF line2(static_cast<QPointF>(*p1L2), static_cast<QPointF>(*p2L2));
QPointF fPoint;
QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
return intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection;
} }
else catch (const VExceptionBadId &)
{ {
return false; return false;
} }

View File

@ -217,11 +217,18 @@ void DialogRotation::ShowDialog(bool click)
/*We will ignore click if pointer is in point circle*/ /*We will ignore click if pointer is in point circle*/
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene()); VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr) SCASSERT(scene != nullptr)
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetOrigPointId()); try
const QLineF line = QLineF(static_cast<QPointF>(*point), scene->getScenePos()); {
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetOrigPointId());
const QLineF line = QLineF(static_cast<QPointF>(*point), scene->getScenePos());
//Radius of point circle, but little bigger. Need handle with hover sizes. //Radius of point circle, but little bigger. Need handle with hover sizes.
if (line.length() <= ScaledRadius(SceneScale(qApp->getCurrentScene()))*1.5) if (line.length() <= ScaledRadius(SceneScale(qApp->getCurrentScene()))*1.5)
{
return;
}
}
catch (const VExceptionBadId &)
{ {
return; return;
} }

View File

@ -487,15 +487,22 @@ void DialogSpline::PointNameChanged()
} }
else else
{ {
VSpline spline(*GetP1(), *GetP4(), spl.GetStartAngle(), spl.GetEndAngle(), spl.GetKasm1(), spl.GetKasm2(), try
spl.GetKcurve());
if (not data->IsUnique(spline.name()))
{ {
newDuplicate = static_cast<qint32>(DNumber(spline.name())); VSpline spline(*GetP1(), *GetP4(), spl.GetStartAngle(), spl.GetEndAngle(), spl.GetKasm1(),
spline.SetDuplicate(static_cast<quint32>(newDuplicate)); spl.GetKasm2(), spl.GetKcurve());
if (not data->IsUnique(spline.name()))
{
newDuplicate = static_cast<qint32>(DNumber(spline.name()));
spline.SetDuplicate(static_cast<quint32>(newDuplicate));
}
ui->lineEditSplineName->setText(qApp->TrVars()->VarToUser(spline.name()));
}
catch (const VExceptionBadId &)
{
flagError = false;
color = errorColor;
} }
ui->lineEditSplineName->setText(qApp->TrVars()->VarToUser(spline.name()));
} }
} }
ChangeColor(ui->labelName, color); ChangeColor(ui->labelName, color);

View File

@ -617,48 +617,62 @@ void DialogSplinePath::PointChanged(int row)
void DialogSplinePath::currentPointChanged(int index) void DialogSplinePath::currentPointChanged(int index)
{ {
const quint32 id = qvariant_cast<quint32>(ui->comboBoxPoint->itemData(index)); const quint32 id = qvariant_cast<quint32>(ui->comboBoxPoint->itemData(index));
QListWidgetItem *item = ui->listWidget->item( ui->listWidget->currentRow() );
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
const auto point = data->GeometricObject<VPointF>(id);
p.SetP(*point);
DataPoint(p);
item->setData(Qt::UserRole, QVariant::fromValue(p));
ShowPointIssue(p.P().name());
QColor color; QColor color;
if (not IsPathValid())
try
{
QListWidgetItem *item = ui->listWidget->item( ui->listWidget->currentRow() );
VSplinePoint p = qvariant_cast<VSplinePoint>(item->data(Qt::UserRole));
const auto point = data->GeometricObject<VPointF>(id);
p.SetP(*point);
DataPoint(p);
item->setData(Qt::UserRole, QVariant::fromValue(p));
ShowPointIssue(p.P().name());
if (not IsPathValid())
{
flagError = false;
color = errorColor;
ui->lineEditSplPathName->setText(tr("Invalid spline path"));
}
else
{
flagError = true;
color = OkColor(this);
auto first = qvariant_cast<VSplinePoint>(ui->listWidget->item(0)->data(Qt::UserRole));
auto last = qvariant_cast<VSplinePoint>(ui->listWidget->item(ui->listWidget->count()-1)->data(Qt::UserRole));
if (first.P().id() == path.at(0).P().id() && last.P().id() == path.at(path.CountPoints()-1).P().id())
{
newDuplicate = -1;
ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(path.name()));
}
else
{
VSplinePath newPath = ExtractPath();
if (not data->IsUnique(newPath.name()))
{
newDuplicate = static_cast<qint32>(DNumber(newPath.name()));
newPath.SetDuplicate(static_cast<quint32>(newDuplicate));
}
ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(newPath.name()));
}
}
}
catch (const VExceptionBadId &)
{ {
flagError = false; flagError = false;
color = errorColor; color = errorColor;
ui->lineEditSplPathName->setText(tr("Invalid spline path")); ui->lineEditSplPathName->setText(tr("Cannot find point with id %1").arg(id));
} }
else
{
flagError = true;
color = OkColor(this);
auto first = qvariant_cast<VSplinePoint>(ui->listWidget->item(0)->data(Qt::UserRole));
auto last = qvariant_cast<VSplinePoint>(ui->listWidget->item(ui->listWidget->count()-1)->data(Qt::UserRole));
if (first.P().id() == path.at(0).P().id() && last.P().id() == path.at(path.CountPoints()-1).P().id())
{
newDuplicate = -1;
ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(path.name()));
}
else
{
VSplinePath newPath = ExtractPath();
if (not data->IsUnique(newPath.name()))
{
newDuplicate = static_cast<qint32>(DNumber(newPath.name()));
newPath.SetDuplicate(static_cast<quint32>(newDuplicate));
}
ui->lineEditSplPathName->setText(qApp->TrVars()->VarToUser(newPath.name()));
}
}
ChangeColor(ui->labelName, color); ChangeColor(ui->labelName, color);
ChangeColor(ui->labelPoint, color); ChangeColor(ui->labelPoint, color);
CheckState(); CheckState();