Ejemplo n.º 1
0
void KstPsdDialogI::delete_I() {
  int index, i_plot, i_curve;
  KstPSDCurvePtr curve;
  KstPlot *plot;

  index = Select->currentItem();
  if (index < 0) {
    KMessageBox::sorry(0L, i18n("You need to select an active PSD to delete."));
    return;
  }

  KstPSDCurveList curves = kstObjectSubList<KstDataObject, KstPSDCurve>(KST::dataObjectList);
  curve = curves[index];
  if (curve->slaveVectorsUsed()) {
    KMessageBox::sorry(0L, i18n("Cannot delete: This PSD is used by at least one curve. Delete curves first."));
    return;
  }

  /* delete the curve from all plots */
  for (i_plot = 0; i_plot<(int)KST::plotList.count(); i_plot++) {
    plot = KST::plotList.at(i_plot);
    for (i_curve=0; i_curve<(int)plot->Curves.count(); i_curve++) {
      if (plot->Curves[i_curve]->tagName() == curve->tagName()) {
        plot->Curves.remove(plot->Curves[i_curve]);
        i_curve--;
      }
    }
  }

  /* delete the curve */
  KST::dataObjectList.remove(curve.data());
  curve = 0L;
  curves.clear();
  emit modified();
}
Ejemplo n.º 2
0
void KstPsdDialogI::edit_I() {
  int index;
  KstPSDCurvePtr curve;
  double new_freq;
  int new_len;

  index = Select->currentItem();
  KstPSDCurveList curves = kstObjectSubList<KstDataObject, KstPSDCurve>(KST::dataObjectList);
  if (index < 0 || unsigned(index) >= curves.count()) {
    new_I();
    return;
  }
  curve = curves[index];

  /* verify that the curve name is unique */
  QString tag_name = Select->currentText();

  if (tag_name != curve->tagName()) {
    if (KST::dataTagNameNotUnique(tag_name)) {
      Select->setFocus();
      return;
    }
  }
  curve->setTagName(tag_name);
  KST::vectorList.lock().readLock();
  curve->setVector(*KST::vectorList.findTag(_vector->selectedVector()));
  KST::vectorList.lock().readUnlock();

  curve->setColor(_curveAppearance->color());
  curve->setHasPoints(_curveAppearance->showPoints());
  curve->setHasLines(_curveAppearance->showLines());
  curve->Point.setType(_curveAppearance->pointType());

  /* find new_freq */
  new_freq = SampRate->text().toDouble();
  if (new_freq <= 0) {
    KMessageBox::sorry(NULL, i18n("The sample rate must be greater than 0"));
    return;
  }

  /* find new_len */
  new_len = FFTLen->text().toInt();
  if (new_len<2) {
    KMessageBox::sorry(NULL, i18n("The FFT length must be greater than 2^2"));
    return;
  }

  curve->setFreq(new_freq);
  curve->setLen(new_len);

  curve->VUnits = VectorUnits->text();
  curve->RUnits = RateUnits->text();

  curve->setAppodize(Appodize->isChecked());
  curve->setRemoveMean(RemoveMean->isChecked());

  curve->update();
  curve = 0L;
  curves.clear();
  emit modified();
}