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@52
|
4 Sonic Visualiser
|
Chris@52
|
5 An audio file viewer and annotation editor.
|
Chris@52
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@52
|
7 This file copyright 2006 Chris Cannam.
|
Chris@8
|
8
|
Chris@52
|
9 This program is free software; you can redistribute it and/or
|
Chris@52
|
10 modify it under the terms of the GNU General Public License as
|
Chris@52
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@52
|
12 License, or (at your option) any later version. See the file
|
Chris@52
|
13 COPYING included with this distribution for more information.
|
Chris@8
|
14 */
|
Chris@8
|
15
|
Chris@8
|
16 #ifndef _SELECTION_H_
|
Chris@8
|
17 #define _SELECTION_H_
|
Chris@8
|
18
|
Chris@8
|
19 #include <cstddef>
|
Chris@24
|
20 #include <set>
|
Chris@8
|
21
|
Chris@46
|
22 #include "XmlExportable.h"
|
Chris@46
|
23
|
Chris@8
|
24 class Selection
|
Chris@8
|
25 {
|
Chris@8
|
26 public:
|
Chris@8
|
27 Selection();
|
Chris@928
|
28 Selection(int startFrame, int endFrame);
|
Chris@8
|
29 Selection(const Selection &);
|
Chris@8
|
30 Selection &operator=(const Selection &);
|
Chris@8
|
31 virtual ~Selection();
|
Chris@8
|
32
|
Chris@8
|
33 bool isEmpty() const;
|
Chris@928
|
34 int getStartFrame() const;
|
Chris@928
|
35 int getEndFrame() const;
|
Chris@928
|
36 bool contains(int frame) const;
|
Chris@8
|
37
|
Chris@8
|
38 bool operator<(const Selection &) const;
|
Chris@8
|
39 bool operator==(const Selection &) const;
|
Chris@8
|
40
|
Chris@8
|
41 protected:
|
Chris@928
|
42 int m_startFrame;
|
Chris@928
|
43 int m_endFrame;
|
Chris@8
|
44 };
|
Chris@8
|
45
|
Chris@46
|
46 class MultiSelection : public XmlExportable
|
Chris@24
|
47 {
|
Chris@24
|
48 public:
|
Chris@24
|
49 MultiSelection();
|
Chris@24
|
50 virtual ~MultiSelection();
|
Chris@24
|
51
|
Chris@24
|
52 typedef std::set<Selection> SelectionList;
|
Chris@24
|
53
|
Chris@24
|
54 const SelectionList &getSelections() const;
|
Chris@24
|
55 void setSelection(const Selection &selection);
|
Chris@24
|
56 void addSelection(const Selection &selection);
|
Chris@24
|
57 void removeSelection(const Selection &selection);
|
Chris@24
|
58 void clearSelections();
|
Chris@24
|
59
|
Chris@928
|
60 void getExtents(int &startFrame, int &endFrame) const;
|
Chris@300
|
61
|
Chris@24
|
62 /**
|
Chris@24
|
63 * Return the selection that contains a given frame.
|
Chris@24
|
64 * If defaultToFollowing is true, and if the frame is not in a
|
Chris@24
|
65 * selected area, return the next selection after the given frame.
|
Chris@24
|
66 * Return the empty selection if no appropriate selection is found.
|
Chris@24
|
67 */
|
Chris@928
|
68 Selection getContainingSelection(int frame, bool defaultToFollowing) const;
|
Chris@24
|
69
|
Chris@314
|
70 virtual void toXml(QTextStream &stream, QString indent = "",
|
Chris@314
|
71 QString extraAttributes = "") const;
|
Chris@46
|
72
|
Chris@24
|
73 protected:
|
Chris@24
|
74 SelectionList m_selections;
|
Chris@24
|
75 };
|
Chris@24
|
76
|
Chris@24
|
77
|
Chris@8
|
78 #endif
|