Mercurial > hg > svgui
comparison layer/Colour3DPlotLayer.cpp @ 472:13e8edbffbd7
* Try out a smooth-scaling paint method... not especially promising
author | Chris Cannam |
---|---|
date | Mon, 26 Jan 2009 16:54:44 +0000 |
parents | 72a080272a4e |
children | efc2bd6d3611 |
comparison
equal
deleted
inserted
replaced
471:72a080272a4e | 472:13e8edbffbd7 |
---|---|
1196 delete[] peaks; | 1196 delete[] peaks; |
1197 | 1197 |
1198 paint.drawImage(x0, 0, img); | 1198 paint.drawImage(x0, 0, img); |
1199 } | 1199 } |
1200 | 1200 |
1201 void | |
1202 Colour3DPlotLayer::paintSmooth(View *v, QPainter &paint, QRect rect) const | |
1203 { | |
1204 Profiler profiler("Colour3DPlotLayer:paintSmooth"); | |
1205 if (!m_cache) return; | |
1206 | |
1207 float modelStart = m_model->getStartFrame(); | |
1208 float modelResolution = m_model->getResolution(); | |
1209 | |
1210 int mmsr = v->getViewManager()->getMainModelSampleRate(); | |
1211 int msr = m_model->getSampleRate(); | |
1212 float srRatio = float(mmsr) / float(msr); | |
1213 | |
1214 int x0 = rect.left(); | |
1215 int x1 = rect.right() + 1; | |
1216 | |
1217 int h = v->height(); // we always paint full height | |
1218 int sh = m_model->getHeight(); | |
1219 | |
1220 int symin = m_miny; | |
1221 int symax = m_maxy; | |
1222 if (symax <= symin) { | |
1223 symin = 0; | |
1224 symax = sh; | |
1225 } | |
1226 if (symin < 0) symin = 0; | |
1227 if (symax > sh) symax = sh; | |
1228 | |
1229 // QImage img(w, h, QImage::Format_Indexed8); | |
1230 // img.setColorTable(m_cache->colorTable()); | |
1231 | |
1232 int zoomLevel = v->getZoomLevel(); | |
1233 | |
1234 QImage *source = m_cache; | |
1235 if (m_peaksCache && | |
1236 ((modelResolution * srRatio * m_peakResolution) / zoomLevel) < 1) { | |
1237 std::cerr << "using peaks cache" << std::endl; | |
1238 source = m_peaksCache; | |
1239 modelResolution *= m_peakResolution; | |
1240 } else { | |
1241 std::cerr << "not using peaks cache" << std::endl; | |
1242 } | |
1243 | |
1244 float sx0 = (float(v->getFrameForX(x0)) / srRatio - modelStart) / modelResolution; | |
1245 float sx1 = (float(v->getFrameForX(x1)) / srRatio - modelStart) / modelResolution; | |
1246 int sx0i = int(sx0 + 0.001); | |
1247 int sx1i = int(sx1); | |
1248 | |
1249 if (sx0i < 0) sx0i = 0; | |
1250 if (sx0i > source->width()) sx0i = source->width(); | |
1251 | |
1252 int tx0 = v->getXForFrame(((sx0i * modelResolution) + modelStart) * srRatio + 0.001); | |
1253 int tx1 = v->getXForFrame(((sx1i * modelResolution) + modelStart) * srRatio); | |
1254 | |
1255 std::cerr << "x0 " << x0 << ", x1 " << x1 << " -> sx0 " << sx0i << ", sx1 " << sx1i << " -> tx0 " << tx0 << ", tx1 " << tx1 << std::endl; | |
1256 | |
1257 QImage img = source->copy(sx0i, 0, sx1i - sx0i, source->height()) | |
1258 .scaled(QSize(tx1 - tx0, h), | |
1259 Qt::IgnoreAspectRatio, Qt::SmoothTransformation); | |
1260 paint.drawImage(x0, 0, img); | |
1261 } | |
1262 | |
1201 bool | 1263 bool |
1202 Colour3DPlotLayer::snapToFeatureFrame(View *v, int &frame, | 1264 Colour3DPlotLayer::snapToFeatureFrame(View *v, int &frame, |
1203 size_t &resolution, | 1265 size_t &resolution, |
1204 SnapType snap) const | 1266 SnapType snap) const |
1205 { | 1267 { |