Esempio n. 1
0
QStringList KstIfaceImpl::createPowerSpectrum(const QString& name,
                                              const QString& vector,
                                              bool appodize,
                                              bool removeMean,
                                              int fftLength,
                                              const QString& rateUnits,
                                              double sampleRate,
                                              const QString& vectorUnits)
{
  //get the vector
  KST::vectorList.lock().readLock();
  KstVectorList::Iterator iter = KST::vectorList.findTag(vector);
  KST::vectorList.lock().unlock();

  if (iter == KST::vectorList.end()) {
    return QStringList();
  }

  //suggest a name if not supplied
  QString pstag_end;
  if (name.isEmpty())
    pstag_end = vector;
  else
    pstag_end = name;

  //count number of power spectra and make a unique name
  KstPSDList pslist = kstObjectSubList<KstDataObject,KstPSD>(KST::dataObjectList);
  int i = pslist.count() + 1;
  QString stringnum = QString::number(i);

  QString pstag = stringnum + "-" + pstag_end;

  while (KstData::self()->dataTagNameNotUnique(pstag, false)) {
    stringnum.setNum(++i);
    pstag = stringnum + "-" + pstag_end;
  }

  KstPSDPtr powerspectrum = new KstPSD(pstag, *iter, sampleRate, true, fftLength,
                                       appodize, removeMean, vectorUnits, rateUnits, WindowOriginal);
  
  KST::dataObjectList.lock().writeLock();
  KST::dataObjectList.append(KstDataObjectPtr(powerspectrum));
  KST::dataObjectList.lock().unlock();
  
  QStringList returnList;
  returnList.push_back(powerspectrum->tagName());
  returnList.push_back(powerspectrum->xVTag());
  returnList.push_back(powerspectrum->yVTag());
  
  _doc->forceUpdate();
  _doc->setModified();
  
  return returnList;
}
Esempio n. 2
0
void KstPsdDialog::populateEditMultiple() {
  KstPSDList pslist;

  pslist = kstObjectSubList<KstDataObject,KstPSD>(KST::dataObjectList);
  _editMultipleWidget->_objectList->insertItems(0, pslist.tagNames());

  //
  // also intermediate state for multiple edit...
  //

  _w->_vector->_vector->insertItem(0, "");
  _w->_vector->_vector->setCurrentIndex(0);
  _w->_kstFFTOptions->ApodizeFxn->insertItem(0, "");
  _w->_kstFFTOptions->ApodizeFxn->setCurrentIndex(0);
  _w->_kstFFTOptions->Apodize->setChecked(Qt::PartiallyChecked);
  _w->_kstFFTOptions->RemoveMean->setChecked(Qt::PartiallyChecked);
  _w->_kstFFTOptions->Interleaved->setChecked(Qt::PartiallyChecked);
  _w->_kstFFTOptions->InterpolateHoles->setChecked(Qt::PartiallyChecked);
  _w->_kstFFTOptions->SampRate->setText("");
  _w->_kstFFTOptions->VectorUnits->setText("");
  _w->_kstFFTOptions->RateUnits->setText("");
  _w->_kstFFTOptions->FFTLen->setMinimum(_w->_kstFFTOptions->FFTLen->minimum() - 1);
  _w->_kstFFTOptions->FFTLen->setSpecialValueText(" ");
  _w->_kstFFTOptions->FFTLen->setValue(_w->_kstFFTOptions->FFTLen->minimum());
  _w->_kstFFTOptions->Sigma->setMinimum(_w->_kstFFTOptions->Sigma->minimum() - 0.01);
  _w->_kstFFTOptions->Sigma->setSpecialValueText(" ");
  _w->_kstFFTOptions->Sigma->setValue(_w->_kstFFTOptions->Sigma->minimum());
  _w->_kstFFTOptions->Output->insertItem(0, "");
  _w->_kstFFTOptions->Output->setCurrentIndex(0);

  _tagName->setText("");
  _tagName->setEnabled(false);

  _vectorDirty = false;
  _apodizeDirty = false;
  _apodizeFxnDirty = false;
  _gaussianSigmaDirty = false;
  _removeMeanDirty = false;
  _interleavedDirty = false;
  _sampRateDirty = false;
  _vectorUnitsDirty = false;
  _rateUnitsDirty = false;
  _fFTLenDirty = false;
  _outputDirty = false;
  _interpolateHolesDirty = false;
}
Esempio n. 3
0
void KstPsdDialogI::populateEditMultiple() {
  KstPSDList pslist = kstObjectSubList<KstDataObject,KstPSD>(KST::dataObjectList);
  _editMultipleWidget->_objectList->insertStringList(pslist.tagNames());

  // also intermediate state for multiple edit
  _w->_vector->_vector->insertItem("", 0);
  _w->_vector->_vector->setCurrentItem(0);
  _w->_kstFFTOptions->ApodizeFxn->insertItem("", 0);
  _w->_kstFFTOptions->ApodizeFxn->setCurrentItem(0);
  _w->_kstFFTOptions->Apodize->setNoChange();
  _w->_kstFFTOptions->RemoveMean->setNoChange();
  _w->_kstFFTOptions->Interleaved->setNoChange();
  _w->_kstFFTOptions->InterpolateHoles->setNoChange();
  _w->_kstFFTOptions->SampRate->setText("");
  _w->_kstFFTOptions->VectorUnits->setText("");
  _w->_kstFFTOptions->RateUnits->setText("");
  _w->_kstFFTOptions->FFTLen->setMinValue(_w->_kstFFTOptions->FFTLen->minValue() - 1);
  _w->_kstFFTOptions->FFTLen->setSpecialValueText(" ");
  _w->_kstFFTOptions->FFTLen->setValue(_w->_kstFFTOptions->FFTLen->minValue());
  _w->_kstFFTOptions->Sigma->setMinValue(_w->_kstFFTOptions->Sigma->minValue() - 0.01);
  _w->_kstFFTOptions->Sigma->setSpecialValueText(" ");
  _w->_kstFFTOptions->Sigma->setValue(_w->_kstFFTOptions->Sigma->minValue());
  _w->_kstFFTOptions->Output->insertItem("", 0);
  _w->_kstFFTOptions->Output->setCurrentItem(0);
  
  _tagName->setText("");
  _tagName->setEnabled(false);

  // and clean all the fields
  _vectorDirty = false;
  _apodizeDirty = false;
  _apodizeFxnDirty = false;
  _gaussianSigmaDirty = false;
  _removeMeanDirty = false;
  _interleavedDirty = false;
  _sampRateDirty = false;
  _vectorUnitsDirty = false;
  _rateUnitsDirty = false;
  _fFTLenDirty = false;
  _outputDirty = false;
  _interpolateHolesDirty = false;
}
Esempio n. 4
0
bool KstPsdDialog::editObject() {
  KstPSDList psList;

  //
  // if the user selected no vector, treat it as non-dirty...
  //

  _vectorDirty = _w->_vector->_vector->currentIndex() != 0;
  _apodizeFxnDirty = _w->_kstFFTOptions->ApodizeFxn->currentIndex() != 0;
  _fFTLenDirty = _w->_kstFFTOptions->FFTLen->text() != " ";
  _sampRateDirty = !_w->_kstFFTOptions->SampRate->text().isEmpty();
  _vectorUnitsDirty = !_w->_kstFFTOptions->VectorUnits->text().isEmpty();
  _rateUnitsDirty = !_w->_kstFFTOptions->RateUnits->text().isEmpty();
  _outputDirty = _w->_kstFFTOptions->Output->currentIndex() != 0;
  psList = kstObjectSubList<KstDataObject,KstPSD>(KST::dataObjectList);

  if (_editMultipleMode) { 
    bool didEdit = false;
    int i;

    for (i = 0; i < _editMultipleWidget->_objectList->count(); i++) {
      if (_editMultipleWidget->_objectList->item(i)->isSelected()) {
        KstPSDList::Iterator psIter;
        KstPSDPtr psPtr;

        psIter = psList.findTag(_editMultipleWidget->_objectList->item(i)->text());
        if (psIter == psList.end()) {
          return false;
        }

        psPtr = *psIter;

        if (!editSingleObject(psPtr)) {
          return false;
        }
        didEdit = true;
      }
    } 
    if (!didEdit) {
      QMessageBox::warning(this, QObject::tr("Kst"), QObject::tr("Select one or more objects to edit."));
      return false;  
    }
  } else {
    KstPSDPtr pp;
    QString tag_name;

    pp = kst_cast<KstPSD>(_dp);
    tag_name = _tagName->text();

    if (!pp || (tag_name != pp->tagName() && KstData::self()->dataTagNameNotUnique(tag_name))) {
      _tagName->setFocus();
      return false;
    }

    pp->writeLock();
    pp->setTagName(tag_name);
    pp->unlock();

    // then edit the object
    _vectorDirty = true;
    _apodizeDirty = true;
    _apodizeFxnDirty = true;
    _gaussianSigmaDirty = true;
    _removeMeanDirty = true;
    _interleavedDirty = true;
    _sampRateDirty = true;
    _vectorUnitsDirty = true;
    _rateUnitsDirty = true;
    _fFTLenDirty = true;
    _outputDirty = true;
    _interpolateHolesDirty = true;
    if (!editSingleObject(pp)) {
      return false;
    }
  }

  emit modified();

  return true;
}
Esempio n. 5
0
// returns true if succesful
bool KstPsdDialogI::editObject() {
  // if the user selected no vector, treat it as non-dirty
  _vectorDirty = _w->_vector->_vector->currentItem() != 0;
  _apodizeDirty = _w->_kstFFTOptions->ApodizeFxn->currentItem() != 0;
  _fFTLenDirty = _w->_kstFFTOptions->FFTLen->text() != " ";
  _sampRateDirty = !_w->_kstFFTOptions->SampRate->text().isEmpty();
  _vectorUnitsDirty = !_w->_kstFFTOptions->VectorUnits->text().isEmpty();
  _rateUnitsDirty = !_w->_kstFFTOptions->RateUnits->text().isEmpty();
  _outputDirty = !_w->_kstFFTOptions->Output->currentItem() != 0;
  KstPSDList psList = kstObjectSubList<KstDataObject,KstPSD>(KST::dataObjectList);
  
  // if editing multiple objects, edit each one
  if (_editMultipleMode) { 
    bool didEdit = false;
    for (uint i = 0; i < _editMultipleWidget->_objectList->count(); i++) {
      if (_editMultipleWidget->_objectList->isSelected(i)) {
        // get the pointer to the object
        KstPSDList::Iterator psIter = psList.findTag(_editMultipleWidget->_objectList->text(i));
        if (psIter == psList.end()) {
          return false;
        }
          
        KstPSDPtr psPtr = *psIter;
        
        if (!editSingleObject(psPtr)) {
          return false;
        }
        didEdit = true;
      }
    } 
    if (!didEdit) {
      KMessageBox::sorry(this, i18n("Select one or more objects to edit."));
      return false;  
    }
  } else {
    KstPSDPtr pp = kst_cast<KstPSD>(_dp);
    // verify that the name is unique
    QString tag_name = _tagName->text();
    if (!pp || (tag_name != pp->tagName() && KstData::self()->dataTagNameNotUnique(tag_name))) {
      _tagName->setFocus();
      return false;
    }
    
    pp->writeLock();
    pp->setTagName(KstObjectTag(tag_name, pp->tag().context())); // FIXME: doesn't allow changing tag context
    pp->unlock();
    
    // then edit the object
    _vectorDirty = true;
    _apodizeDirty = true;
    _apodizeFxnDirty = true;
    _gaussianSigmaDirty = true;
    _removeMeanDirty = true;
    _interleavedDirty = true;
    _sampRateDirty = true;
    _vectorUnitsDirty = true;
    _rateUnitsDirty = true;
    _fFTLenDirty = true;
    _outputDirty = true;
    _interpolateHolesDirty = true;
    if (!editSingleObject(pp)) {
      return false;
    }
  }
  emit modified();
  return true;
}