Пример #1
0
void KstDataManagerI::contextMenu(QListViewItem *i, const QPoint& p, int col) {
  Q_UNUSED(col)
  KstObjectItem *koi = static_cast<KstObjectItem*>(i);
  KstBaseCurve *c;

  if (koi->rtti() == RTTI_OBJ_OBJECT || koi->rtti() == RTTI_OBJ_DATA_VECTOR) {
    KPopupMenu *m = new KPopupMenu(this);

    m->setTitle(koi->text(0));

    int id = m->insertItem(i18n("&Edit..."), this, SLOT(edit_I()));
    //m->setItemEnabled(id, RTTI_OBJ_VECTOR != koi->rtti());

    if (koi->rtti() == RTTI_OBJ_DATA_VECTOR) {
      id = m->insertItem(i18n("&Make Curve..."), koi, SLOT(makeCurve()));
    } else if ((c = dynamic_cast<KstBaseCurve*>(koi->dataObject().data()))) {
      KPopupMenu *addMenu = new KPopupMenu(this);
      KPopupMenu *removeMenu = new KPopupMenu(this);
      PlotMap.clear();
      id = 100;
      bool haveAdd = false, haveRemove = false;
      for (KstPlot *p = KST::plotList.first(); p; p = KST::plotList.next()) {
        if (!p->Curves.contains(c)) {
          addMenu->insertItem(p->tagName(), koi, SLOT(addToPlot(int)), 0, id);
          haveAdd = true;
        } else {
Пример #2
0
const QString& KstIfaceImpl::createPlot(const QString& name) {
  QString n = name;

  if (KST::plotList.FindKstPlot(n)) {
    n = KST::plotList.generatePlotName();
  }

  KstPlot *p = new KstPlot(n);
  KST::plotList.append(p);
  _doc->forceUpdate();
  _doc->setModified();
  KST::plotList.arrangePlots(KST::plotList.getPlotCols());

  return p->tagName();
}
Пример #3
0
void KstPsdDialogI::new_I() {
  KstPSDCurvePtr curve;
  double new_freq;
  int new_len;

  QString tag_name = Select->currentText();
  tag_name.replace(i18n("<New_PSD>"), "PSD_" + _vector->selectedVector());

  /* verify that the curve name is unique */
  if (KST::dataTagNameNotUnique(tag_name)) {
    Select->setFocus();
    return;
  }

  if (_vector->selectedVector().isEmpty()) {
    KMessageBox::sorry(0L, i18n("New PSD not made: define vectors first."));
    return;
  }

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

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

  {
    KST::vectorList.lock().readLock();
    KstVectorList::Iterator i = KST::vectorList.findTag(_vector->selectedVector());
    if (i == KST::vectorList.end()) {
      kdFatal() << "Bug in kst: the vector field in plotDialog (PSD) refers to "
                << "a non existant vector...." << endl;
    }

    KstVectorPtr p = *i;
    KST::vectorList.lock().readUnlock();

    /* create the psd curve */
    curve = new KstPSDCurve(tag_name, p, new_freq, new_len,
                            VectorUnits->text(), RateUnits->text(),
                            _curveAppearance->color());
  }

  curve->setHasPoints(_curveAppearance->showPoints());
  curve->setHasLines(_curveAppearance->showLines());
  curve->Point.setType(_curveAppearance->pointType());
  curve->setAppodize(Appodize->isChecked());
  curve->setRemoveMean(RemoveMean->isChecked());

  KstPlot *plot = 0L;
  if (_curvePlacement->existingPlot()) {
    /* assign curve to plot */
    plot = KST::plotList.FindKstPlot(_curvePlacement->plotName());
    plot->addCurve(curve);
  }
  if (_curvePlacement->newPlot()) {
    /* assign curve to plot */
    plot = KST::plotList.addPlot(QString::null, _curvePlacement->columns());
    _curvePlacement->appendPlot(plot->tagName(), true);
    plot->addCurve(curve);
    plot->GenerateDefaultLabels();
  }

  KST::dataObjectList.lock().writeLock();
  KST::dataObjectList.append(curve.data());
  KST::dataObjectList.lock().writeUnlock();
  curve = 0L;
  emit modified();
}
Пример #4
0
void KstQuickPSDDialogI::addPlot() {
  KstPlot *plot = KST::plotList.addPlot(QString::null, PlotCols->value());
  PlotList->insertItem(plot->tagName());
  PlotList->setCurrentItem(PlotList->count()-1);
  apply(true);
}
Пример #5
0
void KstCurveDialogI::new_I() {
  KstWriteLocker ml(&KST::vectorList.lock());
  KstVectorList::Iterator VX, VY;
  KstVectorList::Iterator EX, EY;
  KstVCurvePtr curve;
  KstPlot *plot;

  if (_xVector->selectedVector().isEmpty()) {
    KMessageBox::sorry(0L, i18n("New curve not made: define vectors first."));
    return;
  }

  /* find VX and VY */
  VX = KST::vectorList.findTag(_xVector->selectedVector());
  VY = KST::vectorList.findTag(_yVector->selectedVector());
  EX = KST::vectorList.findTag(_xError->selectedVector());
  EY = KST::vectorList.findTag(_yError->selectedVector());
  if (VX == KST::vectorList.end() || VY == KST::vectorList.end()) {
    kdFatal() << "Bug in kst: the XVector field in plotDialog refers to "
              << "a non existant vector...." << endl;
  }

  KstReadLocker rl1(*VX), rl2(*VY);

  QString tag_name = Select->currentText();
  tag_name.replace(i18n("<New_Curve>"), (*VY)->tagName());

  /* verify that the curve name is unique */
  if (KST::dataTagNameNotUnique(tag_name)) {
    return;
  }

  /* create the curve */
  curve = new KstVCurve(tag_name, *VX, *VY,
                        EX != KST::vectorList.end() ? *EX : KstVectorPtr(0L),
                        EY != KST::vectorList.end() ? *EY : KstVectorPtr(0L),
                        _curveAppearance->color());
  curve->setHasPoints(_curveAppearance->showPoints());
  curve->setHasLines(_curveAppearance->showLines());
  curve->Point.setType(_curveAppearance->pointType());

  if (_curvePlacement->existingPlot()) {
    /* assign curve to plot */
    plot = KST::plotList.FindKstPlot(_curvePlacement->plotName());
    plot->addCurve(curve);
  }

  if (_curvePlacement->newPlot()) {
    /* assign curve to plot */
    plot = KST::plotList.addPlot(QString::null, _curvePlacement->columns());
    _curvePlacement->appendPlot(plot->tagName(), true);
    plot->addCurve(curve);
    plot->GenerateDefaultLabels();
  }

  KST::dataObjectList.lock().readLock();
  KST::dataObjectList.append(curve.data());
  KST::dataObjectList.lock().writeUnlock();
  curve = 0L;
  emit modified();
}