本文整理汇总了C++中KstDataSourcePtr::frameCount方法的典型用法代码示例。如果您正苦于以下问题:C++ KstDataSourcePtr::frameCount方法的具体用法?C++ KstDataSourcePtr::frameCount怎么用?C++ KstDataSourcePtr::frameCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KstDataSourcePtr
的用法示例。
在下文中一共展示了KstDataSourcePtr::frameCount方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: frameCount
KJS::Value KstBindDataSource::frameCount(KJS::ExecState *exec, const KJS::List& args) {
QString field;
if (args.size() == 1) {
if (args[0].type() != KJS::StringType) {
KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
exec->setException(eobj);
return KJS::Number(0);
}
field = args[0].toString(exec).qstring();
} else if (args.size() != 0) {
KJS::Object eobj = KJS::Error::create(exec, KJS::SyntaxError, "Requires at most one argument.");
exec->setException(eobj);
return KJS::Number(0);
}
KstDataSourcePtr s = makeSource(_d);
if (!s) {
KJS::Object eobj = KJS::Error::create(exec, KJS::GeneralError);
exec->setException(eobj);
return KJS::Number(0);
}
s->writeLock();
int rc = s->frameCount(field);
s->unlock();
return KJS::Number(rc);
}
示例2: new_I
void KstVectorDialogI::new_I() {
KstDataSourcePtr file;
KstRVectorPtr vector;
KstRVectorList vectorList = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
QString tag_name = Select->currentText();
tag_name.replace(i18n("<New_Vector>"), Field->currentText());
KST::vectorList.lock().readLock();
int i_c = KST::vectorList.count() + 1;
KST::vectorList.lock().readUnlock();
while (KST::dataTagNameNotUnique(tag_name, false)) {
tag_name.sprintf("V%d-", i_c);
tag_name += Field->currentText();
i_c++;
}
/* if there is not an active KstFile, create one */
{
KST::dataSourceList.lock().writeLock();
KstDataSourceList::Iterator it = KST::dataSourceList.findFileName(FileName->url());
if (it == KST::dataSourceList.end()) {
file = KstDataSource::loadSource(FileName->url());
if (!file || !file->isValid()) {
KMessageBox::sorry(0L, i18n("The file could not be loaded."));
return;
}
if (file->frameCount() < 1) {
KMessageBox::sorry(0L, i18n("The file does not contain data."));
return;
}
KST::dataSourceList.append(file);
} else {
file = *it;
}
KST::dataSourceList.lock().writeUnlock();
}
if (!file->isValidField(Field->currentText())) {
KMessageBox::sorry(0L, i18n("The requested field is not defined for the requested file."));
return;
}
/* create the vector */
vector = new KstRVector(file, Field->currentText(),
tag_name,
(CountFromEnd->isChecked() ? -1 : F0->value()),
(ReadToEnd->isChecked() ? -1 : N->value()),
Skip->value(),
DoSkip->isChecked(),
DoFilter->isChecked());
emit vectorCreated(KstVectorPtr(vector));
vector = 0L;
vectorList.clear();
emit modified();
}
示例3: applyNptsChange
void KstChangeNptsDialogI::applyNptsChange() {
KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
for (uint i = 0; i < CurveList->count(); ++i) {
if (CurveList->isSelected(i)) {
KstRVectorPtr vector = *(rvl.findTag(CurveList->text(i)));
if (vector) {
int f0, n;
vector->readLock();
KstDataSourcePtr ds = vector->dataSource();
if (_kstDataRange->isStartRelativeTime() && ds) {
ds->readLock();
f0 = ds->sampleForTime(_kstDataRange->f0Value());
ds->unlock();
} else if (_kstDataRange->isStartAbsoluteTime() && ds) {
ds->readLock();
f0 = ds->sampleForTime(_kstDataRange->f0DateTimeValue());
ds->unlock();
} else {
f0 = int(_kstDataRange->f0Value());
}
if (_kstDataRange->isRangeRelativeTime() && ds) {
ds->readLock();
double nValStored = _kstDataRange->nValue();
if (_kstDataRange->CountFromEnd->isChecked()) {
int frameCount = ds->frameCount(vector->field());
double msCount = ds->relativeTimeForSample(frameCount - 1);
n = frameCount - 1 - ds->sampleForTime(msCount - nValStored);
} else {
double fTime = ds->relativeTimeForSample(f0);
n = ds->sampleForTime(fTime + nValStored) - ds->sampleForTime(fTime);
}
ds->unlock();
} else {
n = int(_kstDataRange->nValue());
}
vector->unlock();
vector->writeLock();
vector->changeFrames(
(_kstDataRange->CountFromEnd->isChecked() ? -1 : f0),
(_kstDataRange->ReadToEnd->isChecked() ? -1 : n),
_kstDataRange->Skip->value(),
_kstDataRange->DoSkip->isChecked(),
_kstDataRange->DoFilter->isChecked());
vector->unlock();
}
}
}
_modifiedRange = false;
// avoid re-entering the dialog
QTimer::singleShot(0, this, SLOT(emitDocChanged()));
}
示例4: while
const QString& KstIfaceImpl::loadVector(const QString& file, const QString& field) {
KstDataSourcePtr src;
/* generate or find the kstfile */
KST::dataSourceList.lock().writeLock();
KstDataSourceList::Iterator it = KST::dataSourceList.findFileName(file);
if (it == KST::dataSourceList.end()) {
src = KstDataSource::loadSource(file);
if (!src || !src->isValid()) {
KST::dataSourceList.lock().writeUnlock();
return QString::null;
}
if (src->frameCount() < 1) {
KST::dataSourceList.lock().writeUnlock();
return QString::null;
}
KST::dataSourceList.append(src);
} else {
src = *it;
}
src->writeLock();
KST::dataSourceList.lock().writeUnlock();
KST::vectorList.lock().readLock();
QString vname = "V" + QString::number(KST::vectorList.count() + 1);
while (KST::vectorTagNameNotUnique(vname, false)) {
vname = "V" + QString::number(KST::vectorList.count() + 1);
}
KST::vectorList.lock().readUnlock();
KstVectorPtr p = new KstRVector(src, field, vname, 0, -1, 0, false, false);
KST::addVectorToList(p);
src->writeUnlock();
if (p) {
_doc->forceUpdate();
_doc->setModified();
return p->tagName();
}
return QString::null;
}
示例5: applyFileChange
void KstChangeFileDialogI::applyFileChange() {
KstDataSourcePtr file;
KstRVectorPtr vector;
KstWriteLocker ml(&KST::dataSourceList.lock());
/* if there is not an active KstFile, create one */
KstDataSourceList::Iterator it;
for (it = KST::dataSourceList.begin(); it != KST::dataSourceList.end(); ++it) {
if ((*it)->fileName() == ChangeFileName->currentText()) {
file = *it;
break;
}
}
if (it == KST::dataSourceList.end()) {
file = KstDataSource::loadSource(ChangeFileName->currentText());
if (!file || !file->isValid()) {
KMessageBox::sorry(0L, i18n("%1: Unable to open file.").arg(ChangeFileName->currentText()));
return;
}
if (file->frameCount() < 1) {
KMessageBox::sorry(0L, i18n("%1: File does not contain data. Operation canceled.").arg(ChangeFileName->currentText()));
return;
}
KST::dataSourceList.append(file);
}
KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
for (int i = 0; i < (int)ChangeFileCurveList->count(); i++) {
if (ChangeFileCurveList->isSelected(i)) {
vector = rvl[i];
if (!file->isValidField(vector->getField())) {
KMessageBox::sorry(0L, i18n("%1: Field is not defined for the requested file.").arg(vector->getField()));
} else {
vector->changeFile(file);
}
}
}
/** purge unused files */
//KST::fileList.Purge();
emit docChanged();
}
示例6: edit_I
void KstVectorDialogI::edit_I() {
KstDataSourcePtr file;
KstRVectorPtr vector;
int index = Select->currentItem();
if (index < 0) {
KMessageBox::sorry(0L, i18n("You need to select an active vector to edit."));
return;
}
KstRVectorList vectorList = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
if (unsigned(index) >= vectorList.count()) {
new_I();
} else {
/* verify that the vector name is unique */
if (Select->currentText() != vectorList[index]->tagName()) {
if (KST::dataTagNameNotUnique(Select->currentText())) return;
}
/* if there is not an active KstFile, create one */
{
KST::dataSourceList.lock().writeLock();
KstDataSourceList::Iterator it = KST::dataSourceList.findFileName(FileName->url());
if (it == KST::dataSourceList.end()) {
file = KstDataSource::loadSource(FileName->url());
if (!file || !file->isValid()) {
KMessageBox::sorry(0L, i18n("The file could not be opened."));
return;
}
if (file->frameCount() < 1) {
KMessageBox::sorry(0L, i18n("The file does not contain data."));
return;
}
KST::dataSourceList.append(file);
} else {
file = *it;
}
KST::dataSourceList.lock().writeUnlock();
}
if (!file->isValidField(Field->currentText())) {
KMessageBox::sorry(0L, i18n("The requested field is not defined for the requested file\n"));
return;
}
vector = vectorList[index];
/* change the vector */
vector->change(file, Field->currentText(),
Select->currentText(),
(CountFromEnd->isChecked() ?
-1 : F0->value()),
(ReadToEnd->isChecked() ?
-1 : N->value()),
Skip->value(),
DoSkip->isChecked(),
DoFilter->isChecked());
/** purge unused files */
//doc->fileList.Purge();
vector = 0L;
vectorList.clear();
emit modified();
}
}
示例7: apply
void KstQuickPSDDialogI::apply(bool autolabel) {
KstDataSourcePtr file;
KstVectorPtr vx;
KstRVectorPtr trv;
KstPlot *plot;
int i_v;
QString v_name, c_name;
bool x_is_new;
KstPSDCurvePtr curve;
double new_freq;
int new_len;
if (KST::plotList.count() < 1) {
addPlot();
return;
}
if (SourceVector->isChecked()) { // set vx from existing vectors
i_v = Vectors->currentItem();
KstReadLocker ml(&KST::vectorList.lock());
if (i_v >= (int)KST::vectorList.count()) {
return;
}
vx = KST::vectorList[i_v];
} else { // set vx from data file specification
KstReadLocker ml(&KST::dataSourceList.lock());
/* generate or find the kstfile */
KstDataSourceList::Iterator it = KST::dataSourceList.findFileName(FileName->url());
if (it == KST::dataSourceList.end()) {
file = KstDataSource::loadSource(FileName->url());
if (!file || !file->isValid()) {
KMessageBox::sorry(0L, i18n("The file could not be loaded."));
return;
}
if (file->frameCount() < 1) {
KMessageBox::sorry(0L, i18n("The file does not contain data."));
return;
}
KST::dataSourceList.append(file);
} else {
file = *it;
}
KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
x_is_new = true;
/**** Build the XVector ***/
/* make sure there are no vectors with the current vectors props */
for (i_v = 0; unsigned(i_v) < rvl.count(); i_v++) {
trv = rvl[i_v];
if ((trv->filename() == FileName->url()) &&
(trv->getField() == Field->text()) &&
(trv->reqStartFrame() == F0->value()) &&
(trv->reqNumFrames() == N->value()) &&
(trv->skip() == Skip->value()) &&
(trv->doSkip() == DoSkip->isChecked()) &&
(trv->doAve() == DoFilter->isChecked()) &&
(trv->readToEOF() == ReadToEnd->isChecked()) &&
(trv->countFromEOF() == CountFromEnd->isChecked())) {
x_is_new = false;
i_v = rvl.count();
vx = trv;
}
}
if (x_is_new) {
KST::vectorList.lock().readLock();
/* If not, Generate a unique vector name */
v_name = "V" + QString::number(KST::vectorList.count()+1)+"-"
+ Field->text();
while (KST::vectorList.findTag(v_name) != KST::vectorList.end()) {
v_name += "'";
}
KST::vectorList.lock().readUnlock();
KST::dataObjectList.lock().readLock();
while (KST::dataObjectList.findTag(v_name) != KST::dataObjectList.end()) {
v_name += "'";
}
KST::dataObjectList.lock().readUnlock();
if (!file->isValidField(Field->text())) {
KMessageBox::sorry(0L, i18n("The requested field is not defined for the requested file."));
return;
}
/* generate and append the vector */
trv = new KstRVector(file, Field->text(),
v_name,
(CountFromEnd->isChecked() ? -1 : F0->value()),
(ReadToEnd->isChecked() ? -1 : N->value()),
Skip->value(),
DoSkip->isChecked(),
DoFilter->isChecked());
KST::addVectorToList(KstVectorPtr(trv));
vx = trv;
}
}
/**** Build the PSD ***/
/* find new_freq */
//.........这里部分代码省略.........
示例8: editSingleObjectRV
bool KstVectorDialogI::editSingleObjectRV(KstVectorPtr vcPtr) {
KstRVectorPtr rvp = kst_cast<KstRVector>(vcPtr);
KstDataSourcePtr file;
if (_fileNameDirty) {
// if there is not an active KstFile, create one
KST::dataSourceList.lock().writeLock();
KstDataSourceList::Iterator it = KST::dataSourceList.findReusableFileName(_w->FileName->url());
if (it == KST::dataSourceList.end()) {
file = KstDataSource::loadSource(_w->FileName->url());
if (!file || !file->isValid()) {
KST::dataSourceList.lock().unlock();
KMessageBox::sorry(this, i18n("The file could not be opened."));
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();
} else {
KstRVectorList vcList = kstObjectSubList<KstVector,KstRVector>(KST::vectorList);
for (uint i = 0; i < _editMultipleWidget->_objectList->count(); i++) {
if (_editMultipleWidget->_objectList->isSelected(i)) {
// get the pointer to the object
KstRVectorList::Iterator vcIter = vcList.findTag(_editMultipleWidget->_objectList->text(i));
if (vcIter == vcList.end()) {
return false;
}
KstRVectorPtr rvp = *vcIter;
rvp->readLock();
file = rvp->dataSource();
rvp->unlock();
}
}
}
file->writeLock();
if (rvp) {
QString pField;
if (_fileNameDirty) {
pField = _w->Field->currentText();
if (!file->isValidField(pField)) {
KMessageBox::sorry(this, i18n("The requested field is not defined for the requested file."));
file->unlock();
return false;
}
} else {
pField = rvp->field();
}
int f0 = 0, n = 0;
if (_f0Dirty) {
if (_w->_kstDataRange->isStartRelativeTime()) {
f0 = file->sampleForTime(_w->_kstDataRange->f0Value());
} else if (_w->_kstDataRange->isStartAbsoluteTime()) {
bool ok = false;
f0 = file->sampleForTime(_w->_kstDataRange->f0DateTimeValue(), &ok);
if (!ok) {
file->unlock();
KMessageBox::sorry(this, i18n("The requested field or file could not use the specified date."));
return false;
}
} else {
f0 = int(_w->_kstDataRange->f0Value());
}
}
if (_nDirty) {
if (_w->_kstDataRange->isRangeRelativeTime()) {
double nValStored = _w->_kstDataRange->nValue();
if (_w->_kstDataRange->CountFromEnd->isChecked()) {
int frameCount = file->frameCount(_w->Field->currentText());
double msCount = file->relativeTimeForSample(frameCount - 1);
n = frameCount - 1 - file->sampleForTime(msCount - nValStored);
} else {
double fTime = file->relativeTimeForSample(f0);
n = file->sampleForTime(fTime + nValStored) - file->sampleForTime(fTime);
}
} else {
n = int(_w->_kstDataRange->nValue());
}
}
// use existing requested start and number of frames if not dirty
rvp->readLock();
if (!_f0Dirty) {
f0 = rvp->reqStartFrame();
}
if (!_nDirty) {
n = rvp->reqNumFrames();
}
// other parameters for multiple edit
bool pCountFromEnd, pReadToEnd, pDoSkip, pDoFilter;
int pSkip;
//.........这里部分代码省略.........
示例9: newObject
bool KstVectorDialogI::newObject() {
KstDataSourcePtr file;
QString tag_name = _tagName->text();
if (_w->_readFromSource->isChecked()) {
tag_name.replace(defaultTag, _w->Field->currentText());
tag_name = KST::suggestVectorName(tag_name);
// if there is not an active DataSource, create one
{
KST::dataSourceList.lock().writeLock();
KstDataSourceList::Iterator it = KST::dataSourceList.findReusableFileName(_w->FileName->url());
if (it == KST::dataSourceList.end()) {
file = KstDataSource::loadSource(_w->FileName->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();
}
file->readLock();
if (!file->isValidField(_w->Field->currentText())) {
file->unlock();
KMessageBox::sorry(this, i18n("The requested field is not defined for the requested file."));
return false;
}
int f0, n;
if (_w->_kstDataRange->isStartRelativeTime()) {
f0 = file->sampleForTime(_w->_kstDataRange->f0Value());
} else if (_w->_kstDataRange->isStartAbsoluteTime()) {
bool ok = false;
f0 = file->sampleForTime(_w->_kstDataRange->f0DateTimeValue(), &ok);
if (!ok) {
file->unlock();
KMessageBox::sorry(this, i18n("The requested field or file could not use the specified date."));
return false;
}
} else {
f0 = int(_w->_kstDataRange->f0Value());
}
if (_w->_kstDataRange->isRangeRelativeTime()) {
double nValStored = _w->_kstDataRange->nValue();
if (_w->_kstDataRange->CountFromEnd->isChecked()) {
int frameCount = file->frameCount(_w->Field->currentText());
double msCount = file->relativeTimeForSample(frameCount - 1);
n = frameCount - 1 - file->sampleForTime(msCount - nValStored);
} else {
double fTime = file->relativeTimeForSample(f0);
n = file->sampleForTime(fTime + nValStored) - file->sampleForTime(fTime);
}
} else {
n = int(_w->_kstDataRange->nValue());
}
file->unlock();
// create the vector
KstRVectorPtr vector = new KstRVector(
file, _w->Field->currentText(),
KstObjectTag(tag_name, file->tag(), false),
_w->_kstDataRange->CountFromEnd->isChecked() ? -1 : f0,
_w->_kstDataRange->ReadToEnd->isChecked() ? -1 : n,
_w->_kstDataRange->Skip->value(),
_w->_kstDataRange->DoSkip->isChecked(),
_w->_kstDataRange->DoFilter->isChecked());
emit vectorCreated(KstVectorPtr(vector));
vector = 0L;
emit modified();
} else {
double x0 = _w->_xMin->text().toDouble();
double x1 = _w->_xMax->text().toDouble();
int n = _w->_N->value();
QString tagname = _tagName->text();
if (tagname == defaultTag) {
tagname = KST::suggestVectorName(QString("(%1..%2)").arg(x0).arg(x1));
}
KstSVectorPtr svector = new KstSVector(x0, x1, n, KstObjectTag(tagname, KstObjectTag::globalTagContext));
emit vectorCreated(KstVectorPtr(svector));
svector = 0L;
emit modified();
}
return true;
}
示例10: main
//.........这里部分代码省略.........
eqcurve =
new KstEquationCurve(QString("E")+QString::number(n_eq+1)+
"-" + eqS,
eqS,
min,max,n, KstColorSequence::next());
KST::dataObjectList.lock().writeLock();
KST::dataObjectList.append(eqcurve);
KST::dataObjectList.lock().writeUnlock();
plot->addCurve(eqcurve);
if (in.sep_plots) {
i_plot++;
if (i_plot <in.n_plots) plot = KST::plotList.at(i_plot);
}
}
}
}
}
}
/* Make the requested curves for each data file */
for (i_curve = i_v = 0, i_file = 0; i_file < args->count(); i_file++) {
/* Make the file */
file = KstDataSource::loadSource(args->arg(i_file));
if (!file) {
kdWarning() << I18N_NOOP("Error: No data in file: ")
<< args->arg(i_file) << endl;
delete kst;
exit(0);
}
if (!file->isValid() || file->frameCount() < 1) {
kdWarning() << I18N_NOOP("Error: No data in file: ")
<< args->arg(i_file) << endl;
// The file might get data later!
}
KST::dataObjectList.lock().writeLock();
KST::dataSourceList.append(file);
KST::dataObjectList.lock().writeUnlock();
if (!ycolList.isEmpty()) { // if there are some xy plots
/* make the x axis vector */
xvector = GetOrCreateVector(args->getOption("x"), file, in);
/* make the y axis vectors */
for (i_ycol = 0; i_ycol < ycolList.count(); ++i_ycol ) {
yvector = GetOrCreateVector(*(ycolList.at(i_ycol)), file, in);
/* make the curves */
color = KstColorSequence::next();
curve = new KstVCurve(QString("C") + QString::number(1+i_curve++)
+ "-" + yvector->getField(),
KstVectorPtr(xvector), KstVectorPtr(yvector),
0L, 0L, color);
if (in.has_points) {
curve->setHasPoints(true);
curve->setHasLines(false);
}
if (i_ycol<errorList.count()) {
evector = GetOrCreateVector(*(errorList.at(i_ycol)), file, in);
curve->setYError(KstVectorPtr(evector));
}