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

Nicolas Brisset nicolas.brisset at eurocopter.com
Mon May 20 21:43:17 UTC 2013


SVN commit 1355706 by brisset:

OK, I got it to work: if you read time from an ASCII file (type string =
"ASCII file", not "ASCII"!) then the same format is set as default for x
axis labels. Test it, I think it's really nice. And it should not have
too many side effects as it's active only for ASCII formatted time, not
C time or other formats.


 M  +11 -0     datasources/ascii/asciisource.cpp  
 M  +2 -0      datasources/ascii/asciisource.h  
 M  +3 -0      libkst/datasource.cpp  
 M  +1 -0      libkst/datasource.h  
 M  +8 -0      libkstapp/datawizard.cpp  


--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.cpp #1355705:1355706
@@ -689,6 +689,17 @@
 }
 
 //-------------------------------------------------------------------------------------------
+QString AsciiSource::timeFormat() const
+{
+  if (_config._indexInterpretation.value() != AsciiSourceConfig::FormattedTime) {
+    return QString("");
+  }
+  else {
+    return _config._timeAsciiFormatString;
+  }
+}
+
+//-------------------------------------------------------------------------------------------
 Kst::ObjectList<Kst::Object> AsciiSource::autoCurves(ObjectStore& objectStore)
 {
   // here we could do more sophisticated stuff when generating a list of curves
--- branches/work/kst/portto4/kst/src/datasources/ascii/asciisource.h #1355705:1355706
@@ -68,6 +68,8 @@
 
     Kst::ObjectList<Kst::Object> autoCurves(Kst::ObjectStore& objectStore);
 
+    QString timeFormat() const;
+
   private:
     AsciiDataReader _reader;
     AsciiFileBuffer _fileBuffer;
--- branches/work/kst/portto4/kst/src/libkst/datasource.cpp #1355705:1355706
@@ -323,6 +323,9 @@
   return false;
 }
 
+QString DataSource::timeFormat() const {
+  return QString();
+}
 
 int DataSource::sampleForTime(const QDateTime& time, bool *ok) {
   Q_UNUSED(time)
--- branches/work/kst/portto4/kst/src/libkst/datasource.h #1355705:1355706
@@ -124,6 +124,7 @@
     /* if you use it)                                           */
     /************************************************************/
     static bool supportsTime(const QString& plugin, const QString& type = QString());
+    virtual QString timeFormat() const; // Used by the data wizard to set X axis display format
 
     /** Does it support time conversion of sample numbers, in general? */
     virtual bool supportsTimeConversions() const;
--- branches/work/kst/portto4/kst/src/libkstapp/datawizard.cpp #1355705:1355706
@@ -1224,7 +1224,15 @@
     foreach (PlotItem* plot, plotList) {
       if (xAxisIsTime) {
         plot->xAxis()->setAxisInterpret(true);
+        // For ASCII, we can get the time/date format string from the datasource config
+        DataSourcePtr ds = _pageDataSource->dataSource();
+        if (ds->typeString() == "ASCII file") {
+          if (!ds->timeFormat().isEmpty()) { // Only set it when we use a specific ASCII format
+            plot->xAxis()->setAxisDisplayFormatString(ds->timeFormat());
+            plot->xAxis()->setAxisDisplay(AXIS_DISPLAY_QTDATETIME_FORMAT);
       }
+        }
+      }
       plot->update();
       plot->view()->appendToLayout(layout_type, plot, num_columns);
     }


More information about the Kst mailing list