Mercurial > hg > svgui
comparison layer/RegionLayer.cpp @ 559:5bcfc5606528
* Add option to import time+duration (or time+endtime) from CSV files
(importing to Region layers)
* Fix ffwd/rwd in Region layers so as to behave like time-value layers
author | Chris Cannam |
---|---|
date | Thu, 08 Jul 2010 14:22:28 +0000 |
parents | 2e8194a30f40 |
children | f4960f8ce798 |
comparison
equal
deleted
inserted
replaced
558:9fc13f61ae74 | 559:5bcfc5606528 |
---|---|
509 } | 509 } |
510 found = true; | 510 found = true; |
511 break; | 511 break; |
512 } | 512 } |
513 } | 513 } |
514 } | |
515 | |
516 frame = snapped; | |
517 return found; | |
518 } | |
519 | |
520 bool | |
521 RegionLayer::snapToSimilarFeature(View *v, int &frame, | |
522 size_t &resolution, | |
523 SnapType snap) const | |
524 { | |
525 if (!m_model) { | |
526 return Layer::snapToSimilarFeature(v, frame, resolution, snap); | |
527 } | |
528 | |
529 resolution = m_model->getResolution(); | |
530 | |
531 const RegionModel::PointList &points = m_model->getPoints(); | |
532 RegionModel::PointList close = m_model->getPoints(frame, frame); | |
533 | |
534 RegionModel::PointList::const_iterator i; | |
535 | |
536 int matchframe = frame; | |
537 float matchvalue = 0.f; | |
538 | |
539 for (i = close.begin(); i != close.end(); ++i) { | |
540 if (i->frame > frame) break; | |
541 matchvalue = i->value; | |
542 matchframe = i->frame; | |
543 } | |
544 | |
545 int snapped = frame; | |
546 bool found = false; | |
547 bool distant = false; | |
548 float epsilon = 0.0001; | |
549 | |
550 i = close.begin(); | |
551 | |
552 // Scan through the close points first, then the more distant ones | |
553 // if no suitable close one is found | |
554 | |
555 while (i != points.end()) { | |
556 | |
557 if (i == close.end()) { | |
558 i = points.begin(); | |
559 distant = true; | |
560 } | |
561 | |
562 if (snap == SnapRight) { | |
563 | |
564 if (i->frame > matchframe && | |
565 fabsf(i->value - matchvalue) < epsilon) { | |
566 snapped = i->frame; | |
567 found = true; | |
568 break; | |
569 } | |
570 | |
571 } else if (snap == SnapLeft) { | |
572 | |
573 if (i->frame < matchframe) { | |
574 if (fabsf(i->value - matchvalue) < epsilon) { | |
575 snapped = i->frame; | |
576 found = true; // don't break, as the next may be better | |
577 } | |
578 } else if (found || distant) { | |
579 break; | |
580 } | |
581 | |
582 } else { | |
583 // no other snap types supported | |
584 } | |
585 | |
586 ++i; | |
514 } | 587 } |
515 | 588 |
516 frame = snapped; | 589 frame = snapped; |
517 return found; | 590 return found; |
518 } | 591 } |
845 if (!shouldIlluminate || | 918 if (!shouldIlluminate || |
846 // "illuminatePoint != p" | 919 // "illuminatePoint != p" |
847 RegionModel::Point::Comparator()(illuminatePoint, p) || | 920 RegionModel::Point::Comparator()(illuminatePoint, p) || |
848 RegionModel::Point::Comparator()(p, illuminatePoint)) { | 921 RegionModel::Point::Comparator()(p, illuminatePoint)) { |
849 | 922 |
923 paint.setPen(QPen(getForegroundQColor(v), 1)); | |
850 paint.drawLine(x, 0, x, v->height()); | 924 paint.drawLine(x, 0, x, v->height()); |
851 paint.setPen(Qt::NoPen); | 925 paint.setPen(Qt::NoPen); |
852 | 926 |
853 } else { | 927 } else { |
854 paint.setPen(QPen(getForegroundQColor(v), 2)); | 928 paint.setPen(QPen(getForegroundQColor(v), 2)); |
855 } | 929 } |
856 | 930 |
857 paint.drawRect(x, 0, ex - x, v->height() + 1); | 931 paint.drawRect(x, -1, ex - x, v->height() + 2); |
858 | 932 |
859 } else { | 933 } else { |
860 | 934 |
861 if (shouldIlluminate && | 935 if (shouldIlluminate && |
862 // "illuminatePoint == p" | 936 // "illuminatePoint == p" |