Mercurial > hg > svapp
comparison framework/Document.h @ 673:d62fd61082a1
Merge from branch tuning-difference
author | Chris Cannam |
---|---|
date | Fri, 17 May 2019 09:46:22 +0100 |
parents | ae7584dbd668 |
children | 1f18e0f64af8 |
comparison
equal
deleted
inserted
replaced
665:e19c609a7bec | 673:d62fd61082a1 |
---|---|
292 * the main model has changed since they were calculated. | 292 * the main model has changed since they were calculated. |
293 */ | 293 */ |
294 void alignModels(); | 294 void alignModels(); |
295 | 295 |
296 /** | 296 /** |
297 * Re-generate alignments for all appropriate models against the | |
298 * main model. Existing alignments will be re-calculated. | |
299 */ | |
300 void realignModels(); | |
301 | |
302 /** | |
297 * Return true if any external files (most obviously audio) failed | 303 * Return true if any external files (most obviously audio) failed |
298 * to be found on load, so that the document is incomplete | 304 * to be found on load, so that the document is incomplete |
299 * compared to its saved description. | 305 * compared to its saved description. |
300 */ | 306 */ |
301 bool isIncomplete() const { return m_isIncomplete; } | 307 bool isIncomplete() const { return m_isIncomplete; } |
336 protected: | 342 protected: |
337 void releaseModel(Model *model); | 343 void releaseModel(Model *model); |
338 | 344 |
339 /** | 345 /** |
340 * If model is suitable for alignment, align it against the main | 346 * If model is suitable for alignment, align it against the main |
341 * model and store the alignment in the model. (If the model has | 347 * model and store the alignment in the model. If the model has an |
342 * an alignment already for the current main model, leave it | 348 * alignment already for the current main model, leave it |
343 * unchanged.) | 349 * unchanged unless forceRecalculate is true. |
344 */ | 350 */ |
345 void alignModel(Model *); | 351 void alignModel(Model *, bool forceRecalculate = false); |
346 | 352 |
347 /* | 353 /* |
348 * Every model that is in use by a layer in the document must be | 354 * Every model that is in use by a layer in the document must be |
349 * found in either m_mainModel or m_models. We own and control | 355 * found in either m_mainModel or m_models. We own and control |
350 * the lifespan of all of these models. | 356 * the lifespan of all of these models. |
368 | 374 |
369 // This does not use ModelTransformer::Input, because it would | 375 // This does not use ModelTransformer::Input, because it would |
370 // be confusing to have Input objects hanging around with NULL | 376 // be confusing to have Input objects hanging around with NULL |
371 // models in them. | 377 // models in them. |
372 | 378 |
379 Model *model; | |
373 const Model *source; | 380 const Model *source; |
374 int channel; | 381 int channel; |
375 Transform transform; | 382 Transform transform; |
376 bool additional; | 383 bool additional; |
377 | 384 |
378 // Count of the number of layers using this model. | 385 // Count of the number of layers using this model. |
379 int refcount; | 386 int refcount; |
380 }; | 387 }; |
381 | 388 |
382 typedef std::map<Model *, ModelRecord> ModelMap; | 389 // This used to be a map<Model *, ModelRecord>, but a vector |
383 ModelMap m_models; | 390 // ensures that models are consistently recorded in order of |
391 // creation rather than at the whim of heap allocation, and that's | |
392 // useful for automated testing. We don't expect ever to have so | |
393 // many models that there is any significant overhead there. | |
394 typedef std::vector<ModelRecord> ModelList; | |
395 ModelList m_models; | |
396 | |
397 ModelList::iterator findModelInList(Model *m) { | |
398 for (ModelList::iterator i = m_models.begin(); | |
399 i != m_models.end(); ++i) { | |
400 if (i->model == m) { | |
401 return i; | |
402 } | |
403 } | |
404 return m_models.end(); | |
405 } | |
406 | |
407 void deleteModelFromList(Model *m) { | |
408 ModelList keep; | |
409 bool found = false; | |
410 for (const ModelRecord &rec: m_models) { | |
411 if (rec.model == m) { | |
412 found = true; | |
413 m->aboutToDelete(); | |
414 emit modelAboutToBeDeleted(m); | |
415 } else { | |
416 keep.push_back(rec); | |
417 } | |
418 } | |
419 m_models = keep; | |
420 if (found) { | |
421 delete m; | |
422 } | |
423 } | |
384 | 424 |
385 /** | 425 /** |
386 * Add an extra derived model (returned at the end of processing a | 426 * Add an extra derived model (returned at the end of processing a |
387 * transform). | 427 * transform). |
388 */ | 428 */ |
445 | 485 |
446 /** | 486 /** |
447 * And these are the layers. We also control the lifespans of | 487 * And these are the layers. We also control the lifespans of |
448 * these (usually through the commands used to add and remove them). | 488 * these (usually through the commands used to add and remove them). |
449 */ | 489 */ |
450 typedef std::set<Layer *> LayerSet; | 490 typedef std::vector<Layer *> LayerList; |
451 LayerSet m_layers; | 491 LayerList m_layers; |
452 | 492 |
453 bool m_autoAlignment; | 493 bool m_autoAlignment; |
454 Align *m_align; | 494 Align *m_align; |
455 | 495 |
456 bool m_isIncomplete; | 496 bool m_isIncomplete; |