Chris@49
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- 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@46
|
16 #include "XmlExportable.h"
|
Chris@46
|
17
|
Chris@8
|
18 class Selection
|
Chris@8
|
19 {
|
Chris@8
|
20 public:
|
Chris@8
|
21 Selection();
|
Chris@8
|
22 Selection(size_t startFrame, size_t endFrame);
|
Chris@8
|
23 Selection(const Selection &);
|
Chris@8
|
24 Selection &operator=(const Selection &);
|
Chris@8
|
25 virtual ~Selection();
|
Chris@8
|
26
|
Chris@8
|
27 bool isEmpty() const;
|
Chris@8
|
28 size_t getStartFrame() const;
|
Chris@8
|
29 size_t getEndFrame() const;
|
Chris@9
|
30 bool contains(size_t frame) const;
|
Chris@8
|
31
|
Chris@8
|
32 bool operator<(const Selection &) const;
|
Chris@8
|
33 bool operator==(const Selection &) const;
|
Chris@8
|
34
|
Chris@8
|
35 protected:
|
Chris@8
|
36 size_t m_startFrame;
|
Chris@8
|
37 size_t m_endFrame;
|
Chris@8
|
38 };
|
Chris@8
|
39
|
Chris@46
|
40 class MultiSelection : public XmlExportable
|
Chris@24
|
41 {
|
Chris@24
|
42 public:
|
Chris@24
|
43 MultiSelection();
|
Chris@24
|
44 virtual ~MultiSelection();
|
Chris@24
|
45
|
Chris@24
|
46 typedef std::set<Selection> SelectionList;
|
Chris@24
|
47
|
Chris@24
|
48 const SelectionList &getSelections() const;
|
Chris@24
|
49 void setSelection(const Selection &selection);
|
Chris@24
|
50 void addSelection(const Selection &selection);
|
Chris@24
|
51 void removeSelection(const Selection &selection);
|
Chris@24
|
52 void clearSelections();
|
Chris@24
|
53
|
Chris@24
|
54 /**
|
Chris@24
|
55 * Return the selection that contains a given frame.
|
Chris@24
|
56 * If defaultToFollowing is true, and if the frame is not in a
|
Chris@24
|
57 * selected area, return the next selection after the given frame.
|
Chris@24
|
58 * Return the empty selection if no appropriate selection is found.
|
Chris@24
|
59 */
|
Chris@36
|
60 Selection getContainingSelection(size_t frame, bool defaultToFollowing) const;
|
Chris@24
|
61
|
Chris@46
|
62 virtual QString toXmlString(QString indent = "",
|
Chris@46
|
63 QString extraAttributes = "") const;
|
Chris@46
|
64
|
Chris@24
|
65 protected:
|
Chris@24
|
66 SelectionList m_selections;
|
Chris@24
|
67 };
|
Chris@24
|
68
|
Chris@24
|
69
|
Chris@8
|
70 #endif
|