comparison framework/Document.cpp @ 589:cce97b00663a

Write aggregate models to .sv file when saving document. They still are not reloaded, but I think this is far as I'm prepared to go for 3.0.
author Chris Cannam
date Mon, 27 Feb 2017 16:52:47 +0000
parents d122d3595a32
children b23bebfdfaba
comparison
equal deleted inserted replaced
588:d122d3595a32 589:cce97b00663a
1288 std::set<const Model *> used; 1288 std::set<const Model *> used;
1289 1289
1290 for (LayerViewMap::const_iterator i = m_layerViewMap.begin(); 1290 for (LayerViewMap::const_iterator i = m_layerViewMap.begin();
1291 i != m_layerViewMap.end(); ++i) { 1291 i != m_layerViewMap.end(); ++i) {
1292 1292
1293 if (i->first && !i->second.empty() && i->first->getModel()) { 1293 if (i->first && !i->second.empty()) { // Layer exists, is in views
1294 used.insert(i->first->getModel()); 1294 Model *m = i->first->getModel();
1295 } 1295 if (m) {
1296 used.insert(m);
1297 if (m->getSourceModel()) {
1298 used.insert(m->getSourceModel());
1299 }
1300 }
1301 }
1302 }
1303
1304 // Write aggregate models first, so that when re-reading
1305 // derivations we already know about their existence. But only
1306 // those that are actually used
1307
1308 for (std::set<Model *>::iterator i = m_aggregateModels.begin();
1309 i != m_aggregateModels.end(); ++i) {
1310
1311 SVDEBUG << "checking aggregate model " << *i << endl;
1312
1313 AggregateWaveModel *aggregate = qobject_cast<AggregateWaveModel *>(*i);
1314 if (!aggregate) continue;
1315 if (used.find(aggregate) == used.end()) {
1316 SVDEBUG << "(unused, skipping)" << endl;
1317 continue;
1318 }
1319
1320 SVDEBUG << "(used, writing)" << endl;
1321
1322 aggregate->toXml(out, indent + " ");
1296 } 1323 }
1297 1324
1298 std::set<Model *> written; 1325 std::set<Model *> written;
1299 1326
1300 for (ModelMap::const_iterator i = m_models.begin(); 1327 for (ModelMap::const_iterator i = m_models.begin();
1351 (out, indent + " ", 1378 (out, indent + " ",
1352 QString("model=\"%1\"") 1379 QString("model=\"%1\"")
1353 .arg(XmlExportable::getObjectExportId(model))); 1380 .arg(XmlExportable::getObjectExportId(model)));
1354 } 1381 }
1355 } 1382 }
1356 1383
1357 //!!! 1384 //!!!
1358 1385
1359 // We should write out the alignment models here. AlignmentModel 1386 // We should write out the alignment models here. AlignmentModel
1360 // needs a toXml that writes out the export IDs of its reference 1387 // needs a toXml that writes out the export IDs of its reference
1361 // and aligned models, and then streams its path model. Note that 1388 // and aligned models, and then streams its path model. Note that