Minore changes for VTextGraphicsItem.
Clearing code. Changed size for control objects. --HG-- branch : feature
This commit is contained in:
parent
a3f7b9f60f
commit
b16ee3a4d1
|
@ -49,12 +49,12 @@ class QWidget;
|
||||||
class VAbstractPattern;
|
class VAbstractPattern;
|
||||||
class VPatternPieceData;
|
class VPatternPieceData;
|
||||||
|
|
||||||
#define RESIZE_SQUARE 30
|
const qreal resizeSquare = (3./*mm*/ / 25.4) * PrintDPI;
|
||||||
#define ROTATE_CIRCLE 20
|
const qreal rotateCircle = (2./*mm*/ / 25.4) * PrintDPI;
|
||||||
#define ROTATE_RECT 60
|
#define ROTATE_RECT 60
|
||||||
#define ROTATE_ARC 50
|
#define ROTATE_ARC 50
|
||||||
#define MIN_W 120
|
const qreal minW = (4./*mm*/ / 25.4) * PrintDPI + resizeSquare;
|
||||||
#define MIN_H 60
|
const qreal minH = (4./*mm*/ / 25.4) * PrintDPI + resizeSquare;
|
||||||
#define INACTIVE_Z 2
|
#define INACTIVE_Z 2
|
||||||
#define ACTIVE_Z 10
|
#define ACTIVE_Z 10
|
||||||
|
|
||||||
|
@ -64,12 +64,21 @@ class VPatternPieceData;
|
||||||
* @param pParent pointer to the parent item
|
* @param pParent pointer to the parent item
|
||||||
*/
|
*/
|
||||||
VTextGraphicsItem::VTextGraphicsItem(QGraphicsItem* pParent)
|
VTextGraphicsItem::VTextGraphicsItem(QGraphicsItem* pParent)
|
||||||
:QGraphicsObject(pParent), m_eMode(VTextGraphicsItem::mNormal), m_bReleased(false),
|
: QGraphicsObject(pParent),
|
||||||
m_ptStartPos(), m_ptStart(), m_ptRotCenter(), m_szStart(), m_dRotation(0), m_dAngle(0),
|
m_eMode(VTextGraphicsItem::mNormal),
|
||||||
m_rectResize(), m_iMinH(MIN_H), m_rectBoundingBox(), m_tm()
|
m_bReleased(false),
|
||||||
|
m_ptStartPos(),
|
||||||
|
m_ptStart(),
|
||||||
|
m_ptRotCenter(),
|
||||||
|
m_szStart(),
|
||||||
|
m_dRotation(0),
|
||||||
|
m_dAngle(0),
|
||||||
|
m_rectResize(),
|
||||||
|
m_rectBoundingBox(),
|
||||||
|
m_tm()
|
||||||
{
|
{
|
||||||
m_rectBoundingBox.setTopLeft(QPointF(0, 0));
|
m_rectBoundingBox.setTopLeft(QPointF(0, 0));
|
||||||
SetSize(MIN_W, m_iMinH);
|
SetSize(minW, minH);
|
||||||
setZValue(INACTIVE_Z);
|
setZValue(INACTIVE_Z);
|
||||||
setAcceptHoverEvents(true);
|
setAcceptHoverEvents(true);
|
||||||
}
|
}
|
||||||
|
@ -165,20 +174,23 @@ void VTextGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
||||||
painter->setBrush(Qt::black);
|
painter->setBrush(Qt::black);
|
||||||
painter->drawEllipse(
|
painter->drawEllipse(
|
||||||
QPointF(m_rectBoundingBox.width()/2, m_rectBoundingBox.height()/2),
|
QPointF(m_rectBoundingBox.width()/2, m_rectBoundingBox.height()/2),
|
||||||
ROTATE_CIRCLE,
|
rotateCircle,
|
||||||
ROTATE_CIRCLE
|
rotateCircle
|
||||||
);
|
);
|
||||||
painter->setPen(QPen(Qt::black, 3));
|
if (m_rectBoundingBox.width() > minW*3 && m_rectBoundingBox.height() > minH*3)
|
||||||
painter->setBrush(Qt::NoBrush);
|
{
|
||||||
// and then draw the arc in each of the corners
|
painter->setPen(QPen(Qt::black, 3));
|
||||||
int iTop = ROTATE_RECT - ROTATE_ARC;
|
painter->setBrush(Qt::NoBrush);
|
||||||
int iLeft = ROTATE_RECT - ROTATE_ARC;
|
// and then draw the arc in each of the corners
|
||||||
int iRight = qRound(m_rectBoundingBox.width()) - ROTATE_RECT;
|
int iTop = ROTATE_RECT - ROTATE_ARC;
|
||||||
int iBottom = qRound(m_rectBoundingBox.height()) - ROTATE_RECT;
|
int iLeft = ROTATE_RECT - ROTATE_ARC;
|
||||||
painter->drawArc(iLeft, iTop, ROTATE_ARC, ROTATE_ARC, 180*16, -90*16);
|
int iRight = qRound(m_rectBoundingBox.width()) - ROTATE_RECT;
|
||||||
painter->drawArc(iRight, iTop, ROTATE_ARC, ROTATE_ARC, 90*16, -90*16);
|
int iBottom = qRound(m_rectBoundingBox.height()) - ROTATE_RECT;
|
||||||
painter->drawArc(iLeft, iBottom, ROTATE_ARC, ROTATE_ARC, 270*16, -90*16);
|
painter->drawArc(iLeft, iTop, ROTATE_ARC, ROTATE_ARC, 180*16, -90*16);
|
||||||
painter->drawArc(iRight, iBottom, ROTATE_ARC, ROTATE_ARC, 0*16, -90*16);
|
painter->drawArc(iRight, iTop, ROTATE_ARC, ROTATE_ARC, 90*16, -90*16);
|
||||||
|
painter->drawArc(iLeft, iBottom, ROTATE_ARC, ROTATE_ARC, 270*16, -90*16);
|
||||||
|
painter->drawArc(iRight, iBottom, ROTATE_ARC, ROTATE_ARC, 0*16, -90*16);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,26 +247,21 @@ void VTextGraphicsItem::SetSize(qreal fW, qreal fH)
|
||||||
{
|
{
|
||||||
qDebug() << "Setting size to" << fW << parentItem()->boundingRect().width();
|
qDebug() << "Setting size to" << fW << parentItem()->boundingRect().width();
|
||||||
// don't allow resize under specific size
|
// don't allow resize under specific size
|
||||||
if (fW < MIN_W || fH < m_iMinH)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fW > parentItem()->boundingRect().width())
|
if (fW > parentItem()->boundingRect().width())
|
||||||
{
|
{
|
||||||
fW = parentItem()->boundingRect().width();
|
fW = parentItem()->boundingRect().width();
|
||||||
}
|
}
|
||||||
if (fW < MIN_W)
|
if (fW < minW)
|
||||||
{
|
{
|
||||||
fW = MIN_W;
|
fW = minW;
|
||||||
}
|
}
|
||||||
if (fH > parentItem()->boundingRect().height())
|
if (fH > parentItem()->boundingRect().height())
|
||||||
{
|
{
|
||||||
fH = parentItem()->boundingRect().height();
|
fH = parentItem()->boundingRect().height();
|
||||||
}
|
}
|
||||||
if (fH < m_iMinH)
|
if (fH < minH)
|
||||||
{
|
{
|
||||||
fH = m_iMinH;
|
fH = minH;
|
||||||
}
|
}
|
||||||
|
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
@ -262,9 +269,9 @@ void VTextGraphicsItem::SetSize(qreal fW, qreal fH)
|
||||||
m_rectBoundingBox.setTopLeft(QPointF(0, 0));
|
m_rectBoundingBox.setTopLeft(QPointF(0, 0));
|
||||||
m_rectBoundingBox.setWidth(fW);
|
m_rectBoundingBox.setWidth(fW);
|
||||||
m_rectBoundingBox.setHeight(fH);
|
m_rectBoundingBox.setHeight(fH);
|
||||||
m_rectResize.setTopLeft(QPointF(fW - RESIZE_SQUARE, fH - RESIZE_SQUARE));
|
m_rectResize.setTopLeft(QPointF(fW - resizeSquare, fH - resizeSquare));
|
||||||
m_rectResize.setWidth(RESIZE_SQUARE);
|
m_rectResize.setWidth(resizeSquare);
|
||||||
m_rectResize.setHeight(RESIZE_SQUARE);
|
m_rectResize.setHeight(resizeSquare);
|
||||||
setTransformOriginPoint(m_rectBoundingBox.center());
|
setTransformOriginPoint(m_rectBoundingBox.center());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,13 +75,14 @@ public:
|
||||||
virtual ~VTextGraphicsItem();
|
virtual ~VTextGraphicsItem();
|
||||||
|
|
||||||
void SetFont(const QFont& fnt);
|
void SetFont(const QFont& fnt);
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
void Reset();
|
void Reset();
|
||||||
bool IsIdle() const;
|
bool IsIdle() const;
|
||||||
|
|
||||||
int GetFontSize() const;
|
int GetFontSize() const;
|
||||||
QRectF boundingRect() const;
|
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
|
||||||
void AddLine(const TextLine& tl);
|
void AddLine(const TextLine& tl);
|
||||||
void Clear();
|
void Clear();
|
||||||
void SetSize(qreal fW, qreal fH);
|
void SetSize(qreal fW, qreal fH);
|
||||||
|
@ -92,11 +93,11 @@ public:
|
||||||
int GetTextLines() const;
|
int GetTextLines() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent* pME);
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent* pME) Q_DECL_OVERRIDE;
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent* pME);
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* pME) Q_DECL_OVERRIDE;
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent* pME);
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* pME) Q_DECL_OVERRIDE;
|
||||||
void hoverMoveEvent(QGraphicsSceneHoverEvent* pHE);
|
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent* pHE) Q_DECL_OVERRIDE;
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent* pHE);
|
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* pHE) Q_DECL_OVERRIDE;
|
||||||
void UpdateBox();
|
void UpdateBox();
|
||||||
void CorrectLabel();
|
void CorrectLabel();
|
||||||
|
|
||||||
|
@ -118,7 +119,6 @@ private:
|
||||||
double m_dRotation;
|
double m_dRotation;
|
||||||
double m_dAngle;
|
double m_dAngle;
|
||||||
QRectF m_rectResize;
|
QRectF m_rectResize;
|
||||||
int m_iMinH;
|
|
||||||
QRectF m_rectBoundingBox;
|
QRectF m_rectBoundingBox;
|
||||||
VTextManager m_tm;
|
VTextManager m_tm;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user