[Kst] branches/work/kst/portto4/kst/src/libkstapp
Mike Fenton
mike at staikos.net
Mon Mar 23 16:54:07 CET 2009
SVN commit 943279 by fenton:
Eliminate extra validation / recalculation of Tick locations.
M +2 -1 plotaxis.cpp
M +2 -1 plotaxis.h
M +4 -4 plotitem.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/plotaxis.cpp #943278:943279
@@ -590,7 +590,7 @@
// Function validates that the labels will not overlap. Only functions for x Axis.
-void PlotAxis::validateDrawingRegion(int flags, QPainter *painter) {
+void PlotAxis::validateDrawingRegion(QPainter *painter) {
if (_orientation != Qt::Horizontal) {
return;
}
@@ -601,6 +601,7 @@
updateTicks();
}
+ int flags = Qt::TextSingleLine | Qt::AlignCenter;
int longest = 0;
QMapIterator<qreal, QString> iLongestLabelCheck(_axisLabels);
while (iLongestLabelCheck.hasNext()) {
--- branches/work/kst/portto4/kst/src/libkstapp/plotaxis.h #943278:943279
@@ -107,7 +107,7 @@
void saveInPlot(QXmlStreamWriter &xml, QString axisId);
bool configureFromXml(QXmlStreamReader &xml, ObjectStore *store);
- void validateDrawingRegion(int flags, QPainter *painter);
+ void validateDrawingRegion(QPainter *painter);
// return the value and reset.
bool ticksUpdated() { bool bReturn = _ticksUpdated; _ticksUpdated = false; return bReturn; }
@@ -117,6 +117,7 @@
public Q_SLOTS:
void updateTicks(bool useOverrideTicks = false);
+ void setTicksUpdated() { _ticksUpdated = true; }
private:
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #943278:943279
@@ -100,8 +100,8 @@
_xAxis = new PlotAxis(this, Qt::Horizontal);
_yAxis = new PlotAxis(this, Qt::Vertical);
- connect(this, SIGNAL(geometryChanged()), this, SLOT(updateXAxisLines()));
- connect(this, SIGNAL(geometryChanged()), this, SLOT(updateYAxisLines()));
+ connect(this, SIGNAL(geometryChanged()), _xAxis, SLOT(setTicksUpdated()));
+ connect(this, SIGNAL(geometryChanged()), _yAxis, SLOT(setTicksUpdated()));
_globalFont = parentView()->defaultFont();
_leftLabelFont = parentView()->defaultFont();
@@ -622,9 +622,11 @@
void PlotItem::paintPlot(QPainter *painter) {
if (xAxis()->ticksUpdated()) {
+ xAxis()->validateDrawingRegion(painter);
updateXAxisLines();
}
if (yAxis()->ticksUpdated()) {
+ yAxis()->validateDrawingRegion(painter);
updateYAxisLines();
}
@@ -805,8 +807,6 @@
QRectF xLabelRect;
int flags = Qt::TextSingleLine | Qt::AlignCenter;
- _xAxis->validateDrawingRegion(flags, painter);
-
painter->save();
painter->setPen(_numberLabelFontColor);
More information about the Kst
mailing list