svcore  1.9
AlignmentModel.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2007 QMUL.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #ifndef _ALIGNMENT_MODEL_H_
00017 #define _ALIGNMENT_MODEL_H_
00018 
00019 #include "Model.h"
00020 #include "PathModel.h"
00021 #include "base/RealTime.h"
00022 
00023 #include <QString>
00024 #include <QStringList>
00025 
00026 class SparseTimeValueModel;
00027 
00028 class AlignmentModel : public Model
00029 {
00030     Q_OBJECT
00031 
00032 public:
00033     AlignmentModel(Model *reference,
00034                    Model *aligned,
00035                    Model *inputModel, // probably an AggregateWaveModel; I take ownership
00036                    SparseTimeValueModel *path); // I take ownership
00037     ~AlignmentModel();
00038 
00039     virtual bool isOK() const;
00040     virtual int getStartFrame() const;
00041     virtual int getEndFrame() const;
00042     virtual int getSampleRate() const;
00043     virtual Model *clone() const;
00044     virtual bool isReady(int *completion = 0) const;
00045     virtual const ZoomConstraint *getZoomConstraint() const;
00046 
00047     QString getTypeName() const { return tr("Alignment"); }
00048 
00049     const Model *getReferenceModel() const;
00050     const Model *getAlignedModel() const;
00051 
00052     int toReference(int frame) const;
00053     int fromReference(int frame) const;
00054 
00055     void setPath(PathModel *path);
00056 
00057     virtual void toXml(QTextStream &stream,
00058                        QString indent = "",
00059                        QString extraAttributes = "") const;
00060 
00061 signals:
00062     void modelChanged();
00063     void modelChangedWithin(int startFrame, int endFrame);
00064     void completionChanged();
00065 
00066 protected slots:
00067     void pathChanged();
00068     void pathChangedWithin(int startFrame, int endFrame);
00069     void pathCompletionChanged();
00070 
00071 protected:
00072     Model *m_reference; // I don't own this
00073     Model *m_aligned; // I don't own this
00074 
00075     Model *m_inputModel; // I own this
00076 
00077     SparseTimeValueModel *m_rawPath; // I own this
00078     mutable PathModel *m_path; // I own this
00079     mutable PathModel *m_reversePath; // I own this
00080     bool m_pathBegun;
00081     bool m_pathComplete;
00082 
00083     void constructPath() const;
00084     void constructReversePath() const;
00085 
00086     int align(PathModel *path, int frame) const;
00087 };
00088 
00089 #endif