예제 #1
0
bool KstEqDialogI::editSingleObject(KstEquationPtr eqPtr) {
  eqPtr->writeLock();
  if (!checkEntries()) {
    eqPtr->unlock();
    return false;
  }

  // update the vector only if it is dirty 
  KstVectorPtr vp;
  if (_xVectorsDirty) {
    KST::vectorList.lock().readLock();
    /* find *V */
    KstVectorList::Iterator i = KST::vectorList.findTag(_w->_xVectors->selectedVector());
    if (i == KST::vectorList.end()) {
      kstdFatal() << "Bug in kst: the Vector field (Eq) "
                  << "refers to a non existant vector..." << endl;
    }
    vp = *i;
  } else {
    vp = eqPtr->vX();
  }
  KST::vectorList.lock().unlock();
  
  // update the DoInterpolation only if it is dirty
  if (_doInterpolationDirty) {
    eqPtr->setExistingXVector(vp, _w->_doInterpolation->isChecked());
  } else {
    eqPtr->setExistingXVector(vp, eqPtr->doInterp());
  }
  
  if (_equationDirty) {
    eqPtr->setEquation(_w->_equation->text());
    if (!eqPtr->isValid()) {
      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);
      eqPtr->unlock();
      return false;
    }
  }
  eqPtr->unlock();
  return true;
}
예제 #2
0
bool KstEqDialog::editSingleObject(KstEquationPtr eqPtr) {
  KstVectorPtr vp;

  eqPtr->writeLock();
  if (!checkEntries()) {
    eqPtr->unlock();

    return false;
  }

  if (_xVectorsDirty) {
    KstVectorList::iterator i;
    
    KST::vectorList.lock().readLock();

    i = KST::vectorList.findTag(_w->_xVectors->selectedVector());
    if (i != KST::vectorList.end()) {
      vp = *i;
    }

    KST::vectorList.lock().unlock();
  } else {
    vp = eqPtr->vX();
  }

  //
  // update the _doInterpolation only if it is dirty...
  //

  if (_doInterpolationDirty) {
    eqPtr->setExistingXVector(vp, _w->_doInterpolation->isChecked());
  } else {
    eqPtr->setExistingXVector(vp, eqPtr->doInterp());
  }

  if (_equationDirty) {
    eqPtr->setEquation(_w->_equation->text());
    if (!eqPtr->isValid()) {
      QStringList::const_iterator i;
      QString strWarning = QObject::tr("There is an error in the equation you entered.\n");

      for (i = Equation::errorStack.begin(); i != Equation::errorStack.end(); ++i) {
        strWarning += *i;
        strWarning += "\n";
      }

      QMessageBox::warning(this, QObject::tr("Kst"), strWarning);
      eqPtr->unlock();

      return true;
    }

    eqPtr->setRecursed(false);
    if (eqPtr->recursion()) {
      eqPtr->setRecursed(true);
      eqPtr->unlock();
      QMessageBox::critical(this, QObject::tr("Kst"), QObject::tr("There is a recursion resulting from the equation you entered."));

      return false;
    }
  }

  eqPtr->unlock();

  return true;
}