Mercurial > hg > svcore
comparison data/model/Labeller.h @ 1741:9d82b164f264 by-id
Work on commands, and some other model updates
author | Chris Cannam |
---|---|
date | Thu, 27 Jun 2019 13:08:10 +0100 |
parents | 08bed13d3a26 |
children | 52705a328b34 |
comparison
equal
deleted
inserted
replaced
1740:fe3f7f8df3a3 | 1741:9d82b164f264 |
---|---|
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 template |
229 * parameter must be a type that can be dynamic_cast to | |
230 * EventEditable and that has a ById store. | |
229 */ | 231 */ |
230 Command *labelAll(EventEditable *editable, | 232 template <typename EditableBase> |
233 Command *labelAll(typename EditableBase::Id editable, | |
231 MultiSelection *ms, | 234 MultiSelection *ms, |
232 const EventVector &allEvents) { | 235 const EventVector &allEvents) { |
233 | 236 |
234 ChangeEventsCommand *command = new ChangeEventsCommand | 237 auto command = new ChangeEventsCommand<EditableBase> |
235 (editable, tr("Label Points")); | 238 (editable, tr("Label Points")); |
236 | 239 |
237 Event prev; | 240 Event prev; |
238 bool havePrev = false; | 241 bool havePrev = false; |
239 | 242 |
268 /** | 271 /** |
269 * For each event in the given event vector (except the last), if | 272 * 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 | 273 * that event lies within the given multi-selection, add n-1 new |
271 * events at equally spaced intervals between it and the following | 274 * events at equally spaced intervals between it and the following |
272 * event. Return a command that has been executed but not yet | 275 * event. Return a command that has been executed but not yet |
273 * added to the history. | 276 * added to the history. The template parameter must be a type |
277 * that can be dynamic_cast to EventEditable and that has a ById | |
278 * store. | |
274 */ | 279 */ |
275 Command *subdivide(EventEditable *editable, | 280 template <typename EditableBase> |
281 Command *subdivide(typename EditableBase::Id editable, | |
276 MultiSelection *ms, | 282 MultiSelection *ms, |
277 const EventVector &allEvents, | 283 const EventVector &allEvents, |
278 int n) { | 284 int n) { |
279 | 285 |
280 ChangeEventsCommand *command = new ChangeEventsCommand | 286 auto command = new ChangeEventsCommand<EditableBase> |
281 (editable, tr("Subdivide Points")); | 287 (editable, tr("Subdivide Points")); |
282 | 288 |
283 for (auto i = allEvents.begin(); i != allEvents.end(); ++i) { | 289 for (auto i = allEvents.begin(); i != allEvents.end(); ++i) { |
284 | 290 |
285 auto j = i; | 291 auto j = i; |
317 /** | 323 /** |
318 * The opposite of subdivide. Given an event vector, a | 324 * The opposite of subdivide. Given an event vector, a |
319 * multi-selection, and a number n, remove all but every nth event | 325 * multi-selection, and a number n, remove all but every nth event |
320 * from the vector within the extents of the multi-selection. | 326 * from the vector within the extents of the multi-selection. |
321 * Return a command that has been executed but not yet added to | 327 * Return a command that has been executed but not yet added to |
322 * the history. | 328 * the history. The template parameter must be a type |
329 * that can be dynamic_cast to EventEditable and that has a ById | |
330 * store. | |
323 */ | 331 */ |
324 Command *winnow(EventEditable *editable, | 332 template <typename EditableBase> |
333 Command *winnow(typename EditableBase::Id editable, | |
325 MultiSelection *ms, | 334 MultiSelection *ms, |
326 const EventVector &allEvents, | 335 const EventVector &allEvents, |
327 int n) { | 336 int n) { |
328 | 337 |
329 ChangeEventsCommand *command = new ChangeEventsCommand | 338 auto command = new ChangeEventsCommand<EditableBase> |
330 (editable, tr("Winnow Points")); | 339 (editable, tr("Winnow Points")); |
331 | 340 |
332 int counter = 0; | 341 int counter = 0; |
333 | 342 |
334 for (auto p: allEvents) { | 343 for (auto p: allEvents) { |