changeset 1062:1ec57a28e924 tonioni

Merge
author Chris Cannam
date Tue, 31 Mar 2015 10:39:54 +0100
parents c1e43c8d2527 (current diff) 57633d605547 (diff)
children 074d7c51e973
files
diffstat 13 files changed, 67 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/base/DataExportOptions.h	Tue Mar 31 10:39:54 2015 +0100
@@ -0,0 +1,27 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Sonic Visualiser
+    An audio file viewer and annotation editor.
+    Centre for Digital Music, Queen Mary, University of London.
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#ifndef DATA_EXPORT_OPTIONS_H
+#define DATA_EXPORT_OPTIONS_H
+
+enum DataExportOption
+{
+    DataExportDefaults = 0x0,
+    DataExportFillGaps = 0x1,
+    DataExportOmitLevels = 0x2,
+};
+
+typedef int DataExportOptions;
+
+#endif
--- a/base/Window.h	Tue Mar 31 10:36:52 2015 +0100
+++ b/base/Window.h	Tue Mar 31 10:39:54 2015 +0100
@@ -22,7 +22,7 @@
 #include <map>
 #include <cstdlib>
 
-#include <cstdlib>
+#include "system/System.h"
 
 enum WindowType {
     RectangularWindow,
--- a/data/model/FlexiNoteModel.h	Tue Mar 31 10:36:52 2015 +0100
+++ b/data/model/FlexiNoteModel.h	Tue Mar 31 10:39:54 2015 +0100
@@ -66,13 +66,15 @@
             .arg(XmlExportable::encodeEntities(label)).arg(extraAttributes);
     }
 
-    QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const
+    QString toDelimitedDataString(QString delimiter, DataExportOptions opts, sv_samplerate_t sampleRate) const
     {
         QStringList list;
         list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str();
         list << QString("%1").arg(value);
         list << RealTime::frame2RealTime(duration, sampleRate).toString().c_str();
-        list << QString("%1").arg(level);
+        if (!(opts & DataExportOmitLevels)) {
+            list << QString("%1").arg(level);
+        }
         if (label != "") list << label;
         return list.join(delimiter);
     }
--- a/data/model/ImageModel.h	Tue Mar 31 10:36:52 2015 +0100
+++ b/data/model/ImageModel.h	Tue Mar 31 10:39:54 2015 +0100
@@ -55,7 +55,7 @@
             .arg(extraAttributes);
     }
 
-    QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const
+    QString toDelimitedDataString(QString delimiter, DataExportOptions, sv_samplerate_t sampleRate) const
     {
         QStringList list;
         list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str();
--- a/data/model/Model.h	Tue Mar 31 10:36:52 2015 +0100
+++ b/data/model/Model.h	Tue Mar 31 10:39:54 2015 +0100
@@ -22,6 +22,7 @@
 #include "base/XmlExportable.h"
 #include "base/Playable.h"
 #include "base/BaseTypes.h"
+#include "base/DataExportOptions.h"
 
 typedef std::vector<float> SampleBlock;
 
@@ -237,9 +238,16 @@
     virtual QString toDelimitedDataString(QString delimiter) const {
         return toDelimitedDataStringSubset(delimiter, getStartFrame(), getEndFrame());
     }
+    virtual QString toDelimitedDataStringWithOptions(QString delimiter, DataExportOptions opts) const {
+        return toDelimitedDataStringSubsetWithOptions(delimiter, opts, getStartFrame(), getEndFrame());
+    }
     virtual QString toDelimitedDataStringSubset(QString, sv_frame_t /* f0 */, sv_frame_t /* f1 */) const {
         return "";
     }
+    virtual QString toDelimitedDataStringSubsetWithOptions(QString delimiter, DataExportOptions, sv_frame_t f0, sv_frame_t f1) const {
+        // Default implementation supports no options
+        return toDelimitedDataStringSubset(delimiter, f0, f1);
+    }
 
 public slots:
     void aboutToDelete();
--- a/data/model/NoteModel.h	Tue Mar 31 10:36:52 2015 +0100
+++ b/data/model/NoteModel.h	Tue Mar 31 10:39:54 2015 +0100
@@ -62,13 +62,14 @@
             .arg(XmlExportable::encodeEntities(label)).arg(extraAttributes);
     }
 
-    QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const
-    {
+    QString toDelimitedDataString(QString delimiter, DataExportOptions opts, sv_samplerate_t sampleRate) const {
         QStringList list;
         list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str();
         list << QString("%1").arg(value);
         list << RealTime::frame2RealTime(duration, sampleRate).toString().c_str();
-        list << QString("%1").arg(level);
+        if (!(opts & DataExportOmitLevels)) {
+            list << QString("%1").arg(level);
+        }
         if (label != "") list << label;
         return list.join(delimiter);
     }
--- a/data/model/PathModel.h	Tue Mar 31 10:36:52 2015 +0100
+++ b/data/model/PathModel.h	Tue Mar 31 10:39:54 2015 +0100
@@ -43,7 +43,7 @@
             .arg(indent).arg(frame).arg(mapframe).arg(extraAttributes);
     }
         
