comparison layer/TextLayer.cpp @ 1423:62e908518c71 single-point

Update to Event api in place of Clipboard points
author Chris Cannam
date Fri, 08 Mar 2019 13:37:30 +0000
parents c8a6fd3f9dff
children e2b6a13a1f69
comparison
equal deleted inserted replaced
1422:6f51297a0250 1423:62e908518c71
707 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); 707 m_model->getPoints(s.getStartFrame(), s.getEndFrame());
708 708
709 for (TextModel::PointList::iterator i = points.begin(); 709 for (TextModel::PointList::iterator i = points.begin();
710 i != points.end(); ++i) { 710 i != points.end(); ++i) {
711 if (s.contains(i->frame)) { 711 if (s.contains(i->frame)) {
712 Clipboard::Point point(i->frame, i->height, i->label); 712 Event point(i->frame, i->height, i->label);
713 point.setReferenceFrame(alignToReference(v, i->frame)); 713 to.addPoint(point.withReferenceFrame(alignToReference(v, i->frame)));
714 to.addPoint(point);
715 } 714 }
716 } 715 }
717 } 716 }
718 717
719 bool 718 bool
720 TextLayer::paste(LayerGeometryProvider *v, const Clipboard &from, sv_frame_t /* frameOffset */, bool /* interactive */) 719 TextLayer::paste(LayerGeometryProvider *v, const Clipboard &from, sv_frame_t /* frameOffset */, bool /* interactive */)
721 { 720 {
722 if (!m_model) return false; 721 if (!m_model) return false;
723 722
724 const Clipboard::PointList &points = from.getPoints(); 723 const EventVector &points = from.getPoints();
725 724
726 bool realign = false; 725 bool realign = false;
727 726
728 if (clipboardHasDifferentAlignment(v, from)) { 727 if (clipboardHasDifferentAlignment(v, from)) {
729 728
744 743
745 TextModel::EditCommand *command = 744 TextModel::EditCommand *command =
746 new TextModel::EditCommand(m_model, tr("Paste")); 745 new TextModel::EditCommand(m_model, tr("Paste"));
747 746
748 double valueMin = 0.0, valueMax = 1.0; 747 double valueMin = 0.0, valueMax = 1.0;
749 for (Clipboard::PointList::const_iterator i = points.begin(); 748 for (EventVector::const_iterator i = points.begin();
750 i != points.end(); ++i) { 749 i != points.end(); ++i) {
751 if (i->haveValue()) { 750 if (i->hasValue()) {
752 if (i->getValue() < valueMin) valueMin = i->getValue(); 751 if (i->getValue() < valueMin) valueMin = i->getValue();
753 if (i->getValue() > valueMax) valueMax = i->getValue(); 752 if (i->getValue() > valueMax) valueMax = i->getValue();
754 } 753 }
755 } 754 }
756 if (valueMax < valueMin + 1.0) valueMax = valueMin + 1.0; 755 if (valueMax < valueMin + 1.0) valueMax = valueMin + 1.0;
757 756
758 for (Clipboard::PointList::const_iterator i = points.begin(); 757 for (EventVector::const_iterator i = points.begin();
759 i != points.end(); ++i) { 758 i != points.end(); ++i) {
760 759
761 if (!i->haveFrame()) continue;
762 sv_frame_t frame = 0; 760 sv_frame_t frame = 0;
763 761
764 if (!realign) { 762 if (!realign) {
765 763
766 frame = i->getFrame(); 764 frame = i->getFrame();
767 765
768 } else { 766 } else {
769 767
770 if (i->haveReferenceFrame()) { 768 if (i->hasReferenceFrame()) {
771 frame = i->getReferenceFrame(); 769 frame = i->getReferenceFrame();
772 frame = alignFromReference(v, frame); 770 frame = alignFromReference(v, frame);
773 } else { 771 } else {
774 frame = i->getFrame(); 772 frame = i->getFrame();
775 } 773 }
776 } 774 }
777 775
778 TextModel::Point newPoint(frame); 776 TextModel::Point newPoint(frame);
779 777
780 if (i->haveValue()) { 778 if (i->hasValue()) {
781 newPoint.height = float((i->getValue() - valueMin) / (valueMax - valueMin)); 779 newPoint.height = float((i->getValue() - valueMin) / (valueMax - valueMin));
782 } else { 780 } else {
783 newPoint.height = 0.5f; 781 newPoint.height = 0.5f;
784 } 782 }
785 783
786 if (i->haveLabel()) { 784 if (i->hasLabel()) {
787 newPoint.label = i->getLabel(); 785 newPoint.label = i->getLabel();
788 } else if (i->haveValue()) { 786 } else if (i->hasValue()) {
789 newPoint.label = QString("%1").arg(i->getValue()); 787 newPoint.label = QString("%1").arg(i->getValue());
790 } else { 788 } else {
791 newPoint.label = tr("New Point"); 789 newPoint.label = tr("New Point");
792 } 790 }
793 791