New warning. Grainline is not valid.
This commit is contained in:
parent
4fe4efe859
commit
5eb8784cd4
|
@ -9,6 +9,7 @@
|
|||
- Improve multisize measurements format. Allow decimal step 0.5.
|
||||
- Improve restrict dimension dialog. Disable not available combinations.
|
||||
- Improve multisize measurements format. Allow excluding combinations inside min/max range.
|
||||
- New warning. Grainline is not valid.
|
||||
|
||||
# Version 0.7.41 Dec 4, 2020
|
||||
- Bug fixes.
|
||||
|
|
|
@ -1919,3 +1919,19 @@ QVector<QPointF> VAbstractPiece::GrainlinePoints(const VGrainlineData &geom, con
|
|||
|
||||
return CorrectPosition(boundingRect, v);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPainterPath VAbstractPiece::PainterPath(const QVector<QPointF> &points)
|
||||
{
|
||||
QPainterPath path;
|
||||
path.setFillRule(Qt::WindingFill);
|
||||
|
||||
path.moveTo(points.at(0));
|
||||
for (qint32 i = 1; i < points.count(); ++i)
|
||||
{
|
||||
path.lineTo(points.at(i));
|
||||
}
|
||||
path.lineTo(points.at(0));
|
||||
|
||||
return path;
|
||||
}
|
||||
|
|
|
@ -114,6 +114,8 @@ public:
|
|||
static QVector<QPointF> GrainlinePoints(const VGrainlineData &geom, const VContainer *pattern,
|
||||
const QRectF &boundingRect, qreal &dAng);
|
||||
|
||||
static QPainterPath PainterPath(const QVector<QPointF> &points);
|
||||
|
||||
friend QDataStream& operator<< (QDataStream& dataStream, const VAbstractPiece& piece);
|
||||
friend QDataStream& operator>> (QDataStream& dataStream, VAbstractPiece& piece);
|
||||
|
||||
|
|
|
@ -305,7 +305,7 @@ bool VLayoutPaper::SaveResult(const VBestSquare &bestResult, const VLayoutPiece
|
|||
VCachedPositions positionChache;
|
||||
QVector<QPointF> layoutPoints = workDetail.GetLayoutAllowancePoints();
|
||||
positionChache.boundingRect = VLayoutPiece::BoundingRect(layoutPoints);
|
||||
positionChache.layoutAllowancePath = VLayoutPiece::PainterPath(layoutPoints);
|
||||
positionChache.layoutAllowancePath = VAbstractPiece::PainterPath(layoutPoints);
|
||||
d->positionsCache.append(positionChache);
|
||||
|
||||
#ifdef LAYOUT_DEBUG
|
||||
|
|
|
@ -1140,22 +1140,6 @@ QPainterPath VLayoutPiece::LayoutAllowancePath() const
|
|||
return PainterPath(GetLayoutAllowancePoints());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QPainterPath VLayoutPiece::PainterPath(const QVector<QPointF> &points)
|
||||
{
|
||||
QPainterPath path;
|
||||
path.setFillRule(Qt::WindingFill);
|
||||
|
||||
path.moveTo(points.at(0));
|
||||
for (qint32 i = 1; i < points.count(); ++i)
|
||||
{
|
||||
path.lineTo(points.at(i));
|
||||
}
|
||||
path.lineTo(points.at(0));
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QGraphicsItem *VLayoutPiece::GetItem(bool textAsPaths) const
|
||||
{
|
||||
|
|
|
@ -149,8 +149,6 @@ public:
|
|||
QPainterPath ContourPath() const;
|
||||
QPainterPath LayoutAllowancePath() const;
|
||||
|
||||
static QPainterPath PainterPath(const QVector<QPointF> &points);
|
||||
|
||||
Q_REQUIRED_RESULT QGraphicsItem *GetItem(bool textAsPaths) const;
|
||||
|
||||
bool IsLayoutAllowanceValid() const;
|
||||
|
|
|
@ -471,12 +471,12 @@ VPosition::CrossingType VPosition::Crossing(const VLayoutPiece &detail) const
|
|||
|
||||
const QVector<QPointF> layoutPoints = detail.GetLayoutAllowancePoints();
|
||||
const QRectF layoutBoundingRect = VLayoutPiece::BoundingRect(layoutPoints);
|
||||
const QPainterPath layoutAllowancePath = VLayoutPiece::PainterPath(layoutPoints);
|
||||
const QPainterPath layoutAllowancePath = VAbstractPiece::PainterPath(layoutPoints);
|
||||
|
||||
const QVector<QPointF> contourPoints = detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn() ?
|
||||
detail.GetMappedSeamAllowancePoints() : detail.GetMappedContourPoints();
|
||||
const QRectF detailBoundingRect = VLayoutPiece::BoundingRect(contourPoints);
|
||||
const QPainterPath contourPath = VLayoutPiece::PainterPath(contourPoints);
|
||||
const QPainterPath contourPath = VAbstractPiece::PainterPath(contourPoints);
|
||||
|
||||
for(auto &position : m_data.positionsCache)
|
||||
{
|
||||
|
|
|
@ -681,6 +681,14 @@ void VToolSeamAllowance::UpdateGrainline()
|
|||
m_grainLine->UpdateGeometry(pos, dRotation, ToPixel(dLength, *VDataTool::data.GetPatternUnit()),
|
||||
geom.GetArrowType());
|
||||
m_grainLine->show();
|
||||
|
||||
if (m_geometryIsReady && not IsGrainlinePositionValid())
|
||||
{
|
||||
const QString errorMsg = QObject::tr("Piece '%1'. Grainline is not valid.")
|
||||
.arg(detail.GetName());
|
||||
qApp->IsPedantic() ? throw VException(errorMsg) :
|
||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1366,6 +1374,9 @@ void VToolSeamAllowance::RefreshGeometry(bool updateChildren)
|
|||
m_passmarks->setPath(futurePassmarks.result());
|
||||
|
||||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||
|
||||
// Now we can start checking validity of the grainline
|
||||
m_geometryIsReady = true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -1950,6 +1961,20 @@ QList<VToolSeamAllowance *> VToolSeamAllowance::SelectedTools() const
|
|||
return tools;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VToolSeamAllowance::IsGrainlinePositionValid() const -> bool
|
||||
{
|
||||
QLineF grainLine = m_grainLine->Grainline();
|
||||
QPainterPath grainLinePath = VAbstractPiece::PainterPath(QVector<QPointF>{grainLine.p1(), grainLine.p2()});
|
||||
|
||||
const VPiece detail = VAbstractTool::data.GetPiece(m_id);
|
||||
const QVector<QPointF> contourPoints = detail.IsSeamAllowance() && not detail.IsSeamAllowanceBuiltIn() ?
|
||||
detail.SeamAllowancePoints(getData()) : detail.MainPathPoints(getData());
|
||||
const QPainterPath contourPath = VAbstractPiece::PainterPath(contourPoints);
|
||||
|
||||
return contourPath.contains(grainLinePath);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolSeamAllowance::AddPointRecords(VAbstractPattern *doc, QDomElement &domElement,
|
||||
const QVector<quint32> &records, const QString &tag)
|
||||
|
|
|
@ -191,6 +191,9 @@ private:
|
|||
|
||||
bool m_acceptHoverEvents;
|
||||
|
||||
/** @brief m_geometryIsReady is true when a piece's geometry is ready and checks for validity can be enabled. */
|
||||
bool m_geometryIsReady{false};
|
||||
|
||||
VToolSeamAllowance(const VToolSeamAllowanceInitData &initData, QGraphicsItem * parent = nullptr);
|
||||
|
||||
void UpdateExcludeState();
|
||||
|
@ -213,6 +216,8 @@ private:
|
|||
|
||||
QList<VToolSeamAllowance *> SelectedTools() const;
|
||||
|
||||
bool IsGrainlinePositionValid() const;
|
||||
|
||||
static void AddPointRecords(VAbstractPattern *doc, QDomElement &domElement, const QVector<quint32> &records,
|
||||
const QString &tag);
|
||||
|
||||
|
|
|
@ -264,6 +264,12 @@ bool VGrainlineItem::IsContained(const QPointF& pt, qreal dRot, qreal &dX, qreal
|
|||
return bInside;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QLineF VGrainlineItem::Grainline() const
|
||||
{
|
||||
return {m_ptStart, m_ptFinish};
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VGrainlineItem::mousePressEvent handles left button mouse press events
|
||||
|
|
|
@ -50,6 +50,8 @@ public:
|
|||
|
||||
bool IsContained(const QPointF &pt, qreal dRot, qreal &dX, qreal &dY) const;
|
||||
|
||||
QLineF Grainline() const;
|
||||
|
||||
signals:
|
||||
void SignalResized(qreal dLength);
|
||||
void SignalRotated(qreal dRot, const QPointF& ptNewPos);
|
||||
|
|
Loading…
Reference in New Issue
Block a user