comparison layer/Colour3DPlotLayer.cpp @ 1045:f535f6e5dbb0 alignment-simple

Merge in from SV 3.0-integration branches
author Chris Cannam
date Wed, 02 Mar 2016 17:25:27 +0000
parents 25ec2390fad3
children 40480e4bab6a
comparison
equal deleted inserted replaced
976:f2c63ec85901 1045:f535f6e5dbb0
23 23
24 #include <QPainter> 24 #include <QPainter>
25 #include <QImage> 25 #include <QImage>
26 #include <QRect> 26 #include <QRect>
27 #include <QTextStream> 27 #include <QTextStream>
28 #include <QSettings>
28 29
29 #include <iostream> 30 #include <iostream>
30 31
31 #include <cassert> 32 #include <cassert>
32 33
52 m_binScale(LinearBinScale), 53 m_binScale(LinearBinScale),
53 m_normalizeColumns(false), 54 m_normalizeColumns(false),
54 m_normalizeVisibleArea(false), 55 m_normalizeVisibleArea(false),
55 m_normalizeHybrid(false), 56 m_normalizeHybrid(false),
56 m_invertVertical(false), 57 m_invertVertical(false),
57 m_rectified(false),
58 m_opaque(false), 58 m_opaque(false),
59 m_smooth(false), 59 m_smooth(false),
60 m_peakResolution(256), 60 m_peakResolution(256),
61 m_miny(0), 61 m_miny(0),
62 m_maxy(0) 62 m_maxy(0)
63 { 63 {
64 64 QSettings settings;
65 settings.beginGroup("Preferences");
66 setColourMap(settings.value("colour-3d-plot-colour", ColourMapper::Green).toInt());
67 settings.endGroup();
65 } 68 }
66 69
67 Colour3DPlotLayer::~Colour3DPlotLayer() 70 Colour3DPlotLayer::~Colour3DPlotLayer()
68 { 71 {
69 delete m_cache; 72 delete m_cache;
161 list.push_back("Normalize Columns"); 164 list.push_back("Normalize Columns");
162 list.push_back("Normalize Visible Area"); 165 list.push_back("Normalize Visible Area");
163 list.push_back("Gain"); 166 list.push_back("Gain");
164 list.push_back("Bin Scale"); 167 list.push_back("Bin Scale");
165 list.push_back("Invert Vertical Scale"); 168 list.push_back("Invert Vertical Scale");
166 list.push_back("Show Rectified");
167 list.push_back("Opaque"); 169 list.push_back("Opaque");
168 list.push_back("Smooth"); 170 list.push_back("Smooth");
169 return list; 171 return list;
170 } 172 }
171 173
175 if (name == "Colour") return tr("Colour"); 177 if (name == "Colour") return tr("Colour");
176 if (name == "Colour Scale") return tr("Scale"); 178 if (name == "Colour Scale") return tr("Scale");
177 if (name == "Normalize Columns") return tr("Normalize Columns"); 179 if (name == "Normalize Columns") return tr("Normalize Columns");
178 if (name == "Normalize Visible Area") return tr("Normalize Visible Area"); 180 if (name == "Normalize Visible Area") return tr("Normalize Visible Area");
179 if (name == "Invert Vertical Scale") return tr("Invert Vertical Scale"); 181 if (name == "Invert Vertical Scale") return tr("Invert Vertical Scale");
180 if (name == "Show Rectified") return tr("Half-Wave Rectify");
181 if (name == "Gain") return tr("Gain"); 182 if (name == "Gain") return tr("Gain");
182 if (name == "Opaque") return tr("Always Opaque"); 183 if (name == "Opaque") return tr("Always Opaque");
183 if (name == "Smooth") return tr("Smooth"); 184 if (name == "Smooth") return tr("Smooth");
184 if (name == "Bin Scale") return tr("Bin Scale"); 185 if (name == "Bin Scale") return tr("Bin Scale");
185 return ""; 186 return "";
189 Colour3DPlotLayer::getPropertyIconName(const PropertyName &name) const 190 Colour3DPlotLayer::getPropertyIconName(const PropertyName &name) const
190 { 191 {
191 if (name == "Normalize Columns") return "normalise-columns"; 192 if (name == "Normalize Columns") return "normalise-columns";
192 if (name == "Normalize Visible Area") return "normalise"; 193 if (name == "Normalize Visible Area") return "normalise";
193 if (name == "Invert Vertical Scale") return "invert-vertical"; 194 if (name == "Invert Vertical Scale") return "invert-vertical";
194 if (name == "Show Rectified") return "derivative";
195 if (name == "Opaque") return "opaque"; 195 if (name == "Opaque") return "opaque";
196 if (name == "Smooth") return "smooth"; 196 if (name == "Smooth") return "smooth";
197 return ""; 197 return "";
198 } 198 }
199 199
202 { 202 {
203 if (name == "Gain") return RangeProperty; 203 if (name == "Gain") return RangeProperty;
204 if (name == "Normalize Columns") return ToggleProperty; 204 if (name == "Normalize Columns") return ToggleProperty;
205 if (name == "Normalize Visible Area") return ToggleProperty; 205 if (name == "Normalize Visible Area") return ToggleProperty;
206 if (name == "Invert Vertical Scale") return ToggleProperty; 206 if (name == "Invert Vertical Scale") return ToggleProperty;
207 if (name == "Show Rectified") return ToggleProperty;
208 if (name == "Opaque") return ToggleProperty; 207 if (name == "Opaque") return ToggleProperty;
209 if (name == "Smooth") return ToggleProperty; 208 if (name == "Smooth") return ToggleProperty;
210 return ValueProperty; 209 return ValueProperty;
211 } 210 }
212 211
214 Colour3DPlotLayer::getPropertyGroupName(const PropertyName &name) const 213 Colour3DPlotLayer::getPropertyGroupName(const PropertyName &name) const
215 { 214 {
216 if (name == "Normalize Columns" || 215 if (name == "Normalize Columns" ||
217 name == "Normalize Visible Area" || 216 name == "Normalize Visible Area" ||
218 name == "Colour Scale" || 217 name == "Colour Scale" ||
219 name == "Show Rectified" ||
220 name == "Gain") return tr("Scale"); 218 name == "Gain") return tr("Scale");
221 if (name == "Bin Scale" || 219 if (name == "Bin Scale" ||
222 name == "Invert Vertical Scale") return tr("Bins"); 220 name == "Invert Vertical Scale") return tr("Bins");
223 if (name == "Opaque" || 221 if (name == "Opaque" ||
224 name == "Smooth" || 222 name == "Smooth" ||
278 276
279 } else if (name == "Invert Vertical Scale") { 277 } else if (name == "Invert Vertical Scale") {
280 278
281 *deflt = 0; 279 *deflt = 0;
282 val = (m_invertVertical ? 1 : 0); 280 val = (m_invertVertical ? 1 : 0);
283
284 } else if (name == "Show Rectified") {
285
286 if (min) *min = 0;
287 if (max) *max = 0;
288 if (deflt) *deflt = 0;
289 val = (m_rectified ? 1.0 : 0.0);
290 281
291 } else if (name == "Bin Scale") { 282 } else if (name == "Bin Scale") {
292 283
293 *min = 0; 284 *min = 0;
294 *max = 1; 285 *max = 1;
366 setNormalizeColumns(value ? true : false); 357 setNormalizeColumns(value ? true : false);
367 } else if (name == "Normalize Visible Area") { 358 } else if (name == "Normalize Visible Area") {
368 setNormalizeVisibleArea(value ? true : false); 359 setNormalizeVisibleArea(value ? true : false);
369 } else if (name == "Invert Vertical Scale") { 360 } else if (name == "Invert Vertical Scale") {
370 setInvertVertical(value ? true : false); 361 setInvertVertical(value ? true : false);
371 } else if (name == "Show Rectified") {
372 setShowRectified(value > 0.5);
373 } else if (name == "Opaque") { 362 } else if (name == "Opaque") {
374 setOpaque(value ? true : false); 363 setOpaque(value ? true : false);
375 } else if (name == "Smooth") { 364 } else if (name == "Smooth") {
376 setSmooth(value ? true : false); 365 setSmooth(value ? true : false);
377 } else if (name == "Bin Scale") { 366 } else if (name == "Bin Scale") {
485 cacheInvalid(); 474 cacheInvalid();
486 emit layerParametersChanged(); 475 emit layerParametersChanged();
487 } 476 }
488 477
489 void 478 void
490 Colour3DPlotLayer::setShowRectified(bool show)
491 {
492 if (m_rectified == show) return;
493 m_rectified = show;
494 cacheInvalid();
495 emit layerParametersChanged();
496 }
497
498 void
499 Colour3DPlotLayer::setOpaque(bool n) 479 Colour3DPlotLayer::setOpaque(bool n)
500 { 480 {
501 if (m_opaque == n) return; 481 if (m_opaque == n) return;
502 m_opaque = n; 482 m_opaque = n;
503 emit layerParametersChanged(); 483 emit layerParametersChanged();
528 { 508 {
529 return m_smooth; 509 return m_smooth;
530 } 510 }
531 511
532 void 512 void
533 Colour3DPlotLayer::setLayerDormant(const View *v, bool dormant) 513 Colour3DPlotLayer::setLayerDormant(const LayerGeometryProvider *v, bool dormant)
534 { 514 {
535 if (dormant) { 515 if (dormant) {
536 516
537 #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT 517 #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT
538 cerr << "Colour3DPlotLayer::setLayerDormant(" << dormant << ")" 518 cerr << "Colour3DPlotLayer::setLayerDormant(" << dormant << ")"
552 Layer::setLayerDormant(v, false); 532 Layer::setLayerDormant(v, false);
553 } 533 }
554 } 534 }
555 535
556 bool 536 bool
557 Colour3DPlotLayer::isLayerScrollable(const View *v) const 537 Colour3DPlotLayer::isLayerScrollable(const LayerGeometryProvider *v) const
558 { 538 {
559 if (m_normalizeVisibleArea) { 539 if (m_normalizeVisibleArea) {
560 return false; 540 return false;
561 } 541 }
562 if (shouldPaintDenseIn(v)) { 542 if (shouldPaintDenseIn(v)) {
611 emit layerParametersChanged(); 591 emit layerParametersChanged();
612 return true; 592 return true;
613 } 593 }
614 594
615 bool 595 bool
616 Colour3DPlotLayer::getYScaleValue(const View *, int, 596 Colour3DPlotLayer::getYScaleValue(const LayerGeometryProvider *, int,
617 double &, QString &) const 597 double &, QString &) const
618 { 598 {
619 return false;//!!! 599 return false;//!!!
620 } 600 }
621 601
667 return new LinearRangeMapper(0, m_model->getHeight(), 647 return new LinearRangeMapper(0, m_model->getHeight(),
668 0, m_model->getHeight(), ""); 648 0, m_model->getHeight(), "");
669 } 649 }
670 650
671 double 651 double
672 Colour3DPlotLayer::getYForBin(View *v, double bin) const 652 Colour3DPlotLayer::getYForBin(LayerGeometryProvider *v, double bin) const
673 { 653 {
674 double y = bin; 654 double y = bin;
675 if (!m_model) return y; 655 if (!m_model) return y;
676 double mn = 0, mx = m_model->getHeight(); 656 double mn = 0, mx = m_model->getHeight();
677 getDisplayExtents(mn, mx); 657 getDisplayExtents(mn, mx);
678 double h = v->height(); 658 double h = v->getPaintHeight();
679 if (m_binScale == LinearBinScale) { 659 if (m_binScale == LinearBinScale) {
680 y = h - (((bin - mn) * h) / (mx - mn)); 660 y = h - (((bin - mn) * h) / (mx - mn));
681 } else { 661 } else {
682 double logmin = mn + 1, logmax = mx + 1; 662 double logmin = mn + 1, logmax = mx + 1;
683 LogRange::mapRange(logmin, logmax); 663 LogRange::mapRange(logmin, logmax);
685 } 665 }
686 return y; 666 return y;
687 } 667 }
688 668
689 int 669 int
690 Colour3DPlotLayer::getIYForBin(View *v, int bin) const 670 Colour3DPlotLayer::getIYForBin(LayerGeometryProvider *v, int bin) const
691 { 671 {
692 return int(round(getYForBin(v, bin))); 672 return int(round(getYForBin(v, bin)));
693 } 673 }
694 674
695 double 675 double
696 Colour3DPlotLayer::getBinForY(View *v, double y) const 676 Colour3DPlotLayer::getBinForY(LayerGeometryProvider *v, double y) const
697 { 677 {
698 double bin = y; 678 double bin = y;
699 if (!m_model) return bin; 679 if (!m_model) return bin;
700 double mn = 0, mx = m_model->getHeight(); 680 double mn = 0, mx = m_model->getHeight();
701 getDisplayExtents(mn, mx); 681 getDisplayExtents(mn, mx);
702 double h = v->height(); 682 double h = v->getPaintHeight();
703 if (m_binScale == LinearBinScale) { 683 if (m_binScale == LinearBinScale) {
704 bin = mn + ((h - y) * (mx - mn)) / h; 684 bin = mn + ((h - y) * (mx - mn)) / h;
705 } else { 685 } else {
706 double logmin = mn + 1, logmax = mx + 1; 686 double logmin = mn + 1, logmax = mx + 1;
707 LogRange::mapRange(logmin, logmax); 687 LogRange::mapRange(logmin, logmax);
709 } 689 }
710 return bin; 690 return bin;
711 } 691 }
712 692
713 int 693 int
714 Colour3DPlotLayer::getIBinForY(View *v, int y) const 694 Colour3DPlotLayer::getIBinForY(LayerGeometryProvider *v, int y) const
715 { 695 {
716 return int(floor(getBinForY(v, y))); 696 return int(floor(getBinForY(v, y)));
717 } 697 }
718 698
719 QString 699 QString
720 Colour3DPlotLayer::getFeatureDescription(View *v, QPoint &pos) const 700 Colour3DPlotLayer::getFeatureDescription(LayerGeometryProvider *v, QPoint &pos) const
721 { 701 {
722 if (!m_model) return ""; 702 if (!m_model) return "";
723 703
724 int x = pos.x(); 704 int x = pos.x();
725 int y = pos.y(); 705 int y = pos.y();
746 symax = sh; 726 symax = sh;
747 } 727 }
748 if (symin < 0) symin = 0; 728 if (symin < 0) symin = 0;
749 if (symax > sh) symax = sh; 729 if (symax > sh) symax = sh;
750 730
751 // double binHeight = double(v->height()) / (symax - symin); 731 // double binHeight = double(v->getPaintHeight()) / (symax - symin);
752 // int sy = int((v->height() - y) / binHeight) + symin; 732 // int sy = int((v->getPaintHeight() - y) / binHeight) + symin;
753 733
754 int sy = getIBinForY(v, y); 734 int sy = getIBinForY(v, y);
755 735
756 if (sy < 0 || sy >= m_model->getHeight()) { 736 if (sy < 0 || sy >= m_model->getHeight()) {
757 return ""; 737 return "";
777 757
778 return text; 758 return text;
779 } 759 }
780 760
781 int 761 int
782 Colour3DPlotLayer::getColourScaleWidth(QPainter &) const 762 Colour3DPlotLayer::getColourScaleWidth(QPainter &p) const
783 { 763 {
784 int cw = 20; 764 // Font is rotated
765 int cw = p.fontMetrics().height();
785 return cw; 766 return cw;
786 } 767 }
787 768
788 int 769 int
789 Colour3DPlotLayer::getVerticalScaleWidth(View *, bool, QPainter &paint) const 770 Colour3DPlotLayer::getVerticalScaleWidth(LayerGeometryProvider *, bool, QPainter &paint) const
790 { 771 {
791 if (!m_model) return 0; 772 if (!m_model) return 0;
792 773
793 QString sampleText = QString("[%1]").arg(m_model->getHeight()); 774 QString sampleText = QString("[%1]").arg(m_model->getHeight());
794 int tw = paint.fontMetrics().width(sampleText); 775 int tw = paint.fontMetrics().width(sampleText);
806 787
807 return tw + 13 + getColourScaleWidth(paint); 788 return tw + 13 + getColourScaleWidth(paint);
808 } 789 }
809 790
810 void 791 void
811 Colour3DPlotLayer::paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const 792 Colour3DPlotLayer::paintVerticalScale(LayerGeometryProvider *v, bool, QPainter &paint, QRect rect) const
812 { 793 {
813 if (!m_model) return; 794 if (!m_model) return;
814 795
815 int h = rect.height(), w = rect.width(); 796 int h = rect.height(), w = rect.width();
816 797
866 QString maxstr = QString("%1").arg(max); 847 QString maxstr = QString("%1").arg(max);
867 848
868 paint.save(); 849 paint.save();
869 850
870 QFont font = paint.font(); 851 QFont font = paint.font();
871 font.setPixelSize(10); 852 font.setPixelSize(int(font.pixelSize() * 0.65));
872 paint.setFont(font); 853 paint.setFont(font);
873 854
874 int msw = paint.fontMetrics().width(maxstr); 855 int msw = paint.fontMetrics().width(maxstr);
875 856
876 QMatrix m; 857 QMatrix m;
904 885
905 paint.save(); 886 paint.save();
906 887
907 int py = h; 888 int py = h;
908 889
890 int defaultFontHeight = paint.fontMetrics().height();
891
909 for (int i = symin; i <= symax; ++i) { 892 for (int i = symin; i <= symax; ++i) {
910 893
911 int y0; 894 int y0;
912 895
913 y0 = getIYForBin(v, i); 896 y0 = getIYForBin(v, i);
914 int h = py - y0; 897 int h = py - y0;
915 898
916 if (i > symin) { 899 if (i > symin) {
917 if (paint.fontMetrics().height() >= h) { 900 if (paint.fontMetrics().height() >= h) {
918 if (h >= 8) { 901 if (h >= defaultFontHeight * 0.8) {
919 QFont tf = paint.font(); 902 QFont tf = paint.font();
920 tf.setPixelSize(h-2); 903 tf.setPixelSize(int(h * 0.8));
921 paint.setFont(tf); 904 paint.setFont(tf);
922 } else { 905 } else {
923 continue; 906 continue;
924 } 907 }
925 } 908 }
952 DenseThreeDimensionalModel::Column 935 DenseThreeDimensionalModel::Column
953 Colour3DPlotLayer::getColumn(int col) const 936 Colour3DPlotLayer::getColumn(int col) const
954 { 937 {
955 Profiler profiler("Colour3DPlotLayer::getColumn"); 938 Profiler profiler("Colour3DPlotLayer::getColumn");
956 939
957 DenseThreeDimensionalModel::Column prev;
958 if (m_rectified && (col > m_model->getStartFrame())) {
959 prev = m_model->getColumn(col - 1);
960 }
961
962 DenseThreeDimensionalModel::Column values = m_model->getColumn(col); 940 DenseThreeDimensionalModel::Column values = m_model->getColumn(col);
963 941 values.resize(m_model->getHeight(), 0.f);
964 if (m_rectified && !prev.empty()) {
965 for (int y = 0; y < values.size(); ++y) {
966 if (values[y] < prev[y]) values[y] = 0;
967 else values[y] -= prev[y];
968 }
969 }
970
971 while (values.size() < m_model->getHeight()) values.push_back(0.f);
972 if (!m_normalizeColumns && !m_normalizeHybrid) return values; 942 if (!m_normalizeColumns && !m_normalizeHybrid) return values;
973 943
974 double colMax = 0.f, colMin = 0.f; 944 double colMax = 0.f, colMin = 0.f;
975 double min = 0.f, max = 0.f; 945 double min = 0.f, max = 0.f;
976 946
947 int nv = int(values.size());
948
977 min = m_model->getMinimumLevel(); 949 min = m_model->getMinimumLevel();
978 max = m_model->getMaximumLevel(); 950 max = m_model->getMaximumLevel();
979 951
980 for (int y = 0; y < values.size(); ++y) { 952 for (int y = 0; y < nv; ++y) {
981 if (y == 0 || values.at(y) > colMax) colMax = values.at(y); 953 if (y == 0 || values.at(y) > colMax) colMax = values.at(y);
982 if (y == 0 || values.at(y) < colMin) colMin = values.at(y); 954 if (y == 0 || values.at(y) < colMin) colMin = values.at(y);
983 } 955 }
984 if (colMin == colMax) colMax = colMin + 1; 956 if (colMin == colMax) colMax = colMin + 1;
985 957
986 for (int y = 0; y < values.size(); ++y) { 958 for (int y = 0; y < nv; ++y) {
987 959
988 double value = values.at(y); 960 double value = values.at(y);
989 double norm = (value - colMin) / (colMax - colMin); 961 double norm = (value - colMin) / (colMax - colMin);
990 double newvalue = min + (max - min) * norm; 962 double newvalue = min + (max - min) * norm;
991 963
992 if (value != newvalue) values[y] = float(newvalue); 964 if (value != newvalue) values[y] = float(newvalue);
993 } 965 }
994 966
995 if (m_normalizeHybrid && (colMax > 0.0)) { 967 if (m_normalizeHybrid && (colMax > 0.0)) {
996 double logmax = log10(colMax); 968 double logmax = log10(colMax);
997 for (int y = 0; y < values.size(); ++y) { 969 for (int y = 0; y < nv; ++y) {
998 values[y] = float(values[y] * logmax); 970 values[y] = float(values[y] * logmax);
999 } 971 }
1000 } 972 }
1001 973
1002 return values; 974 return values;
1164 values = getColumn(c); 1136 values = getColumn(c);
1165 1137
1166 double colMax = 0.f, colMin = 0.f; 1138 double colMax = 0.f, colMin = 0.f;
1167 1139
1168 for (int y = 0; y < cacheHeight; ++y) { 1140 for (int y = 0; y < cacheHeight; ++y) {
1169 if (y >= values.size()) break; 1141 if (!in_range_for(values, y)) break;
1170 if (y == 0 || values[y] > colMax) colMax = values[y]; 1142 if (y == 0 || values[y] > colMax) colMax = values[y];
1171 if (y == 0 || values[y] < colMin) colMin = values[y]; 1143 if (y == 0 || values[y] < colMin) colMin = values[y];
1172 } 1144 }
1173 1145
1174 if (c == fillStart || colMax > visibleMax) visibleMax = colMax; 1146 if (c == fillStart || colMax > visibleMax) visibleMax = colMax;
1214 } 1186 }
1215 1187
1216 for (int y = 0; y < cacheHeight; ++y) { 1188 for (int y = 0; y < cacheHeight; ++y) {
1217 1189
1218 double value = min; 1190 double value = min;
1219 if (y < values.size()) { 1191 if (in_range_for(values, y)) {
1220 value = values.at(y); 1192 value = values.at(y);
1221 } 1193 }
1222 1194
1223 value = value * m_gain; 1195 value = value * m_gain;
1224 1196
1281 1253
1282 delete[] peaks; 1254 delete[] peaks;
1283 } 1255 }
1284 1256
1285 bool 1257 bool
1286 Colour3DPlotLayer::shouldPaintDenseIn(const View *v) const 1258 Colour3DPlotLayer::shouldPaintDenseIn(const LayerGeometryProvider *v) const
1287 { 1259 {
1288 if (!m_model || !v || !(v->getViewManager())) { 1260 if (!m_model || !v || !(v->getViewManager())) {
1289 return false; 1261 return false;
1290 } 1262 }
1291 double srRatio = 1263 double srRatio =
1292 v->getViewManager()->getMainModelSampleRate() / m_model->getSampleRate(); 1264 v->getViewManager()->getMainModelSampleRate() / m_model->getSampleRate();
1293 if (m_opaque || 1265 if (m_opaque ||
1294 m_smooth || 1266 m_smooth ||
1295 m_model->getHeight() >= v->height() || 1267 m_model->getHeight() >= v->getPaintHeight() ||
1296 ((m_model->getResolution() * srRatio) / v->getZoomLevel()) < 2) { 1268 ((m_model->getResolution() * srRatio) / v->getZoomLevel()) < 2) {
1297 return true; 1269 return true;
1298 } 1270 }
1299 return false; 1271 return false;
1300 } 1272 }
1301 1273
1302 void 1274 void
1303 Colour3DPlotLayer::paint(View *v, QPainter &paint, QRect rect) const 1275 Colour3DPlotLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const
1304 { 1276 {
1305 /* 1277 /*
1306 if (m_model) { 1278 if (m_model) {
1307 SVDEBUG << "Colour3DPlotLayer::paint: model says shouldUseLogValueScale = " << m_model->shouldUseLogValueScale() << endl; 1279 SVDEBUG << "Colour3DPlotLayer::paint: model says shouldUseLogValueScale = " << m_model->shouldUseLogValueScale() << endl;
1308 } 1280 }
1313 #endif 1285 #endif
1314 1286
1315 int completion = 0; 1287 int completion = 0;
1316 if (!m_model || !m_model->isOK() || !m_model->isReady(&completion)) { 1288 if (!m_model || !m_model->isOK() || !m_model->isReady(&completion)) {
1317 if (completion > 0) { 1289 if (completion > 0) {
1318 paint.fillRect(0, 10, v->width() * completion / 100, 1290 paint.fillRect(0, 10, v->getPaintWidth() * completion / 100,
1319 10, QColor(120, 120, 120)); 1291 10, QColor(120, 120, 120));
1320 } 1292 }
1321 return; 1293 return;
1322 } 1294 }
1323 1295
1324 if (m_normalizeVisibleArea && !m_normalizeColumns) rect = v->rect(); 1296 if (m_normalizeVisibleArea && !m_normalizeColumns) rect = v->getPaintRect();
1325 1297
1326 sv_frame_t modelStart = m_model->getStartFrame(); 1298 sv_frame_t modelStart = m_model->getStartFrame();
1327 sv_frame_t modelEnd = m_model->getEndFrame(); 1299 sv_frame_t modelEnd = m_model->getEndFrame();
1328 int modelResolution = m_model->getResolution(); 1300 int modelResolution = m_model->getResolution();
1329 1301
1337 // "small". This is "large"; see paintDense below for "small". 1309 // "small". This is "large"; see paintDense below for "small".
1338 1310
1339 int x0 = rect.left(); 1311 int x0 = rect.left();
1340 int x1 = rect.right() + 1; 1312 int x1 = rect.right() + 1;
1341 1313
1342 int h = v->height(); 1314 int h = v->getPaintHeight();
1343 1315
1344 double srRatio = 1316 double srRatio =
1345 v->getViewManager()->getMainModelSampleRate() / m_model->getSampleRate(); 1317 v->getViewManager()->getMainModelSampleRate() / m_model->getSampleRate();
1346 1318
1347 int sx0 = int((double(v->getFrameForX(x0)) / srRatio - double(modelStart)) 1319 int sx0 = int((double(v->getFrameForX(x0)) / srRatio - double(modelStart))
1459 } 1431 }
1460 } 1432 }
1461 } 1433 }
1462 1434
1463 void 1435 void
1464 Colour3DPlotLayer::paintDense(View *v, QPainter &paint, QRect rect) const 1436 Colour3DPlotLayer::paintDense(LayerGeometryProvider *v, QPainter &paint, QRect rect) const
1465 { 1437 {
1466 Profiler profiler("Colour3DPlotLayer::paintDense", true); 1438 Profiler profiler("Colour3DPlotLayer::paintDense", true);
1467 if (!m_cache) return; 1439 if (!m_cache) return;
1468 1440
1469 double modelStart = double(m_model->getStartFrame()); 1441 double modelStart = double(m_model->getStartFrame());
1475 1447
1476 int x0 = rect.left(); 1448 int x0 = rect.left();
1477 int x1 = rect.right() + 1; 1449 int x1 = rect.right() + 1;
1478 1450
1479 const int w = x1 - x0; // const so it can be used as array size below 1451 const int w = x1 - x0; // const so it can be used as array size below
1480 int h = v->height(); // we always paint full height 1452 int h = v->getPaintHeight(); // we always paint full height
1481 int sh = m_model->getHeight(); 1453 int sh = m_model->getHeight();
1482 1454
1483 int symin = m_miny; 1455 int symin = m_miny;
1484 int symax = m_maxy; 1456 int symax = m_maxy;
1485 if (symax <= symin) { 1457 if (symax <= symin) {
1690 1662
1691 paint.drawImage(x0, 0, img); 1663 paint.drawImage(x0, 0, img);
1692 } 1664 }
1693 1665
1694 bool 1666 bool
1695 Colour3DPlotLayer::snapToFeatureFrame(View *v, sv_frame_t &frame, 1667 Colour3DPlotLayer::snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame,
1696 int &resolution, 1668 int &resolution,
1697 SnapType snap) const 1669 SnapType snap) const
1698 { 1670 {
1699 if (!m_model) { 1671 if (!m_model) {
1700 return Layer::snapToFeatureFrame(v, frame, resolution, snap); 1672 return Layer::snapToFeatureFrame(v, frame, resolution, snap);