Chris@49: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@8: Chris@8: /* Chris@52: Sonic Visualiser Chris@52: An audio file viewer and annotation editor. Chris@52: Centre for Digital Music, Queen Mary, University of London. Chris@52: This file copyright 2006 Chris Cannam. Chris@8: Chris@52: This program is free software; you can redistribute it and/or Chris@52: modify it under the terms of the GNU General Public License as Chris@52: published by the Free Software Foundation; either version 2 of the Chris@52: License, or (at your option) any later version. See the file Chris@52: COPYING included with this distribution for more information. Chris@8: */ Chris@8: Chris@8: #ifndef _SELECTION_H_ Chris@8: #define _SELECTION_H_ Chris@8: Chris@8: #include Chris@24: #include Chris@8: Chris@46: #include "XmlExportable.h" Chris@46: Chris@8: class Selection Chris@8: { Chris@8: public: Chris@8: Selection(); Chris@8: Selection(size_t startFrame, size_t endFrame); Chris@8: Selection(const Selection &); Chris@8: Selection &operator=(const Selection &); Chris@8: virtual ~Selection(); Chris@8: Chris@8: bool isEmpty() const; Chris@8: size_t getStartFrame() const; Chris@8: size_t getEndFrame() const; Chris@9: bool contains(size_t frame) const; Chris@8: Chris@8: bool operator<(const Selection &) const; Chris@8: bool operator==(const Selection &) const; Chris@8: Chris@8: protected: Chris@8: size_t m_startFrame; Chris@8: size_t m_endFrame; Chris@8: }; Chris@8: Chris@46: class MultiSelection : public XmlExportable Chris@24: { Chris@24: public: Chris@24: MultiSelection(); Chris@24: virtual ~MultiSelection(); Chris@24: Chris@24: typedef std::set SelectionList; Chris@24: Chris@24: const SelectionList &getSelections() const; Chris@24: void setSelection(const Selection &selection); Chris@24: void addSelection(const Selection &selection); Chris@24: void removeSelection(const Selection &selection); Chris@24: void clearSelections(); Chris@24: Chris@24: /** Chris@24: * Return the selection that contains a given frame. Chris@24: * If defaultToFollowing is true, and if the frame is not in a Chris@24: * selected area, return the next selection after the given frame. Chris@24: * Return the empty selection if no appropriate selection is found. Chris@24: */ Chris@36: Selection getContainingSelection(size_t frame, bool defaultToFollowing) const; Chris@24: Chris@46: virtual QString toXmlString(QString indent = "", Chris@46: QString extraAttributes = "") const; Chris@46: Chris@24: protected: Chris@24: SelectionList m_selections; Chris@24: }; Chris@24: Chris@24: Chris@8: #endif