comparison layer/TimeValueLayer.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 8a7c82282fbc
comparison
equal deleted inserted replaced
1422:6f51297a0250 1423:62e908518c71
1690 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); 1690 m_model->getPoints(s.getStartFrame(), s.getEndFrame());
1691 1691
1692 for (SparseTimeValueModel::PointList::iterator i = points.begin(); 1692 for (SparseTimeValueModel::PointList::iterator i = points.begin();
1693 i != points.end(); ++i) { 1693 i != points.end(); ++i) {
1694 if (s.contains(i->frame)) { 1694 if (s.contains(i->frame)) {
1695 Clipboard::Point point(i->frame, i->value, i->label); 1695 Event point(i->frame, i->value, i->label);
1696 point.setReferenceFrame(alignToReference(v, i->frame)); 1696 to.addPoint(point.withReferenceFrame(alignToReference(v, i->frame)));
1697 to.addPoint(point);
1698 } 1697 }
1699 } 1698 }
1700 } 1699 }
1701 1700
1702 bool 1701 bool
1703 TimeValueLayer::paste(LayerGeometryProvider *v, const Clipboard &from, sv_frame_t /* frameOffset */, 1702 TimeValueLayer::paste(LayerGeometryProvider *v, const Clipboard &from, sv_frame_t /* frameOffset */,
1704 bool interactive) 1703 bool interactive)
1705 { 1704 {
1706 if (!m_model) return false; 1705 if (!m_model) return false;
1707 1706
1708 const Clipboard::PointList &points = from.getPoints(); 1707 const EventVector &points = from.getPoints();
1709 1708
1710 bool realign = false; 1709 bool realign = false;
1711 1710
1712 if (clipboardHasDifferentAlignment(v, from)) { 1711 if (clipboardHasDifferentAlignment(v, from)) {
1713 1712
1744 1743
1745 if (interactive) { 1744 if (interactive) {
1746 1745
1747 ValueAvailability availability = UnknownAvailability; 1746 ValueAvailability availability = UnknownAvailability;
1748 1747
1749 for (Clipboard::PointList::const_iterator i = points.begin(); 1748 for (EventVector::const_iterator i = points.begin();
1750 i != points.end(); ++i) { 1749 i != points.end(); ++i) {
1751 1750
1752 if (!i->haveFrame()) continue;
1753
1754 if (availability == UnknownAvailability) { 1751 if (availability == UnknownAvailability) {
1755 if (i->haveValue()) availability = AllValues; 1752 if (i->hasValue()) availability = AllValues;
1756 else availability = NoValues; 1753 else availability = NoValues;
1757 continue; 1754 continue;
1758 } 1755 }
1759 1756
1760 if (i->haveValue()) { 1757 if (i->hasValue()) {
1761 if (availability == NoValues) { 1758 if (availability == NoValues) {
1762 availability = SomeValues; 1759 availability = SomeValues;
1763 } 1760 }
1764 } else { 1761 } else {
1765 if (availability == AllValues) { 1762 if (availability == AllValues) {
1766 availability = SomeValues; 1763 availability = SomeValues;
1767 } 1764 }
1768 } 1765 }
1769 1766
1770 if (!haveUsableLabels) { 1767 if (!haveUsableLabels) {
1771 if (i->haveLabel()) { 1768 if (i->hasLabel()) {
1772 if (i->getLabel().contains(QRegExp("[0-9]"))) { 1769 if (i->getLabel().contains(QRegExp("[0-9]"))) {
1773 haveUsableLabels = true; 1770 haveUsableLabels = true;
1774 } 1771 }
1775 } 1772 }
1776 } 1773 }
1836 } 1833 }
1837 } 1834 }
1838 1835
1839 SparseTimeValueModel::Point prevPoint(0); 1836 SparseTimeValueModel::Point prevPoint(0);
1840 1837
1841 for (Clipboard::PointList::const_iterator i = points.begin(); 1838 for (EventVector::const_iterator i = points.begin();
1842 i != points.end(); ++i) { 1839 i != points.end(); ++i) {
1843 1840
1844 if (!i->haveFrame()) continue;
1845
1846 sv_frame_t frame = 0; 1841 sv_frame_t frame = 0;
1847 1842
1848 if (!realign) { 1843 if (!realign) {
1849 1844
1850 frame = i->getFrame(); 1845 frame = i->getFrame();
1851 1846
1852 } else { 1847 } else {
1853 1848
1854 if (i->haveReferenceFrame()) { 1849 if (i->hasReferenceFrame()) {
1855 frame = i->getReferenceFrame(); 1850 frame = i->getReferenceFrame();
1856 frame = alignFromReference(v, frame); 1851 frame = alignFromReference(v, frame);
1857 } else { 1852 } else {
1858 frame = i->getFrame(); 1853 frame = i->getFrame();
1859 } 1854 }
1860 } 1855 }
1861 1856
1862 SparseTimeValueModel::Point newPoint(frame); 1857 SparseTimeValueModel::Point newPoint(frame);
1863 1858
1864 if (i->haveLabel()) { 1859 if (i->hasLabel()) {
1865 newPoint.label = i->getLabel(); 1860 newPoint.label = i->getLabel();
1866 } else if (i->haveValue()) { 1861 } else if (i->hasValue()) {
1867 newPoint.label = QString("%1").arg(i->getValue()); 1862 newPoint.label = QString("%1").arg(i->getValue());
1868 } 1863 }
1869 1864
1870 bool usePrev = false; 1865 bool usePrev = false;
1871 SparseTimeValueModel::Point formerPrevPoint = prevPoint; 1866 SparseTimeValueModel::Point formerPrevPoint = prevPoint;
1872 1867
1873 if (i->haveValue()) { 1868 if (i->hasValue()) {
1874 newPoint.value = i->getValue(); 1869 newPoint.value = i->getValue();
1875 } else { 1870 } else {
1876 #ifdef DEBUG_TIME_VALUE_LAYER 1871 #ifdef DEBUG_TIME_VALUE_LAYER
1877 cerr << "Setting value on point at " << newPoint.frame << " from labeller"; 1872 cerr << "Setting value on point at " << newPoint.frame << " from labeller";
1878 if (i == points.begin()) { 1873 if (i == points.begin()) {