[Kst] branches/work/kst/portto4/kst/src/libkstapp

Barth Netterfield netterfield at astro.utoronto.ca
Wed Jun 9 17:20:03 CEST 2010


SVN commit 1136349 by netterfield:

Don't let X axis label overlap with base value in base/offset mode.



 M  +9 -2      plotitem.cpp  
 M  +1 -0      plotitem.h  


--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #1136348:1136349
@@ -67,6 +67,7 @@
   _calculatedRightLabelMargin(0.0),
   _calculatedTopLabelMargin(0.0),
   _calculatedBottomLabelMargin(0.0),
+  _calculatedBottomLabelWidth(0.0),
   _calculatedLabelMarginWidth(0.0),
   _calculatedLabelMarginHeight(0.0),
   _calculatedAxisMarginWidth(0.0),
@@ -806,14 +807,15 @@
 
 
 void PlotItem::calculateBorders(QPainter *painter) {
-  calculateBottomTickLabelBound(painter);
-  calculateLeftTickLabelBound(painter);
 
   calculateLeftLabelMargin(painter);
   calculateRightLabelMargin(painter);
   calculateTopLabelMargin(painter);
   calculateBottomLabelMargin(painter);
 
+  calculateBottomTickLabelBound(painter);
+  calculateLeftTickLabelBound(painter);
+
   calculateMargins();
 
   setPlotRectsDirty();
@@ -2158,6 +2160,7 @@
     painter->restore();
 
     _calculatedBottomLabelMargin = bottomLabelBound.height();
+    _calculatedBottomLabelWidth = bottomLabelBound.width();
 
     //No more than 1/4 the height of the plot
     if (height() < _calculatedBottomLabelMargin * 4)
@@ -2422,10 +2425,14 @@
       }
     }
   }
+
   xLabelRect.setHeight(xLabelRect.height() + _calculatedAxisMarginVLead);
 
   if (!_xAxis->baseLabel().isEmpty()) {
     qreal height = painter->boundingRect(QRectF(), flags, _xAxis->baseLabel()).height();
+    if (painter->boundingRect(QRectF(), flags, _xAxis->baseLabel()).width() + _calculatedBottomLabelWidth/2 + xLabelRect.height()/2 > plotRect().width()/2) {
+      height += bottomLabelMargin();
+    }
     if (bottomLabelMargin() < height) {
       xLabelRect.setHeight(xLabelRect.height() + (height - bottomLabelMargin()));
     }
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #1136348:1136349
@@ -412,6 +412,7 @@
     qreal _calculatedTopLabelMargin;
     qreal _calculatedTopLabelHeight;
     qreal _calculatedBottomLabelMargin;
+    qreal _calculatedBottomLabelWidth;
     qreal _calculatedLabelMarginWidth;
     qreal _calculatedLabelMarginHeight;
 


More information about the Kst mailing list