DataObjectPtr CSD::makeDuplicate() const{ CSDPtr csd = store()->createObject<CSD>(); csd->change(_inputVectors[CSD_INVECTOR], _frequency, _average, _removeMean, _apodize, _apodizeFxn, _windowSize, _averageLength, _gaussianSigma, _outputType, _vectorUnits, _rateUnits); if (descriptiveNameIsManual()) { csd->setDescriptiveName(descriptiveName()); } csd->writeLock(); csd->registerChange(); csd->unlock(); return DataObjectPtr(csd); }
DataObjectPtr CSDFactory::generateObject(ObjectStore *store, QXmlStreamReader& xml) { Q_ASSERT(store); double frequency=1.0, gaussianSigma=1.0; int length=8, windowSize=8, apodizeFunction=0, outputType=0; QString vectorName, vectorUnits, rateUnits, descriptiveName; bool average=false, removeMean=false, apodize=false; while (!xml.atEnd()) { const QString n = xml.name().toString(); if (xml.isStartElement()) { if (n == CSD::staticTypeTag) { QXmlStreamAttributes attrs = xml.attributes(); vectorName = attrs.value("vector").toString(); vectorUnits = attrs.value("vectorunits").toString(); rateUnits = attrs.value("rateunits").toString(); frequency = attrs.value("samplerate").toString().toDouble(); gaussianSigma = attrs.value("gaussiansigma").toString().toDouble(); length = attrs.value("fftlength").toString().toInt(); windowSize = attrs.value("windowsize").toString().toInt(); apodizeFunction = attrs.value("apodizefunction").toString().toInt(); outputType = attrs.value("outputtype").toString().toInt(); average = attrs.value("average").toString() == "true" ? true : false; removeMean = attrs.value("removemean").toString() == "true" ? true : false; apodize = attrs.value("apodize").toString() == "true" ? true : false; if (attrs.value("descriptiveNameIsManual").toString() == "true") { descriptiveName = attrs.value("descriptiveName").toString(); } Object::processShortNameIndexAttributes(attrs); } else { return 0; } } else if (xml.isEndElement()) { if (n == CSD::staticTypeTag) { break; } else { Debug::self()->log(QObject::tr("Error creating CSD from Kst file."), Debug::Warning); return 0; } } xml.readNext(); } if (xml.hasError()) { return 0; } VectorPtr vector = 0; if (store && !vectorName.isEmpty()) { vector = kst_cast<Vector>(store->retrieveObject(vectorName)); } if (!vector) { Debug::self()->log(QObject::tr("Error creating CSD from Kst file. Could not find Vector."), Debug::Warning); return 0; } CSDPtr csd = store->createObject<CSD>(); csd->change(vector, frequency, average, removeMean, apodize, (ApodizeFunction)apodizeFunction, windowSize, length, gaussianSigma, (PSDType)outputType, vectorUnits, rateUnits); csd->setDescriptiveName(descriptiveName); csd->writeLock(); csd->registerChange(); csd->unlock(); return csd; }