comparison layer/TimeInstantLayer.cpp @ 335:2f83b6e3b8ca

* Add Erase tool and mode * Add icons for Normalize buttons in property boxes, and for Show Peaks * Add support for velocity in notes -- not yet reflected in display or editable in the note edit dialog, but they are imported from MIDI, played, and exported * Begin work on making pastes align pasted times (subtler than I thought)
author Chris Cannam
date Fri, 23 Nov 2007 16:48:23 +0000
parents 984c1975f1ff
children bff85425228c 0895517bb2d1
comparison
equal deleted inserted replaced
334:0a74248af622 335:2f83b6e3b8ca
491 m_editingCommand = 0; 491 m_editingCommand = 0;
492 m_editing = false; 492 m_editing = false;
493 } 493 }
494 494
495 void 495 void
496 TimeInstantLayer::eraseStart(View *v, QMouseEvent *e)
497 {
498 if (!m_model) return;
499
500 SparseOneDimensionalModel::PointList points = getLocalPoints(v, e->x());
501 if (points.empty()) return;
502
503 m_editingPoint = *points.begin();
504
505 if (m_editingCommand) {
506 m_editingCommand->finish();
507 m_editingCommand = 0;
508 }
509
510 m_editing = true;
511 }
512
513 void
514 TimeInstantLayer::eraseDrag(View *v, QMouseEvent *e)
515 {
516 }
517
518 void
519 TimeInstantLayer::eraseEnd(View *v, QMouseEvent *e)
520 {
521 if (!m_model || !m_editing) return;
522
523 m_editing = false;
524
525 SparseOneDimensionalModel::PointList points = getLocalPoints(v, e->x());
526 if (points.empty()) return;
527 if (points.begin()->frame != m_editingPoint.frame) return;
528
529 m_editingCommand = new SparseOneDimensionalModel::EditCommand
530 (m_model, tr("Erase Point"));
531
532 m_editingCommand->deletePoint(m_editingPoint);
533
534 m_editingCommand->finish();
535 m_editingCommand = 0;
536 m_editing = false;
537 }
538
539 void
496 TimeInstantLayer::editStart(View *v, QMouseEvent *e) 540 TimeInstantLayer::editStart(View *v, QMouseEvent *e)
497 { 541 {
498 std::cerr << "TimeInstantLayer::editStart(" << e->x() << ")" << std::endl; 542 std::cerr << "TimeInstantLayer::editStart(" << e->x() << ")" << std::endl;
499 543
500 if (!m_model) return; 544 if (!m_model) return;
676 720
677 for (SparseOneDimensionalModel::PointList::iterator i = points.begin(); 721 for (SparseOneDimensionalModel::PointList::iterator i = points.begin();
678 i != points.end(); ++i) { 722 i != points.end(); ++i) {
679 if (s.contains(i->frame)) { 723 if (s.contains(i->frame)) {
680 Clipboard::Point point(i->frame, i->label); 724 Clipboard::Point point(i->frame, i->label);
725 point.setReferenceFrame(m_model->alignToReference(i->frame));
681 to.addPoint(point); 726 to.addPoint(point);
682 } 727 }
683 } 728 }
684 } 729 }
685 730
690 735
691 const Clipboard::PointList &points = from.getPoints(); 736 const Clipboard::PointList &points = from.getPoints();
692 737
693 SparseOneDimensionalModel::EditCommand *command = 738 SparseOneDimensionalModel::EditCommand *command =
694 new SparseOneDimensionalModel::EditCommand(m_model, tr("Paste")); 739 new SparseOneDimensionalModel::EditCommand(m_model, tr("Paste"));
740
741 //!!!
742
743 // Clipboard::haveReferenceFrames() will return true if any of the
744 // items in the clipboard came from an aligned, non-reference model.
745
746 // We need to know whether these points came from our model or not
747 // -- if they did, we don't want to align them.
748
749 // If they didn't come from our model, and if reference frames are
750 // available, then we want to offer to align them. If reference
751 // frames are unavailable but they came from the reference model,
752 // we want to offer to align them too.
695 753
696 for (Clipboard::PointList::const_iterator i = points.begin(); 754 for (Clipboard::PointList::const_iterator i = points.begin();
697 i != points.end(); ++i) { 755 i != points.end(); ++i) {
698 756
699 if (!i->haveFrame()) continue; 757 if (!i->haveFrame()) continue;