コード例 #1
0
void KstImageDialogI::placeInPlot(KstImagePtr image) {
  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 image to plot */
      plot = kst_cast<Kst2DPlot>(w->view()->findChild(_w->_curvePlacement->plotName()));
      if (plot) {
        plot->addCurve(KstBaseCurvePtr(image));
      }
    }

    if (_w->_curvePlacement->newPlot()) {
      /* assign image 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->setXScaleMode(AUTO);
        plot->setYScaleMode(AUTO);
        plot->addCurve(KstBaseCurvePtr(image));
        plot->generateDefaultLabels();
      }
    }
  }
}
コード例 #2
0
KstBindCurveCollection::KstBindCurveCollection(KJS::ExecState *exec, Kst2DPlotPtr p)
: KstBindCollection(exec, "CurveCollection", false) {
  _isPlot = true;
  p->readLock();
  _plot = p->tagName();
  p->readUnlock();
}
コード例 #3
0
bool KstTopLevelView::tiedZoom(bool x, double xmin, double xmax, bool y, double ymin, double ymax, const QString& plotName) {
  Kst2DPlotList pl = findChildrenType<Kst2DPlot>(true);
  bool repaint = false;
  for (Kst2DPlotList::Iterator i = pl.begin(); i != pl.end(); ++i) {
    Kst2DPlotPtr p = *i;
    if (p->isTied() && p->tagName() != plotName) {
      p->tiedZoom(x, xmin, xmax, y, ymin, ymax);
      repaint = true;
    }
  }
  return repaint;
}
コード例 #4
0
bool KstTopLevelView::tiedZoomMode(int zoom, bool flag, double center, int mode, int modeExtra, const QString& plotName) {
  Kst2DPlotList pl = findChildrenType<Kst2DPlot>(true);
  bool repaint = false;
  for (Kst2DPlotList::Iterator i = pl.begin(); i != pl.end(); ++i) {
    Kst2DPlotPtr p = *i;
    if (p->isTied() && p->tagName() != plotName) {
      p->tiedZoomMode((ZoomType)zoom, flag, center, (KstScaleModeType)mode, (KstScaleModeType)modeExtra);
      repaint = true;
    }
  }
  return repaint;
}
コード例 #5
0
bool KstTopLevelView::tiedZoomPrev(const QString& plotName) {
  Kst2DPlotList pl = findChildrenType<Kst2DPlot>(true);
  bool repaint = false;
  for (Kst2DPlotList::Iterator i = pl.begin(); i != pl.end(); ++i) {
    Kst2DPlotPtr p = *i;
    if (p->isTied() && p->tagName() != plotName) {
      if (p->tiedZoomPrev(widget())) {
        repaint = true;
      }
    }
  }
  return repaint;
}
コード例 #6
0
KstImagePtr KstCsdDialogI::createImage(KstCSDPtr csd) {
    KPalette* newPal = new KPalette(_w->_colorPalette->selectedPalette());
    csd->readLock();
    KstImagePtr image = new KstImage(csd->tagName()+"-I", csd->outputMatrix(), 0, 1, true, newPal);
    csd->unlock();

    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 image to plot */
            plot = kst_cast<Kst2DPlot>(w->view()->findChild(_w->_curvePlacement->plotName()));
            if (plot) {
                plot->addCurve(KstBaseCurvePtr(image));
            }
        }

        if (_w->_curvePlacement->newPlot()) {
            /* assign image 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(KstBaseCurvePtr(image));
                plot->generateDefaultLabels();
            }
        }
    }
    return image;
}
コード例 #7
0
bool KstEqDialogI::newObject() {
  QString tag_name = _tagName->text();
  QString etext = _w->_equation->text();
  etext.remove(QRegExp("[^a-zA-Z0-9\\(\\)\\+\\-\\*/\\%\\^\\|\\&\\!<>=_.]"));
  if (etext.length() > 12) {
    etext.truncate(12);
    etext += "...";
  }

  if (tag_name == defaultTag) {
    tag_name = KST::suggestEQName(etext);
  }

  /* verify that the curve name is unique */
  if (KstData::self()->dataTagNameNotUnique(tag_name)) {
    _tagName->setFocus();
    return false;
  }

  if (!checkEntries()) {
    return false;
  }

  KST::vectorList.lock().readLock();
  /* find *V */
  KstVectorPtr vp = *KST::vectorList.findTag(_w->_xVectors->selectedVector());
  if (!vp) {
    kstdFatal() << "Bug in kst: the Vector field (Eq) "
                << "refers to a non-existent vector..." << endl;
  }
  KST::vectorList.lock().unlock();

  /** Create the equation here */
  vp->readLock();
  KstEquationPtr eq = new KstEquation(tag_name, _w->_equation->text(), vp, _w->_doInterpolation->isChecked());
  vp->unlock();

  if (!eq->isValid()) {
    eq = 0L;
    QString parseErrors;
    for (QStringList::ConstIterator i = Equation::errorStack.begin(); i != Equation::errorStack.end(); ++i) {
      parseErrors += *i;
      parseErrors += "\n";
    }

    KMessageBox::detailedSorry(this, i18n("There is an error in the equation you entered."), parseErrors);
    return false;
  }

  KstVCurvePtr vc = new KstVCurve(KST::suggestCurveName(tag_name, true), eq->vX(), eq->vY(), 0L, 0L, 0L, 0L, _w->_curveAppearance->color());
  vc->setHasPoints(_w->_curveAppearance->showPoints());
  vc->setHasLines(_w->_curveAppearance->showLines());
  vc->setHasBars(_w->_curveAppearance->showBars());
  vc->setLineWidth(_w->_curveAppearance->lineWidth());
  vc->setLineStyle(_w->_curveAppearance->lineStyle());
  vc->pointType = _w->_curveAppearance->pointType();
  vc->setPointDensity(_w->_curveAppearance->pointDensity());
  vc->setBarStyle(_w->_curveAppearance->barStyle());
  
  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 = dynamic_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(eq.data());
  KST::dataObjectList.append(vc.data());
  KST::dataObjectList.lock().unlock();

  eq = 0L; // drop the reference before we update
  vc = 0L;
  emit modified();
  return true;
}
コード例 #8
0
bool KstPsdDialog::newObject() {
  QString tag_name = _tagName->text();
  bool retVal = false;

  if (tag_name == defaultTag) {
    tag_name = KST::suggestPSDName(KstObjectTag::fromString(_w->_vector->selectedVector()));
  }

  if (KstData::self()->dataTagNameNotUnique(tag_name)) {
    _tagName->setFocus();
    return false;
  }

  if (_w->_vector->selectedVector().isEmpty()) {
    QMessageBox::warning(this, QObject::tr("Kst"), QObject::tr("New spectrum not made: define vectors first."));
    return false;
  }

  KST::vectorList.lock().readLock();
  KstVectorPtr p = *KST::vectorList.findTag(_w->_vector->selectedVector());
  KST::vectorList.lock().unlock();

  if (_w->_kstFFTOptions->checkValues()) {
    if (p) {
      KstVCurvePtr vc;
      KstPSDPtr psd;
      QColor color;

      p->readLock();
      psd = new KstPSD(tag_name, p,
                       _w->_kstFFTOptions->SampRate->text().toDouble(),
                       _w->_kstFFTOptions->Interleaved->isChecked(),
                       _w->_kstFFTOptions->FFTLen->text().toInt(),
                       _w->_kstFFTOptions->Apodize->isChecked(),
                       _w->_kstFFTOptions->RemoveMean->isChecked(),
                       _w->_kstFFTOptions->VectorUnits->text(),
                       _w->_kstFFTOptions->RateUnits->text(),
                       ApodizeFunction(_w->_kstFFTOptions->ApodizeFxn->currentIndex()),
                       _w->_kstFFTOptions->Sigma->value(),
                       PSDType(_w->_kstFFTOptions->Output->currentIndex()));
      psd->setInterpolateHoles(_w->_kstFFTOptions->InterpolateHoles->isChecked());
      p->unlock();
  
// xxx      color = KstApp::inst()->chooseColorDlg()->getColorForCurve(psd->vX(), psd->vY());
      if (!color.isValid()) {
        color = _w->_curveAppearance->color();
      }

      vc = new KstVCurve(KST::suggestCurveName(psd->tag(),true), psd->vX(), psd->vY(), KstVectorPtr(), KstVectorPtr(), KstVectorPtr(), KstVectorPtr(), color);
      vc->setHasPoints(_w->_curveAppearance->showPoints());
      vc->setHasLines(_w->_curveAppearance->showLines());
      vc->setHasBars(_w->_curveAppearance->showBars());
      vc->setPointStyle(_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::null);
      } else {
        vc->setLegendText(legend_text);
      }
  
      Kst2DPlotPtr plot;
      KstViewWindow *w;
/* xxx
      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) {
        if (_w->_curvePlacement->existingPlot()) {
          plot = kst_cast<Kst2DPlot>(w->view()->findChild(_w->_curvePlacement->plotName()));
          if (plot) {
            plot->addCurve(vc);
          }
        }
  
        if (_w->_curvePlacement->newPlot()) {
          QString name = w->createPlot(KST::suggestPlotName());

          if (_w->_curvePlacement->reGrid()) {
            w->view()->cleanup(_w->_curvePlacement->columns());
          }
          plot = kst_cast<Kst2DPlot>(w->view()->findChild(name));
          if (plot) {
            plot->setXAxisInterpretation(false, KstAxisInterpretation(), KstAxisDisplay());
            plot->setYAxisInterpretation(false, KstAxisInterpretation(), KstAxisDisplay());
            _w->_curvePlacement->update();
            _w->_curvePlacement->setCurrentPlot(plot->tagName());
            plot->addCurve(vc);
            plot->generateDefaultLabels();
          }
        }
      }
      KST::dataObjectList.lock().writeLock();
      KST::dataObjectList.append(psd);
      KST::dataObjectList.append(vc);
      KST::dataObjectList.lock().unlock();

      psd = 0L;
      vc = 0L;

      emit modified();

      retVal = true;
    }
  }

  return retVal;
}
コード例 #9
0
bool KstHsDialog::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()) {
    QMessageBox::warning(this, QObject::tr("Kst"), QObject::tr("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) {
    QMessageBox::warning(this, QObject::tr("kst"), QObject::tr("Max and Min can not be equal."));
    return false;
  }

  int new_n_bins = _w->N->text().toInt();
  if (new_n_bins < 1) {
    QMessageBox::warning(this, QObject::tr("kst"), QObject::tr("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) {
    KstVCurvePtr vc;
    KstViewWindow *w;
    QColor color;

    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());
  
// xxx    color = KstApp::inst()->chooseColorDlg()->getColorForCurve(hs->vX(), hs->vY());
    if (!color.isValid()) {
      color = _w->_curveAppearance->color();
    }
    vc = new KstVCurve(KST::suggestCurveName(hs->tag(), true), hs->vX(), hs->vY(), KstVectorPtr(), KstVectorPtr(), KstVectorPtr(), KstVectorPtr(), color);
  
    vc->setHasPoints(_w->_curveAppearance->showPoints());
    vc->setHasLines(_w->_curveAppearance->showLines());
    vc->setHasBars(_w->_curveAppearance->showBars());
    vc->setPointStyle(_w->_curveAppearance->pointType());
    vc->setLineWidth(_w->_curveAppearance->lineWidth());
    vc->setLineStyle(_w->_curveAppearance->lineStyle());
    vc->setBarStyle(_w->_curveAppearance->barStyle());
    vc->setPointDensity(_w->_curveAppearance->pointDensity());
  
    QString legendText = _legendText->text();

    if (legendText == defaultTag) {
      vc->setLegendText(QString(""));
    } else {
      vc->setLegendText(legendText);
    }
/* xxx  
    w = dynamic_cast<KstViewWindow*>(KstApp::inst()->findWindow(_w->_curvePlacement->_plotWindow->currentText()));
*/
    if (!w) {
      QString n = KstApp::inst()->newWindow(KST::suggestWinName());

// xxx      w = static_cast<KstViewWindow*>(KstApp::inst()->findWindow(n));
    }
    
    if (w) {
      Kst2DPlotPtr plot;
    
      if (_w->_curvePlacement->existingPlot()) {
        plot = kst_cast<Kst2DPlot>(w->view()->findChild(_w->_curvePlacement->plotName()));
        if (plot) {
          plot->addCurve(vc);
        }
      }
  
      if (_w->_curvePlacement->newPlot()) {
        QString name = w->createPlot(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);
          plot->generateDefaultLabels();
        }
      }
    }
  
    KST::dataObjectList.lock().writeLock();
    KST::dataObjectList.append(hs);
    KST::dataObjectList.append(vc);
    KST::dataObjectList.lock().unlock();
  
    hs = 0L;
    vc = 0L;

    emit modified();
  }

  return true;
}
コード例 #10
0
/* returns true if succesful */
bool KstPsdDialogI::newObject() {
  QString tag_name = _tagName->text();
  if (tag_name == defaultTag) {
    tag_name = KST::suggestPSDName(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 PSD not made: define vectors first."));
    return false;
  }

  KST::vectorList.lock().readLock();
  KstVectorPtr p = *KST::vectorList.findTag(_w->_vector->selectedVector());
  KST::vectorList.lock().unlock();
  if (!p) {
    kstdFatal() << "Bug in kst: the vector field (PSD) refers to "
                << "a non existant vector...." << endl;
  }

  // create the psd curve
  if (!_w->_kstFFTOptions->checkValues()) {
    return false;
  } else {
    p->readLock();
    KstPSDPtr psd = new KstPSD(tag_name, p,
                            _w->_kstFFTOptions->SampRate->text().toDouble(),
                            _w->_kstFFTOptions->Interleaved->isChecked(),
                            _w->_kstFFTOptions->FFTLen->text().toInt(),
                            _w->_kstFFTOptions->Apodize->isChecked(),
                            _w->_kstFFTOptions->RemoveMean->isChecked(),
                            _w->_kstFFTOptions->VectorUnits->text(),
                            _w->_kstFFTOptions->RateUnits->text(),
                            ApodizeFunction(_w->_kstFFTOptions->ApodizeFxn->currentItem()),
                            _w->_kstFFTOptions->Sigma->value(),
                            PSDType(_w->_kstFFTOptions->Output->currentItem()));
    psd->setInterpolateHoles(_w->_kstFFTOptions->InterpolateHoles->isChecked());
    p->unlock();

    KstVCurvePtr vc = new KstVCurve(KST::suggestCurveName(psd->tag(),true), psd->vX(), psd->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::null);
    } else {
      vc->setLegendText(legend_text);
    }

    Kst2DPlotPtr plot;
    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) {
      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) {
          plot->setXAxisInterpretation(false, KstAxisInterpretation(), KstAxisDisplay());
          plot->setYAxisInterpretation(false, KstAxisInterpretation(), KstAxisDisplay());
          _w->_curvePlacement->update();
          _w->_curvePlacement->setCurrentPlot(plot->tagName());
          plot->addCurve(vc.data());
          plot->generateDefaultLabels();
        }
      }
    }
    KST::dataObjectList.lock().writeLock();
    KST::dataObjectList.append(psd.data());
    KST::dataObjectList.append(vc.data());
    KST::dataObjectList.lock().unlock();
    psd = 0L;
    vc = 0L;
    emit modified();
  }
  return true;
}
コード例 #11
0
bool KstEqDialog::newObject() {
  QString tag_name = _tagName->text();
  QString etext = _w->_equation->text();

  etext.remove(QRegExp("[^a-zA-Z0-9\\(\\)\\+\\-\\*/\\%\\^\\|\\&\\!<>=_.]"));
  etext.replace(KstObjectTag::tagSeparator, KstObjectTag::tagSeparatorReplacement);
  if (etext.length() > 12) {
    etext.truncate(12);
    etext += "...";
  }

  if (tag_name == defaultTag) {
    tag_name = KST::suggestEQName(etext);
  }

  if (KstData::self()->dataTagNameNotUnique(tag_name)) {
    _tagName->setFocus();
    return false;
  }

  if (!checkEntries()) {
    return false;
  }

  KST::vectorList.lock().readLock();
  KstVectorPtr vp = *KST::vectorList.findTag(_w->_xVectors->selectedVector());
  if (vp) {
    KST::vectorList.lock().unlock();
  
    KstEquationPtr eq;

    eq = new KstEquation(tag_name, _w->_equation->text(), vp, _w->_doInterpolation->isChecked());
  
    if (!eq->isValid()) {
      QStringList::const_iterator i;
      QString strWarning = QObject::tr("There is an error in the equation you entered.\n");
  
      eq = 0L;
  
      for (i = Equation::errorStack.begin(); i != Equation::errorStack.end(); ++i) {
        strWarning += *i;
        strWarning += "\n";
      }
  
      QMessageBox::warning(this, QObject::tr("Kst"), strWarning);

      return false;
    }
  
    KstVCurvePtr vc;
    QColor color;

// xxx    color = KstApp::inst()->chooseColorDlg()->getColorForCurve(eq->vX(), eq->vY());
    if (!color.isValid()) {
      color = _w->_curveAppearance->color();
    }

    vc = new KstVCurve(KST::suggestCurveName(eq->tag(), true), eq->vX(), eq->vY(), KstVectorPtr(), KstVectorPtr(), KstVectorPtr(), KstVectorPtr(), color);
    vc->setHasPoints(_w->_curveAppearance->showPoints());
    vc->setHasLines(_w->_curveAppearance->showLines());
    vc->setHasBars(_w->_curveAppearance->showBars());
    vc->setLineWidth(_w->_curveAppearance->lineWidth());
    vc->setLineStyle(_w->_curveAppearance->lineStyle());
    vc->setPointStyle(_w->_curveAppearance->pointType());
    vc->setPointDensity(_w->_curveAppearance->pointDensity());
    vc->setBarStyle(_w->_curveAppearance->barStyle());
  
    QString legend_text = _legendText->text();
    if (legend_text == defaultTag) {
      vc->setLegendText(QString(""));
    } else {
      vc->setLegendText(legend_text);
    }
  
    KstViewWindow *w;
/* xxx
    w = dynamic_cast<KstViewWindow*>(KstApp::inst()->findWindow(_w->_curvePlacement->_plotWindow->currentText()));
    if (!w) {
      QString n = KstApp::inst()->newWindow(KST::suggestWinName());

      w = dynamic_cast<KstViewWindow*>(KstApp::inst()->findWindow(n));
    }
*/  
    if (w) {
      Kst2DPlotPtr plot;

      if (_w->_curvePlacement->existingPlot()) {
        plot = kst_cast<Kst2DPlot>(w->view()->findChild(_w->_curvePlacement->plotName()));
        if (plot) {
          plot->addCurve(vc);
        }
      }
  
      if (_w->_curvePlacement->newPlot()) {
        QString name = w->createPlot(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);
          plot->generateDefaultLabels();
        }
      }
    }
  
    KST::dataObjectList.lock().writeLock();
    KST::dataObjectList.append(eq);
    KST::dataObjectList.append(vc);
    KST::dataObjectList.lock().unlock();
  
    //
    // drop the reference before we update...
    //

    eq = 0L; 
    vc = 0L;

    emit modified();
  }

  return true;
}