Mercurial > hg > svgui
comparison layer/Colour3DPlotLayer.cpp @ 904:e0f08e108064 cxx11
Move to using double rather than float for floating-point calculations (float only for storage); more build fixes
author | Chris Cannam |
---|---|
date | Mon, 09 Mar 2015 12:02:10 +0000 |
parents | 1757933ce5a7 |
children | 4a578a360011 |
comparison
equal
deleted
inserted
replaced
903:1757933ce5a7 | 904:e0f08e108064 |
---|---|
541 QPoint discard; | 541 QPoint discard; |
542 return !v->shouldIlluminateLocalFeatures(this, discard); | 542 return !v->shouldIlluminateLocalFeatures(this, discard); |
543 } | 543 } |
544 | 544 |
545 bool | 545 bool |
546 Colour3DPlotLayer::getValueExtents(float &min, float &max, | 546 Colour3DPlotLayer::getValueExtents(double &min, double &max, |
547 bool &logarithmic, QString &unit) const | 547 bool &logarithmic, QString &unit) const |
548 { | 548 { |
549 if (!m_model) return false; | 549 if (!m_model) return false; |
550 | 550 |
551 min = 0; | 551 min = 0; |
552 max = float(m_model->getHeight()); | 552 max = double(m_model->getHeight()); |
553 | 553 |
554 logarithmic = false; | 554 logarithmic = false; |
555 unit = ""; | 555 unit = ""; |
556 | 556 |
557 return true; | 557 return true; |
558 } | 558 } |
559 | 559 |
560 bool | 560 bool |
561 Colour3DPlotLayer::getDisplayExtents(float &min, float &max) const | 561 Colour3DPlotLayer::getDisplayExtents(double &min, double &max) const |
562 { | 562 { |
563 if (!m_model) return false; | 563 if (!m_model) return false; |
564 | 564 |
565 float hmax = float(m_model->getHeight()); | 565 double hmax = double(m_model->getHeight()); |
566 | 566 |
567 min = float(m_miny); | 567 min = m_miny; |
568 max = float(m_maxy); | 568 max = m_maxy; |
569 if (max <= min) { | 569 if (max <= min) { |
570 min = 0; | 570 min = 0; |
571 max = hmax; | 571 max = hmax; |
572 } | 572 } |
573 if (min < 0) min = 0; | 573 if (min < 0) min = 0; |
575 | 575 |
576 return true; | 576 return true; |
577 } | 577 } |
578 | 578 |
579 bool | 579 bool |
580 Colour3DPlotLayer::setDisplayExtents(float min, float max) | 580 Colour3DPlotLayer::setDisplayExtents(double min, double max) |
581 { | 581 { |
582 if (!m_model) return false; | 582 if (!m_model) return false; |
583 | 583 |
584 m_miny = int(lrintf(min)); | 584 m_miny = int(lrint(min)); |
585 m_maxy = int(lrintf(max)); | 585 m_maxy = int(lrint(max)); |
586 | 586 |
587 emit layerParametersChanged(); | 587 emit layerParametersChanged(); |
588 return true; | 588 return true; |
589 } | 589 } |
590 | 590 |
591 bool | 591 bool |
592 Colour3DPlotLayer::getYScaleValue(const View *, int, | 592 Colour3DPlotLayer::getYScaleValue(const View *, int, |
593 float &, QString &) const | 593 double &, QString &) const |
594 { | 594 { |
595 return false;//!!! | 595 return false;//!!! |
596 } | 596 } |
597 | 597 |
598 int | 598 int |
608 int | 608 int |
609 Colour3DPlotLayer::getCurrentVerticalZoomStep() const | 609 Colour3DPlotLayer::getCurrentVerticalZoomStep() const |
610 { | 610 { |
611 if (!m_model) return 0; | 611 if (!m_model) return 0; |
612 | 612 |
613 float min, max; | 613 double min, max; |
614 getDisplayExtents(min, max); | 614 getDisplayExtents(min, max); |
615 return m_model->getHeight() - int(lrintf(max - min)); | 615 return m_model->getHeight() - int(lrint(max - min)); |
616 } | 616 } |
617 | 617 |
618 void | 618 void |
619 Colour3DPlotLayer::setVerticalZoomStep(int step) | 619 Colour3DPlotLayer::setVerticalZoomStep(int step) |
620 { | 620 { |
622 | 622 |
623 // SVDEBUG << "Colour3DPlotLayer::setVerticalZoomStep(" <<step <<"): before: miny = " << m_miny << ", maxy = " << m_maxy << endl; | 623 // SVDEBUG << "Colour3DPlotLayer::setVerticalZoomStep(" <<step <<"): before: miny = " << m_miny << ", maxy = " << m_maxy << endl; |
624 | 624 |
625 int dist = m_model->getHeight() - step; | 625 int dist = m_model->getHeight() - step; |
626 if (dist < 1) dist = 1; | 626 if (dist < 1) dist = 1; |
627 float centre = float(m_miny) + (float(m_maxy) - float(m_miny)) / 2.f; | 627 double centre = m_miny + (m_maxy - m_miny) / 2.0; |
628 m_miny = int(lrintf(centre - float(dist)/2)); | 628 m_miny = int(lrint(centre - dist/2.0)); |
629 if (m_miny < 0) m_miny = 0; | 629 if (m_miny < 0) m_miny = 0; |
630 m_maxy = m_miny + dist; | 630 m_maxy = m_miny + dist; |
631 if (m_maxy > m_model->getHeight()) m_maxy = m_model->getHeight(); | 631 if (m_maxy > m_model->getHeight()) m_maxy = m_model->getHeight(); |
632 | 632 |
633 // SVDEBUG << "Colour3DPlotLayer::setVerticalZoomStep(" <<step <<"): after: miny = " << m_miny << ", maxy = " << m_maxy << endl; | 633 // SVDEBUG << "Colour3DPlotLayer::setVerticalZoomStep(" <<step <<"): after: miny = " << m_miny << ", maxy = " << m_maxy << endl; |
642 | 642 |
643 return new LinearRangeMapper(0, m_model->getHeight(), | 643 return new LinearRangeMapper(0, m_model->getHeight(), |
644 0, m_model->getHeight(), ""); | 644 0, m_model->getHeight(), ""); |
645 } | 645 } |
646 | 646 |
647 float | 647 double |
648 Colour3DPlotLayer::getYForBin(View *v, float bin) const | 648 Colour3DPlotLayer::getYForBin(View *v, double bin) const |
649 { | 649 { |
650 float y = bin; | 650 double y = bin; |
651 if (!m_model) return y; | 651 if (!m_model) return y; |
652 float mn = 0, mx = float(m_model->getHeight()); | 652 double mn = 0, mx = m_model->getHeight(); |
653 getDisplayExtents(mn, mx); | 653 getDisplayExtents(mn, mx); |
654 float h = float(v->height()); | 654 double h = v->height(); |
655 if (m_binScale == LinearBinScale) { | 655 if (m_binScale == LinearBinScale) { |
656 y = h - (((bin - mn) * h) / (mx - mn)); | 656 y = h - (((bin - mn) * h) / (mx - mn)); |
657 } else { | 657 } else { |
658 float logmin = mn + 1, logmax = mx + 1; | 658 double logmin = mn + 1, logmax = mx + 1; |
659 LogRange::mapRange(logmin, logmax); | 659 LogRange::mapRange(logmin, logmax); |
660 y = h - (((LogRange::map(bin + 1) - logmin) * h) / (logmax - logmin)); | 660 y = h - (((LogRange::map(bin + 1) - logmin) * h) / (logmax - logmin)); |
661 } | 661 } |
662 return y; | 662 return y; |
663 } | 663 } |
664 | 664 |
665 int | 665 int |
666 Colour3DPlotLayer::getIYForBin(View *v, int bin) const | 666 Colour3DPlotLayer::getIYForBin(View *v, int bin) const |
667 { | 667 { |
668 return int(roundf(getYForBin(v, float(bin)))); | 668 return int(round(getYForBin(v, bin))); |
669 } | 669 } |
670 | 670 |
671 float | 671 double |
672 Colour3DPlotLayer::getBinForY(View *v, float y) const | 672 Colour3DPlotLayer::getBinForY(View *v, double y) const |
673 { | 673 { |
674 float bin = y; | 674 double bin = y; |
675 if (!m_model) return bin; | 675 if (!m_model) return bin; |
676 float mn = 0, mx = float(m_model->getHeight()); | 676 double mn = 0, mx = m_model->getHeight(); |
677 getDisplayExtents(mn, mx); | 677 getDisplayExtents(mn, mx); |
678 float h = float(v->height()); | 678 double h = v->height(); |
679 if (m_binScale == LinearBinScale) { | 679 if (m_binScale == LinearBinScale) { |
680 bin = mn + ((h - y) * (mx - mn)) / h; | 680 bin = mn + ((h - y) * (mx - mn)) / h; |
681 } else { | 681 } else { |
682 float logmin = mn + 1, logmax = mx + 1; | 682 double logmin = mn + 1, logmax = mx + 1; |
683 LogRange::mapRange(logmin, logmax); | 683 LogRange::mapRange(logmin, logmax); |
684 bin = LogRange::unmap(logmin + ((h - y) * (logmax - logmin)) / h) - 1; | 684 bin = LogRange::unmap(logmin + ((h - y) * (logmax - logmin)) / h) - 1; |
685 } | 685 } |
686 return bin; | 686 return bin; |
687 } | 687 } |
688 | 688 |
689 int | 689 int |
690 Colour3DPlotLayer::getIBinForY(View *v, int y) const | 690 Colour3DPlotLayer::getIBinForY(View *v, int y) const |
691 { | 691 { |
692 return int(floorf(getBinForY(v, float(y)))); | 692 return int(floor(getBinForY(v, y))); |
693 } | 693 } |
694 | 694 |
695 QString | 695 QString |
696 Colour3DPlotLayer::getFeatureDescription(View *v, QPoint &pos) const | 696 Colour3DPlotLayer::getFeatureDescription(View *v, QPoint &pos) const |
697 { | 697 { |
722 symax = sh; | 722 symax = sh; |
723 } | 723 } |
724 if (symin < 0) symin = 0; | 724 if (symin < 0) symin = 0; |
725 if (symax > sh) symax = sh; | 725 if (symax > sh) symax = sh; |
726 | 726 |
727 // float binHeight = float(v->height()) / (symax - symin); | 727 // double binHeight = double(v->height()) / (symax - symin); |
728 // int sy = int((v->height() - y) / binHeight) + symin; | 728 // int sy = int((v->height() - y) / binHeight) + symin; |
729 | 729 |
730 int sy = getIBinForY(v, y); | 730 int sy = getIBinForY(v, y); |
731 | 731 |
732 if (sy < 0 || sy >= m_model->getHeight()) { | 732 if (sy < 0 || sy >= m_model->getHeight()) { |
793 int cw = getColourScaleWidth(paint); | 793 int cw = getColourScaleWidth(paint); |
794 | 794 |
795 int ch = h - 20; | 795 int ch = h - 20; |
796 if (ch > 20 && m_cache) { | 796 if (ch > 20 && m_cache) { |
797 | 797 |
798 float min = m_model->getMinimumLevel(); | 798 double min = m_model->getMinimumLevel(); |
799 float max = m_model->getMaximumLevel(); | 799 double max = m_model->getMaximumLevel(); |
800 | 800 |
801 float mmin = min; | 801 double mmin = min; |
802 float mmax = max; | 802 double mmax = max; |
803 | 803 |
804 if (m_colourScale == LogScale) { | 804 if (m_colourScale == LogScale) { |
805 LogRange::mapRange(mmin, mmax); | 805 LogRange::mapRange(mmin, mmax); |
806 } else if (m_colourScale == PlusMinusOneScale) { | 806 } else if (m_colourScale == PlusMinusOneScale) { |
807 mmin = -1.f; | 807 mmin = -1.f; |
808 mmax = 1.f; | 808 mmax = 1.f; |
809 } else if (m_colourScale == AbsoluteScale) { | 809 } else if (m_colourScale == AbsoluteScale) { |
810 if (mmin < 0) { | 810 if (mmin < 0) { |
811 if (fabsf(mmin) > fabsf(mmax)) mmax = fabsf(mmin); | 811 if (fabs(mmin) > fabs(mmax)) mmax = fabs(mmin); |
812 else mmax = fabsf(mmax); | 812 else mmax = fabs(mmax); |
813 mmin = 0; | 813 mmin = 0; |
814 } else { | 814 } else { |
815 mmin = fabsf(mmin); | 815 mmin = fabs(mmin); |
816 mmax = fabsf(mmax); | 816 mmax = fabs(mmax); |
817 } | 817 } |
818 } | 818 } |
819 | 819 |
820 if (max == min) max = min + 1.f; | 820 if (max == min) max = min + 1.f; |
821 if (mmax == mmin) mmax = mmin + 1.f; | 821 if (mmax == mmin) mmax = mmin + 1.f; |
822 | 822 |
823 paint.setPen(v->getForeground()); | 823 paint.setPen(v->getForeground()); |
824 paint.drawRect(4, 10, cw - 8, ch+1); | 824 paint.drawRect(4, 10, cw - 8, ch+1); |
825 | 825 |
826 for (int y = 0; y < ch; ++y) { | 826 for (int y = 0; y < ch; ++y) { |
827 float value = ((max - min) * (float(ch-y) - 1.f)) / float(ch) + min; | 827 double value = ((max - min) * (double(ch-y) - 1.0)) / double(ch) + min; |
828 if (m_colourScale == LogScale) { | 828 if (m_colourScale == LogScale) { |
829 value = LogRange::map(value); | 829 value = LogRange::map(value); |
830 } | 830 } |
831 int pixel = int(((value - mmin) * 256) / (mmax - mmin)); | 831 int pixel = int(((value - mmin) * 256) / (mmax - mmin)); |
832 if (pixel >= 0 && pixel < 256) { | 832 if (pixel >= 0 && pixel < 256) { |
932 | 932 |
933 DenseThreeDimensionalModel::Column values = m_model->getColumn(col); | 933 DenseThreeDimensionalModel::Column values = m_model->getColumn(col); |
934 while (values.size() < m_model->getHeight()) values.push_back(0.f); | 934 while (values.size() < m_model->getHeight()) values.push_back(0.f); |
935 if (!m_normalizeColumns && !m_normalizeHybrid) return values; | 935 if (!m_normalizeColumns && !m_normalizeHybrid) return values; |
936 | 936 |
937 float colMax = 0.f, colMin = 0.f; | 937 double colMax = 0.f, colMin = 0.f; |
938 float min = 0.f, max = 0.f; | 938 double min = 0.f, max = 0.f; |
939 | 939 |
940 min = m_model->getMinimumLevel(); | 940 min = m_model->getMinimumLevel(); |
941 max = m_model->getMaximumLevel(); | 941 max = m_model->getMaximumLevel(); |
942 | 942 |
943 for (int y = 0; y < values.size(); ++y) { | 943 for (int y = 0; y < values.size(); ++y) { |
946 } | 946 } |
947 if (colMin == colMax) colMax = colMin + 1; | 947 if (colMin == colMax) colMax = colMin + 1; |
948 | 948 |
949 for (int y = 0; y < values.size(); ++y) { | 949 for (int y = 0; y < values.size(); ++y) { |
950 | 950 |
951 float value = values.at(y); | 951 double value = values.at(y); |
952 float norm = (value - colMin) / (colMax - colMin); | 952 double norm = (value - colMin) / (colMax - colMin); |
953 float newvalue = min + (max - min) * norm; | 953 double newvalue = min + (max - min) * norm; |
954 | 954 |
955 if (value != newvalue) values[y] = newvalue; | 955 if (value != newvalue) values[y] = float(newvalue); |
956 } | 956 } |
957 | 957 |
958 if (m_normalizeHybrid && (colMax > 0.0)) { | 958 if (m_normalizeHybrid && (colMax > 0.0)) { |
959 float logmax = log10f(colMax); | 959 double logmax = log10(colMax); |
960 for (int y = 0; y < values.size(); ++y) { | 960 for (int y = 0; y < values.size(); ++y) { |
961 values[y] *= logmax; | 961 values[y] = float(values[y] * logmax); |
962 } | 962 } |
963 } | 963 } |
964 | 964 |
965 return values; | 965 return values; |
966 } | 966 } |
1083 cerr << "Cache size " << cacheWidth << "x" << cacheHeight << " will be valid from " << m_cacheValidStart << " to " << m_cacheValidEnd << " (fillStart = " << fillStart << ", fillEnd = " << fillEnd << ")" << endl; | 1083 cerr << "Cache size " << cacheWidth << "x" << cacheHeight << " will be valid from " << m_cacheValidStart << " to " << m_cacheValidEnd << " (fillStart = " << fillStart << ", fillEnd = " << fillEnd << ")" << endl; |
1084 #endif | 1084 #endif |
1085 | 1085 |
1086 DenseThreeDimensionalModel::Column values; | 1086 DenseThreeDimensionalModel::Column values; |
1087 | 1087 |
1088 float min = m_model->getMinimumLevel(); | 1088 double min = m_model->getMinimumLevel(); |
1089 float max = m_model->getMaximumLevel(); | 1089 double max = m_model->getMaximumLevel(); |
1090 | 1090 |
1091 if (m_colourScale == LogScale) { | 1091 if (m_colourScale == LogScale) { |
1092 LogRange::mapRange(min, max); | 1092 LogRange::mapRange(min, max); |
1093 } else if (m_colourScale == PlusMinusOneScale) { | 1093 } else if (m_colourScale == PlusMinusOneScale) { |
1094 min = -1.f; | 1094 min = -1.f; |
1095 max = 1.f; | 1095 max = 1.f; |
1096 } else if (m_colourScale == AbsoluteScale) { | 1096 } else if (m_colourScale == AbsoluteScale) { |
1097 if (min < 0) { | 1097 if (min < 0) { |
1098 if (fabsf(min) > fabsf(max)) max = fabsf(min); | 1098 if (fabs(min) > fabs(max)) max = fabs(min); |
1099 else max = fabsf(max); | 1099 else max = fabs(max); |
1100 min = 0; | 1100 min = 0; |
1101 } else { | 1101 } else { |
1102 min = fabsf(min); | 1102 min = fabs(min); |
1103 max = fabsf(max); | 1103 max = fabs(max); |
1104 } | 1104 } |
1105 } | 1105 } |
1106 | 1106 |
1107 if (max == min) max = min + 1.f; | 1107 if (max == min) max = min + 1.f; |
1108 | 1108 |
1116 m_peaksCache->setColor | 1116 m_peaksCache->setColor |
1117 (index, qRgb(colour.red(), colour.green(), colour.blue())); | 1117 (index, qRgb(colour.red(), colour.green(), colour.blue())); |
1118 } | 1118 } |
1119 } | 1119 } |
1120 | 1120 |
1121 float visibleMax = 0.f, visibleMin = 0.f; | 1121 double visibleMax = 0.f, visibleMin = 0.f; |
1122 | 1122 |
1123 if (normalizeVisible) { | 1123 if (normalizeVisible) { |
1124 | 1124 |
1125 for (int c = fillStart; c <= fillEnd; ++c) { | 1125 for (int c = fillStart; c <= fillEnd; ++c) { |
1126 | 1126 |
1127 values = getColumn(c); | 1127 values = getColumn(c); |
1128 | 1128 |
1129 float colMax = 0.f, colMin = 0.f; | 1129 double colMax = 0.f, colMin = 0.f; |
1130 | 1130 |
1131 for (int y = 0; y < cacheHeight; ++y) { | 1131 for (int y = 0; y < cacheHeight; ++y) { |
1132 if (y >= values.size()) break; | 1132 if (y >= values.size()) break; |
1133 if (y == 0 || values[y] > colMax) colMax = values[y]; | 1133 if (y == 0 || values[y] > colMax) colMax = values[y]; |
1134 if (y == 0 || values[y] < colMin) colMin = values[y]; | 1134 if (y == 0 || values[y] < colMin) colMin = values[y]; |
1142 visibleMin = LogRange::map(visibleMin); | 1142 visibleMin = LogRange::map(visibleMin); |
1143 visibleMax = LogRange::map(visibleMax); | 1143 visibleMax = LogRange::map(visibleMax); |
1144 if (visibleMin > visibleMax) std::swap(visibleMin, visibleMax); | 1144 if (visibleMin > visibleMax) std::swap(visibleMin, visibleMax); |
1145 } else if (m_colourScale == AbsoluteScale) { | 1145 } else if (m_colourScale == AbsoluteScale) { |
1146 if (visibleMin < 0) { | 1146 if (visibleMin < 0) { |
1147 if (fabsf(visibleMin) > fabsf(visibleMax)) visibleMax = fabsf(visibleMin); | 1147 if (fabs(visibleMin) > fabs(visibleMax)) visibleMax = fabs(visibleMin); |
1148 else visibleMax = fabsf(visibleMax); | 1148 else visibleMax = fabs(visibleMax); |
1149 visibleMin = 0; | 1149 visibleMin = 0; |
1150 } else { | 1150 } else { |
1151 visibleMin = fabsf(visibleMin); | 1151 visibleMin = fabs(visibleMin); |
1152 visibleMax = fabsf(visibleMax); | 1152 visibleMax = fabs(visibleMax); |
1153 } | 1153 } |
1154 } | 1154 } |
1155 } | 1155 } |
1156 | 1156 |
1157 if (visibleMin == visibleMax) visibleMax = visibleMin + 1; | 1157 if (visibleMin == visibleMax) visibleMax = visibleMin + 1; |
1176 continue; | 1176 continue; |
1177 } | 1177 } |
1178 | 1178 |
1179 for (int y = 0; y < cacheHeight; ++y) { | 1179 for (int y = 0; y < cacheHeight; ++y) { |
1180 | 1180 |
1181 float value = min; | 1181 double value = min; |
1182 if (y < values.size()) { | 1182 if (y < values.size()) { |
1183 value = values.at(y); | 1183 value = values.at(y); |
1184 } | 1184 } |
1185 | 1185 |
1186 value = value * m_gain; | 1186 value = value * m_gain; |
1187 | 1187 |
1188 if (m_colourScale == LogScale) { | 1188 if (m_colourScale == LogScale) { |
1189 value = LogRange::map(value); | 1189 value = LogRange::map(value); |
1190 } else if (m_colourScale == AbsoluteScale) { | 1190 } else if (m_colourScale == AbsoluteScale) { |
1191 value = fabsf(value); | 1191 value = fabs(value); |
1192 } | 1192 } |
1193 | 1193 |
1194 if (normalizeVisible) { | 1194 if (normalizeVisible) { |
1195 float norm = (value - visibleMin) / (visibleMax - visibleMin); | 1195 double norm = (value - visibleMin) / (visibleMax - visibleMin); |
1196 value = min + (max - min) * norm; | 1196 value = min + (max - min) * norm; |
1197 } | 1197 } |
1198 | 1198 |
1199 int pixel = int(((value - min) * 256) / (max - min)); | 1199 int pixel = int(((value - min) * 256) / (max - min)); |
1200 if (pixel < 0) pixel = 0; | 1200 if (pixel < 0) pixel = 0; |
1408 paint.drawRect(r); | 1408 paint.drawRect(r); |
1409 | 1409 |
1410 if (showLabel) { | 1410 if (showLabel) { |
1411 if (sx >= 0 && sx < m_cache->width() && | 1411 if (sx >= 0 && sx < m_cache->width() && |
1412 sy >= 0 && sy < m_cache->height()) { | 1412 sy >= 0 && sy < m_cache->height()) { |
1413 float value = m_model->getValueAt(sx, sy); | 1413 double value = m_model->getValueAt(sx, sy); |
1414 snprintf(labelbuf, buflen, "%06f", value); | 1414 snprintf(labelbuf, buflen, "%06f", value); |
1415 QString text(labelbuf); | 1415 QString text(labelbuf); |
1416 paint.setPen(v->getBackground()); | 1416 paint.setPen(v->getBackground()); |
1417 paint.drawText(rx0 + 2, | 1417 paint.drawText(rx0 + 2, |
1418 ry0 - h / sh - 1 + 2 + paint.fontMetrics().ascent(), | 1418 ry0 - h / sh - 1 + 2 + paint.fontMetrics().ascent(), |
1507 | 1507 |
1508 sxa[x*2] = sx0; | 1508 sxa[x*2] = sx0; |
1509 sxa[x*2 + 1] = sx1; | 1509 sxa[x*2 + 1] = sx1; |
1510 } | 1510 } |
1511 | 1511 |
1512 float logmin = float(symin+1), logmax = float(symax+1); | 1512 double logmin = symin+1, logmax = symax+1; |
1513 LogRange::mapRange(logmin, logmax); | 1513 LogRange::mapRange(logmin, logmax); |
1514 | 1514 |
1515 #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT | 1515 #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT |
1516 cerr << "m_smooth = " << m_smooth << ", w = " << w << ", h = " << h << endl; | 1516 cerr << "m_smooth = " << m_smooth << ", w = " << w << ", h = " << h << endl; |
1517 #endif | 1517 #endif |
1518 | 1518 |
1519 if (m_smooth) { | 1519 if (m_smooth) { |
1520 | 1520 |
1521 for (int y = 0; y < h; ++y) { | 1521 for (int y = 0; y < h; ++y) { |
1522 | 1522 |
1523 double sy = getBinForY(v, float(y)) - 0.5; | 1523 double sy = getBinForY(v, y) - 0.5; |
1524 int syi = int(sy + epsilon); | 1524 int syi = int(sy + epsilon); |
1525 if (syi < 0 || syi >= source->height()) continue; | 1525 if (syi < 0 || syi >= source->height()) continue; |
1526 | 1526 |
1527 uchar *targetLine = img.scanLine(y); | 1527 uchar *targetLine = img.scanLine(y); |
1528 uchar *sourceLine = source->scanLine(syi); | 1528 uchar *sourceLine = source->scanLine(syi); |
1588 targetLine[x] = uchar(vi); | 1588 targetLine[x] = uchar(vi); |
1589 } | 1589 } |
1590 } | 1590 } |
1591 } else { | 1591 } else { |
1592 | 1592 |
1593 float sy0 = getBinForY(v, 0); | 1593 double sy0 = getBinForY(v, 0); |
1594 | 1594 |
1595 int psy0i = -1, psy1i = -1; | 1595 int psy0i = -1, psy1i = -1; |
1596 | 1596 |
1597 for (int y = 0; y < h; ++y) { | 1597 for (int y = 0; y < h; ++y) { |
1598 | 1598 |
1599 float sy1 = sy0; | 1599 double sy1 = sy0; |
1600 sy0 = getBinForY(v, float(y + 1)); | 1600 sy0 = getBinForY(v, double(y + 1)); |
1601 | 1601 |
1602 int sy0i = int(sy0 + epsilon); | 1602 int sy0i = int(sy0 + epsilon); |
1603 int sy1i = int(sy1); | 1603 int sy1i = int(sy1); |
1604 | 1604 |
1605 uchar *targetLine = img.scanLine(y); | 1605 uchar *targetLine = img.scanLine(y); |
1653 | 1653 |
1654 paint.drawImage(x0, 0, img); | 1654 paint.drawImage(x0, 0, img); |
1655 } | 1655 } |
1656 | 1656 |
1657 bool | 1657 bool |
1658 Colour3DPlotLayer::snapToFeatureFrame(View *v, int &frame, | 1658 Colour3DPlotLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, |
1659 int &resolution, | 1659 int &resolution, |
1660 SnapType snap) const | 1660 SnapType snap) const |
1661 { | 1661 { |
1662 if (!m_model) { | 1662 if (!m_model) { |
1663 return Layer::snapToFeatureFrame(v, frame, resolution, snap); | 1663 return Layer::snapToFeatureFrame(v, frame, resolution, snap); |
1664 } | 1664 } |
1665 | 1665 |
1666 resolution = m_model->getResolution(); | 1666 resolution = m_model->getResolution(); |
1667 int left = (frame / resolution) * resolution; | 1667 sv_frame_t left = (frame / resolution) * resolution; |
1668 int right = left + resolution; | 1668 sv_frame_t right = left + resolution; |
1669 | 1669 |
1670 switch (snap) { | 1670 switch (snap) { |
1671 case SnapLeft: frame = left; break; | 1671 case SnapLeft: frame = left; break; |
1672 case SnapRight: frame = right; break; | 1672 case SnapRight: frame = right; break; |
1673 case SnapNearest: | 1673 case SnapNearest: |