BornAgain
1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
|
Loader for experimental reflectometry CSV files that contain three columns with Q,R,E, namely Q = wavenumber, R = reflectivity, E = error of R.
Definition at line 29 of file QREDataLoader.h.
Classes | |
struct | ColumnDefinition |
struct | ErrorDefinition |
Contains a line related error (stored in the import result). Used for showing line related errors in the import data table. More... | |
struct | ImportResult |
Result of the file import. Some of the contained data is only relevant for showing the results in the result table. The usage of vectors which cover also invalid or skipped lines has its reason also in this result showing (to improve presentation performance). More... | |
struct | ImportSettings |
Settings for importing the file. More... | |
Signals | |
void | contentsProcessed () |
Emitted whenever contents have been processed. More... | |
void | importSettingsChanged () |
Emitted whenever an import setting changed. More... | |
Public Member Functions | |
QREDataLoader () | |
void | applyImportSettings () override |
Read all values from the properties UI into the internal variables. More... | |
AbstractDataLoader * | clone () const override |
Create a complete clone, including all internal states. More... | |
AbstractDataLoaderResultModel * | createResultModel () const override |
Create a table model which contains the import information like original file content, raw content, processed content. The returned pointer will be owned by the caller. This base class' implementation does nothing (return nullptr). More... | |
virtual QByteArray | defaultImportSettings () const |
Return the default import settings. More... | |
void | deserialize (const QByteArray &data) override |
Initialize from serialization data. If any error occurred, then a DeserializationException has to be thrown. The complete state has to be restored. Therefore if e.g. errors occurred in the former serialization, but errors are not serialized, then they have to be regenerated/ recalculated in here. More... | |
QByteArray | fileContent () const override |
Returns the original file content. If not available any more (like for legacy project file import), then an empty array will be returned. More... | |
void | guessSettings () override |
Guess appropriate settings (for example the separator in a CSV file). Is called only once, directly after setting the file content. More... | |
void | initWithDefaultImportSettings () override |
Set import settings to defaults. More... | |
QStringList | lineUnrelatedErrors () const override |
Errors not related to a particular line. More... | |
QString | name () const override |
The name shown in the format selection combo. More... | |
int | numErrors () const override |
Number of errors found while processing the content. An error means that either a particular content (line) can't be used or may be suspicious (line related error), or that the whole content can't be used (e.g. only 1 line present). More... | |
int | numLineRelatedErrors () const override |
Number of errors related to a specific line. Such an error means that a particular content (line) can't be used or may be suspicious. More... | |
QString | persistentClassName () const override |
A name which can be used for save/load purposes (which will not change ever more) More... | |
void | populateImportSettingsWidget (QWidget *parent) override |
Fills the widget on the import dialog pane. The implementation here in the base class does nothing (meaning "no editable properties"). More... | |
void | processContents () override |
Process the file contents. Can be called more than once, e.g. if the import settings have changed. Any error has to be stored in the loader (see numErrors()). More... | |
RealDataItem * | realDataItem () |
The real data item on which the import shall work. More... | |
const RealDataItem * | realDataItem () const |
The real data item on which the import shall work. More... | |
QByteArray | serialize () const override |
Returns every internal setting so it can be restored completely. More... | |
void | setFileContents (const QByteArray &fileContent) override |
Sets the file contents to be imported. If the file was a compressed file, then the decompressed content will be handed over already here. More... | |
void | setRealDataItem (RealDataItem *item) |
Define the real data item on which the import shall work. More... | |
Protected Attributes | |
RealDataItem * | m_item |
The real-data-item which owns this loader. Never delete this! More... | |
Private Types | |
enum class | DataType { Q , R , dR } |
enum class | UnitInFile { none , perNanoMeter , perAngstrom , other } |
Private Member Functions | |
void | calculateFromParseResult () const |
void | datafieldFromParsingResult (RealDataItem *item) const |
void | parseFileContent () const |
Private Attributes | |
QByteArray | m_fileContent |
ImportResult | m_importResult |
struct QREDataLoader::ImportSettings | m_importSettings |
QPointer< QREDataLoaderProperties > | m_propertiesWidget |
Friends | |
QDataStream & | operator<< (QDataStream &stream, const QREDataLoader::ErrorDefinition &s) |
QDataStream & | operator<< (QDataStream &stream, const QREDataLoader::ImportSettings &s) |
QDataStream & | operator>> (QDataStream &stream, QREDataLoader::ErrorDefinition &s) |
QDataStream & | operator>> (QDataStream &stream, QREDataLoader::ImportSettings &s) |
class | QREDataLoaderResultModel |
|
strongprivate |
|
strongprivate |
Enumerator | |
---|---|
none | |
perNanoMeter | |
perAngstrom | |
other |
Definition at line 55 of file QREDataLoader.h.
QREDataLoader::QREDataLoader | ( | ) |
Definition at line 76 of file QREDataLoader.cpp.
References initWithDefaultImportSettings().
Referenced by clone().
|
overridevirtual |
Read all values from the properties UI into the internal variables.
Reimplemented from AbstractDataLoader.
Definition at line 586 of file QREDataLoader.cpp.
References QREDataLoader::ImportSettings::columnDefinitions, dR, QREDataLoader::ImportSettings::headerPrefix, QREDataLoader::ImportSettings::linesToSkip, m_importSettings, m_propertiesWidget, perAngstrom, perNanoMeter, Q, and QREDataLoader::ImportSettings::separator.
Referenced by populateImportSettingsWidget().
|
private |
Definition at line 441 of file QREDataLoader.cpp.
References QREDataLoader::ImportResult::addError(), QREDataLoader::ImportSettings::allowValuesGreaterOne, QREDataLoader::ImportResult::clearCalculatedValues(), QREDataLoader::ImportSettings::columnDefinitions, QREDataLoader::ErrorDefinition::columnDoesNotContainValidNumber, dR, QREDataLoader::ErrorDefinition::duplicateQ, QREDataLoader::ImportResult::eValues, QREDataLoader::ImportResult::lines, m_importResult, m_importSettings, perAngstrom, Q, QREDataLoader::ImportResult::qValues, R, QREDataLoader::ImportResult::rawValues, QREDataLoader::ErrorDefinition::RGreaterOne, QREDataLoader::ErrorDefinition::RLessZero, QREDataLoader::ImportResult::rValues, and QREDataLoader::ImportResult::validCalculatedLines.
Referenced by processContents().
|
overridevirtual |
Create a complete clone, including all internal states.
Implements AbstractDataLoader.
Definition at line 212 of file QREDataLoader.cpp.
References QREDataLoader(), and serialize().
|
signalinherited |
Emitted whenever contents have been processed.
Referenced by AutomaticDataLoader1D::processContents(), processContents(), and RealDataItem::setDataLoader().
|
overridevirtual |
Create a table model which contains the import information like original file content, raw content, processed content. The returned pointer will be owned by the caller. This base class' implementation does nothing (return nullptr).
Reimplemented from AbstractDataLoader.
Definition at line 291 of file QREDataLoader.cpp.
References m_importResult, and QREDataLoaderResultModel.
|
private |
Definition at line 521 of file QREDataLoader.cpp.
References QREDataLoader::ImportResult::calculationErrors, RealDataItem::initNativeData(), QREDataLoader::ImportResult::lines, m_importResult, GUI::Util::CoordName::nameFromCoord(), QREDataLoader::ImportResult::qValues, QREDataLoader::ImportResult::rValues, SpecularDataItem::setAxesRangeToData(), DataItem::setAxesUnits(), SpecularDataItem::setDatafield(), RealDataItem::setNativeDatafield(), RealDataItem::setNativeDataUnits(), SpecularDataItem::setXaxisTitle(), SpecularDataItem::setYaxisTitle(), and RealDataItem::specularDataItem().
Referenced by processContents().
|
virtualinherited |
Return the default import settings.
Definition at line 31 of file AbstractDataLoader.cpp.
References AbstractDataLoader::clone().
|
overridevirtual |
Initialize from serialization data. If any error occurred, then a DeserializationException has to be thrown. The complete state has to be restored. Therefore if e.g. errors occurred in the former serialization, but errors are not serialized, then they have to be regenerated/ recalculated in here.
Reimplemented from AbstractDataLoader.
Definition at line 177 of file QREDataLoader.cpp.
References QREDataLoader::ImportResult::calculationErrors, QREDataLoader::ImportResult::clear(), QREDataLoader::ImportSettings::columnDefinitions, QREDataLoader::ImportResult::error, QREDataLoader::ImportResult::eValues, QREDataLoader::ImportResult::importSettings, QREDataLoader::ImportResult::lines, m_fileContent, m_importResult, m_importSettings, QREDataLoader::ImportResult::maxColumnCount, QREDataLoader::ImportResult::qValues, QREDataLoader::ImportResult::rawValues, QREDataLoader::ImportResult::rValues, DeserializationException::streamError(), DeserializationException::tooNew(), DeserializationException::tooOld(), and QREDataLoader::ImportResult::validCalculatedLines.
|
overridevirtual |
Returns the original file content. If not available any more (like for legacy project file import), then an empty array will be returned.
Reimplemented from AbstractDataLoader.
Definition at line 296 of file QREDataLoader.cpp.
References m_fileContent.
Referenced by setFileContents().
|
overridevirtual |
Guess appropriate settings (for example the separator in a CSV file). Is called only once, directly after setting the file content.
Reimplemented from AbstractDataLoader.
Definition at line 301 of file QREDataLoader.cpp.
References m_fileContent, m_importSettings, and QREDataLoader::ImportSettings::separator.
|
signalinherited |
Emitted whenever an import setting changed.
Referenced by UserDefinedDataLoader1D::UserDefinedDataLoader1D(), SpecularDataImportWidget::onFormatSelectionChanged(), populateImportSettingsWidget(), and SpecularDataImportWidget::setItem().
|
overridevirtual |
Set import settings to defaults.
Reimplemented from AbstractDataLoader.
Definition at line 134 of file QREDataLoader.cpp.
References QREDataLoader::ImportSettings::columnDefinitions, dR, QREDataLoader::ImportSettings::headerPrefix, QREDataLoader::ImportSettings::linesToSkip, m_importSettings, none, perNanoMeter, Q, R, and QREDataLoader::ImportSettings::separator.
Referenced by QREDataLoader().
|
overridevirtual |
Errors not related to a particular line.
Reimplemented from AbstractDataLoader.
Definition at line 283 of file QREDataLoader.cpp.
References QREDataLoader::ImportResult::error, and m_importResult.
|
overridevirtual |
The name shown in the format selection combo.
Implements AbstractDataLoader.
Definition at line 82 of file QREDataLoader.cpp.
|
overridevirtual |
Number of errors found while processing the content. An error means that either a particular content (line) can't be used or may be suspicious (line related error), or that the whole content can't be used (e.g. only 1 line present).
Reimplemented from AbstractDataLoader.
Definition at line 273 of file QREDataLoader.cpp.
References QREDataLoader::ImportResult::calculationErrors, QREDataLoader::ImportResult::error, and m_importResult.
|
overridevirtual |
Number of errors related to a specific line. Such an error means that a particular content (line) can't be used or may be suspicious.
Reimplemented from AbstractDataLoader.
Definition at line 278 of file QREDataLoader.cpp.
References QREDataLoader::ImportResult::calculationErrors, and m_importResult.
|
private |
Definition at line 369 of file QREDataLoader.cpp.
References QREDataLoader::ImportResult::clear(), QREDataLoader::ImportSettings::headerPrefix, QREDataLoader::ImportResult::lines, QREDataLoader::ImportSettings::linesToSkip, m_fileContent, m_importResult, m_importSettings, QREDataLoader::ImportResult::maxColumnCount, QREDataLoader::ImportResult::rawValues, and QREDataLoader::ImportSettings::separator.
Referenced by processContents().
|
overridevirtual |
A name which can be used for save/load purposes (which will not change ever more)
Implements AbstractDataLoader.
Definition at line 87 of file QREDataLoader.cpp.
|
overridevirtual |
Fills the widget on the import dialog pane. The implementation here in the base class does nothing (meaning "no editable properties").
Reimplemented from AbstractDataLoader.
Definition at line 92 of file QREDataLoader.cpp.
References applyImportSettings(), QREDataLoader::ImportSettings::columnDefinitions, dR, QREDataLoader::ImportSettings::headerPrefix, AbstractDataLoader::importSettingsChanged(), QREDataLoader::ImportSettings::linesToSkip, m_importSettings, m_propertiesWidget, perAngstrom, QREDataLoaderProperties::propertiesChanged(), Q, R, and QREDataLoader::ImportSettings::separator.
|
overridevirtual |
Process the file contents. Can be called more than once, e.g. if the import settings have changed. Any error has to be stored in the loader (see numErrors()).
Implements AbstractDataLoader.
Definition at line 219 of file QREDataLoader.cpp.
References calculateFromParseResult(), QREDataLoader::ImportSettings::columnDefinitions, AbstractDataLoader::contentsProcessed(), datafieldFromParsingResult(), QREDataLoader::ImportResult::error, QREDataLoader::ImportSettings::headerPrefix, QREDataLoader::ImportResult::importSettings, RealDataItem::isSpecularData(), QREDataLoader::ImportSettings::linesToSkip, m_importResult, m_importSettings, AbstractDataLoader::m_item, parseFileContent(), RealDataItem::removeNativeData(), QREDataLoader::ImportSettings::separator, SpecularDataItem::setDatafield(), RealDataItem::specularDataItem(), and QREDataLoader::ImportResult::validCalculatedLines.
|
inherited |
The real data item on which the import shall work.
Definition at line 70 of file AbstractDataLoader.cpp.
References AbstractDataLoader::m_item.
|
inherited |
The real data item on which the import shall work.
Definition at line 75 of file AbstractDataLoader.cpp.
References AbstractDataLoader::m_item.
|
overridevirtual |
Returns every internal setting so it can be restored completely.
Reimplemented from AbstractDataLoader.
Definition at line 150 of file QREDataLoader.cpp.
References QREDataLoader::ImportResult::calculationErrors, QREDataLoader::ImportResult::error, QREDataLoader::ImportResult::eValues, QREDataLoader::ImportResult::importSettings, QREDataLoader::ImportResult::lines, m_fileContent, m_importResult, m_importSettings, QREDataLoader::ImportResult::maxColumnCount, QREDataLoader::ImportResult::qValues, QREDataLoader::ImportResult::rawValues, QREDataLoader::ImportResult::rValues, and QREDataLoader::ImportResult::validCalculatedLines.
Referenced by clone(), and QREDataLoader::ImportSettings::operator!=().
|
overridevirtual |
Sets the file contents to be imported. If the file was a compressed file, then the decompressed content will be handed over already here.
Implements AbstractDataLoader.
Definition at line 364 of file QREDataLoader.cpp.
References fileContent(), and m_fileContent.
|
inherited |
Define the real data item on which the import shall work.
Definition at line 65 of file AbstractDataLoader.cpp.
References AbstractDataLoader::m_item.
Referenced by GUI::View::ImportDataUtils::Import1dData(), and SpecularDataImportWidget::onFormatSelectionChanged().
|
friend |
Definition at line 760 of file QREDataLoader.cpp.
|
friend |
Definition at line 572 of file QREDataLoader.cpp.
|
friend |
Definition at line 774 of file QREDataLoader.cpp.
|
friend |
Definition at line 578 of file QREDataLoader.cpp.
|
friend |
Definition at line 137 of file QREDataLoader.h.
Referenced by createResultModel().
|
private |
Definition at line 129 of file QREDataLoader.h.
Referenced by deserialize(), fileContent(), guessSettings(), parseFileContent(), serialize(), and setFileContents().
|
mutableprivate |
Definition at line 128 of file QREDataLoader.h.
Referenced by calculateFromParseResult(), createResultModel(), datafieldFromParsingResult(), deserialize(), lineUnrelatedErrors(), numErrors(), numLineRelatedErrors(), parseFileContent(), processContents(), and serialize().
|
private |
|
protectedinherited |
The real-data-item which owns this loader. Never delete this!
Definition at line 124 of file AbstractDataLoader.h.
Referenced by AutomaticDataLoader1D::createResultModel(), AutomaticDataLoader1D::processContents(), processContents(), AbstractDataLoader::realDataItem(), and AbstractDataLoader::setRealDataItem().
|
private |
Definition at line 131 of file QREDataLoader.h.
Referenced by applyImportSettings(), and populateImportSettingsWidget().