annotate base/Clipboard.cpp @ 1247:8f076d02569a piper

Make SVDEBUG always write to a log file -- formerly this was disabled in NDEBUG builds. I think there's little use to that, it just means that we keep adding more cerr debug output because we aren't getting the log we need. And SVDEBUG logging is not usually used in tight loops, I don't think the performance overhead is too serious. Also update the About box.
author Chris Cannam
date Thu, 03 Nov 2016 14:57:00 +0000
parents 31f01931b781
children 7db29268cf4c
rev   line source
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@74 16 #include "Clipboard.h"
Chris@74 17
Chris@1044 18 Clipboard::Point::Point(sv_frame_t frame, QString label) :
Chris@74 19 m_haveFrame(true),
Chris@74 20 m_frame(frame),
Chris@74 21 m_haveValue(false),
Chris@977 22 m_value(0),
Chris@74 23 m_haveDuration(false),
Chris@955 24 m_duration(0),
Chris@74 25 m_haveLabel(true),
Chris@340 26 m_label(label),
Chris@340 27 m_haveLevel(false),
Chris@340 28 m_level(0.f),
Chris@370 29 m_haveReferenceFrame(false),
Chris@340 30 m_referenceFrame(frame)
Chris@74 31 {
Chris@74 32 }
Chris@74 33
Chris@1044 34 Clipboard::Point::Point(sv_frame_t frame, float value, QString label) :
Chris@74 35 m_haveFrame(true),
Chris@74 36 m_frame(frame),
Chris@74 37 m_haveValue(true),
Chris@74 38 m_value(value),
Chris@74 39 m_haveDuration(false),
Chris@955 40 m_duration(0),
Chris@74 41 m_haveLabel(true),
Chris@340 42 m_label(label),
Chris@340 43 m_haveLevel(false),
Chris@340 44 m_level(0.f),
Chris@370 45 m_haveReferenceFrame(false),
Chris@340 46 m_referenceFrame(frame)
Chris@74 47 {
Chris@74 48 }
Chris@74 49
Chris@1044 50 Clipboard::Point::Point(sv_frame_t frame, float value, sv_frame_t duration, QString label) :
Chris@74 51 m_haveFrame(true),
Chris@74 52 m_frame(frame),
Chris@74 53 m_haveValue(true),
Chris@74 54 m_value(value),
Chris@74 55 m_haveDuration(true),
Chris@74 56 m_duration(duration),
Chris@74 57 m_haveLabel(true),
Chris@340 58 m_label(label),
Chris@340 59 m_haveLevel(false),
Chris@340 60 m_level(0.f),
Chris@370 61 m_haveReferenceFrame(false),
Chris@340 62 m_referenceFrame(frame)
Chris@340 63 {
Chris@340 64 }
Chris@340 65
Chris@1044 66 Clipboard::Point::Point(sv_frame_t frame, float value, sv_frame_t duration, float level, QString label) :
Chris@340 67 m_haveFrame(true),
Chris@340 68 m_frame(frame),
Chris@340 69 m_haveValue(true),
Chris@340 70 m_value(value),
Chris@340 71 m_haveDuration(true),
Chris@340 72 m_duration(duration),
Chris@340 73 m_haveLabel(true),
Chris@340 74 m_label(label),
Chris@340 75 m_haveLevel(true),
Chris@340 76 m_level(level),
Chris@370 77 m_haveReferenceFrame(false),
Chris@340 78 m_referenceFrame(frame)
Chris@74 79 {
Chris@74 80 }
Chris@74 81
Chris@74 82 Clipboard::Point::Point(const Point &point) :
Chris@74 83 m_haveFrame(point.m_haveFrame),
Chris@74 84 m_frame(point.m_frame),
Chris@74 85 m_haveValue(point.m_haveValue),
Chris@74 86 m_value(point.m_value),
Chris@74 87 m_haveDuration(point.m_haveDuration),
Chris@74 88 m_duration(point.m_duration),
Chris@74 89 m_haveLabel(point.m_haveLabel),
Chris@340 90 m_label(point.m_label),
Chris@340 91 m_haveLevel(point.m_haveLevel),
Chris@340 92 m_level(point.m_level),
Chris@370 93 m_haveReferenceFrame(point.m_haveReferenceFrame),
Chris@340 94 m_referenceFrame(point.m_referenceFrame)
Chris@74 95 {
Chris@74 96 }
Chris@74 97
Chris@74 98 Clipboard::Point &
Chris@74 99 Clipboard::Point::operator=(const Point &point)
Chris@74 100 {
Chris@74 101 if (this == &point) return *this;
Chris@74 102 m_haveFrame = point.m_haveFrame;
Chris@74 103 m_frame = point.m_frame;
Chris@74 104 m_haveValue = point.m_haveValue;
Chris@74 105 m_value = point.m_value;
Chris@74 106 m_haveDuration = point.m_haveDuration;
Chris@74 107 m_duration = point.m_duration;
Chris@74 108 m_haveLabel = point.m_haveLabel;
Chris@74 109 m_label = point.m_label;
Chris@340 110 m_haveLevel = point.m_haveLevel;
Chris@340 111 m_level = point.m_level;
Chris@370 112 m_haveReferenceFrame = point.m_haveReferenceFrame;
Chris@340 113 m_referenceFrame = point.m_referenceFrame;
Chris@74 114 return *this;
Chris@74 115 }
Chris@74 116
Chris@74 117 bool
Chris@74 118 Clipboard::Point::haveFrame() const
Chris@74 119 {
Chris@74 120 return m_haveFrame;
Chris@74 121 }
Chris@74 122
Chris@1044 123 sv_frame_t
Chris@74 124 Clipboard::Point::getFrame() const
Chris@74 125 {
Chris@74 126 return m_frame;
Chris@74 127 }
Chris@74 128
Chris@872 129 Clipboard::Point
Chris@1044 130 Clipboard::Point::withFrame(sv_frame_t frame) const
Chris@872 131 {
Chris@872 132 Point p(*this);
Chris@872 133 p.m_haveFrame = true;
Chris@872 134 p.m_frame = frame;
Chris@872 135 return p;
Chris@872 136 }
Chris@872 137
Chris@74 138 bool
Chris@74 139 Clipboard::Point::haveValue() const
Chris@74 140 {
Chris@74 141 return m_haveValue;
Chris@74 142 }
Chris@74 143
Chris@74 144 float
Chris@74 145 Clipboard::Point::getValue() const
Chris@74 146 {
Chris@74 147 return m_value;
Chris@74 148 }
Chris@74 149
Chris@872 150 Clipboard::Point
Chris@872 151 Clipboard::Point::withValue(float value) const
Chris@872 152 {
Chris@872 153 Point p(*this);
Chris@872 154 p.m_haveValue = true;
Chris@872 155 p.m_value = value;
Chris@872 156 return p;
Chris@872 157 }
Chris@872 158
Chris@74 159 bool
Chris@74 160 Clipboard::Point::haveDuration() const
Chris@74 161 {
Chris@74 162 return m_haveDuration;
Chris@74 163 }
Chris@74 164
Chris@1044 165 sv_frame_t
Chris@74 166 Clipboard::Point::getDuration() const
Chris@74 167 {
Chris@74 168 return m_duration;
Chris@74 169 }
Chris@74 170
Chris@872 171 Clipboard::Point
Chris@1044 172 Clipboard::Point::withDuration(sv_frame_t duration) const
Chris@872 173 {
Chris@872 174 Point p(*this);
Chris@872 175 p.m_haveDuration = true;
Chris@872 176 p.m_duration = duration;
Chris@872 177 return p;
Chris@872 178 }
Chris@872 179
Chris@74 180 bool
Chris@74 181 Clipboard::Point::haveLabel() const
Chris@74 182 {
Chris@74 183 return m_haveLabel;
Chris@74 184 }
Chris@74 185
Chris@74 186 QString
Chris@74 187 Clipboard::Point::getLabel() const
Chris@74 188 {
Chris@74 189 return m_label;
Chris@74 190 }
Chris@74 191
Chris@872 192 Clipboard::Point
Chris@872 193 Clipboard::Point::withLabel(QString label) const
Chris@872 194 {
Chris@872 195 Point p(*this);
Chris@872 196 p.m_haveLabel = true;
Chris@872 197 p.m_label = label;
Chris@872 198 return p;
Chris@872 199 }
Chris@872 200
Chris@340 201 bool
Chris@340 202 Clipboard::Point::haveLevel() const
Chris@340 203 {
Chris@340 204 return m_haveLevel;
Chris@340 205 }
Chris@340 206
Chris@340 207 float
Chris@340 208 Clipboard::Point::getLevel() const
Chris@340 209 {
Chris@340 210 return m_level;
Chris@340 211 }
Chris@340 212
Chris@872 213 Clipboard::Point
Chris@872 214 Clipboard::Point::withLevel(float level) const
Chris@872 215 {
Chris@872 216 Point p(*this);
Chris@872 217 p.m_haveLevel = true;
Chris@872 218 p.m_level = level;
Chris@872 219 return p;
Chris@872 220 }
Chris@872 221
Chris@340 222 bool
Chris@370 223 Clipboard::Point::haveReferenceFrame() const
Chris@340 224 {
Chris@370 225 return m_haveReferenceFrame;
Chris@370 226 }
Chris@370 227
Chris@370 228 bool
Chris@370 229 Clipboard::Point::referenceFrameDiffers() const
Chris@370 230 {
Chris@370 231 return m_haveReferenceFrame && (m_referenceFrame != m_frame);
Chris@340 232 }
Chris@340 233
Chris@1044 234 sv_frame_t
Chris@340 235 Clipboard::Point::getReferenceFrame() const
Chris@340 236 {
Chris@340 237 return m_referenceFrame;
Chris@340 238 }
Chris@340 239
Chris@340 240 void
Chris@1044 241 Clipboard::Point::setReferenceFrame(sv_frame_t f)
Chris@340 242 {
Chris@370 243 m_haveReferenceFrame = true;
Chris@340 244 m_referenceFrame = f;
Chris@340 245 }
Chris@340 246
Chris@74 247 Clipboard::Clipboard() { }
Chris@74 248 Clipboard::~Clipboard() { }
Chris@74 249
Chris@74 250 void
Chris@74 251 Clipboard::clear()
Chris@74 252 {
Chris@74 253 m_points.clear();
Chris@74 254 }
Chris@74 255
Chris@74 256 bool
Chris@74 257 Clipboard::empty() const
Chris@74 258 {
Chris@74 259 return m_points.empty();
Chris@74 260 }
Chris@74 261
Chris@74 262 const Clipboard::PointList &
Chris@74 263 Clipboard::getPoints() const
Chris@74 264 {
Chris@74 265 return m_points;
Chris@74 266 }
Chris@74 267
Chris@74 268 void
Chris@74 269 Clipboard::setPoints(const PointList &pl)
Chris@74 270 {
Chris@74 271 m_points = pl;
Chris@74 272 }
Chris@74 273
Chris@74 274 void
Chris@74 275 Clipboard::addPoint(const Point &point)
Chris@74 276 {
Chris@74 277 m_points.push_back(point);
Chris@74 278 }
Chris@74 279
Chris@340 280 bool
Chris@370 281 Clipboard::haveReferenceFrames() const
Chris@370 282 {
Chris@370 283 for (PointList::const_iterator i = m_points.begin();
Chris@370 284 i != m_points.end(); ++i) {
Chris@370 285 if (i->haveReferenceFrame()) return true;
Chris@370 286 }
Chris@370 287 return false;
Chris@370 288 }
Chris@370 289
Chris@370 290 bool
Chris@369 291 Clipboard::referenceFramesDiffer() const
Chris@340 292 {
Chris@340 293 for (PointList::const_iterator i = m_points.begin();
Chris@340 294 i != m_points.end(); ++i) {
Chris@370 295 if (i->referenceFrameDiffers()) return true;
Chris@340 296 }
Chris@340 297 return false;
Chris@340 298 }
Chris@340 299