annotate data/model/PathModel.h @ 1247:8f076d02569a piper

Make SVDEBUG always write to a log file -- formerly this was disabled in NDEBUG builds. I think there's little use to that, it just means that we keep adding more cerr debug output because we aren't getting the log we need. And SVDEBUG logging is not usually used in tight loops, I don't think the performance overhead is too serious. Also update the About box.
author Chris Cannam
date Thu, 03 Nov 2016 14:57:00 +0000
parents 57633d605547
children c01cbe41aeb5
rev   line source
Chris@407 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@407 2
Chris@407 3 /*
Chris@407 4 Sonic Visualiser
Chris@407 5 An audio file viewer and annotation editor.
Chris@407 6 Centre for Digital Music, Queen Mary, University of London.
Chris@407 7 This file copyright 2007 QMUL.
Chris@407 8
Chris@407 9 This program is free software; you can redistribute it and/or
Chris@407 10 modify it under the terms of the GNU General Public License as
Chris@407 11 published by the Free Software Foundation; either version 2 of the
Chris@407 12 License, or (at your option) any later version. See the file
Chris@407 13 COPYING included with this distribution for more information.
Chris@407 14 */
Chris@407 15
Chris@407 16 #ifndef _PATH_MODEL_H_
Chris@407 17 #define _PATH_MODEL_H_
Chris@407 18
Chris@407 19 #include "Model.h"
Chris@407 20 #include "SparseModel.h"
Chris@407 21 #include "base/RealTime.h"
Chris@1040 22 #include "base/BaseTypes.h"
Chris@407 23
Chris@407 24 #include <QStringList>
Chris@407 25
Chris@407 26
Chris@407 27 struct PathPoint
Chris@407 28 {
Chris@1040 29 PathPoint(sv_frame_t _frame) : frame(_frame), mapframe(_frame) { }
Chris@1040 30 PathPoint(sv_frame_t _frame, sv_frame_t _mapframe) :
Chris@407 31 frame(_frame), mapframe(_mapframe) { }
Chris@407 32
Chris@407 33 int getDimensions() const { return 2; }
Chris@407 34
Chris@1040 35 sv_frame_t frame;
Chris@1040 36 sv_frame_t mapframe;
Chris@407 37
Chris@407 38 QString getLabel() const { return ""; }
Chris@407 39
Chris@407 40 void toXml(QTextStream &stream, QString indent = "",
Chris@407 41 QString extraAttributes = "") const {
Chris@407 42 stream << QString("%1<point frame=\"%2\" mapframe=\"%3\" %4/>\n")
Chris@407 43 .arg(indent).arg(frame).arg(mapframe).arg(extraAttributes);
Chris@407 44 }
Chris@407 45
Chris@1060 46 QString toDelimitedDataString(QString delimiter, DataExportOptions,
Chris@1040 47 sv_samplerate_t sampleRate) const {
Chris@407 48 QStringList list;
Chris@407 49 list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str();
Chris@407 50 list << QString("%1").arg(mapframe);
Chris@407 51 return list.join(delimiter);
Chris@407 52 }
Chris@407 53
Chris@407 54 struct Comparator {
Chris@407 55 bool operator()(const PathPoint &p1, const PathPoint &p2) const {
Chris@407 56 if (p1.frame != p2.frame) return p1.frame < p2.frame;
Chris@407 57 return p1.mapframe < p2.mapframe;
Chris@407 58 }
Chris@407 59 };
Chris@407 60
Chris@407 61 struct OrderComparator {
Chris@407 62 bool operator()(const PathPoint &p1, const PathPoint &p2) const {
Chris@407 63 return p1.frame < p2.frame;
Chris@407 64 }
Chris@407 65 };
Chris@407 66 };
Chris@407 67
Chris@407 68 class PathModel : public SparseModel<PathPoint>
Chris@407 69 {
Chris@407 70 public:
Chris@1040 71 PathModel(sv_samplerate_t sampleRate, int resolution, bool notify = true) :
Chris@407 72 SparseModel<PathPoint>(sampleRate, resolution, notify) { }
Chris@407 73
Chris@407 74 virtual void toXml(QTextStream &out,
Chris@407 75 QString indent = "",
Chris@407 76 QString extraAttributes = "") const
Chris@407 77 {
Chris@407 78 SparseModel<PathPoint>::toXml
Chris@407 79 (out,
Chris@407 80 indent,
Chris@407 81 QString("%1 subtype=\"path\"")
Chris@407 82 .arg(extraAttributes));
Chris@407 83 }
Chris@425 84
Chris@425 85 /**
Chris@425 86 * TabularModel is inherited via SparseModel, but we don't need it here.
Chris@425 87 */
Chris@425 88 virtual QString getHeading(int) const { return ""; }
Chris@425 89 virtual bool isColumnTimeValue(int) const { return false; }
Chris@425 90 virtual SortType getSortType(int) const { return SortNumeric; }
Chris@425 91
Chris@407 92 };
Chris@407 93
Chris@407 94
Chris@407 95 #endif