Chris@8: /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */ Chris@8: Chris@8: /* Chris@8: A waveform viewer and audio annotation editor. Chris@8: Chris Cannam, Queen Mary University of London, 2005-2006 Chris@8: Chris@8: This is experimental software. Not for distribution. 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@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@24: class MultiSelection 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@24: protected: Chris@24: SelectionList m_selections; Chris@24: }; Chris@24: Chris@24: Chris@8: #endif