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_haveDuration(false),
00023     m_haveLabel(true),
00024     m_label(label),
00025     m_haveLevel(false),
00026     m_level(0.f),
00027     m_haveReferenceFrame(false),
00028     m_referenceFrame(frame)
00029 {
00030 }
00031 
00032 Clipboard::Point::Point(long frame, float value, QString label) :
00033     m_haveFrame(true),
00034     m_frame(frame),
00035     m_haveValue(true),
00036     m_value(value),
00037     m_haveDuration(false),
00038     m_haveLabel(true),
00039     m_label(label),
00040     m_haveLevel(false),
00041     m_level(0.f),
00042     m_haveReferenceFrame(false),
00043     m_referenceFrame(frame)
00044 {
00045 }
00046 
00047 Clipboard::Point::Point(long frame, float value, size_t duration, QString label) :
00048     m_haveFrame(true),
00049     m_frame(frame),
00050     m_haveValue(true),
00051     m_value(value),
00052     m_haveDuration(true),
00053     m_duration(duration),
00054     m_haveLabel(true),
00055     m_label(label),
00056     m_haveLevel(false),
00057     m_level(0.f),
00058     m_haveReferenceFrame(false),
00059     m_referenceFrame(frame)
00060 {
00061 }
00062 
00063 Clipboard::Point::Point(long frame, float value, size_t duration, float level, QString label) :
00064     m_haveFrame(true),
00065     m_frame(frame),
00066     m_haveValue(true),
00067     m_value(value),
00068     m_haveDuration(true),
00069     m_duration(duration),
00070     m_haveLabel(true),
00071     m_label(label),
00072     m_haveLevel(true),
00073     m_level(level),
00074     m_haveReferenceFrame(false),
00075     m_referenceFrame(frame)
00076 {
00077 }
00078 
00079 Clipboard::Point::Point(const Point &point) :
00080     m_haveFrame(point.m_haveFrame),
00081     m_frame(point.m_frame),
00082     m_haveValue(point.m_haveValue),
00083     m_value(point.m_value),
00084     m_haveDuration(point.m_haveDuration),
00085     m_duration(point.m_duration),
00086     m_haveLabel(point.m_haveLabel),
00087     m_label(point.m_label),
00088     m_haveLevel(point.m_haveLevel),
00089     m_level(point.m_level),
00090     m_haveReferenceFrame(point.m_haveReferenceFrame),
00091     m_referenceFrame(point.m_referenceFrame)
00092 {
00093 }
00094 
00095 Clipboard::Point &
00096 Clipboard::Point::operator=(const Point &point)
00097 {
00098     if (this == &point) return *this;
00099     m_haveFrame = point.m_haveFrame;
00100     m_frame = point.m_frame;
00101     m_haveValue = point.m_haveValue;
00102     m_value = point.m_value;
00103     m_haveDuration = point.m_haveDuration;
00104     m_duration = point.m_duration;
00105     m_haveLabel = point.m_haveLabel;
00106     m_label = point.m_label;
00107     m_haveLevel = point.m_haveLevel;
00108     m_level = point.m_level;
00109     m_haveReferenceFrame = point.m_haveReferenceFrame;
00110     m_referenceFrame = point.m_referenceFrame;
00111     return *this;
00112 }
00113 
00114 bool
00115 Clipboard::Point::haveFrame() const
00116 {
00117     return m_haveFrame;
00118 }
00119 
00120 long
00121 Clipboard::Point::getFrame() const
00122 {
00123     return m_frame;
00124 }
00125 
00126 bool
00127 Clipboard::Point::haveValue() const
00128 {
00129     return m_haveValue;
00130 }
00131 
00132 float
00133 Clipboard::Point::getValue() const
00134 {
00135     return m_value;
00136 }
00137 
00138 bool
00139 Clipboard::Point::haveDuration() const
00140 {
00141     return m_haveDuration;
00142 }
00143 
00144 size_t
00145 Clipboard::Point::getDuration() const
00146 {
00147     return m_duration;
00148 }
00149 
00150 bool
00151 Clipboard::Point::haveLabel() const
00152 {
00153     return m_haveLabel;
00154 }
00155 
00156 QString
00157 Clipboard::Point::getLabel() const
00158 {
00159     return m_label;
00160 }
00161 
00162 bool
00163 Clipboard::Point::haveLevel() const
00164 {
00165     return m_haveLevel;
00166 }
00167 
00168 float
00169 Clipboard::Point::getLevel() const
00170 {
00171     return m_level;
00172 }
00173 
00174 bool
00175 Clipboard::Point::haveReferenceFrame() const
00176 {
00177     return m_haveReferenceFrame;
00178 }
00179 
00180 bool
00181 Clipboard::Point::referenceFrameDiffers() const
00182 {
00183     return m_haveReferenceFrame && (m_referenceFrame != m_frame);
00184 }
00185 
00186 long
00187 Clipboard::Point::getReferenceFrame() const
00188 {
00189     return m_referenceFrame;
00190 }
00191 
00192 void
00193 Clipboard::Point::setReferenceFrame(long f) 
00194 {
00195     m_haveReferenceFrame = true;
00196     m_referenceFrame = f;
00197 }
00198 
00199 Clipboard::Clipboard() { }
00200 Clipboard::~Clipboard() { }
00201 
00202 void
00203 Clipboard::clear()
00204 {
00205     m_points.clear();
00206 }
00207 
00208 bool
00209 Clipboard::empty() const
00210 {
00211     return m_points.empty();
00212 }
00213 
00214 const Clipboard::PointList &
00215 Clipboard::getPoints() const
00216 {
00217     return m_points;
00218 }
00219 
00220 void
00221 Clipboard::setPoints(const PointList &pl)
00222 {
00223     m_points = pl;
00224 }
00225 
00226 void
00227 Clipboard::addPoint(const Point &point)
00228 {
00229     m_points.push_back(point);
00230 }
00231 
00232 bool
00233 Clipboard::haveReferenceFrames() const
00234 {
00235     for (PointList::const_iterator i = m_points.begin();
00236          i != m_points.end(); ++i) {
00237         if (i->haveReferenceFrame()) return true;
00238     } 
00239     return false;
00240 }
00241 
00242 bool
00243 Clipboard::referenceFramesDiffer() const
00244 {
00245     for (PointList::const_iterator i = m_points.begin();
00246          i != m_points.end(); ++i) {
00247         if (i->referenceFrameDiffers()) return true;
00248     } 
00249     return false;
00250 }
00251 

Generated on Wed Feb 20 15:45:25 2008 for SonicVisualiser by  doxygen 1.5.1