BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
UserDefinedDataLoader1D Class Reference

Description

A user defined data loader. This is a thin wrapper around the real loader implementation, storing the relevant settings to make it user definable (namely name and import settings).

Definition at line 23 of file UserDefinedDataLoader1D.h.

Inheritance diagram for UserDefinedDataLoader1D:
[legend]
Collaboration diagram for UserDefinedDataLoader1D:
[legend]

Signals

void contentsProcessed ()
 Emitted whenever contents have been processed. More...
 
void importSettingsChanged ()
 Emitted whenever an import setting changed. More...
 

Public Member Functions

 UserDefinedDataLoader1D (AbstractDataLoader1D *wrappedLoader, QString name, QByteArray defaultProperties)
 
virtual void applyImportSettings ()
 Read all values from the properties UI into the internal variables. More...
 
AbstractDataLoaderclone () const override
 Create a complete clone, including all internal states. More...
 
virtual AbstractDataLoaderResultModelcreateResultModel () const
 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...
 
virtual QByteArray fileContent () const
 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...
 
virtual QStringList lineUnrelatedErrors () const
 Errors not related to a particular line. More...
 
QString name () const override
 The name shown in the format selection combo. More...
 
virtual int numErrors () const
 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...
 
virtual int numLineRelatedErrors () const
 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...
 
RealDataItemrealDataItem ()
 The real data item on which the import shall work. More...
 
const RealDataItemrealDataItem () 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

RealDataItemm_item
 The real-data-item which owns this loader. Never delete this! More...
 

Private Attributes

QByteArray m_defaultProperties
 
QString m_name
 
AbstractDataLoader1Dm_wrappedLoader
 

Constructor & Destructor Documentation

◆ UserDefinedDataLoader1D()

UserDefinedDataLoader1D::UserDefinedDataLoader1D ( AbstractDataLoader1D wrappedLoader,
QString  name,
QByteArray  defaultProperties 
)

Definition at line 19 of file UserDefinedDataLoader1D.cpp.

21  : m_name(std::move(name))
22  , m_wrappedLoader(wrappedLoader)
23  , m_defaultProperties(std::move(defaultProperties))
24 {
27 }
void importSettingsChanged()
Emitted whenever an import setting changed.
AbstractDataLoader1D * m_wrappedLoader
QString name() const override
The name shown in the format selection combo.

References AbstractDataLoader::importSettingsChanged(), and m_wrappedLoader.

Referenced by clone().

Member Function Documentation

◆ applyImportSettings()

void AbstractDataLoader::applyImportSettings ( )
virtualinherited

Read all values from the properties UI into the internal variables.

Reimplemented in QREDataLoader.

Definition at line 20 of file AbstractDataLoader.cpp.

20 {}

Referenced by cloneAsUserDefinedLoader(), and SpecularDataImportWidget::onPropertiesChanged().

◆ clone()

AbstractDataLoader * UserDefinedDataLoader1D::clone ( ) const
overridevirtual

Create a complete clone, including all internal states.

Implements AbstractDataLoader.

Definition at line 59 of file UserDefinedDataLoader1D.cpp.

60 {
61  auto* cloned = dynamic_cast<AbstractDataLoader1D*>(m_wrappedLoader->clone());
62  auto* loader = new UserDefinedDataLoader1D(cloned, m_name, m_defaultProperties);
63  return loader;
64 }
Abstract base class for reflectometry data loaders.
virtual AbstractDataLoader * clone() const =0
Create a complete clone, including all internal states.
UserDefinedDataLoader1D(AbstractDataLoader1D *wrappedLoader, QString name, QByteArray defaultProperties)

References UserDefinedDataLoader1D(), AbstractDataLoader::clone(), m_defaultProperties, m_name, and m_wrappedLoader.

Here is the call graph for this function:

◆ contentsProcessed

void AbstractDataLoader::contentsProcessed ( )
signalinherited

Emitted whenever contents have been processed.

Referenced by AutomaticDataLoader1D::processContents(), QREDataLoader::processContents(), and RealDataItem::setDataLoader().

◆ createResultModel()

