예제 #1
0
void KstHsDialog::fillFieldsForEdit() {
  KstHistogramPtr hp;

  hp = kst_cast<KstHistogram>(_dp);
  if (hp) {
    hp->readLock();
  
    _tagName->setText(hp->tagName());
  
    _w->_vector->setSelection(hp->vTag());
  
    _w->N->setValue(hp->nBins());
    _w->Min->setText(QString::number(hp->vX()->min() - (hp->width()/2.0)));
    _w->Max->setText(QString::number(hp->vX()->max() + (hp->width()/2.0)));
    _w->_realTimeAutoBin->setChecked(hp->realTimeAutoBin());
  
    if (hp->isNormPercent()) {
      _w->NormIsPercent->setChecked(true);
    } else if (hp->isNormFraction()) {
      _w->NormIsFraction->setChecked(true);
    } else if (hp->isNormOne()) {
      _w->PeakIs1->setChecked(true);
    } else {
      _w->NormIsNumber->setChecked(true);
    }
  
  
    hp->unlock();
    updateButtons();
  
    // can't edit curve props from here....
    _w->_curveAppearance->hide();
    _w->_curvePlacement->hide();
    _legendText->hide();
    _legendLabel->hide();
  
    adjustSize();
    resize(minimumSizeHint());
    setFixedHeight(height());
  }
}
예제 #2
0
bool KstHsDialog::editSingleObject(KstHistogramPtr hsPtr) {
  double new_min;
  double new_max;

  hsPtr->readLock();
  new_min = hsPtr->xMin();
  new_max = hsPtr->xMax();
  hsPtr->unlock();

  if (_minDirty) {
    new_min = _w->Min->text().toDouble();
  }

  if (_maxDirty) {
    new_max = _w->Max->text().toDouble();
  }

  if (new_max < new_min) {
    double m = new_max;

    new_max = new_min;
    new_min = m;
  }

  if (new_max == new_min) {
    QMessageBox::warning(this, QObject::tr("Kst"), QObject::tr("Max and Min can not be equal."));
    _w->Min->setFocus();
    return false;
  }

  int new_n_bins = _w->N->text().toInt();
  if (_nDirty && new_n_bins < 1) {
    QMessageBox::warning(this, QObject::tr("Kst"), QObject::tr("You must have one or more bins in a histogram."));
    _w->N->setFocus();
    return false;
  }

  if (_vectorDirty) {
    KST::vectorList.lock().readLock();
    hsPtr->setVector(*KST::vectorList.findTag(_w->_vector->selectedVector()));
    KST::vectorList.lock().unlock();
  }

  hsPtr->writeLock();

  if (_nDirty) {
    hsPtr->setNBins(new_n_bins);
  }

  if (_minDirty || _maxDirty) {
    hsPtr->setXRange(new_min, new_max);
  }

  if (_realTimeAutoBinDirty) {
    hsPtr->setRealTimeAutoBin(_w->_realTimeAutoBin->isChecked());
  }

  if (_normIsPercentDirty || _normIsFractionDirty || _peakIs1Dirty || _normIsNumberDirty) {
    if (_w->NormIsPercent->isChecked()) {
      hsPtr->setIsNormPercent();
    } else if (_w->NormIsFraction->isChecked()) {
      hsPtr->setIsNormFraction();
    } else if (_w->PeakIs1->isChecked()) {
      hsPtr->setIsNormOne();
    } else {
      hsPtr->setIsNormNum();
    }
  }

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

  hsPtr->setDirty();
  hsPtr->unlock();

  return true;
}