本文整理汇总了C++中KstMatrixPtr类的典型用法代码示例。如果您正苦于以下问题:C++ KstMatrixPtr类的具体用法?C++ KstMatrixPtr怎么用?C++ KstMatrixPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KstMatrixPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
QString KstIfaceImpl::loadMatrix(const QString& name, const QString& file, const QString& field,
int xStart, int yStart, int xNumSteps, int yNumSteps,
int skipFrames, bool boxcarFilter) {
KstDataSourcePtr src;
/* generate or find the kstfile */
KST::dataSourceList.lock().writeLock();
KstDataSourceList::Iterator it = KST::dataSourceList.findReusableFileName(file);
if (it == KST::dataSourceList.end()) {
src = KstDataSource::loadSource(file);
if (!src || !src->isValid()) {
KST::dataSourceList.lock().unlock();
return QString::null;
}
if (src->isEmpty()) {
KST::dataSourceList.lock().unlock();
return QString::null;
}
KST::dataSourceList.append(src);
} else {
src = *it;
}
src->writeLock();
KST::dataSourceList.lock().unlock();
// make sure field is valid
if (!src->isValidMatrix(field)) {
src->unlock();
return QString::null;
}
// make sure name is unique, else generate a unique one
KST::matrixList.lock().readLock();
QString matrixName;
if (name.isEmpty()) {
matrixName = "M" + QString::number(KST::matrixList.count() + 1);
} else {
matrixName = name;
}
while (KstData::self()->matrixTagNameNotUnique(matrixName, false)) {
matrixName = "M" + QString::number(KST::matrixList.count() + 1);
}
KST::matrixList.lock().unlock();
KstMatrixPtr p = new KstRMatrix(src, field, matrixName, xStart, yStart, xNumSteps, yNumSteps,
boxcarFilter, skipFrames > 0, skipFrames);
KST::addMatrixToList(p);
src->unlock();
if (p) {
_doc->forceUpdate();
_doc->setModified();
return p->tagName();
}
return QString::null;
}
示例2: hitsMap
QString BinnedMap::hitsMapTag() const {
KstMatrixPtr m = hitsMap();
if (m) {
return m->tagName();
}
return QString::null;
}
示例3: paintCell
void KstMatrixTable::paintCell( QPainter* painter, int row, int col, const QRect& cr, bool selected, const QColorGroup& cg ) {
KstMatrixList matrices = KST::matrixList;
KstMatrixPtr matrix = *matrices.findTag(_strMatrix);
QString str;
double value;
painter->eraseRect( 0, 0, cr.width(), cr.height() );
if (selected) {
painter->fillRect( 0, 0, cr.width(), cr.height(), cg.highlight() );
painter->setPen(cg.highlightedText());
} else {
painter->fillRect( 0, 0, cr.width(), cr.height(), cg.base() );
painter->setPen(cg.text());
}
if (matrix) {
bool ok;
value = matrix->valueRaw(col, row, &ok);
if (ok) {
str.setNum(value, 'g', 16);
}
}
painter->drawText(0, 0, cr.width(), cr.height(), AlignLeft, str);
}
示例4: i18n
void KstCSD::commonConstructor(const QString& in_tag, KstVectorPtr in_V,
double in_freq, bool in_average, bool in_removeMean, bool in_apodize,
ApodizeFunction in_apodizeFxn, int in_windowSize, int in_averageLength,
double in_gaussianSigma, const QString& in_vectorUnits,
const QString& in_rateUnits, PSDType in_outputType, const QString& vecName) {
_typeString = i18n("Cumulative Spectral Decay");
_inputVectors[INVECTOR] = in_V;
setTagName(in_tag);
_frequency = in_freq;
_average = in_average;
_apodize = in_apodize;
_windowSize = in_windowSize;
_apodizeFxn = in_apodizeFxn;
_gaussianSigma = in_gaussianSigma;
_removeMean = in_removeMean;
_averageLength = in_averageLength;
_vectorUnits = in_vectorUnits;
_rateUnits = in_rateUnits;
_outputType = in_outputType;
if (_frequency <= 0.0) {
_frequency = 1.0;
}
KstMatrixPtr outMatrix = new KstMatrix(in_tag+"-csd", this, 1, 1);
outMatrix->setLabel(i18n("Power [%1/%2^{1/2}]").arg(_vectorUnits).arg(_rateUnits));
outMatrix->setXLabel(i18n("%1 [%2]").arg(vecName).arg(_vectorUnits));
outMatrix->setYLabel(i18n("Frequency [%1]").arg(_rateUnits));
_outMatrix = _outputMatrices.insert(OUTMATRIX, outMatrix);
KST::addMatrixToList(outMatrix);
updateMatrixLabels();
(*_outMatrix)->setDirty();
}
示例5: QObject
KstObjectItem::KstObjectItem(QListViewItem *parent, KstMatrixPtr x, KstDataManagerI *dm, int localUseCount)
: QObject(), QListViewItem(parent), _rtti(RTTI_OBJ_MATRIX), _tag(x->tag()), _dm(dm) {
assert(x);
_inUse = false;
setText(0, x->tag().tag());
setText(1, i18n("Slave Matrix"));
x = 0L; // keep the counts in sync
update(true, localUseCount);
}
示例6: newMatrixCreated
void MatrixSelector::newMatrixCreated( KstMatrixPtr v ) {
QString name;
v->readLock();
name = v->tagName();
v->unlock();
v = 0L; // deref
emit newMatrixCreated(name);
}
示例7: replaceDependency
void EventMonitorEntry::replaceDependency(KstMatrixPtr oldMatrix, KstMatrixPtr newMatrix) {
QString newExp = _event;
// also replace all occurences of scalar stats for the oldMatrix
QHashIterator<QString, KstScalar*> scalarDictIter(oldMatrix->scalars());
while (scalarDictIter.hasNext()) {
const QString oldTag = scalarDictIter.next().value()->tagName();
const QString newTag = newMatrix->scalars()[scalarDictIter.key()]->tagName();
newExp = newExp.replace("[" + oldTag + "]", "[" + newTag + "]");
}
setEvent(newExp);
setDirty();
}
示例8: 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();
}
}
}
示例9: 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());
}
}
示例10: editMatrix
void MatrixSelector::editMatrix() {
KstDataObjectPtr pro;
KstMatrixPtr matrix;
KST::matrixList.lock().readLock();
matrix = *KST::matrixList.findTag(_matrix->currentText());
KST::matrixList.lock().unlock();
if (matrix) {
pro = kst_cast<KstDataObject>(matrix->provider());
}
if (pro) {
pro->readLock();
pro->showDialog(false);
pro->unlock();
} else {
// xxx KstDialogs::self()->showMatrixDialog(_matrix->currentText(), true);
}
}
示例11: 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();
}
}
示例12: i18n
void KstCSD::commonConstructor(const QString& in_tag, KstVectorPtr in_V, double in_freq, bool in_average,
bool in_removeMean, bool in_apodize, ApodizeFunction in_apodizeFxn, int in_windowSize,
int in_averageLength, double in_gaussianSigma, const QString& in_vectorUnits,
const QString& in_rateUnits, PSDType in_outputType, bool in_interpolateHoles,
const QString& vecName) {
_typeString = i18n("Spectrogram");
_type = "Spectrogram";
_inputVectors[INVECTOR] = in_V;
setTagName(KstObjectTag::fromString(in_tag));
_frequency = in_freq;
_average = in_average;
_apodize = in_apodize;
_windowSize = in_windowSize;
_apodizeFxn = in_apodizeFxn;
_gaussianSigma = in_gaussianSigma;
_removeMean = in_removeMean;
_averageLength = in_averageLength;
_vectorUnits = in_vectorUnits;
_rateUnits = in_rateUnits;
_outputType = in_outputType;
_interpolateHoles = in_interpolateHoles;
if (_frequency <= 0.0) {
_frequency = 1.0;
}
{
KstWriteLocker blockMatrixUpdates(&KST::matrixList.lock());
KstMatrixPtr outMatrix = new KstMatrix(KstObjectTag("csd", tag()), this, 1, 1);
outMatrix->setLabel(i18n("Power [%1/%2^{1/2}]").arg(_vectorUnits).arg(_rateUnits));
outMatrix->setXLabel(i18n("%1 [%2]").arg(vecName).arg(_vectorUnits));
outMatrix->setYLabel(i18n("Frequency [%1]").arg(_rateUnits));
_outMatrix = _outputMatrices.insert(OUTMATRIX, outMatrix);
}
updateMatrixLabels();
(*_outMatrix)->setDirty();
}
示例13: 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();
}
}
}
示例14: switch
//.........这里部分代码省略.........
found = true;
break;
}
}
if (!found) {
KstObjectItem *item = new KstObjectItem(this, p.data(), _dm);
connect(item, SIGNAL(updated()), this, SIGNAL(updated()));
}
}
}
_removable = x->getUsage() == 1;
x->unlock();
}
break;
}
case RTTI_OBJ_DATA_MATRIX:
{
KST::matrixList.lock().readLock();
KstRMatrixPtr x = kst_cast<KstRMatrix>(*KST::matrixList.findTag(_tag));
KST::matrixList.lock().unlock();
if (x) {
x->readLock();
// getUsage: subtract 1 for KstRMatrixPtr x
bool inUse = (x->getUsage() - 1 - localUseCount) > 0;
if (inUse != _inUse) {
_inUse = inUse;
setPixmap(2, inUse ? _dm->yesPixmap() : QPixmap());
}
QString field = QString::number(x->sampleCount());
if (text(3) != field) {
setText(3, field);
}
field = i18n("%1: %2 (%3 by %4)").arg(x->filename()).arg(x->field())
.arg(x->xNumSteps())
.arg(x->yNumSteps());
if (text(4) != field) {
setText(4, field);
}
_removable = x->getUsage() == 2;
x->unlock();
}
break;
}
case RTTI_OBJ_STATIC_MATRIX:
{
KST::matrixList.lock().readLock();
KstSMatrixPtr x = kst_cast<KstSMatrix>(*KST::matrixList.findTag(_tag));
KST::matrixList.lock().unlock();
if (x) {
x->readLock();
// getUsage: subtract 1 for KstRMatrixPtr x
bool inUse = (x->getUsage() - 1 - localUseCount) > 0;
if (inUse != _inUse) {
_inUse = inUse;
setPixmap(2, inUse ? _dm->yesPixmap() : QPixmap());
}
QString field = QString::number(x->sampleCount());
if (text(3) != field) {
setText(3, field);
}
field = i18n("%1 to %2").arg(x->gradZMin()).arg(x->gradZMax());
if (text(4) != field) {
setText(4, field);
}
_removable = x->getUsage() == 2;
x->unlock();
}
break;
}
case RTTI_OBJ_MATRIX:
{
KST::matrixList.lock().readLock();
KstMatrixPtr x = *KST::matrixList.findTag(_tag);
KST::matrixList.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->sampleCount());
if (text(3) != field) {
setText(3, field);
}
field = i18n("[%1..%2]").arg(x->minValue()).arg(x->maxValue());
if (text(4) != field) {
setText(4, field);
}
x->unlock();
_removable = false;
}
break;
}
default:
assert(0);
}
}
示例15: 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);
//.........这里部分代码省略.........