Mercurial > hg > sonic-visualiser
diff document/Document.cpp @ 55:ca1e3f5657d5
* Simplify maker names in plugin menu
* Make sure derived models have a name (based on the transform)
* Don't start deriving a model from a derived model until the derived model is
ready
* Tidy up completion management in writable wave file model
* Make writable models save/reload correctly from session file (i.e.
regenerating from the original transform)
* Same for dense 3d models -- don't save the data, just the transform details
* Add a comment describing the SV file format
author | Chris Cannam |
---|---|
date | Fri, 13 Oct 2006 12:51:05 +0000 |
parents | ec77936c268e |
children | cf27fc7feb7a |
line wrap: on
line diff
--- a/document/Document.cpp Thu Oct 12 14:56:28 2006 +0000 +++ b/document/Document.cpp Fri Oct 13 12:51:05 2006 +0000 @@ -16,6 +16,8 @@ #include "Document.h" #include "data/model/WaveFileModel.h" +#include "data/model/WritableWaveFileModel.h" +#include "data/model/DenseThreeDimensionalModel.h" #include "layer/Layer.h" #include "base/CommandHistory.h" #include "base/Command.h" @@ -164,10 +166,10 @@ const PluginTransform::ExecutionContext &context, QString configurationXml) { - Model *newModel = createModelForTransform(transform, inputModel, - context, configurationXml); + Model *newModel = addDerivedModel(transform, inputModel, + context, configurationXml); if (!newModel) { - // error already printed to stderr by createModelForTransform + // error already printed to stderr by addDerivedModel emit modelGenerationFailed(transform); return 0; } @@ -262,10 +264,10 @@ PluginTransform::ExecutionContext context = m_models[model].context; Model *replacementModel = - createModelForTransform(transform, - m_mainModel, - context, - m_models[model].configurationXml); + addDerivedModel(transform, + m_mainModel, + context, + m_models[model].configurationXml); if (!replacementModel) { std::cerr << "WARNING: Document::setMainModel: Failed to regenerate model for transform \"" @@ -353,10 +355,10 @@ } Model * -Document::createModelForTransform(TransformName transform, - Model *inputModel, - const PluginTransform::ExecutionContext &context, - QString configurationXml) +Document::addDerivedModel(TransformName transform, + Model *inputModel, + const PluginTransform::ExecutionContext &context, + QString configurationXml) { Model *model = 0; @@ -373,7 +375,7 @@ (transform, inputModel, context, configurationXml); if (!model) { - std::cerr << "WARNING: Document::createModelForTransform: no output model for transform " << transform.toStdString() << std::endl; + std::cerr << "WARNING: Document::addDerivedModel: no output model for transform " << transform.toStdString() << std::endl; } else { addDerivedModel(transform, inputModel, context, model, configurationXml); } @@ -494,7 +496,12 @@ Model *previousModel = layer->getModel(); if (previousModel == model) { - std::cerr << "WARNING: Document::setModel: Layer is already set to this model" << std::endl; + std::cerr << "WARNING: Document::setModel: Layer " << layer << " (\"" + << layer->objectName().toStdString() + << "\") is already set to model " + << model << " (\"" + << (model ? model->objectName().toStdString() : "(null)") + << "\")" << std::endl; return; } @@ -520,7 +527,10 @@ { Model *model = layer->getModel(); if (!model) { - std::cerr << "Document::addLayerToView: Layer with no model being added to view: normally you want to set the model first" << std::endl; + std::cerr << "Document::addLayerToView: Layer (\"" + << layer->objectName().toStdString() + << "\") with no model being added to view: " + << "normally you want to set the model first" << std::endl; } else { if (model != m_mainModel && m_models.find(model) == m_models.end()) { @@ -714,11 +724,42 @@ for (ModelMap::const_iterator i = m_models.begin(); i != m_models.end(); ++i) { - i->first->toXml(out, indent + " "); - + const Model *model = i->first; const ModelRecord &rec = i->second; - if (rec.source && rec.transform != "") { + // We need an intelligent way to determine which models need + // to be streamed (i.e. have been edited, or are small) and + // which should not be (i.e. remain as generated by a + // transform, and are large). + // + // At the moment we can get away with deciding not to stream + // dense 3d models or writable wave file models, provided they + // were generated from a transform, because at the moment there + // is no way to edit those model types so it should be safe to + // regenerate them. That won't always work in future though. + // It would be particularly nice to be able to ask the user, + // as well as making an intelligent guess. + + bool writeModel = true; + bool haveDerivation = false; + + if (rec.source && rec.transform != "") { + haveDerivation = true; + } + + if (haveDerivation) { + if (dynamic_cast<const WritableWaveFileModel *>(model)) { + writeModel = false; + } else if (dynamic_cast<const DenseThreeDimensionalModel *>(model)) { + writeModel = false; + } + } + + if (writeModel) { + i->first->toXml(out, indent + " "); + } + + if (haveDerivation) { //!!! stream the rest of the execution context in both directions (i.e. not just channel)