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


C++ KstMatrixPtr::readLock方法代码示例

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


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

示例1: fillFieldsForEdit

void KstMatrixDialog::fillFieldsForEdit() {
  KstMatrixPtr mp;

  mp = kst_cast<KstMatrix>(_dp);
  if (mp) {
    KstRMatrixPtr rmp;

    mp->readLock();
    _tagName->setText(mp->tagName());
    _w->_minX->setText(QString::number(mp->minX()));
    _w->_minY->setText(QString::number(mp->minY()));
    _w->_xStep->setText(QString::number(mp->xStepSize()));
    _w->_yStep->setText(QString::number(mp->yStepSize()));
    mp->unlock();
  
    _w->_sourceGroup->hide();
  
    rmp = kst_cast<KstRMatrix>(mp);
    if (rmp) {
      fillFieldsForRMatrixEdit();
    } else {
      fillFieldsForSMatrixEdit();
    }
  
    updateEnables();
  
    adjustSize();
    resize(minimumSizeHint());
    setFixedHeight(height());
  }
}
开发者ID:,项目名称:,代码行数:31,代码来源:

示例2: newMatrixCreated

void MatrixSelector::newMatrixCreated( KstMatrixPtr v ) {
  QString name;

  v->readLock();
  name = v->tagName();
  v->unlock();
  v = 0L; // deref

  emit newMatrixCreated(name);
}
开发者ID:,项目名称:,代码行数:10,代码来源:

示例3: calcAutoThreshold

void KstImageDialogI::calcAutoThreshold() {
  //make sure an matrix is selected
  if (!_w->_matrix->selectedMatrix().isEmpty()){
    KST::matrixList.lock().readLock();
    KstMatrixPtr matrix = *KST::matrixList.findTag(_w->_matrix->selectedMatrix());
    KST::matrixList.lock().unlock();
    if (matrix) {
      matrix->readLock();
      _w->_lowerZ->setText(QString::number(matrix->minValue()));
      _w->_upperZ->setText(QString::number(matrix->maxValue()));
      matrix->unlock();
    }
  }
}
开发者ID:,项目名称:,代码行数:14,代码来源:

示例4: calcSmartThreshold

// This should use a smart (percentile based) algorithm to
// calculate the thresholds.  It will be expensive.
void KstImageDialogI::calcSmartThreshold() {
  //make sure an matrix is selected
  if (!_w->_matrix->selectedMatrix().isEmpty()){
    KST::matrixList.lock().readLock();
    KstMatrixPtr matrix = *KST::matrixList.findTag(_w->_matrix->selectedMatrix());
    KST::matrixList.lock().unlock();
    if (matrix) {
      matrix->readLock();
      double per = _w->_smartThresholdValue->value()/100.0;

      matrix->calcNoSpikeRange(per);
      _w->_lowerZ->setText(QString::number(matrix->minValueNoSpike()));
      _w->_upperZ->setText(QString::number(matrix->maxValueNoSpike()));
      matrix->unlock();
    }
  }
}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例5: updateViewMatricesDialog

void KstViewMatricesDialogI::updateViewMatricesDialog(const QString& matrixName) {
  int needed = 0;
  
  KST::matrixList.lock().readLock();
  KstMatrixPtr matrix = *KST::matrixList.findTag(matrixName);
  KST::matrixList.lock().unlock();
  if (matrix) {
    matrix->readLock();
    
    needed = matrix->xNumSteps();
    if (needed != _tableMatrices->numCols()) {
      _tableMatrices->setNumCols(needed);
    }    
    
    needed = matrix->yNumSteps();
    if (needed != _tableMatrices->numRows()) {
      _tableMatrices->setNumRows(needed);
    }  
        
    matrix->unlock();
  }
}
开发者ID:,项目名称:,代码行数:22,代码来源:

示例6: update

