comparison layer/Colour3DPlotLayer.cpp @ 28:202d1dca67d2

* Rationalise the local feature identification API in Layer subclasses * Add segmentation mode to TimeInstantLayer
author Chris Cannam
date Mon, 06 Feb 2006 17:24:52 +0000
parents 94381052a6c9
children ad214997dddb
comparison
equal deleted inserted replaced
27:38fe0ea9e46e 28:202d1dca67d2
372 372
373 paint.drawImage(x0, 0, scaled); 373 paint.drawImage(x0, 0, scaled);
374 */ 374 */
375 } 375 }
376 376
377 int 377 bool
378 Colour3DPlotLayer::getNearestFeatureFrame(int frame, 378 Colour3DPlotLayer::snapToFeatureFrame(int &frame,
379 size_t &resolution, 379 size_t &resolution,
380 bool snapRight) const 380 SnapType snap) const
381 { 381 {
382 if (!m_model) { 382 if (!m_model) {
383 return Layer::getNearestFeatureFrame(frame, resolution, snapRight); 383 return Layer::snapToFeatureFrame(frame, resolution, snap);
384 } 384 }
385 385
386 resolution = m_model->getWindowSize(); 386 resolution = m_model->getWindowSize();
387 int left = (frame / resolution) * resolution;
388 int right = left + resolution;
389
390 switch (snap) {
391 case SnapLeft: frame = left; break;
392 case SnapRight: frame = right; break;
393 case SnapNearest:
394 case SnapNeighbouring:
395 if (frame - left > right - frame) frame = right;
396 else frame = left;
397 break;
398 }
387 399
388 int returnFrame = (frame / resolution) * resolution; 400 return true;
389 if (snapRight) returnFrame += resolution;
390
391 return returnFrame;
392 } 401 }
393 402
394 #ifdef INCLUDE_MOCFILES 403 #ifdef INCLUDE_MOCFILES
395 #include "Colour3DPlotLayer.moc.cpp" 404 #include "Colour3DPlotLayer.moc.cpp"
396 #endif 405 #endif