QString KST::suggestPluginName(const QString& pname, KstObjectTag vname) {
  QString tag;
  
  if (!vname.isValid()) {
    tag = pname;
  } else {
    tag = vname.tag() + "-" + pname;
  }
  return suggestDataObjectName(tag, 
                      i18n("Minimal abbreviation for 'pluGin'", "G"),
                      false);
}
예제 #2
0
KstString::KstString(KstObjectTag in_tag, KstObject *provider, const QString& val, bool orphan)
: KstPrimitive(provider), _value(val), _orphan(orphan), _editable(false) {
  QString _tag = in_tag.tag();
  if (!in_tag.isValid()) {
    QString nt = i18n("Anonymous String %1");

    do {
      _tag = nt.arg(anonymousStringCounter++);
    } while (KstData::self()->vectorTagNameNotUniqueInternal(_tag));  // FIXME: why vector?
    KstObject::setTagName(KstObjectTag(_tag, in_tag.context()));
  } else {
    KstObject::setTagName(KST::suggestUniqueStringTag(in_tag));
  }

  KST::stringList.lock().writeLock();
  KST::stringList.append(this);
  KST::stringList.lock().unlock();
}
예제 #3
0
/** Create a vector */
KstVector::KstVector(KstObjectTag in_tag, int size, KstObject *provider, bool isScalarList)
    : KstPrimitive(provider), _nsum(0), _scalars(isScalarList ? 0 : 11) {
    //kstdDebug() << "+++ CREATING VECTOR: " << (void*) this << endl;
    _editable = false;
    NumShifted = 0;
    NumNew = 0;
    _saveData = false;
    _isScalarList = isScalarList;

    _saveable = false;

    if (size <= 0) {
        size = INITSIZE;
    }

    if (!in_tag.isValid()) {
        QString nt = i18n("Anonymous Vector %1");

        do {
            KstObject::setTagName(KstObjectTag(nt.arg(anonymousVectorCounter++), in_tag.context()));
        } while (KstData::self()->vectorTagNameNotUnique(tagName(), false));
    } else {
        KstObject::setTagName(KST::suggestUniqueVectorTag(in_tag));
    }

    _v = static_cast<double*>(KST::malloc(size * sizeof(double)));
    if (!_v) { // Malloc failed
        _v = static_cast<double*>(KST::malloc(sizeof(double)));
        _size = 1;
    } else {
        _size = size;
    }
    _is_rising = false;

    createScalars();
    blank();

    KST::vectorList.lock().writeLock();
    KST::vectorList.append(this);
    KST::vectorList.lock().unlock();
}
예제 #4
0
KstEquation::KstEquation(const QDomElement &e)
: KstDataObject(e) {
  QString in_tag, equation;

  int ns = -1;
  double x0 = 0.0, x1 = 1.0;
  KstObjectTag xvtag = KstObjectTag::invalidTag;
  bool haveVector = false;

  _doInterp = false;

  /* parse the DOM tree */
  QDomNode n = e.firstChild();
  while (!n.isNull()) {
    QDomElement e = n.toElement(); // try to convert the node to an element.
    if (!e.isNull()) { // the node was really an element.
      if (e.tagName() == "tag") {
        in_tag = e.text();
      } else if (e.tagName() == "equation") {
        equation = e.text();
      } else if (e.tagName() == "x0") {
        x0 = e.text().toDouble();
      } else if (e.tagName() == "x1") {
        x1 = e.text().toDouble();
      } else if (e.tagName() == "ns") {
        ns = e.text().toInt();
      } else if (e.tagName() == "xvtag") {
        xvtag = KstObjectTag::fromString(e.text());
      } else if (e.tagName() == "xvector") {
        _inputVectorLoadQueue.append(qMakePair(XINVECTOR, e.text()));
        haveVector = true;
      } else if (e.tagName() == "interpolate") {
        _doInterp = true;
      }
    }
    n = n.nextSibling();
  }

  if (!haveVector) {
    if (ns < 0) {
      ns = 2;
    }
    if (x0 == x1) {
      x1 = x0 + 2;
    }

    KstObjectTag vtag = KstObjectTag::invalidTag;
    if (!xvtag.isValid()) {
      vtag = KST::suggestUniqueVectorTag(KstObjectTag(QString("(%1..%2)").arg(x0).arg(x1), KstObjectTag::globalTagContext));
    } else {
      vtag = xvtag;
    }

    KstVectorPtr xvector = new KstSVector(x0, x1, ns, vtag);

    _doInterp = false;
    _xInVector = _inputVectors.insert(XINVECTOR, xvector);
  } else {
    _xInVector = _inputVectors.end();
  }
  commonConstructor(in_tag, equation);
}