--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-07-03 10:25:42 +02:00
commit c58717a803
3 changed files with 34 additions and 14 deletions

View File

@ -42,7 +42,7 @@
#define MIN_W 120 #define MIN_W 120
#define MIN_H 60 #define MIN_H 60
#define MIN_FONT_SIZE 12 #define MIN_FONT_SIZE 12
#define MAX_FONT_SIZE 48 #define MAX_FONT_SIZE 128
#define SPACING 2 #define SPACING 2
#define TOP_Z 2 #define TOP_Z 2
@ -50,8 +50,6 @@
VTextGraphicsItem::VTextGraphicsItem(QGraphicsItem* pParent) VTextGraphicsItem::VTextGraphicsItem(QGraphicsItem* pParent)
: QGraphicsObject(pParent) : QGraphicsObject(pParent)
{ {
setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
m_eMode = mNormal; m_eMode = mNormal;
m_bReleased = false; m_bReleased = false;
m_rectBoundingBox.setTopLeft(QPointF(0, 0)); m_rectBoundingBox.setTopLeft(QPointF(0, 0));
@ -172,12 +170,14 @@ void VTextGraphicsItem::SetSize(qreal fW, qreal fH)
if (fW < MIN_W || fH < m_iMinH) if (fW < MIN_W || fH < m_iMinH)
return; return;
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 - RESIZE_SQUARE, fH - RESIZE_SQUARE));
m_rectResize.setWidth(RESIZE_SQUARE); m_rectResize.setWidth(RESIZE_SQUARE);
m_rectResize.setHeight(RESIZE_SQUARE); m_rectResize.setHeight(RESIZE_SQUARE);
setTransformOriginPoint(m_rectBoundingBox.center()); setTransformOriginPoint(m_rectBoundingBox.center());
prepareGeometryChange();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -134,15 +134,15 @@ VToolDetail::VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32
connect(dataLabel, &VTextGraphicsItem::SignalMoved, this, &VToolDetail::SaveMoveDetail); connect(dataLabel, &VTextGraphicsItem::SignalMoved, this, &VToolDetail::SaveMoveDetail);
connect(dataLabel, &VTextGraphicsItem::SignalResized, this, &VToolDetail::SaveResizeDetail); connect(dataLabel, &VTextGraphicsItem::SignalResized, this, &VToolDetail::SaveResizeDetail);
connect(dataLabel, &VTextGraphicsItem::SignalRotated, this, &VToolDetail::SaveRotationDetail); connect(dataLabel, &VTextGraphicsItem::SignalRotated, this, &VToolDetail::SaveRotationDetail);
connect(dataLabel, &VTextGraphicsItem::SignalShrink, this, &VToolDetail::UpdateAll); //connect(dataLabel, &VTextGraphicsItem::SignalShrink, this, &VToolDetail::UpdateAll);
patternInfo = new VTextGraphicsItem(this); patternInfo = new VTextGraphicsItem(this);
connect(patternInfo, &VTextGraphicsItem::SignalMoved, this, &VToolDetail::SaveMovePattern); connect(patternInfo, &VTextGraphicsItem::SignalMoved, this, &VToolDetail::SaveMovePattern);
connect(patternInfo, &VTextGraphicsItem::SignalResized, this, &VToolDetail::SaveResizePattern); connect(patternInfo, &VTextGraphicsItem::SignalResized, this, &VToolDetail::SaveResizePattern);
connect(patternInfo, &VTextGraphicsItem::SignalRotated, this, &VToolDetail::SaveRotationPattern); connect(patternInfo, &VTextGraphicsItem::SignalRotated, this, &VToolDetail::SaveRotationPattern);
connect(patternInfo, &VTextGraphicsItem::SignalShrink, this, &VToolDetail::UpdateAll); //connect(patternInfo, &VTextGraphicsItem::SignalShrink, this, &VToolDetail::UpdateAll);
connect(doc, &VAbstractPattern::patternChanged, this, &VToolDetail::UpdatePatternInfo);
connect(doc, &VAbstractPattern::patternChanged, this, &VToolDetail::UpdatePatternInfo);
connect(doc, &VAbstractPattern::CheckLayout, this, &VToolDetail::UpdateLabel); connect(doc, &VAbstractPattern::CheckLayout, this, &VToolDetail::UpdateLabel);
connect(doc, &VAbstractPattern::CheckLayout, this, &VToolDetail::UpdatePatternInfo); connect(doc, &VAbstractPattern::CheckLayout, this, &VToolDetail::UpdatePatternInfo);
UpdateLabel(); UpdateLabel();
@ -712,7 +712,17 @@ void VToolDetail::UpdateLabel()
dataLabel->AddLine(tl); dataLabel->AddLine(tl);
} }
dataLabel->setPos(data.GetPos()); QPointF pt;
// check if center is inside
if (boundingRect().contains(data.GetPos() + QPointF(data.GetLabelWidth()/2, data.GetLabelHeight()/2)) == false)
{
pt = boundingRect().topLeft();
}
else
{
pt = data.GetPos();
}
dataLabel->setPos(pt);
dataLabel->setRotation(data.GetRotation()); dataLabel->setRotation(data.GetRotation());
dataLabel->Update(); dataLabel->Update();
dataLabel->show(); dataLabel->show();
@ -775,7 +785,17 @@ void VToolDetail::UpdatePatternInfo()
tl.m_qsText = qslDate.last(); tl.m_qsText = qslDate.last();
patternInfo->AddLine(tl); patternInfo->AddLine(tl);
patternInfo->setPos(geom.GetPos()); // check if center is inside
QPointF pt;
if (boundingRect().contains(geom.GetPos() + QPointF(geom.GetLabelWidth()/2, geom.GetLabelHeight()/2)) == false)
{
pt = boundingRect().topLeft();
}
else
{
pt = geom.GetPos();
}
patternInfo->setPos(pt);
patternInfo->setRotation(geom.GetRotation()); patternInfo->setRotation(geom.GetRotation());
patternInfo->Update(); patternInfo->Update();
} }

View File

@ -128,8 +128,8 @@ private:
QString drawName; QString drawName;
VNoBrushScalePathItem *seamAllowance; VNoBrushScalePathItem *seamAllowance;
VTextGraphicsItem* dataLabel; VTextGraphicsItem *dataLabel;
VTextGraphicsItem* patternInfo; VTextGraphicsItem *patternInfo;
VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation, VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation,
VMainGraphicsScene *scene, const QString &drawName, QGraphicsItem * parent = nullptr); VMainGraphicsScene *scene, const QString &drawName, QGraphicsItem * parent = nullptr);