Ejemplo n.º 1
0
void KstCurveDialogI::edit_I() {
  int index;
  KstVCurvePtr curve;

  KstVCurveList curves = kstObjectSubList<KstDataObject, KstVCurve>(KST::dataObjectList);
  index = Select->currentItem();
  if (index < 0 || unsigned(index) >= curves.count()) {
    new_I();
    return;
  }

  QString tag_name = Select->currentText();

  /* verify that the curve name is unique */
  if (tag_name != curves[index]->tagName()) {
    if (KST::dataTagNameNotUnique(tag_name)) {
      Select->setFocus();
      return;
    }
  }

  curve = curves[index];
  curve->setTagName(tag_name);

  { // leave this scope here to destroy the iterator
    KstReadLocker ml(&KST::vectorList.lock());
    KstVectorList::Iterator i = KST::vectorList.findTag(_xVector->selectedVector());
    if (i != KST::vectorList.end())
      curve->setXVector(*i);

    i = KST::vectorList.findTag(_yVector->selectedVector());
    if (i != KST::vectorList.end())
      curve->setYVector(*i);

    i = KST::vectorList.findTag(_xError->selectedVector());
    curve->setXError(*i);

    i = KST::vectorList.findTag(_yError->selectedVector());
    curve->setYError(*i);
  }

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

  curve->update(-1);
  curve = 0L;
  curves.clear();
  emit modified();
}
Ejemplo n.º 2
0
void KstBindCurve::setColor(KJS::ExecState *exec, const KJS::Value& value) {
  QVariant cv = KJSEmbed::convertToVariant(exec, value);
  if (!cv.canCast(QVariant::Color)) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return;
  }
  KstVCurvePtr d = makeCurve(_d);
  if (d) {
    KstWriteLocker rl(d);
    d->setColor(cv.toColor());
  }
}