comparison layer/Layer.cpp @ 360:d58701996fae

* Update remaining editable layers to support proper realignment on copy/paste * Permit pasting when no suitable layer is current: create a new layer on paste * Add preference for showing the splash screen or not * Rename spectrogram smoothing prefs (partly following Craig's suggestions)
author Chris Cannam
date Wed, 06 Feb 2008 14:15:09 +0000
parents 020c485aa7e0
children 6167a28d25fc
comparison
equal deleted inserted replaced
359:020c485aa7e0 360:d58701996fae
182 return v->alignFromReference(frame); 182 return v->alignFromReference(frame);
183 } 183 }
184 } 184 }
185 185
186 bool 186 bool
187 Layer::clipboardHasDifferentAlignment(View *v, const Clipboard &clip) const
188 {
189 // Notes on pasting to an aligned layer:
190 //
191 // Each point may have a reference frame that may differ from the
192 // point's given frame (in its source model). If it has no
193 // reference frame, we have to assume the source model was not
194 // aligned or was the reference model: when cutting or copying
195 // points from a layer, we must always set their reference frame
196 // correctly if we are aligned.
197 //
198 // When pasting:
199 // - if point's reference and aligned frames differ:
200 // - if this layer is aligned:
201 // - if point's aligned frame matches this layer's aligned version
202 // of point's reference frame:
203 // - we can paste at reference frame or our frame
204 // - else
205 // - we can paste at reference frame, result of aligning reference
206 // frame in our model, or literal source frame
207 // - else
208 // - we can paste at reference (our) frame, or literal source frame
209 // - else
210 // - if this layer is aligned:
211 // - we can paste at reference (point's only available) frame,
212 // or result of aligning reference frame in our model
213 // - else
214 // - we can only paste at reference frame
215 //
216 // Which of these alternatives are useful?
217 //
218 // Example: we paste between two tracks that are aligned to the
219 // same reference, and the points are at 10s and 20s in the source
220 // track, corresponding to 5s and 10s in the reference but 20s and
221 // 30s in the target track.
222 //
223 // The obvious default is to paste at 20s and 30s; if we aren't
224 // doing that, would it be better to paste at 5s and 10s or at 10s
225 // and 20s? We probably don't ever want to do the former, do we?
226 // We either want to be literal all the way through, or aligned
227 // all the way through.
228
229 for (Clipboard::PointList::const_iterator i = clip.getPoints().begin();
230 i != clip.getPoints().end(); ++i) {
231
232 // In principle, we want to know whether the aligned version
233 // of the reference frame in our layer is the same as the
234 // source frame contained in the clipboard point. However,
235 // because of rounding during alignment, that won't
236 // necessarily be the case even if the clipboard point came
237 // from our layer! What we need to check is whether, if we
238 // aligned the clipboard point's frame back to the reference
239 // using this layer's alignment, we would obtain the same
240 // reference frame as that for the clipboard point.
241
242 // What if the clipboard point has no reference frame? Then
243 // we have to treat it as having its own frame as the
244 // reference (i.e. having been copied from the reference
245 // model).
246
247 long sourceFrame = i->getFrame();
248 long referenceFrame = sourceFrame;
249 if (i->haveReferenceFrame()) {
250 referenceFrame = i->getReferenceFrame();
251 }
252 long myMappedFrame = alignToReference(v, sourceFrame);
253
254 // std::cerr << "sourceFrame = " << sourceFrame << ", referenceFrame = " << referenceFrame << " (have = " << i->haveReferenceFrame() << "), myMappedFrame = " << myMappedFrame << std::endl;
255
256 if (myMappedFrame != referenceFrame) return true;
257 }
258
259 return false;
260 }
261
262 bool
187 Layer::MeasureRect::operator<(const MeasureRect &mr) const 263 Layer::MeasureRect::operator<(const MeasureRect &mr) const
188 { 264 {
189 if (haveFrames) { 265 if (haveFrames) {
190 if (startFrame == mr.startFrame) { 266 if (startFrame == mr.startFrame) {
191 if (endFrame != mr.endFrame) { 267 if (endFrame != mr.endFrame) {