svcore  1.9
Selection.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006 Chris Cannam.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef _SELECTION_H_
17 #define _SELECTION_H_
18 
19 #include <cstddef>
20 #include <set>
21 
22 #include "XmlExportable.h"
23 
39 class Selection
40 {
41 public:
42  Selection();
43  Selection(int startFrame, int endFrame);
44  Selection(const Selection &);
45  Selection &operator=(const Selection &);
46  virtual ~Selection();
47 
48  bool isEmpty() const;
49  int getStartFrame() const;
50  int getEndFrame() const;
51  bool contains(int frame) const;
52 
53  bool operator<(const Selection &) const;
54  bool operator==(const Selection &) const;
55 
56 protected:
59 };
60 
62 {
63 public:
65  virtual ~MultiSelection();
66 
67  typedef std::set<Selection> SelectionList;
68 
69  const SelectionList &getSelections() const;
70  void setSelection(const Selection &selection);
71  void addSelection(const Selection &selection);
72  void removeSelection(const Selection &selection);
73  void clearSelections();
74 
75  void getExtents(int &startFrame, int &endFrame) const;
76 
83  Selection getContainingSelection(int frame, bool defaultToFollowing) const;
84 
85  virtual void toXml(QTextStream &stream, QString indent = "",
86  QString extraAttributes = "") const;
87 
88 protected:
90 };
91 
92 
93 #endif
void removeSelection(const Selection &selection)
Definition: Selection.cpp:156
void setSelection(const Selection &selection)
Definition: Selection.cpp:117
int m_endFrame
Definition: Selection.h:58
bool isEmpty() const
Definition: Selection.cpp:57
A selection object simply represents a range in time, via start and end frame.
Definition: Selection.h:39
bool contains(int frame) const
Definition: Selection.cpp:75
virtual ~MultiSelection()
Definition: Selection.cpp:106
bool operator==(const Selection &) const
Definition: Selection.cpp:93
SelectionList m_selections
Definition: Selection.h:89
int getEndFrame() const
Definition: Selection.cpp:69
void addSelection(const Selection &selection)
Definition: Selection.cpp:124
void getExtents(int &startFrame, int &endFrame) const
Definition: Selection.cpp:177
Selection getContainingSelection(int frame, bool defaultToFollowing) const
Return the selection that contains a given frame.
Definition: Selection.cpp:196
bool operator<(const Selection &) const
Definition: Selection.cpp:81
std::set< Selection > SelectionList
Definition: Selection.h:67
const SelectionList & getSelections() const
Definition: Selection.cpp:111
void clearSelections()
Definition: Selection.cpp:169
int getStartFrame() const
Definition: Selection.cpp:63
Selection & operator=(const Selection &)
Definition: Selection.cpp:43
virtual ~Selection()
Definition: Selection.cpp:52
virtual void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const
Stream this exportable object out to XML on a text stream.
Definition: Selection.cpp:217
int m_startFrame
Definition: Selection.h:57