Mercurial > hg > svgui
comparison layer/RegionLayer.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 | 2487521e857b |
children | c9fa16e41664 |
comparison
equal
deleted
inserted
replaced
1422:6f51297a0250 | 1423:62e908518c71 |
---|---|
1476 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); | 1476 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); |
1477 | 1477 |
1478 for (RegionModel::PointList::iterator i = points.begin(); | 1478 for (RegionModel::PointList::iterator i = points.begin(); |
1479 i != points.end(); ++i) { | 1479 i != points.end(); ++i) { |
1480 if (s.contains(i->frame)) { | 1480 if (s.contains(i->frame)) { |
1481 Clipboard::Point point(i->frame, i->value, i->duration, i->label); | 1481 Event point(i->frame, i->value, i->duration, i->label); |
1482 point.setReferenceFrame(alignToReference(v, i->frame)); | 1482 to.addPoint(point.withReferenceFrame(alignToReference(v, i->frame))); |
1483 to.addPoint(point); | |
1484 } | 1483 } |
1485 } | 1484 } |
1486 } | 1485 } |
1487 | 1486 |
1488 bool | 1487 bool |
1489 RegionLayer::paste(LayerGeometryProvider *v, const Clipboard &from, sv_frame_t /* frameOffset */, bool /* interactive */) | 1488 RegionLayer::paste(LayerGeometryProvider *v, const Clipboard &from, sv_frame_t /* frameOffset */, bool /* interactive */) |
1490 { | 1489 { |
1491 if (!m_model) return false; | 1490 if (!m_model) return false; |
1492 | 1491 |
1493 const Clipboard::PointList &points = from.getPoints(); | 1492 const EventVector &points = from.getPoints(); |
1494 | 1493 |
1495 bool realign = false; | 1494 bool realign = false; |
1496 | 1495 |
1497 if (clipboardHasDifferentAlignment(v, from)) { | 1496 if (clipboardHasDifferentAlignment(v, from)) { |
1498 | 1497 |
1512 } | 1511 } |
1513 | 1512 |
1514 RegionModel::EditCommand *command = | 1513 RegionModel::EditCommand *command = |
1515 new RegionModel::EditCommand(m_model, tr("Paste")); | 1514 new RegionModel::EditCommand(m_model, tr("Paste")); |
1516 | 1515 |
1517 for (Clipboard::PointList::const_iterator i = points.begin(); | 1516 for (EventVector::const_iterator i = points.begin(); |
1518 i != points.end(); ++i) { | 1517 i != points.end(); ++i) { |
1519 | 1518 |
1520 if (!i->haveFrame()) continue; | |
1521 sv_frame_t frame = 0; | 1519 sv_frame_t frame = 0; |
1522 | 1520 |
1523 if (!realign) { | 1521 if (!realign) { |
1524 | 1522 |
1525 frame = i->getFrame(); | 1523 frame = i->getFrame(); |
1526 | 1524 |
1527 } else { | 1525 } else { |
1528 | 1526 |
1529 if (i->haveReferenceFrame()) { | 1527 if (i->hasReferenceFrame()) { |
1530 frame = i->getReferenceFrame(); | 1528 frame = i->getReferenceFrame(); |
1531 frame = alignFromReference(v, frame); | 1529 frame = alignFromReference(v, frame); |
1532 } else { | 1530 } else { |
1533 frame = i->getFrame(); | 1531 frame = i->getFrame(); |
1534 } | 1532 } |
1535 } | 1533 } |
1536 | 1534 |
1537 RegionModel::Point newPoint(frame); | 1535 RegionModel::Point newPoint(frame); |
1538 | 1536 |
1539 if (i->haveLabel()) newPoint.label = i->getLabel(); | 1537 if (i->hasLabel()) newPoint.label = i->getLabel(); |
1540 if (i->haveValue()) newPoint.value = i->getValue(); | 1538 if (i->hasValue()) newPoint.value = i->getValue(); |
1541 else newPoint.value = (m_model->getValueMinimum() + | 1539 else newPoint.value = (m_model->getValueMinimum() + |
1542 m_model->getValueMaximum()) / 2; | 1540 m_model->getValueMaximum()) / 2; |
1543 if (i->haveDuration()) newPoint.duration = i->getDuration(); | 1541 if (i->hasDuration()) newPoint.duration = i->getDuration(); |
1544 else { | 1542 else { |
1545 sv_frame_t nextFrame = frame; | 1543 sv_frame_t nextFrame = frame; |
1546 Clipboard::PointList::const_iterator j = i; | 1544 EventVector::const_iterator j = i; |
1547 for (; j != points.end(); ++j) { | 1545 for (; j != points.end(); ++j) { |
1548 if (!j->haveFrame()) continue; | |
1549 if (j != i) break; | 1546 if (j != i) break; |
1550 } | 1547 } |
1551 if (j != points.end()) { | 1548 if (j != points.end()) { |
1552 nextFrame = j->getFrame(); | 1549 nextFrame = j->getFrame(); |
1553 } | 1550 } |