Chris@74
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@74
|
2
|
Chris@74
|
3 /*
|
Chris@74
|
4 Sonic Visualiser
|
Chris@74
|
5 An audio file viewer and annotation editor.
|
Chris@74
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@74
|
7 This file copyright 2006 Chris Cannam.
|
Chris@74
|
8
|
Chris@74
|
9 This program is free software; you can redistribute it and/or
|
Chris@74
|
10 modify it under the terms of the GNU General Public License as
|
Chris@74
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@74
|
12 License, or (at your option) any later version. See the file
|
Chris@74
|
13 COPYING included with this distribution for more information.
|
Chris@74
|
14 */
|
Chris@74
|
15
|
Chris@1581
|
16 #ifndef SV_CLIPBOARD_H
|
Chris@1581
|
17 #define SV_CLIPBOARD_H
|
Chris@74
|
18
|
Chris@74
|
19 #include <QString>
|
Chris@74
|
20 #include <vector>
|
Chris@74
|
21
|
Chris@1044
|
22 #include "BaseTypes.h"
|
Chris@1044
|
23
|
Chris@74
|
24 class Clipboard
|
Chris@74
|
25 {
|
Chris@74
|
26 public:
|
Chris@74
|
27 class Point
|
Chris@74
|
28 {
|
Chris@74
|
29 public:
|
Chris@1044
|
30 Point(sv_frame_t frame, QString label);
|
Chris@1044
|
31 Point(sv_frame_t frame, float value, QString label);
|
Chris@1044
|
32 Point(sv_frame_t frame, float value, sv_frame_t duration, QString label);
|
Chris@1044
|
33 Point(sv_frame_t frame, float value, sv_frame_t duration, float level, QString label);
|
Chris@1610
|
34
|
Chris@1610
|
35 Point(const Point &point) =default;
|
Chris@1610
|
36 Point &operator=(const Point &point) =default;
|
Chris@74
|
37
|
Chris@74
|
38 bool haveFrame() const;
|
Chris@1044
|
39 sv_frame_t getFrame() const;
|
Chris@1044
|
40 Point withFrame(sv_frame_t frame) const;
|
Chris@74
|
41
|
Chris@74
|
42 bool haveValue() const;
|
Chris@74
|
43 float getValue() const;
|
Chris@872
|
44 Point withValue(float value) const;
|
Chris@74
|
45
|
Chris@74
|
46 bool haveDuration() const;
|
Chris@1044
|
47 sv_frame_t getDuration() const;
|
Chris@1044
|
48 Point withDuration(sv_frame_t duration) const;
|
Chris@74
|
49
|
Chris@74
|
50 bool haveLabel() const;
|
Chris@74
|
51 QString getLabel() const;
|
Chris@872
|
52 Point withLabel(QString label) const;
|
Chris@74
|
53
|
Chris@340
|
54 bool haveLevel() const;
|
Chris@340
|
55 float getLevel() const;
|
Chris@872
|
56 Point withLevel(float level) const;
|
Chris@340
|
57
|
Chris@370
|
58 bool haveReferenceFrame() const;
|
Chris@370
|
59 bool referenceFrameDiffers() const; // from point frame
|
Chris@370
|
60
|
Chris@1044
|
61 sv_frame_t getReferenceFrame() const;
|
Chris@1044
|
62 void setReferenceFrame(sv_frame_t);
|
Chris@340
|
63
|
Chris@74
|
64 private:
|
Chris@1610
|
65 // Order of fields here is chosen to minimise overall size of struct.
|
Chris@1610
|
66 // If you change something, check what difference it makes to packing.
|
Chris@1610
|
67 bool m_haveValue : 1;
|
Chris@1610
|
68 bool m_haveLevel : 1;
|
Chris@1610
|
69 bool m_haveFrame : 1;
|
Chris@1610
|
70 bool m_haveDuration : 1;
|
Chris@1610
|
71 bool m_haveReferenceFrame : 1;
|
Chris@1610
|
72 bool m_haveLabel : 1;
|
Chris@1610
|
73 float m_value;
|
Chris@1610
|
74 float m_level;
|
Chris@1044
|
75 sv_frame_t m_frame;
|
Chris@1044
|
76 sv_frame_t m_duration;
|
Chris@1610
|
77 sv_frame_t m_referenceFrame;
|
Chris@74
|
78 QString m_label;
|
Chris@74
|
79 };
|
Chris@74
|
80
|
Chris@74
|
81 Clipboard();
|
Chris@74
|
82 ~Clipboard();
|
Chris@74
|
83
|
Chris@74
|
84 typedef std::vector<Point> PointList;
|
Chris@74
|
85
|
Chris@74
|
86 void clear();
|
Chris@74
|
87 bool empty() const;
|
Chris@74
|
88 const PointList &getPoints() const;
|
Chris@74
|
89 void setPoints(const PointList &points);
|
Chris@74
|
90 void addPoint(const Point &point);
|
Chris@74
|
91
|
Chris@370
|
92 bool haveReferenceFrames() const;
|
Chris@369
|
93 bool referenceFramesDiffer() const;
|
Chris@340
|
94
|
Chris@74
|
95 protected:
|
Chris@74
|
96 PointList m_points;
|
Chris@74
|
97 };
|
Chris@74
|
98
|
Chris@74
|
99 #endif
|