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 2006 Chris Cannam. 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 _SELECTION_H_ 00017 #define _SELECTION_H_ 00018 00019 #include <cstddef> 00020 #include <set> 00021 00022 #include "XmlExportable.h" 00023 00024 class Selection 00025 { 00026 public: 00027 Selection(); 00028 Selection(size_t startFrame, size_t endFrame); 00029 Selection(const Selection &); 00030 Selection &operator=(const Selection &); 00031 virtual ~Selection(); 00032 00033 bool isEmpty() const; 00034 size_t getStartFrame() const; 00035 size_t getEndFrame() const; 00036 bool contains(size_t frame) const; 00037 00038 bool operator<(const Selection &) const; 00039 bool operator==(const Selection &) const; 00040 00041 protected: 00042 size_t m_startFrame; 00043 size_t m_endFrame; 00044 }; 00045 00046 class MultiSelection : public XmlExportable 00047 { 00048 public: 00049 MultiSelection(); 00050 virtual ~MultiSelection(); 00051 00052 typedef std::set<Selection> SelectionList; 00053 00054 const SelectionList &getSelections() const; 00055 void setSelection(const Selection &selection); 00056 void addSelection(const Selection &selection); 00057 void removeSelection(const Selection &selection); 00058 void clearSelections(); 00059 00060 void getExtents(size_t &startFrame, size_t &endFrame) const; 00061 00068 Selection getContainingSelection(size_t frame, bool defaultToFollowing) const; 00069 00070 virtual void toXml(QTextStream &stream, QString indent = "", 00071 QString extraAttributes = "") const; 00072 00073 protected: 00074 SelectionList m_selections; 00075 }; 00076 00077 00078 #endif
1.5.1