本文整理汇总了C++中KstDataSourcePtr::isValidMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ KstDataSourcePtr::isValidMatrix方法的具体用法?C++ KstDataSourcePtr::isValidMatrix怎么用?C++ KstDataSourcePtr::isValidMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KstDataSourcePtr
的用法示例。
在下文中一共展示了KstDataSourcePtr::isValidMatrix方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadMatrix
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: editSingleRMatrix
bool KstMatrixDialog::editSingleRMatrix(KstRMatrixPtr rmp) {
KstDataSourcePtr file;
QString pField;
bool doSkip, doAve;
int xStart;
int yStart;
int xNumSteps;
int yNumSteps;
int skip;
if (_fileNameDirty) {
KstDataSourceList::iterator it;
//
// if there is not an active KstFile, create one...
//
KST::dataSourceList.lock().writeLock();
// xxx it = KST::dataSourceList.findReusableFileName(_w->_fileName->url());
if (it == KST::dataSourceList.end()) {
// xxx file = KstDataSource::loadSource(_w->_fileName->url());
if (!file || !file->isValid()) {
KST::dataSourceList.lock().unlock();
QMessageBox::warning(this, QObject::tr("Kst"), QObject::tr("The file could not be opened."));
return false;
}
if (file->isEmpty()) {
KST::dataSourceList.lock().unlock();
QMessageBox::warning(this, QObject::tr("Kst"), QObject::tr("The file does not contain data."));
return false;
}
KST::dataSourceList.append(file);
} else {
file = *it;
}
KST::dataSourceList.lock().unlock();
pField = _w->_field->currentText();
if (!file->isValidMatrix(pField)) {
QMessageBox::warning(this, QObject::tr("Kst"), QObject::tr("The requested field is not defined for the requested file."));
file->unlock();
return false;
}
} else {
rmp->readLock();
file = rmp->dataSource();
pField = rmp->field();
rmp->unlock();
}
rmp->readLock();
if (_xStartDirty || _xStartCountFromEndDirty) {
xStart = _w->_xStartCountFromEnd->isChecked() ? -1 : _w->_xStart->value();
} else {
xStart = rmp->reqXStart();
}
if (_yStartDirty || _yStartCountFromEndDirty) {
yStart = _w->_yStartCountFromEnd->isChecked() ? -1 : _w->_yStart->value();
} else {
yStart = rmp->reqYStart();
}
if (_xNumStepsDirty || _xNumStepsReadToEndDirty) {
xNumSteps = _w->_xNumStepsReadToEnd->isChecked() ? -1 : _w->_xNumSteps->value();
} else {
xNumSteps = rmp->reqXNumSteps();
}
if (_yNumStepsDirty || _yNumStepsReadToEndDirty) {
yNumSteps = _w->_yNumStepsReadToEnd->isChecked() ? -1 : _w->_yNumSteps->value();
} else {
yNumSteps = rmp->reqYNumSteps();
}
if (_doSkipDirty) {
doSkip = _w->_doSkip->isChecked();
} else {
doSkip = rmp->doSkip();
}
if (_doAveDirty) {
doAve = _w->_doAve->isChecked();
} else {
doAve = rmp->doAverage();
}
if (_skipDirty) {
skip = _w->_skip->value();
} else {
skip = rmp->skip();
}
rmp->unlock();
//.........这里部分代码省略.........
示例3: new_IRMatrix
bool KstMatrixDialog::new_IRMatrix() {
KstDataSourcePtr file;
KstRMatrixPtr matrix;
KstDataSourceList::iterator it;
QString pField;
QString tagName;
bool doSkip;
bool doAve;
int xStart = _w->_xStartCountFromEnd->isChecked() ? -1 : _w->_xStart->value();
int yStart = _w->_yStartCountFromEnd->isChecked() ? -1 : _w->_yStart->value();
int xNumSteps = _w->_xNumStepsReadToEnd->isChecked() ? -1 : _w->_xNumSteps->value();
int yNumSteps = _w->_yNumStepsReadToEnd->isChecked() ? -1 : _w->_yNumSteps->value();
int skip;
//
// create a unique name...
//
tagName = (_tagName->text() == "<New_Matrix>") ? KST::suggestMatrixName(_w->_field->currentText()) : _tagName->text();
if (KstData::self()->matrixTagNameNotUnique(tagName)) {
_tagName->setFocus();
return false;
}
//
// if there is not an active KstFile, create one...
//
KST::dataSourceList.lock().writeLock();
// xxx it = KST::dataSourceList.findReusableFileName(_w->_fileName->url());
if (it == KST::dataSourceList.end()) {
// xxx file = KstDataSource::loadSource(_w->_fileName->url());
if (!file || !file->isValid()) {
KST::dataSourceList.lock().unlock();
QMessageBox::warning(this, QObject::tr("Kst"), QObject::tr("The file could not be opened."));
return false;
}
if (file->isEmpty()) {
KST::dataSourceList.lock().unlock();
QMessageBox::warning(this, QObject::tr("Kst"), QObject::tr("The file does not contain data."));
return false;
}
KST::dataSourceList.append(file);
} else {
file = *it;
}
KST::dataSourceList.lock().unlock();
pField = _w->_field->currentText();
if (!file->isValidMatrix(pField)) {
QMessageBox::warning(this, QObject::tr("Kst"), QObject::tr("The requested matrix is not defined for the requested file."));
file->unlock();
return false;
}
doSkip = _w->_doSkip->isChecked();
doAve = _w->_doAve->isChecked();
skip = _w->_skip->value();
matrix = new KstRMatrix(file, pField, KstObjectTag(tagName, file->tag(), false),
xStart, yStart, xNumSteps, yNumSteps, doAve, doSkip, skip);
emit matrixCreated(KstMatrixPtr(matrix));
matrix = 0L; // drop the reference
emit modified();
return true;
}
示例4: applyFileChange
bool KstChangeFileDialog::applyFileChange() {
KstDataSourcePtr file;
KST::dataSourceList.lock().writeLock();
KstDataSourceList::Iterator it = KST::dataSourceList.findReusableFileName(_dataFile->url());
QString invalidSources;
int invalid = 0;
if (it == KST::dataSourceList.end()) {
file = KstDataSource::loadSource(_dataFile->url());
if (!file || !file->isValid()) {
KST::dataSourceList.lock().unlock();
QMessageBox::warning(this, tr("Kst"), tr("The file could not be loaded."));
return false;
}
if (file->isEmpty()) {
KST::dataSourceList.lock().unlock();
QMessageBox::warning(this, tr("Kst"), tr("The file does not contain data."));
return false;
}
KST::dataSourceList.append(file);
} else {
file = *it;
}
KST::dataSourceList.lock().unlock();
KstApp *app = KstApp::inst();
KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
KstRMatrixList rml = kstObjectSubList<KstMatrix,KstRMatrix>(KST::matrixList);
int selected = 0;
int handled = 0;
int count = (int)ChangeFileCurveList->count();
for (int i = 0; i < count; i++) {
if (ChangeFileCurveList->isSelected(i)) {
++selected;
}
}
// a map to keep track of which objects have been duplicated, and mapping
// old object -> new object
KstDataObjectDataObjectMap duplicatedMap;
QMap<KstVectorPtr, KstVectorPtr> duplicatedVectors;
QMap<KstMatrixPtr, KstMatrixPtr> duplicatedMatrices;
KstDataSourceList oldSources;
// go through the vectors
for (int i = 0; i < (int)rvl.count(); i++) {
if (ChangeFileCurveList->isSelected(i)) {
KstRVectorPtr vector = rvl[i];
vector->writeLock();
file->readLock();
bool valid = file->isValidField(vector->field());
file->unlock();
if (!valid) {
if (invalid > 0) {
invalidSources = tr("%1, %2").arg(invalidSources).arg(vector->field());
} else {
invalidSources = vector->field();
}
++invalid;
} else {
if (_duplicateSelected->isChecked()) {
// block vector updates until vector is setup properly
KST::vectorList.lock().writeLock();
// create a new vector
KstRVectorPtr newVector = vector->makeDuplicate();
if (!oldSources.contains(newVector->dataSource())) {
oldSources << newVector->dataSource();
}
newVector->changeFile(file);
KST::vectorList.lock().unlock();
// duplicate dependents
if (_duplicateDependents->isChecked()) {
duplicatedVectors.insert(KstVectorPtr(vector), KstVectorPtr(newVector));
KST::duplicateDependents(KstVectorPtr(vector), duplicatedMap, duplicatedVectors);
}
} else {
if (!oldSources.contains(vector->dataSource())) {
oldSources << vector->dataSource();
}
vector->changeFile(file);
}
}
vector->unlock();
app->slotUpdateProgress(selected, ++handled, tr("Updating vectors..."));
}
}
// go through the matrices
for (int i = (int)rvl.count(); i < (int)ChangeFileCurveList->count(); i++) {
if (ChangeFileCurveList->isSelected(i)) {
KstRMatrixPtr matrix = rml[i-rvl.count()];
matrix->writeLock();
file->readLock();
bool valid = file->isValidMatrix(matrix->field());
file->unlock();
//.........这里部分代码省略.........
示例5: applyFileChange
bool KstChangeFileDialogI::applyFileChange() {
KstDataSourcePtr file;
KST::dataSourceList.lock().writeLock();
KstDataSourceList::Iterator it = KST::dataSourceList.findReusableFileName(_dataFile->url());
QString invalidSources;
int invalid = 0;
if (it == KST::dataSourceList.end()) {
file = KstDataSource::loadSource(_dataFile->url());
if (!file || !file->isValid()) {
KST::dataSourceList.lock().unlock();
KMessageBox::sorry(this, i18n("The file could not be loaded."));
return false;
}
if (file->isEmpty()) {
KST::dataSourceList.lock().unlock();
KMessageBox::sorry(this, i18n("The file does not contain data."));
return false;
}
KST::dataSourceList.append(file);
} else {
file = *it;
}
KST::dataSourceList.lock().unlock();
KstApp *app = KstApp::inst();
KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
KstRMatrixList rml = kstObjectSubList<KstMatrix,KstRMatrix>(KST::matrixList);
int selected = 0;
int handled = 0;
int count = (int)ChangeFileCurveList->count();
for (int i = 0; i < count; i++) {
if (ChangeFileCurveList->isSelected(i)) {
++selected;
}
}
// a map to keep track of which objects have been duplicated, and mapping
// old object -> new object
KstDataObjectDataObjectMap duplicatedMap;
QMap<KstVectorPtr, KstVectorPtr> duplicatedVectors;
QMap<KstMatrixPtr, KstMatrixPtr> duplicatedMatrices;
KstDataSourceList oldSources;
// go through the vectors
for (int i = 0; i < (int)rvl.count(); i++) {
if (ChangeFileCurveList->isSelected(i)) {
KstRVectorPtr vector = rvl[i];
vector->writeLock();
file->readLock();
bool valid = file->isValidField(vector->field());
file->unlock();
if (!valid) {
if (invalid > 0) {
// FIXME: invalid list construction for i18n
invalidSources = i18n("%1, %2").arg(invalidSources).arg(vector->field());
} else {
invalidSources = vector->field();
}
++invalid;
} else {
if (_duplicateSelected->isChecked()) {
// block vector updates until vector is setup properly
KST::vectorList.lock().writeLock();
// create a new vector
KstRVectorPtr newVector = vector->makeDuplicate();
if (!oldSources.contains(newVector->dataSource())) {
oldSources << newVector->dataSource();
}
newVector->changeFile(file);
KST::vectorList.lock().unlock();
// duplicate dependents
if (_duplicateDependents->isChecked()) {
duplicatedVectors.insert(KstVectorPtr(vector), KstVectorPtr(newVector));
KST::duplicateDependents(KstVectorPtr(vector), duplicatedMap, duplicatedVectors);
}
} else {
if (!oldSources.contains(vector->dataSource())) {
oldSources << vector->dataSource();
}
vector->changeFile(file);
}
}
vector->unlock();
app->slotUpdateProgress(selected, ++handled, i18n("Updating vectors..."));
}
}
// go through the matrices
for (int i = (int)rvl.count(); i < (int)ChangeFileCurveList->count(); i++) {
if (ChangeFileCurveList->isSelected(i)) {
KstRMatrixPtr matrix = rml[i-rvl.count()];
matrix->writeLock();
file->readLock();
bool valid = file->isValidMatrix(matrix->field());
//.........这里部分代码省略.........
示例6: main
//.........这里部分代码省略.........
KstHistogram::AutoBin(KstVectorPtr(yvector), &N, &max, &min);
hs = new KstHistogram(KST::suggestHistogramName(yvector->tag()),
KstVectorPtr(yvector), min, max, N, KST_HS_NUMBER);
KstVCurvePtr vc = new KstVCurve(KST::suggestCurveName(hs->tag(), true),
hs->vX(), hs->vY(),
0L, 0L, 0L, 0L, color);
vc->setHasPoints(false);
vc->setHasLines(false);
vc->setHasBars(true);
vc->setBarStyle(1);
KST::dataObjectList.lock().writeLock();
KST::dataObjectList.append(hs.data());
KST::dataObjectList.append(vc.data());
KST::dataObjectList.lock().unlock();
plot->addCurve(vc.data());
if (in.sep_plots) {
plot->setTagName(hs->tag());
i_plot++;
if (i_plot < in.n_plots) {
plot = *plist.at(i_plot);
}
}
}
} // next histogram
} // end (if there are some histograms)
if (matrixList.count() > 0) { // if there are some matrixes
for (mat_i = matrixList.begin(); mat_i != matrixList.end(); ++mat_i) {
QString tag_name = KST::suggestMatrixName(*mat_i);
if (!file->isValidMatrix(*mat_i)) {
startupErrors.append(i18n("Failed to create matrix '%1' from file '%2'.").arg(*mat_i).arg(file->fileName()));
}
KstRMatrixPtr matrix = new KstRMatrix(file, *mat_i,
KstObjectTag(tag_name, file->tag()),
0,0,-1,-1,false,false,0);
// xStart, yStart, xNumSteps, yNumSteps,
//doAve, doSkip, skip);
// Time to create the image from the matrix
tag_name = KST::suggestImageName(matrix->tag());
QStringList palList = KPalette::getPaletteList();
QString pal;
if (palList.contains("IDL 13 RAINBOW")) {
pal = QString("IDL 13 RAINBOW");
} else {
pal = QString(*palList.at(0));
}
KPalette* newPal = new KPalette(pal);
KstImagePtr image = new KstImage(tag_name, KstMatrixPtr(matrix), 0.0, 1.0,
true, newPal);
plot->addCurve(KstBaseCurvePtr(image));
KST::dataObjectList.lock().writeLock();
KST::dataObjectList.append(image.data());
KST::dataObjectList.lock().unlock();
image = 0L; // drop the reference
if (in.sep_plots) {
plot->setTagName(matrix->tag());
i_plot++;
if (i_plot < in.n_plots) {
plot = *plist.at(i_plot);