comparison document/Document.cpp @ 27:61259228d029

* More to do with passing around step/blocksize etc from plugin dialog to plugins. Still some puzzling unresolved details.
author Chris Cannam
date Tue, 19 Sep 2006 14:37:06 +0000
parents 40116f709d3b
children 56e1d4242bb4
comparison
equal deleted inserted replaced
26:d88d117e0c34 27:61259228d029
159 } 159 }
160 160
161 Layer * 161 Layer *
162 Document::createDerivedLayer(TransformName transform, 162 Document::createDerivedLayer(TransformName transform,
163 Model *inputModel, 163 Model *inputModel,
164 int channel, 164 const PluginTransform::ExecutionContext &context,
165 QString configurationXml) 165 QString configurationXml)
166 { 166 {
167 Model *newModel = createModelForTransform(transform, inputModel, 167 Model *newModel = createModelForTransform(transform, inputModel,
168 channel, configurationXml); 168 context, configurationXml);
169 if (!newModel) { 169 if (!newModel) {
170 // error already printed to stderr by createModelForTransform 170 // error already printed to stderr by createModelForTransform
171 emit modelGenerationFailed(transform); 171 emit modelGenerationFailed(transform);
172 return 0; 172 return 0;
173 } 173 }
250 250
251 // This model was derived from the previous main 251 // This model was derived from the previous main
252 // model: regenerate it. 252 // model: regenerate it.
253 253
254 TransformName transform = m_models[model].transform; 254 TransformName transform = m_models[model].transform;
255 int channel = m_models[model].channel; 255 PluginTransform::ExecutionContext context = m_models[model].context;
256 256
257 Model *replacementModel = 257 Model *replacementModel =
258 createModelForTransform(transform, 258 createModelForTransform(transform,
259 m_mainModel, 259 m_mainModel,
260 channel, 260 context,
261 m_models[model].configurationXml); 261 m_models[model].configurationXml);
262 262
263 if (!replacementModel) { 263 if (!replacementModel) {
264 std::cerr << "WARNING: Document::setMainModel: Failed to regenerate model for transform \"" 264 std::cerr << "WARNING: Document::setMainModel: Failed to regenerate model for transform \""
265 << transform.toStdString() << "\"" << " in layer " << layer << std::endl; 265 << transform.toStdString() << "\"" << " in layer " << layer << std::endl;
286 } 286 }
287 287
288 void 288 void
289 Document::addDerivedModel(TransformName transform, 289 Document::addDerivedModel(TransformName transform,
290 Model *inputModel, 290 Model *inputModel,
291 int channel, 291 const PluginTransform::ExecutionContext &context,
292 Model *outputModelToAdd, 292 Model *outputModelToAdd,
293 QString configurationXml) 293 QString configurationXml)
294 { 294 {
295 if (m_models.find(outputModelToAdd) != m_models.end()) { 295 if (m_models.find(outputModelToAdd) != m_models.end()) {
296 std::cerr << "WARNING: Document::addDerivedModel: Model already added" 296 std::cerr << "WARNING: Document::addDerivedModel: Model already added"
299 } 299 }
300 300
301 ModelRecord rec; 301 ModelRecord rec;
302 rec.source = inputModel; 302 rec.source = inputModel;
303 rec.transform = transform; 303 rec.transform = transform;
304 rec.channel = channel; 304 rec.context = context;
305 rec.configurationXml = configurationXml; 305 rec.configurationXml = configurationXml;
306 rec.refcount = 0; 306 rec.refcount = 0;
307 307
308 m_models[outputModelToAdd] = rec; 308 m_models[outputModelToAdd] = rec;
309 309
321 } 321 }
322 322
323 ModelRecord rec; 323 ModelRecord rec;
324 rec.source = 0; 324 rec.source = 0;
325 rec.transform = ""; 325 rec.transform = "";
326 rec.channel = -1;
327 rec.refcount = 0; 326 rec.refcount = 0;
328 327
329 m_models[model] = rec; 328 m_models[model] = rec;
330 329
331 emit modelAdded(model); 330 emit modelAdded(model);
332 } 331 }
333 332
334 Model * 333 Model *
335 Document::createModelForTransform(TransformName transform, 334 Document::createModelForTransform(TransformName transform,
336 Model *inputModel, 335 Model *inputModel,
337 int channel, 336 const PluginTransform::ExecutionContext &context,
338 QString configurationXml) 337 QString configurationXml)
339 { 338 {
340 Model *model = 0; 339 Model *model = 0;
341 340
342 for (ModelMap::iterator i = m_models.begin(); i != m_models.end(); ++i) { 341 for (ModelMap::iterator i = m_models.begin(); i != m_models.end(); ++i) {
343 if (i->second.transform == transform && 342 if (i->second.transform == transform &&
344 i->second.source == inputModel && 343 i->second.source == inputModel &&
345 i->second.channel == channel && 344 i->second.context == context &&
346 i->second.configurationXml == configurationXml) { 345 i->second.configurationXml == configurationXml) {
347 return i->first; 346 return i->first;
348 } 347 }
349 } 348 }
350 349
351 model = TransformFactory::getInstance()->transform 350 model = TransformFactory::getInstance()->transform
352 (transform, inputModel, channel, configurationXml); 351 (transform, inputModel, context, configurationXml);
353 352
354 if (!model) { 353 if (!model) {
355 std::cerr << "WARNING: Document::createModelForTransform: no output model for transform " << transform.toStdString() << std::endl; 354 std::cerr << "WARNING: Document::createModelForTransform: no output model for transform " << transform.toStdString() << std::endl;
356 } else { 355 } else {
357 addDerivedModel(transform, inputModel, channel, model, configurationXml); 356 addDerivedModel(transform, inputModel, context, model, configurationXml);
358 } 357 }
359 358
360 return model; 359 return model;
361 } 360 }
362 361
694 693
695 const ModelRecord &rec = i->second; 694 const ModelRecord &rec = i->second;
696 695
697 if (rec.source && rec.transform != "") { 696 if (rec.source && rec.transform != "") {
698 697
698 //!!! stream the rest of the execution context in both directions (i.e. not just channel)
699
699 out << indent; 700 out << indent;
700 out << QString(" <derivation source=\"%1\" model=\"%2\" channel=\"%3\" transform=\"%4\"") 701 out << QString(" <derivation source=\"%1\" model=\"%2\" channel=\"%3\" transform=\"%4\"")
701 .arg(XmlExportable::getObjectExportId(rec.source)) 702 .arg(XmlExportable::getObjectExportId(rec.source))
702 .arg(XmlExportable::getObjectExportId(i->first)) 703 .arg(XmlExportable::getObjectExportId(i->first))
703 .arg(rec.channel) 704 .arg(rec.context.channel)
704 .arg(XmlExportable::encodeEntities(rec.transform)); 705 .arg(XmlExportable::encodeEntities(rec.transform));
705 706
706 if (rec.configurationXml != "") { 707 if (rec.configurationXml != "") {
707 out << ">\n " + indent + rec.configurationXml 708 out << ">\n " + indent + rec.configurationXml
708 + "\n" + indent + " </derivation>\n"; 709 + "\n" + indent + " </derivation>\n";