Mercurial > hg > svgui
comparison layer/Colour3DPlotLayer.cpp @ 772:986f1670a502 tonioni
Merge from default branch
author | Chris Cannam |
---|---|
date | Wed, 14 May 2014 09:58:16 +0100 |
parents | d7e8cefedbbc |
children | 1d526ba11a24 |
comparison
equal
deleted
inserted
replaced
764:6388ddae6ce3 | 772:986f1670a502 |
---|---|
577 | 577 |
578 emit layerParametersChanged(); | 578 emit layerParametersChanged(); |
579 return true; | 579 return true; |
580 } | 580 } |
581 | 581 |
582 bool | |
583 Colour3DPlotLayer::getYScaleValue(const View *v, int y, | |
584 float &value, QString &unit) const | |
585 { | |
586 return false;//!!! | |
587 } | |
588 | |
582 int | 589 int |
583 Colour3DPlotLayer::getVerticalZoomSteps(int &defaultStep) const | 590 Colour3DPlotLayer::getVerticalZoomSteps(int &defaultStep) const |
584 { | 591 { |
585 if (!m_model) return 0; | 592 if (!m_model) return 0; |
586 | 593 |
950 size_t cacheWidth = modelEndBin - modelStartBin + 1; | 957 size_t cacheWidth = modelEndBin - modelStartBin + 1; |
951 if (lastBin > modelEndBin) cacheWidth = lastBin - modelStartBin + 1; | 958 if (lastBin > modelEndBin) cacheWidth = lastBin - modelStartBin + 1; |
952 size_t cacheHeight = m_model->getHeight(); | 959 size_t cacheHeight = m_model->getHeight(); |
953 | 960 |
954 if (m_cache && (m_cache->height() != int(cacheHeight))) { | 961 if (m_cache && (m_cache->height() != int(cacheHeight))) { |
962 // height has changed: delete everything rather than resizing | |
955 delete m_cache; | 963 delete m_cache; |
956 delete m_peaksCache; | 964 delete m_peaksCache; |
957 m_cache = 0; | 965 m_cache = 0; |
958 m_peaksCache = 0; | 966 m_peaksCache = 0; |
959 } | 967 } |
960 | 968 |
961 if (m_cache && (m_cache->width() != int(cacheWidth))) { | 969 if (m_cache && (m_cache->width() != int(cacheWidth))) { |
970 // width has changed and we have an existing cache: resize it | |
962 QImage *newCache = | 971 QImage *newCache = |
963 new QImage(m_cache->copy(0, 0, cacheWidth, cacheHeight)); | 972 new QImage(m_cache->copy(0, 0, cacheWidth, cacheHeight)); |
964 delete m_cache; | 973 delete m_cache; |
965 m_cache = newCache; | 974 m_cache = newCache; |
966 if (m_peaksCache) { | 975 if (m_peaksCache) { |
967 QImage *newPeaksCache = | 976 QImage *newPeaksCache = |
968 new QImage(m_peaksCache->copy | 977 new QImage(m_peaksCache->copy |
969 (0, 0, cacheWidth / m_peakResolution, cacheHeight)); | 978 (0, 0, cacheWidth / m_peakResolution + 1, cacheHeight)); |
970 delete m_peaksCache; | 979 delete m_peaksCache; |
971 m_peaksCache = newPeaksCache; | 980 m_peaksCache = newPeaksCache; |
972 } | 981 } |
973 } | 982 } |
974 | 983 |
989 } | 998 } |
990 m_cacheValidStart = 0; | 999 m_cacheValidStart = 0; |
991 m_cacheValidEnd = 0; | 1000 m_cacheValidEnd = 0; |
992 } | 1001 } |
993 | 1002 |
1003 // cerr << "cache size = " << m_cache->width() << "x" << m_cache->height() | |
1004 // << " peaks cache size = " << m_peaksCache->width() << "x" << m_peaksCache->height() << endl; | |
1005 | |
994 if (m_cacheValidStart <= firstBin && m_cacheValidEnd >= lastBin) { | 1006 if (m_cacheValidStart <= firstBin && m_cacheValidEnd >= lastBin) { |
995 #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT | 1007 #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT |
996 cerr << "Cache is valid in this region already" << endl; | 1008 cerr << "Cache is valid in this region already" << endl; |
997 #endif | 1009 #endif |
998 return; | 1010 return; |
1115 | 1127 |
1116 for (size_t c = fillStart; c <= fillEnd; ++c) { | 1128 for (size_t c = fillStart; c <= fillEnd; ++c) { |
1117 | 1129 |
1118 values = getColumn(c); | 1130 values = getColumn(c); |
1119 | 1131 |
1132 if (c >= m_cache->width()) { | |
1133 cerr << "ERROR: column " << c << " >= cache width " | |
1134 << m_cache->width() << endl; | |
1135 continue; | |
1136 } | |
1137 | |
1120 for (size_t y = 0; y < cacheHeight; ++y) { | 1138 for (size_t y = 0; y < cacheHeight; ++y) { |
1121 | 1139 |
1122 float value = min; | 1140 float value = min; |
1123 if (y < values.size()) { | 1141 if (y < values.size()) { |
1124 value = values.at(y); | 1142 value = values.at(y); |
1143 if (peaks && (pixel > peaks[y])) peaks[y] = pixel; | 1161 if (peaks && (pixel > peaks[y])) peaks[y] = pixel; |
1144 | 1162 |
1145 if (m_invertVertical) { | 1163 if (m_invertVertical) { |
1146 m_cache->setPixel(c, cacheHeight - y - 1, pixel); | 1164 m_cache->setPixel(c, cacheHeight - y - 1, pixel); |
1147 } else { | 1165 } else { |
1148 m_cache->setPixel(c, y, pixel); | 1166 if (y >= m_cache->height()) { |
1167 cerr << "ERROR: row " << y << " >= cache height " << m_cache->height() << endl; | |
1168 } else { | |
1169 m_cache->setPixel(c, y, pixel); | |
1170 } | |
1149 } | 1171 } |
1150 } | 1172 } |
1151 | 1173 |
1152 if (peaks) { | 1174 if (peaks) { |
1153 size_t notch = (c % m_peakResolution); | 1175 size_t notch = (c % m_peakResolution); |
1154 if (notch == m_peakResolution-1 || c == fillEnd) { | 1176 if (notch == m_peakResolution-1 || c == fillEnd) { |
1155 size_t pc = c / m_peakResolution; | 1177 size_t pc = c / m_peakResolution; |
1178 if (pc >= m_peaksCache->width()) { | |
1179 cerr << "ERROR: peak column " << pc | |
1180 << " (from col " << c << ") >= peaks cache width " | |
1181 << m_peaksCache->width() << endl; | |
1182 continue; | |
1183 } | |
1156 for (size_t y = 0; y < cacheHeight; ++y) { | 1184 for (size_t y = 0; y < cacheHeight; ++y) { |
1157 if (m_invertVertical) { | 1185 if (m_invertVertical) { |
1158 m_peaksCache->setPixel(pc, cacheHeight - y - 1, peaks[y]); | 1186 m_peaksCache->setPixel(pc, cacheHeight - y - 1, peaks[y]); |
1159 } else { | 1187 } else { |
1160 m_peaksCache->setPixel(pc, y, peaks[y]); | 1188 if (y >= m_peaksCache->height()) { |
1189 cerr << "ERROR: row " << y | |
1190 << " >= peaks cache height " | |
1191 << m_peaksCache->height() << endl; | |
1192 } else { | |
1193 m_peaksCache->setPixel(pc, y, peaks[y]); | |
1194 } | |
1161 } | 1195 } |
1162 } | 1196 } |
1163 for (int y = 0; y < cacheHeight; ++y) { | 1197 for (int y = 0; y < cacheHeight; ++y) { |
1164 peaks[y] = 0; | 1198 peaks[y] = 0; |
1165 } | 1199 } |