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

Mike Fenton mike at staikos.net
Thu Apr 30 16:56:59 CEST 2009


SVN commit 961715 by fenton:

Add dirty flag for PlotAxis to pickup changes made directly in PlotAxis dialog requiring a redraw.


 M  +75 -18    plotaxis.cpp  
 M  +3 -0      plotaxis.h  
 M  +5 -1      plotitem.cpp  
 M  +1 -1      plotitem.h  
 M  +2 -2      plotitemdialog.cpp  


--- branches/work/kst/portto4/kst/src/libkstapp/plotaxis.cpp #961714:961715
@@ -28,6 +28,7 @@
 PlotAxis::PlotAxis(PlotItem *plotItem, Qt::Orientation orientation) :
   _plotItem(plotItem),
   _orientation(orientation),
+  _dirty(true),
   _axisZoomMode(Auto),
   _isAxisVisible(true),
   _ticksUpdated(true),
@@ -350,7 +351,10 @@
 
 
 void PlotAxis::setAxisZoomMode(ZoomMode mode) {
-  _axisZoomMode = mode;
+  if (_axisZoomMode != mode) {
+    _axisZoomMode = mode;
+    _dirty = true;
+  }
 }
 
 
@@ -360,7 +364,10 @@
 
 
 void PlotAxis::setAxisLog(bool log) {
-  _axisLog = log;
+  if (_axisLog != log) {
+    _axisLog = log;
+    _dirty = true;
+  }
 }
 
 
@@ -370,7 +377,10 @@
 
 
 void PlotAxis::setAxisSignificantDigits(const int digits) {
-  _axisSignificantDigits = digits;
+  if (_axisSignificantDigits != digits) {
+    _axisSignificantDigits = digits;
+    _dirty = true;
+  }
 }
 
 
@@ -380,7 +390,10 @@
 
 
 void PlotAxis::setAxisMajorTickMode(PlotAxis::MajorTickMode mode) {
-  _axisMajorTickMode = mode;
+  if (_axisMajorTickMode != mode) {
+    _axisMajorTickMode = mode;
+    _dirty = true;
+  }
 }
 
 
@@ -390,7 +403,10 @@
 
 
 void PlotAxis::setAxisMinorTickCount(const int count) {
-  _axisMinorTickCount = count;
+  if (_axisMinorTickCount != count) {
+    _axisMinorTickCount = count;
+    _dirty = true;
+  }
 }
 
 
@@ -400,7 +416,10 @@
 
 
 void PlotAxis::setDrawAxisMajorTicks(bool draw) {
-  _drawAxisMajorTicks = draw;
+  if (_drawAxisMajorTicks != draw) {
+    _drawAxisMajorTicks = draw;
+    _dirty = true;
+  }
 }
 
 
@@ -410,7 +429,10 @@
 
 
 void PlotAxis::setDrawAxisMinorTicks(bool draw) {
-  _drawAxisMinorTicks = draw;
+  if (_drawAxisMinorTicks != draw) {
+    _drawAxisMinorTicks = draw;
+    _dirty = true;
+  }
 }
 
 
@@ -420,7 +442,10 @@
 
 
 void PlotAxis::setDrawAxisMajorGridLines(bool draw) {
-  _drawAxisMajorGridLines = draw;
+  if (_drawAxisMajorGridLines != draw) {
+    _drawAxisMajorGridLines = draw;
+    _dirty = true;
+  }
 }
 
 
@@ -430,7 +455,10 @@
 
 
 void PlotAxis::setDrawAxisMinorGridLines(bool draw) {
-  _drawAxisMinorGridLines = draw;
+  if (_drawAxisMinorGridLines != draw) {
+    _drawAxisMinorGridLines = draw;
+    _dirty = true;
+  }
 }
 
 
@@ -440,7 +468,10 @@
 
 
 void PlotAxis::setAxisMajorGridLineColor(const QColor &color) {
-  _axisMajorGridLineColor = color;
+  if (_axisMajorGridLineColor != color) {
+    _axisMajorGridLineColor = color;
+    _dirty = true;
+  }
 }
 
 
@@ -450,7 +481,10 @@
 
 
 void PlotAxis::setAxisMinorGridLineColor(const QColor &color) {
-  _axisMinorGridLineColor = color;
+  if (_axisMinorGridLineColor != color) {
+    _axisMinorGridLineColor = color;
+    _dirty = true;
+  }
 }
 
 
@@ -460,7 +494,10 @@
 
 
 void PlotAxis::setAxisMajorGridLineStyle(const Qt::PenStyle style) {
-  _axisMajorGridLineStyle = style;
+  if (_axisMajorGridLineStyle != style) {
+    _axisMajorGridLineStyle = style;
+    _dirty = true;
+  }
 }
 
 
@@ -470,7 +507,10 @@
 
 
 void PlotAxis::setAxisMinorGridLineStyle(const Qt::PenStyle style) {
-  _axisMinorGridLineStyle = style;
+  if (_axisMinorGridLineStyle != style) {
+    _axisMinorGridLineStyle = style;
+    _dirty = true;
+  }
 }
 
 
