16 #include "Device/Data/DataUtils.h"
144 ASSERT(rank == 1 || rank == 2);
150 throw Error(
"Error in RealDataItem::initDataItem: trying to set data "
151 "incompatible with underlying data item");
159 &&
"Assertion failed in RealDataItem::initDataItem: inserting data item failed.");
167 ASSERT(data &&
"Assertion failed in RealDataItem::setDatafield: passed data is nullptr");
182 const size_t data_rank = info.
dataRank();
191 item<DataItem>(
T_NATIVE_DATA)->setDatafield(output_data.release());
196 const size_t rank = 1;
202 const size_t rank = 2;
238 return data_item->shape();
259 return intensity_data->maskContainerItem();
276 QDataStream s(&a, QIODevice::WriteOnly);
277 s.setVersion(QDataStream::Qt_5_12);
298 s.setVersion(QDataStream::Qt_5_12);
305 QString persistentLoaderClassName;
306 s >> persistentLoaderClassName;
307 if (!persistentLoaderClassName.isEmpty()) {
319 if (s.status() != QDataStream::Ok)
341 const bool hasLinkToInstrument = !
instrumentId().isEmpty();
342 if (hasLinkToInstrument)
363 maskContainer->clear();
367 projectionsContainer->model()->removeRows(0, projectionsContainer->numberOfChildren(),
368 projectionsContainer->index());
373 DataUtils::Data::createRearrangedDataSet(*input, 1).release());
403 std::unique_ptr<Datafield> native_data(
nativeData()->getDatafield()->clone());
411 auto* data_source = native_data_item ? native_data_item : data_item;
413 std::unique_ptr<Datafield> native_data(data_source->getDatafield()->clone());
Defines class AbstractDataLoader1D.
Defines class DataLoaders1D.
Defines class DeserializationException.
Defines ImportDataInfo helper struct.
Defines class InstrumentItem and all its children.
Defines class IntensityDataItem.
Defines namespace GUI::Model::FilenameUtils.
Defines namespace GUI::Model::JobItemUtils.
Defines MaskItems classes.
Defines items related to projections over color map.
Defines class RealDataItem.
Defines class SpecularDataItem.
Abstract base class for all data loaders (classes to import real data).
void contentsProcessed()
Emitted whenever contents have been processed.
virtual int numErrors() const
Number of errors found while processing the content. An error means that either a particular content ...
Abstract base class for IntensityDataItem and SpecularDataItem. Owns one simulated data set of type D...
virtual void setDatafield(Datafield *data)=0
The given pointer becomes owned by this class!!
Datafield * getDatafield()
virtual void updateCoords(const InstrumentItem *instrument)=0
virtual void reset(ImportDataInfo data)=0
Resets data to the state defined by user (imported) data.
static DataLoaders1D & instance()
The one and only instance.
static DeserializationException streamError()
static DeserializationException tooNew()
Carries information about loaded data.
size_t dataRank() const
Returns number of dimensions.
QString unitsLabel() const
std::unique_ptr< Datafield > clonedData() const &
Abstract base class for instrument-specific item classes.
void setAxesRangeToData() override
set zoom range of x,y axes to axes of input data
static constexpr auto M_TYPE
void setDatafield(Datafield *data) override
The given pointer becomes owned by this class!!
Container holding various masks as children.
A container to hold ProjectionItems, intended to store projections of color map on X,...
Provides access to experimental data, for display and fitting. Owns an AbstractDataLoader.
void initDataItem(size_t data_rank, const QString &tag)
Creates and inserts a data item except if such item with same tag already exists. Checks for rank com...
void initAsSpecularItem()
MaskContainerItem * maskContainerItem()
Returns mask container item.
bool hasImportErrors() const
bool holdsDimensionalData() const
QByteArray serializeBinaryData() const override
QString nativeDataUnits() const
void linkToInstrument(const InstrumentItem *instrument)
void unlinkFromInstrument()
static constexpr auto P_INSTRUMENT_ID
void setNativeDatafield(Datafield *data)
takes ownership of data
static constexpr auto T_INTENSITY_DATA
void deserializeBinaryData(const QByteArray &data) override
QByteArray m_importSettings
QString dataName() const
The name which is presented to the user.
bool isIntensityData() const
std::vector< int > shape() const
Returns the shape of underlying data item.
std::unique_ptr< AbstractDataLoader > m_dataLoader
bool isSpecularData() const
AbstractDataLoader * dataLoader() const
void setDataName(const QString &name)
void updateToInstrument(const InstrumentItem *instrument)
This does not set the link to the instrument! Use linkToInstrument() if you want to link to this inst...
QString instrumentId() const
void setImportData(ImportDataInfo info)
Sets imported data to underlying item. Creates it if not existing. This is used for 1D import....
QString nativeFileName() const
void setDataLoader(AbstractDataLoader *loader)
Takes ownership of loader.
bool hasNativeData() const
void setNativeFileName(const QString &filename)
The name from where the native data was originally imported.
IntensityDataItem * intensityDataItem()
void setNativeDataUnits(const QString &units)
static constexpr auto P_NATIVE_DATA_UNITS
SpecularDataItem * specularDataItem()
void initAsIntensityItem()
static constexpr auto T_NATIVE_DATA
const Datafield * nativeDatafield() const
bool rotationAffectsSetup() const
Returns true, if rotation will affect linked instrument or mask presence.
void importContentsProcessed()
void updateNonXMLDataFileNames()
Updates the name of file to store intensity data.
void setDatafield(Datafield *data)
Sets Datafield to underlying item. Creates it if not existing.
Base class for a GUI data item.
QString itemName() const
Get item name, return display name if no name is set.
void setItemName(const QString &name)
Set item name, add property if necessary.
SessionItem * addProperty(const QString &name, const QVariant &variant)
Add new property item and register new tag. name is the tag name and the display name....
bool registerTag(const QString &name, int min=0, int max=-1, QStringList modelTypes={})
Add new tag to this item with given name, min, max and types. max = -1 -> unlimited,...
bool setValue(QVariant value)
Set value, ensure that variant types match.
QVariant getItemValue(const QString &tag) const
Directly access value of item under given tag.
void setItemValue(const QString &tag, const QVariant &variant) const
Directly set value of item under given tag.
void setDefaultTag(const QString &tag)
Set default tag.
SessionModel * model() const
Returns model of this item.
T * item(const QString &tag) const
SessionItem * getItem(const QString &tag="", int row=0) const
Returns item in given row of given tag.
T * insertItem(SessionItem *parent=nullptr, int row=-1, QString tag="")
void setDatafield(Datafield *data) override
The given pointer becomes owned by this class!!
static constexpr auto M_TYPE
QString nativeDataFileName(const QString &dataName)
QString realDataFileName(const QString &dataName)
Constructs the name of the intensity file belonging to real data item.
void setIntensityItemCoords(DataItem *intensityItem, const InstrumentItem *instrumentItem)
Sets axes units suitable for given instrument.
QString const & name(EShape k)