Chris@407: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@407: Chris@407: /* Chris@407: Sonic Visualiser Chris@407: An audio file viewer and annotation editor. Chris@407: Centre for Digital Music, Queen Mary, University of London. Chris@407: This file copyright 2007 QMUL. Chris@407: Chris@407: This program is free software; you can redistribute it and/or Chris@407: modify it under the terms of the GNU General Public License as Chris@407: published by the Free Software Foundation; either version 2 of the Chris@407: License, or (at your option) any later version. See the file Chris@407: COPYING included with this distribution for more information. Chris@407: */ Chris@407: Chris@407: #ifndef _PATH_MODEL_H_ Chris@407: #define _PATH_MODEL_H_ Chris@407: Chris@407: #include "Model.h" Chris@407: #include "SparseModel.h" Chris@407: #include "base/RealTime.h" Chris@407: Chris@407: #include Chris@407: Chris@407: Chris@407: struct PathPoint Chris@407: { Chris@407: PathPoint(long _frame) : frame(_frame), mapframe(_frame) { } Chris@407: PathPoint(long _frame, long _mapframe) : Chris@407: frame(_frame), mapframe(_mapframe) { } Chris@407: Chris@407: int getDimensions() const { return 2; } Chris@407: Chris@407: long frame; Chris@407: long mapframe; Chris@407: Chris@407: QString getLabel() const { return ""; } Chris@407: Chris@407: void toXml(QTextStream &stream, QString indent = "", Chris@407: QString extraAttributes = "") const { Chris@407: stream << QString("%1\n") Chris@407: .arg(indent).arg(frame).arg(mapframe).arg(extraAttributes); Chris@407: } Chris@407: Chris@407: QString toDelimitedDataString(QString delimiter, Chris@407: size_t sampleRate) const { Chris@407: QStringList list; Chris@407: list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); Chris@407: list << QString("%1").arg(mapframe); Chris@407: return list.join(delimiter); Chris@407: } Chris@407: Chris@407: struct Comparator { Chris@407: bool operator()(const PathPoint &p1, const PathPoint &p2) const { Chris@407: if (p1.frame != p2.frame) return p1.frame < p2.frame; Chris@407: return p1.mapframe < p2.mapframe; Chris@407: } Chris@407: }; Chris@407: Chris@407: struct OrderComparator { Chris@407: bool operator()(const PathPoint &p1, const PathPoint &p2) const { Chris@407: return p1.frame < p2.frame; Chris@407: } Chris@407: }; Chris@407: }; Chris@407: Chris@407: class PathModel : public SparseModel Chris@407: { Chris@407: public: Chris@407: PathModel(size_t sampleRate, size_t resolution, bool notify = true) : Chris@407: SparseModel(sampleRate, resolution, notify) { } Chris@407: Chris@407: virtual void toXml(QTextStream &out, Chris@407: QString indent = "", Chris@407: QString extraAttributes = "") const Chris@407: { Chris@407: SparseModel::toXml Chris@407: (out, Chris@407: indent, Chris@407: QString("%1 subtype=\"path\"") Chris@407: .arg(extraAttributes)); Chris@407: } Chris@425: Chris@425: /** Chris@425: * TabularModel is inherited via SparseModel, but we don't need it here. Chris@425: */ Chris@425: virtual QString getHeading(int) const { return ""; } Chris@425: virtual bool isColumnTimeValue(int) const { return false; } Chris@425: virtual SortType getSortType(int) const { return SortNumeric; } Chris@425: Chris@407: }; Chris@407: Chris@407: Chris@407: #endif