本文整理汇总了C++中AMDataSource::rank方法的典型用法代码示例。如果您正苦于以下问题:C++ AMDataSource::rank方法的具体用法?C++ AMDataSource::rank怎么用?C++ AMDataSource::rank使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AMDataSource
的用法示例。
在下文中一共展示了AMDataSource::rank方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copyValues
void AMExternalScanDataSourceAB::copyValues(int dataSourceIndex)
{
AMDataSource* ds = scan_->dataSourceAt(dataSourceIndex);
const AMnDIndex size = ds->size();
switch(ds->rank()) {
case 0:
values_.clear();
values_ << ds->value(AMnDIndex());
break;
case 1: {
values_.resize(size.i());
for(int i=0; i<size.i(); i++)
values_[i] = ds->value(i);
break;
}
case 2: {
values_.resize(size.i()*size.j());
for(int i=0; i<size.i(); i++)
for(int j=0; j<size.j(); j++)
values_[i*size.j() + j] = ds->value(AMnDIndex(i,j));
break;
}
case 3: {
values_.resize(size.i()*size.j()*size.k());
for(int i=0; i<size.i(); i++)
for(int j=0; j<size.j(); j++)
for(int k=0; k<size.k(); k++)
values_[i*size.j()*size.k() + j*size.k() + k] = ds->value(AMnDIndex(i,j,k));
break;
}
case 4: {
values_.resize(size.i()*size.j()*size.k()*size.l());
for(int i=0; i<size.i(); i++)
for(int j=0; j<size.j(); j++)
for(int k=0; k<size.k(); k++)
for(int l=0; l<size.l(); l++)
values_[i*size.j()*size.k()*size.l() + j*size.k()*size.l() + k*size.l() + l] = ds->value(AMnDIndex(i,j,k,l));
break;
}
case 5: {
values_.resize(size.i()*size.j()*size.k()*size.l()*size.m());
for(int i=0; i<size.i(); i++)
for(int j=0; j<size.j(); j++)
for(int k=0; k<size.k(); k++)
for(int l=0; l<size.l(); l++)
for(int m=0; m<size.m(); m++)
values_[i*size.j()*size.k()*size.l()*size.m() + j*size.k()*size.l()*size.m() + k*size.l()*size.m() + l*size.m() + m] = ds->value(AMnDIndex(i,j,k,l,m));
/// \todo oh god, we really need a block copy or a multi-dimensional iterator for AMDataSource::value()...
break;
}
}
}
示例2: data
QVariant AMScanSetModel::data(const QModelIndex & index, int role) const {
if(!index.isValid())
return QVariant();
// scan-level index:
///////////////////////////
if(index.internalId() == -1 && index.row() < scans_.count() && index.column() == 0) {
AMScan* scan = scans_.at(index.row());
switch(role) {
case Qt::DisplayRole: {
QString rv = scan->fullName();
if(scan->modified())
rv.append( " (modified)");
return rv;
}
break;
case Qt::DecorationRole:
/// \bug this is temporary and meaningless. It's just the color of the first data source in the scan.
if(scan->dataSourceCount() > 0)
return sourcePlotSettings_.at(index.row()).at(0).linePen.color();
else
return QVariant();
break;
case Qt::ToolTipRole:
return QString("%1, #%2 (sample: %3): %4").arg(scan->name()).arg(scan->number()).arg(scan->sampleName()).arg(AMDateTimeUtils::prettyDateTime(scan->dateTime(), "h:mm:ssap"));
break;
case AM::DescriptionRole:
return QString("%1, on %2").arg(AMDateTimeUtils::prettyDateTime(scan->dateTime())).arg(scan->sampleName());
case AM::DateTimeRole:
return scan->dateTime();
case Qt::CheckStateRole:
return QVariant(); /// \todo For now... No checking/unchecking scans.
break;
case AM::PointerRole:
return qVariantFromValue(scan);
break;
case AM::ModifiedRole:
return scan->modified();
case AM::CanCloseRole: // allows views to show the 'close' button beside each scan, to delete it. Do we want this on?
return true;
case AM::NameRole: {
return scan->fullName();
}
break;
default:
return QVariant();
break;
}
}
// data source-level index:
////////////////////////////
if(index.internalId() >= 0 && index.internalId() < scans_.count() ) {
AMScan* scan = scans_.at(index.internalId());
if(index.row() < scan->dataSourceCount() && index.column() == 0) {
AMDataSource* dataSource = scan->dataSourceAt(index.row());
switch(role) {
case Qt::DisplayRole:
return QString("%1 (%2)").arg(dataSource->description(), dataSource->name());
break;
case Qt::DecorationRole:
return sourcePlotSettings_.at(index.internalId()).at(index.row()).linePen.color();
break;
case Qt::ToolTipRole:
case AM::NameRole:
return dataSource->name();
case AM::DescriptionRole:
return dataSource->description();
case AM::DetailedDescriptionRole:
return QString("%1 (%2) From scan: %3\n%4").arg(dataSource->description(),
dataSource->name(),
scan->name(),
//scan->evaluatedName(),
dataSource->typeDescription());
break;
case Qt::CheckStateRole: // this controls visibility on plots.
if(isVisible(index.internalId(), index.row()))
return Qt::Checked;
else
return Qt::Unchecked;
break;
case AM::PointerRole:
return qVariantFromValue(dataSource);
break;
case AM::PriorityRole:
return sourcePlotSettings_.at(index.internalId()).at(index.row()).priority;
break;
case AM::CanCloseRole: // allows views to show the 'close' button beside each scan, to delete it.
return true;
case AM::LinePenRole:
return sourcePlotSettings_.at(index.internalId()).at(index.row()).linePen;
case AM::RankRole:
return dataSource->rank();
case AMScanSetModel::ColorMapRole:
return qVariantFromValue(sourcePlotSettings_.at(index.internalId()).at(index.row()).colorMap);
case AMScanSetModel::MarkerColorRole:
//.........这里部分代码省略.........
示例3: writeSeparateSections
void AMExporterGeneralAscii::writeSeparateSections()
{
QTextStream ts(file_);
if (option_->higherDimensionsInRows()){
for(int s=0; s<separateSectionDataSources_.count(); s++) {
ts << option_->newlineDelimiter();
setCurrentDataSource(separateSectionDataSources_.at(s)); // sets currentDataSourceIndex_
AMDataSource* ds = currentScan_->dataSourceAt(currentDataSourceIndex_);
int precision = option_->exportPrecision(ds->name());
// section header?
if(option_->sectionHeaderIncluded()) {
ts << parseKeywordString(option_->sectionHeader());
ts << option_->newlineDelimiter();
}
// column header?
if(option_->columnHeaderIncluded()) {
// 1D data sources:
if(ds->rank() == 0) {
ts << parseKeywordString(option_->columnHeader()) << option_->columnDelimiter();
}
else if(ds->rank() == 1) {
if(separateSectionIncludeX_.at(s))
ts << parseKeywordString(option_->columnHeader()) << ".X" << option_->columnDelimiter();
ts << parseKeywordString(option_->columnHeader()) << option_->columnDelimiter();
}
else if(ds->rank() == 2) { // 2D
if(separateSectionIncludeX_.at(s))
ts << parseKeywordString(option_->columnHeader()) << ".X" << option_->columnDelimiter();
// need a loop over the second axis columns
for(int cc=0; cc<ds->size(1); cc++) {
setCurrentColumnIndex(cc);
ts << parseKeywordString(option_->columnHeader()) << "[" << ds->axisValue(1, cc).toString(precision) << ds->axisInfoAt(1).units << "]" << option_->columnDelimiter();
}
}
ts << option_->newlineDelimiter() << option_->columnHeaderDelimiter() << option_->newlineDelimiter();
}
// table
switch(ds->rank()) {
case 0:
ts << ds->value(AMnDIndex()).toString(precision) << option_->columnDelimiter() << option_->newlineDelimiter();
break;
case 1: {
int maxTableRows = ds->size(0);
for(int r=0; r<maxTableRows; r++) {
if(separateSectionIncludeX_.at(s)) {
ts << ds->axisValue(0,r).toString(precision) << option_->columnDelimiter();
}
ts << ds->value(r).toString(precision) << option_->columnDelimiter() << option_->newlineDelimiter();
}
}
break;
case 2: {
int maxTableRows = ds->size(0);
for(int r=0; r<maxTableRows; r++) {
if(separateSectionIncludeX_.at(s))
ts << ds->axisValue(0,r).toString(precision) << option_->columnDelimiter();
// need a loop over the second axis columns
for(int cc=0; cc<ds->size(1); cc++) {
ts << ds->value(AMnDIndex(r,cc)).toString(precision) << option_->columnDelimiter();
}
ts << option_->newlineDelimiter();
}
}
break;
default:
/// \todo Implement 3D
break;
}
}
}
// For writing out in columns. Essentially transposing the file.
else{
for(int s=0; s<separateSectionDataSources_.count(); s++) {
setCurrentDataSource(separateSectionDataSources_.at(s)); // sets currentDataSourceIndex_
AMDataSource* ds = currentScan_->dataSourceAt(currentDataSourceIndex_);
int precision = option_->exportPrecision(ds->name());
// section header?
if(option_->sectionHeaderIncluded()) {
ts << parseKeywordString(option_->sectionHeader());
ts << option_->newlineDelimiter();
}
// If including the X values.
if (separateSectionIncludeX_.at(s)){
switch(ds->rank()){
case 0:
break;
//.........这里部分代码省略.........
示例4: onNewDataSourceNamed
void AMDataSourcesEditor::onNewDataSourceNamed() {
if(!editingNewDataSourceName_)
return;
editingNewDataSourceName_ = false;
QString chName = nameEdit_->text();
disconnect(nameEdit_, SIGNAL(editingFinished()), this, SLOT(onNewDataSourceNamed()));
nameEdit_->clearFocus();
nameEdit_->setReadOnly(true);
int si = currentScanIndex();
if(si < 0 || si >= model_->scanCount()) {
// this should have never happened. How did we get here? You shouldn't have been able to press the addNewChannel button without a current scan.
return;
}
if(chName.isEmpty())
return;
if(model_->scanAt(si)->indexOfDataSource(chName) != -1) {
AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -1, QString("Couldn't create a new data source with the name \"%1\". Make sure to choose a name that doesn't exist already in this scan.").arg(chName)));
scanSetView_->setCurrentIndex(scanSetView_->currentIndex());
return;
}
AMScan* scan = model_->scanAt(si);
QList<AMDataSource*> singleDimDataSources;
QList<AMDataSource *> twoDimDataSources;
QList<AMDataSource *> threeDimDataSources;
AMAnalysisBlock *newAnalysisBlock = 0;
AMDataSource *tempSource = 0;
// find out all the available 1D and 2D data sources, to use for inputs on this new data source.
/// \todo Currently this only provides access to the raw data sources, until we can figure out a way to detect or work-around the circular reference problem if analyzed data sources could be used as input.
/// \note DH: I have changed this to use all of the data sources. There currently is still no work-around for the circular reference problem. We are just going to have to be careful about using this.
for(int i=0; i<scan->dataSourceCount(); i++){
tempSource = scan->dataSourceAt(i);
if(tempSource->rank() == 1)
singleDimDataSources << tempSource;
else if(tempSource->rank() == 2)
twoDimDataSources << tempSource;
else if (tempSource->rank() == 3)
threeDimDataSources << tempSource;
}
newAnalysisBlock = qobject_cast<AMAnalysisBlock *>(AMDbObjectSupport::s()->objectInfoForClass(nameOfAnalysisBlockToBeAdded_)->metaObject->newInstance(Q_ARG(QString, chName)));
// This should always happen. But just to be safe.
if (newAnalysisBlock){
if (newAnalysisBlock->desiredInputRank() == 1)
newAnalysisBlock->setInputDataSources(singleDimDataSources);
else if (newAnalysisBlock->desiredInputRank() == 2)
newAnalysisBlock->setInputDataSources(twoDimDataSources);
else if (newAnalysisBlock->desiredInputRank() == 3)
newAnalysisBlock->setInputDataSources(threeDimDataSources);
scan->addAnalyzedDataSource(newAnalysisBlock);
}
int di = scan->dataSourceCount()-1;
scanSetView_->setCurrentIndex(model_->indexForDataSource(si, di));
// this should automatically create a new detail editor for this new scan.
}