@@ -485,6 +525,7 @@
   }
 
   _isAxisVisible = visible;
+  _dirty = true;
 }
 
 
@@ -494,7 +535,10 @@
 
 
 void PlotAxis::setAxisReversed(const bool enabled) {
-  _axisReversed = enabled;
+  if (_axisReversed != enabled) {
+    _axisReversed = enabled;
+    _dirty = true;
+  }
 }
 
 
@@ -504,7 +548,10 @@
 
 
 void PlotAxis::setAxisBaseOffset(const bool enabled) {
-  _axisBaseOffset = enabled;
+  if (_axisBaseOffset != enabled) {
+    _axisBaseOffset = enabled;
+    _dirty = true;
+  }
 }
 
 
@@ -514,7 +561,10 @@
 
 
 void PlotAxis::setAxisInterpret(const bool enabled) {
-  _axisInterpret = enabled;
+  if (_axisInterpret != enabled) {
+    _axisInterpret = enabled;
+    _dirty = true;
+  }
 }
 
 
@@ -524,7 +574,10 @@
 
 
 void PlotAxis::setAxisDisplay(const AxisDisplayType display) {
-  _axisDisplay = display;
+  if (_axisDisplay != display) {
+    _axisDisplay = display;
+    _dirty = true;
+  }
 }
 
 
@@ -534,7 +587,10 @@
 
 
 void PlotAxis::setAxisInterpretation(const AxisInterpretationType display) {
-  _axisInterpretation = display;
+  if (_axisInterpretation != display) {
+    _axisInterpretation = display;
+    _dirty = true;
+  }
 }
 
 
@@ -660,6 +716,7 @@
     majorTickCount = _axisMajorTickMode;
     _axisBaseOffsetOverride = false;
   }
+  _dirty = false;
 
   QMap<qreal, QString> labels;
   QList<qreal> ticks;
--- branches/work/kst/portto4/kst/src/libkstapp/plotaxis.h #961714:961715
@@ -111,6 +111,7 @@
 
     // return the value and reset.
     bool ticksUpdated() { bool bReturn = _ticksUpdated; _ticksUpdated = false; return bReturn; }
+    bool isDirty() { return _dirty; }
 
   public Q_SLOTS:
     void updateTicks(bool useOverrideTicks = false);
@@ -134,6 +135,8 @@
     PlotItem *_plotItem;
     Qt::Orientation _orientation;
 
+    bool _dirty;
+
     ZoomMode _axisZoomMode;
     bool _isAxisVisible;
 
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #961714:961715
@@ -2103,7 +2103,7 @@
 }
 
 
-void PlotItem::setProjectionRect(const QRectF &rect) {
+void PlotItem::setProjectionRect(const QRectF &rect, bool forceAxisUpdate) {
   if (!(_projectionRect == rect || rect.isEmpty() || !rect.isValid())) {
 #if DEBUG_ZOOM
     qDebug() << "=== setProjectionRect() ======================>\n"
@@ -2115,6 +2115,10 @@
     setPlotBordersDirty(true);
     emit updateAxes();
     update(); //slow, but need to update everything...
+  } else if (forceAxisUpdate) {
+    setPlotBordersDirty(true);
+    emit updateAxes();
+    update(); //slow, but need to update everything...
   }
 }
 
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #961714:961715
@@ -136,7 +136,7 @@
     QRectF plotRect();
 
     QRectF projectionRect() const;
-    void setProjectionRect(const QRectF &rect);
+    void setProjectionRect(const QRectF &rect, bool forceAxisUpdate = false);
     QRectF computedProjectionRect();
     void computedRelationalMax(qreal &minimum, qreal &maximum);
     void computeBorder(Qt::Orientation orientation, qreal &minimum, qreal &maximum) const;
--- branches/work/kst/portto4/kst/src/libkstapp/plotitemdialog.cpp #961714:961715
@@ -518,7 +518,7 @@
   _plotItem->xAxis()->setAxisBaseOffset(_xAxisTab->isBaseOffset());
   _plotItem->xAxis()->setAxisMinorTickCount(_xAxisTab->axisMinorTickCount());
   _plotItem->xAxis()->setAxisSignificantDigits(_xAxisTab->significantDigits());
-  _plotItem->setProjectionRect(_plotItem->projectionRect());
+  _plotItem->setProjectionRect(_plotItem->projectionRect(), _plotItem->xAxis()->isDirty());
 }
 
 
@@ -542,7 +542,7 @@
   _plotItem->yAxis()->setAxisBaseOffset(_yAxisTab->isBaseOffset());
   _plotItem->yAxis()->setAxisMinorTickCount(_yAxisTab->axisMinorTickCount());
   _plotItem->yAxis()->setAxisSignificantDigits(_yAxisTab->significantDigits());
-  _plotItem->setProjectionRect(_plotItem->projectionRect());
+  _plotItem->setProjectionRect(_plotItem->projectionRect(), _plotItem->yAxis()->isDirty());
 }
 
 


More information about the Kst mailing list