comparison document/SVFileReader.cpp @ 167:567df8af372c

* Fix failure to auto-calculate bounds on time-value or note model loaded from session file if min and max not specified in the model * Attempt to work out why some points in time-value layer are not being locally illuminated when expected, and why models are loaded from sv file without their names -- both failed so far...
author Chris Cannam
date Thu, 12 Jul 2007 21:10:43 +0000
parents f6ce5febc07f
children 102317ae3970
comparison
equal deleted inserted replaced
166:4d762fe10919 167:567df8af372c
394 return false; 394 return false;
395 } 395 }
396 396
397 QString name = attributes.value("name"); 397 QString name = attributes.value("name");
398 398
399 std::cerr << "SVFileReader::readModel: model name \"" << name.toStdString() << "\"" << std::endl;
400
399 READ_MANDATORY(int, sampleRate, toInt); 401 READ_MANDATORY(int, sampleRate, toInt);
400 402
401 QString type = attributes.value("type").trimmed(); 403 QString type = attributes.value("type").trimmed();
402 bool mainModel = (attributes.value("mainModel").trimmed() == "true"); 404 bool mainModel = (attributes.value("mainModel").trimmed() == "true");
403 405
433 } 435 }
434 } 436 }
435 437
436 if (!model) return false; 438 if (!model) return false;
437 439
440 model->setObjectName(name);
438 m_models[id] = model; 441 m_models[id] = model;
439 if (mainModel) { 442 if (mainModel) {
440 m_document->setMainModel(model); 443 m_document->setMainModel(model);
441 m_addedModels.insert(model); 444 m_addedModels.insert(model);
442 } 445 }
470 if (ok) model->setMaximumLevel(maximum); 473 if (ok) model->setMaximumLevel(maximum);
471 474
472 int dataset = attributes.value("dataset").trimmed().toInt(&ok); 475 int dataset = attributes.value("dataset").trimmed().toInt(&ok);
473 if (ok) m_awaitingDatasets[dataset] = id; 476 if (ok) m_awaitingDatasets[dataset] = id;
474 477
478 model->setObjectName(name);
475 m_models[id] = model; 479 m_models[id] = model;
476 return true; 480 return true;
477 481
478 } else { 482 } else {
479 483
488 492
489 READ_MANDATORY(int, resolution, toInt); 493 READ_MANDATORY(int, resolution, toInt);
490 494
491 SparseOneDimensionalModel *model = new SparseOneDimensionalModel 495 SparseOneDimensionalModel *model = new SparseOneDimensionalModel
492 (sampleRate, resolution); 496 (sampleRate, resolution);
497 model->setObjectName(name);
493 m_models[id] = model; 498 m_models[id] = model;
494 499
495 int dataset = attributes.value("dataset").trimmed().toInt(&ok); 500 int dataset = attributes.value("dataset").trimmed().toInt(&ok);
496 if (ok) m_awaitingDatasets[dataset] = id; 501 if (ok) m_awaitingDatasets[dataset] = id;
497 502
499 504
500 } else if (dimensions == 2 || dimensions == 3) { 505 } else if (dimensions == 2 || dimensions == 3) {
501 506
502 READ_MANDATORY(int, resolution, toInt); 507 READ_MANDATORY(int, resolution, toInt);
503 508
509 bool haveMinMax = true;
504 float minimum = attributes.value("minimum").trimmed().toFloat(&ok); 510 float minimum = attributes.value("minimum").trimmed().toFloat(&ok);
511 if (!ok) haveMinMax = false;
505 float maximum = attributes.value("maximum").trimmed().toFloat(&ok); 512 float maximum = attributes.value("maximum").trimmed().toFloat(&ok);
513 if (!ok) haveMinMax = false;
514
506 float valueQuantization = 515 float valueQuantization =
507 attributes.value("valueQuantization").trimmed().toFloat(&ok); 516 attributes.value("valueQuantization").trimmed().toFloat(&ok);
508 517
509 bool notifyOnAdd = (attributes.value("notifyOnAdd") == "true"); 518 bool notifyOnAdd = (attributes.value("notifyOnAdd") == "true");
510 519
512 521
513 if (dimensions == 2) { 522 if (dimensions == 2) {
514 if (attributes.value("subtype") == "text") { 523 if (attributes.value("subtype") == "text") {
515 TextModel *model = new TextModel 524 TextModel *model = new TextModel
516 (sampleRate, resolution, notifyOnAdd); 525 (sampleRate, resolution, notifyOnAdd);
526 model->setObjectName(name);
517 m_models[id] = model; 527 m_models[id] = model;
518 } else { 528 } else {
519 SparseTimeValueModel *model = new SparseTimeValueModel 529 SparseTimeValueModel *model;
520 (sampleRate, resolution, minimum, maximum, notifyOnAdd); 530 if (haveMinMax) {
531 model = new SparseTimeValueModel
532 (sampleRate, resolution, minimum, maximum, notifyOnAdd);
533 } else {
534 model = new SparseTimeValueModel
535 (sampleRate, resolution, notifyOnAdd);
536 }
521 model->setScaleUnits(units); 537 model->setScaleUnits(units);
538 model->setObjectName(name);
522 m_models[id] = model; 539 m_models[id] = model;
523 } 540 }
524 } else { 541 } else {
525 NoteModel *model = new NoteModel 542 NoteModel *model;
526 (sampleRate, resolution, minimum, maximum, notifyOnAdd); 543 if (haveMinMax) {
544 model = new NoteModel
545 (sampleRate, resolution, minimum, maximum, notifyOnAdd);
546 } else {
547 model = new NoteModel
548 (sampleRate, resolution, notifyOnAdd);
549 }
527 model->setValueQuantization(valueQuantization); 550 model->setValueQuantization(valueQuantization);
528 model->setScaleUnits(units); 551 model->setScaleUnits(units);
552 model->setObjectName(name);
529 m_models[id] = model; 553 m_models[id] = model;
530 } 554 }
531 555
532 int dataset = attributes.value("dataset").trimmed().toInt(&ok); 556 int dataset = attributes.value("dataset").trimmed().toInt(&ok);
533 if (ok) m_awaitingDatasets[dataset] = id; 557 if (ok) m_awaitingDatasets[dataset] = id;