Mercurial > hg > svapp
comparison framework/Document.cpp @ 78:58bfaaed07ed
* Part of #1877436 transform fails to re-run when file loaded at different rate
author | Chris Cannam |
---|---|
date | Wed, 23 Jan 2008 18:09:50 +0000 |
parents | 0535c49069ba |
children | b1a68403714b |
comparison
equal
deleted
inserted
replaced
77:0535c49069ba | 78:58bfaaed07ed |
---|---|
203 | 203 |
204 Layer * | 204 Layer * |
205 Document::createDerivedLayer(const Transform &transform, | 205 Document::createDerivedLayer(const Transform &transform, |
206 const ModelTransformer::Input &input) | 206 const ModelTransformer::Input &input) |
207 { | 207 { |
208 Model *newModel = addDerivedModel(transform, input); | 208 QString message; |
209 Model *newModel = addDerivedModel(transform, input, message); | |
209 if (!newModel) { | 210 if (!newModel) { |
210 // error already printed to stderr by addDerivedModel | 211 emit modelGenerationFailed(transform.getIdentifier(), message); |
211 emit modelGenerationFailed(transform.getIdentifier()); | |
212 return 0; | 212 return 0; |
213 } else if (message != "") { | |
214 emit modelGenerationWarning(transform.getIdentifier(), message); | |
213 } | 215 } |
214 | 216 |
215 LayerFactory::LayerTypeSet types = | 217 LayerFactory::LayerTypeSet types = |
216 LayerFactory::getInstance()->getValidLayerTypes(newModel); | 218 LayerFactory::getInstance()->getValidLayerTypes(newModel); |
217 | 219 |
315 QString transformId = transform.getIdentifier(); | 317 QString transformId = transform.getIdentifier(); |
316 | 318 |
317 //!!! We have a problem here if the number of channels in | 319 //!!! We have a problem here if the number of channels in |
318 //the main model has changed. | 320 //the main model has changed. |
319 | 321 |
322 QString message; | |
320 Model *replacementModel = | 323 Model *replacementModel = |
321 addDerivedModel(transform, | 324 addDerivedModel(transform, |
322 ModelTransformer::Input | 325 ModelTransformer::Input |
323 (m_mainModel, | 326 (m_mainModel, m_models[model].channel), |
324 m_models[model].channel)); | 327 message); |
325 | 328 |
326 if (!replacementModel) { | 329 if (!replacementModel) { |
327 std::cerr << "WARNING: Document::setMainModel: Failed to regenerate model for transform \"" | 330 std::cerr << "WARNING: Document::setMainModel: Failed to regenerate model for transform \"" |
328 << transformId.toStdString() << "\"" << " in layer " << layer << std::endl; | 331 << transformId.toStdString() << "\"" << " in layer " << layer << std::endl; |
329 if (failedTransformers.find(transformId) | 332 if (failedTransformers.find(transformId) |
330 == failedTransformers.end()) { | 333 == failedTransformers.end()) { |
331 emit modelRegenerationFailed(layer->objectName(), | 334 emit modelRegenerationFailed(layer->objectName(), |
332 transformId); | 335 transformId, |
336 message); | |
333 failedTransformers.insert(transformId); | 337 failedTransformers.insert(transformId); |
334 } | 338 } |
335 obsoleteLayers.push_back(layer); | 339 obsoleteLayers.push_back(layer); |
336 } else { | 340 } else { |
341 if (message != "") { | |
342 emit modelRegenerationWarning(layer->objectName(), | |
343 transformId, | |
344 message); | |
345 } | |
337 #ifdef DEBUG_DOCUMENT | 346 #ifdef DEBUG_DOCUMENT |
338 std::cerr << "Replacing model " << model << " (type " | 347 std::cerr << "Replacing model " << model << " (type " |
339 << typeid(*model).name() << ") with model " | 348 << typeid(*model).name() << ") with model " |
340 << replacementModel << " (type " | 349 << replacementModel << " (type " |
341 << typeid(*replacementModel).name() << ") in layer " | 350 << typeid(*replacementModel).name() << ") in layer " |
426 emit modelAdded(model); | 435 emit modelAdded(model); |
427 } | 436 } |
428 | 437 |
429 Model * | 438 Model * |
430 Document::addDerivedModel(const Transform &transform, | 439 Document::addDerivedModel(const Transform &transform, |
431 const ModelTransformer::Input &input) | 440 const ModelTransformer::Input &input, |
441 QString &message) | |
432 { | 442 { |
433 Model *model = 0; | 443 Model *model = 0; |
434 | 444 |
435 for (ModelMap::iterator i = m_models.begin(); i != m_models.end(); ++i) { | 445 for (ModelMap::iterator i = m_models.begin(); i != m_models.end(); ++i) { |
436 if (i->second.transform == transform && | 446 if (i->second.transform == transform && |
438 i->second.channel == input.getChannel()) { | 448 i->second.channel == input.getChannel()) { |
439 return i->first; | 449 return i->first; |
440 } | 450 } |
441 } | 451 } |
442 | 452 |
443 model = ModelTransformerFactory::getInstance()->transform(transform, input); | 453 model = ModelTransformerFactory::getInstance()->transform |
454 (transform, input, message); | |
444 | 455 |
445 if (!model) { | 456 if (!model) { |
446 std::cerr << "WARNING: Document::addDerivedModel: no output model for transform " << transform.getIdentifier().toStdString() << std::endl; | 457 std::cerr << "WARNING: Document::addDerivedModel: no output model for transform " << transform.getIdentifier().toStdString() << std::endl; |
447 } else { | 458 } else { |
448 addDerivedModel(transform, input, model); | 459 addDerivedModel(transform, input, model); |
785 //!!! QString args = "<plugin param-serialise=\"1\"/>"; | 796 //!!! QString args = "<plugin param-serialise=\"1\"/>"; |
786 // Model *transformOutput = factory->transform(id, aggregate, context, args); | 797 // Model *transformOutput = factory->transform(id, aggregate, context, args); |
787 | 798 |
788 ModelTransformerFactory *mtf = ModelTransformerFactory::getInstance(); | 799 ModelTransformerFactory *mtf = ModelTransformerFactory::getInstance(); |
789 | 800 |
790 Model *transformOutput = mtf->transform(transform, aggregate); | 801 QString message; |
802 Model *transformOutput = mtf->transform(transform, aggregate, message); | |
791 | 803 |
792 if (!transformOutput) { | 804 if (!transformOutput) { |
793 transform.setStepSize(0); | 805 transform.setStepSize(0); |
794 transformOutput = mtf->transform(transform, aggregate); | 806 transformOutput = mtf->transform(transform, aggregate, message); |
795 } | 807 } |
796 | 808 |
797 SparseTimeValueModel *path = dynamic_cast<SparseTimeValueModel *> | 809 SparseTimeValueModel *path = dynamic_cast<SparseTimeValueModel *> |
798 (transformOutput); | 810 (transformOutput); |
799 | 811 |
800 if (!path) { | 812 if (!path) { |
801 std::cerr << "Document::alignModel: ERROR: Failed to create alignment path (no MATCH plugin?)" << std::endl; | 813 std::cerr << "Document::alignModel: ERROR: Failed to create alignment path (no MATCH plugin?)" << std::endl; |
814 emit alignmentFailed(id, message); | |
802 delete transformOutput; | 815 delete transformOutput; |
803 delete aggregate; | 816 delete aggregate; |
804 return; | 817 return; |
805 } | 818 } |
806 | 819 |