-    QString toDelimitedDataString(QString delimiter,
+    QString toDelimitedDataString(QString delimiter, DataExportOptions,
                                   sv_samplerate_t sampleRate) const {
         QStringList list;
         list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str();
--- a/data/model/RegionModel.h	Tue Mar 31 10:36:52 2015 +0100
+++ b/data/model/RegionModel.h	Tue Mar 31 10:39:54 2015 +0100
@@ -60,7 +60,7 @@
             .arg(XmlExportable::encodeEntities(label)).arg(extraAttributes);
     }
 
-    QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const
+    QString toDelimitedDataString(QString delimiter, DataExportOptions, sv_samplerate_t sampleRate) const
     {
         QStringList list;
         list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str();
--- a/data/model/SparseModel.h	Tue Mar 31 10:36:52 2015 +0100
+++ b/data/model/SparseModel.h	Tue Mar 31 10:39:54 2015 +0100
@@ -148,21 +148,28 @@
                        QString indent = "",
                        QString extraAttributes = "") const;
 
-    virtual QString toDelimitedDataString(QString delimiter) const
-    { 
+    virtual QString toDelimitedDataString(QString delimiter) const {
+        return toDelimitedDataStringWithOptions(delimiter, DataExportDefaults);
+    }
+
+    virtual QString toDelimitedDataStringWithOptions(QString delimiter,
+                                                     DataExportOptions opts) const { 
         QString s;
         for (PointListConstIterator i = m_points.begin(); i != m_points.end(); ++i) {
-            s += i->toDelimitedDataString(delimiter, m_sampleRate) + "\n";
+            s += i->toDelimitedDataString(delimiter, opts, m_sampleRate) + "\n";
         }
         return s;
     }
 
-    virtual QString toDelimitedDataStringSubset(QString delimiter, sv_frame_t f0, sv_frame_t f1) const
-    { 
+    virtual QString toDelimitedDataStringSubset(QString delimiter, sv_frame_t f0, sv_frame_t f1) const {
+        return toDelimitedDataStringSubsetWithOptions(delimiter, DataExportDefaults, f0, f1);
+    }
+
+    virtual QString toDelimitedDataStringSubsetWithOptions(QString delimiter, DataExportOptions opts, sv_frame_t f0, sv_frame_t f1) const { 
         QString s;
         for (PointListConstIterator i = m_points.begin(); i != m_points.end(); ++i) {
             if (i->frame >= f0 && i->frame < f1) {
-                s += i->toDelimitedDataString(delimiter, m_sampleRate) + "\n";
+                s += i->toDelimitedDataString(delimiter, opts, m_sampleRate) + "\n";
             }
         }
         return s;
--- a/data/model/SparseOneDimensionalModel.h	Tue Mar 31 10:36:52 2015 +0100
+++ b/data/model/SparseOneDimensionalModel.h	Tue Mar 31 10:39:54 2015 +0100
@@ -45,7 +45,7 @@
             .arg(extraAttributes);
     }
 
-    QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const
+    QString toDelimitedDataString(QString delimiter, DataExportOptions, sv_samplerate_t sampleRate) const
     {
         QStringList list;
         list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str();
--- a/data/model/SparseTimeValueModel.h	Tue Mar 31 10:36:52 2015 +0100
+++ b/data/model/SparseTimeValueModel.h	Tue Mar 31 10:39:54 2015 +0100
@@ -49,7 +49,7 @@
             .arg(extraAttributes);
     }
 
-    QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const
+    QString toDelimitedDataString(QString delimiter, DataExportOptions, sv_samplerate_t sampleRate) const
     {
         QStringList list;
         list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str();
--- a/data/model/TextModel.h	Tue Mar 31 10:36:52 2015 +0100
+++ b/data/model/TextModel.h	Tue Mar 31 10:39:54 2015 +0100
@@ -51,7 +51,7 @@
             .arg(encodeEntities(label)).arg(extraAttributes);
     }
 
-    QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const
+    QString toDelimitedDataString(QString delimiter, DataExportOptions, sv_samplerate_t sampleRate) const
     {
         QStringList list;
         list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str();
--- a/system/System.h	Tue Mar 31 10:36:52 2015 +0100
+++ b/system/System.h	Tue Mar 31 10:39:54 2015 +0100
@@ -156,6 +156,10 @@
 
 #include <cmath>
 
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
 extern double mod(double x, double y);
 extern float modf(float x, float y);