void KstObjectItem::update(bool recursive, int localUseCount) {
  switch (_rtti) {
    case RTTI_OBJ_DATA_VECTOR:
    {
      KST::vectorList.lock().readLock();
      KstRVectorPtr x = kst_cast<KstRVector>(*KST::vectorList.findTag(_tag));
      KST::vectorList.lock().unlock();
      if (x) {
        x->readLock();
        // getUsage: subtract 1 for KstRVectorPtr x
        bool inUse = (x->getUsage() - 1 - localUseCount) > 0;
        if (inUse != _inUse) {
          _inUse = inUse;
          setPixmap(2, inUse ? _dm->yesPixmap() : QPixmap());
        }
        QString field;
        if (inUse) {
          field = QString::number(x->length());
        } else {
          field = "-";
        }
        if (text(3) != field) {
          setText(3, field);
        }
        field = i18n("%3: %4 [%1..%2]").arg(x->reqStartFrame())
            .arg(x->reqStartFrame() + x->reqNumFrames())
            .arg(x->filename())
            .arg(x->field());
        if (text(4) != field) {
          setText(4, field);
        }
        _removable = x->getUsage() == 2;
        x->unlock();
      }
      // Hmmm what happens if this if() fails??  We become inconsistent?
      break;
    }
    case RTTI_OBJ_STATIC_VECTOR:
    {
      KST::vectorList.lock().readLock();
      KstSVectorPtr x = kst_cast<KstSVector>(*KST::vectorList.findTag(_tag));
      KST::vectorList.lock().unlock();
      if (x) {
        x->readLock();
        // getUsage: subtract 1 for KstRVectorPtr x
        bool inUse = (x->getUsage() - 1 - localUseCount) > 0;
        if (inUse != _inUse) {
          _inUse = inUse;
          setPixmap(2, inUse ? _dm->yesPixmap() : QPixmap());
        }
        QString field;
        if (inUse) {
          field = QString::number(x->length());
        } else {
          field = "-";
        }
        if (text(3) != field) {
          setText(3, field);
        }
        field = i18n("%1 to %2").arg(x->min()).arg(x->max());
        if (text(4) != field) {
          setText(4, field);
        }
        _removable = x->getUsage() == 2;
        x->unlock();
      }
      // Hmmm what happens if this if() fails??  We become inconsistent?
      break;
    }
    case RTTI_OBJ_VECTOR:
    {
      KST::vectorList.lock().readLock();
      KstVectorPtr x = *KST::vectorList.findTag(_tag);
      KST::vectorList.lock().unlock();
      if (x) {
        x->readLock();
        // getUsage:
        //  subtract 1 for KstVectorPtr x
        bool inUse = (x->getUsage() - 1 - localUseCount) > 0;
        if (inUse != _inUse) {
          _inUse = inUse;
          setPixmap(2, inUse ? _dm->yesPixmap() : QPixmap());
        }
        QString field = QString::number(x->length());
        if (text(3) != field) {
          setText(3, field);
        }
        field = i18n("[%1..%2]").arg(x->min()).arg(x->max());
        if (text(4) != field) {
          setText(4, field);
        }
        x->unlock();
        _removable = false;
      }
      break;
    }
    case RTTI_OBJ_OBJECT:
    {
      KST::dataObjectList.lock().readLock();
      KstDataObjectPtr x = *KST::dataObjectList.findTag(_tag.tag());
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例7: setSelection

void MatrixSelector::setSelection( KstMatrixPtr v ) {
  v->readLock();
  setSelection(v->tagName());
  v->unlock();
}
开发者ID:,项目名称:,代码行数:5,代码来源:

示例8: newObject

bool KstImageDialogI::newObject() {
  //if matrixCombo is empty then display an error message
  if (_w->_matrix->selectedMatrix().isEmpty()){
    KMessageBox::sorry(this, i18n("Matrix is a 2D grid of numbers, used to create image", "New image not made: define matrix first."));
    return false;
  }

  //do some checks on the inputs
  double lowerZDouble, upperZDouble;
  if (!checkParameters(lowerZDouble, upperZDouble)) {
    return false;
  }

  KST::matrixList.lock().readLock();
  KstMatrixPtr matrix = *KST::matrixList.findTag(_w->_matrix->selectedMatrix());
  KST::matrixList.lock().unlock();
  if (!matrix) {
    KMessageBox::sorry(this, i18n("Matrix is a 2D grid of numbers, used to create image", "Could not find matrix."));
    return false;
  }
  KST::dataObjectList.lock().readLock();
  matrix->readLock();

  //create a unique name
  QString tag_name = KST::suggestImageName(matrix->tag());
  if (KstData::self()->dataTagNameNotUnique(tag_name)) {
    _tagName->setFocus();
    matrix->unlock();
    KST::dataObjectList.lock().unlock();
    return false;
  }

  KstImagePtr image;
  if (_w->_contourOnly->isChecked()) {
    //need a contour map only
    QColor tempColor = _w->_contourColor->color();
    image = new KstImage(tag_name, matrix, _w->_numContourLines->text().toInt(), tempColor,
                         _w->_useVariableWeight->isChecked() ? -1 : _w->_contourWeight->value());
  } else if (_w->_colorOnly->isChecked()) {
    //need a color map only
    KPalette* newPal = new KPalette(_w->_colorPalette->selectedPalette());
    image = new KstImage(tag_name, matrix, lowerZDouble, upperZDouble,
                         _w->_realTimeAutoThreshold->isChecked(), newPal);
  } else {
    //need both a contour map and colour map
    QColor tempColor = _w->_contourColor->color();
    KPalette* newPal = new KPalette(_w->_colorPalette->selectedPalette());
    image = new KstImage(tag_name, matrix, lowerZDouble, upperZDouble,
                         _w->_realTimeAutoThreshold->isChecked(), newPal,
                         _w->_numContourLines->text().toInt(), tempColor,
                         _w->_useVariableWeight->isChecked() ? -1 : _w->_contourWeight->value());
  }
  matrix->unlock();
  KST::dataObjectList.lock().unlock();
  placeInPlot(image);
  KST::dataObjectList.lock().writeLock();
  KST::dataObjectList.append(image.data());
  KST::dataObjectList.lock().unlock();
  image = 0L; // drop the reference
  emit modified();
  return true;
}
开发者ID:,项目名称:,代码行数:62,代码来源:

示例9: createImage

QString KstIfaceImpl::createImage(const QString &name,
                                  const QString &in_matrix,
                                  double lowerZ,
                                  double upperZ,
                                  const QString &paletteName,
                                  int numContours,
                                  const QColor& contourColor,
                                  uint imageType) {
  //get the matrix
  KstMatrixList matrices = kstObjectSubList<KstDataObject, KstMatrix>(KST::dataObjectList);
  KstMatrixPtr matrix = *matrices.findTag(in_matrix);
  if (!matrix) {
    return QString::null;
  }

  //make a name if necessary
  QString imgtag;
  if (name.isEmpty()) {
    imgtag = KST::suggestImageName(in_matrix);
  } else {
    QString imgtag_end = QString(name);
    //count number of data objects and make a unique name
    int i = KST::dataObjectList.count() + 1;
    imgtag = QString::number(i) + "-" + imgtag_end;
  }
  while (KstData::self()->dataTagNameNotUnique(imgtag, false)) {
    imgtag += "\'";
  }

  //determine the image type
  KstImagePtr image;
  if (imageType == 0) {
    //need a colormap
    if (lowerZ > upperZ) {
      return QString::null;
    }
    KPalette* pal = new KPalette(paletteName);
    matrix->readLock();
    image = new KstImage(imgtag, matrix, lowerZ, upperZ, false, pal);
    matrix->unlock();
  } else if (imageType == 1) {
    //need a contourmap
    if (numContours < 1) {
      return QString::null;
    }
    matrix->readLock();
    image = new KstImage(imgtag, matrix, numContours, contourColor.isValid() ? contourColor : QColor("darkBlue"), 0);
    matrix->unlock();
  } else if (imageType == 2) {
    //need both contourmap and colormap
    if (lowerZ > upperZ) {
      return QString::null;
    }
    if (numContours < 1) {
      return QString::null;
    }
    KPalette* pal = new KPalette(paletteName);
    matrix->readLock();
    image = new KstImage(imgtag, matrix, lowerZ, upperZ, false, pal,
                         numContours, contourColor.isValid() ? contourColor : QColor("darkBlue"), 0);
    matrix->unlock();
  } else {
    return QString::null;
  }

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

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

  return imgtag;

}
开发者ID:,项目名称:,代码行数:75,代码来源:


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