Mercurial > hg > svgui
comparison layer/Colour3DPlotLayer.cpp @ 130:10eec0da9efe last-cc-copyright
* Move the current DenseThreeDimensionalModel to EditableDenseThreeDimensionalModel
(wow!), and make DTDM an abstract base
* Move FFTFuzzyAdapter to FFTModel as a new subclass of DTDM
author | Chris Cannam |
---|---|
date | Mon, 31 Jul 2006 17:05:18 +0000 |
parents | 33929e0c3c6b |
children | c1fb771b7646 |
comparison
equal
deleted
inserted
replaced
129:26d9d65e4941 | 130:10eec0da9efe |
---|---|
88 | 88 |
89 int x = pos.x(); | 89 int x = pos.x(); |
90 int y = pos.y(); | 90 int y = pos.y(); |
91 | 91 |
92 size_t modelStart = m_model->getStartFrame(); | 92 size_t modelStart = m_model->getStartFrame(); |
93 size_t modelWindow = m_model->getWindowSize(); | 93 size_t modelResolution = m_model->getResolution(); |
94 | 94 |
95 int sx0 = modelWindow * | 95 int sx0 = modelResolution * |
96 int((v->getFrameForX(x) - long(modelStart)) / long(modelWindow)); | 96 int((v->getFrameForX(x) - long(modelStart)) / long(modelResolution)); |
97 int sx1 = sx0 + modelWindow; | 97 int sx1 = sx0 + modelResolution; |
98 | 98 |
99 float binHeight = float(v->height()) / m_model->getYBinCount(); | 99 float binHeight = float(v->height()) / m_model->getYBinCount(); |
100 int sy = (v->height() - y) / binHeight; | 100 int sy = (v->height() - y) / binHeight; |
101 | 101 |
102 float value = m_model->getBinValue(sx0, sy); | 102 float value = m_model->getBinValue(sx0, sy); |
196 return; | 196 return; |
197 } | 197 } |
198 | 198 |
199 size_t modelStart = m_model->getStartFrame(); | 199 size_t modelStart = m_model->getStartFrame(); |
200 size_t modelEnd = m_model->getEndFrame(); | 200 size_t modelEnd = m_model->getEndFrame(); |
201 size_t modelWindow = m_model->getWindowSize(); | 201 size_t modelResolution = m_model->getResolution(); |
202 | 202 |
203 size_t cacheWidth = (modelEnd - modelStart) / modelWindow + 1; | 203 size_t cacheWidth = (modelEnd - modelStart) / modelResolution + 1; |
204 size_t cacheHeight = m_model->getYBinCount(); | 204 size_t cacheHeight = m_model->getYBinCount(); |
205 | 205 |
206 if (m_cache && | 206 if (m_cache && |
207 (m_cache->width() != cacheWidth || | 207 (m_cache->width() != cacheWidth || |
208 m_cache->height() != cacheHeight)) { | 208 m_cache->height() != cacheHeight)) { |
229 m_cache->setColor(value, qRgba(colour.red(), colour.green(), colour.blue(), 80)); | 229 m_cache->setColor(value, qRgba(colour.red(), colour.green(), colour.blue(), 80)); |
230 } | 230 } |
231 | 231 |
232 m_cache->fill(min); | 232 m_cache->fill(min); |
233 | 233 |
234 for (size_t f = modelStart; f <= modelEnd; f += modelWindow) { | 234 for (size_t f = modelStart; f <= modelEnd; f += modelResolution) { |
235 | 235 |
236 values.clear(); | 236 values.clear(); |
237 m_model->getBinValues(f, values); | 237 m_model->getBinValues(f, values); |
238 | 238 |
239 for (size_t y = 0; y < m_model->getYBinCount(); ++y) { | 239 for (size_t y = 0; y < m_model->getYBinCount(); ++y) { |
243 | 243 |
244 int pixel = int(((value - min) * 256) / (max - min)); | 244 int pixel = int(((value - min) * 256) / (max - min)); |
245 if (pixel < 0) pixel = 0; | 245 if (pixel < 0) pixel = 0; |
246 if (pixel > 255) pixel = 255; | 246 if (pixel > 255) pixel = 255; |
247 | 247 |
248 m_cache->setPixel(f / modelWindow, y, pixel); | 248 m_cache->setPixel(f / modelResolution, y, pixel); |
249 } | 249 } |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 if (m_model->getYBinCount() >= v->height()) { | 253 if (m_model->getYBinCount() >= v->height()) { |
269 //!!! Strictly speaking we want quite different paint mechanisms | 269 //!!! Strictly speaking we want quite different paint mechanisms |
270 //for models that have more than one bin per pixel in either | 270 //for models that have more than one bin per pixel in either |
271 //direction. This one is only really appropriate for models with | 271 //direction. This one is only really appropriate for models with |
272 //far fewer bins in both directions. | 272 //far fewer bins in both directions. |
273 | 273 |
274 int sx0 = int((v->getFrameForX(x0) - long(modelStart)) / long(modelWindow)); | 274 int sx0 = int((v->getFrameForX(x0) - long(modelStart)) / long(modelResolution)); |
275 int sx1 = int((v->getFrameForX(x1) - long(modelStart)) / long(modelWindow)); | 275 int sx1 = int((v->getFrameForX(x1) - long(modelStart)) / long(modelResolution)); |
276 int sw = sx1 - sx0; | 276 int sw = sx1 - sx0; |
277 int sh = m_model->getYBinCount(); | 277 int sh = m_model->getYBinCount(); |
278 | 278 |
279 #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT | 279 #ifdef DEBUG_COLOUR_3D_PLOT_LAYER_PAINT |
280 std::cerr << "Colour3DPlotLayer::paint: w " << w << ", h " << h << ", sx0 " << sx0 << ", sx1 " << sx1 << ", sw " << sw << ", sh " << sh << std::endl; | 280 std::cerr << "Colour3DPlotLayer::paint: w " << w << ", h " << h << ", sx0 " << sx0 << ", sx1 " << sx1 << ", sw " << sw << ", sh " << sh << std::endl; |
281 std::cerr << "Colour3DPlotLayer: sample rate is " << m_model->getSampleRate() << ", window size " << m_model->getWindowSize() << std::endl; | 281 std::cerr << "Colour3DPlotLayer: sample rate is " << m_model->getSampleRate() << ", resolution " << m_model->getResolution() << std::endl; |
282 #endif | 282 #endif |
283 | 283 |
284 QPoint illuminatePos; | 284 QPoint illuminatePos; |
285 bool illuminate = v->shouldIlluminateLocalFeatures(this, illuminatePos); | 285 bool illuminate = v->shouldIlluminateLocalFeatures(this, illuminatePos); |
286 char labelbuf[10]; | 286 char labelbuf[10]; |
287 | 287 |
288 for (int sx = sx0 - 1; sx <= sx1; ++sx) { | 288 for (int sx = sx0 - 1; sx <= sx1; ++sx) { |
289 | 289 |
290 int fx = sx * int(modelWindow); | 290 int fx = sx * int(modelResolution); |
291 | 291 |
292 if (fx + modelWindow < int(modelStart) || | 292 if (fx + modelResolution < int(modelStart) || |
293 fx > int(modelEnd)) continue; | 293 fx > int(modelEnd)) continue; |
294 | 294 |
295 int rx0 = v->getXForFrame(fx + int(modelStart)); | 295 int rx0 = v->getXForFrame(fx + int(modelStart)); |
296 int rx1 = v->getXForFrame(fx + int(modelStart) + int(modelWindow)); | 296 int rx1 = v->getXForFrame(fx + int(modelStart) + int(modelResolution)); |
297 | 297 |
298 int w = rx1 - rx0; | 298 int w = rx1 - rx0; |
299 if (w < 1) w = 1; | 299 if (w < 1) w = 1; |
300 | 300 |
301 bool showLabel = (w > 10 && | 301 bool showLabel = (w > 10 && |
354 long startFrame = v->getStartFrame(); | 354 long startFrame = v->getStartFrame(); |
355 int zoomLevel = v->getZoomLevel(); | 355 int zoomLevel = v->getZoomLevel(); |
356 | 356 |
357 size_t modelStart = m_model->getStartFrame(); | 357 size_t modelStart = m_model->getStartFrame(); |
358 size_t modelEnd = m_model->getEndFrame(); | 358 size_t modelEnd = m_model->getEndFrame(); |
359 size_t modelWindow = m_model->getWindowSize(); | 359 size_t modelResolution = m_model->getResolution(); |
360 | 360 |
361 int x0 = rect.left(); | 361 int x0 = rect.left(); |
362 int x1 = rect.right() + 1; | 362 int x1 = rect.right() + 1; |
363 | 363 |
364 int w = x1 - x0; | 364 int w = x1 - x0; |
375 img.setPixel(x - x0, y, m_cache->color(0)); | 375 img.setPixel(x - x0, y, m_cache->color(0)); |
376 } | 376 } |
377 continue; | 377 continue; |
378 } | 378 } |
379 | 379 |
380 float sx0 = (float(xf) - modelStart) / modelWindow; | 380 float sx0 = (float(xf) - modelStart) / modelResolution; |
381 float sx1 = (float(v->getFrameForX(x+1)) - modelStart) / modelWindow; | 381 float sx1 = (float(v->getFrameForX(x+1)) - modelStart) / modelResolution; |
382 | 382 |
383 int sx0i = int(sx0 + 0.001); | 383 int sx0i = int(sx0 + 0.001); |
384 int sx1i = int(sx1); | 384 int sx1i = int(sx1); |
385 | 385 |
386 for (int y = 0; y < h; ++y) { | 386 for (int y = 0; y < h; ++y) { |
430 { | 430 { |
431 if (!m_model) { | 431 if (!m_model) { |
432 return Layer::snapToFeatureFrame(v, frame, resolution, snap); | 432 return Layer::snapToFeatureFrame(v, frame, resolution, snap); |
433 } | 433 } |
434 | 434 |
435 resolution = m_model->getWindowSize(); | 435 resolution = m_model->getResolution(); |
436 int left = (frame / resolution) * resolution; | 436 int left = (frame / resolution) * resolution; |
437 int right = left + resolution; | 437 int right = left + resolution; |
438 | 438 |
439 switch (snap) { | 439 switch (snap) { |
440 case SnapLeft: frame = left; break; | 440 case SnapLeft: frame = left; break; |