Mercurial > hg > svgui
comparison layer/TimeValueLayer.cpp @ 908:4a578a360011 cxx11
More type fixes
author | Chris Cannam |
---|---|
date | Tue, 10 Mar 2015 13:22:10 +0000 |
parents | 33157c3f0e80 |
children | 251dd0abc7b7 |
comparison
equal
deleted
inserted
replaced
907:28d05ae8741c | 908:4a578a360011 |
---|---|
327 QPoint discard; | 327 QPoint discard; |
328 return !v->shouldIlluminateLocalFeatures(this, discard); | 328 return !v->shouldIlluminateLocalFeatures(this, discard); |
329 } | 329 } |
330 | 330 |
331 bool | 331 bool |
332 TimeValueLayer::getValueExtents(float &min, float &max, | 332 TimeValueLayer::getValueExtents(double &min, double &max, |
333 bool &logarithmic, QString &unit) const | 333 bool &logarithmic, QString &unit) const |
334 { | 334 { |
335 if (!m_model) return false; | 335 if (!m_model) return false; |
336 | 336 |
337 min = m_model->getValueMinimum(); | 337 min = m_model->getValueMinimum(); |
340 logarithmic = (m_verticalScale == LogScale); | 340 logarithmic = (m_verticalScale == LogScale); |
341 | 341 |
342 unit = getScaleUnits(); | 342 unit = getScaleUnits(); |
343 | 343 |
344 if (m_derivative) { | 344 if (m_derivative) { |
345 max = std::max(fabsf(min), fabsf(max)); | 345 max = std::max(fabs(min), fabs(max)); |
346 min = -max; | 346 min = -max; |
347 } | 347 } |
348 | 348 |
349 #ifdef DEBUG_TIME_VALUE_LAYER | 349 #ifdef DEBUG_TIME_VALUE_LAYER |
350 cerr << "TimeValueLayer::getValueExtents: min = " << min << ", max = " << max << endl; | 350 cerr << "TimeValueLayer::getValueExtents: min = " << min << ", max = " << max << endl; |
354 | 354 |
355 if (max == min) { | 355 if (max == min) { |
356 max = max + 0.5; | 356 max = max + 0.5; |
357 min = min - 0.5; | 357 min = min - 0.5; |
358 } else { | 358 } else { |
359 float margin = (max - min) / 10.0; | 359 double margin = (max - min) / 10.0; |
360 max = max + margin; | 360 max = max + margin; |
361 min = min - margin; | 361 min = min - margin; |
362 } | 362 } |
363 | 363 |
364 #ifdef DEBUG_TIME_VALUE_LAYER | 364 #ifdef DEBUG_TIME_VALUE_LAYER |
368 | 368 |
369 return true; | 369 return true; |
370 } | 370 } |
371 | 371 |
372 bool | 372 bool |
373 TimeValueLayer::getDisplayExtents(float &min, float &max) const | 373 TimeValueLayer::getDisplayExtents(double &min, double &max) const |
374 { | 374 { |
375 if (!m_model || shouldAutoAlign()) return false; | 375 if (!m_model || shouldAutoAlign()) return false; |
376 | 376 |
377 if (m_scaleMinimum == m_scaleMaximum) { | 377 if (m_scaleMinimum == m_scaleMaximum) { |
378 bool log; | 378 bool log; |
382 min = m_scaleMinimum; | 382 min = m_scaleMinimum; |
383 max = m_scaleMaximum; | 383 max = m_scaleMaximum; |
384 } | 384 } |
385 | 385 |
386 if (m_derivative) { | 386 if (m_derivative) { |
387 max = std::max(fabsf(min), fabsf(max)); | 387 max = std::max(fabs(min), fabs(max)); |
388 min = -max; | 388 min = -max; |
389 } | 389 } |
390 | 390 |
391 #ifdef DEBUG_TIME_VALUE_LAYER | 391 #ifdef DEBUG_TIME_VALUE_LAYER |
392 cerr << "TimeValueLayer::getDisplayExtents: min = " << min << ", max = " << max << endl; | 392 cerr << "TimeValueLayer::getDisplayExtents: min = " << min << ", max = " << max << endl; |
394 | 394 |
395 return true; | 395 return true; |
396 } | 396 } |
397 | 397 |
398 bool | 398 bool |
399 TimeValueLayer::setDisplayExtents(float min, float max) | 399 TimeValueLayer::setDisplayExtents(double min, double max) |
400 { | 400 { |
401 if (!m_model) return false; | 401 if (!m_model) return false; |
402 | 402 |
403 if (min == max) { | 403 if (min == max) { |
404 if (min == 0.f) { | 404 if (min == 0.f) { |
436 if (!m_model) return 0; | 436 if (!m_model) return 0; |
437 | 437 |
438 RangeMapper *mapper = getNewVerticalZoomRangeMapper(); | 438 RangeMapper *mapper = getNewVerticalZoomRangeMapper(); |
439 if (!mapper) return 0; | 439 if (!mapper) return 0; |
440 | 440 |
441 float dmin, dmax; | 441 double dmin, dmax; |
442 getDisplayExtents(dmin, dmax); | 442 getDisplayExtents(dmin, dmax); |
443 | 443 |
444 int nr = mapper->getPositionForValue(dmax - dmin); | 444 int nr = mapper->getPositionForValue(dmax - dmin); |
445 | 445 |
446 #ifdef DEBUG_TIME_VALUE_LAYER | 446 #ifdef DEBUG_TIME_VALUE_LAYER |
459 if (!m_model) return; | 459 if (!m_model) return; |
460 | 460 |
461 RangeMapper *mapper = getNewVerticalZoomRangeMapper(); | 461 RangeMapper *mapper = getNewVerticalZoomRangeMapper(); |
462 if (!mapper) return; | 462 if (!mapper) return; |
463 | 463 |
464 float min, max; | 464 double min, max; |
465 bool logarithmic; | 465 bool logarithmic; |
466 QString unit; | 466 QString unit; |
467 getValueExtents(min, max, logarithmic, unit); | 467 getValueExtents(min, max, logarithmic, unit); |
468 | 468 |
469 float dmin, dmax; | 469 double dmin, dmax; |
470 getDisplayExtents(dmin, dmax); | 470 getDisplayExtents(dmin, dmax); |
471 | 471 |
472 float newdist = mapper->getValueForPosition(100 - step); | 472 double newdist = mapper->getValueForPosition(100 - step); |
473 | 473 |
474 float newmin, newmax; | 474 double newmin, newmax; |
475 | 475 |
476 if (logarithmic) { | 476 if (logarithmic) { |
477 | 477 |
478 // see SpectrogramLayer::setVerticalZoomStep | 478 // see SpectrogramLayer::setVerticalZoomStep |
479 | 479 |
480 newmax = (newdist + sqrtf(newdist*newdist + 4*dmin*dmax)) / 2; | 480 newmax = (newdist + sqrt(newdist*newdist + 4*dmin*dmax)) / 2; |
481 newmin = newmax - newdist; | 481 newmin = newmax - newdist; |
482 | 482 |
483 #ifdef DEBUG_TIME_VALUE_LAYER | 483 #ifdef DEBUG_TIME_VALUE_LAYER |
484 cerr << "newmin = " << newmin << ", newmax = " << newmax << endl; | 484 cerr << "newmin = " << newmin << ", newmax = " << newmax << endl; |
485 #endif | 485 #endif |
486 | 486 |
487 } else { | 487 } else { |
488 float dmid = (dmax + dmin) / 2; | 488 double dmid = (dmax + dmin) / 2; |
489 newmin = dmid - newdist / 2; | 489 newmin = dmid - newdist / 2; |
490 newmax = dmid + newdist / 2; | 490 newmax = dmid + newdist / 2; |
491 } | 491 } |
492 | 492 |
493 if (newmin < min) { | 493 if (newmin < min) { |
510 { | 510 { |
511 if (!m_model) return 0; | 511 if (!m_model) return 0; |
512 | 512 |
513 RangeMapper *mapper; | 513 RangeMapper *mapper; |
514 | 514 |
515 float min, max; | 515 double min, max; |
516 bool logarithmic; | 516 bool logarithmic; |
517 QString unit; | 517 QString unit; |
518 getValueExtents(min, max, logarithmic, unit); | 518 getValueExtents(min, max, logarithmic, unit); |
519 | 519 |
520 if (min == max) return 0; | 520 if (min == max) return 0; |
531 SparseTimeValueModel::PointList | 531 SparseTimeValueModel::PointList |
532 TimeValueLayer::getLocalPoints(View *v, int x) const | 532 TimeValueLayer::getLocalPoints(View *v, int x) const |
533 { | 533 { |
534 if (!m_model) return SparseTimeValueModel::PointList(); | 534 if (!m_model) return SparseTimeValueModel::PointList(); |
535 | 535 |
536 long frame = v->getFrameForX(x); | 536 sv_frame_t frame = v->getFrameForX(x); |
537 | 537 |
538 SparseTimeValueModel::PointList onPoints = | 538 SparseTimeValueModel::PointList onPoints = |
539 m_model->getPoints(frame); | 539 m_model->getPoints(frame); |
540 | 540 |
541 if (!onPoints.empty()) { | 541 if (!onPoints.empty()) { |
551 | 551 |
552 if (prevPoints.empty()) { | 552 if (prevPoints.empty()) { |
553 usePoints = nextPoints; | 553 usePoints = nextPoints; |
554 } else if (nextPoints.empty()) { | 554 } else if (nextPoints.empty()) { |
555 // stick with prevPoints | 555 // stick with prevPoints |
556 } else if (long(prevPoints.begin()->frame) < v->getStartFrame() && | 556 } else if (prevPoints.begin()->frame < v->getStartFrame() && |
557 !(nextPoints.begin()->frame > v->getEndFrame())) { | 557 !(nextPoints.begin()->frame > v->getEndFrame())) { |
558 usePoints = nextPoints; | 558 usePoints = nextPoints; |
559 } else if (nextPoints.begin()->frame - frame < | 559 } else if (nextPoints.begin()->frame - frame < |
560 frame - prevPoints.begin()->frame) { | 560 frame - prevPoints.begin()->frame) { |
561 usePoints = nextPoints; | 561 usePoints = nextPoints; |
600 } else { | 600 } else { |
601 return tr("No local points"); | 601 return tr("No local points"); |
602 } | 602 } |
603 } | 603 } |
604 | 604 |
605 long useFrame = points.begin()->frame; | 605 sv_frame_t useFrame = points.begin()->frame; |
606 | 606 |
607 RealTime rt = RealTime::frame2RealTime(useFrame, m_model->getSampleRate()); | 607 RealTime rt = RealTime::frame2RealTime(useFrame, m_model->getSampleRate()); |
608 | 608 |
609 QString text; | 609 QString text; |
610 QString unit = getScaleUnits(); | 610 QString unit = getScaleUnits(); |
627 getYForValue(v, points.begin()->value)); | 627 getYForValue(v, points.begin()->value)); |
628 return text; | 628 return text; |
629 } | 629 } |
630 | 630 |
631 bool | 631 bool |
632 TimeValueLayer::snapToFeatureFrame(View *v, int &frame, | 632 TimeValueLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, |
633 int &resolution, | 633 int &resolution, |
634 SnapType snap) const | 634 SnapType snap) const |
635 { | 635 { |
636 if (!m_model) { | 636 if (!m_model) { |
637 return Layer::snapToFeatureFrame(v, frame, resolution, snap); | 637 return Layer::snapToFeatureFrame(v, frame, resolution, snap); |
647 frame = points.begin()->frame; | 647 frame = points.begin()->frame; |
648 return true; | 648 return true; |
649 } | 649 } |
650 | 650 |
651 points = m_model->getPoints(frame, frame); | 651 points = m_model->getPoints(frame, frame); |
652 int snapped = frame; | 652 sv_frame_t snapped = frame; |
653 bool found = false; | 653 bool found = false; |
654 | 654 |
655 for (SparseTimeValueModel::PointList::const_iterator i = points.begin(); | 655 for (SparseTimeValueModel::PointList::const_iterator i = points.begin(); |
656 i != points.end(); ++i) { | 656 i != points.end(); ++i) { |
657 | 657 |
699 frame = snapped; | 699 frame = snapped; |
700 return found; | 700 return found; |
701 } | 701 } |
702 | 702 |
703 bool | 703 bool |
704 TimeValueLayer::snapToSimilarFeature(View *v, int &frame, | 704 TimeValueLayer::snapToSimilarFeature(View *v, sv_frame_t &frame, |
705 int &resolution, | 705 int &resolution, |
706 SnapType snap) const | 706 SnapType snap) const |
707 { | 707 { |
708 if (!m_model) { | 708 if (!m_model) { |
709 return Layer::snapToSimilarFeature(v, frame, resolution, snap); | 709 return Layer::snapToSimilarFeature(v, frame, resolution, snap); |
714 const SparseTimeValueModel::PointList &points = m_model->getPoints(); | 714 const SparseTimeValueModel::PointList &points = m_model->getPoints(); |
715 SparseTimeValueModel::PointList close = m_model->getPoints(frame, frame); | 715 SparseTimeValueModel::PointList close = m_model->getPoints(frame, frame); |
716 | 716 |
717 SparseTimeValueModel::PointList::const_iterator i; | 717 SparseTimeValueModel::PointList::const_iterator i; |
718 | 718 |
719 int matchframe = frame; | 719 sv_frame_t matchframe = frame; |
720 float matchvalue = 0.f; | 720 double matchvalue = 0.0; |
721 | 721 |
722 for (i = close.begin(); i != close.end(); ++i) { | 722 for (i = close.begin(); i != close.end(); ++i) { |
723 if (i->frame > frame) break; | 723 if (i->frame > frame) break; |
724 matchvalue = i->value; | 724 matchvalue = i->value; |
725 matchframe = i->frame; | 725 matchframe = i->frame; |
726 } | 726 } |
727 | 727 |
728 int snapped = frame; | 728 sv_frame_t snapped = frame; |
729 bool found = false; | 729 bool found = false; |
730 bool distant = false; | 730 bool distant = false; |
731 float epsilon = 0.0001; | 731 double epsilon = 0.0001; |
732 | 732 |
733 i = close.begin(); | 733 i = close.begin(); |
734 | 734 |
735 // Scan through the close points first, then the more distant ones | 735 // Scan through the close points first, then the more distant ones |
736 // if no suitable close one is found. So the while-termination | 736 // if no suitable close one is found. So the while-termination |
751 } | 751 } |
752 | 752 |
753 if (snap == SnapRight) { | 753 if (snap == SnapRight) { |
754 | 754 |
755 if (i->frame > matchframe && | 755 if (i->frame > matchframe && |
756 fabsf(i->value - matchvalue) < epsilon) { | 756 fabs(i->value - matchvalue) < epsilon) { |
757 snapped = i->frame; | 757 snapped = i->frame; |
758 found = true; | 758 found = true; |
759 break; | 759 break; |
760 } | 760 } |
761 | 761 |
762 } else if (snap == SnapLeft) { | 762 } else if (snap == SnapLeft) { |
763 | 763 |
764 if (i->frame < matchframe) { | 764 if (i->frame < matchframe) { |
765 if (fabsf(i->value - matchvalue) < epsilon) { | 765 if (fabs(i->value - matchvalue) < epsilon) { |
766 snapped = i->frame; | 766 snapped = i->frame; |
767 found = true; // don't break, as the next may be better | 767 found = true; // don't break, as the next may be better |
768 } | 768 } |
769 } else if (found || distant) { | 769 } else if (found || distant) { |
770 break; | 770 break; |
780 frame = snapped; | 780 frame = snapped; |
781 return found; | 781 return found; |
782 } | 782 } |
783 | 783 |
784 void | 784 void |
785 TimeValueLayer::getScaleExtents(View *v, float &min, float &max, bool &log) const | 785 TimeValueLayer::getScaleExtents(View *v, double &min, double &max, bool &log) const |
786 { | 786 { |
787 min = 0.0; | 787 min = 0.0; |
788 max = 0.0; | 788 max = 0.0; |
789 log = false; | 789 log = false; |
790 | 790 |
816 cerr << "TimeValueLayer::getScaleExtents: min = " << min << ", max = " << max << endl; | 816 cerr << "TimeValueLayer::getScaleExtents: min = " << min << ", max = " << max << endl; |
817 #endif | 817 #endif |
818 } | 818 } |
819 | 819 |
820 int | 820 int |
821 TimeValueLayer::getYForValue(View *v, float val) const | 821 TimeValueLayer::getYForValue(View *v, double val) const |
822 { | 822 { |
823 float min = 0.0, max = 0.0; | 823 double min = 0.0, max = 0.0; |
824 bool logarithmic = false; | 824 bool logarithmic = false; |
825 int h = v->height(); | 825 int h = v->height(); |
826 | 826 |
827 getScaleExtents(v, min, max, logarithmic); | 827 getScaleExtents(v, min, max, logarithmic); |
828 | 828 |
836 } | 836 } |
837 | 837 |
838 return int(h - ((val - min) * h) / (max - min)); | 838 return int(h - ((val - min) * h) / (max - min)); |
839 } | 839 } |
840 | 840 |
841 float | 841 double |
842 TimeValueLayer::getValueForY(View *v, int y) const | 842 TimeValueLayer::getValueForY(View *v, int y) const |
843 { | 843 { |
844 float min = 0.0, max = 0.0; | 844 double min = 0.0, max = 0.0; |
845 bool logarithmic = false; | 845 bool logarithmic = false; |
846 int h = v->height(); | 846 int h = v->height(); |
847 | 847 |
848 getScaleExtents(v, min, max, logarithmic); | 848 getScaleExtents(v, min, max, logarithmic); |
849 | 849 |
850 float val = min + (float(h - y) * float(max - min)) / h; | 850 double val = min + (double(h - y) * double(max - min)) / h; |
851 | 851 |
852 if (logarithmic) { | 852 if (logarithmic) { |
853 val = LogRange::map(val); | 853 val = LogRange::map(val); |
854 } | 854 } |
855 | 855 |
863 QString unit = getScaleUnits(); | 863 QString unit = getScaleUnits(); |
864 return (m_verticalScale == AutoAlignScale && unit != ""); | 864 return (m_verticalScale == AutoAlignScale && unit != ""); |
865 } | 865 } |
866 | 866 |
867 QColor | 867 QColor |
868 TimeValueLayer::getColourForValue(View *v, float val) const | 868 TimeValueLayer::getColourForValue(View *v, double val) const |
869 { | 869 { |
870 float min, max; | 870 double min, max; |
871 bool log; | 871 bool log; |
872 getScaleExtents(v, min, max, log); | 872 getScaleExtents(v, min, max, log); |
873 | 873 |
874 if (min > max) std::swap(min, max); | 874 if (min > max) std::swap(min, max); |
875 if (max == min) max = min + 1; | 875 if (max == min) max = min + 1; |
898 void | 898 void |
899 TimeValueLayer::paint(View *v, QPainter &paint, QRect rect) const | 899 TimeValueLayer::paint(View *v, QPainter &paint, QRect rect) const |
900 { | 900 { |
901 if (!m_model || !m_model->isOK()) return; | 901 if (!m_model || !m_model->isOK()) return; |
902 | 902 |
903 int sampleRate = m_model->getSampleRate(); | 903 sv_samplerate_t sampleRate = m_model->getSampleRate(); |
904 if (!sampleRate) return; | 904 if (!sampleRate) return; |
905 | 905 |
906 paint.setRenderHint(QPainter::Antialiasing, false); | 906 paint.setRenderHint(QPainter::Antialiasing, false); |
907 | 907 |
908 // Profiler profiler("TimeValueLayer::paint", true); | 908 // Profiler profiler("TimeValueLayer::paint", true); |
909 | 909 |
910 int x0 = rect.left(), x1 = rect.right(); | 910 int x0 = rect.left(), x1 = rect.right(); |
911 long frame0 = v->getFrameForX(x0); | 911 sv_frame_t frame0 = v->getFrameForX(x0); |
912 long frame1 = v->getFrameForX(x1); | 912 sv_frame_t frame1 = v->getFrameForX(x1); |
913 if (m_derivative) --frame0; | 913 if (m_derivative) --frame0; |
914 | 914 |
915 SparseTimeValueModel::PointList points(m_model->getPoints | 915 SparseTimeValueModel::PointList points(m_model->getPoints |
916 (frame0, frame1)); | 916 (frame0, frame1)); |
917 if (points.empty()) return; | 917 if (points.empty()) return; |
925 #ifdef DEBUG_TIME_VALUE_LAYER | 925 #ifdef DEBUG_TIME_VALUE_LAYER |
926 cerr << "TimeValueLayer::paint: resolution is " | 926 cerr << "TimeValueLayer::paint: resolution is " |
927 << m_model->getResolution() << " frames" << endl; | 927 << m_model->getResolution() << " frames" << endl; |
928 #endif | 928 #endif |
929 | 929 |
930 float min = m_model->getValueMinimum(); | 930 double min = m_model->getValueMinimum(); |
931 float max = m_model->getValueMaximum(); | 931 double max = m_model->getValueMaximum(); |
932 if (max == min) max = min + 1.0; | 932 if (max == min) max = min + 1.0; |
933 | 933 |
934 int origin = int(nearbyint(v->height() - | 934 int origin = int(nearbyint(v->height() - |
935 (-min * v->height()) / (max - min))); | 935 (-min * v->height()) / (max - min))); |
936 | 936 |
937 QPoint localPos; | 937 QPoint localPos; |
938 long illuminateFrame = -1; | 938 sv_frame_t illuminateFrame = -1; |
939 | 939 |
940 if (v->shouldIlluminateLocalFeatures(this, localPos)) { | 940 if (v->shouldIlluminateLocalFeatures(this, localPos)) { |
941 SparseTimeValueModel::PointList localPoints = | 941 SparseTimeValueModel::PointList localPoints = |
942 getLocalPoints(v, localPos.x()); | 942 getLocalPoints(v, localPos.x()); |
943 #ifdef DEBUG_TIME_VALUE_LAYER | 943 #ifdef DEBUG_TIME_VALUE_LAYER |
972 paint.drawLine(x0, originY, x1, originY); | 972 paint.drawLine(x0, originY, x1, originY); |
973 paint.restore(); | 973 paint.restore(); |
974 } | 974 } |
975 } | 975 } |
976 | 976 |
977 int prevFrame = 0; | 977 sv_frame_t prevFrame = 0; |
978 | 978 |
979 for (SparseTimeValueModel::PointList::const_iterator i = points.begin(); | 979 for (SparseTimeValueModel::PointList::const_iterator i = points.begin(); |
980 i != points.end(); ++i) { | 980 i != points.end(); ++i) { |
981 | 981 |
982 if (m_derivative && i == points.begin()) continue; | 982 if (m_derivative && i == points.begin()) continue; |
983 | 983 |
984 const SparseTimeValueModel::Point &p(*i); | 984 const SparseTimeValueModel::Point &p(*i); |
985 | 985 |
986 float value = p.value; | 986 double value = p.value; |
987 if (m_derivative) { | 987 if (m_derivative) { |
988 SparseTimeValueModel::PointList::const_iterator j = i; | 988 SparseTimeValueModel::PointList::const_iterator j = i; |
989 --j; | 989 --j; |
990 value -= j->value; | 990 value -= j->value; |
991 } | 991 } |
1010 textY = paint.fontMetrics().ascent() + 1; | 1010 textY = paint.fontMetrics().ascent() + 1; |
1011 } | 1011 } |
1012 } | 1012 } |
1013 | 1013 |
1014 bool haveNext = false; | 1014 bool haveNext = false; |
1015 float nvalue = 0.f; | 1015 double nvalue = 0.f; |
1016 int nf = v->getModelsEndFrame(); | 1016 sv_frame_t nf = v->getModelsEndFrame(); |
1017 int nx = v->getXForFrame(nf); | 1017 int nx = v->getXForFrame(nf); |
1018 int ny = y; | 1018 int ny = y; |
1019 | 1019 |
1020 SparseTimeValueModel::PointList::const_iterator j = i; | 1020 SparseTimeValueModel::PointList::const_iterator j = i; |
1021 ++j; | 1021 ++j; |
1120 // paint.drawLine(x + w/2, y, nx + w/2, ny); | 1120 // paint.drawLine(x + w/2, y, nx + w/2, ny); |
1121 path.lineTo(nx + w/2, ny); | 1121 path.lineTo(nx + w/2, ny); |
1122 | 1122 |
1123 } else { | 1123 } else { |
1124 | 1124 |
1125 float x0 = x + float(w)/2; | 1125 double x0 = x + double(w)/2; |
1126 float x1 = nx + float(w)/2; | 1126 double x1 = nx + double(w)/2; |
1127 | 1127 |
1128 float y0 = y; | 1128 double y0 = y; |
1129 float y1 = ny; | 1129 double y1 = ny; |
1130 | 1130 |
1131 if (m_plotStyle == PlotDiscreteCurves) { | 1131 if (m_plotStyle == PlotDiscreteCurves) { |
1132 bool nextGap = | 1132 bool nextGap = |
1133 (nvalue == 0.0) || | 1133 (nvalue == 0.0) || |
1134 (nf - p.frame >= m_model->getResolution() * 2); | 1134 (nf - p.frame >= m_model->getResolution() * 2); |
1253 TimeValueLayer::paintVerticalScale(View *v, bool, QPainter &paint, QRect) const | 1253 TimeValueLayer::paintVerticalScale(View *v, bool, QPainter &paint, QRect) const |
1254 { | 1254 { |
1255 if (!m_model || m_model->getPoints().empty()) return; | 1255 if (!m_model || m_model->getPoints().empty()) return; |
1256 | 1256 |
1257 QString unit; | 1257 QString unit; |
1258 float min, max; | 1258 double min, max; |
1259 bool logarithmic; | 1259 bool logarithmic; |
1260 | 1260 |
1261 int w = getVerticalScaleWidth(v, false, paint); | 1261 int w = getVerticalScaleWidth(v, false, paint); |
1262 int h = v->height(); | 1262 int h = v->height(); |
1263 | 1263 |
1308 cerr << "TimeValueLayer::drawStart(" << e->x() << "," << e->y() << ")" << endl; | 1308 cerr << "TimeValueLayer::drawStart(" << e->x() << "," << e->y() << ")" << endl; |
1309 #endif | 1309 #endif |
1310 | 1310 |
1311 if (!m_model) return; | 1311 if (!m_model) return; |
1312 | 1312 |
1313 long frame = v->getFrameForX(e->x()); | 1313 sv_frame_t frame = v->getFrameForX(e->x()); |
1314 long resolution = m_model->getResolution(); | 1314 int resolution = m_model->getResolution(); |
1315 if (frame < 0) frame = 0; | 1315 if (frame < 0) frame = 0; |
1316 frame = (frame / resolution) * resolution; | 1316 frame = (frame / resolution) * resolution; |
1317 | 1317 |
1318 float value = getValueForY(v, e->y()); | 1318 double value = getValueForY(v, e->y()); |
1319 | 1319 |
1320 bool havePoint = false; | 1320 bool havePoint = false; |
1321 | 1321 |
1322 SparseTimeValueModel::PointList points = getLocalPoints(v, e->x()); | 1322 SparseTimeValueModel::PointList points = getLocalPoints(v, e->x()); |
1323 if (!points.empty()) { | 1323 if (!points.empty()) { |
1334 } | 1334 } |
1335 } | 1335 } |
1336 | 1336 |
1337 if (!havePoint) { | 1337 if (!havePoint) { |
1338 m_editingPoint = SparseTimeValueModel::Point | 1338 m_editingPoint = SparseTimeValueModel::Point |
1339 (frame, value, tr("New Point")); | 1339 (frame, float(value), tr("New Point")); |
1340 } | 1340 } |
1341 | 1341 |
1342 m_originalPoint = m_editingPoint; | 1342 m_originalPoint = m_editingPoint; |
1343 | 1343 |
1344 if (m_editingCommand) finish(m_editingCommand); | 1344 if (m_editingCommand) finish(m_editingCommand); |
1358 cerr << "TimeValueLayer::drawDrag(" << e->x() << "," << e->y() << ")" << endl; | 1358 cerr << "TimeValueLayer::drawDrag(" << e->x() << "," << e->y() << ")" << endl; |
1359 #endif | 1359 #endif |
1360 | 1360 |
1361 if (!m_model || !m_editing) return; | 1361 if (!m_model || !m_editing) return; |
1362 | 1362 |
1363 long frame = v->getFrameForX(e->x()); | 1363 sv_frame_t frame = v->getFrameForX(e->x()); |
1364 long resolution = m_model->getResolution(); | 1364 int resolution = m_model->getResolution(); |
1365 if (frame < 0) frame = 0; | 1365 if (frame < 0) frame = 0; |
1366 frame = (frame / resolution) * resolution; | 1366 frame = (frame / resolution) * resolution; |
1367 | 1367 |
1368 float value = getValueForY(v, e->y()); | 1368 double value = getValueForY(v, e->y()); |
1369 | 1369 |
1370 SparseTimeValueModel::PointList points = getLocalPoints(v, e->x()); | 1370 SparseTimeValueModel::PointList points = getLocalPoints(v, e->x()); |
1371 | 1371 |
1372 #ifdef DEBUG_TIME_VALUE_LAYER | 1372 #ifdef DEBUG_TIME_VALUE_LAYER |
1373 cerr << points.size() << " points" << endl; | 1373 cerr << points.size() << " points" << endl; |
1407 } | 1407 } |
1408 } | 1408 } |
1409 | 1409 |
1410 // m_editingCommand->deletePoint(m_editingPoint); | 1410 // m_editingCommand->deletePoint(m_editingPoint); |
1411 m_editingPoint.frame = frame; | 1411 m_editingPoint.frame = frame; |
1412 m_editingPoint.value = value; | 1412 m_editingPoint.value = float(value); |
1413 m_editingCommand->addPoint(m_editingPoint); | 1413 m_editingCommand->addPoint(m_editingPoint); |
1414 } | 1414 } |
1415 | 1415 |
1416 void | 1416 void |
1417 TimeValueLayer::drawEnd(View *, QMouseEvent *) | 1417 TimeValueLayer::drawEnd(View *, QMouseEvent *) |
1500 cerr << "TimeValueLayer::editDrag(" << e->x() << "," << e->y() << ")" << endl; | 1500 cerr << "TimeValueLayer::editDrag(" << e->x() << "," << e->y() << ")" << endl; |
1501 #endif | 1501 #endif |
1502 | 1502 |
1503 if (!m_model || !m_editing) return; | 1503 if (!m_model || !m_editing) return; |
1504 | 1504 |
1505 long frame = v->getFrameForX(e->x()); | 1505 sv_frame_t frame = v->getFrameForX(e->x()); |
1506 if (frame < 0) frame = 0; | 1506 if (frame < 0) frame = 0; |
1507 frame = frame / m_model->getResolution() * m_model->getResolution(); | 1507 frame = frame / m_model->getResolution() * m_model->getResolution(); |
1508 | 1508 |
1509 float value = getValueForY(v, e->y()); | 1509 double value = getValueForY(v, e->y()); |
1510 | 1510 |
1511 if (!m_editingCommand) { | 1511 if (!m_editingCommand) { |
1512 m_editingCommand = new SparseTimeValueModel::EditCommand(m_model, | 1512 m_editingCommand = new SparseTimeValueModel::EditCommand(m_model, |
1513 tr("Drag Point")); | 1513 tr("Drag Point")); |
1514 } | 1514 } |
1515 | 1515 |
1516 m_editingCommand->deletePoint(m_editingPoint); | 1516 m_editingCommand->deletePoint(m_editingPoint); |
1517 m_editingPoint.frame = frame; | 1517 m_editingPoint.frame = frame; |
1518 m_editingPoint.value = value; | 1518 m_editingPoint.value = float(value); |
1519 m_editingCommand->addPoint(m_editingPoint); | 1519 m_editingCommand->addPoint(m_editingPoint); |
1520 } | 1520 } |
1521 | 1521 |
1522 void | 1522 void |
1523 TimeValueLayer::editEnd(View *, QMouseEvent *) | 1523 TimeValueLayer::editEnd(View *, QMouseEvent *) |
1587 delete dialog; | 1587 delete dialog; |
1588 return true; | 1588 return true; |
1589 } | 1589 } |
1590 | 1590 |
1591 void | 1591 void |
1592 TimeValueLayer::moveSelection(Selection s, int newStartFrame) | 1592 TimeValueLayer::moveSelection(Selection s, sv_frame_t newStartFrame) |
1593 { | 1593 { |
1594 if (!m_model) return; | 1594 if (!m_model) return; |
1595 | 1595 |
1596 SparseTimeValueModel::EditCommand *command = | 1596 SparseTimeValueModel::EditCommand *command = |
1597 new SparseTimeValueModel::EditCommand(m_model, | 1597 new SparseTimeValueModel::EditCommand(m_model, |
1633 for (SparseTimeValueModel::PointList::iterator i = points.begin(); | 1633 for (SparseTimeValueModel::PointList::iterator i = points.begin(); |
1634 i != points.end(); ++i) { | 1634 i != points.end(); ++i) { |
1635 | 1635 |
1636 if (s.contains(i->frame)) { | 1636 if (s.contains(i->frame)) { |
1637 | 1637 |
1638 double target = i->frame; | 1638 double target = double(i->frame); |
1639 target = newSize.getStartFrame() + | 1639 target = double(newSize.getStartFrame()) + |
1640 double(target - s.getStartFrame()) * ratio; | 1640 target - double(s.getStartFrame()) * ratio; |
1641 | 1641 |
1642 SparseTimeValueModel::Point newPoint(*i); | 1642 SparseTimeValueModel::Point newPoint(*i); |
1643 newPoint.frame = lrint(target); | 1643 newPoint.frame = lrint(target); |
1644 command->deletePoint(*i); | 1644 command->deletePoint(*i); |
1645 command->addPoint(newPoint); | 1645 command->addPoint(newPoint); |
1689 } | 1689 } |
1690 } | 1690 } |
1691 } | 1691 } |
1692 | 1692 |
1693 bool | 1693 bool |
1694 TimeValueLayer::paste(View *v, const Clipboard &from, int /* frameOffset */, | 1694 TimeValueLayer::paste(View *v, const Clipboard &from, sv_frame_t /* frameOffset */, |
1695 bool interactive) | 1695 bool interactive) |
1696 { | 1696 { |
1697 if (!m_model) return false; | 1697 if (!m_model) return false; |
1698 | 1698 |
1699 const Clipboard::PointList &points = from.getPoints(); | 1699 const Clipboard::PointList &points = from.getPoints(); |
1832 for (Clipboard::PointList::const_iterator i = points.begin(); | 1832 for (Clipboard::PointList::const_iterator i = points.begin(); |
1833 i != points.end(); ++i) { | 1833 i != points.end(); ++i) { |
1834 | 1834 |
1835 if (!i->haveFrame()) continue; | 1835 if (!i->haveFrame()) continue; |
1836 | 1836 |
1837 int frame = 0; | 1837 sv_frame_t frame = 0; |
1838 | 1838 |
1839 if (!realign) { | 1839 if (!realign) { |
1840 | 1840 |
1841 frame = i->getFrame(); | 1841 frame = i->getFrame(); |
1842 | 1842 |