Corrected the label placement when moved on the detail edge

--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-07-10 11:20:53 +02:00
parent 6e1dce0cd7
commit d76cc0bd38

View File

@ -711,11 +711,15 @@ void VToolDetail::UpdateLabel()
dataLabel->AddLine(tl);
}
QPointF pt;
QPointF pt = data.GetPos() + QPointF(data.GetLabelWidth()/2, data.GetLabelHeight()/2);
// check if center is inside
if (boundingRect().contains(data.GetPos() + QPointF(data.GetLabelWidth()/2, data.GetLabelHeight()/2)) == false)
if (boundingRect().contains(pt) == false)
{
pt = boundingRect().topLeft();
QRectF rect = boundingRect();
pt.setX(qMin(rect.right(), qMax(pt.x(), rect.left())));
pt.setY(qMin(rect.bottom(), qMax(pt.y(), rect.top())));
pt.setX(pt.x() - data.GetLabelWidth()/2);
pt.setY(pt.y() - data.GetLabelHeight()/2);
}
else
{
@ -786,10 +790,15 @@ void VToolDetail::UpdatePatternInfo()
patternInfo->AddLine(tl);
// check if center is inside
QPointF pt;
if (boundingRect().contains(geom.GetPos() + QPointF(geom.GetLabelWidth()/2, geom.GetLabelHeight()/2)) == false)
QPointF pt = geom.GetPos() + QPointF(geom.GetLabelWidth()/2, geom.GetLabelHeight()/2);
if (boundingRect().contains(pt) == false)
{
pt = boundingRect().topLeft();
QRectF rect = boundingRect();
qDebug() << "FALSE" << rect << pt << pt.x() - rect.left();
pt.setX(qMin(rect.right(), qMax(pt.x(), rect.left())));
pt.setY(qMin(rect.bottom(), qMax(pt.y(), rect.top())));
pt.setX(pt.x() - geom.GetLabelWidth()/2);
pt.setY(pt.y() - geom.GetLabelHeight()/2);
}
else
{