##// END OF EJS Templates
Fix checking for labels out of axis grid....
Miikka Heikkinen -
r2570:ac7068d4fd37
parent child
Show More
@@ -122,6 +122,7 void HorizontalAxis::updateGeometry()
122 QPointF center = rect.center();
122 QPointF center = rect.center();
123 labelItem->setTransformOriginPoint(center.x(), center.y());
123 labelItem->setTransformOriginPoint(center.x(), center.y());
124 qreal heightDiff = rect.height() - boundingRect.height();
124 qreal heightDiff = rect.height() - boundingRect.height();
125 qreal widthDiff = rect.width() - boundingRect.width();
125
126
126 //ticks and label position
127 //ticks and label position
127 if (axis()->alignment() == Qt::AlignTop) {
128 if (axis()->alignment() == Qt::AlignTop) {
@@ -146,11 +147,10 void HorizontalAxis::updateGeometry()
146 labelItem->setPos(leftBound + (delta / 2.0) - center.x(), labelItem->pos().y());
147 labelItem->setPos(leftBound + (delta / 2.0) - center.x(), labelItem->pos().y());
147 }
148 }
148 }
149 }
149
150 //label overlap detection - compensate one pixel for rounding errors
150 //label overlap detection - compensate one pixel for rounding errors
151 if (labelItem->pos().x() < width || forceHide ||
151 if (labelItem->pos().x() < width || forceHide ||
152 labelItem->pos().x() < (axisRect.left() - 1.0) ||
152 (labelItem->pos().x() + (widthDiff / 2.0)) < (axisRect.left() - 1.0) ||
153 (labelItem->pos().x() + boundingRect.width() - 1.0) > axisRect.right()){
153 (labelItem->pos().x() + (widthDiff / 2.0) - 1.0) > axisRect.right()){
154 labelItem->setVisible(false);
154 labelItem->setVisible(false);
155 } else {
155 } else {
156 labelItem->setVisible(true);
156 labelItem->setVisible(true);
@@ -126,6 +126,7 void VerticalAxis::updateGeometry()
126 QPointF center = rect.center();
126 QPointF center = rect.center();
127 labelItem->setTransformOriginPoint(center.x(), center.y());
127 labelItem->setTransformOriginPoint(center.x(), center.y());
128 qreal widthDiff = rect.width() - boundingRect.width();
128 qreal widthDiff = rect.width() - boundingRect.width();
129 qreal heightDiff = rect.height() - boundingRect.height();
129
130
130 //ticks and label position
131 //ticks and label position
131 if (axis()->alignment() == Qt::AlignLeft) {
132 if (axis()->alignment() == Qt::AlignLeft) {
@@ -153,8 +154,8 void VerticalAxis::updateGeometry()
153
154
154 //label overlap detection - compensate one pixel for rounding errors
155 //label overlap detection - compensate one pixel for rounding errors
155 if (labelItem->pos().y() + boundingRect.height() > height || forceHide ||
156 if (labelItem->pos().y() + boundingRect.height() > height || forceHide ||
156 (labelItem->pos().y() + (boundingRect.height() / 2.0) - 1.0) > axisRect.bottom() ||
157 (labelItem->pos().y() + (heightDiff / 2.0) - 1.0) > axisRect.bottom() ||
157 labelItem->pos().y() + (boundingRect.height() / 2.0) < (axisRect.top() - 1.0)) {
158 labelItem->pos().y() + (heightDiff / 2.0) < (axisRect.top() - 1.0)) {
158 labelItem->setVisible(false);
159 labelItem->setVisible(false);
159 }
160 }
160 else {
161 else {
General Comments 0
You need to be logged in to leave comments. Login now