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 VPatternPieceData;
|
||||
|
||||
#define RESIZE_SQUARE 30
|
||||
#define ROTATE_CIRCLE 20
|
||||
const qreal resizeSquare = (3./*mm*/ / 25.4) * PrintDPI;
|
||||
const qreal rotateCircle = (2./*mm*/ / 25.4) * PrintDPI;
|
||||
#define ROTATE_RECT 60
|
||||
#define ROTATE_ARC 50
|
||||
#define MIN_W 120
|
||||
#define MIN_H 60
|
||||
const qreal minW = (4./*mm*/ / 25.4) * PrintDPI + resizeSquare;
|
||||
const qreal minH = (4./*mm*/ / 25.4) * PrintDPI + resizeSquare;
|
||||
#define INACTIVE_Z 2
|
||||
#define ACTIVE_Z 10
|
||||
|
||||
|
@ -64,12 +64,21 @@ class VPatternPieceData;
|
|||
* @param pParent pointer to the parent item
|
||||
*/
|
||||
VTextGraphicsItem::VTextGraphicsItem(QGraphicsItem* pParent)
|
||||
:QGraphicsObject(pParent), m_eMode(VTextGraphicsItem::mNormal), m_bReleased(false),
|
||||
m_ptStartPos(), m_ptStart(), m_ptRotCenter(), m_szStart(), m_dRotation(0), m_dAngle(0),
|
||||
m_rectResize(), m_iMinH(MIN_H), m_rectBoundingBox(), m_tm()
|
||||
: QGraphicsObject(pParent),
|
||||
m_eMode(VTextGraphicsItem::mNormal),
|
||||
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));
|
||||
SetSize(MIN_W, m_iMinH);
|
||||
SetSize(minW, minH);
|
||||
setZValue(INACTIVE_Z);
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
|
@ -165,9 +174,11 @@ void VTextGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
|||
painter->setBrush(Qt::black);
|
||||
painter->drawEllipse(
|
||||
QPointF(m_rectBoundingBox.width()/2, m_rectBoundingBox.height()/2),
|
||||
ROTATE_CIRCLE,
|
||||
ROTATE_CIRCLE
|
||||
rotateCircle,
|
||||
rotateCircle
|
||||
);
|
||||
if (m_rectBoundingBox.width() > minW*3 && m_rectBoundingBox.height() > minH*3)
|
||||
{
|
||||
painter->setPen(QPen(Qt::black, 3));
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
// and then draw the arc in each of the corners
|
||||
|
@ -181,6 +192,7 @@ void VTextGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
|||
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();
|
||||
// don't allow resize under specific size
|
||||
if (fW < MIN_W || fH < m_iMinH)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (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())
|
||||
{
|
||||
fH = parentItem()->boundingRect().height();
|
||||
}
|
||||
if (fH < m_iMinH)
|
||||
if (fH < minH)
|
||||
{
|
||||
fH = m_iMinH;
|
||||
fH = minH;
|
||||
}
|
||||
|
||||
prepareGeometryChange();
|
||||
|
@ -262,9 +269,9 @@ void VTextGraphicsItem::SetSize(qreal fW, qreal fH)
|
|||
m_rectBoundingBox.setTopLeft(QPointF(0, 0));
|
||||
m_rectBoundingBox.setWidth(fW);
|
||||
m_rectBoundingBox.setHeight(fH);
|
||||
m_rectResize.setTopLeft(QPointF(fW - RESIZE_SQUARE, fH - RESIZE_SQUARE));
|
||||
m_rectResize.setWidth(RESIZE_SQUARE);
|
||||
m_rectResize.setHeight(RESIZE_SQUARE);
|
||||
m_rectResize.setTopLeft(QPointF(fW - resizeSquare, fH - resizeSquare));
|
||||
m_rectResize.setWidth(resizeSquare);
|
||||
m_rectResize.setHeight(resizeSquare);
|
||||
setTransformOriginPoint(m_rectBoundingBox.center());
|
||||
}
|
||||
|
||||
|
|
|
@ -75,13 +75,14 @@ public:
|
|||
virtual ~VTextGraphicsItem();
|
||||
|
||||
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();
|
||||
bool IsIdle() const;
|
||||
|
||||
int GetFontSize() const;
|
||||
QRectF boundingRect() const;
|
||||
virtual QRectF boundingRect() const Q_DECL_OVERRIDE;
|
||||
void AddLine(const TextLine& tl);
|
||||
void Clear();
|
||||
void SetSize(qreal fW, qreal fH);
|
||||
|
@ -92,11 +93,11 @@ public:
|
|||
int GetTextLines() const;
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent* pME);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent* pME);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent* pME);
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent* pHE);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent* pHE);
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent* pME) Q_DECL_OVERRIDE;
|
||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* pME) Q_DECL_OVERRIDE;
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent* pME) Q_DECL_OVERRIDE;
|
||||
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent* pHE) Q_DECL_OVERRIDE;
|
||||
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent* pHE) Q_DECL_OVERRIDE;
|
||||
void UpdateBox();
|
||||
void CorrectLabel();
|
||||
|
||||
|
@ -118,7 +119,6 @@ private:
|
|||
double m_dRotation;
|
||||
double m_dAngle;
|
||||
QRectF m_rectResize;
|
||||
int m_iMinH;
|
||||
QRectF m_rectBoundingBox;
|
||||
VTextManager m_tm;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user