annotate base/Selection.h @ 38:a6b2128eed56

* Continue MainWindow refactoring by making MainWindow actually use the new Document class -- still somewhat unstable * Fix crash in spectrogram layer * Rename tonalestimator to TonalEstimator and add to project file
author Chris Cannam
date Fri, 03 Mar 2006 16:56:20 +0000
parents 935a2419a77c
children 5364a9d338a2
rev   line source
Chris@8 1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
Chris@8 2
Chris@8 3 /*
Chris@8 4 A waveform viewer and audio annotation editor.
Chris@8 5 Chris Cannam, Queen Mary University of London, 2005-2006
Chris@8 6
Chris@8 7 This is experimental software. Not for distribution.
Chris@8 8 */
Chris@8 9
Chris@8 10 #ifndef _SELECTION_H_
Chris@8 11 #define _SELECTION_H_
Chris@8 12
Chris@8 13 #include <cstddef>
Chris@24 14 #include <set>
Chris@8 15
Chris@8 16 class Selection
Chris@8 17 {
Chris@8 18 public:
Chris@8 19 Selection();
Chris@8 20 Selection(size_t startFrame, size_t endFrame);
Chris@8 21 Selection(const Selection &);
Chris@8 22 Selection &operator=(const Selection &);
Chris@8 23 virtual ~Selection();
Chris@8 24
Chris@8 25 bool isEmpty() const;
Chris@8 26 size_t getStartFrame() const;
Chris@8 27 size_t getEndFrame() const;
Chris@9 28 bool contains(size_t frame) const;
Chris@8 29
Chris@8 30 bool operator<(const Selection &) const;
Chris@8 31 bool operator==(const Selection &) const;
Chris@8 32
Chris@8 33 protected:
Chris@8 34 size_t m_startFrame;
Chris@8 35 size_t m_endFrame;
Chris@8 36 };
Chris@8 37
Chris@24 38 class MultiSelection
Chris@24 39 {
Chris@24 40 public:
Chris@24 41 MultiSelection();
Chris@24 42 virtual ~MultiSelection();
Chris@24 43
Chris@24 44 typedef std::set<Selection> SelectionList;
Chris@24 45
Chris@24 46 const SelectionList &getSelections() const;
Chris@24 47 void setSelection(const Selection &selection);
Chris@24 48 void addSelection(const Selection &selection);
Chris@24 49 void removeSelection(const Selection &selection);
Chris@24 50 void clearSelections();
Chris@24 51
Chris@24 52 /**
Chris@24 53 * Return the selection that contains a given frame.
Chris@24 54 * If defaultToFollowing is true, and if the frame is not in a
Chris@24 55 * selected area, return the next selection after the given frame.
Chris@24 56 * Return the empty selection if no appropriate selection is found.
Chris@24 57 */
Chris@36 58 Selection getContainingSelection(size_t frame, bool defaultToFollowing) const;
Chris@24 59
Chris@24 60 protected:
Chris@24 61 SelectionList m_selections;
Chris@24 62 };
Chris@24 63
Chris@24 64
Chris@8 65 #endif