svcore  1.9
Clipboard.cpp
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2006 Chris Cannam.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #include "Clipboard.h"
00017 
00018 Clipboard::Point::Point(long frame, QString label) :
00019     m_haveFrame(true),
00020     m_frame(frame),
00021     m_haveValue(false),
00022     m_value(0),
00023     m_haveDuration(false),
00024     m_duration(0),
00025     m_haveLabel(true),
00026     m_label(label),
00027     m_haveLevel(false),
00028     m_level(0.f),
00029     m_haveReferenceFrame(false),
00030     m_referenceFrame(frame)
00031 {
00032 }
00033 
00034 Clipboard::Point::Point(long frame, float value, QString label) :
00035     m_haveFrame(true),
00036     m_frame(frame),
00037     m_haveValue(true),
00038     m_value(value),
00039     m_haveDuration(false),
00040     m_duration(0),
00041     m_haveLabel(true),
00042     m_label(label),
00043     m_haveLevel(false),
00044     m_level(0.f),
00045     m_haveReferenceFrame(false),
00046     m_referenceFrame(frame)
00047 {
00048 }
00049 
00050 Clipboard::Point::Point(long frame, float value, int duration, QString label) :
00051     m_haveFrame(true),
00052     m_frame(frame),
00053     m_haveValue(true),
00054     m_value(value),
00055     m_haveDuration(true),
00056     m_duration(duration),
00057     m_haveLabel(true),
00058     m_label(label),
00059     m_haveLevel(false),
00060     m_level(0.f),
00061     m_haveReferenceFrame(false),
00062     m_referenceFrame(frame)
00063 {
00064 }
00065 
00066 Clipboard::Point::Point(long frame, float value, int duration, float level, QString label) :
00067     m_haveFrame(true),
00068     m_frame(frame),
00069     m_haveValue(true),
00070     m_value(value),
00071     m_haveDuration(true),
00072     m_duration(duration),
00073     m_haveLabel(true),
00074     m_label(label),
00075     m_haveLevel(true),
00076     m_level(level),
00077     m_haveReferenceFrame(false),
00078     m_referenceFrame(frame)
00079 {
00080 }
00081 
00082 Clipboard::Point::Point(const Point &point) :
00083     m_haveFrame(point.m_haveFrame),
00084     m_frame(point.m_frame),
00085     m_haveValue(point.m_haveValue),
00086     m_value(point.m_value),
00087     m_haveDuration(point.m_haveDuration),
00088     m_duration(point.m_duration),
00089     m_haveLabel(point.m_haveLabel),
00090     m_label(point.m_label),
00091     m_haveLevel(point.m_haveLevel),
00092     m_level(point.m_level),
00093     m_haveReferenceFrame(point.m_haveReferenceFrame),
00094     m_referenceFrame(point.m_referenceFrame)
00095 {
00096 }
00097 
00098 Clipboard::Point &
00099 Clipboard::Point::operator=(const Point &point)
00100 {
00101     if (this == &point) return *this;
00102     m_haveFrame = point.m_haveFrame;
00103     m_frame = point.m_frame;
00104     m_haveValue = point.m_haveValue;
00105     m_value = point.m_value;
00106     m_haveDuration = point.m_haveDuration;
00107     m_duration = point.m_duration;
00108     m_haveLabel = point.m_haveLabel;
00109     m_label = point.m_label;
00110     m_haveLevel = point.m_haveLevel;
00111     m_level = point.m_level;
00112     m_haveReferenceFrame = point.m_haveReferenceFrame;
00113     m_referenceFrame = point.m_referenceFrame;
00114     return *this;
00115 }
00116 
00117 bool
00118 Clipboard::Point::haveFrame() const
00119 {
00120     return m_haveFrame;
00121 }
00122 
00123 long
00124 Clipboard::Point::getFrame() const
00125 {
00126     return m_frame;
00127 }
00128 
00129 Clipboard::Point
00130 Clipboard::Point::withFrame(long frame) const
00131 {
00132     Point p(*this);
00133     p.m_haveFrame = true;
00134     p.m_frame = frame;
00135     return p;
00136 }
00137 
00138 bool
00139 Clipboard::Point::haveValue() const
00140 {
00141     return m_haveValue;
00142 }
00143 
00144 float
00145 Clipboard::Point::getValue() const
00146 {
00147     return m_value;
00148 }
00149 
00150 Clipboard::Point
00151 Clipboard::Point::withValue(float value) const
00152 {
00153     Point p(*this);
00154     p.m_haveValue = true;
00155     p.m_value = value;
00156     return p;
00157 }
00158 
00159 bool
00160 Clipboard::Point::haveDuration() const
00161 {
00162     return m_haveDuration;
00163 }
00164 
00165 int
00166 Clipboard::Point::getDuration() const
00167 {
00168     return m_duration;
00169 }
00170 
00171 Clipboard::Point
00172 Clipboard::Point::withDuration(int duration) const
00173 {
00174     Point p(*this);
00175     p.m_haveDuration = true;
00176     p.m_duration = duration;
00177     return p;
00178 }
00179 
00180 bool
00181 Clipboard::Point::haveLabel() const
00182 {
00183     return m_haveLabel;
00184 }
00185 
00186 QString
00187 Clipboard::Point::getLabel() const
00188 {
00189     return m_label;
00190 }
00191 
00192 Clipboard::Point
00193 Clipboard::Point::withLabel(QString label) const
00194 {
00195     Point p(*this);
00196     p.m_haveLabel = true;
00197     p.m_label = label;
00198     return p;
00199 }
00200 
00201 bool
00202 Clipboard::Point::haveLevel() const
00203 {
00204     return m_haveLevel;
00205 }
00206 
00207 float
00208 Clipboard::Point::getLevel() const
00209 {
00210     return m_level;
00211 }
00212 
00213 Clipboard::Point
00214 Clipboard::Point::withLevel(float level) const
00215 {
00216     Point p(*this);
00217     p.m_haveLevel = true;
00218     p.m_level = level;
00219     return p;
00220 }
00221 
00222 bool
00223 Clipboard::Point::haveReferenceFrame() const
00224 {
00225     return m_haveReferenceFrame;
00226 }
00227 
00228 bool
00229 Clipboard::Point::referenceFrameDiffers() const
00230 {
00231     return m_haveReferenceFrame && (m_referenceFrame != m_frame);
00232 }
00233 
00234 long
00235 Clipboard::Point::getReferenceFrame() const
00236 {
00237     return m_referenceFrame;
00238 }
00239 
00240 void
00241 Clipboard::Point::setReferenceFrame(long f) 
00242 {
00243     m_haveReferenceFrame = true;
00244     m_referenceFrame = f;
00245 }
00246 
00247 Clipboard::Clipboard() { }
00248 Clipboard::~Clipboard() { }
00249 
00250 void
00251 Clipboard::clear()
00252 {
00253     m_points.clear();
00254 }
00255 
00256 bool
00257 Clipboard::empty() const
00258 {
00259     return m_points.empty();
00260 }
00261 
00262 const Clipboard::PointList &
00263 Clipboard::getPoints() const
00264 {
00265     return m_points;
00266 }
00267 
00268 void
00269 Clipboard::setPoints(const PointList &pl)
00270 {
00271     m_points = pl;
00272 }
00273 
00274 void
00275 Clipboard::addPoint(const Point &point)
00276 {
00277     m_points.push_back(point);
00278 }
00279 
00280 bool
00281 Clipboard::haveReferenceFrames() const
00282 {
00283     for (PointList::const_iterator i = m_points.begin();
00284          i != m_points.end(); ++i) {
00285         if (i->haveReferenceFrame()) return true;
00286     } 
00287     return false;
00288 }
00289 
00290 bool
00291 Clipboard::referenceFramesDiffer() const
00292 {
00293     for (PointList::const_iterator i = m_points.begin();
00294          i != m_points.end(); ++i) {
00295         if (i->referenceFrameDiffers()) return true;
00296     } 
00297     return false;
00298 }
00299