diff --git a/GUI/Model/Device/DatafileItem.cpp b/GUI/Model/Device/DatafileItem.cpp index 982b43807bfb48e3399e44ff8d55d30b8e21db4a..36fa1f2f77e265158c7660a5c36276c075186b01 100644 --- a/GUI/Model/Device/DatafileItem.cpp +++ b/GUI/Model/Device/DatafileItem.cpp @@ -20,17 +20,16 @@ #include "GUI/Model/Axis/AmplitudeAxisItem.h" #include "GUI/Model/Data/Data1DItem.h" #include "GUI/Model/Data/Data2DItem.h" -#include "GUI/Model/Device/InstrumentItems.h" #include "GUI/Support/Util/Path.h" #include "GUI/Support/XML/Backup.h" #include "GUI/Support/XML/DeserializationException.h" +#include "GUI/Support/XML/UtilXML.h" namespace { namespace Tag { const QString BinaryData("BinaryData"); const QString Data("Data"); -const QString InstrumentId("InstrumentId"); const QString Name("Name"); const QString NativeData("NativeData"); // obsolete since v22.0 const QString NativeDataUnits("NativeDataUnits"); // obsolete since v22.0 @@ -104,35 +103,11 @@ bool DatafileItem::holdsDimensionalData() const return false; } -void DatafileItem::setInstrumentId(const QString& id) -{ - m_instrument_id = id; -} - -void DatafileItem::linkToInstrument(const InstrumentItem* instrument) -{ - if (instrument) { - m_instrument_id = instrument->id(); - updateToInstrument(instrument); - } else - unlinkFromInstrument(); -} - -void DatafileItem::unlinkFromInstrument() -{ - m_instrument_id = {}; - updateToInstrument(nullptr); -} - bool DatafileItem::rotationAffectsSetup() const { if (rank() == 1) // rotation only for 2D items possible return false; - const bool hasLinkToInstrument = !instrumentId().isEmpty(); - if (hasLinkToInstrument) - return true; - if (data2DItem()->hasMasks()) return true; @@ -147,9 +122,6 @@ void DatafileItem::rotateData() if (rank() == 1) // rotation only for 2D items possible return; - // -- first break instrument link, clear masks and projections - unlinkFromInstrument(); - data2DItem()->clearMasks(); // -- now rotate data @@ -177,11 +149,6 @@ void DatafileItem::writeTo(QXmlStreamWriter* w) const { XML::writeAttribute(w, XML::Attrib::version, uint(2)); - // instrument id - w->writeStartElement(Tag::InstrumentId); - XML::writeAttribute(w, XML::Attrib::value, m_instrument_id); - w->writeEndElement(); - // name w->writeStartElement(Tag::Name); XML::writeAttribute(w, XML::Attrib::value, name()); @@ -204,13 +171,8 @@ void DatafileItem::readFrom(QXmlStreamReader* r) while (r->readNextStartElement()) { QString tag = r->name().toString(); - // instrument id - if (tag == Tag::InstrumentId) { - XML::readAttribute(r, XML::Attrib::value, &m_instrument_id); - XML::gotoEndElementOfTag(r, Tag::InstrumentId); - - // name - } else if (tag == Tag::Name) { + // name + if (tag == Tag::Name) { setName(XML::readAttributeString(r, XML::Attrib::value)); XML::gotoEndElementOfTag(r, tag); @@ -254,15 +216,3 @@ std::vector<int> DatafileItem::axdims() const ASSERT(dataItem()); return m_data_item->axdims(); } - -void DatafileItem::updateToInstrument(const InstrumentItem* instrument) -{ - if (m_data_item) - return; - - if (instrument) - return; - - // instrument == nullptr => unlinking => going back to native data - // TODO now the function does nothing. do not remove this function, but give it meaning again -} diff --git a/GUI/Model/Device/DatafileItem.h b/GUI/Model/Device/DatafileItem.h index 9c34439429117862f98d5d990a48f1512fd10ffa..e2c4e8fed35d6d81ae7a50c9e0d9b4889c64d26f 100644 --- a/GUI/Model/Device/DatafileItem.h +++ b/GUI/Model/Device/DatafileItem.h @@ -24,7 +24,6 @@ class Data1DItem; class Data2DItem; class DataItem; class Datafield; -class InstrumentItem; class MessageService; //! Provides access to experimental data, for display and fitting. @@ -50,13 +49,6 @@ public: bool holdsDimensionalData() const; - //... Instrument - - QString instrumentId() const { return m_instrument_id; } - void setInstrumentId(const QString& id); - void linkToInstrument(const InstrumentItem* instrument); - void unlinkFromInstrument(); - //! Returns true, if rotation will affect linked instrument or mask presence. bool rotationAffectsSetup() const; void rotateData(); @@ -75,13 +67,8 @@ public: std::vector<int> axdims() const; private: - //! This does not set the link to the instrument! Use linkToInstrument() if you want - //! to link to this instrument. - void updateToInstrument(const InstrumentItem* instrument); void updateFileName(); - QString m_instrument_id; - std::unique_ptr<DataItem> m_data_item; //!< Can be 1D or 2D item. }; diff --git a/GUI/Model/Job/JobItem.cpp b/GUI/Model/Job/JobItem.cpp index 10b5f34ca9b1ddeb153b07af475cc30a26262fa4..61ace64b95fd5e75507e1e5ddaabac05c72f563b 100644 --- a/GUI/Model/Job/JobItem.cpp +++ b/GUI/Model/Job/JobItem.cpp @@ -187,9 +187,6 @@ void JobItem::copyDatafileItemIntoJob(const DatafileItem* source) void JobItem::adjustReaDataToJobInstrument() { - // update stored instrument id without updating rest of real data - m_dfile_item->setInstrumentId(instrumentItem()->id()); - if (instrumentItem()->is<SpecularInstrumentItem>()) { // coords of loaded data --> instrumental --> representation coords diff --git a/Tests/Unit/GUI/TestDatafilesModel.cpp b/Tests/Unit/GUI/TestDatafilesModel.cpp index d744c5e52517b5d1af982bc0452e5b9c7db91840..255a00cb36e7369db446c9d7fd203608d5d4eaec 100644 --- a/Tests/Unit/GUI/TestDatafilesModel.cpp +++ b/Tests/Unit/GUI/TestDatafilesModel.cpp @@ -86,7 +86,6 @@ TEST(TestDatafilesSet, saveXMLData) model1.add_item(spec1); auto* t1 = new SpecularInstrumentItem; instrument_model.add_item(t1); - spec1->linkToInstrument(t1); // add second specular DatafileItem auto* spec2 = new DatafileItem("spec2", df2); @@ -101,8 +100,6 @@ TEST(TestDatafilesSet, saveXMLData) auto* t3 = new OffspecInstrumentItem; instrument_model.add_item(t2); instrument_model.add_item(t3); - intensity1->linkToInstrument(t2); - intensity2->linkToInstrument(t3); // set non-default top-level model parameters model1.setCurrentIndex(1);