comparison widgets/Pane.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 38fe0ea9e46e
children 10ba9276a315
comparison
equal deleted inserted replaced
27:38fe0ea9e46e 28:202d1dca67d2
38 } 38 }
39 39
40 bool 40 bool
41 Pane::shouldIlluminateLocalFeatures(const Layer *layer, QPoint &pos) 41 Pane::shouldIlluminateLocalFeatures(const Layer *layer, QPoint &pos)
42 { 42 {
43 /*!!!
44 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
45 --vi;
46 if (layer != *vi) return false;
47 pos = m_identifyPoint;
48 return m_identifyFeatures;
49 }
50 */
51 if (layer == getSelectedLayer()) { 43 if (layer == getSelectedLayer()) {
52 pos = m_identifyPoint; 44 pos = m_identifyPoint;
53 return m_identifyFeatures; 45 return m_identifyFeatures;
54 } 46 }
55 47
350 size_t resolution = 1; 342 size_t resolution = 1;
351 int snapFrame = mouseFrame; 343 int snapFrame = mouseFrame;
352 344
353 Layer *layer = getSelectedLayer(); 345 Layer *layer = getSelectedLayer();
354 if (layer) { 346 if (layer) {
355 snapFrame = layer->getNearestFeatureFrame(mouseFrame, resolution, 347 layer->snapToFeatureFrame(snapFrame, resolution, Layer::SnapLeft);
356 false);
357 } 348 }
358 349
359 if (snapFrame < 0) snapFrame = 0; 350 if (snapFrame < 0) snapFrame = 0;
360 m_selectionStartFrame = snapFrame; 351 m_selectionStartFrame = snapFrame;
361 if (m_manager) { 352 if (m_manager) {
483 void 474 void
484 Pane::mouseMoveEvent(QMouseEvent *e) 475 Pane::mouseMoveEvent(QMouseEvent *e)
485 { 476 {
486 ViewManager::ToolMode mode = ViewManager::NavigateMode; 477 ViewManager::ToolMode mode = ViewManager::NavigateMode;
487 if (m_manager) mode = m_manager->getToolMode(); 478 if (m_manager) mode = m_manager->getToolMode();
479
480 QPoint prevPoint = m_identifyPoint;
481 m_identifyPoint = e->pos();
488 482
489 if (!m_clickedInRange) { 483 if (!m_clickedInRange) {
490 484
491 if (mode == ViewManager::SelectMode) { 485 if (mode == ViewManager::SelectMode) {
492 bool closeToLeft = false, closeToRight = false; 486 bool closeToLeft = false, closeToRight = false;
499 } 493 }
500 494
501 if (mode != ViewManager::DrawMode) { 495 if (mode != ViewManager::DrawMode) {
502 496
503 bool previouslyIdentifying = m_identifyFeatures; 497 bool previouslyIdentifying = m_identifyFeatures;
504 QPoint prevPoint = m_identifyPoint;
505
506 m_identifyFeatures = true; 498 m_identifyFeatures = true;
507 m_identifyPoint = e->pos();
508 499
509 if (m_identifyFeatures != previouslyIdentifying || 500 if (m_identifyFeatures != previouslyIdentifying ||
510 m_identifyPoint != prevPoint) { 501 m_identifyPoint != prevPoint) {
511 update(); 502 update();
512 } 503 }
553 int snapFrameLeft = mouseFrame; 544 int snapFrameLeft = mouseFrame;
554 int snapFrameRight = mouseFrame; 545 int snapFrameRight = mouseFrame;
555 546
556 Layer *layer = getSelectedLayer(); 547 Layer *layer = getSelectedLayer();
557 if (layer) { 548 if (layer) {
558 snapFrameLeft = layer->getNearestFeatureFrame(mouseFrame, resolution, 549 layer->snapToFeatureFrame(snapFrameLeft, resolution, Layer::SnapLeft);
559 false); 550 layer->snapToFeatureFrame(snapFrameRight, resolution, Layer::SnapRight);
560 snapFrameRight = layer->getNearestFeatureFrame(mouseFrame, resolution, 551 }
561 true); 552
562 } 553 std::cerr << "snap: frame = " << mouseFrame << ", start frame = " << m_selectionStartFrame << ", left = " << snapFrameLeft << ", right = " << snapFrameRight << std::endl;
563 554
564 if (snapFrameLeft < 0) snapFrameLeft = 0; 555 if (snapFrameLeft < 0) snapFrameLeft = 0;
565 if (snapFrameRight < 0) snapFrameRight = 0; 556 if (snapFrameRight < 0) snapFrameRight = 0;
566 557
567 size_t min, max; 558 size_t min, max;
568 559