[Kst] kdeextragear-2/kst/kst

Andrew Walker arwalker at sumusltd.com
Fri Oct 15 20:21:30 CEST 2004


CVS commit by arwalker: 

Display delta time values in seconds, minutes, hours, days depending on the range of the data.

I think this about wraps about the time value on the x-axis. If there are any additional features that are wanted please submit a wishlist request.

CCMAIL: 66138-done at bugs.kde.org


  M +20 -6     kst2dplot.cpp   1.282
  M +2 -2      kst2dplot.h   1.118


--- kdeextragear-2/kst/kst/kst2dplot.cpp  #1.281:1.282
@@ -1402,5 +1402,5 @@ void Kst2DPlot::convertTimeValueToString
 
 
-void Kst2DPlot::convertDiffTimevalueToString(QString& label, double zbase, double zvalue, bool isLog) {
+void Kst2DPlot::convertDiffTimevalueToString(QString& label, double zbase, double zvalue, bool isLog, double scale) {
   double zdiff;
 
@@ -1432,4 +1432,6 @@ void Kst2DPlot::convertDiffTimevalueToSt
   }
 
+  zdiff *= scale;
+  
   if (zdiff > 0.0) {
     label = i18n("+[%1]").arg(zdiff, 0, 'g', DIFFERENCE_PRECISION);
@@ -1455,9 +1457,9 @@ void Kst2DPlot::genAxisTickLabelFullPrec
 
 
-void Kst2DPlot::genAxisTickLabelDifference(QString& label, double zbase, double zvalue, bool isLog, bool isX) {
+void Kst2DPlot::genAxisTickLabelDifference(QString& label, double zbase, double zvalue, bool isLog, bool isX, double scale) {
   double zdiff;
 
   if (isX && _isXAxisInterpreted) {
-    convertDiffTimevalueToString(label, zbase, zvalue, isLog);    
+    convertDiffTimevalueToString(label, zbase, zvalue, isLog, scale);    
   } else {
     if (isLog) {
@@ -1501,4 +1503,5 @@ void Kst2DPlot::genAxisTickLabels(QPaint
   double dWidth;
   double dHeight;
+  double scale = 1.0;
   bool bDuplicate = false;
   uint uiShortestLength = 1000;
@@ -1553,5 +1556,16 @@ void Kst2DPlot::genAxisTickLabels(QPaint
       case X_AXIS_DISPLAY_QTTEXTDATEHHMMSS_SS:
       case X_AXIS_DISPLAY_QTLOCALDATEHHMMSS_SS:
+        if( range > 10.0 * 24.0 * 60.0 * 60.0 ) {
+          scale /= 24.0 * 60.0 * 60.0;
+          strUnits  = i18n("days");
+        } else if( range > 10.0 * 24.0 * 60.0 ) {
+          scale /= 60.0 * 60.0;
+          strUnits  = i18n("hours");
+        } else if( range > 10.0 * 60.0 ) {
+          scale /= 60.0;
+          strUnits  = i18n("minutes");
+        } else {
         strUnits  = i18n("seconds");
+        }
         break;
       case X_AXIS_DISPLAY_JD:
@@ -1613,7 +1627,7 @@ void Kst2DPlot::genAxisTickLabels(QPaint
       }
       if (bLog) {
-        genAxisTickLabelDifference(strTmp, (double)iShortestIndex * Tick + Org, (double)i * Tick + Org, bLog, isX);
+        genAxisTickLabelDifference(strTmp, (double)iShortestIndex * Tick + Org, (double)i * Tick + Org, bLog, isX, scale);
       } else {
-        genAxisTickLabelDifference(strTmp, (double)iShortestIndex * Tick, (double)i * Tick, bLog, isX);
+        genAxisTickLabelDifference(strTmp, (double)iShortestIndex * Tick, (double)i * Tick, bLog, isX, scale);
       }
       labelList.append(strTmp);

--- kdeextragear-2/kst/kst/kst2dplot.h  #1.117:1.118
@@ -347,7 +347,7 @@ private:
   void convertJDToDateString(QString& label, uint& length, KstXAxisDisplay display, double dJD);
   void convertTimeValueToString(QString& label, uint& length, double z, bool isLog);
-  void convertDiffTimevalueToString(QString& label, double zbase, double zvalue, bool isLog);
+  void convertDiffTimevalueToString(QString& label, double zbase, double zvalue, bool isLog, double scale);
   void genAxisTickLabelFullPrecision(QString& label, uint& length, double z, bool isLog, bool isX);
-  void genAxisTickLabelDifference(QString& label, double zbase, double zvalue, bool isLog, bool isX);
+  void genAxisTickLabelDifference(QString& label, double zbase, double zvalue, bool isLog, bool isX, double scale);
   void genAxisTickLabels(QPainter& p, double Min, double Max,
       double Org, double Tick, bool isLog, KstLabel *Label, bool &delta,





More information about the Kst mailing list