[Kst] branches/work/kst/portto4/kst/src/libkstapp
Mike Fenton
mike at staikos.net
Mon Mar 30 20:39:41 CEST 2009
SVN commit 947011 by fenton:
Add cached PlotMarkers.
M +1 -1 plotaxis.h
M +21 -26 plotitem.cpp
M +3 -0 plotitem.h
--- branches/work/kst/portto4/kst/src/libkstapp/plotaxis.h #947010:947011
@@ -97,7 +97,7 @@
void setAxisInterpretation(const AxisInterpretationType interpret);
PlotMarkers axisPlotMarkers() { return _axisPlotMarkers; }
- void setAxisPlotMarkers(const PlotMarkers &plotMarkers) { _axisPlotMarkers = plotMarkers; }
+ void setAxisPlotMarkers(const PlotMarkers &plotMarkers) { _axisPlotMarkers = plotMarkers; _ticksUpdated = true; }
QMap<qreal, QString> axisLabels() { return _axisLabels; }
QList<qreal> axisMajorTicks() { return _axisMajorTicks; }
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #947010:947011
@@ -721,6 +721,14 @@
p2 = p1 + QPointF(0, minorTickLength);
_xMinorTickLines << QLineF(p1, p2);
}
+ _xPlotMarkerLines.clear();
+ foreach (double x, _xAxis->axisPlotMarkers().markers()) {
+ if (x > _xMin && x < _xMax) {
+ QPointF p1 = QPointF(mapXToPlot(x), rect.bottom());
+ QPointF p2 = p1 - QPointF(0, rect.height());
+ _xPlotMarkerLines << QLineF(p1, p2);
+ }
+ }
}
@@ -801,6 +809,15 @@
p2 = p1 - QPointF(minorTickLength, 0);
_yMinorTickLines << QLineF(p1, p2);
}
+
+ _yPlotMarkerLines.clear();
+ foreach (double y, _yAxis->axisPlotMarkers().markers()) {
+ if (y > _yMin && y < _yMax) {
+ QPointF p1 = QPointF(rect.left(), mapYToPlot(y));
+ QPointF p2 = p1 + QPointF(rect.width(), 0);
+ _yPlotMarkerLines << QLineF(p1, p2);
+ }
+ }
}
@@ -979,38 +996,16 @@
void PlotItem::paintPlotMarkers(QPainter *painter) {
-
- QRectF rect = plotRect();
-
- QVector<QLineF> xPlotMarkers;
- foreach (double x, _xAxis->axisPlotMarkers().markers()) {
- if (x > _xMin && x < _xMax) {
- QPointF p1 = QPointF(mapXToPlot(x), plotRect().bottom());
- QPointF p2 = p1 - QPointF(0, rect.height());
- xPlotMarkers << QLineF(p1, p2);
- }
- }
-
- if (!xPlotMarkers.isEmpty()) {
+ if (!_xPlotMarkerLines.isEmpty()) {
painter->save();
painter->setPen(QPen(QBrush(_xAxis->axisPlotMarkers().lineColor()), _xAxis->axisPlotMarkers().lineWidth(), _xAxis->axisPlotMarkers().lineStyle()));
- painter->drawLines(xPlotMarkers);
+ painter->drawLines(_xPlotMarkerLines);
painter->restore();
}
-
- QVector<QLineF> yPlotMarkers;
- foreach (double y, _yAxis->axisPlotMarkers().markers()) {
- if (y > _yMin && y < _yMax) {
- QPointF p1 = QPointF(plotRect().left(), mapYToPlot(y));
- QPointF p2 = p1 + QPointF(rect.width(), 0);
- yPlotMarkers << QLineF(p1, p2);
- }
- }
-
- if (!yPlotMarkers.isEmpty()) {
+ if (!_yPlotMarkerLines.isEmpty()) {
painter->save();
painter->setPen(QPen(QBrush(_yAxis->axisPlotMarkers().lineColor()), _yAxis->axisPlotMarkers().lineWidth(), _yAxis->axisPlotMarkers().lineStyle()));
- painter->drawLines(yPlotMarkers);
+ painter->drawLines(_yPlotMarkerLines);
painter->restore();
}
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #947010:947011
@@ -507,6 +507,9 @@
QVector<QLineF> _xMinorTickLines;
QVector<QLineF> _yMinorTickLines;
+ QVector<QLineF> _xPlotMarkerLines;
+ QVector<QLineF> _yPlotMarkerLines;
+
QVector<CachedPlotLabel> _xPlotLabels;
QVector<CachedPlotLabel> _yPlotLabels;
More information about the Kst
mailing list