AbstractDataLoaderResultModel * AbstractDataLoader::createResultModel ( ) const
virtualinherited

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 in QREDataLoader, and AutomaticDataLoader1D.

Definition at line 55 of file AbstractDataLoader.cpp.

56 {
57  return nullptr;
58 }

Referenced by SpecularDataImportWidget::updatePreview().

◆ defaultImportSettings()

QByteArray AbstractDataLoader::defaultImportSettings ( ) const
virtualinherited

Return the default import settings.

Definition at line 31 of file AbstractDataLoader.cpp.

32 {
33  std::unique_ptr<AbstractDataLoader> cloned(clone());
34  cloned->initWithDefaultImportSettings();
35  return cloned->serialize();
36 }

References AbstractDataLoader::clone().

Here is the call graph for this function:

◆ deserialize()

void UserDefinedDataLoader1D::deserialize ( const QByteArray &  data)
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 54 of file UserDefinedDataLoader1D.cpp.

55 {
57 }
virtual void deserialize(const QByteArray &data)
Initialize from serialization data. If any error occurred, then a DeserializationException has to be ...

References AbstractDataLoader::deserialize(), and m_wrappedLoader.

Referenced by initWithDefaultImportSettings().

Here is the call graph for this function:

◆ fileContent()

QByteArray AbstractDataLoader::fileContent ( ) const
virtualinherited

Returns the original file content. If not available any more (like for legacy project file import), then an empty array will be returned.

Reimplemented in QREDataLoader, and AutomaticDataLoader1D.

Definition at line 60 of file AbstractDataLoader.cpp.

61 {
62  return {};
63 }

Referenced by SpecularDataImportWidget::onFormatSelectionChanged(), and setFileContents().

◆ guessSettings()

void UserDefinedDataLoader1D::guessSettings ( )
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 71 of file UserDefinedDataLoader1D.cpp.

72 {
74 }
virtual void guessSettings()
Guess appropriate settings (for example the separator in a CSV file). Is called only once,...

References AbstractDataLoader::guessSettings(), and m_wrappedLoader.

Here is the call graph for this function:

◆ importSettingsChanged

void AbstractDataLoader::importSettingsChanged ( )
signalinherited

◆ initWithDefaultImportSettings()

void UserDefinedDataLoader1D::initWithDefaultImportSettings ( )
overridevirtual

Set import settings to defaults.

Reimplemented from AbstractDataLoader.

Definition at line 39 of file UserDefinedDataLoader1D.cpp.

40 {
42 }
void deserialize(const QByteArray &data) override
Initialize from serialization data. If any error occurred, then a DeserializationException has to be ...

References deserialize(), and m_defaultProperties.

Here is the call graph for this function:

◆ lineUnrelatedErrors()

QStringList AbstractDataLoader::lineUnrelatedErrors ( ) const
virtualinherited

Errors not related to a particular line.

Reimplemented in QREDataLoader, and AutomaticDataLoader1D.

Definition at line 50 of file AbstractDataLoader.cpp.

51 {
52  return {};
53 }

Referenced by SpecularDataImportWidget::updatePreview().

◆ name()

QString UserDefinedDataLoader1D::name ( ) const
overridevirtual

The name shown in the format selection combo.

Implements AbstractDataLoader.

Definition at line 29 of file UserDefinedDataLoader1D.cpp.

30 {
31  return m_name;
32 }

References m_name.

◆ numErrors()

int AbstractDataLoader::numErrors ( ) const
virtualinherited

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 in QREDataLoader, and AutomaticDataLoader1D.

Definition at line 40 of file AbstractDataLoader.cpp.

41 {
42  return 0;
43 }

Referenced by RealDataItem::hasImportErrors(), and SpecularDataImportWidget::updatePreview().

◆ numLineRelatedErrors()

int AbstractDataLoader::numLineRelatedErrors ( ) const
virtualinherited

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 in QREDataLoader.

Definition at line 45 of file AbstractDataLoader.cpp.

46 {
47  return 0;
48 }

◆ persistentClassName()

