svgui  1.9
TimeInstantLayer.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.
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 "TimeInstantLayer.h"
17 
18 #include "data/model/Model.h"
19 #include "base/RealTime.h"
20 #include "view/View.h"
21 #include "base/Profiler.h"
22 #include "base/Clipboard.h"
23 #include "ColourDatabase.h"
24 
25 #include "data/model/SparseOneDimensionalModel.h"
26 
27 #include "widgets/ItemEditDialog.h"
29 
30 #include <QPainter>
31 #include <QMouseEvent>
32 #include <QTextStream>
33 #include <QMessageBox>
34 
35 #include <iostream>
36 #include <cmath>
37 
38 //#define DEBUG_TIME_INSTANT_LAYER 1
39 
42  m_model(0),
43  m_editing(false),
44  m_editingPoint(0, tr("New Point")),
45  m_editingCommand(0),
46  m_plotStyle(PlotInstants)
47 {
48 }
49 
51 {
52 }
53 
54 void
55 TimeInstantLayer::setModel(SparseOneDimensionalModel *model)
56 {
57  if (m_model == model) return;
58  m_model = model;
59 
61 
62 #ifdef DEBUG_TIME_INSTANT_LAYER
63  cerr << "TimeInstantLayer::setModel(" << model << ")" << endl;
64 #endif
65 
66  if (m_model && m_model->getRDFTypeURI().endsWith("Segment")) {
68  }
69 
70  emit modelReplaced();
71 }
72 
73 Layer::PropertyList
75 {
76  PropertyList list = SingleColourLayer::getProperties();
77  list.push_back("Plot Type");
78  return list;
79 }
80 
81 QString
82 TimeInstantLayer::getPropertyLabel(const PropertyName &name) const
83 {
84  if (name == "Plot Type") return tr("Plot Type");
86 }
87 
88 Layer::PropertyType
89 TimeInstantLayer::getPropertyType(const PropertyName &name) const
90 {
91  if (name == "Plot Type") return ValueProperty;
93 }
94 
95 int
97  int *min, int *max, int *deflt) const
98 {
99  int val = 0;
100 
101  if (name == "Plot Type") {
102 
103  if (min) *min = 0;
104  if (max) *max = 1;
105  if (deflt) *deflt = 0;
106 
107  val = int(m_plotStyle);
108 
109  } else {
110 
111  val = SingleColourLayer::getPropertyRangeAndValue(name, min, max, deflt);
112  }
113 
114  return val;
115 }
116 
117 QString
119  int value) const
120 {
121  if (name == "Plot Type") {
122  switch (value) {
123  default:
124  case 0: return tr("Instants");
125  case 1: return tr("Segmentation");
126  }
127  }
128  return SingleColourLayer::getPropertyValueLabel(name, value);
129 }
130 
131 void
132 TimeInstantLayer::setProperty(const PropertyName &name, int value)
133 {
134  if (name == "Plot Type") {
135  setPlotStyle(PlotStyle(value));
136  } else {
137  SingleColourLayer::setProperty(name, value);
138  }
139 }
140 
141 void
143 {
144  if (m_plotStyle == style) return;
145  m_plotStyle = style;
146  emit layerParametersChanged();
147 }
148 
149 bool
151 {
152  QPoint discard;
153  return !v->shouldIlluminateLocalFeatures(this, discard);
154 }
155 
156 SparseOneDimensionalModel::PointList
158 {
159  // Return a set of points that all have the same frame number, the
160  // nearest to the given x coordinate, and that are within a
161  // certain fuzz distance of that x coordinate.
162 
163  if (!m_model) return SparseOneDimensionalModel::PointList();
164 
165  long frame = v->getFrameForX(x);
166 
167  SparseOneDimensionalModel::PointList onPoints =
168  m_model->getPoints(frame);
169 
170  if (!onPoints.empty()) {
171  return onPoints;
172  }
173 
174  SparseOneDimensionalModel::PointList prevPoints =
175  m_model->getPreviousPoints(frame);
176  SparseOneDimensionalModel::PointList nextPoints =
177  m_model->getNextPoints(frame);
178 
179  SparseOneDimensionalModel::PointList usePoints = prevPoints;
180 
181  if (prevPoints.empty()) {
182  usePoints = nextPoints;
183  } else if (long(prevPoints.begin()->frame) < v->getStartFrame() &&
184  !(nextPoints.begin()->frame > v->getEndFrame())) {
185  usePoints = nextPoints;
186  } else if (nextPoints.begin()->frame - frame <
187  frame - prevPoints.begin()->frame) {
188  usePoints = nextPoints;
189  }
190 
191  if (!usePoints.empty()) {
192  int fuzz = 2;
193  int px = v->getXForFrame(usePoints.begin()->frame);
194  if ((px > x && px - x > fuzz) ||
195  (px < x && x - px > fuzz + 1)) {
196  usePoints.clear();
197  }
198  }
199 
200  return usePoints;
201 }
202 
203 QString
205 {
206  if (!m_model) return "";
207  SparseOneDimensionalModel::PointList points = m_model->getPreviousPoints(frame);
208  for (SparseOneDimensionalModel::PointList::const_iterator i = points.begin();
209  i != points.end(); ++i) {
210  if (i->label != "") return i->label;
211  }
212  return "";
213 }
214 
215 QString
217 {
218  int x = pos.x();
219 
220  if (!m_model || !m_model->getSampleRate()) return "";
221 
222  SparseOneDimensionalModel::PointList points = getLocalPoints(v, x);
223 
224  if (points.empty()) {
225  if (!m_model->isReady()) {
226  return tr("In progress");
227  } else {
228  return tr("No local points");
229  }
230  }
231 
232  long useFrame = points.begin()->frame;
233 
234  RealTime rt = RealTime::frame2RealTime(useFrame, m_model->getSampleRate());
235 
236  QString text;
237 
238  if (points.begin()->label == "") {
239  text = QString(tr("Time:\t%1\nNo label"))
240  .arg(rt.toText(true).c_str());
241  } else {
242  text = QString(tr("Time:\t%1\nLabel:\t%2"))
243  .arg(rt.toText(true).c_str())
244  .arg(points.begin()->label);
245  }
246 
247  pos = QPoint(v->getXForFrame(useFrame), pos.y());
248  return text;
249 }
250 
251 bool
253  int &resolution,
254  SnapType snap) const
255 {
256  if (!m_model) {
257  return Layer::snapToFeatureFrame(v, frame, resolution, snap);
258  }
259 
260  resolution = m_model->getResolution();
261  SparseOneDimensionalModel::PointList points;
262 
263  if (snap == SnapNeighbouring) {
264 
265  points = getLocalPoints(v, v->getXForFrame(frame));
266  if (points.empty()) return false;
267  frame = points.begin()->frame;
268  return true;
269  }
270 
271  points = m_model->getPoints(frame, frame);
272  int snapped = frame;
273  bool found = false;
274 
275  for (SparseOneDimensionalModel::PointList::const_iterator i = points.begin();
276  i != points.end(); ++i) {
277 
278  if (snap == SnapRight) {
279 
280  if (i->frame >= frame) {
281  snapped = i->frame;
282  found = true;
283  break;
284  }
285 
286  } else if (snap == SnapLeft) {
287 
288  if (i->frame <= frame) {
289  snapped = i->frame;
290  found = true; // don't break, as the next may be better
291  } else {
292  break;
293  }
294 
295  } else { // nearest
296 
297  SparseOneDimensionalModel::PointList::const_iterator j = i;
298  ++j;
299 
300  if (j == points.end()) {
301 
302  snapped = i->frame;
303  found = true;
304  break;
305 
306  } else if (j->frame >= frame) {
307 
308  if (j->frame - frame < frame - i->frame) {
309  snapped = j->frame;
310  } else {
311  snapped = i->frame;
312  }
313  found = true;
314  break;
315  }
316  }
317  }
318 
319  frame = snapped;
320  return found;
321 }
322 
323 void
324 TimeInstantLayer::paint(View *v, QPainter &paint, QRect rect) const
325 {
326  if (!m_model || !m_model->isOK()) return;
327 
328 // Profiler profiler("TimeInstantLayer::paint", true);
329 
330  int x0 = rect.left(), x1 = rect.right();
331 
332  long frame0 = v->getFrameForX(x0);
333  long frame1 = v->getFrameForX(x1);
334 
335  SparseOneDimensionalModel::PointList points(m_model->getPoints
336  (frame0, frame1));
337 
338  bool odd = false;
339  if (m_plotStyle == PlotSegmentation && !points.empty()) {
340  int index = m_model->getIndexOf(*points.begin());
341  odd = ((index % 2) == 1);
342  }
343 
344  paint.setPen(getBaseQColor());
345 
346  QColor brushColour(getBaseQColor());
347  brushColour.setAlpha(100);
348  paint.setBrush(brushColour);
349 
350  QColor oddBrushColour(brushColour);
351  if (m_plotStyle == PlotSegmentation) {
352  if (getBaseQColor() == Qt::black) {
353  oddBrushColour = Qt::gray;
354  } else if (getBaseQColor() == Qt::darkRed) {
355  oddBrushColour = Qt::red;
356  } else if (getBaseQColor() == Qt::darkBlue) {
357  oddBrushColour = Qt::blue;
358  } else if (getBaseQColor() == Qt::darkGreen) {
359  oddBrushColour = Qt::green;
360  } else {
361  oddBrushColour = oddBrushColour.light(150);
362  }
363  oddBrushColour.setAlpha(100);
364  }
365 
366 // SVDEBUG << "TimeInstantLayer::paint: resolution is "
367 // << m_model->getResolution() << " frames" << endl;
368 
369  QPoint localPos;
370  long illuminateFrame = -1;
371 
372  if (v->shouldIlluminateLocalFeatures(this, localPos)) {
373  SparseOneDimensionalModel::PointList localPoints =
374  getLocalPoints(v, localPos.x());
375  if (!localPoints.empty()) illuminateFrame = localPoints.begin()->frame;
376  }
377 
378  int prevX = -1;
379  int textY = v->getTextLabelHeight(this, paint);
380 
381  for (SparseOneDimensionalModel::PointList::const_iterator i = points.begin();
382  i != points.end(); ++i) {
383 
384  const SparseOneDimensionalModel::Point &p(*i);
385  SparseOneDimensionalModel::PointList::const_iterator j = i;
386  ++j;
387 
388  int x = v->getXForFrame(p.frame);
389  if (x == prevX && m_plotStyle == PlotInstants &&
390  p.frame != illuminateFrame) continue;
391 
392  int iw = v->getXForFrame(p.frame + m_model->getResolution()) - x;
393  if (iw < 2) {
394  if (iw < 1) {
395  iw = 2;
396  if (j != points.end()) {
397  int nx = v->getXForFrame(j->frame);
398  if (nx < x + 3) iw = 1;
399  }
400  } else {
401  iw = 2;
402  }
403  }
404 
405  if (p.frame == illuminateFrame) {
406  paint.setPen(getForegroundQColor(v));
407  } else {
408  paint.setPen(brushColour);
409  }
410 
411  if (m_plotStyle == PlotInstants) {
412  if (iw > 1) {
413  paint.drawRect(x, 0, iw - 1, v->height() - 1);
414  } else {
415  paint.drawLine(x, 0, x, v->height() - 1);
416  }
417  } else {
418 
419  if (odd) paint.setBrush(oddBrushColour);
420  else paint.setBrush(brushColour);
421 
422  int nx;
423 
424  if (j != points.end()) {
425  const SparseOneDimensionalModel::Point &q(*j);
426  nx = v->getXForFrame(q.frame);
427  } else {
428  nx = v->getXForFrame(m_model->getEndFrame());
429  }
430 
431  if (nx >= x) {
432 
433  if (illuminateFrame != p.frame &&
434  (nx < x + 5 || x >= v->width() - 1)) {
435  paint.setPen(Qt::NoPen);
436  }
437 
438  paint.drawRect(x, -1, nx - x, v->height() + 1);
439  }
440 
441  odd = !odd;
442  }
443 
444  paint.setPen(getBaseQColor());
445 
446  if (p.label != "") {
447 
448  // only draw if there's enough room from here to the next point
449 
450  int lw = paint.fontMetrics().width(p.label);
451  bool good = true;
452 
453  if (j != points.end()) {
454  int nx = v->getXForFrame(j->frame);
455  if (nx >= x && nx - x - iw - 3 <= lw) good = false;
456  }
457 
458  if (good) {
459  v->drawVisibleText(paint, x + iw + 2, textY, p.label, View::OutlinedText);
460 // paint.drawText(x + iw + 2, textY, p.label);
461  }
462  }
463 
464  prevX = x;
465  }
466 }
467 
468 void
470 {
471 #ifdef DEBUG_TIME_INSTANT_LAYER
472  cerr << "TimeInstantLayer::drawStart(" << e->x() << ")" << endl;
473 #endif
474 
475  if (!m_model) return;
476 
477  long frame = v->getFrameForX(e->x());
478  if (frame < 0) frame = 0;
479  frame = frame / m_model->getResolution() * m_model->getResolution();
480 
481  m_editingPoint = SparseOneDimensionalModel::Point(frame, tr("New Point"));
482 
484  m_editingCommand = new SparseOneDimensionalModel::EditCommand(m_model,
485  tr("Draw Point"));
486  m_editingCommand->addPoint(m_editingPoint);
487 
488  m_editing = true;
489 }
490 
491 void
492 TimeInstantLayer::drawDrag(View *v, QMouseEvent *e)
493 {
494 #ifdef DEBUG_TIME_INSTANT_LAYER
495  cerr << "TimeInstantLayer::drawDrag(" << e->x() << ")" << endl;
496 #endif
497 
498  if (!m_model || !m_editing) return;
499 
500  long frame = v->getFrameForX(e->x());
501  if (frame < 0) frame = 0;
502  frame = frame / m_model->getResolution() * m_model->getResolution();
503  m_editingCommand->deletePoint(m_editingPoint);
504  m_editingPoint.frame = frame;
505  m_editingCommand->addPoint(m_editingPoint);
506 }
507 
508 void
510 {
511 #ifdef DEBUG_TIME_INSTANT_LAYER
512  cerr << "TimeInstantLayer::drawEnd(" << e->x() << ")" << endl;
513 #endif
514  if (!m_model || !m_editing) return;
515  QString newName = tr("Add Point at %1 s")
516  .arg(RealTime::frame2RealTime(m_editingPoint.frame,
517  m_model->getSampleRate())
518  .toText(false).c_str());
519  m_editingCommand->setName(newName);
521  m_editingCommand = 0;
522  m_editing = false;
523 }
524 
525 void
527 {
528  if (!m_model) return;
529 
530  SparseOneDimensionalModel::PointList points = getLocalPoints(v, e->x());
531  if (points.empty()) return;
532 
533  m_editingPoint = *points.begin();
534 
535  if (m_editingCommand) {
537  m_editingCommand = 0;
538  }
539 
540  m_editing = true;
541 }
542 
543 void
545 {
546 }
547 
548 void
549 TimeInstantLayer::eraseEnd(View *v, QMouseEvent *e)
550 {
551  if (!m_model || !m_editing) return;
552 
553  m_editing = false;
554 
555  SparseOneDimensionalModel::PointList points = getLocalPoints(v, e->x());
556  if (points.empty()) return;
557  if (points.begin()->frame != m_editingPoint.frame) return;
558 
559  m_editingCommand = new SparseOneDimensionalModel::EditCommand
560  (m_model, tr("Erase Point"));
561 
562  m_editingCommand->deletePoint(m_editingPoint);
563 
565  m_editingCommand = 0;
566  m_editing = false;
567 }
568 
569 void
571 {
572 #ifdef DEBUG_TIME_INSTANT_LAYER
573  cerr << "TimeInstantLayer::editStart(" << e->x() << ")" << endl;
574 #endif
575 
576  if (!m_model) return;
577 
578  SparseOneDimensionalModel::PointList points = getLocalPoints(v, e->x());
579  if (points.empty()) return;
580 
581  m_editingPoint = *points.begin();
582 
583  if (m_editingCommand) {
585  m_editingCommand = 0;
586  }
587 
588  m_editing = true;
589 }
590 
591 void
592 TimeInstantLayer::editDrag(View *v, QMouseEvent *e)
593 {
594 #ifdef DEBUG_TIME_INSTANT_LAYER
595  cerr << "TimeInstantLayer::editDrag(" << e->x() << ")" << endl;
596 #endif
597 
598  if (!m_model || !m_editing) return;
599 
600  long frame = v->getFrameForX(e->x());
601  if (frame < 0) frame = 0;
602  frame = frame / m_model->getResolution() * m_model->getResolution();
603 
604  if (!m_editingCommand) {
605  m_editingCommand = new SparseOneDimensionalModel::EditCommand(m_model,
606  tr("Drag Point"));
607  }
608 
609  m_editingCommand->deletePoint(m_editingPoint);
610  m_editingPoint.frame = frame;
611  m_editingCommand->addPoint(m_editingPoint);
612 }
613 
614 void
616 {
617 #ifdef DEBUG_TIME_INSTANT_LAYER
618  cerr << "TimeInstantLayer::editEnd(" << e->x() << ")" << endl;
619 #endif
620  if (!m_model || !m_editing) return;
621  if (m_editingCommand) {
622  QString newName = tr("Move Point to %1 s")
623  .arg(RealTime::frame2RealTime(m_editingPoint.frame,
624  m_model->getSampleRate())
625  .toText(false).c_str());
626  m_editingCommand->setName(newName);
628  }
629  m_editingCommand = 0;
630  m_editing = false;
631 }
632 
633 bool
634 TimeInstantLayer::editOpen(View *v, QMouseEvent *e)
635 {
636  if (!m_model) return false;
637 
638  SparseOneDimensionalModel::PointList points = getLocalPoints(v, e->x());
639  if (points.empty()) return false;
640 
641  SparseOneDimensionalModel::Point point = *points.begin();
642 
643  ItemEditDialog *dialog = new ItemEditDialog
644  (m_model->getSampleRate(),
647 
648  dialog->setFrameTime(point.frame);
649  dialog->setText(point.label);
650 
651  if (dialog->exec() == QDialog::Accepted) {
652 
653  SparseOneDimensionalModel::Point newPoint = point;
654  newPoint.frame = dialog->getFrameTime();
655  newPoint.label = dialog->getText();
656 
657  SparseOneDimensionalModel::EditCommand *command =
658  new SparseOneDimensionalModel::EditCommand(m_model, tr("Edit Point"));
659  command->deletePoint(point);
660  command->addPoint(newPoint);
661  finish(command);
662  }
663 
664  delete dialog;
665  return true;
666 }
667 
668 void
669 TimeInstantLayer::moveSelection(Selection s, int newStartFrame)
670 {
671  if (!m_model) return;
672 
673  SparseOneDimensionalModel::EditCommand *command =
674  new SparseOneDimensionalModel::EditCommand(m_model,
675  tr("Drag Selection"));
676 
677  SparseOneDimensionalModel::PointList points =
678  m_model->getPoints(s.getStartFrame(), s.getEndFrame());
679 
680  for (SparseOneDimensionalModel::PointList::iterator i = points.begin();
681  i != points.end(); ++i) {
682 
683  if (s.contains(i->frame)) {
684  SparseOneDimensionalModel::Point newPoint(*i);
685  newPoint.frame = i->frame + newStartFrame - s.getStartFrame();
686  command->deletePoint(*i);
687  command->addPoint(newPoint);
688  }
689  }
690 
691  finish(command);
692 }
693 
694 void
695 TimeInstantLayer::resizeSelection(Selection s, Selection newSize)
696 {
697  if (!m_model) return;
698 
699  SparseOneDimensionalModel::EditCommand *command =
700  new SparseOneDimensionalModel::EditCommand(m_model,
701  tr("Resize Selection"));
702 
703  SparseOneDimensionalModel::PointList points =
704  m_model->getPoints(s.getStartFrame(), s.getEndFrame());
705 
706  double ratio =
707  double(newSize.getEndFrame() - newSize.getStartFrame()) /
708  double(s.getEndFrame() - s.getStartFrame());
709 
710  for (SparseOneDimensionalModel::PointList::iterator i = points.begin();
711  i != points.end(); ++i) {
712 
713  if (s.contains(i->frame)) {
714 
715  double target = i->frame;
716  target = newSize.getStartFrame() +
717  double(target - s.getStartFrame()) * ratio;
718 
719  SparseOneDimensionalModel::Point newPoint(*i);
720  newPoint.frame = lrint(target);
721  command->deletePoint(*i);
722  command->addPoint(newPoint);
723  }
724  }
725 
726  finish(command);
727 }
728 
729 void
731 {
732  if (!m_model) return;
733 
734  SparseOneDimensionalModel::EditCommand *command =
735  new SparseOneDimensionalModel::EditCommand(m_model,
736  tr("Delete Selection"));
737 
738  SparseOneDimensionalModel::PointList points =
739  m_model->getPoints(s.getStartFrame(), s.getEndFrame());
740 
741  for (SparseOneDimensionalModel::PointList::iterator i = points.begin();
742  i != points.end(); ++i) {
743  if (s.contains(i->frame)) command->deletePoint(*i);
744  }
745 
746  finish(command);
747 }
748 
749 void
750 TimeInstantLayer::copy(View *v, Selection s, Clipboard &to)
751 {
752  if (!m_model) return;
753 
754  SparseOneDimensionalModel::PointList points =
755  m_model->getPoints(s.getStartFrame(), s.getEndFrame());
756 
757  for (SparseOneDimensionalModel::PointList::iterator i = points.begin();
758  i != points.end(); ++i) {
759  if (s.contains(i->frame)) {
760  Clipboard::Point point(i->frame, i->label);
761  point.setReferenceFrame(alignToReference(v, i->frame));
762  to.addPoint(point);
763  }
764  }
765 }
766 
767 bool
768 TimeInstantLayer::paste(View *v, const Clipboard &from, int frameOffset, bool)
769 {
770  if (!m_model) return false;
771 
772  const Clipboard::PointList &points = from.getPoints();
773 
774  bool realign = false;
775 
776  if (clipboardHasDifferentAlignment(v, from)) {
777 
778  QMessageBox::StandardButton button =
779  QMessageBox::question(v, tr("Re-align pasted instants?"),
780  tr("The instants you are pasting came from a layer with different source material from this one. Do you want to re-align them in time, to match the source material for this layer?"),
781  QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
782  QMessageBox::Yes);
783 
784  if (button == QMessageBox::Cancel) {
785  return false;
786  }
787 
788  if (button == QMessageBox::Yes) {
789  realign = true;
790  }
791  }
792 
793  SparseOneDimensionalModel::EditCommand *command =
794  new SparseOneDimensionalModel::EditCommand(m_model, tr("Paste"));
795 
796  for (Clipboard::PointList::const_iterator i = points.begin();
797  i != points.end(); ++i) {
798 
799  if (!i->haveFrame()) continue;
800 
801  int frame = 0;
802 
803  if (!realign) {
804 
805  frame = i->getFrame();
806 
807  } else {
808 
809  if (i->haveReferenceFrame()) {
810  frame = i->getReferenceFrame();
811  frame = alignFromReference(v, frame);
812  } else {
813  frame = i->getFrame();
814  }
815  }
816 
817  if (frameOffset > 0) frame += frameOffset;
818  else if (frameOffset < 0) {
819  if (frame > -frameOffset) frame += frameOffset;
820  else frame = 0;
821  }
822 
823  SparseOneDimensionalModel::Point newPoint(frame);
824  if (i->haveLabel()) {
825  newPoint.label = i->getLabel();
826  } else if (i->haveValue()) {
827  newPoint.label = QString("%1").arg(i->getValue());
828  }
829 
830  command->addPoint(newPoint);
831  }
832 
833  finish(command);
834  return true;
835 }
836 
837 int
838 TimeInstantLayer::getDefaultColourHint(bool darkbg, bool &impose)
839 {
840  impose = false;
842  (QString(darkbg ? "Bright Purple" : "Purple"));
843 }
844 
845 void
846 TimeInstantLayer::toXml(QTextStream &stream,
847  QString indent, QString extraAttributes) const
848 {
849  SingleColourLayer::toXml(stream, indent,
850  extraAttributes +
851  QString(" plotStyle=\"%1\"")
852  .arg(m_plotStyle));
853 }
854 
855 void
856 TimeInstantLayer::setProperties(const QXmlAttributes &attributes)
857 {
859 
860  bool ok;
861  PlotStyle style = (PlotStyle)
862  attributes.value("plotStyle").toInt(&ok);
863  if (ok) setPlotStyle(style);
864 }
865 
virtual QString getPropertyLabel(const PropertyName &) const
virtual void eraseDrag(View *v, QMouseEvent *)
int getFrameForX(int x) const
Return the closest frame to the given pixel x-coordinate.
Definition: View.cpp:363
virtual void copy(View *v, Selection s, Clipboard &to)
void setFrameTime(int frame)
virtual void resizeSelection(Selection s, Selection newSize)
virtual PropertyList getProperties() const
virtual QString getFeatureDescription(View *v, QPoint &) const
virtual void drawStart(View *v, QMouseEvent *)
virtual void drawDrag(View *v, QMouseEvent *)
virtual bool snapToFeatureFrame(View *, int &, int &resolution, SnapType) const
Adjust the given frame to snap to the nearest feature, if possible.
Definition: Layer.h:183
void connectSignals(const Model *)
Definition: Layer.cpp:49
virtual void moveSelection(Selection s, int newStartFrame)
virtual QString getLabelPreceding(int) const
void modelReplaced()
SparseOneDimensionalModel::Point m_editingPoint
void setModel(SparseOneDimensionalModel *model)
SparseOneDimensionalModel * m_model
virtual void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const
Convert the layer's data (though not those of the model it refers to) into XML for file output.
virtual PropertyType getPropertyType(const PropertyName &) const
virtual bool shouldIlluminateLocalFeatures(const Layer *, QPoint &) const
Definition: View.h:260
int getFrameTime() const
virtual void drawEnd(View *v, QMouseEvent *)
virtual int getTextLabelHeight(const Layer *layer, QPainter &) const
Definition: View.cpp:222
virtual bool snapToFeatureFrame(View *v, int &frame, int &resolution, SnapType snap) const
Adjust the given frame to snap to the nearest feature, if possible.
virtual QColor getForegroundQColor(View *v) const
void setProperties(const QXmlAttributes &attributes)
Set the particular properties of a layer (those specific to the subclass) from a set of XML attribute...
virtual QColor getBaseQColor() const
void setText(QString text)
SparseOneDimensionalModel::EditCommand * m_editingCommand
int getColourIndex(QString name) const
virtual void paint(View *v, QPainter &paint, QRect rect) const
Paint the given rectangle of this layer onto the given view using the given painter,...
void setPlotStyle(PlotStyle style)
virtual QString getPropertyLabel(const PropertyName &) const
int getStartFrame() const
Retrieve the first visible sample frame on the widget.
Definition: View.cpp:302
virtual bool paste(View *v, const Clipboard &from, int frameOffset, bool interactive)
Paste from the given clipboard onto the layer at the given frame offset.
void layerParametersChanged()
virtual int getDefaultColourHint(bool dark, bool &impose)
virtual void setProperties(const QXmlAttributes &attributes)
Set the particular properties of a layer (those specific to the subclass) from a set of XML attribute...
int getEndFrame() const
Retrieve the last visible sample frame on the widget.
Definition: View.cpp:308
SnapType
Definition: Layer.h:157
virtual int getPropertyRangeAndValue(const PropertyName &, int *min, int *max, int *deflt) const
virtual void eraseStart(View *v, QMouseEvent *)
bool clipboardHasDifferentAlignment(View *v, const Clipboard &clip) const
Definition: Layer.cpp:193
virtual bool isLayerScrollable(const View *v) const
This should return true if the layer can safely be scrolled automatically by a given view (simply cop...
virtual bool editOpen(View *, QMouseEvent *)
Open an editor on the item under the mouse (e.g.
virtual int getPropertyRangeAndValue(const PropertyName &, int *min, int *max, int *deflt) const
virtual int alignFromReference(View *v, int frame) const
Definition: Layer.cpp:181
virtual int alignToReference(View *v, int frame) const
Definition: Layer.cpp:169
virtual ~TimeInstantLayer()
View is the base class of widgets that display one or more overlaid views of data against a horizonta...
Definition: View.h:50
virtual QString getPropertyValueLabel(const PropertyName &, int value) const
virtual void editEnd(View *v, QMouseEvent *)
virtual QString getPropertyValueLabel(const PropertyName &, int value) const
virtual void drawVisibleText(QPainter &p, int x, int y, QString text, TextStyle style) const
Definition: View.cpp:787
virtual void setProperty(const PropertyName &, int value)
virtual void deleteSelection(Selection s)
virtual void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const
Convert the layer's data (though not those of the model it refers to) into XML for file output.
virtual void editDrag(View *v, QMouseEvent *)
virtual PropertyList getProperties() const
void finish(SparseOneDimensionalModel::EditCommand *command)
virtual void eraseEnd(View *v, QMouseEvent *)
virtual PropertyType getPropertyType(const PropertyName &) const
int getXForFrame(int frame) const
Return the pixel x-coordinate corresponding to a given sample frame (which may be negative).
Definition: View.cpp:357
static ColourDatabase * getInstance()
virtual void setProperty(const PropertyName &, int value)
virtual void editStart(View *v, QMouseEvent *)
SparseOneDimensionalModel::PointList getLocalPoints(View *v, int) const
QString getText() const