Mercurial > hg > svapp
comparison framework/SVFileReader.cpp @ 293:068235cf5bf7
Drop std:: from cout, cerr, endl -- pull these in through Debug.h
author | Chris Cannam |
---|---|
date | Tue, 26 Nov 2013 14:12:50 +0000 |
parents | ecbf3b75c562 |
children | 933b5aed341a |
comparison
equal
deleted
inserted
replaced
291:3fc0df289533 | 293:068235cf5bf7 |
---|---|
95 } | 95 } |
96 | 96 |
97 SVFileReader::~SVFileReader() | 97 SVFileReader::~SVFileReader() |
98 { | 98 { |
99 if (!m_awaitingDatasets.empty()) { | 99 if (!m_awaitingDatasets.empty()) { |
100 std::cerr << "WARNING: SV-XML: File ended with " | 100 cerr << "WARNING: SV-XML: File ended with " |
101 << m_awaitingDatasets.size() << " unfilled model dataset(s)" | 101 << m_awaitingDatasets.size() << " unfilled model dataset(s)" |
102 << std::endl; | 102 << endl; |
103 } | 103 } |
104 | 104 |
105 std::set<Model *> unaddedModels; | 105 std::set<Model *> unaddedModels; |
106 | 106 |
107 for (std::map<int, Model *>::iterator i = m_models.begin(); | 107 for (std::map<int, Model *>::iterator i = m_models.begin(); |
110 unaddedModels.insert(i->second); | 110 unaddedModels.insert(i->second); |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 if (!unaddedModels.empty()) { | 114 if (!unaddedModels.empty()) { |
115 std::cerr << "WARNING: SV-XML: File contained " | 115 cerr << "WARNING: SV-XML: File contained " |
116 << unaddedModels.size() << " unused models" | 116 << unaddedModels.size() << " unused models" |
117 << std::endl; | 117 << endl; |
118 while (!unaddedModels.empty()) { | 118 while (!unaddedModels.empty()) { |
119 delete *unaddedModels.begin(); | 119 delete *unaddedModels.begin(); |
120 unaddedModels.erase(unaddedModels.begin()); | 120 unaddedModels.erase(unaddedModels.begin()); |
121 } | 121 } |
122 } | 122 } |
233 } else if (name == "parameter") { | 233 } else if (name == "parameter") { |
234 | 234 |
235 ok = readParameter(attributes); | 235 ok = readParameter(attributes); |
236 | 236 |
237 } else { | 237 } else { |
238 std::cerr << "WARNING: SV-XML: Unexpected element \"" | 238 cerr << "WARNING: SV-XML: Unexpected element \"" |
239 << name.toLocal8Bit().data() << "\"" << std::endl; | 239 << name.toLocal8Bit().data() << "\"" << endl; |
240 } | 240 } |
241 | 241 |
242 if (!ok) { | 242 if (!ok) { |
243 std::cerr << "WARNING: SV-XML: Failed to completely process element \"" | 243 cerr << "WARNING: SV-XML: Failed to completely process element \"" |
244 << name.toLocal8Bit().data() << "\"" << std::endl; | 244 << name.toLocal8Bit().data() << "\"" << endl; |
245 } | 245 } |
246 | 246 |
247 return true; | 247 return true; |
248 } | 248 } |
249 | 249 |
253 bool ok = false; | 253 bool ok = false; |
254 | 254 |
255 if (m_inRow) { | 255 if (m_inRow) { |
256 ok = readRowData(text); | 256 ok = readRowData(text); |
257 if (!ok) { | 257 if (!ok) { |
258 std::cerr << "WARNING: SV-XML: Failed to read row data content for row " << m_rowNumber << std::endl; | 258 cerr << "WARNING: SV-XML: Failed to read row data content for row " << m_rowNumber << endl; |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 return true; | 262 return true; |
263 } | 263 } |
283 break; | 283 break; |
284 } | 284 } |
285 } | 285 } |
286 | 286 |
287 if (!foundInAwaiting) { | 287 if (!foundInAwaiting) { |
288 std::cerr << "WARNING: SV-XML: Dataset precedes model, or no model uses dataset" << std::endl; | 288 cerr << "WARNING: SV-XML: Dataset precedes model, or no model uses dataset" << endl; |
289 } | 289 } |
290 } | 290 } |
291 | 291 |
292 m_currentDataset = 0; | 292 m_currentDataset = 0; |
293 | 293 |
298 | 298 |
299 } else if (name == "derivation") { | 299 } else if (name == "derivation") { |
300 | 300 |
301 if (!m_currentDerivedModel) { | 301 if (!m_currentDerivedModel) { |
302 if (m_currentDerivedModel < 0) { | 302 if (m_currentDerivedModel < 0) { |
303 std::cerr << "WARNING: SV-XML: Bad derivation output model id " | 303 cerr << "WARNING: SV-XML: Bad derivation output model id " |
304 << m_currentDerivedModelId << std::endl; | 304 << m_currentDerivedModelId << endl; |
305 } else if (haveModel(m_currentDerivedModelId)) { | 305 } else if (haveModel(m_currentDerivedModelId)) { |
306 std::cerr << "WARNING: SV-XML: Derivation has existing model " | 306 cerr << "WARNING: SV-XML: Derivation has existing model " |
307 << m_currentDerivedModelId | 307 << m_currentDerivedModelId |
308 << " as target, not regenerating" << std::endl; | 308 << " as target, not regenerating" << endl; |
309 } else { | 309 } else { |
310 QString message; | 310 QString message; |
311 m_currentDerivedModel = m_models[m_currentDerivedModelId] = | 311 m_currentDerivedModel = m_models[m_currentDerivedModelId] = |
312 m_document->addDerivedModel | 312 m_document->addDerivedModel |
313 (m_currentTransform, | 313 (m_currentTransform, |
360 m_errorString = | 360 m_errorString = |
361 QString("ERROR: SV-XML: %1 at line %2, column %3") | 361 QString("ERROR: SV-XML: %1 at line %2, column %3") |
362 .arg(exception.message()) | 362 .arg(exception.message()) |
363 .arg(exception.lineNumber()) | 363 .arg(exception.lineNumber()) |
364 .arg(exception.columnNumber()); | 364 .arg(exception.columnNumber()); |
365 std::cerr << m_errorString.toLocal8Bit().data() << std::endl; | 365 cerr << m_errorString.toLocal8Bit().data() << endl; |
366 return QXmlDefaultHandler::error(exception); | 366 return QXmlDefaultHandler::error(exception); |
367 } | 367 } |
368 | 368 |
369 bool | 369 bool |
370 SVFileReader::fatalError(const QXmlParseException &exception) | 370 SVFileReader::fatalError(const QXmlParseException &exception) |
372 m_errorString = | 372 m_errorString = |
373 QString("FATAL ERROR: SV-XML: %1 at line %2, column %3") | 373 QString("FATAL ERROR: SV-XML: %1 at line %2, column %3") |
374 .arg(exception.message()) | 374 .arg(exception.message()) |
375 .arg(exception.lineNumber()) | 375 .arg(exception.lineNumber()) |
376 .arg(exception.columnNumber()); | 376 .arg(exception.columnNumber()); |
377 std::cerr << m_errorString.toLocal8Bit().data() << std::endl; | 377 cerr << m_errorString.toLocal8Bit().data() << endl; |
378 return QXmlDefaultHandler::fatalError(exception); | 378 return QXmlDefaultHandler::fatalError(exception); |
379 } | 379 } |
380 | 380 |
381 | 381 |
382 #define READ_MANDATORY(TYPE, NAME, CONVERSION) \ | 382 #define READ_MANDATORY(TYPE, NAME, CONVERSION) \ |
383 TYPE NAME = attributes.value(#NAME).trimmed().CONVERSION(&ok); \ | 383 TYPE NAME = attributes.value(#NAME).trimmed().CONVERSION(&ok); \ |
384 if (!ok) { \ | 384 if (!ok) { \ |
385 std::cerr << "WARNING: SV-XML: Missing or invalid mandatory " #TYPE " attribute \"" #NAME "\"" << std::endl; \ | 385 cerr << "WARNING: SV-XML: Missing or invalid mandatory " #TYPE " attribute \"" #NAME "\"" << endl; \ |
386 return false; \ | 386 return false; \ |
387 } | 387 } |
388 | 388 |
389 bool | 389 bool |
390 SVFileReader::readWindow(const QXmlAttributes &attributes) | 390 SVFileReader::readWindow(const QXmlAttributes &attributes) |
433 bool ok = false; | 433 bool ok = false; |
434 | 434 |
435 READ_MANDATORY(int, id, toInt); | 435 READ_MANDATORY(int, id, toInt); |
436 | 436 |
437 if (haveModel(id)) { | 437 if (haveModel(id)) { |
438 std::cerr << "WARNING: SV-XML: Ignoring duplicate model id " << id | 438 cerr << "WARNING: SV-XML: Ignoring duplicate model id " << id |
439 << std::endl; | 439 << endl; |
440 return false; | 440 return false; |
441 } | 441 } |
442 | 442 |
443 QString name = attributes.value("name"); | 443 QString name = attributes.value("name"); |
444 | 444 |
463 ProgressDialog dialog(tr("Opening file or URL..."), true, 2000); | 463 ProgressDialog dialog(tr("Opening file or URL..."), true, 2000); |
464 FileSource file(path, &dialog); | 464 FileSource file(path, &dialog); |
465 file.waitForStatus(); | 465 file.waitForStatus(); |
466 | 466 |
467 if (!file.isOK()) { | 467 if (!file.isOK()) { |
468 std::cerr << "SVFileReader::readModel: Failed to retrieve file \"" << path << "\" for wave file model: " << file.getErrorString() << std::endl; | 468 cerr << "SVFileReader::readModel: Failed to retrieve file \"" << path << "\" for wave file model: " << file.getErrorString() << endl; |
469 } else if (!file.isAvailable()) { | 469 } else if (!file.isAvailable()) { |
470 std::cerr << "SVFileReader::readModel: Failed to retrieve file \"" << path << "\" for wave file model: Source unavailable" << std::endl; | 470 cerr << "SVFileReader::readModel: Failed to retrieve file \"" << path << "\" for wave file model: Source unavailable" << endl; |
471 } else { | 471 } else { |
472 | 472 |
473 file.waitForData(); | 473 file.waitForData(); |
474 | 474 |
475 size_t rate = 0; | 475 size_t rate = 0; |
535 m_models[id] = model; | 535 m_models[id] = model; |
536 return true; | 536 return true; |
537 | 537 |
538 } else { | 538 } else { |
539 | 539 |
540 std::cerr << "WARNING: SV-XML: Unexpected dense model dimension (" | 540 cerr << "WARNING: SV-XML: Unexpected dense model dimension (" |
541 << dimensions << ")" << std::endl; | 541 << dimensions << ")" << endl; |
542 } | 542 } |
543 } else if (type == "sparse") { | 543 } else if (type == "sparse") { |
544 | 544 |
545 READ_MANDATORY(int, dimensions, toInt); | 545 READ_MANDATORY(int, dimensions, toInt); |
546 | 546 |
647 | 647 |
648 return true; | 648 return true; |
649 | 649 |
650 } else { | 650 } else { |
651 | 651 |
652 std::cerr << "WARNING: SV-XML: Unexpected sparse model dimension (" | 652 cerr << "WARNING: SV-XML: Unexpected sparse model dimension (" |
653 << dimensions << ")" << std::endl; | 653 << dimensions << ")" << endl; |
654 } | 654 } |
655 | 655 |
656 } else if (type == "alignment") { | 656 } else if (type == "alignment") { |
657 | 657 |
658 READ_MANDATORY(int, reference, toInt); | 658 READ_MANDATORY(int, reference, toInt); |
662 Model *refModel = 0, *alignedModel = 0, *pathModel = 0; | 662 Model *refModel = 0, *alignedModel = 0, *pathModel = 0; |
663 | 663 |
664 if (m_models.find(reference) != m_models.end()) { | 664 if (m_models.find(reference) != m_models.end()) { |
665 refModel = m_models[reference]; | 665 refModel = m_models[reference]; |
666 } else { | 666 } else { |
667 std::cerr << "WARNING: SV-XML: Unknown reference model id " | 667 cerr << "WARNING: SV-XML: Unknown reference model id " |
668 << reference << " in alignment model id " << id | 668 << reference << " in alignment model id " << id |
669 << std::endl; | 669 << endl; |
670 } | 670 } |
671 | 671 |
672 if (m_models.find(aligned) != m_models.end()) { | 672 if (m_models.find(aligned) != m_models.end()) { |
673 alignedModel = m_models[aligned]; | 673 alignedModel = m_models[aligned]; |
674 } else { | 674 } else { |
675 std::cerr << "WARNING: SV-XML: Unknown aligned model id " | 675 cerr << "WARNING: SV-XML: Unknown aligned model id " |
676 << aligned << " in alignment model id " << id | 676 << aligned << " in alignment model id " << id |
677 << std::endl; | 677 << endl; |
678 } | 678 } |
679 | 679 |
680 if (m_models.find(path) != m_models.end()) { | 680 if (m_models.find(path) != m_models.end()) { |
681 pathModel = m_models[path]; | 681 pathModel = m_models[path]; |
682 } else { | 682 } else { |
683 std::cerr << "WARNING: SV-XML: Unknown path model id " | 683 cerr << "WARNING: SV-XML: Unknown path model id " |
684 << path << " in alignment model id " << id | 684 << path << " in alignment model id " << id |
685 << std::endl; | 685 << endl; |
686 } | 686 } |
687 | 687 |
688 if (refModel && alignedModel && pathModel) { | 688 if (refModel && alignedModel && pathModel) { |
689 AlignmentModel *model = new AlignmentModel | 689 AlignmentModel *model = new AlignmentModel |
690 (refModel, alignedModel, 0, 0); | 690 (refModel, alignedModel, 0, 0); |
691 PathModel *pm = dynamic_cast<PathModel *>(pathModel); | 691 PathModel *pm = dynamic_cast<PathModel *>(pathModel); |
692 if (!pm) { | 692 if (!pm) { |
693 std::cerr << "WARNING: SV-XML: Model id " << path | 693 cerr << "WARNING: SV-XML: Model id " << path |
694 << " referenced as path for alignment " << id | 694 << " referenced as path for alignment " << id |
695 << " is not a path model" << std::endl; | 695 << " is not a path model" << endl; |
696 } else { | 696 } else { |
697 model->setPath(pm); | 697 model->setPath(pm); |
698 pm->setCompletion(100); | 698 pm->setCompletion(100); |
699 } | 699 } |
700 model->setObjectName(name); | 700 model->setObjectName(name); |
703 return true; | 703 return true; |
704 } | 704 } |
705 | 705 |
706 } else { | 706 } else { |
707 | 707 |
708 std::cerr << "WARNING: SV-XML: Unexpected model type \"" | 708 cerr << "WARNING: SV-XML: Unexpected model type \"" |
709 << type.toLocal8Bit().data() << "\" for model id " << id << std::endl; | 709 << type.toLocal8Bit().data() << "\" for model id " << id << endl; |
710 } | 710 } |
711 | 711 |
712 return false; | 712 return false; |
713 } | 713 } |
714 | 714 |
717 { | 717 { |
718 QString type = attributes.value("type"); | 718 QString type = attributes.value("type"); |
719 m_currentPane = 0; | 719 m_currentPane = 0; |
720 | 720 |
721 if (type != "pane") { | 721 if (type != "pane") { |
722 std::cerr << "WARNING: SV-XML: Unexpected view type \"" | 722 cerr << "WARNING: SV-XML: Unexpected view type \"" |
723 << type.toLocal8Bit().data() << "\"" << std::endl; | 723 << type.toLocal8Bit().data() << "\"" << endl; |
724 return false; | 724 return false; |
725 } | 725 } |
726 | 726 |
727 m_currentPane = m_paneCallback.addPane(); | 727 m_currentPane = m_paneCallback.addPane(); |
728 | 728 |
729 if (!m_currentPane) { | 729 if (!m_currentPane) { |
730 std::cerr << "WARNING: SV-XML: Internal error: Failed to add pane!" | 730 cerr << "WARNING: SV-XML: Internal error: Failed to add pane!" |
731 << std::endl; | 731 << endl; |
732 return false; | 732 return false; |
733 } | 733 } |
734 | 734 |
735 bool ok = false; | 735 bool ok = false; |
736 | 736 |
775 int id; | 775 int id; |
776 bool ok = false; | 776 bool ok = false; |
777 id = attributes.value("id").trimmed().toInt(&ok); | 777 id = attributes.value("id").trimmed().toInt(&ok); |
778 | 778 |
779 if (!ok) { | 779 if (!ok) { |
780 std::cerr << "WARNING: SV-XML: No layer id for layer of type \"" | 780 cerr << "WARNING: SV-XML: No layer id for layer of type \"" |
781 << type.toLocal8Bit().data() | 781 << type.toLocal8Bit().data() |
782 << "\"" << std::endl; | 782 << "\"" << endl; |
783 return false; | 783 return false; |
784 } | 784 } |
785 | 785 |
786 Layer *layer = 0; | 786 Layer *layer = 0; |
787 bool isNewLayer = false; | 787 bool isNewLayer = false; |
793 // expect it to exist. | 793 // expect it to exist. |
794 | 794 |
795 if (m_inData) { | 795 if (m_inData) { |
796 | 796 |
797 if (m_layers.find(id) != m_layers.end()) { | 797 if (m_layers.find(id) != m_layers.end()) { |
798 std::cerr << "WARNING: SV-XML: Ignoring duplicate layer id " << id | 798 cerr << "WARNING: SV-XML: Ignoring duplicate layer id " << id |
799 << " in data section" << std::endl; | 799 << " in data section" << endl; |
800 return false; | 800 return false; |
801 } | 801 } |
802 | 802 |
803 layer = m_layers[id] = m_document->createLayer | 803 layer = m_layers[id] = m_document->createLayer |
804 (LayerFactory::getInstance()->getLayerTypeForName(type)); | 804 (LayerFactory::getInstance()->getLayerTypeForName(type)); |
809 } | 809 } |
810 | 810 |
811 } else { | 811 } else { |
812 | 812 |
813 if (!m_currentPane) { | 813 if (!m_currentPane) { |
814 std::cerr << "WARNING: SV-XML: No current pane for layer " << id | 814 cerr << "WARNING: SV-XML: No current pane for layer " << id |
815 << " in view section" << std::endl; | 815 << " in view section" << endl; |
816 return false; | 816 return false; |
817 } | 817 } |
818 | 818 |
819 if (m_layers.find(id) != m_layers.end()) { | 819 if (m_layers.find(id) != m_layers.end()) { |
820 | 820 |
821 layer = m_layers[id]; | 821 layer = m_layers[id]; |
822 | 822 |
823 } else { | 823 } else { |
824 std::cerr << "WARNING: SV-XML: Layer id " << id | 824 cerr << "WARNING: SV-XML: Layer id " << id |
825 << " in view section has not been defined -- defining it here" | 825 << " in view section has not been defined -- defining it here" |
826 << std::endl; | 826 << endl; |
827 | 827 |
828 layer = m_document->createLayer | 828 layer = m_document->createLayer |
829 (LayerFactory::getInstance()->getLayerTypeForName(type)); | 829 (LayerFactory::getInstance()->getLayerTypeForName(type)); |
830 | 830 |
831 if (layer) { | 831 if (layer) { |
834 } | 834 } |
835 } | 835 } |
836 } | 836 } |
837 | 837 |
838 if (!layer) { | 838 if (!layer) { |
839 std::cerr << "WARNING: SV-XML: Failed to add layer of type \"" | 839 cerr << "WARNING: SV-XML: Failed to add layer of type \"" |
840 << type.toLocal8Bit().data() | 840 << type.toLocal8Bit().data() |
841 << "\"" << std::endl; | 841 << "\"" << endl; |
842 return false; | 842 return false; |
843 } | 843 } |
844 | 844 |
845 if (isNewLayer) { | 845 if (isNewLayer) { |
846 | 846 |
857 if (modelOk) { | 857 if (modelOk) { |
858 if (haveModel(modelId)) { | 858 if (haveModel(modelId)) { |
859 Model *model = m_models[modelId]; | 859 Model *model = m_models[modelId]; |
860 m_document->setModel(layer, model); | 860 m_document->setModel(layer, model); |
861 } else { | 861 } else { |
862 std::cerr << "WARNING: SV-XML: Unknown model id " << modelId | 862 cerr << "WARNING: SV-XML: Unknown model id " << modelId |
863 << " in layer definition" << std::endl; | 863 << " in layer definition" << endl; |
864 } | 864 } |
865 } | 865 } |
866 | 866 |
867 layer->setProperties(attributes); | 867 layer->setProperties(attributes); |
868 } | 868 } |
899 | 899 |
900 READ_MANDATORY(int, id, toInt); | 900 READ_MANDATORY(int, id, toInt); |
901 READ_MANDATORY(int, dimensions, toInt); | 901 READ_MANDATORY(int, dimensions, toInt); |
902 | 902 |
903 if (m_awaitingDatasets.find(id) == m_awaitingDatasets.end()) { | 903 if (m_awaitingDatasets.find(id) == m_awaitingDatasets.end()) { |
904 std::cerr << "WARNING: SV-XML: Unwanted dataset " << id << std::endl; | 904 cerr << "WARNING: SV-XML: Unwanted dataset " << id << endl; |
905 return false; | 905 return false; |
906 } | 906 } |
907 | 907 |
908 int modelId = m_awaitingDatasets[id]; | 908 int modelId = m_awaitingDatasets[id]; |
909 | 909 |
910 Model *model = 0; | 910 Model *model = 0; |
911 if (haveModel(modelId)) { | 911 if (haveModel(modelId)) { |
912 model = m_models[modelId]; | 912 model = m_models[modelId]; |
913 } else { | 913 } else { |
914 std::cerr << "WARNING: SV-XML: Internal error: Unknown model " << modelId | 914 cerr << "WARNING: SV-XML: Internal error: Unknown model " << modelId |
915 << " expecting dataset " << id << std::endl; | 915 << " expecting dataset " << id << endl; |
916 return false; | 916 return false; |
917 } | 917 } |
918 | 918 |
919 bool good = false; | 919 bool good = false; |
920 | 920 |
939 } | 939 } |
940 break; | 940 break; |
941 } | 941 } |
942 | 942 |
943 if (!good) { | 943 if (!good) { |
944 std::cerr << "WARNING: SV-XML: Model id " << modelId << " has wrong number of dimensions or inappropriate type for " << dimensions << "-D dataset " << id << std::endl; | 944 cerr << "WARNING: SV-XML: Model id " << modelId << " has wrong number of dimensions or inappropriate type for " << dimensions << "-D dataset " << id << endl; |
945 m_currentDataset = 0; | 945 m_currentDataset = 0; |
946 return false; | 946 return false; |
947 } | 947 } |
948 | 948 |
949 m_currentDataset = model; | 949 m_currentDataset = model; |
961 | 961 |
962 SparseOneDimensionalModel *sodm = dynamic_cast<SparseOneDimensionalModel *> | 962 SparseOneDimensionalModel *sodm = dynamic_cast<SparseOneDimensionalModel *> |
963 (m_currentDataset); | 963 (m_currentDataset); |
964 | 964 |
965 if (sodm) { | 965 if (sodm) { |
966 // std::cerr << "Current dataset is a sparse one dimensional model" << std::endl; | 966 // cerr << "Current dataset is a sparse one dimensional model" << endl; |
967 QString label = attributes.value("label"); | 967 QString label = attributes.value("label"); |
968 sodm->addPoint(SparseOneDimensionalModel::Point(frame, label)); | 968 sodm->addPoint(SparseOneDimensionalModel::Point(frame, label)); |
969 return true; | 969 return true; |
970 } | 970 } |
971 | 971 |
972 SparseTimeValueModel *stvm = dynamic_cast<SparseTimeValueModel *> | 972 SparseTimeValueModel *stvm = dynamic_cast<SparseTimeValueModel *> |
973 (m_currentDataset); | 973 (m_currentDataset); |
974 | 974 |
975 if (stvm) { | 975 if (stvm) { |
976 // std::cerr << "Current dataset is a sparse time-value model" << std::endl; | 976 // cerr << "Current dataset is a sparse time-value model" << endl; |
977 float value = 0.0; | 977 float value = 0.0; |
978 value = attributes.value("value").trimmed().toFloat(&ok); | 978 value = attributes.value("value").trimmed().toFloat(&ok); |
979 QString label = attributes.value("label"); | 979 QString label = attributes.value("label"); |
980 stvm->addPoint(SparseTimeValueModel::Point(frame, value, label)); | 980 stvm->addPoint(SparseTimeValueModel::Point(frame, value, label)); |
981 return ok; | 981 return ok; |
982 } | 982 } |
983 | 983 |
984 NoteModel *nm = dynamic_cast<NoteModel *>(m_currentDataset); | 984 NoteModel *nm = dynamic_cast<NoteModel *>(m_currentDataset); |
985 | 985 |
986 if (nm) { | 986 if (nm) { |
987 // std::cerr << "Current dataset is a note model" << std::endl; | 987 // cerr << "Current dataset is a note model" << endl; |
988 float value = 0.0; | 988 float value = 0.0; |
989 value = attributes.value("value").trimmed().toFloat(&ok); | 989 value = attributes.value("value").trimmed().toFloat(&ok); |
990 size_t duration = 0; | 990 size_t duration = 0; |
991 duration = attributes.value("duration").trimmed().toUInt(&ok); | 991 duration = attributes.value("duration").trimmed().toUInt(&ok); |
992 QString label = attributes.value("label"); | 992 QString label = attributes.value("label"); |
1000 } | 1000 } |
1001 | 1001 |
1002 RegionModel *rm = dynamic_cast<RegionModel *>(m_currentDataset); | 1002 RegionModel *rm = dynamic_cast<RegionModel *>(m_currentDataset); |
1003 | 1003 |
1004 if (rm) { | 1004 if (rm) { |
1005 // std::cerr << "Current dataset is a note model" << std::endl; | 1005 // cerr << "Current dataset is a note model" << endl; |
1006 float value = 0.0; | 1006 float value = 0.0; |
1007 value = attributes.value("value").trimmed().toFloat(&ok); | 1007 value = attributes.value("value").trimmed().toFloat(&ok); |
1008 size_t duration = 0; | 1008 size_t duration = 0; |
1009 duration = attributes.value("duration").trimmed().toUInt(&ok); | 1009 duration = attributes.value("duration").trimmed().toUInt(&ok); |
1010 QString label = attributes.value("label"); | 1010 QString label = attributes.value("label"); |
1013 } | 1013 } |
1014 | 1014 |
1015 TextModel *tm = dynamic_cast<TextModel *>(m_currentDataset); | 1015 TextModel *tm = dynamic_cast<TextModel *>(m_currentDataset); |
1016 | 1016 |
1017 if (tm) { | 1017 if (tm) { |
1018 // std::cerr << "Current dataset is a text model" << std::endl; | 1018 // cerr << "Current dataset is a text model" << endl; |
1019 float height = 0.0; | 1019 float height = 0.0; |
1020 height = attributes.value("height").trimmed().toFloat(&ok); | 1020 height = attributes.value("height").trimmed().toFloat(&ok); |
1021 QString label = attributes.value("label"); | 1021 QString label = attributes.value("label"); |
1022 // SVDEBUG << "SVFileReader::addPointToDataset: TextModel: frame = " << frame << ", height = " << height << ", label = " << label << ", ok = " << ok << endl; | 1022 // SVDEBUG << "SVFileReader::addPointToDataset: TextModel: frame = " << frame << ", height = " << height << ", label = " << label << ", ok = " << ok << endl; |
1023 tm->addPoint(TextModel::Point(frame, height, label)); | 1023 tm->addPoint(TextModel::Point(frame, height, label)); |
1025 } | 1025 } |
1026 | 1026 |
1027 PathModel *pm = dynamic_cast<PathModel *>(m_currentDataset); | 1027 PathModel *pm = dynamic_cast<PathModel *>(m_currentDataset); |
1028 | 1028 |
1029 if (pm) { | 1029 if (pm) { |
1030 // std::cerr << "Current dataset is a path model" << std::endl; | 1030 // cerr << "Current dataset is a path model" << endl; |
1031 int mapframe = attributes.value("mapframe").trimmed().toInt(&ok); | 1031 int mapframe = attributes.value("mapframe").trimmed().toInt(&ok); |
1032 // SVDEBUG << "SVFileReader::addPointToDataset: PathModel: frame = " << frame << ", mapframe = " << mapframe << ", ok = " << ok << endl; | 1032 // SVDEBUG << "SVFileReader::addPointToDataset: PathModel: frame = " << frame << ", mapframe = " << mapframe << ", ok = " << ok << endl; |
1033 pm->addPoint(PathModel::Point(frame, mapframe)); | 1033 pm->addPoint(PathModel::Point(frame, mapframe)); |
1034 return ok; | 1034 return ok; |
1035 } | 1035 } |
1036 | 1036 |
1037 ImageModel *im = dynamic_cast<ImageModel *>(m_currentDataset); | 1037 ImageModel *im = dynamic_cast<ImageModel *>(m_currentDataset); |
1038 | 1038 |
1039 if (im) { | 1039 if (im) { |
1040 // std::cerr << "Current dataset is an image model" << std::endl; | 1040 // cerr << "Current dataset is an image model" << endl; |
1041 QString image = attributes.value("image"); | 1041 QString image = attributes.value("image"); |
1042 QString label = attributes.value("label"); | 1042 QString label = attributes.value("label"); |
1043 // SVDEBUG << "SVFileReader::addPointToDataset: ImageModel: frame = " << frame << ", image = " << image << ", label = " << label << ", ok = " << ok << endl; | 1043 // SVDEBUG << "SVFileReader::addPointToDataset: ImageModel: frame = " << frame << ", image = " << image << ", label = " << label << ", ok = " << ok << endl; |
1044 im->addPoint(ImageModel::Point(frame, image, label)); | 1044 im->addPoint(ImageModel::Point(frame, image, label)); |
1045 return ok; | 1045 return ok; |
1046 } | 1046 } |
1047 | 1047 |
1048 std::cerr << "WARNING: SV-XML: Point element found in non-point dataset" << std::endl; | 1048 cerr << "WARNING: SV-XML: Point element found in non-point dataset" << endl; |
1049 | 1049 |
1050 return false; | 1050 return false; |
1051 } | 1051 } |
1052 | 1052 |
1053 bool | 1053 bool |
1060 if (dtdm) { | 1060 if (dtdm) { |
1061 | 1061 |
1062 bool ok = false; | 1062 bool ok = false; |
1063 int n = attributes.value("number").trimmed().toInt(&ok); | 1063 int n = attributes.value("number").trimmed().toInt(&ok); |
1064 if (!ok) { | 1064 if (!ok) { |
1065 std::cerr << "WARNING: SV-XML: Missing or invalid bin number" | 1065 cerr << "WARNING: SV-XML: Missing or invalid bin number" |
1066 << std::endl; | 1066 << endl; |
1067 return false; | 1067 return false; |
1068 } | 1068 } |
1069 | 1069 |
1070 QString name = attributes.value("name"); | 1070 QString name = attributes.value("name"); |
1071 | 1071 |
1072 dtdm->setBinName(n, name); | 1072 dtdm->setBinName(n, name); |
1073 return true; | 1073 return true; |
1074 } | 1074 } |
1075 | 1075 |
1076 std::cerr << "WARNING: SV-XML: Bin definition found in incompatible dataset" << std::endl; | 1076 cerr << "WARNING: SV-XML: Bin definition found in incompatible dataset" << endl; |
1077 | 1077 |
1078 return false; | 1078 return false; |
1079 } | 1079 } |
1080 | 1080 |
1081 | 1081 |
1085 m_inRow = false; | 1085 m_inRow = false; |
1086 | 1086 |
1087 bool ok = false; | 1087 bool ok = false; |
1088 m_rowNumber = attributes.value("n").trimmed().toInt(&ok); | 1088 m_rowNumber = attributes.value("n").trimmed().toInt(&ok); |
1089 if (!ok) { | 1089 if (!ok) { |
1090 std::cerr << "WARNING: SV-XML: Missing or invalid row number" | 1090 cerr << "WARNING: SV-XML: Missing or invalid row number" |
1091 << std::endl; | 1091 << endl; |
1092 return false; | 1092 return false; |
1093 } | 1093 } |
1094 | 1094 |
1095 m_inRow = true; | 1095 m_inRow = true; |
1096 | 1096 |
1097 // std::cerr << "SV-XML: In row " << m_rowNumber << std::endl; | 1097 // cerr << "SV-XML: In row " << m_rowNumber << endl; |
1098 | 1098 |
1099 return true; | 1099 return true; |
1100 } | 1100 } |
1101 | 1101 |
1102 bool | 1102 bool |
1115 | 1115 |
1116 for (QStringList::iterator i = data.begin(); i != data.end(); ++i) { | 1116 for (QStringList::iterator i = data.begin(); i != data.end(); ++i) { |
1117 | 1117 |
1118 if (values.size() == dtdm->getHeight()) { | 1118 if (values.size() == dtdm->getHeight()) { |
1119 if (!warned) { | 1119 if (!warned) { |
1120 std::cerr << "WARNING: SV-XML: Too many y-bins in 3-D dataset row " | 1120 cerr << "WARNING: SV-XML: Too many y-bins in 3-D dataset row " |
1121 << m_rowNumber << std::endl; | 1121 << m_rowNumber << endl; |
1122 warned = true; | 1122 warned = true; |
1123 } | 1123 } |
1124 } | 1124 } |
1125 | 1125 |
1126 bool ok; | 1126 bool ok; |
1127 float value = i->toFloat(&ok); | 1127 float value = i->toFloat(&ok); |
1128 if (!ok) { | 1128 if (!ok) { |
1129 std::cerr << "WARNING: SV-XML: Bad floating-point value " | 1129 cerr << "WARNING: SV-XML: Bad floating-point value " |
1130 << i->toLocal8Bit().data() | 1130 << i->toLocal8Bit().data() |
1131 << " in row data" << std::endl; | 1131 << " in row data" << endl; |
1132 } else { | 1132 } else { |
1133 values.push_back(value); | 1133 values.push_back(value); |
1134 } | 1134 } |
1135 } | 1135 } |
1136 | 1136 |
1137 dtdm->setColumn(m_rowNumber, values); | 1137 dtdm->setColumn(m_rowNumber, values); |
1138 return true; | 1138 return true; |
1139 } | 1139 } |
1140 | 1140 |
1141 std::cerr << "WARNING: SV-XML: Row data found in non-row dataset" << std::endl; | 1141 cerr << "WARNING: SV-XML: Row data found in non-row dataset" << endl; |
1142 | 1142 |
1143 return false; | 1143 return false; |
1144 } | 1144 } |
1145 | 1145 |
1146 bool | 1146 bool |
1149 int modelId = 0; | 1149 int modelId = 0; |
1150 bool modelOk = false; | 1150 bool modelOk = false; |
1151 modelId = attributes.value("model").trimmed().toInt(&modelOk); | 1151 modelId = attributes.value("model").trimmed().toInt(&modelOk); |
1152 | 1152 |
1153 if (!modelOk) { | 1153 if (!modelOk) { |
1154 std::cerr << "WARNING: SV-XML: No model id specified for derivation" << std::endl; | 1154 cerr << "WARNING: SV-XML: No model id specified for derivation" << endl; |
1155 return false; | 1155 return false; |
1156 } | 1156 } |
1157 | 1157 |
1158 if (haveModel(modelId)) { | 1158 if (haveModel(modelId)) { |
1159 m_currentDerivedModel = m_models[modelId]; | 1159 m_currentDerivedModel = m_models[modelId]; |
1241 int modelId = 0; | 1241 int modelId = 0; |
1242 bool modelOk = false; | 1242 bool modelOk = false; |
1243 modelId = attributes.value("model").trimmed().toInt(&modelOk); | 1243 modelId = attributes.value("model").trimmed().toInt(&modelOk); |
1244 | 1244 |
1245 if (!modelOk) { | 1245 if (!modelOk) { |
1246 std::cerr << "WARNING: SV-XML: No model id specified for play parameters" << std::endl; | 1246 cerr << "WARNING: SV-XML: No model id specified for play parameters" << endl; |
1247 return false; | 1247 return false; |
1248 } | 1248 } |
1249 | 1249 |
1250 if (haveModel(modelId)) { | 1250 if (haveModel(modelId)) { |
1251 | 1251 |
1253 | 1253 |
1254 PlayParameters *parameters = PlayParameterRepository::getInstance()-> | 1254 PlayParameters *parameters = PlayParameterRepository::getInstance()-> |
1255 getPlayParameters(m_models[modelId]); | 1255 getPlayParameters(m_models[modelId]); |
1256 | 1256 |
1257 if (!parameters) { | 1257 if (!parameters) { |
1258 std::cerr << "WARNING: SV-XML: Play parameters for model " | 1258 cerr << "WARNING: SV-XML: Play parameters for model " |
1259 << modelId | 1259 << modelId |
1260 << " not found - has model been added to document?" | 1260 << " not found - has model been added to document?" |
1261 << std::endl; | 1261 << endl; |
1262 return false; | 1262 return false; |
1263 } | 1263 } |
1264 | 1264 |
1265 bool muted = (attributes.value("mute").trimmed() == "true"); | 1265 bool muted = (attributes.value("mute").trimmed() == "true"); |
1266 parameters->setPlayMuted(muted); | 1266 parameters->setPlayMuted(muted); |
1274 QString pluginId = attributes.value("pluginId"); | 1274 QString pluginId = attributes.value("pluginId"); |
1275 if (pluginId != "") parameters->setPlayPluginId(pluginId); | 1275 if (pluginId != "") parameters->setPlayPluginId(pluginId); |
1276 | 1276 |
1277 m_currentPlayParameters = parameters; | 1277 m_currentPlayParameters = parameters; |
1278 | 1278 |
1279 // std::cerr << "Current play parameters for model: " << m_models[modelId] << ": " << m_currentPlayParameters << std::endl; | 1279 // cerr << "Current play parameters for model: " << m_models[modelId] << ": " << m_currentPlayParameters << endl; |
1280 | 1280 |
1281 } else { | 1281 } else { |
1282 | 1282 |
1283 std::cerr << "WARNING: SV-XML: Unknown model " << modelId | 1283 cerr << "WARNING: SV-XML: Unknown model " << modelId |
1284 << " for play parameters" << std::endl; | 1284 << " for play parameters" << endl; |
1285 return false; | 1285 return false; |
1286 } | 1286 } |
1287 | 1287 |
1288 return true; | 1288 return true; |
1289 } | 1289 } |
1290 | 1290 |
1291 bool | 1291 bool |
1292 SVFileReader::readPlugin(const QXmlAttributes &attributes) | 1292 SVFileReader::readPlugin(const QXmlAttributes &attributes) |
1293 { | 1293 { |
1294 if (m_currentDerivedModelId < 0 && !m_currentPlayParameters) { | 1294 if (m_currentDerivedModelId < 0 && !m_currentPlayParameters) { |
1295 std::cerr << "WARNING: SV-XML: Plugin found outside derivation or play parameters" << std::endl; | 1295 cerr << "WARNING: SV-XML: Plugin found outside derivation or play parameters" << endl; |
1296 return false; | 1296 return false; |
1297 } | 1297 } |
1298 | 1298 |
1299 if (!m_currentPlayParameters && m_currentTransformIsNewStyle) { | 1299 if (!m_currentPlayParameters && m_currentTransformIsNewStyle) { |
1300 return true; | 1300 return true; |
1323 | 1323 |
1324 bool | 1324 bool |
1325 SVFileReader::readTransform(const QXmlAttributes &attributes) | 1325 SVFileReader::readTransform(const QXmlAttributes &attributes) |
1326 { | 1326 { |
1327 if (m_currentDerivedModelId < 0) { | 1327 if (m_currentDerivedModelId < 0) { |
1328 std::cerr << "WARNING: SV-XML: Transform found outside derivation" << std::endl; | 1328 cerr << "WARNING: SV-XML: Transform found outside derivation" << endl; |
1329 return false; | 1329 return false; |
1330 } | 1330 } |
1331 | 1331 |
1332 m_currentTransform = Transform(); | 1332 m_currentTransform = Transform(); |
1333 m_currentTransform.setFromXmlAttributes(attributes); | 1333 m_currentTransform.setFromXmlAttributes(attributes); |
1336 | 1336 |
1337 bool | 1337 bool |
1338 SVFileReader::readParameter(const QXmlAttributes &attributes) | 1338 SVFileReader::readParameter(const QXmlAttributes &attributes) |
1339 { | 1339 { |
1340 if (m_currentDerivedModelId < 0) { | 1340 if (m_currentDerivedModelId < 0) { |
1341 std::cerr << "WARNING: SV-XML: Parameter found outside derivation" << std::endl; | 1341 cerr << "WARNING: SV-XML: Parameter found outside derivation" << endl; |
1342 return false; | 1342 return false; |
1343 } | 1343 } |
1344 | 1344 |
1345 QString name = attributes.value("name"); | 1345 QString name = attributes.value("name"); |
1346 if (name == "") { | 1346 if (name == "") { |
1347 std::cerr << "WARNING: SV-XML: Ignoring nameless transform parameter" | 1347 cerr << "WARNING: SV-XML: Ignoring nameless transform parameter" |
1348 << std::endl; | 1348 << endl; |
1349 return false; | 1349 return false; |
1350 } | 1350 } |
1351 | 1351 |
1352 float value = attributes.value("value").trimmed().toFloat(); | 1352 float value = attributes.value("value").trimmed().toFloat(); |
1353 | 1353 |
1373 { | 1373 { |
1374 SVDEBUG << "SVFileReader::readMeasurement: inLayer " | 1374 SVDEBUG << "SVFileReader::readMeasurement: inLayer " |
1375 << m_inLayer << ", layer " << m_currentLayer << endl; | 1375 << m_inLayer << ", layer " << m_currentLayer << endl; |
1376 | 1376 |
1377 if (!m_inLayer) { | 1377 if (!m_inLayer) { |
1378 std::cerr << "WARNING: SV-XML: Measurement found outside layer" << std::endl; | 1378 cerr << "WARNING: SV-XML: Measurement found outside layer" << endl; |
1379 return false; | 1379 return false; |
1380 } | 1380 } |
1381 | 1381 |
1382 m_currentLayer->addMeasurementRect(attributes); | 1382 m_currentLayer->addMeasurementRect(attributes); |
1383 return true; | 1383 return true; |