QString UserDefinedDataLoader1D::persistentClassName ( ) const
overridevirtual

A name which can be used for save/load purposes (which will not change ever more)

Implements AbstractDataLoader.

Definition at line 44 of file UserDefinedDataLoader1D.cpp.

45 {
47 }
virtual QString persistentClassName() const =0
A name which can be used for save/load purposes (which will not change ever more)

References m_wrappedLoader, and AbstractDataLoader::persistentClassName().

Here is the call graph for this function:

◆ populateImportSettingsWidget()

void UserDefinedDataLoader1D::populateImportSettingsWidget ( QWidget *  parent)
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 34 of file UserDefinedDataLoader1D.cpp.

35 {
37 }
virtual void populateImportSettingsWidget(QWidget *parent)
Fills the widget on the import dialog pane. The implementation here in the base class does nothing (m...

References m_wrappedLoader, and AbstractDataLoader::populateImportSettingsWidget().

Here is the call graph for this function:

◆ processContents()

void UserDefinedDataLoader1D::processContents ( )
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 76 of file UserDefinedDataLoader1D.cpp.

77 {
79 }
virtual void processContents()=0
Process the file contents. Can be called more than once, e.g. if the import settings have changed....

References m_wrappedLoader, and AbstractDataLoader::processContents().

Here is the call graph for this function:

◆ realDataItem() [1/2]

RealDataItem * AbstractDataLoader::realDataItem ( )
inherited

The real data item on which the import shall work.

Definition at line 70 of file AbstractDataLoader.cpp.

71 {
72  return m_item;
73 }
RealDataItem * m_item
The real-data-item which owns this loader. Never delete this!

References AbstractDataLoader::m_item.

◆ realDataItem() [2/2]

const RealDataItem * AbstractDataLoader::realDataItem ( ) const
inherited

The real data item on which the import shall work.

Definition at line 75 of file AbstractDataLoader.cpp.

76 {
77  return m_item;
78 }

References AbstractDataLoader::m_item.

◆ serialize()

QByteArray UserDefinedDataLoader1D::serialize ( ) const
overridevirtual

Returns every internal setting so it can be restored completely.

Reimplemented from AbstractDataLoader.

Definition at line 49 of file UserDefinedDataLoader1D.cpp.

50 {
51  return m_wrappedLoader->serialize();
52 }
virtual QByteArray serialize() const
Returns every internal setting so it can be restored completely.

References m_wrappedLoader, and AbstractDataLoader::serialize().

Here is the call graph for this function:

◆ setFileContents()

void UserDefinedDataLoader1D::setFileContents ( const QByteArray &  fileContent)
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 66 of file UserDefinedDataLoader1D.cpp.

67 {
69 }
virtual void setFileContents(const QByteArray &fileContent)=0
Sets the file contents to be imported. If the file was a compressed file, then the decompressed conte...
virtual QByteArray fileContent() const
Returns the original file content. If not available any more (like for legacy project file import),...

References AbstractDataLoader::fileContent(), m_wrappedLoader, and AbstractDataLoader::setFileContents().

Here is the call graph for this function:

◆ setRealDataItem()

void AbstractDataLoader::setRealDataItem ( RealDataItem item)
inherited

Define the real data item on which the import shall work.

Definition at line 65 of file AbstractDataLoader.cpp.

66 {
67  m_item = item;
68 }

References AbstractDataLoader::m_item.

Referenced by GUI::View::ImportDataUtils::Import1dData(), and SpecularDataImportWidget::onFormatSelectionChanged().

Member Data Documentation

◆ m_defaultProperties

QByteArray UserDefinedDataLoader1D::m_defaultProperties
private

Definition at line 43 of file UserDefinedDataLoader1D.h.

Referenced by clone(), and initWithDefaultImportSettings().

◆ m_item

RealDataItem* AbstractDataLoader::m_item
protectedinherited

◆ m_name

QString UserDefinedDataLoader1D::m_name
private

Definition at line 41 of file UserDefinedDataLoader1D.h.

Referenced by clone(), and name().

◆ m_wrappedLoader


The documentation for this class was generated from the following files: