Fix infinite redrawing.
--HG-- branch : feature
This commit is contained in:
parent
449543f203
commit
02fde1464d
|
@ -767,22 +767,9 @@ void VToolSeamAllowance::SaveRotateGrainline(qreal dRot, const QPointF& ptPos)
|
||||||
*/
|
*/
|
||||||
void VToolSeamAllowance::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void VToolSeamAllowance::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
{
|
{
|
||||||
if (scene()->views().count() > 0)
|
if ((m_dataLabel->IsIdle() == false
|
||||||
{
|
|| m_patternInfo->IsIdle() == false
|
||||||
const QPoint pt0 = scene()->views().at(0)->mapFromScene(0, 0);
|
|| m_grainLine->IsIdle() == false) && not isSelected())
|
||||||
const QPoint pt = scene()->views().at(0)->mapFromScene(0, 100);
|
|
||||||
|
|
||||||
const QPoint p = pt - pt0;
|
|
||||||
|
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
|
||||||
const qreal dScale = qSqrt(QPoint::dotProduct(p, p));
|
|
||||||
#else
|
|
||||||
const qreal dScale = qSqrt(p.x() * p.x() + p.y() * p.y());
|
|
||||||
#endif //QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
|
||||||
m_grainLine->SetScale(100/dScale);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_dataLabel->IsIdle() == false || m_patternInfo->IsIdle() == false || m_grainLine->IsIdle() == false)
|
|
||||||
{
|
{
|
||||||
setSelected(true);
|
setSelected(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QStyleOptionGraphicsItem>
|
#include <QStyleOptionGraphicsItem>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsView>
|
||||||
|
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
#include "../vmisc/vmath.h"
|
#include "../vmisc/vmath.h"
|
||||||
|
@ -104,8 +106,10 @@ void VGrainlineItem::paint(QPainter* pP, const QStyleOptionGraphicsItem* pOption
|
||||||
pP->drawLine(pt1, pt2);
|
pP->drawLine(pt1, pt2);
|
||||||
|
|
||||||
pP->setBrush(clr);
|
pP->setBrush(clr);
|
||||||
|
|
||||||
QPolygonF poly;
|
QPolygonF poly;
|
||||||
QPointF ptA;
|
QPointF ptA;
|
||||||
|
m_dScale = GetScale();
|
||||||
qreal dArrLen = ARROW_LENGTH*m_dScale;
|
qreal dArrLen = ARROW_LENGTH*m_dScale;
|
||||||
if (m_eArrowType != ArrowType::atRear)
|
if (m_eArrowType != ArrowType::atRear)
|
||||||
{
|
{
|
||||||
|
@ -175,7 +179,6 @@ void VGrainlineItem::paint(QPainter* pP, const QStyleOptionGraphicsItem* pOption
|
||||||
pP->drawArc(iX - iR, -iY, iR, iR, 90*16, -90*16);
|
pP->drawArc(iX - iR, -iY, iR, iR, 90*16, -90*16);
|
||||||
pP->restore();
|
pP->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
pP->restore();
|
pP->restore();
|
||||||
}
|
}
|
||||||
|
@ -270,18 +273,6 @@ bool VGrainlineItem::IsContained(const QPointF& pt, qreal dRot, qreal &dX, qreal
|
||||||
return bInside;
|
return bInside;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief VGrainlineItem::SetScale sets the scale for keeping the arrows of constant size
|
|
||||||
* @param dScale scale factor
|
|
||||||
*/
|
|
||||||
void VGrainlineItem::SetScale(qreal dScale)
|
|
||||||
{
|
|
||||||
m_dScale = dScale;
|
|
||||||
UpdateRectangle();
|
|
||||||
Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief VGrainlineItem::mousePressEvent handles left button mouse press events
|
* @brief VGrainlineItem::mousePressEvent handles left button mouse press events
|
||||||
|
@ -547,3 +538,27 @@ QPointF VGrainlineItem::GetInsideCorner(int i, qreal dDist) const
|
||||||
|
|
||||||
return m_polyBound.at(i) + pt1 + pt2;
|
return m_polyBound.at(i) + pt1 + pt2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* @brief GetScale gets the scale for keeping the arrows of constant size
|
||||||
|
*/
|
||||||
|
qreal VGrainlineItem::GetScale() const
|
||||||
|
{
|
||||||
|
if (scene()->views().count() > 0)
|
||||||
|
{
|
||||||
|
const QPoint pt0 = scene()->views().at(0)->mapFromScene(0, 0);
|
||||||
|
const QPoint pt = scene()->views().at(0)->mapFromScene(0, 100);
|
||||||
|
|
||||||
|
const QPoint p = pt - pt0;
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||||
|
const qreal dScale = qSqrt(QPoint::dotProduct(p, p));
|
||||||
|
#else
|
||||||
|
const qreal dScale = qSqrt(p.x() * p.x() + p.y() * p.y());
|
||||||
|
#endif //QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||||
|
return 100/dScale;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@ public:
|
||||||
void UpdateGeometry(const QPointF& ptPos, qreal dRotation, qreal dLength, ArrowType eAT);
|
void UpdateGeometry(const QPointF& ptPos, qreal dRotation, qreal dLength, ArrowType eAT);
|
||||||
|
|
||||||
bool IsContained(const QPointF &pt, qreal dRot, qreal &dX, qreal &dY) const;
|
bool IsContained(const QPointF &pt, qreal dRot, qreal &dX, qreal &dY) const;
|
||||||
void SetScale(qreal dScale);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void SignalResized(qreal dLength);
|
void SignalResized(qreal dLength);
|
||||||
|
@ -75,6 +74,8 @@ private:
|
||||||
QPointF m_ptCenter;
|
QPointF m_ptCenter;
|
||||||
qreal m_dAngle;
|
qreal m_dAngle;
|
||||||
ArrowType m_eArrowType;
|
ArrowType m_eArrowType;
|
||||||
|
|
||||||
|
qreal GetScale() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VGRAINLINEITEM_H
|
#endif // VGRAINLINEITEM_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user