comparison layer/NoteLayer.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 6f51297a0250
children 2ee77c9974d7
comparison
equal deleted inserted replaced
1422:6f51297a0250 1423:62e908518c71
1216 m_model->getPoints(s.getStartFrame(), s.getEndFrame()); 1216 m_model->getPoints(s.getStartFrame(), s.getEndFrame());
1217 1217
1218 for (NoteModel::PointList::iterator i = points.begin(); 1218 for (NoteModel::PointList::iterator i = points.begin();
1219 i != points.end(); ++i) { 1219 i != points.end(); ++i) {
1220 if (s.contains(i->frame)) { 1220 if (s.contains(i->frame)) {
1221 Clipboard::Point point(i->frame, i->value, i->duration, i->level, i->label); 1221 Event point(i->frame, i->value, i->duration, i->level, i->label);
1222 point.setReferenceFrame(alignToReference(v, i->frame)); 1222 to.addPoint(point.withReferenceFrame(alignToReference(v, i->frame)));
1223 to.addPoint(point);
1224 } 1223 }
1225 } 1224 }
1226 } 1225 }
1227 1226
1228 bool 1227 bool
1229 NoteLayer::paste(LayerGeometryProvider *v, const Clipboard &from, sv_frame_t /* frameOffset */, bool /* interactive */) 1228 NoteLayer::paste(LayerGeometryProvider *v, const Clipboard &from, sv_frame_t /* frameOffset */, bool /* interactive */)
1230 { 1229 {
1231 if (!m_model) return false; 1230 if (!m_model) return false;
1232 1231
1233 const Clipboard::PointList &points = from.getPoints(); 1232 const EventVector &points = from.getPoints();
1234 1233
1235 bool realign = false; 1234 bool realign = false;
1236 1235
1237 if (clipboardHasDifferentAlignment(v, from)) { 1236 if (clipboardHasDifferentAlignment(v, from)) {
1238 1237
1252 } 1251 }
1253 1252
1254 NoteModel::EditCommand *command = 1253 NoteModel::EditCommand *command =
1255 new NoteModel::EditCommand(m_model, tr("Paste")); 1254 new NoteModel::EditCommand(m_model, tr("Paste"));
1256 1255
1257 for (Clipboard::PointList::const_iterator i = points.begin(); 1256 for (EventVector::const_iterator i = points.begin();
1258 i != points.end(); ++i) { 1257 i != points.end(); ++i) {
1259 1258
1260 if (!i->haveFrame()) continue;
1261 sv_frame_t frame = 0; 1259 sv_frame_t frame = 0;
1262 1260
1263 if (!realign) { 1261 if (!realign) {
1264 1262
1265 frame = i->getFrame(); 1263 frame = i->getFrame();
1266 1264
1267 } else { 1265 } else {
1268 1266
1269 if (i->haveReferenceFrame()) { 1267 if (i->hasReferenceFrame()) {
1270 frame = i->getReferenceFrame(); 1268 frame = i->getReferenceFrame();
1271 frame = alignFromReference(v, frame); 1269 frame = alignFromReference(v, frame);
1272 } else { 1270 } else {
1273 frame = i->getFrame(); 1271 frame = i->getFrame();
1274 } 1272 }
1275 } 1273 }
1276 1274
1277 NoteModel::Point newPoint(frame); 1275 NoteModel::Point newPoint(frame);
1278 1276
1279 if (i->haveLabel()) newPoint.label = i->getLabel(); 1277 if (i->hasLabel()) newPoint.label = i->getLabel();
1280 if (i->haveValue()) newPoint.value = i->getValue(); 1278 if (i->hasValue()) newPoint.value = i->getValue();
1281 else newPoint.value = (m_model->getValueMinimum() + 1279 else newPoint.value = (m_model->getValueMinimum() +
1282 m_model->getValueMaximum()) / 2; 1280 m_model->getValueMaximum()) / 2;
1283 if (i->haveLevel()) newPoint.level = i->getLevel(); 1281 if (i->hasLevel()) newPoint.level = i->getLevel();
1284 if (i->haveDuration()) newPoint.duration = i->getDuration(); 1282 if (i->hasDuration()) newPoint.duration = i->getDuration();
1285 else { 1283 else {
1286 sv_frame_t nextFrame = frame; 1284 sv_frame_t nextFrame = frame;
1287 Clipboard::PointList::const_iterator j = i; 1285 EventVector::const_iterator j = i;
1288 for (; j != points.end(); ++j) { 1286 for (; j != points.end(); ++j) {
1289 if (!j->haveFrame()) continue;
1290 if (j != i) break; 1287 if (j != i) break;
1291 } 1288 }
1292 if (j != points.end()) { 1289 if (j != points.end()) {
1293 nextFrame = j->getFrame(); 1290 nextFrame = j->getFrame();
1294 } 1291 }