// Called whenever the connection state of any PV changes: emits valuesChanged(), sizeChanged(), and stateChanged() as required. void REIXSXESMCPDataSourcePre2013::onConnectionStateChanged() { bool wasConnected = isConnected_; isConnected_ = imagePV_->isConnected() && resolutionXPV_->hasValues() && resolutionYPV_->hasValues(); // becoming disconnected... if(wasConnected && !isConnected_) { pixelsX_ = axes_[0].size = 0; pixelsY_ = axes_[1].size = 0; emitValuesChanged(); emitSizeChanged(); emitStateChanged(AMDataSource::InvalidFlag); AMErrorMon::report(AMErrorReport(this, AMErrorReport::Alert, -2, "Lost connection to MCP Detector " + imagePV_->pvName())); } // becoming connected... if(!wasConnected && isConnected_) { pixelsX_ = axes_[0].size = int(pow(2.0, double(resolutionXPV_->getInt()))); pixelsY_ = axes_[1].size = int(pow(2.0, double(resolutionYPV_->getInt()))); emitValuesChanged(); emitSizeChanged(); emitStateChanged(AMDataSource::ProcessingFlag); } }
// Connected to be called when the values of the input data source change void AM2DDeadTimeAB::onInputSourceValuesChanged(const AMnDIndex& start, const AMnDIndex& end) { if (start.rank() == axes_.size() && end.rank() == axes_.size()) emitValuesChanged(start, end); else emitValuesChanged(); }
// Connected to be called when the values of the input data source change void AMDeadTimeAB::onInputSourceValuesChanged(const AMnDIndex& start, const AMnDIndex& end) { if (start.isValid() && end.isValid()) emitValuesChanged(start, end); else emitValuesChanged(); }
// X-values (or axis values) /////////////////////////////// // Set the expression used for the independent variable (aka x-axis... the one returned by axisValue()). If \c xExpression is an empty string, the expression is set back to default, ie: the independent variable of the first input data source. bool AM1DExpressionAB::setXExpression(const QString& xExpressionIn) { QString xExpression = xExpressionIn; xExpressionValid_ = true; xUsedVariables_.clear(); xDirect_ = false; if(xExpression.isEmpty() && !sources_.isEmpty()) xExpression = sources_.at(0)->name() + ".x"; try { xParser_.SetExpr(xExpression.toStdString()); xParser_.Eval(); // determine usedVariables_: mu::varmap_type usedvar = xParser_.GetUsedVar(); mu::varmap_type::const_iterator item = usedvar.begin(); // Query the used variables. item->second is a pointer to the variable storage location. (With a better design, we might not need the inner loop.) for (; item!=usedvar.end(); ++item) { // search to find out if a variable is used. It is used if the pointer to the storage location matches item->second. for(int i=0; i<allVariables_.count(); i++) if( &(allVariables_.at(i).value) == item->second) xUsedVariables_ << &(allVariables_[i]); } // Optimization: is the whole expression merely a single input source name? Can we operate in direct mode? if(xExpressionValid_ && xUsedVariables_.count() == 1) { // precondition: only one input variable xDirectVar_ = *(xUsedVariables_.at(0)); // storing it here won't matter if xDirect_ is not set. if(xDirectVar_.useAxisValue) { // is this an axisValue name? if(xExpression.trimmed() == sources_.at(xDirectVar_.sourceIndex)->name() + ".x") // the whole expression matches just the name. We can go direct. xDirect_ = true; } else { if(xExpression.trimmed() == sources_.at(xDirectVar_.sourceIndex)->name()) // whole expression matches justthe name. Can go direct xDirect_ = true; } } } catch(mu::Parser::exception_type& e) { // QString explanation = QString("AM1DExpressionAB Analysis Block: error setting X expression: %1: '%2'. We found '%3' at position %4.").arg(QString::fromStdString(e.GetMsg())).arg(QString::fromStdString(e.GetExpr())).arg(QString::fromStdString(e.GetToken())).arg(e.GetPos()); // AMErrorMon::report(AMErrorReport(this, AMErrorReport::Debug, e.GetCode(), explanation)); xExpressionValid_ = false; } // anything that could trigger a change in the output validity must call this reviewState(); emitValuesChanged(); /// \todo: actually, we mean that the axis values changed. How to signal that? if(!currentlySettingInputSources_) setModified(true); return xExpressionValid_; }
void AMNormalizationAB::setInputDataSourcesImplementation(const QList<AMDataSource *> &dataSources) { // disconnect connections from old sources, if they exist. if(!sources_.isEmpty()) { for (int i = 0; i < sources_.size(); i++){ disconnect(sources_.at(i)->signalSource(), SIGNAL(valuesChanged(AMnDIndex,AMnDIndex)), this, SLOT(onInputSourceValuesChanged(AMnDIndex,AMnDIndex))); disconnect(sources_.at(i)->signalSource(), SIGNAL(sizeChanged(int)), this, SLOT(onInputSourceSizeChanged())); disconnect(sources_.at(i)->signalSource(), SIGNAL(stateChanged(int)), this, SLOT(onInputSourceStateChanged())); } } if(dataSources.isEmpty()) { sources_.clear(); axes_.clear(); setDescription("-- No input data --"); } // we know that this will only be called with valid input source /* else { sources_ = dataSources; axes_.clear(); for (int i = 0, size = sources_.at(0)->rank(); i < size; i++) axes_.append(sources_.at(0)->axisInfoAt(i)); cacheUpdateRequired_ = true; cachedData_ = QVector<double>(size().product()); setDescription(QString("Sum of spectra from %1 maps").arg(sources_.size())); for (int i = 0; i < sources_.size(); i++){ connect(sources_.at(i)->signalSource(), SIGNAL(valuesChanged(AMnDIndex,AMnDIndex)), this, SLOT(onInputSourceValuesChanged(AMnDIndex,AMnDIndex))); connect(sources_.at(i)->signalSource(), SIGNAL(sizeChanged(int)), this, SLOT(onInputSourceSizeChanged())); connect(sources_.at(i)->signalSource(), SIGNAL(stateChanged(int)), this, SLOT(onInputSourceStateChanged())); } } */ else { sources_ = dataSources; setInputSources(); } reviewState(); emitSizeChanged(); emitValuesChanged(AMnDIndex(0), size()-1); emitAxisInfoChanged(); emitInfoChanged(); }
bool AMExternalScanDataSourceAB::refreshData() { AMDbObject* dbObject = 0; AMnDIndex oldSize = size(); try { // We might have a scan_ loaded already from the constructor. If not, attempt to load ourselves. if(!scan_) { dbObject = AMDbObjectSupport::s()->createAndLoadObjectAt(sourceDb_, AMDbObjectSupport::s()->tableNameForClass<AMScan>(), sourceScanId_); scan_ = qobject_cast<AMScan*>(dbObject); if(!scan_) throw -1; } scan_->retain(this); int dataSourceIndex = scan_->indexOfDataSource(sourceDataSourceName_); if(dataSourceIndex < 0) throw -2; // get the axes from the source data. Since we're using AMStandardAnalysisBlock, this will automatically expose everything we need. axes_ = scan_->dataSourceAt(dataSourceIndex)->axes(); // grab the data copyValues(dataSourceIndex); copyAxisValues(dataSourceIndex); setState(scan_->dataSourceAt(dataSourceIndex)->state()); // delete the scan scan_->release(this); scan_ = 0; // signalling: emitAxisInfoChanged(); if(oldSize != size()) emitSizeChanged(); emitValuesChanged(); return true; } catch(int errCode) { if(dbObject) delete dbObject; if(scan_) { scan_->release(this); scan_ = 0; } setState(AMDataSource::InvalidFlag); AMErrorMon::report(AMErrorReport(this, AMErrorReport::Serious, errCode, "Could not load external scan data.")); return false; } }
void REIXSXESImageInterpolationAB::setInputDataSourcesImplementation(const QList<AMDataSource *> &dataSources) { // disconnect connections from old source, if it exists. if(inputSource_) { disconnect(inputSource_->signalSource(), SIGNAL(valuesChanged(AMnDIndex,AMnDIndex)), this, SLOT(onInputSourceValuesChanged(AMnDIndex,AMnDIndex))); disconnect(inputSource_->signalSource(), SIGNAL(sizeChanged(int)), this, SLOT(onInputSourceSizeChanged())); disconnect(inputSource_->signalSource(), SIGNAL(stateChanged(int)), this, SLOT(onInputSourceStateChanged())); inputSource_ = 0; } if(dataSources.isEmpty()) { inputSource_ = 0; sources_.clear(); axes_[0] = AMAxisInfo("invalid", 0, "No input data"); } // we know that this will only be called with one valid input source else { inputSource_ = dataSources.at(0); sources_ = dataSources; axes_[0] = inputSource_->axisInfoAt(0); // take the X axis info from the data source. axes_[0].description = "Emission Energy"; axes_[0].units = "eV"; axes_[0].size /= binningLevel_; cacheUpdateRequired_ = true; axisValueCacheInvalid_ = true; cachedData_ = QVector<double>(axes_.at(0).size); cachedAxisValues_ = QVector<double>(axes_.at(0).size); if(shiftValues1_.isEmpty()) { for(int i=0,cc=inputSource_->size(1); i<cc; i++) shiftValues1_ << 0; // make a null shift list, matching the size of the input data. Don't do this if we already have a shift list. } if(shiftValues2_.isEmpty()) { for(int i=0,cc=inputSource_->size(1); i<cc; i++) shiftValues2_ << 0; // make a null shift list, matching the size of the input data. Don't do this if we already have a shift list. } connect(inputSource_->signalSource(), SIGNAL(valuesChanged(AMnDIndex,AMnDIndex)), this, SLOT(onInputSourceValuesChanged(AMnDIndex,AMnDIndex))); connect(inputSource_->signalSource(), SIGNAL(sizeChanged(int)), this, SLOT(onInputSourceSizeChanged())); connect(inputSource_->signalSource(), SIGNAL(stateChanged(int)), this, SLOT(onInputSourceStateChanged())); } reviewState(); emitSizeChanged(); emitValuesChanged(); emitAxisInfoChanged(); emitInfoChanged(); }
void REIXSXESImageInterpolationAB::setShiftValues2(const AMIntList &shiftValues2) { if(shiftValues2 == shiftValues2_) return; shiftValues2_ = shiftValues2; cacheUpdateRequired_ = true; // could change all our cached values reviewState(); // might change the state to valid, if we didn't have proper number of shift values before. emitValuesChanged(); emit shiftValuesChanged(); setModified(true); }
// Connected to be called when the values of the input data source change void AM3DAdditionAB::onInputSourceValuesChanged(const AMnDIndex& start, const AMnDIndex& end) { cacheUpdateRequired_ = true; AMnDIndex scanStart = start; AMnDIndex scanEnd = end; scanStart.setRank(start.rank()-1); scanEnd.setRank(end.rank()-1); if (scanStart == scanEnd) dirtyIndices_ << start; emitValuesChanged(start, end); }
// Set the data source inputs. void AM2DAdditionAB::setInputDataSourcesImplementation(const QList<AMDataSource*>& dataSources) { // disconnect connections from old sources, if they exist. if(!sources_.isEmpty()) { for (int i = 0; i < sources_.size(); i++){ disconnect(sources_.at(i)->signalSource(), SIGNAL(valuesChanged(AMnDIndex,AMnDIndex)), this, SLOT(onInputSourceValuesChanged(AMnDIndex,AMnDIndex))); disconnect(sources_.at(i)->signalSource(), SIGNAL(sizeChanged(int)), this, SLOT(onInputSourceSizeChanged())); disconnect(sources_.at(i)->signalSource(), SIGNAL(stateChanged(int)), this, SLOT(onInputSourceStateChanged())); } } if(dataSources.isEmpty()) { sources_.clear(); axes_[0] = AMAxisInfo("invalid", 0, "No input data"); axes_[1] = AMAxisInfo("invalid", 0, "No input data"); setDescription("-- No input data --"); } // we know that this will only be called with valid input source else { sources_ = dataSources; axes_[0] = sources_.at(0)->axisInfoAt(0); axes_[1] = sources_.at(0)->axisInfoAt(1); setDescription(QString("Sum of %1").arg(sources_.at(0)->description())); for (int i = 0; i < sources_.size(); i++){ connect(sources_.at(i)->signalSource(), SIGNAL(valuesChanged(AMnDIndex,AMnDIndex)), this, SLOT(onInputSourceValuesChanged(AMnDIndex,AMnDIndex))); connect(sources_.at(i)->signalSource(), SIGNAL(sizeChanged(int)), this, SLOT(onInputSourceSizeChanged())); connect(sources_.at(i)->signalSource(), SIGNAL(stateChanged(int)), this, SLOT(onInputSourceStateChanged())); } } reviewState(); emitSizeChanged(0); emitSizeChanged(1); emitValuesChanged(); emitAxisInfoChanged(0); emitAxisInfoChanged(1); emitInfoChanged(); }
void REIXSXESImageInterpolationAB::setSumRangeMaxX(int sumRangeMaxX) { if(sumRangeMaxX == sumRangeMaxX_) return; sumRangeMaxX_ = sumRangeMaxX; if(liveCorrelation()) { callCorrelation_.schedule(); } cacheUpdateRequired_ = true; reviewState(); emitValuesChanged(); setModified(true); }
void REIXSXESImageInterpolationAB::setRangeRound(double rangeRound) { if(rangeRound == rangeRound_) return; rangeRound_ = rangeRound; if(liveCorrelation()) { callCorrelation_.schedule(); } cacheUpdateRequired_ = true; reviewState(); emitValuesChanged(); setModified(true); }
// Set the data source inputs. void AM1DRunningAverageFilterAB::setInputDataSourcesImplementation(const QList<AMDataSource*>& dataSources) { // disconnect connections from old source, if it exists. if(inputSource_) { disconnect(inputSource_->signalSource(), SIGNAL(valuesChanged(AMnDIndex,AMnDIndex)), this, SLOT(onInputSourceValuesChanged(AMnDIndex,AMnDIndex))); disconnect(inputSource_->signalSource(), SIGNAL(sizeChanged(int)), this, SLOT(onInputSourceSizeChanged())); disconnect(inputSource_->signalSource(), SIGNAL(stateChanged(int)), this, SLOT(onInputSourceStateChanged())); } if(dataSources.isEmpty()) { inputSource_ = 0; sources_.clear(); axes_[0] = AMAxisInfo("invalid", 0, "No input data"); setDescription("-- No input data --"); } // we know that this will only be called with valid input source else { inputSource_ = dataSources.at(0); sources_ = dataSources; axes_[0] = inputSource_->axisInfoAt(0); setDescription(QString("Running Average of %1") .arg(inputSource_->name())); connect(inputSource_->signalSource(), SIGNAL(valuesChanged(AMnDIndex,AMnDIndex)), this, SLOT(onInputSourceValuesChanged(AMnDIndex,AMnDIndex))); connect(inputSource_->signalSource(), SIGNAL(sizeChanged(int)), this, SLOT(onInputSourceSizeChanged())); connect(inputSource_->signalSource(), SIGNAL(stateChanged(int)), this, SLOT(onInputSourceStateChanged())); } reviewState(); emitSizeChanged(0); emitValuesChanged(); emitAxisInfoChanged(0); emitInfoChanged(); }
/// Connected to be called when the values of the input data source change void AM1DInterpolationAB::onInputSourceValuesChanged(const AMnDIndex& start, const AMnDIndex& end) { emitValuesChanged(start, end); }
void AMNormalizationAB::onInputSourceValuesChanged(const AMnDIndex &start, const AMnDIndex &end) { cacheUpdateRequired_ = true; emitValuesChanged(start, end); }
/// Connected to be called when the values of the input data source change void AM1DRunningAverageFilterAB::onInputSourceValuesChanged(const AMnDIndex& start, const AMnDIndex& end) { emitValuesChanged(start, end); }
// Connected to be called when the values of the input data source change void AM1DSummingAB::onInputSourceValuesChanged(const AMnDIndex& start, const AMnDIndex& end) { emitValuesChanged(start, end); }
void AM1DExpressionAB::onInputSourceValuesChanged(const AMnDIndex& start, const AMnDIndex& end) { emitValuesChanged(start, end); }
// Called when the image PV changes. emits valuesChanged(). void REIXSXESMCPDataSourcePre2013::onImageValuesChanged() { emitValuesChanged(); }
// Connected to be called when the values of the input data source change void AM2DAdditionAB::onInputSourceValuesChanged(const AMnDIndex& start, const AMnDIndex& end) { emitValuesChanged(start, end); }
void AM3DDeadTimeCorrectionAB::onInputSourceValuesChanged(const AMnDIndex& start, const AMnDIndex& end) { emitValuesChanged(start, end); }