Ejemplo n.º 1
0
void KstFilterDialogI::show_setCurve(const QString& curveName,
                                  const QString& plotName,
                                  const QString& window) {

  KstBaseCurveList curves = kstObjectSubList<KstDataObject, KstBaseCurve>(KST::dataObjectList);
  KstVCurveList vcurves = kstObjectSubList<KstBaseCurve, KstVCurve>(curves);
  _window   = window;
  _plotName = plotName;
  _curve    = curveName;

  // it should be impossible for the curve not to exist so this should
  // always be true.  If it is false, we do not properly take care of it,
  // here and bad things will happen....
  KstVCurvePtr curve = *vcurves.findTag(curveName);
  if (curve) {
    curve->readLock();
    _xvector = curve->xVTag().displayString();
    _yvector = curve->yVTag().displayString();
    curve->unlock();
  }
  show();
}
Ejemplo n.º 2
0
void KstCurveDialogI::update(int new_index) {
  int i_curve;
  KstVCurvePtr curve;
  int index;
  bool isNew = false;
  int n_v, n_c;

  KstVCurveList curves = kstObjectSubList<KstDataObject, KstVCurve>(KST::dataObjectList);

  if (new_index == -1) {
    if (curves.findTag(Select->currentText()) != curves.end()) {
      QString save = Select->currentText();
      Select->blockSignals(true);
      Select->clear();
      for (KstVCurveList::iterator i = curves.begin(); i != curves.end(); ++i) {
        Select->insertItem((*i)->tagName());
      }
      Select->setCurrentText(save);
      Select->blockSignals(false);
      return;
    }
  }

  /**********************/
  /* initialize indexes */
  KST::vectorList.lock().readLock();
  n_v = KST::vectorList.count();
  KST::vectorList.lock().readUnlock();
  n_c = curves.count();
  if (new_index == -2) { // initialize for new curve
    isNew = true;
    index = n_c;
  } else if (n_c < 1) {
    isNew = true;
    index = 0;
  } else if (new_index >= 0 && new_index < n_c) { // initialize specific curve
    index = new_index;
  } else if (Select->count() > 0) { // initialize for old default
    index = Select->currentItem();
  } else { // initialize for last in list
    index = n_c - 1;
  }

  /*****************************************/
  /* fill the Select combo with curve tags */
  Select->clear();
  for (KstVCurveList::iterator i = curves.begin(); i != curves.end(); ++i) {
    Select->insertItem((*i)->tagName());
  }

  if (isNew) {
    QString new_label;
    new_label.sprintf("C%d-", curves.count()+1);
    new_label += i18n("<New_Curve>");

    Select->insertItem(new_label);
  }
  if ((index>=0) && (index<Select->count())) {
    Select->setCurrentItem(index);
  }

  /*******************************************/
  /* fill the Vector lists with vector names */
  _xVector->update();
  _yVector->update();
  _xError->update();
  _yError->update();

  /***********************************/
  /* set the curve placement window  */
  _curvePlacement->setPlotList(KST::plotList.tagNames(), true);
  _curvePlacement->setColumns(KST::plotList.getPlotCols());

  if (isNew) {
    // guess what placement option is wanted
    if (!KST::plotList.isEmpty() && curves.count() > KST::plotList.count()) {
      _curvePlacement->setNewPlot(false);
      _curvePlacement->setExistingPlot(true);
    } else {
      _curvePlacement->setNewPlot(true);
      _curvePlacement->setExistingPlot(false);
    }
  }

  /****************************************************/
  /* set the vector pull downs to the correct vectors */
  if (n_c > 0 && !isNew) {
    i_curve = Select->currentItem();
    curve = curves[i_curve];

    _xVector->setSelection(curve->getXVTag());
    _yVector->setSelection(curve->getYVTag());
    _xError->setSelection(curve->getXETag());
    _yError->setSelection(curve->getYETag());

    _curveAppearance->setValue(curve->hasLines(), curve->hasPoints(), curve->getColor(), curve->Point.getType());
    Delete->setEnabled(curve->getUsage() == 2);
  } else { /* no curves defined - initialize what we can to vector 0 */
    _curveAppearance->reset();
    Delete->setEnabled(false);
  }
}