Layer.cpp
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006 Chris Cannam and QMUL.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #include "Layer.h"
17 #include "view/View.h"
18 #include "data/model/Model.h"
19 #include "widgets/CommandHistory.h"
20 
21 #include <iostream>
22 
23 #include <QMutexLocker>
24 #include <QMouseEvent>
25 #include <QTextStream>
26 
27 #include <QDomDocument>
28 #include <QDomElement>
29 #include <QDomNamedNodeMap>
30 #include <QDomAttr>
31 
32 #include "LayerFactory.h"
33 #include "base/PlayParameterRepository.h"
34 
35 #include <cmath>
36 
38  m_haveDraggingRect(false),
39  m_haveCurrentMeasureRect(false)
40 {
41 }
42 
44 {
45 // SVDEBUG << "Layer::~Layer(" << this << ")" << endl;
46 }
47 
48 void
49 Layer::connectSignals(ModelId modelId)
50 {
51  auto model = ModelById::get(modelId);
52  if (!model) return;
53 
54  connect(model.get(), SIGNAL(modelChanged(ModelId)),
55  this, SIGNAL(modelChanged(ModelId)));
56 
57  connect(model.get(), SIGNAL(modelChangedWithin(ModelId, sv_frame_t, sv_frame_t)),
58  this, SIGNAL(modelChangedWithin(ModelId, sv_frame_t, sv_frame_t)));
59 
60  connect(model.get(), SIGNAL(completionChanged(ModelId)),
61  this, SIGNAL(modelCompletionChanged(ModelId)));
62 
63  connect(model.get(), SIGNAL(alignmentCompletionChanged(ModelId)),
64  this, SIGNAL(modelAlignmentCompletionChanged(ModelId)));
65 }
66 
67 ModelId
69 {
70  ModelId sourceId;
71  auto model = ModelById::get(getModel());
72  while (model && !model->getSourceModel().isNone()) {
73  sourceId = model->getSourceModel();
74  model = ModelById::get(sourceId);
75  }
76  return sourceId;
77 }
78 
79 QString
81 {
83  (LayerFactory::getInstance()->getLayerType(this));
84 }
85 
86 void
88 {
89  m_presentationName = name;
90 }
91 
92 bool
94 {
95  return (m_presentationName != "");
96 }
97 
98 QString
100 {
101  if (m_presentationName != "") return m_presentationName;
102 
104  QString layerName = factory->getLayerPresentationName
105  (factory->getLayerType(this));
106 
107  QString modelName;
108  auto model = ModelById::get(getModel());
109  if (model) modelName = model->objectName();
110 
111  QString text;
112  if (modelName != "") {
113  text = QString("%1: %2").arg(modelName).arg(layerName);
114  } else {
115  text = layerName;
116  }
117 
118  return text;
119 }
120 
121 void
122 Layer::setObjectName(const QString &name)
123 {
124  QObject::setObjectName(name);
125  emit layerNameChanged();
126 }
127 
128 std::shared_ptr<PlayParameters>
130 {
131  return PlayParameterRepository::getInstance()->getPlayParameters
132  (getModel().untyped);
133 }
134 
135 void
137 {
138  const void *vv = (const void *)v;
139  QMutexLocker locker(&m_dormancyMutex);
140  m_dormancy[vv] = dormant;
141 }
142 
143 bool
145 {
146  const void *vv = (const void *)v;
147  QMutexLocker locker(&m_dormancyMutex);
148  if (m_dormancy.find(vv) == m_dormancy.end()) return false;
149  return m_dormancy.find(vv)->second;
150 }
151 
152 void
154 {
155  setLayerDormant(view, !show);
156  emit layerParametersChanged();
157 }
158 
159 bool
160 Layer::getXScaleValue(const LayerGeometryProvider *v, int x, double &value, QString &unit) const
161 {
162  if (!hasTimeXAxis()) return false;
163 
164  auto model = ModelById::get(getModel());
165  if (!model) return false;
166 
167  value = double(v->getFrameForX(x)) / model->getSampleRate();
168  unit = "s";
169  return true;
170 }
171 
172 bool
174  double &diff, QString &unit) const
175 {
176  double v0, v1;
177  if (!getYScaleValue(v, y0, v0, unit) ||
178  !getYScaleValue(v, y1, v1, unit)) {
179  diff = 0.f;
180  return false;
181  }
182  diff = fabs(v1 - v0);
183  return true;
184 }
185 
186 sv_frame_t
188 {
189  auto model = ModelById::get(getModel());
190  if (model && !model->getAlignmentReference().isNone()) {
191  return model->alignToReference(frame);
192  } else {
193  return v->getView()->alignToReference(frame);
194  }
195 }
196 
197 sv_frame_t
199 {
200  auto model = ModelById::get(getModel());
201  if (model && !model->getAlignmentReference().isNone()) {
202  return model->alignFromReference(frame);
203  } else {
204  return v->getView()->alignFromReference(frame);
205  }
206 }
207 
208 bool
210 {
211  // Notes on pasting to an aligned layer:
212  //
213  // Each point may have a reference frame that may differ from the
214  // point's given frame (in its source model). If it has no
215  // reference frame, we have to assume the source model was not
216  // aligned or was the reference model: when cutting or copying
217  // points from a layer, we must always set their reference frame
218  // correctly if we are aligned.
219  //
220  // When pasting:
221  // - if point's reference and aligned frames differ:
222  // - if this layer is aligned:
223  // - if point's aligned frame matches this layer's aligned version
224  // of point's reference frame:
225  // - we can paste at reference frame or our frame
226  // - else
227  // - we can paste at reference frame, result of aligning reference
228  // frame in our model, or literal source frame
229  // - else
230  // - we can paste at reference (our) frame, or literal source frame
231  // - else
232  // - if this layer is aligned:
233  // - we can paste at reference (point's only available) frame,
234  // or result of aligning reference frame in our model
235  // - else
236  // - we can only paste at reference frame
237  //
238  // Which of these alternatives are useful?
239  //
240  // Example: we paste between two tracks that are aligned to the
241  // same reference, and the points are at 10s and 20s in the source
242  // track, corresponding to 5s and 10s in the reference but 20s and
243  // 30s in the target track.
244  //
245  // The obvious default is to paste at 20s and 30s; if we aren't
246  // doing that, would it be better to paste at 5s and 10s or at 10s
247  // and 20s? We probably don't ever want to do the former, do we?
248  // We either want to be literal all the way through, or aligned
249  // all the way through.
250 
251  for (EventVector::const_iterator i = clip.getPoints().begin();
252  i != clip.getPoints().end(); ++i) {
253 
254  // In principle, we want to know whether the aligned version
255  // of the reference frame in our layer is the same as the
256  // source frame contained in the clipboard point. However,
257  // because of rounding during alignment, that won't
258  // necessarily be the case even if the clipboard point came
259  // from our layer! What we need to check is whether, if we
260  // aligned the clipboard point's frame back to the reference
261  // using this layer's alignment, we would obtain the same
262  // reference frame as that for the clipboard point.
263 
264  // What if the clipboard point has no reference frame? Then
265  // we have to treat it as having its own frame as the
266  // reference (i.e. having been copied from the reference
267  // model).
268 
269  sv_frame_t sourceFrame = i->getFrame();
270  sv_frame_t referenceFrame = sourceFrame;
271  if (i->hasReferenceFrame()) {
272  referenceFrame = i->getReferenceFrame();
273  }
274  sv_frame_t myMappedFrame = alignToReference(v, sourceFrame);
275 
276 // cerr << "sourceFrame = " << sourceFrame << ", referenceFrame = " << referenceFrame << " (have = " << i->hasReferenceFrame() << "), myMappedFrame = " << myMappedFrame << endl;
277 
278  if (myMappedFrame != referenceFrame) return true;
279  }
280 
281  return false;
282 }
283 
284 bool
286 {
287  if (haveFrames) {
288  if (startFrame == mr.startFrame) {
289  if (endFrame != mr.endFrame) {
290  return endFrame < mr.endFrame;
291  }
292  } else {
293  return startFrame < mr.startFrame;
294  }
295  } else {
296  if (pixrect.x() == mr.pixrect.x()) {
297  if (pixrect.width() != mr.pixrect.width()) {
298  return pixrect.width() < mr.pixrect.width();
299  }
300  } else {
301  return pixrect.x() < mr.pixrect.x();
302  }
303  }
304 
305  // the two rects are equal in x and width
306 
307  if (pixrect.y() == mr.pixrect.y()) {
308  return pixrect.height() < mr.pixrect.height();
309  } else {
310  return pixrect.y() < mr.pixrect.y();
311  }
312 }
313 
314 void
315 Layer::MeasureRect::toXml(QTextStream &stream, QString indent) const
316 {
317  stream << indent;
318  stream << QString("<measurement ");
319 
320  if (haveFrames) {
321  stream << QString("startFrame=\"%1\" endFrame=\"%2\" ")
322  .arg(startFrame).arg(endFrame);
323  } else {
324  stream << QString("startX=\"%1\" endX=\"%2\" ")
325  .arg(pixrect.x()).arg(pixrect.x() << pixrect.width());
326  }
327 
328  stream << QString("startY=\"%1\" endY=\"%2\"/>\n")
329  .arg(startY).arg(endY);
330 }
331 
332 void
333 Layer::addMeasurementRect(const QXmlAttributes &attributes)
334 {
335  MeasureRect rect;
336  QString fs = attributes.value("startFrame");
337  int x0 = 0, x1 = 0;
338  if (fs != "") {
339  rect.startFrame = fs.toInt();
340  rect.endFrame = attributes.value("endFrame").toInt();
341  rect.haveFrames = true;
342  } else {
343  x0 = attributes.value("startX").toInt();
344  x1 = attributes.value("endX").toInt();
345  rect.haveFrames = false;
346  }
347  rect.startY = attributes.value("startY").toDouble();
348  rect.endY = attributes.value("endY").toDouble();
349  rect.pixrect = QRect(x0, 0, x1 - x0, 0);
350  addMeasureRectToSet(rect);
351 }
352 
353 QString
355 {
356  return tr("Make Measurement");
357 }
358 
359 void
361 {
362  m_layer->addMeasureRectToSet(m_rect);
363 }
364 
365 void
367 {
368  m_layer->deleteMeasureRectFromSet(m_rect);
369 }
370 
371 QString
373 {
374  return tr("Delete Measurement");
375 }
376 
377 void
379 {
380  m_layer->deleteMeasureRectFromSet(m_rect);
381 }
382 
383 void
385 {
386  m_layer->addMeasureRectToSet(m_rect);
387 }
388 
389 void
391 {
393 
394  // NB if haveFrames, then pixrect x and width will be rewritten on
395  // every paint according to the current locations of the
396  // definitive frame values. So we should set the start frame value
397  // once on measureStart, and then not modify it on drag (to avoid
398  // drift from repeated conversion back and forth).
399 
400  m_draggingRect.pixrect = QRect(e->x(), e->y(), 0, 0);
401 
404  m_draggingRect.endFrame = v->getFrameForX(e->x());
405  }
406 
407  setMeasureRectYCoord(v, m_draggingRect, true, e->y());
408  setMeasureRectYCoord(v, m_draggingRect, false, e->y());
409 
410  m_haveDraggingRect = true;
411 }
412 
413 void
415 {
416  if (!m_haveDraggingRect) return;
417 
418  m_draggingRect.pixrect.setHeight(e->y() - m_draggingRect.pixrect.y());
419 
421  m_draggingRect.endFrame = v->getFrameForX(e->x());
422  } else {
423  m_draggingRect.pixrect.setWidth(e->x() - m_draggingRect.pixrect.x());
424  }
425 
426  setMeasureRectYCoord(v, m_draggingRect, false, e->y());
427 }
428 
429 void
431 {
432  if (!m_haveDraggingRect) return;
433  measureDrag(v, e);
434 
435  if (!m_draggingRect.pixrect.isNull()) {
438  }
439 
440  m_haveDraggingRect = false;
441 }
442 
443 void
445 {
446  // nothing, in the base class
447 }
448 
449 void
451 {
452  if (!m_haveCurrentMeasureRect) return;
453 
454  MeasureRectSet::const_iterator focusRectItr =
456 
457  if (focusRectItr == m_measureRects.end()) return;
458 
460  (new DeleteMeasurementRectCommand(this, *focusRectItr));
461 }
462 
463 void
465  bool showFocus, QPoint focusPoint) const
466 {
468 
469  MeasureRectSet::const_iterator focusRectItr = m_measureRects.end();
470 
471  if (m_haveDraggingRect) {
472 
473  paintMeasurementRect(v, paint, m_draggingRect, true);
474 
475  } else if (showFocus) {
476 
477  focusRectItr = findFocusedMeasureRect(focusPoint);
478  }
479 
480  m_haveCurrentMeasureRect = false;
481 
482  for (MeasureRectSet::const_iterator i = m_measureRects.begin();
483  i != m_measureRects.end(); ++i) {
484 
485  bool focused = (i == focusRectItr);
486  paintMeasurementRect(v, paint, *i, focused);
487 
488  if (focused) {
490  m_currentMeasureRectPoint = focusPoint;
491  }
492  }
493 }
494 
495 bool
497 {
499 
500  MeasureRectSet::const_iterator i0 = findFocusedMeasureRect(prev);
501  MeasureRectSet::const_iterator i1 = findFocusedMeasureRect(now);
502 
503  return (i0 != i1);
504 }
505 
506 void
508 {
509  sv_frame_t sf = v->getStartFrame();
510  sv_frame_t ef = v->getEndFrame();
511 
512  for (MeasureRectSet::const_iterator i = m_measureRects.begin();
513  i != m_measureRects.end(); ++i) {
514 
515  // This logic depends on the fact that if one measure rect in
516  // a layer has frame values, they all will. That is in fact
517  // the case, because haveFrames is based on whether the layer
518  // hasTimeXAxis() or not. Measure rect ordering in the rect
519  // set wouldn't work correctly either, if haveFrames could
520  // vary.
521 
522  if (i->haveFrames) {
523  if (i->startFrame >= ef) break;
524  if (i->endFrame <= sf) continue;
525  }
526 
527  int x0 = i->pixrect.x();
528  int x1 = x0 + i->pixrect.width();
529 
530  if (i->haveFrames) {
531  if (i->startFrame >= v->getStartFrame()) {
532  x0 = v->getXForFrame(i->startFrame);
533  }
534  if (i->endFrame <= int(v->getEndFrame())) {
535  x1 = v->getXForFrame(i->endFrame);
536  }
537  }
538 
539  i->pixrect = QRect(x0, i->pixrect.y(), x1 - x0, i->pixrect.height());
540 
542  }
543 }
544 
545 void
547 {
548  int y0 = int(lrint(r.startY * v->getPaintHeight()));
549  int y1 = int(lrint(r.endY * v->getPaintHeight()));
550  r.pixrect = QRect(r.pixrect.x(), y0, r.pixrect.width(), y1 - y0);
551 }
552 
553 void
555 {
556  if (start) {
557  r.startY = double(y) / double(v->getPaintHeight());
558  r.endY = r.startY;
559  } else {
560  r.endY = double(y) / double(v->getPaintHeight());
561  }
562 }
563 
564 void
566 {
567  r.pixrect = pixrect;
568  r.haveFrames = hasTimeXAxis();
569  if (r.haveFrames) {
570  r.startFrame = v->getFrameForX(pixrect.x());
571  r.endFrame = v->getFrameForX(pixrect.x() + pixrect.width());
572  }
573  setMeasureRectYCoord(v, r, true, pixrect.y());
574  setMeasureRectYCoord(v, r, false, pixrect.y() + pixrect.height());
575 }
576 
577 Layer::MeasureRectSet::const_iterator
578 Layer::findFocusedMeasureRect(QPoint focusPoint) const
579 {
580  double frDist = 0;
581  MeasureRectSet::const_iterator focusRectItr = m_measureRects.end();
582 
583  for (MeasureRectSet::const_iterator i = m_measureRects.begin();
584  i != m_measureRects.end(); ++i) {
585 
586  if (!i->pixrect.adjusted(-2, -2, 2, 2).contains(focusPoint)) continue;
587 
588  int cx = i->pixrect.x() + i->pixrect.width()/2;
589  int cy = i->pixrect.y() + i->pixrect.height()/2;
590  int xd = focusPoint.x() - cx;
591  int yd = focusPoint.y() - cy;
592 
593  double d = sqrt(double(xd * xd + yd * yd));
594 
595  if (focusRectItr == m_measureRects.end() || d < frDist) {
596  focusRectItr = i;
597  frDist = d;
598  }
599  }
600 
601  return focusRectItr;
602 }
603 
604 void
606  const MeasureRect &r, bool focus) const
607 {
608  if (r.haveFrames) {
609 
610  int x0 = -1;
611  int x1 = v->getPaintWidth() + 1;
612 
613  if (r.startFrame >= v->getStartFrame()) {
614  x0 = v->getXForFrame(r.startFrame);
615  }
616  if (r.endFrame <= v->getEndFrame()) {
617  x1 = v->getXForFrame(r.endFrame);
618  }
619 
620  QRect pr = QRect(x0, r.pixrect.y(), x1 - x0, r.pixrect.height());
621  r.pixrect = pr;
622  }
623 
624  v->drawMeasurementRect(paint, this, r.pixrect.normalized(), focus);
625 }
626 
627 bool
629 {
630  double min, min_;
631  double max, max_;
632  bool logarithmic, logarithmic_;
633  QString unit;
634 
635  if (!getValueExtents(min_, max_, logarithmic_, unit)) {
636  return false;
637  }
638 
639  if (!v->getVisibleExtentsForUnit(unit, min, max, logarithmic)) {
640  return false;
641  }
642 
643  if (min != min_ ||
644  max != max_ ||
645  logarithmic != logarithmic_) {
646  return false;
647  }
648 
649  return true;
650 }
651 
652 void
653 Layer::toXml(QTextStream &stream,
654  QString indent, QString extraAttributes) const
655 {
656  stream << indent;
657 
658  if (m_presentationName != "") {
659  extraAttributes = QString("%1 presentationName=\"%2\"")
660  .arg(extraAttributes).arg(encodeEntities(m_presentationName));
661  }
662 
663  int modelExportId = -1;
664  auto model = ModelById::get(getModel());
665  if (model) modelExportId = model->getExportId();
666 
667  stream << QString("<layer id=\"%2\" type=\"%1\" name=\"%3\" model=\"%4\" %5")
668  .arg(encodeEntities(LayerFactory::getInstance()->getLayerTypeName
669  (LayerFactory::getInstance()->getLayerType(this))))
670  .arg(getExportId())
671  .arg(encodeEntities(objectName()))
672  .arg(modelExportId)
673  .arg(extraAttributes);
674 
675  if (m_measureRects.empty()) {
676  stream << QString("/>\n");
677  return;
678  }
679 
680  stream << QString(">\n");
681 
682  for (MeasureRectSet::const_iterator i = m_measureRects.begin();
683  i != m_measureRects.end(); ++i) {
684  i->toXml(stream, indent + " ");
685  }
686 
687  stream << QString("</layer>\n");
688 }
689 
690 void
691 Layer::toBriefXml(QTextStream &stream,
692  QString indent, QString extraAttributes) const
693 {
694  stream << indent;
695 
696  if (m_presentationName != "") {
697  extraAttributes = QString("%1 presentationName=\"%2\"")
698  .arg(extraAttributes).arg(encodeEntities(m_presentationName));
699  }
700 
701  int modelExportId = -1;
702  auto model = ModelById::get(getModel());
703  if (model) modelExportId = model->getExportId();
704 
705  stream << QString("<layer id=\"%2\" type=\"%1\" name=\"%3\" model=\"%4\" %5/>\n")
706  .arg(encodeEntities(LayerFactory::getInstance()->getLayerTypeName
707  (LayerFactory::getInstance()->getLayerType(this))))
708  .arg(getExportId())
709  .arg(encodeEntities(objectName()))
710  .arg(modelExportId)
711  .arg(extraAttributes);
712 }
713 
MeasureRectSet m_measureRects
Definition: Layer.h:693
static LayerFactory * getInstance()
QString getLayerIconName(LayerType)
virtual bool isLayerDormant(const LayerGeometryProvider *v) const
Return whether the layer is dormant (i.e.
Definition: Layer.cpp:144
QPoint m_currentMeasureRectPoint
Definition: Layer.h:697
virtual bool isPresentationNameSet() const
Definition: Layer.cpp:93
sv_frame_t alignFromReference(sv_frame_t) const
Definition: View.cpp:1597
void modelCompletionChanged(ModelId)
bool m_haveCurrentMeasureRect
Definition: Layer.h:696
virtual void addMeasurementRect(const QXmlAttributes &)
Add a measurement rectangle from the given XML attributes (presumably taken from a measurement elemen...
Definition: Layer.cpp:333
Layer()
Definition: Layer.cpp:37
MeasureRect m_draggingRect
Definition: Layer.h:694
virtual bool getXScaleValue(const LayerGeometryProvider *v, int x, double &value, QString &unit) const
Return the value and unit at the given x coordinate in the given view.
Definition: Layer.cpp:160
void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const override
Convert the layer&#39;s data (though not those of the model it refers to) into XML for file output...
Definition: Layer.cpp:653
QMutex m_dormancyMutex
Definition: Layer.h:719
virtual void updateMeasureRectYCoords(LayerGeometryProvider *v, const MeasureRect &r) const
Definition: Layer.cpp:546
void addCommand(Command *command)
Add a command to the command history.
virtual bool getValueExtents(double &min, double &max, bool &logarithmic, QString &unit) const =0
Return the minimum and maximum values for the y axis of the model in this layer, as well as whether t...
sv_frame_t alignToReference(sv_frame_t) const
Definition: View.cpp:1606
virtual void setLayerDormant(const LayerGeometryProvider *v, bool dormant)
Indicate that a layer is not currently visible in the given view and is not expected to become visibl...
Definition: Layer.cpp:136
virtual sv_frame_t getFrameForX(int x) const =0
Return the closest frame to the given pixel x-coordinate.
ModelId getSourceModel() const
Return the ID of the source model for the model represented in this layer.
Definition: Layer.cpp:68
virtual void paint(LayerGeometryProvider *, QPainter &, QRect) const =0
Paint the given rectangle of this layer onto the given view using the given painter, superimposing it on top of any existing material in that view.
void toXml(QTextStream &stream, QString indent) const
Definition: Layer.cpp:315
virtual void measureDoubleClick(LayerGeometryProvider *, QMouseEvent *)
Definition: Layer.cpp:444
bool operator<(const MeasureRect &mr) const
Definition: Layer.cpp:285
virtual void measureDrag(LayerGeometryProvider *, QMouseEvent *)
Definition: Layer.cpp:414
virtual void setObjectName(const QString &name)
Definition: Layer.cpp:122
void modelChanged(ModelId)
Interface for classes that provide geometry information (such as size, start frame, and a large number of other properties) about the disposition of a layer.
virtual void deleteCurrentMeasureRect()
Definition: Layer.cpp:450
QString getLayerPresentationName(LayerType type)
virtual sv_frame_t alignFromReference(LayerGeometryProvider *v, sv_frame_t frame) const
Definition: Layer.cpp:198
std::shared_ptr< PlayParameters > getPlayParameters() override
Return the play parameters for this layer, if any.
Definition: Layer.cpp:129
virtual void setMeasureRectYCoord(LayerGeometryProvider *v, MeasureRect &r, bool start, int y) const
Definition: Layer.cpp:554
QString getName() const override
Definition: Layer.cpp:372
sv_frame_t endFrame
Definition: Layer.h:644
virtual QString getLayerPresentationName() const
Definition: Layer.cpp:99
virtual bool getYScaleValue(const LayerGeometryProvider *, int, double &, QString &) const
Return the value and unit at the given y coordinate in the given view.
Definition: Layer.h:550
void layerParametersChanged()
virtual sv_frame_t getStartFrame() const =0
Retrieve the first visible sample frame on the widget.
bool clipboardHasDifferentAlignment(LayerGeometryProvider *v, const Clipboard &clip) const
Definition: Layer.cpp:209
virtual sv_frame_t alignToReference(LayerGeometryProvider *v, sv_frame_t frame) const
Definition: Layer.cpp:187
virtual void measureEnd(LayerGeometryProvider *, QMouseEvent *)
Definition: Layer.cpp:430
static CommandHistory * getInstance()
std::map< const void *, bool > m_dormancy
Definition: Layer.h:720
virtual void toBriefXml(QTextStream &stream, QString indent="", QString extraAttributes="") const
Produce XML containing the layer&#39;s ID and type.
Definition: Layer.cpp:691
void connectSignals(ModelId)
Definition: Layer.cpp:49
virtual int getPaintHeight() const
bool valueExtentsMatchMine(LayerGeometryProvider *v) const
Definition: Layer.cpp:628
MeasureRectSet::const_iterator findFocusedMeasureRect(QPoint) const
Definition: Layer.cpp:578
bool m_haveDraggingRect
Definition: Layer.h:695
LayerType getLayerType(const Layer *)
void updateMeasurePixrects(LayerGeometryProvider *v) const
Definition: Layer.cpp:507
virtual ~Layer()
Definition: Layer.cpp:43
virtual void drawMeasurementRect(QPainter &p, const Layer *, QRect rect, bool focus) const =0
void showLayer(LayerGeometryProvider *, bool show)
Change the visibility status (dormancy) of the layer in the given view.
Definition: Layer.cpp:153
virtual void setPresentationName(QString name)
Definition: Layer.cpp:87
void modelAlignmentCompletionChanged(ModelId)
double startY
Definition: Layer.h:645
virtual bool hasTimeXAxis() const
Return true if the X axis on the layer is time proportional to audio frames, false otherwise...
Definition: Layer.h:475
virtual void setMeasureRectFromPixrect(LayerGeometryProvider *v, MeasureRect &r, QRect pixrect) const
Definition: Layer.cpp:565
sv_frame_t startFrame
Definition: Layer.h:643
QString m_presentationName
Definition: Layer.h:716
virtual ModelId getModel() const =0
Return the ID of the model represented in this layer.
virtual void measureStart(LayerGeometryProvider *, QMouseEvent *)
Definition: Layer.cpp:390
void addMeasureRectToSet(const MeasureRect &r)
Definition: Layer.h:682
void modelChangedWithin(ModelId, sv_frame_t startFrame, sv_frame_t endFrame)
virtual bool getVisibleExtentsForUnit(QString unit, double &min, double &max, bool &log) const =0
Return the visible vertical extents for the given unit, if any.
virtual sv_frame_t getEndFrame() const =0
Retrieve the last visible sample frame on the widget.
QString getPropertyContainerIconName() const override
Definition: Layer.cpp:80
virtual int getXForFrame(sv_frame_t frame) const =0
Return the pixel x-coordinate corresponding to a given sample frame (which may be negative)...
QString getName() const override
Definition: Layer.cpp:354
virtual int getPaintWidth() const
virtual void paintMeasurementRects(LayerGeometryProvider *, QPainter &, bool showFocus, QPoint focusPoint) const
Definition: Layer.cpp:464
virtual bool getYScaleDifference(const LayerGeometryProvider *v, int y0, int y1, double &diff, QString &unit) const
Return the difference between the values at the given y coordinates in the given view, and the unit of the difference.
Definition: Layer.cpp:173
virtual bool nearestMeasurementRectChanged(LayerGeometryProvider *, QPoint prev, QPoint now) const
Definition: Layer.cpp:496
void layerNameChanged()
void paintMeasurementRect(LayerGeometryProvider *v, QPainter &paint, const MeasureRect &r, bool focus) const
Definition: Layer.cpp:605
virtual View * getView()=0