svcore  1.9
Selection.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 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 
00039 class Selection
00040 {
00041 public:
00042     Selection();
00043     Selection(int startFrame, int endFrame);
00044     Selection(const Selection &);
00045     Selection &operator=(const Selection &);
00046     virtual ~Selection();
00047 
00048     bool isEmpty() const;
00049     int getStartFrame() const;
00050     int getEndFrame() const;
00051     bool contains(int frame) const;
00052 
00053     bool operator<(const Selection &) const;
00054     bool operator==(const Selection &) const;
00055     
00056 protected:
00057     int m_startFrame;
00058     int m_endFrame;
00059 };
00060 
00061 class MultiSelection : public XmlExportable
00062 {
00063 public:
00064     MultiSelection();
00065     virtual ~MultiSelection();
00066 
00067     typedef std::set<Selection> SelectionList;
00068 
00069     const SelectionList &getSelections() const;
00070     void setSelection(const Selection &selection);
00071     void addSelection(const Selection &selection);
00072     void removeSelection(const Selection &selection);
00073     void clearSelections();
00074 
00075     void getExtents(int &startFrame, int &endFrame) const;
00076 
00083     Selection getContainingSelection(int frame, bool defaultToFollowing) const;
00084 
00085     virtual void toXml(QTextStream &stream, QString indent = "",
00086                        QString extraAttributes = "") const;
00087 
00088 protected:
00089     SelectionList m_selections;
00090 };
00091     
00092 
00093 #endif