Performance optimization.
--HG-- branch : develop
This commit is contained in:
parent
cc2b991e78
commit
6f5199c5d1
|
@ -330,19 +330,18 @@ quint32 VDomDocument::GetParametrUInt(const QDomElement &domElement, const QStri
|
||||||
QString parametr;
|
QString parametr;
|
||||||
quint32 id = 0;
|
quint32 id = 0;
|
||||||
|
|
||||||
const QString message = QObject::tr("Can't convert toUInt parameter");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
parametr = GetParametrString(domElement, name, defValue);
|
parametr = GetParametrString(domElement, name, defValue);
|
||||||
id = parametr.toUInt(&ok);
|
id = parametr.toUInt(&ok);
|
||||||
if (ok == false)
|
if (ok == false)
|
||||||
{
|
{
|
||||||
throw VExceptionConversionError(message, name);
|
throw VExceptionConversionError(QObject::tr("Can't convert toUInt parameter"), name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const VExceptionEmptyParameter &e)
|
catch (const VExceptionEmptyParameter &e)
|
||||||
{
|
{
|
||||||
VExceptionConversionError excep(message, name);
|
VExceptionConversionError excep(QObject::tr("Can't convert toUInt parameter"), name);
|
||||||
excep.AddMoreInformation(e.ErrorMessage());
|
excep.AddMoreInformation(e.ErrorMessage());
|
||||||
throw excep;
|
throw excep;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,17 +48,6 @@ VToolRecord::VToolRecord(const quint32 &id, const Tool &typeTool, const QString
|
||||||
:id(id), typeTool(typeTool), nameDraw(nameDraw)
|
:id(id), typeTool(typeTool), nameDraw(nameDraw)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
bool VToolRecord::operator==(const VToolRecord &record) const
|
|
||||||
{
|
|
||||||
bool isEqual = false;
|
|
||||||
if (id == record.getId() && typeTool == record.getTypeTool() && nameDraw == record.getNameDraw())
|
|
||||||
{
|
|
||||||
isEqual = true;
|
|
||||||
}
|
|
||||||
return isEqual;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VToolRecord &VToolRecord::operator=(const VToolRecord &record)
|
VToolRecord &VToolRecord::operator=(const VToolRecord &record)
|
||||||
{
|
{
|
||||||
|
|
|
@ -123,4 +123,11 @@ inline void VToolRecord::setNameDraw(const QString &value)
|
||||||
nameDraw = value;
|
nameDraw = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
inline bool VToolRecord::operator==(const VToolRecord &record) const
|
||||||
|
{
|
||||||
|
// Id should be enough
|
||||||
|
return id == record.getId()/* && typeTool == record.getTypeTool() && nameDraw == record.getNameDraw()*/;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // VTOOLRECORD_H
|
#endif // VTOOLRECORD_H
|
||||||
|
|
|
@ -410,7 +410,7 @@ QVector<QPointF> VPiece::SeamAllowancePoints(const VContainer *data) const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QVector<QLineF> VPiece::PassmarksLines(const VContainer *data) const
|
QVector<QLineF> VPiece::PassmarksLines(const VContainer *data, const QVector<QPointF> &seamAllowance) const
|
||||||
{
|
{
|
||||||
const QVector<VPieceNode> unitedPath = GetUnitedPath(data);
|
const QVector<VPieceNode> unitedPath = GetUnitedPath(data);
|
||||||
if (not IsSeamAllowance() || not IsPassmarksPossible(unitedPath))
|
if (not IsSeamAllowance() || not IsPassmarksPossible(unitedPath))
|
||||||
|
@ -431,7 +431,7 @@ QVector<QLineF> VPiece::PassmarksLines(const VContainer *data) const
|
||||||
const int previousIndex = VPiecePath::FindInLoopNotExcludedUp(i, unitedPath);
|
const int previousIndex = VPiecePath::FindInLoopNotExcludedUp(i, unitedPath);
|
||||||
const int nextIndex = VPiecePath::FindInLoopNotExcludedDown(i, unitedPath);
|
const int nextIndex = VPiecePath::FindInLoopNotExcludedDown(i, unitedPath);
|
||||||
|
|
||||||
passmarks += CreatePassmark(unitedPath, previousIndex, i, nextIndex, data);
|
passmarks += CreatePassmark(unitedPath, previousIndex, i, nextIndex, data, seamAllowance);
|
||||||
}
|
}
|
||||||
|
|
||||||
return passmarks;
|
return passmarks;
|
||||||
|
@ -460,18 +460,23 @@ QPainterPath VPiece::MainPathPath(const VContainer *data) const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QPainterPath VPiece::SeamAllowancePath(const VContainer *data) const
|
QPainterPath VPiece::SeamAllowancePath(const VContainer *data) const
|
||||||
{
|
{
|
||||||
const QVector<QPointF> pointsEkv = SeamAllowancePoints(data);
|
return SeamAllowancePath(SeamAllowancePoints(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QPainterPath VPiece::SeamAllowancePath(const QVector<QPointF> &points) const
|
||||||
|
{
|
||||||
QPainterPath ekv;
|
QPainterPath ekv;
|
||||||
|
|
||||||
// seam allowence
|
// seam allowence
|
||||||
if (IsSeamAllowance() && not IsSeamAllowanceBuiltIn())
|
if (IsSeamAllowance() && not IsSeamAllowanceBuiltIn())
|
||||||
{
|
{
|
||||||
if (not pointsEkv.isEmpty())
|
if (not points.isEmpty())
|
||||||
{
|
{
|
||||||
ekv.moveTo(pointsEkv.at(0));
|
ekv.moveTo(points.at(0));
|
||||||
for (qint32 i = 1; i < pointsEkv.count(); ++i)
|
for (qint32 i = 1; i < points.count(); ++i)
|
||||||
{
|
{
|
||||||
ekv.lineTo(pointsEkv.at(i));
|
ekv.lineTo(points.at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
ekv.setFillRule(Qt::WindingFill);
|
ekv.setFillRule(Qt::WindingFill);
|
||||||
|
@ -482,9 +487,9 @@ QPainterPath VPiece::SeamAllowancePath(const VContainer *data) const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QPainterPath VPiece::PassmarksPath(const VContainer *data) const
|
QPainterPath VPiece::PassmarksPath(const VContainer *data, const QVector<QPointF> &seamAllowance) const
|
||||||
{
|
{
|
||||||
const QVector<QLineF> passmarks = PassmarksLines(data);
|
const QVector<QLineF> passmarks = PassmarksLines(data, seamAllowance);
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
|
|
||||||
// seam allowence
|
// seam allowence
|
||||||
|
@ -1048,7 +1053,8 @@ bool VPiece::IsPassmarkVisible(const QVector<VPieceNode> &path, int passmarkInde
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QVector<QLineF> VPiece::CreatePassmark(const QVector<VPieceNode> &path, int previousIndex, int passmarkIndex,
|
QVector<QLineF> VPiece::CreatePassmark(const QVector<VPieceNode> &path, int previousIndex, int passmarkIndex,
|
||||||
int nextIndex, const VContainer *data) const
|
int nextIndex, const VContainer *data,
|
||||||
|
const QVector<QPointF> &seamAllowance) const
|
||||||
{
|
{
|
||||||
SCASSERT(data != nullptr);
|
SCASSERT(data != nullptr);
|
||||||
|
|
||||||
|
@ -1079,7 +1085,7 @@ QVector<QLineF> VPiece::CreatePassmark(const QVector<VPieceNode> &path, int prev
|
||||||
if (not IsSeamAllowanceBuiltIn())
|
if (not IsSeamAllowanceBuiltIn())
|
||||||
{
|
{
|
||||||
QVector<QLineF> lines;
|
QVector<QLineF> lines;
|
||||||
lines += SAPassmark(path, previousSAPoint, passmarkSAPoint, nextSAPoint, data, passmarkIndex);
|
lines += SAPassmark(path, previousSAPoint, passmarkSAPoint, nextSAPoint, data, passmarkIndex, seamAllowance);
|
||||||
if (qApp->Settings()->IsDoublePassmark()
|
if (qApp->Settings()->IsDoublePassmark()
|
||||||
&& not IsHideMainPath()
|
&& not IsHideMainPath()
|
||||||
&& path.at(passmarkIndex).IsMainPathNode()
|
&& path.at(passmarkIndex).IsMainPathNode()
|
||||||
|
@ -1099,7 +1105,7 @@ QVector<QLineF> VPiece::CreatePassmark(const QVector<VPieceNode> &path, int prev
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QVector<QLineF> VPiece::SAPassmark(const QVector<VPieceNode> &path, VSAPoint &previousSAPoint,
|
QVector<QLineF> VPiece::SAPassmark(const QVector<VPieceNode> &path, VSAPoint &previousSAPoint,
|
||||||
const VSAPoint &passmarkSAPoint, VSAPoint &nextSAPoint, const VContainer *data,
|
const VSAPoint &passmarkSAPoint, VSAPoint &nextSAPoint, const VContainer *data,
|
||||||
int passmarkIndex) const
|
int passmarkIndex, const QVector<QPointF> &seamAllowance) const
|
||||||
{
|
{
|
||||||
QPointF seamPassmarkSAPoint;
|
QPointF seamPassmarkSAPoint;
|
||||||
if (not GetSeamPassmarkSAPoint(previousSAPoint, passmarkSAPoint, nextSAPoint, data, seamPassmarkSAPoint))
|
if (not GetSeamPassmarkSAPoint(previousSAPoint, passmarkSAPoint, nextSAPoint, data, seamPassmarkSAPoint))
|
||||||
|
@ -1135,12 +1141,15 @@ QVector<QLineF> VPiece::SAPassmark(const QVector<VPieceNode> &path, VSAPoint &pr
|
||||||
}
|
}
|
||||||
else if (node.GetPassmarkAngleType() == PassmarkAngleType::Intersection)
|
else if (node.GetPassmarkAngleType() == PassmarkAngleType::Intersection)
|
||||||
{
|
{
|
||||||
|
QVector<QPointF> seamPoints;
|
||||||
|
seamAllowance.isEmpty() ? seamPoints = SeamAllowancePoints(data) : seamPoints = seamAllowance;
|
||||||
|
|
||||||
{
|
{
|
||||||
// first passmark
|
// first passmark
|
||||||
QLineF line(previousSAPoint, passmarkSAPoint);
|
QLineF line(previousSAPoint, passmarkSAPoint);
|
||||||
line.setLength(line.length()*100); // Hope 100 is enough
|
line.setLength(line.length()*100); // Hope 100 is enough
|
||||||
|
|
||||||
const QVector<QPointF> intersections = VAbstractCurve::CurveIntersectLine(SeamAllowancePoints(data), line);
|
const QVector<QPointF> intersections = VAbstractCurve::CurveIntersectLine(seamPoints, line);
|
||||||
if (intersections.isEmpty())
|
if (intersections.isEmpty())
|
||||||
{
|
{
|
||||||
return QVector<QLineF>(); // Something wrong
|
return QVector<QLineF>(); // Something wrong
|
||||||
|
@ -1157,7 +1166,7 @@ QVector<QLineF> VPiece::SAPassmark(const QVector<VPieceNode> &path, VSAPoint &pr
|
||||||
QLineF line(nextSAPoint, passmarkSAPoint);
|
QLineF line(nextSAPoint, passmarkSAPoint);
|
||||||
line.setLength(line.length()*100); // Hope 100 is enough
|
line.setLength(line.length()*100); // Hope 100 is enough
|
||||||
|
|
||||||
const QVector<QPointF> intersections = VAbstractCurve::CurveIntersectLine(SeamAllowancePoints(data), line);
|
const QVector<QPointF> intersections = VAbstractCurve::CurveIntersectLine(seamPoints, line);
|
||||||
|
|
||||||
if (intersections.isEmpty())
|
if (intersections.isEmpty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,11 +69,14 @@ public:
|
||||||
QVector<QPointF> MainPathPoints(const VContainer *data) const;
|
QVector<QPointF> MainPathPoints(const VContainer *data) const;
|
||||||
QVector<VPointF> MainPathNodePoints(const VContainer *data, bool showExcluded = false) const;
|
QVector<VPointF> MainPathNodePoints(const VContainer *data, bool showExcluded = false) const;
|
||||||
QVector<QPointF> SeamAllowancePoints(const VContainer *data) const;
|
QVector<QPointF> SeamAllowancePoints(const VContainer *data) const;
|
||||||
QVector<QLineF> PassmarksLines(const VContainer *data) const;
|
QVector<QLineF> PassmarksLines(const VContainer *data,
|
||||||
|
const QVector<QPointF> &seamAllowance = QVector<QPointF>()) const;
|
||||||
|
|
||||||
QPainterPath MainPathPath(const VContainer *data) const;
|
QPainterPath MainPathPath(const VContainer *data) const;
|
||||||
QPainterPath SeamAllowancePath(const VContainer *data) const;
|
QPainterPath SeamAllowancePath(const VContainer *data) const;
|
||||||
QPainterPath PassmarksPath(const VContainer *data) const;
|
QPainterPath SeamAllowancePath(const QVector<QPointF> &points) const;
|
||||||
|
QPainterPath PassmarksPath(const VContainer *data,
|
||||||
|
const QVector<QPointF> &seamAllowance = QVector<QPointF>()) const;
|
||||||
|
|
||||||
bool IsInLayout() const;
|
bool IsInLayout() const;
|
||||||
void SetInLayout(bool inLayout);
|
void SetInLayout(bool inLayout);
|
||||||
|
@ -133,10 +136,11 @@ private:
|
||||||
bool IsPassmarkVisible(const QVector<VPieceNode> &path, int passmarkIndex) const;
|
bool IsPassmarkVisible(const QVector<VPieceNode> &path, int passmarkIndex) const;
|
||||||
|
|
||||||
QVector<QLineF> CreatePassmark(const QVector<VPieceNode> &path, int previousIndex, int passmarkIndex, int nextIndex,
|
QVector<QLineF> CreatePassmark(const QVector<VPieceNode> &path, int previousIndex, int passmarkIndex, int nextIndex,
|
||||||
const VContainer *data) const;
|
const VContainer *data,
|
||||||
|
const QVector<QPointF> &seamAllowance = QVector<QPointF>()) const;
|
||||||
QVector<QLineF> SAPassmark(const QVector<VPieceNode> &path, VSAPoint &previousSAPoint,
|
QVector<QLineF> SAPassmark(const QVector<VPieceNode> &path, VSAPoint &previousSAPoint,
|
||||||
const VSAPoint &passmarkSAPoint, VSAPoint &nextSAPoint, const VContainer *data,
|
const VSAPoint &passmarkSAPoint, VSAPoint &nextSAPoint, const VContainer *data,
|
||||||
int passmarkIndex) const;
|
int passmarkIndex, const QVector<QPointF> &seamAllowance = QVector<QPointF>()) const;
|
||||||
QVector<QLineF> BuiltInSAPassmark(const QVector<VPieceNode> &path, const VSAPoint &previousSAPoint,
|
QVector<QLineF> BuiltInSAPassmark(const QVector<VPieceNode> &path, const VSAPoint &previousSAPoint,
|
||||||
const VSAPoint &passmarkSAPoint, const VSAPoint &nextSAPoint,
|
const VSAPoint &passmarkSAPoint, const VSAPoint &nextSAPoint,
|
||||||
const VContainer *data, int passmarkIndex) const;
|
const VContainer *data, int passmarkIndex) const;
|
||||||
|
|
|
@ -1207,13 +1207,21 @@ void VToolSeamAllowance::RefreshGeometry()
|
||||||
}
|
}
|
||||||
|
|
||||||
this->setPath(path);
|
this->setPath(path);
|
||||||
m_passmarks->setPath(detail.PassmarksPath(this->getData()));
|
|
||||||
|
QVector<QPointF> seamAllowancePoints;
|
||||||
|
|
||||||
|
if (detail.IsSeamAllowance())
|
||||||
|
{
|
||||||
|
seamAllowancePoints = detail.SeamAllowancePoints(this->getData());
|
||||||
|
}
|
||||||
|
|
||||||
|
m_passmarks->setPath(detail.PassmarksPath(this->getData(), seamAllowancePoints));
|
||||||
|
|
||||||
this->setPos(detail.GetMx(), detail.GetMy());
|
this->setPos(detail.GetMx(), detail.GetMy());
|
||||||
|
|
||||||
if (detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn())
|
if (detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn())
|
||||||
{
|
{
|
||||||
path.addPath(detail.SeamAllowancePath(this->getData()));
|
path.addPath(detail.SeamAllowancePath(seamAllowancePoints));
|
||||||
path.setFillRule(Qt::OddEvenFill);
|
path.setFillRule(Qt::OddEvenFill);
|
||||||
m_seamAllowance->setPath(path);
|
m_seamAllowance->setPath(path);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user