const QString& KstIfaceImpl::generateVector(const QString& name, double from, double to, int points) { KstVectorPtr v = KstVector::generateVector(from, to, points, name); KstReadLocker rl(v); return v->tagName(); }
void KstObjectItem::update(bool recursive, int localUseCount) { switch (_rtti) { case RTTI_OBJ_DATA_VECTOR: { KST::vectorList.lock().readLock(); KstRVectorPtr x = kst_cast<KstRVector>(*KST::vectorList.findTag(_tag)); KST::vectorList.lock().unlock(); if (x) { x->readLock(); // getUsage: subtract 1 for KstRVectorPtr x bool inUse = (x->getUsage() - 1 - localUseCount) > 0; if (inUse != _inUse) { _inUse = inUse; setPixmap(2, inUse ? _dm->yesPixmap() : QPixmap()); } QString field; if (inUse) { field = QString::number(x->length()); } else { field = "-"; } if (text(3) != field) { setText(3, field); } field = i18n("%3: %4 [%1..%2]").arg(x->reqStartFrame()) .arg(x->reqStartFrame() + x->reqNumFrames()) .arg(x->filename()) .arg(x->field()); if (text(4) != field) { setText(4, field); } _removable = x->getUsage() == 2; x->unlock(); } // Hmmm what happens if this if() fails?? We become inconsistent? break; } case RTTI_OBJ_STATIC_VECTOR: { KST::vectorList.lock().readLock(); KstSVectorPtr x = kst_cast<KstSVector>(*KST::vectorList.findTag(_tag)); KST::vectorList.lock().unlock(); if (x) { x->readLock(); // getUsage: subtract 1 for KstRVectorPtr x bool inUse = (x->getUsage() - 1 - localUseCount) > 0; if (inUse != _inUse) { _inUse = inUse; setPixmap(2, inUse ? _dm->yesPixmap() : QPixmap()); } QString field; if (inUse) { field = QString::number(x->length()); } else { field = "-"; } if (text(3) != field) { setText(3, field); } field = i18n("%1 to %2").arg(x->min()).arg(x->max()); if (text(4) != field) { setText(4, field); } _removable = x->getUsage() == 2; x->unlock(); } // Hmmm what happens if this if() fails?? We become inconsistent? break; } case RTTI_OBJ_VECTOR: { KST::vectorList.lock().readLock(); KstVectorPtr x = *KST::vectorList.findTag(_tag); KST::vectorList.lock().unlock(); if (x) { x->readLock(); // getUsage: // subtract 1 for KstVectorPtr x bool inUse = (x->getUsage() - 1 - localUseCount) > 0; if (inUse != _inUse) { _inUse = inUse; setPixmap(2, inUse ? _dm->yesPixmap() : QPixmap()); } QString field = QString::number(x->length()); if (text(3) != field) { setText(3, field); } field = i18n("[%1..%2]").arg(x->min()).arg(x->max()); if (text(4) != field) { setText(4, field); } x->unlock(); _removable = false; } break; } case RTTI_OBJ_OBJECT: { KST::dataObjectList.lock().readLock(); KstDataObjectPtr x = *KST::dataObjectList.findTag(_tag.tag()); KST::dataObjectList.lock().unlock(); if (x) { x->readLock(); QString field = x->typeString(); if (text(1) != field) { setText(1, field); } // getUsage: // subtract 1 for KstDataObjectPtr x bool inUse = (x->getUsage() - 1 - localUseCount) > 0; if (inUse != _inUse) { _inUse = inUse; setPixmap(2, inUse ? _dm->yesPixmap() : QPixmap()); } if (x->sampleCount() > 0) { field = QString::number(x->sampleCount()); if (text(3) != field) { setText(3, field); } } else { if (text(3) != "-") { setText(3, "-"); } } field = x->propertyString(); if (text(4) != field) { setText(4, field); } if (recursive) { QPtrStack<QListViewItem> trash; KstVectorMap vl = x->outputVectors(); KstVectorMap::Iterator vlEnd = vl.end(); for (QListViewItem *i = firstChild(); i; i = i->nextSibling()) { KstObjectItem *oi = static_cast<KstObjectItem*>(i); if (vl.findTag(oi->tag().tag()) == vlEnd) { trash.push(i); } } trash.setAutoDelete(true); trash.clear(); // get the output vectors for (KstVectorMap::Iterator p = vl.begin(); p != vlEnd; ++p) { bool found = false; QString tn = p.data()->tag().tag(); for (QListViewItem *i = firstChild(); i; i = i->nextSibling()) { KstObjectItem *oi = static_cast<KstObjectItem*>(i); if (oi->tag().tag() == tn) { oi->update(); found = true; break; } } if (!found) { KstObjectItem *item = new KstObjectItem(this, p.data(), _dm); connect(item, SIGNAL(updated()), this, SIGNAL(updated())); } } KstMatrixMap ml = x->outputMatrices(); KstMatrixMap::Iterator mlEnd = ml.end(); // also get the output matrices for (KstMatrixMap::Iterator p = ml.begin(); p != mlEnd; ++p) { bool found = false; QString tn = p.data()->tag().tag(); for (QListViewItem *i = firstChild(); i; i = i->nextSibling()) { KstObjectItem *oi = static_cast<KstObjectItem*>(i); if (oi->tag().tag() == tn) { oi->update(); found = true; break; } } if (!found) { KstObjectItem *item = new KstObjectItem(this, p.data(), _dm); connect(item, SIGNAL(updated()), this, SIGNAL(updated())); } } } _removable = x->getUsage() == 1; x->unlock(); } break; } case RTTI_OBJ_DATA_MATRIX: { KST::matrixList.lock().readLock(); KstRMatrixPtr x = kst_cast<KstRMatrix>(*KST::matrixList.findTag(_tag)); KST::matrixList.lock().unlock(); if (x) { x->readLock(); // getUsage: subtract 1 for KstRMatrixPtr x bool inUse = (x->getUsage() - 1 - localUseCount) > 0; if (inUse != _inUse) { _inUse = inUse; setPixmap(2, inUse ? _dm->yesPixmap() : QPixmap()); } QString field = QString::number(x->sampleCount()); if (text(3) != field) { setText(3, field); } field = i18n("%1: %2 (%3 by %4)").arg(x->filename()).arg(x->field()) .arg(x->xNumSteps()) .arg(x->yNumSteps()); if (text(4) != field) { setText(4, field); } _removable = x->getUsage() == 2; x->unlock(); } break; } case RTTI_OBJ_STATIC_MATRIX: { KST::matrixList.lock().readLock(); KstSMatrixPtr x = kst_cast<KstSMatrix>(*KST::matrixList.findTag(_tag)); KST::matrixList.lock().unlock(); if (x) { x->readLock(); // getUsage: subtract 1 for KstRMatrixPtr x bool inUse = (x->getUsage() - 1 - localUseCount) > 0; if (inUse != _inUse) { _inUse = inUse; setPixmap(2, inUse ? _dm->yesPixmap() : QPixmap()); } QString field = QString::number(x->sampleCount()); if (text(3) != field) { setText(3, field); } field = i18n("%1 to %2").arg(x->gradZMin()).arg(x->gradZMax()); if (text(4) != field) { setText(4, field); } _removable = x->getUsage() == 2; x->unlock(); } break; } case RTTI_OBJ_MATRIX: { KST::matrixList.lock().readLock(); KstMatrixPtr x = *KST::matrixList.findTag(_tag); KST::matrixList.lock().unlock(); if (x) { x->readLock(); // getUsage: // subtract 1 for KstVectorPtr x bool inUse = (x->getUsage() - 1 - localUseCount) > 0; if (inUse != _inUse) { _inUse = inUse; setPixmap(2, inUse ? _dm->yesPixmap() : QPixmap()); } QString field = QString::number(x->sampleCount()); if (text(3) != field) { setText(3, field); } field = i18n("[%1..%2]").arg(x->minValue()).arg(x->maxValue()); if (text(4) != field) { setText(4, field); } x->unlock(); _removable = false; } break; } default: assert(0); } }
void KstViewFitsDialog::fitChanged(const QString& strFit) { KstCPluginList fits; KstCPluginPtr plugin; double* params = 0L; double* covars = 0L; double chi2Nu = 0.0; int numParams = 0; int numCovars = 0; int i; fits = kstObjectSubList<KstDataObject,KstCPlugin>(KST::dataObjectList); plugin = *(fits.findTag(strFit)); if (plugin) { KstScalarPtr scalarChi2Nu; KstVectorPtr vectorParam; plugin->readLock(); const KstScalarMap& scalars = plugin->outputScalars(); scalarChi2Nu = scalars["chi^2/nu"]; if (scalarChi2Nu) { scalarChi2Nu->readLock(); chi2Nu = scalarChi2Nu->value(); scalarChi2Nu->unlock(); } const KstVectorMap& vectors = plugin->outputVectors(); vectorParam = vectors["Parameters"]; if (vectorParam) { KstVectorPtr vectorCovar; vectorParam->readLock(); vectorCovar = vectors["Covariance"]; if (vectorCovar) { vectorCovar->readLock(); numParams = vectorParam->length(); numCovars = vectorCovar->length(); if (numParams > 0 && numCovars > 0) { params = new double[numParams]; covars = new double[numCovars]; for (i = 0; i < numParams; i++) { params[i] = vectorParam->value(i); } for (i = 0; i < numCovars; i++) { covars[i] = vectorCovar->value(i); } } vectorCovar->unlock(); } vectorParam->unlock(); } plugin->unlock(); } _tableFits->setParameters(params, numParams, covars, numCovars, chi2Nu); if (numParams > 0) { _tableFits->horizontalHeaderItem(0)->setText(QObject::tr("Value")); _tableFits->horizontalHeaderItem(1)->setText(QObject::tr("Covariance:")); _tableFits->verticalHeaderItem(numParams+0)->setText("---"); _tableFits->verticalHeaderItem(numParams+1)->setText(QObject::tr("Chi^2/Nu")); if (plugin) { QExplicitlySharedDataPointer<Plugin> pluginBase; plugin->readLock(); pluginBase = plugin->plugin(); if (pluginBase) { textLabelFit->setText(pluginBase->data()._readableName); for (i = 0; i < numParams; i++) { QString parameterName = pluginBase->parameterName(i); _tableFits->horizontalHeaderItem(i+2)->setText(parameterName); _tableFits->verticalHeaderItem(i)->setText(parameterName); } } plugin->unlock(); } } _tableFits->update(); }
bool KstHsDialogI::newObject() { QString tag_name = _tagName->text(); if (tag_name == defaultTag) { tag_name = KST::suggestHistogramName(KstObjectTag::fromString(_w->_vector->selectedVector())); } // verify that the curve name is unique if (KstData::self()->dataTagNameNotUnique(tag_name)) { _tagName->setFocus(); return false; } if (_w->_vector->selectedVector().isEmpty()) { KMessageBox::sorry(this, i18n("New Histogram not made: define vectors first.")); return false; } // find max and min double new_min = _w->Min->text().toDouble(); double new_max = _w->Max->text().toDouble(); if (new_max < new_min) { double m = new_max; new_max = new_min; new_min = m; } if (new_max == new_min) { KMessageBox::sorry(this, i18n("Max and Min can not be equal.")); return false; } int new_n_bins = _w->N->text().toInt(); if (new_n_bins < 1) { KMessageBox::sorry(this, i18n("You must have one or more bins in a histogram.")); return false; } KstHsNormType new_norm_mode; if (_w->NormIsPercent->isChecked()) { new_norm_mode = KST_HS_PERCENT; } else if (_w->NormIsFraction->isChecked()) { new_norm_mode = KST_HS_FRACTION; } else if (_w->PeakIs1->isChecked()) { new_norm_mode = KST_HS_MAX_ONE; } else { new_norm_mode = KST_HS_NUMBER; } KstHistogramPtr hs; KST::vectorList.lock().readLock(); KstVectorPtr vp = *KST::vectorList.findTag(_w->_vector->selectedVector()); KST::vectorList.lock().unlock(); if (!vp) { kstdFatal() << "Bug in kst: the Vector field (Hs) refers to " << " a non existant vector..." << endl; } vp->readLock(); hs = new KstHistogram(tag_name, vp, new_min, new_max, new_n_bins, new_norm_mode); vp->unlock(); hs->setRealTimeAutoBin(_w->_realTimeAutoBin->isChecked()); KstVCurvePtr vc = new KstVCurve(KST::suggestCurveName(hs->tag(), true), hs->vX(), hs->vY(), 0L, 0L, 0L, 0L, _w->_curveAppearance->color()); vc->setHasPoints(_w->_curveAppearance->showPoints()); vc->setHasLines(_w->_curveAppearance->showLines()); vc->setHasBars(_w->_curveAppearance->showBars()); vc->pointType = _w->_curveAppearance->pointType(); vc->setLineWidth(_w->_curveAppearance->lineWidth()); vc->setLineStyle(_w->_curveAppearance->lineStyle()); vc->setBarStyle(_w->_curveAppearance->barStyle()); vc->setPointDensity(_w->_curveAppearance->pointDensity()); QString legend_text = _legendText->text(); if (legend_text == defaultTag) { vc->setLegendText(QString("")); } else { vc->setLegendText(legend_text); } KstViewWindow *w = dynamic_cast<KstViewWindow*>(KstApp::inst()->findWindow(_w->_curvePlacement->_plotWindow->currentText())); if (!w) { QString n = KstApp::inst()->newWindow(KST::suggestWinName()); w = static_cast<KstViewWindow*>(KstApp::inst()->findWindow(n)); } if (w) { Kst2DPlotPtr plot; if (_w->_curvePlacement->existingPlot()) { /* assign curve to plot */ plot = kst_cast<Kst2DPlot>(w->view()->findChild(_w->_curvePlacement->plotName())); if (plot) { plot->addCurve(vc.data()); } } if (_w->_curvePlacement->newPlot()) { /* assign curve to plot */ QString name = w->createObject<Kst2DPlot>(KST::suggestPlotName()); if (_w->_curvePlacement->reGrid()) { w->view()->cleanup(_w->_curvePlacement->columns()); } plot = kst_cast<Kst2DPlot>(w->view()->findChild(name)); if (plot) { _w->_curvePlacement->update(); _w->_curvePlacement->setCurrentPlot(plot->tagName()); plot->addCurve(vc.data()); plot->generateDefaultLabels(); } } } KST::dataObjectList.lock().writeLock(); KST::dataObjectList.append(hs.data()); KST::dataObjectList.append(vc.data()); KST::dataObjectList.lock().unlock(); hs = 0L; vc = 0L; emit modified(); return true; }
bool Differentiation::algorithm() { KstVectorPtr inputvector = inputVector(INPUTVECTOR); KstScalarPtr time_step = inputScalar(TIME_STEP); KstVectorPtr derivative = outputVector(DERIVATIVE); /* Memory allocation */ if (derivative->length() != inputvector->length()) { derivative->resize(inputvector->length(), true); } derivative->value()[0] = (inputvector->value()[1] - inputvector->value()[0]) / time_step->value(); int i = 1; for (; i < inputvector->length()-1; i++) { derivative->value()[i] = (inputvector->value()[i+1] - inputvector->value()[i-1])/(2*time_step->value()); } derivative->value()[i] = (inputvector->value()[i] - inputvector->value()[i-1]) / time_step->value(); return true; }
bool KstFilterDialogI::saveInputs(KstCPluginPtr plugin, KstSharedPtr<Plugin> p) { KST::vectorList.lock().readLock(); KST::scalarList.lock().readLock(); KST::stringList.lock().readLock(); const QValueList<Plugin::Data::IOValue>& itable = p->data()._inputs; for (QValueList<Plugin::Data::IOValue>::ConstIterator it = itable.begin(); it != itable.end(); ++it) { if ((*it)._type == Plugin::Data::IOValue::TableType) { if ((*it)._name == p->data()._filterInputVector) { KstVectorPtr v = *KST::vectorList.findTag(_yvector); if (v) { v->writeLock(); // to match with plugin->writeLock() } if (plugin->inputVectors().contains((*it)._name) && plugin->inputVectors()[(*it)._name] != v) { plugin->inputVectors()[(*it)._name]->unlock(); } plugin->inputVectors().insert((*it)._name, v); } else { QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.latin1(), "VectorSelector"); if (field) { VectorSelector *vs = static_cast<VectorSelector*>(field); KstVectorPtr v = *KST::vectorList.findTag(vs->selectedVector()); if (v) { v->writeLock(); // to match with plugin->writeLock() } if (plugin->inputVectors().contains((*it)._name) && plugin->inputVectors()[(*it)._name] != v) { plugin->inputVectors()[(*it)._name]->unlock(); } plugin->inputVectors().insert((*it)._name, v); } } } else if ((*it)._type == Plugin::Data::IOValue::StringType) { QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.latin1(), "StringSelector"); if (field) { StringSelector *ss = static_cast<StringSelector*>(field); KstStringPtr s = *KST::stringList.findTag(ss->selectedString()); if (s == *KST::stringList.end()) { QString val = ss->_string->currentText(); KstStringPtr newString = new KstString(ss->_string->currentText(), 0L, val, true, false); newString->writeLock(); // to match with plugin->writeLock() if (plugin->inputStrings().contains((*it)._name) && plugin->inputStrings()[(*it)._name] != newString) { plugin->inputStrings()[(*it)._name]->unlock(); } plugin->inputStrings().insert((*it)._name, newString); } else { s->writeLock(); // to match with plugin->writeLock() if (plugin->inputStrings().contains((*it)._name) && plugin->inputStrings()[(*it)._name] != s) { plugin->inputStrings()[(*it)._name]->unlock(); } plugin->inputStrings().insert((*it)._name, s); } } } else if ((*it)._type == Plugin::Data::IOValue::PidType) { // Nothing } else { QObject *field = _w->_pluginInputOutputFrame->child((*it)._name.latin1(), "ScalarSelector"); if (field) { ScalarSelector *ss = static_cast<ScalarSelector*>(field); KstScalarPtr s = *KST::scalarList.findTag(ss->selectedScalar()); if (s == *KST::scalarList.end()) { bool ok; double val = ss->_scalar->currentText().toDouble(&ok); if (ok) { KstScalarPtr newScalar = new KstScalar(ss->_scalar->currentText(), 0L, val, true, false, false); newScalar->writeLock(); // to match with plugin->writeLock() if (plugin->inputScalars().contains((*it)._name) && plugin->inputScalars()[(*it)._name] != newScalar) { plugin->inputScalars()[(*it)._name]->unlock(); } plugin->inputScalars().insert((*it)._name, newScalar); } else { s->writeLock(); // to match with plugin->writeLock() if (plugin->inputScalars().contains((*it)._name) && plugin->inputScalars()[(*it)._name] != s) { plugin->inputScalars()[(*it)._name]->unlock(); } plugin->inputScalars().insert((*it)._name, s); } } else { s->writeLock(); // to match with plugin->writeLock() if (plugin->inputScalars().contains((*it)._name) && plugin->inputScalars()[(*it)._name] != s) { plugin->inputScalars()[(*it)._name]->unlock(); } plugin->inputScalars().insert((*it)._name, s); } } } } KST::stringList.lock().unlock(); KST::scalarList.lock().unlock(); KST::vectorList.lock().unlock(); return true; }
void doTests() { KstVectorPtr vp = new KstVector(KstObjectTag("tempVector"), 10); for (int i = 0; i < 10; i++){ vp->value()[i] = i; } KstPSDPtr psd = new KstPSD(QString("psdTest"), vp, 0.0, false, 10, false, false, QString("vUnits"), QString("rUnits"), WindowUndefined, 0.0, PSDUndefined); doTest(psd->tagName() == "psdTest"); doTest(psd->vTag() == "tempVector"); doTest(psd->output() == PSDUndefined); doTest(!psd->apodize()); doTest(!psd->removeMean()); doTest(!psd->average()); doTest(psd->freq() == 0.0); doTest(psd->apodizeFxn() == WindowUndefined); doTest(psd->gaussianSigma() == 0); KstVectorPtr vpVX = psd->vX(); KstVectorPtr vpVY = psd->vY(); // until we call update the x and y vectors will be uninitialised and // and so they should be of length 1 and the value of vpVX[0] and // vpVX[0] should be NAN... doTestV(QString("vpVX->length()"), vpVX->length(), 1); doTestV(QString("vpVY->length()"), vpVY->length(), 1); doTestV(QString("vpVX->length()"), isnan(vpVX->value()[0]), 1); doTestV(QString("vpVY->length()"), isnan(vpVY->value()[0]), 1); doTest(psd->update(0) == KstObject::UPDATE); for(int j = 0; j < vpVX->length(); j++){ doTest(vpVX->value()[j] == 0); } psd->setOutput(PSDAmplitudeSpectralDensity); psd->setApodize(true); psd->setRemoveMean(true); psd->setAverage(true); psd->setFreq(0.1); psd->setApodizeFxn(WindowOriginal); psd->setGaussianSigma(0.2); doTest(psd->tagName() == "psdTest"); doTest(psd->vTag() == "tempVector"); doTest(psd->output() == PSDAmplitudeSpectralDensity); doTest(psd->apodize()); doTest(psd->removeMean()); doTest(psd->average()); doTest(psd->freq() == 0.1); doTest(psd->apodizeFxn() == WindowOriginal); doTest(psd->gaussianSigma() == 0.2); // doTest(psd->update(0) == KstObject::UPDATE); // QString ps = "PSD: " + psd->vTag(); // doTest(psd->propertyString() == ps); // doTest(!psd->curveHints().curveName() == ""); // printf("Curve name [%s]", kstCHL[0].curveName()); // printf("X Vector name [%s]", kstCHL[0].xVectorName()); // printf("Y Vector name [%s]", kstCHL[0].yVectorName()); KTempFile tf(locateLocal("tmp", "kst-csd"), "txt"); QFile *qf = tf.file(); QTextStream ts(qf); psd->save(ts, ""); QFile::remove(tf.name()); QDomNode n = makeDOMElement("psdDOMPsd", "psdDOMVector").firstChild(); QDomElement e = n.toElement(); KstPSDPtr psdDOM = new KstPSD(e); doTest(psdDOM->tagName() == "psdDOMPsd"); doTest(psdDOM->output() == PSDAmplitudeSpectralDensity); doTest(psdDOM->apodize()); doTest(psdDOM->removeMean()); doTest(psdDOM->average()); doTest(psdDOM->freq() == 128); doTest(psdDOM->apodizeFxn() == WindowOriginal); doTest(psdDOM->gaussianSigma() == 0.01); // KstVectorPtr vpVX = psdDOM->vX(); // for(int j = 0; j < vpVX->length(); j++){ // printf("[%d][%lf]", j, vpVX->value()[j]); // } // KstVectorPtr vpVY = psdDOM->vY(); }
bool Normalization::algorithm() { KstVectorPtr vectorIn = inputVector(VECTOR_IN); KstVectorPtr vectorOut = outputVector(VECTOR_OUT); double *arr; double *Yi; int iLength = vectorIn->length(); int w = 1; arr = new double[iLength]; Yi = new double[iLength]; for(int i=0; i<iLength; i++) { Yi[i] = vectorIn->value()[i]; } // // exclude peak values // for(int loop=0; loop<2; loop++) { for(int i=0; i<iLength; i++) { arr[i] = Yi[i]; } for(int i=0; i<iLength; i++) { if(isMin(Yi, i, iLength) || isMax(Yi, i, iLength)) { excludePts(arr, i, w, iLength); } } searchHighPts(arr, iLength); interpolate(Yi, arr, iLength); } // // do a piecewise linear fit // vectorOut->resize(iLength, false); int L = 3; double cof[2] = { 0.0, 0.0 }; for(int i=0; i<iLength; i=i+L) { fit(i, L, iLength, Yi, cof, vectorOut); } // // normalize // for(int i=0; i<iLength; i++) { vectorOut->value()[i] = vectorIn->value()[i] / vectorOut->value()[i]; } // // exclude off points // for(int i=0; i<iLength; i++) { if(vectorOut->value()[i] < 0.0 || vectorOut->value()[i] > 1.2) { vectorOut->value()[i] = NOPOINT; } } delete[] arr; delete[] Yi; return true; }
void doTests() { KstVectorPtr vp = new KstVector(KstObjectTag::fromString("tempVector"), 10); for (int i = 0; i < 10; i++){ vp->value()[i] = i; } KstPSDPtr psd = new KstPSD(QString("psdTest"), vp, 0.0, false, 10, false, false, QString("vUnits"), QString("rUnits"), WindowUndefined, 0.0, PSDUndefined); doTest(psd->tagName() == "psdTest"); doTest(psd->vTag() == "tempVector"); doTest(psd->output() == PSDUndefined); doTest(!psd->apodize()); doTest(!psd->removeMean()); doTest(!psd->average()); doTest(psd->freq() == 0.0); doTest(psd->apodizeFxn() == WindowUndefined); doTest(psd->gaussianSigma() == 0); KstVectorPtr vpVX = psd->vX(); KstVectorPtr vpVY = psd->vY(); doTest(vpVX->length() == 1); doTest(vpVX->value()[0] != vpVX->value()[0]); doTest(vpVY->length() == 1); doTest(vpVY->value()[0] != vpVY->value()[0]); psd->writeLock(); doTest(psd->update(0) == KstObject::UPDATE); psd->unlock(); for(int j = 0; j < vpVX->length(); j++){ doTest(vpVX->value()[j] == 0); } psd->setOutput(PSDAmplitudeSpectralDensity); psd->setApodize(true); psd->setRemoveMean(true); psd->setAverage(true); psd->setFreq(0.1); psd->setApodizeFxn(WindowOriginal); psd->setGaussianSigma(0.2); doTest(psd->tagName() == "psdTest"); doTest(psd->vTag() == "tempVector"); doTest(psd->output() == PSDAmplitudeSpectralDensity); doTest(psd->apodize()); doTest(psd->removeMean()); doTest(psd->average()); doTest(psd->freq() == 0.1); doTest(psd->apodizeFxn() == WindowOriginal); doTest(psd->gaussianSigma() == 0.2); // doTest(psd->update(0) == KstObject::UPDATE); // QString ps = "PSD: " + psd->vTag(); // doTest(psd->propertyString() == ps); // doTest(!psd->curveHints().curveName() == ""); // printf("Curve name [%s]", kstCHL[0].curveName()); // printf("X Vector name [%s]", kstCHL[0].xVectorName()); // printf("Y Vector name [%s]", kstCHL[0].yVectorName()); QTemporaryFile tf; tf.open(); QTextStream ts(&tf); psd->save(ts, ""); QFile::remove(tf.fileName()); QDomNode n = makeDOMElement("psdDOMPsd", "psdDOMVector").firstChild(); QDomElement e = n.toElement(); KstPSDPtr psdDOM = new KstPSD(e); doTest(psdDOM->tagName() == "psdDOMPsd"); doTest(psdDOM->output() == PSDAmplitudeSpectralDensity); doTest(psdDOM->apodize()); doTest(psdDOM->removeMean()); doTest(psdDOM->average()); doTest(psdDOM->freq() == 128); doTest(psdDOM->apodizeFxn() == WindowOriginal); doTest(psdDOM->gaussianSigma() == 0.01); // KstVectorPtr vpVX = psdDOM->vX(); // for(int j = 0; j < vpVX->length(); j++){ // printf("[%d][%lf]", j, vpVX->value()[j]); // } // KstVectorPtr vpVY = psdDOM->vY(); }