예제 #1
0
QString KstIfaceImpl::createPowerSpectrum(const QString & name,
    const QString& vector,
    bool appodize,
    bool removeMean,
    int fftLength,
    const QString& rateUnits,
    double sampleRate,
    const QString& vectorUnits,
    const QColor& color) {

  QStringList objList = createPowerSpectrum(name, vector, appodize, removeMean,
                                            fftLength, rateUnits, sampleRate, 
                                            vectorUnits);
  if (objList.isEmpty())
  {
    return QString::null;
  }
  
  KST::vectorList.lock().readLock();
  KstVectorPtr vx = *KST::vectorList.findTag(objList[1]);
  KstVectorPtr vy = *KST::vectorList.findTag(objList[2]);
  KST::vectorList.lock().unlock();
  
  QString n = objList[0] + "-C";
  KST::dataObjectList.lock().readLock();
  while (KST::dataObjectList.findTag(n) != KST::dataObjectList.end()) {
    n += "'";
  }
  KST::dataObjectList.lock().unlock();
  
  // create curve as well (but don't plot the curve)
  KstVCurvePtr vc = new KstVCurve(n, vx, vy, 
                                  0L, 0L, 0L, 0L, 
                                  color.isValid() ? color : QColor("darkBlue"));

  KST::dataObjectList.lock().writeLock();
  KST::dataObjectList.append(KstDataObjectPtr(vc));
  KST::dataObjectList.lock().unlock();

  _doc->forceUpdate();
  _doc->setModified();

  return vc->tagName(); //return the curve name so user can plot it
}
예제 #2
0
QString KstIfaceImpl::createHistogram(const QString& name,
    const QString& vector,
    double min,
    double max,
    int numBins,
    int normalizationType,
    const QColor& color) {

  QStringList objList = createHistogram(name, vector, min, max, numBins, normalizationType);

  if (objList.isEmpty())
  {
    return QString::null;
  }
  
  // also create the curve for the histogram
  QString n = objList[0] + "-C";
  KST::vectorList.lock().readLock();
  KstVectorPtr vx = *KST::vectorList.findTag(objList[1]);
  KstVectorPtr vy = *KST::vectorList.findTag(objList[2]);
  KST::vectorList.lock().unlock();

  KST::dataObjectList.lock().readLock();
  while (KST::dataObjectList.findTag(n) != KST::dataObjectList.end()) {
    n += "'";
  }
  KST::dataObjectList.lock().unlock();

  KstVCurvePtr c = new KstVCurve(n, vx, vy, 0L, 0L, 0L, 0L, color);
  c->setHasPoints(false);
  c->setHasLines(false);
  c->setHasBars(true);
  c->setBarStyle(1);
  
  KST::dataObjectList.lock().writeLock();
  KST::dataObjectList.append(KstDataObjectPtr(c));
  KST::dataObjectList.lock().unlock();

  _doc->forceUpdate();
  _doc->setModified();
  return c->tagName(); //return the curve name so user can plot it
}
예제 #3
0
const QString& KstIfaceImpl::createCurve(const QString& name, const QString& xVector, const QString& yVector, const QString& xErrorVector, const QString& yErrorVector, const QColor& color) {
  QString n = name;
  KST::vectorList.lock().readLock();
  KstVectorPtr vx = *KST::vectorList.findTag(xVector);
  KstVectorPtr vy = *KST::vectorList.findTag(yVector);
  KstVectorPtr ex = *KST::vectorList.findTag(xErrorVector);
  KstVectorPtr ey = *KST::vectorList.findTag(yErrorVector);
  KST::vectorList.lock().unlock();

  KST::dataObjectList.lock().writeLock();
  while (KST::dataObjectList.findTag(n) != KST::dataObjectList.end()) {
    n += "'";
  }

  KstVCurvePtr c = new KstVCurve(n, vx, vy, ex, ey, ex, ey, color);
  KST::dataObjectList.append(KstDataObjectPtr(c));
  KST::dataObjectList.lock().unlock();
  _doc->forceUpdate();
  _doc->setModified();

  return c->tagName();
}