当前位置: 首页>>代码示例>>C++>>正文


C++ KstScalarPtr::value方法代码示例

本文整理汇总了C++中KstScalarPtr::value方法的典型用法代码示例。如果您正苦于以下问题:C++ KstScalarPtr::value方法的具体用法?C++ KstScalarPtr::value怎么用?C++ KstScalarPtr::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KstScalarPtr的用法示例。


在下文中一共展示了KstScalarPtr::value方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: algorithm

// Remove some elements from the vector starting from vector[0]
bool Trim::algorithm() {
  KstVectorPtr input = inputVector(INPUT);
  KstScalarPtr remove = inputScalar(REMOVE);
  KstVectorPtr cut = outputVector(CUT);
  bool rc = false;

  if (input->length() > remove->value()) {
    int cutSize = (int)input->length() - (int)remove->value();
    cut->resize( cutSize, false );
    for (int j=0; j<cutSize; j++) {
      cut->value()[j] = input->value()[(int)remove->value()+j];
    }

    rc = true;
  }

  return rc;
}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例2: generateEntries

void KstPluginDialogI::generateEntries(bool input, int& cnt, QWidget *parent, QGridLayout *grid, const QValueList<Plugin::Data::IOValue>& table) {
QString scalarLabelTemplate, vectorLabelTemplate;

  if (input) {
    scalarLabelTemplate = i18n("Input Scalar - %1:");
    vectorLabelTemplate = i18n("Input Vector - %1:");
  } else {
    scalarLabelTemplate = i18n("Output Scalar - %1:");
    vectorLabelTemplate = i18n("Output Vector - %1:");
  }

  for (QValueList<Plugin::Data::IOValue>::ConstIterator it = table.begin(); it != table.end(); ++it) {
    QString labellabel;
    bool scalar = false;
    switch ((*it)._type) {
      case Plugin::Data::IOValue::FloatType:
        labellabel = scalarLabelTemplate.arg((*it)._name);
        scalar = true;
        break;
      case Plugin::Data::IOValue::TableType:
        if ((*it)._subType == Plugin::Data::IOValue::FloatSubType) {
          labellabel = vectorLabelTemplate.arg((*it)._name);
        } else {
          // unsupported
          continue;
        }
        break;
      default:
        // unsupported
        continue;
    }

    QLabel *label = new QLabel(labellabel, parent, input ? "Input label" : "Output label");

    QWidget *widget = 0L;

    if (input) {
      if (scalar) {
        ScalarSelector *w = new ScalarSelector(parent, (*it)._name.latin1());
        widget = w;
        connect(w->_scalar, SIGNAL(activated(const QString&)), this, SLOT(updateScalarTooltip(const QString&)));
        connect(widget, SIGNAL(newScalarCreated()), this, SIGNAL(modified()));
        KstScalarPtr p = *KST::scalarList.findTag(w->_scalar->currentText());
        if (p) {
          QToolTip::add(w->_scalar, QString::number(p->value()));
        }
      } else {
        widget = new VectorSelector(parent, (*it)._name.latin1());
        connect(widget, SIGNAL(newVectorCreated(const QString&)), this, SIGNAL(modified()));
      }
    } else {
开发者ID:,项目名称:,代码行数:51,代码来源:

示例3: label

QString KstCPlugin::label(int precision) const {
  QString label;

  label = i18n("%1: %2").arg(plugin()->data()._readableName).arg(tagName());
  if ((outputVectors())["Parameters"]) {
    QString strParamName;
    QString strValue;
    int length = (outputVectors())["Parameters"]->length();
    int i = 0;

    for (strParamName = plugin()->parameterName(0); 
        !strParamName.isEmpty() && i < length; 
        strParamName = plugin()->parameterName(++i)) {
      KstScalarPtr scalar = outputScalars()[strParamName];
      if (scalar) {
        strValue = QString::number(scalar->value(), 'g', precision);
        label += i18n("\n%1: %2").arg(strParamName).arg(strValue);
      }
    }
  }

  return label;
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:23,代码来源:kstcplugin.cpp

示例4: renderLabel

void renderLabel(RenderContext& rc, Label::Chunk *fi) {
  // FIXME: RTL support
  int oldSize = rc.size;
  int oldY = rc.y;
  int oldX = rc.x;
  
  while (fi) {
    if (fi->vOffset != Label::Chunk::None) {
      if (fi->vOffset == Label::Chunk::Up) {
        rc.y -= int(0.4 * rc.fontHeight());
      } else { // Down
        rc.y += int(0.4 * rc.fontHeight());
      }
      if (rc.size > 5) {
        rc.size = (rc.size*2)/3;
      }
    }

    QFont f = rc.font();
    if (rc.fontSize() != rc.size) {
      f.setPointSize(rc.size);
    }

    f.setBold(fi->attributes.bold);
    f.setItalic(fi->attributes.italic);
    f.setUnderline(fi->attributes.underline);
    if (rc.p && fi->attributes.color.isValid()) {
      rc.p->setPen(fi->attributes.color);
    } else if (rc.p) {
      rc.p->setPen(rc.pen);
    }
    rc.setFont(f);

    if (fi->linebreak) {
      rc.x = oldX;
      rc.y += rc.fontAscent() + rc.fontDescent() + 1;
      fi = fi->next;
      continue;
    }

    if (!rc.substitute && (fi->scalar || fi->vector)) {
      QString txt = QString("[") + fi->text + "]";
      if (rc.p) {
        rc.p->drawText(rc.x, rc.y, txt);
      }
      rc.x += rc.fontWidth(txt);
    } else if (fi->scalar) { 
      // do scalar/string/fit substitution
      QString txt;
      if (!fi->text.isEmpty() && fi->text[0] == '=') {
        // Parse and evaluate as an equation
        bool ok = false;
        const double eqResult(Equation::interpret(fi->text.mid(1).latin1(), &ok));
        txt = QString::number(eqResult, 'g', rc.precision);
        if (rc._cache) {
          rc._cache->append(DataRef(DataRef::DRExpression, fi->text, QString::null, 0.0, QVariant(eqResult)));
        }
      } else {
        KST::scalarList.lock().readLock();
        KstScalarPtr scp = *KST::scalarList.findTag(fi->text);
        KST::scalarList.lock().unlock();
        if (scp) {
          scp->readLock();
          txt = QString::number(scp->value(), 'g', rc.precision);
          if (rc._cache) {
            rc._cache->append(DataRef(DataRef::DRScalar, fi->text, QString::null, 0.0, QVariant(scp->value())));
          }
          scp->unlock();
        } else {
          KST::stringList.lock().readLock();
          KstStringPtr stp = *KST::stringList.findTag(fi->text);
          KST::stringList.lock().unlock();
          if (stp) {
            stp->readLock();
            txt = stp->value();
            if (rc._cache) {
              rc._cache->append(DataRef(DataRef::DRString, fi->text, QString::null, 0.0, QVariant(stp->value())));
            }
            stp->unlock();
          } else {
            KST::dataObjectList.lock().readLock();
            KstDataObjectList::Iterator oi = KST::dataObjectList.findTag(fi->text);
            KST::dataObjectList.lock().unlock();
            if (oi != KST::dataObjectList.end()) {
              KstPluginPtr fit = kst_cast<KstPlugin>(*oi);
              if (fit) {
                fit->readLock();
                const QString txtAll = fit->label(rc.precision);
                fit->unlock();
                
                const QValueList<QString> strList = QStringList::split('\n', txtAll);
                QValueListConstIterator<QString> last = --(strList.end());
                for (QValueListConstIterator<QString> iter = strList.begin(); iter != strList.end(); ++iter) {
                  txt = (*iter);

                  if (iter != last) {
                    if (rc.p) {
                      rc.p->drawText(rc.x, rc.y, txt);
                    } else {
                      rc.ascent = kMax(rc.ascent, -rc.y + rc.fontAscent());
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例5: update

KstObject::UpdateType KstCPlugin::update(int update_counter) {
  Q_ASSERT(myLockStatus() == KstRWLock::WRITELOCKED);

  if (!isValid()) {
    return setLastUpdateResult(NO_CHANGE);
  }

  if (recursed()) {
    return setLastUpdateResult(NO_CHANGE);
  }

  bool force = dirty();
  setDirty(false);

  if (KstObject::checkUpdateCounter(update_counter) && !force) {
    return lastUpdateResult();
  }

#define CLEANUP() do {\
  for (unsigned i = 0; i < _outStringCnt; ++i) { \
    if (_outStrings[i]) { \
      free(_outStrings[i]); \
      _outStrings[i] = 0L; \
    } \
  } \
  for (unsigned i = 0; i < _inStringCnt; ++i) { \
    if (_inStrings[i]) { \
      free(_inStrings[i]); \
      _inStrings[i] = 0L; \
    } \
  } \
  } while(0)


  writeLockInputsAndOutputs();

  const QValueList<Plugin::Data::IOValue>& itable = _plugin->data()._inputs;
  const QValueList<Plugin::Data::IOValue>& otable = _plugin->data()._outputs;
  int itcnt = 0, vitcnt = 0, sitcnt = 0;
  bool doUpdate = force;

  // Populate the input scalars and vectors
  for (QValueList<Plugin::Data::IOValue>::ConstIterator it = itable.begin(); it != itable.end(); ++it) {
    if ((*it)._type == Plugin::Data::IOValue::TableType) {
      if (!_inputVectors.contains((*it)._name)) {
        KstDebug::self()->log(i18n("Input vector [%1] for plugin %2 not found.  Unable to continue.").arg((*it)._name).arg(tagName()), KstDebug::Error);
        CLEANUP();
        return setLastUpdateResult(NO_CHANGE);
      }
      KstVectorPtr iv = _inputVectors[(*it)._name];
      if (!iv) {
        kstdFatal() << "Input vector \"" << (*it)._name << "\" for plugin " << tag().displayString() << " is invalid." << endl;
      }
      doUpdate = (UPDATE == iv->update(update_counter)) || doUpdate;
      _inVectors[vitcnt] = iv->value();
      _inArrayLens[vitcnt++] = iv->length();
    } else if ((*it)._type == Plugin::Data::IOValue::FloatType) {
      KstScalarPtr is = _inputScalars[(*it)._name];
      if (!is) {
        kstdFatal() << "Input scalar \"" << (*it)._name << "\" for plugin " << tag().displayString() << " is invalid." << endl;
      }
      doUpdate = (UPDATE == is->update(update_counter)) || doUpdate;
      _inScalars[itcnt++] = is->value();
    } else if ((*it)._type == Plugin::Data::IOValue::StringType) {
      KstStringPtr is = _inputStrings[(*it)._name];
      if (!is) {
        kstdFatal() << "Input string \"" << (*it)._name << "\" for plugin " << tag().displayString() << " is invalid." << endl;
      }
      doUpdate = (UPDATE == is->update(update_counter)) || doUpdate;
      // Maybe we should use UTF-8 instead?
      _inStrings[sitcnt++] = strdup(is->value().latin1());
    } else if ((*it)._type == Plugin::Data::IOValue::PidType) {
      _inScalars[itcnt++] = getpid();
    }
  }

  if (!doUpdate) {
    CLEANUP();
    unlockInputsAndOutputs();
    return setLastUpdateResult(NO_CHANGE);
  }

  vitcnt = 0;
  // Populate the output vectors
  for (QValueList<Plugin::Data::IOValue>::ConstIterator it = otable.begin();
                                                         it != otable.end();
                                                                        ++it) {
    if ((*it)._type == Plugin::Data::IOValue::TableType) {
      if (!_outputVectors.contains((*it)._name)) {
        KstDebug::self()->log(i18n("Output vector [%1] for plugin %2 not found.  Unable to continue.").arg((*it)._name).arg(tagName()), KstDebug::Error);
        CLEANUP();
        unlockInputsAndOutputs();
        return setLastUpdateResult(NO_CHANGE);
      }
      _outVectors[vitcnt] = _outputVectors[(*it)._name]->value();
      _outArrayLens[vitcnt++] = _outputVectors[(*it)._name]->length();
    }
  }

  if (_outStringCnt > 0) {
//.........这里部分代码省略.........
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:101,代码来源:kstcplugin.cpp

示例6: generateEntries

void KstPluginDialogI::generateEntries(bool input, int& cnt, QWidget *parent, QGridLayout *grid, const QValueList<Plugin::Data::IOValue>& table) {
    QString scalarLabelTemplate, vectorLabelTemplate, stringLabelTemplate;

    if (input) {
        stringLabelTemplate = i18n("Input string - %1:");
        scalarLabelTemplate = i18n("Input scalar - %1:");
        vectorLabelTemplate = i18n("Input vector - %1:");
    } else {
        stringLabelTemplate = i18n("Output string - %1:");
        scalarLabelTemplate = i18n("Output scalar - %1:");
        vectorLabelTemplate = i18n("Output vector - %1:");
    }

    for (QValueList<Plugin::Data::IOValue>::ConstIterator it = table.begin(); it != table.end(); ++it) {
        QString labellabel;
        bool scalar = false;
        bool string = false;
        switch ((*it)._type) {
        case Plugin::Data::IOValue::PidType:
            continue;
        case Plugin::Data::IOValue::StringType:
            labellabel = stringLabelTemplate.arg((*it)._name);
            string = true;
            break;
        case Plugin::Data::IOValue::FloatType:
            labellabel = scalarLabelTemplate.arg((*it)._name);
            scalar = true;
            break;
        case Plugin::Data::IOValue::TableType:
            if ((*it)._subType == Plugin::Data::IOValue::FloatSubType ||
                    (*it)._subType == Plugin::Data::IOValue::FloatNonVectorSubType) {
                labellabel = vectorLabelTemplate.arg((*it)._name);
            } else {
                // unsupported
                continue;
            }
            break;
        default:
            // unsupported
            continue;
        }

        QLabel *label = new QLabel(labellabel, parent, input ? "Input label" : "Output label");

        QWidget *widget = 0L;

        if (input) {
            if (scalar) {
                ScalarSelector *w = new ScalarSelector(parent, (*it)._name.latin1());
                widget = w;
                connect(w->_scalar, SIGNAL(activated(const QString&)), this, SLOT(updateScalarTooltip(const QString&)));
                connect(widget, SIGNAL(newScalarCreated()), this, SIGNAL(modified()));
                if (!(*it)._default.isEmpty()) {
                    w->_scalar->insertItem((*it)._default);
                    w->_scalar->setCurrentText((*it)._default);
                }
                KstScalarPtr p = *KST::scalarList.findTag(w->_scalar->currentText());
                w->allowDirectEntry(true);
                if (p) {
                    p->readLock();
                    QToolTip::remove(w->_scalar);
                    QToolTip::add(w->_scalar, QString::number(p->value()));
                    p->unlock();
                }
            } else if (string) {
                StringSelector *w = new StringSelector(parent, (*it)._name.latin1());
                widget = w;
                connect(w->_string, SIGNAL(activated(const QString&)), this, SLOT(updateStringTooltip(const QString&)));
                connect(widget, SIGNAL(newStringCreated()), this, SIGNAL(modified()));
                if (!(*it)._default.isEmpty()) {
                    w->_string->insertItem((*it)._default);
                    w->_string->setCurrentText((*it)._default);
                }
                KstStringPtr p = *KST::stringList.findTag(w->_string->currentText());
                w->allowDirectEntry(true);
                if (p) {
                    p->readLock();
                    QToolTip::remove(w->_string);
                    QToolTip::add(w->_string, p->value());
                    p->unlock();
                }
            } else {
                widget = new VectorSelector(parent, (*it)._name.latin1());
                connect(widget, SIGNAL(newVectorCreated(const QString&)), this, SIGNAL(modified()));
            }
        } else {
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:86,代码来源:kstplugindialog_i.cpp

示例7: crossspectrum

void CrossPowerSpectrum::crossspectrum() {
  KstVectorPtr v1 = *_inputVectors.find(VECTOR_ONE);
  KstVectorPtr v2 = *_inputVectors.find(VECTOR_TWO);

  KstScalarPtr fft = *_inputScalars.find(FFT_LENGTH);
  KstScalarPtr sample = *_inputScalars.find(SAMPLE_RATE);

  KstVectorPtr real = *_outputVectors.find(REAL);
  KstVectorPtr imaginary = *_outputVectors.find(IMAGINARY);
  KstVectorPtr frequency = *_outputVectors.find(FREQUENCY);

  double SR = sample->value(); // sample rate
  double df;
  int i,  xps_len;
  double *a,  *b;
  double mean_a,  mean_b;
  int dv0,  dv1,  v_len;
  int i_subset,  n_subsets;
  int i_samp,  copyLen;
  double norm_factor;

  /* parse fft length */
  xps_len = int( fft->value() - 0.99);
  if ( xps_len > KSTPSDMAXLEN ) xps_len = KSTPSDMAXLEN;
  if ( xps_len<2 ) xps_len = 2;
  xps_len = int ( pow( 2,  xps_len ) );

  /* input vector lengths */
  v_len = ( ( v1->length() < v2->length() ) ?
            v1->length() : v2->length() );
  dv0 = v_len/v1->length();
  dv1 = v_len/v2->length();

  while ( xps_len > v_len ) xps_len/=2;

  // allocate the lengths
  if ( real->length() != xps_len ) {
    real->resize( xps_len, false );
    imaginary->resize( xps_len, false );
    frequency->resize( xps_len, false );
  }

  /* Fill the frequency and zero the xps */
  df = SR/( 2.0*double( xps_len-1 ) );
  for ( i=0; i<xps_len; i++ ) {
    frequency->value()[i] = double( i ) * df;
    real->value()[i] = 0.0;
    imaginary->value()[i] = 0.0;
  }

  /* allocate input arrays */
  int ALen = xps_len * 2;
  a = new double[ALen];
  b = new double[ALen];

  /* do the fft's */
  n_subsets = v_len/xps_len + 1;

  for ( i_subset=0; i_subset<n_subsets; i_subset++ ) {
        /* copy each chunk into a[] and find mean */
    if (i_subset*xps_len + ALen <= v_len) {
      copyLen = ALen;
    } else {
      copyLen = v_len - i_subset*xps_len;
    }
    mean_b = mean_a = 0;
    for (i_samp = 0; i_samp < copyLen; i_samp++) {
      i = ( i_samp + i_subset*xps_len )/dv0;
      mean_a += (
        a[i_samp] = v1->value()[i]
        );
      i = ( i_samp + i_subset*xps_len )/dv1;
      mean_b += (
        b[i_samp] = v2->value()[i]
        );
    }
    if (copyLen>1) {
      mean_a/=(double)copyLen;
      mean_b/=(double)copyLen;
    }

    /* Remove Mean and apodize */
    for (i_samp=0; i_samp<copyLen; i_samp++) {
      a[i_samp] -= mean_a;
      b[i_samp] -= mean_b;
    }

    for (;i_samp < ALen; i_samp++) {
      a[i_samp] = 0.0;
      b[i_samp] = 0.0;
    }

    /* fft */
    rdft(ALen, 1, a);
    rdft(ALen, 1, b);

    /* sum each bin into psd[] */
    real->value()[0] += ( a[0]*b[0] );
    real->value()[xps_len-1] += ( a[1]*b[1] );
    for (i_samp=1; i_samp<xps_len-1; i_samp++) {
//.........这里部分代码省略.........
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:101,代码来源:crosspowerspectrum.cpp

示例8: switch

void KstViewLabel::DataCache::update() {
  for (QValueVector<DataRef>::ConstIterator i = data.begin(); valid && i != data.end(); ++i) {
    switch ((*i).type) {
      case DataRef::DataRef::DRScalar:
        {
          KST::scalarList.lock().readLock();
          KstScalarPtr p = *KST::scalarList.findTag((*i).name);
          KST::scalarList.lock().unlock();
          if (p) {
            p->readLock();
            if (QVariant(p->value()) != (*i).value) {
              valid = false;
            }
            p->unlock();
          }
        }
        break;

      case DataRef::DRString:
        {
          KST::stringList.lock().readLock();
          KstStringPtr p = *KST::stringList.findTag((*i).name);
          KST::stringList.lock().unlock();
          if (p) {
            p->readLock();
            if (QVariant(p->value()) != (*i).value) {
              valid = false;
            }
            p->unlock();
          }
        }
        break;

      case DataRef::DRExpression:
        {
          bool ok = false;
          const double val = Equation::interpret((*i).name.latin1(), &ok, (*i).name.length());
          if (QVariant(val) != (*i).value) {
            valid = false;
          }
        }
        break;

      case DataRef::DRVector:
        {
          bool ok = false;
          const double idx = Equation::interpret((*i).index.latin1(), &ok, (*i).index.length());
          if (idx != (*i).indexValue) {
            valid = false;
            break;
          }
          KST::vectorList.lock().readLock();
          KstVectorPtr p = *KST::vectorList.findTag((*i).name);
          KST::vectorList.lock().unlock();
          if (p) {
            p->readLock();
            if (QVariant(p->value(int((*i).indexValue))) != (*i).value) {
              valid = false;
            }
            p->unlock();
          }
        }
        break;

      case DataRef::DataRef::DRFit:
        {
          KST::dataObjectList.lock().readLock();
          KstDataObjectList::Iterator oi = KST::dataObjectList.findTag((*i).name);
          KST::dataObjectList.lock().unlock();
          if (oi != KST::dataObjectList.end()) {
            KstCPluginPtr fit = kst_cast<KstCPlugin>(*oi);
            if (fit) {
              fit->readLock(); 
              if (fit->label((int)((*i).indexValue)) != (*i).index) {
                valid = false;
              }
              fit->unlock();
            }
          }
        }
        break;
    }
  }
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:84,代码来源:kstviewlabel.cpp

示例9: fillFieldsForEdit

void KstVvDialogI::fillFieldsForEdit() {
  KstVectorViewPtr vp = kst_cast<KstVectorView>(_dp);
  if (!vp) {
    return; // shouldn't be needed
  }

  vp->readLock();

  _tagName->setText(vp->tagName());

  _w->_xVector->setSelection(vp->in_xVTag());
  _w->_yVector->setSelection(vp->in_yVTag());

  if (vp->hasFlag()) {
    _w->_FlagVector->setSelection(vp->FlagTag()); 
  }

  _w->_xMinCheckbox->setChecked(vp->useXmin());
  _w->_xMaxCheckbox->setChecked(vp->useXmax());
  _w->_yMinCheckbox->setChecked(vp->useYmin());
  _w->_yMaxCheckbox->setChecked(vp->useYmax());

  KstScalarPtr sc;
  QString str;

  sc = vp->xMinScalar();
  if (!sc) {
    _w->_xMinScalar->setSelection("0");
  } else if (*KST::scalarList.findTag(sc->tag().displayString())) {
    _w->_xMinScalar->setSelection(sc->tag().displayString());
  } else {
    // our scalar has been removed from the global list...
    // just put its current value into the scalar selector.
    // warning: after edit it won't be updated anymore!
    // the motivation for putting this in is to not lose scale information when a plot is deleted.
    _w->_xMinScalar->setSelection(QString::number(sc->value()));
  }

  sc = vp->xMaxScalar();
  if (!sc) {
    _w->_xMaxScalar->setSelection("0");
  } else if (*KST::scalarList.findTag(sc->tag().displayString())) {
    _w->_xMaxScalar->setSelection(sc->tag().displayString());
  } else {
    _w->_xMaxScalar->setSelection(QString::number(sc->value()));
  }

  sc = vp->yMinScalar();
  if (!sc) {
    _w->_yMinScalar->setSelection("0");
  } else if (*KST::scalarList.findTag(sc->tag().displayString())) {
    _w->_yMinScalar->setSelection(sc->tag().displayString());
  } else {
    _w->_yMinScalar->setSelection(QString::number(sc->value()));
  }

  sc = vp->yMaxScalar();
  if (!sc) {
    _w->_yMaxScalar->setSelection("0");
  } else if (*KST::scalarList.findTag(sc->tag().displayString())) {
    _w->_yMaxScalar->setSelection(sc->tag().displayString());
  } else {
    _w->_yMaxScalar->setSelection(QString::number(sc->value()));
  }

  vp->unlock();
  updateButtons();

  // can't edit curve props from here....
  _w->_curveAppearance->hide();
  _w->_curvePlacement->hide();
  _legendText->hide();
  _legendLabel->hide();

  adjustSize();
  resize(minimumSizeHint());
  setFixedHeight(height());
}
开发者ID:Kst-plot,项目名称:kst-subversion-archive,代码行数:78,代码来源:kstvvdialog_i.cpp

示例10: binnedmap

void BinnedMap::binnedmap() {
    KstVectorPtr x = *_inputVectors.find(VECTOR_X);
    KstVectorPtr y = *_inputVectors.find(VECTOR_Y);
    KstVectorPtr z = *_inputVectors.find(VECTOR_Z);
    KstMatrixPtr map = *_outputMatrices.find(MAP);
    KstMatrixPtr hitsMap = *_outputMatrices.find(HITSMAP);
    KstScalarPtr autobin = *_inputScalars.find(AUTOBIN);

    if (autobin) {
        if (autobin->value() != 0.0) {
            _autoBin = true;
        } else {
            _autoBin = false;
        }
    }

    if (_autoBin) {
        double minx, miny, maxx, maxy;
        int nx, ny;

        autoSize(X(), Y(), &nx, &minx, &maxx, &ny, &miny, &maxy);

        setNX(nx);
        setNY(ny);
        setXMin(minx);
        setXMax(maxx);
        setYMin(miny);
        setYMax(maxy);
    } else {
        KstScalarPtr xmin = *_inputScalars.find(XMIN);
        KstScalarPtr xmax = *_inputScalars.find(XMAX);
        KstScalarPtr ymin = *_inputScalars.find(YMIN);
        KstScalarPtr ymax = *_inputScalars.find(YMAX);
        KstScalarPtr nx = *_inputScalars.find(NX);
        KstScalarPtr ny = *_inputScalars.find(NY);

        if (xmin) {
            _xMin = xmin->value();
        }
        if (xmax) {
            _xMax = xmax->value();
        }
        if (ymin) {
            _yMin = ymin->value();
        }
        if (ymax) {
            _yMax = ymax->value();
        }
        if (nx) {
            _nx = (int)nx->value();
        }
        if (ny) {
            _ny = (int)ny->value();
        }
    }

    bool needsresize = false;

    if (_nx < 2) {
        _nx = 2;
        needsresize = true;
    }
    if (_ny < 2) {
        _ny = 2;
        needsresize = true;
    }

    if ((map->xNumSteps() != _nx) || (map->yNumSteps() != _ny) ||
            (map->minX() != _xMin) || (map->minY() != _yMin)) {
        needsresize = true;
    }

    if (map->xStepSize() != (_xMax - _xMin)/double(_nx-1)) {
        needsresize = true;
    }
    if (map->yStepSize() != (_yMax - _yMin)/double(_ny-1)) {
        needsresize = true;
    }

    if (needsresize) {
        map->change(map->tag(), _nx, _ny, _xMin, _yMin,
                    (_xMax - _xMin)/double(_nx-1), (_yMax - _yMin)/double(_ny-1));
        map->resize(_nx, _ny);
        hitsMap->change(hitsMap->tag(), _nx, _ny, _xMin, _yMin,
                        (_xMax - _xMin)/double(_nx-1), (_yMax - _yMin)/double(_ny-1));
        hitsMap->resize(_nx, _ny);
    }

    map->zero();
    hitsMap->zero();

    int ns = z->length(); // the z vector defines the number of points.
    double n,p, x0, y0, z0;

    for (int i=0; i<ns; i++) {
        x0 = x->interpolate(i, ns);
        y0 = y->interpolate(i, ns);
        z0 = z->interpolate(i, ns);
        p = map->value(x0, y0)+z0;
        map->setValue(x0, y0, p);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例11: doTests

void doTests() {
  KstScalarPtr sp = new KstScalar;
  doTest(!sp->tagName().isEmpty());
  doTest(sp->value() == 0.0);
  *sp = 3.1415;
  doTest(sp->displayable());
  doTest(sp->value() == 3.1415);
  sp->setValue(2.1415);
  doTest(sp->value() == 2.1415);
  sp->setValue(NOPOINT);
  doTest(sp->value() != sp->value());
  sp->setValue(INF);
  doTest(sp->value() == INF);
  doTest((*sp = 2.0).value() == 2.0);
  SListener *listener = new SListener;
  sp->connect(sp, SIGNAL(trigger()), listener, SLOT(trigger()));
  *sp = 3.1415;
  doTest(listener->_trigger == 1);
  sp->setValue(3.1415);
  doTest(listener->_trigger == 2);
  *sp = 1.1415;
  doTest(listener->_trigger == 3);

  KstScalarPtr sp2 = new KstScalar(sp->tagName());
  doTest(sp2->tagName() == sp->tagName() + "'");

  doTest(sp->isGlobal());
  doTest(sp2->isGlobal());
  doTest(sp->displayable());
  doTest(sp2->displayable());

  QDomNode n;
  QDomElement e;
  n = makeDOM1("load1", "2.14159265").firstChild();
  e = n.toElement();
  KstScalarPtr sp3 = new KstScalar(e);
  doTest(sp3->orphan() == false);
  doTest(sp3->value() == 2.14159265);
  doTest(sp3->tagName() == "load1");
  doTest(sp3->isGlobal());
  doTest(sp3->displayable());

  n = makeDOM1("55.4232", "55.4232", true).firstChild();
  e = n.toElement();
  KstScalarPtr sp4 = new KstScalar(e);
  doTest(sp4->orphan());
  doTest(sp4->value() == 55.4232);
  doTest(sp4->tagName() == "55.4232");
  doTest(sp4->isGlobal());
  doTest(!sp4->displayable());

  n = makeDOM1("load2", "NAN").firstChild();
  e = n.toElement();
  sp4 = new KstScalar(e);
  doTest(sp4->value() != sp4->value());

  n = makeDOM1("load3", "INF").firstChild();
  e = n.toElement();
  sp4 = new KstScalar(e);
  doTest(sp4->value() == INF);

  n = makeDOM1("load4", "-INF").firstChild();
  e = n.toElement();
  sp4 = new KstScalar(e);
  doTest(sp4->value() == -INF);

  delete listener;
}
开发者ID:,项目名称:,代码行数:68,代码来源:


注:本文中的KstScalarPtr::value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。