本文整理汇总了C++中KstRMatrixPtr::dataSource方法的典型用法代码示例。如果您正苦于以下问题:C++ KstRMatrixPtr::dataSource方法的具体用法?C++ KstRMatrixPtr::dataSource怎么用?C++ KstRMatrixPtr::dataSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KstRMatrixPtr
的用法示例。
在下文中一共展示了KstRMatrixPtr::dataSource方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showMetadata
void KstObjectItem::showMetadata() {
if (_rtti == RTTI_OBJ_DATA_VECTOR) {
DataSourceMetaDataDialog *dlg = new DataSourceMetaDataDialog(_dm, 0, false, WDestructiveClose);
KstReadLocker vl(&KST::vectorList.lock());
KstVectorList::Iterator m = KST::vectorList.findTag(_tag);
KstRVectorPtr r = kst_cast<KstRVector>(*m);
KstDataSourcePtr dsp;
if (r) {
r->readLock();
dsp = r->dataSource();
r->unlock();
}
dlg->setDataSource(dsp);
dlg->show();
} else if (_rtti == RTTI_OBJ_DATA_MATRIX) {
DataSourceMetaDataDialog *dlg = new DataSourceMetaDataDialog(_dm, 0, false, WDestructiveClose);
KstReadLocker ml(&KST::matrixList.lock());
KstMatrixList::Iterator m = KST::matrixList.findTag(_tag);
KstRMatrixPtr r = kst_cast<KstRMatrix>(*m);
KstDataSourcePtr dsp;
if (r) {
r->readLock();
dsp = r->dataSource();
r->unlock();
}
dlg->setDataSource(dsp);
dlg->show();
}
}
示例2: sync
void KstMatrixDefaults::sync() {
KstRMatrixList::iterator it;
KstRMatrixList rmatrixList;
KstRMatrixPtr rmatrix;
KST::matrixList.lock().readLock();
rmatrixList = kstObjectSubList<KstMatrix,KstRMatrix>(KST::matrixList);
KST::matrixList.lock().unlock();
//
// find a non-stdin source...
//
for (it=rmatrixList.begin(); it!=rmatrixList.end(); ++it) {
KstDataSourcePtr dsp;
rmatrix = *it;
rmatrix->readLock();
dsp = rmatrix->dataSource();
rmatrix->unlock();
if (dsp && !kst_cast<KstStdinSource>(dsp)) {
break;
}
}
if (it != rmatrixList.end()) {
rmatrix->readLock();
_dataSource = rmatrix->filename();
_xStart = rmatrix->reqXStart();
_yStart = rmatrix->reqYStart();
_xNumSteps = rmatrix->reqXNumSteps();
_yNumSteps = rmatrix->reqYNumSteps();
_skip = rmatrix->skip();
_doAve = rmatrix->doAverage();
_doSkip = rmatrix->doSkip();
rmatrix->unlock();
}
}
示例3: 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();
//.........这里部分代码省略.........
示例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());
//.........这里部分代码省略.........