comparison data/model/Labeller.h @ 1766:85b9b466a59f

Merge from branch by-id
author Chris Cannam
date Wed, 17 Jul 2019 14:24:51 +0100
parents 52705a328b34
children
comparison
equal deleted inserted replaced
1730:649ac57c5a2d 1766:85b9b466a59f
223 223
224 /** 224 /**
225 * Relabel all events in the given event vector that lie within 225 * Relabel all events in the given event vector that lie within
226 * the given multi-selection, according to the labelling 226 * the given multi-selection, according to the labelling
227 * properties of this labeller. Return a command that has been 227 * properties of this labeller. Return a command that has been
228 * executed but not yet added to the history. 228 * executed but not yet added to the history. The id must be that
229 * of a type that can be retrieved from the AnyById store and
230 * dynamic_cast to EventEditable.
229 */ 231 */
230 Command *labelAll(EventEditable *editable, 232 Command *labelAll(int editableId,
231 MultiSelection *ms, 233 MultiSelection *ms,
232 const EventVector &allEvents) { 234 const EventVector &allEvents) {
233 235
234 ChangeEventsCommand *command = new ChangeEventsCommand 236 auto command = new ChangeEventsCommand
235 (editable, tr("Label Points")); 237 (editableId, tr("Label Points"));
236 238
237 Event prev; 239 Event prev;
238 bool havePrev = false; 240 bool havePrev = false;
239 241
240 for (auto p: allEvents) { 242 for (auto p: allEvents) {
268 /** 270 /**
269 * For each event in the given event vector (except the last), if 271 * For each event in the given event vector (except the last), if
270 * that event lies within the given multi-selection, add n-1 new 272 * that event lies within the given multi-selection, add n-1 new
271 * events at equally spaced intervals between it and the following 273 * events at equally spaced intervals between it and the following
272 * event. Return a command that has been executed but not yet 274 * event. Return a command that has been executed but not yet
273 * added to the history. 275 * added to the history. The id must be that of a type that can
276 * be retrieved from the AnyById store and dynamic_cast to
277 * EventEditable.
274 */ 278 */
275 Command *subdivide(EventEditable *editable, 279 Command *subdivide(int editableId,
276 MultiSelection *ms, 280 MultiSelection *ms,
277 const EventVector &allEvents, 281 const EventVector &allEvents,
278 int n) { 282 int n) {
279 283
280 ChangeEventsCommand *command = new ChangeEventsCommand 284 auto command = new ChangeEventsCommand
281 (editable, tr("Subdivide Points")); 285 (editableId, tr("Subdivide Points"));
282 286
283 for (auto i = allEvents.begin(); i != allEvents.end(); ++i) { 287 for (auto i = allEvents.begin(); i != allEvents.end(); ++i) {
284 288
285 auto j = i; 289 auto j = i;
286 // require a "next point" even if it's not in selection 290 // require a "next point" even if it's not in selection
317 /** 321 /**
318 * The opposite of subdivide. Given an event vector, a 322 * The opposite of subdivide. Given an event vector, a
319 * multi-selection, and a number n, remove all but every nth event 323 * multi-selection, and a number n, remove all but every nth event
320 * from the vector within the extents of the multi-selection. 324 * from the vector within the extents of the multi-selection.
321 * Return a command that has been executed but not yet added to 325 * Return a command that has been executed but not yet added to
322 * the history. 326 * the history. The id must be that of a type that can be
327 * retrieved from the AnyById store and dynamic_cast to
328 * EventEditable.
323 */ 329 */
324 Command *winnow(EventEditable *editable, 330 Command *winnow(int editableId,
325 MultiSelection *ms, 331 MultiSelection *ms,
326 const EventVector &allEvents, 332 const EventVector &allEvents,
327 int n) { 333 int n) {
328 334
329 ChangeEventsCommand *command = new ChangeEventsCommand 335 auto command = new ChangeEventsCommand
330 (editable, tr("Winnow Points")); 336 (editableId, tr("Winnow Points"));
331 337
332 int counter = 0; 338 int counter = 0;
333 339
334 for (auto p: allEvents) { 340 for (auto p: allEvents) {
335 341