diff --git a/GUI/coregui/Models/BeamItem.cpp b/GUI/coregui/Models/BeamItem.cpp index e45d666978e0d5c9bd55d31bd4692fdadfdef4f2..f36b70b5458ba4cb56daa12a9e29c72184531d50 100644 --- a/GUI/coregui/Models/BeamItem.cpp +++ b/GUI/coregui/Models/BeamItem.cpp @@ -25,6 +25,8 @@ #include "SessionItemUtils.h" #include "Units.h" +using SessionItemUtils::GetVectorItem; + namespace { const QString polarization_tooltip = "Polarization of the beam, given as the Bloch vector"; @@ -129,7 +131,7 @@ std::unique_ptr<Beam> BeamItem::createBeam() const double azimuthal_angle = Units::deg2rad(getAzimuthalAngle()); result->setCentralK(lambda, inclination_angle, azimuthal_angle); - result->setPolarization(SessionItemUtils::GetVectorItem(*this, P_POLARIZATION)); + result->setPolarization(GetVectorItem(*this, P_POLARIZATION)); return result; } diff --git a/GUI/coregui/Models/DetectorItems.cpp b/GUI/coregui/Models/DetectorItems.cpp index 60b8e89e4ebebcf9a240bd7f978a6b434f26f6ea..44c1dad689748c5c9bfc322868fcf189d8ab0c6c 100644 --- a/GUI/coregui/Models/DetectorItems.cpp +++ b/GUI/coregui/Models/DetectorItems.cpp @@ -23,6 +23,8 @@ #include "SessionItemUtils.h" #include "SessionModel.h" +using SessionItemUtils::GetVectorItem; + namespace { const QString res_func_group_label = "Type"; const QString analyzer_direction_tooltip = "Direction of the polarization analysis"; @@ -67,7 +69,7 @@ std::unique_ptr<IDetector2D> DetectorItem::createDetector() const if (auto resFunc = createResolutionFunction()) result->setResolutionFunction(*resFunc); - kvector_t analyzer_dir = SessionItemUtils::GetVectorItem(*this, P_ANALYZER_DIRECTION); + kvector_t analyzer_dir = GetVectorItem(*this, P_ANALYZER_DIRECTION); double analyzer_eff = getItemValue(P_ANALYZER_EFFICIENCY).toDouble(); double analyzer_total_trans = getItemValue(P_ANALYZER_TOTAL_TRANSMISSION).toDouble(); if (analyzer_dir.mag() > 0.0) diff --git a/GUI/coregui/Models/FitParameterProxyModel.cpp b/GUI/coregui/Models/FitParameterProxyModel.cpp index fd2b1d4ef64f8d0e51dce3cfe2527607d18ab487..c0f84437513b5c8af171f1c38398d8cb66b0436d 100644 --- a/GUI/coregui/Models/FitParameterProxyModel.cpp +++ b/GUI/coregui/Models/FitParameterProxyModel.cpp @@ -23,6 +23,7 @@ #include "SessionItemUtils.h" #include <QMimeData> +using SessionItemUtils::ParentRow; FitParameterProxyModel::FitParameterProxyModel(FitParameterContainerItem* fitParContainer, QObject* parent) @@ -119,7 +120,7 @@ QModelIndex FitParameterProxyModel::parent(const QModelIndex& child) const if(parent_item->modelType()==Constants::FitParameterLinkType) { SessionItem* fitPar = parent_item->parent(); if(!isValidSourceItem(fitPar)) return QModelIndex(); - return createIndex(SessionItemUtils::ParentRow(*fitPar), 0, fitPar); + return createIndex(ParentRow(*fitPar), 0, fitPar); } } } @@ -340,7 +341,7 @@ QModelIndex FitParameterProxyModel::indexOfItem(SessionItem* item) const if(SessionItem* parent_item = item->parent()) { if(parent_item->modelType() == Constants::FitParameterContainerType) { if(item->modelType() == Constants::FitParameterType) { - return createIndex(SessionItemUtils::ParentRow(*item), 0, item); + return createIndex(ParentRow(*item), 0, item); } } else if(parent_item->modelType() == Constants::FitParameterType) { @@ -348,7 +349,7 @@ QModelIndex FitParameterProxyModel::indexOfItem(SessionItem* item) const QString tag = parent_item->tagFromItem(item); int col = m_columnNames.key(tag, -1); if(col > 0) { - return createIndex(SessionItemUtils::ParentRow(*parent_item), col, item); + return createIndex(ParentRow(*parent_item), col, item); } } else if(parent_item->modelType() == Constants::FitParameterLinkType) { diff --git a/GUI/coregui/Models/GUIObjectBuilder.cpp b/GUI/coregui/Models/GUIObjectBuilder.cpp index a6bf648d2150321a9abefa90e70e47817cff4b12..ee51647b7a95f3692428a4d27fc79f13d6bb6f29 100644 --- a/GUI/coregui/Models/GUIObjectBuilder.cpp +++ b/GUI/coregui/Models/GUIObjectBuilder.cpp @@ -59,6 +59,8 @@ #include "Particle.h" #include "ParticleCoreShell.h" +using SessionItemUtils::SetVectorItem; + namespace { SessionItem* AddFormFactorItem(SessionItem* p_parent, Constants::ModelType model_type); } @@ -200,8 +202,7 @@ void GUIObjectBuilder::visit(const MultiLayer* p_sample) p_multilayer_item->setItemName(p_sample->getName().c_str()); p_multilayer_item->setItemValue(MultiLayerItem::P_CROSS_CORR_LENGTH, p_sample->crossCorrLength()); - SessionItemUtils::SetVectorItem(*p_multilayer_item, MultiLayerItem::P_EXTERNAL_FIELD, - p_sample->externalField()); + SetVectorItem(*p_multilayer_item, MultiLayerItem::P_EXTERNAL_FIELD, p_sample->externalField()); m_levelToParentItem[depth()] = p_multilayer_item; m_itemToSample[p_multilayer_item] = p_sample; } @@ -256,9 +257,9 @@ void GUIObjectBuilder::visit(const Crystal* p_sample) auto vector_b = lattice.getBasisVectorB(); auto vector_c = lattice.getBasisVectorC(); - SessionItemUtils::SetVectorItem(*p_mesocrystal_item, MesoCrystalItem::P_VECTOR_A, vector_a); - SessionItemUtils::SetVectorItem(*p_mesocrystal_item, MesoCrystalItem::P_VECTOR_B, vector_b); - SessionItemUtils::SetVectorItem(*p_mesocrystal_item, MesoCrystalItem::P_VECTOR_C, vector_c); + SetVectorItem(*p_mesocrystal_item, MesoCrystalItem::P_VECTOR_A, vector_a); + SetVectorItem(*p_mesocrystal_item, MesoCrystalItem::P_VECTOR_B, vector_b); + SetVectorItem(*p_mesocrystal_item, MesoCrystalItem::P_VECTOR_C, vector_c); // Since there is no CrystalItem, set the parent map to the MesoCrystalItem m_levelToParentItem[depth()] = p_mesocrystal_item; @@ -585,7 +586,7 @@ void GUIObjectBuilder::visit(const RotationEuler* p_sample) void GUIObjectBuilder::buildPositionInfo(SessionItem* p_particle_item, const IParticle* p_sample) { kvector_t position = p_sample->position(); - SessionItemUtils::SetVectorItem(*p_particle_item, ParticleItem::P_POSITION, position); + SetVectorItem(*p_particle_item, ParticleItem::P_POSITION, position); } MaterialProperty GUIObjectBuilder::createMaterialFromDomain( @@ -601,8 +602,7 @@ MaterialProperty GUIObjectBuilder::createMaterialFromDomain( complex_t material_data = material->materialData(); MaterialItem* materialItem = model->addMaterial(materialName, material_data.real(),material_data.imag()); - SessionItemUtils::SetVectorItem(*materialItem, MaterialItem::P_MAGNETIZATION, - material->magnetization()); + SetVectorItem(*materialItem, MaterialItem::P_MAGNETIZATION, material->magnetization()); return MaterialProperty(materialItem->getIdentifier()); } diff --git a/GUI/coregui/Models/MaterialItem.cpp b/GUI/coregui/Models/MaterialItem.cpp index e03b35df40c6ef007c65a53129ad33b95a2f64e4..e325044c91f33f1061ada8b6e907bee75d9a1e54 100644 --- a/GUI/coregui/Models/MaterialItem.cpp +++ b/GUI/coregui/Models/MaterialItem.cpp @@ -21,6 +21,8 @@ #include "MaterialFactoryFuncs.h" #include "SessionItemUtils.h" +using SessionItemUtils::GetVectorItem; + namespace { const QString magnetization_tooltip = "Magnetization (A/m)"; @@ -66,7 +68,7 @@ std::unique_ptr<Material> MaterialItem::createMaterial() const double real = materialDataItem->getReal(); double imag = materialDataItem->getImag(); - auto magnetization = SessionItemUtils::GetVectorItem(*this, P_MAGNETIZATION); + auto magnetization = GetVectorItem(*this, P_MAGNETIZATION); return std::make_unique<Material>(HomogeneousMaterial(itemName().toStdString(), real, imag, magnetization)); diff --git a/GUI/coregui/Models/MesoCrystalItem.cpp b/GUI/coregui/Models/MesoCrystalItem.cpp index ab519c2ab34dbd7426f4066272f31247801f311a..6d2025cfb1a2ebf19fd07f06cb4627f9e20d64fe 100644 --- a/GUI/coregui/Models/MesoCrystalItem.cpp +++ b/GUI/coregui/Models/MesoCrystalItem.cpp @@ -31,6 +31,8 @@ #include "TransformToDomain.h" #include "VectorItem.h" +using SessionItemUtils::GetVectorItem; + namespace { const QString abundance_tooltip = "Proportion of this type of mesocrystal normalized to the \n" @@ -148,9 +150,9 @@ QStringList MesoCrystalItem::translateList(const QStringList& list) const Lattice MesoCrystalItem::getLattice() const { - kvector_t a1 = SessionItemUtils::GetVectorItem(*this, P_VECTOR_A); - kvector_t a2 = SessionItemUtils::GetVectorItem(*this, P_VECTOR_B); - kvector_t a3 = SessionItemUtils::GetVectorItem(*this, P_VECTOR_C); + kvector_t a1 = GetVectorItem(*this, P_VECTOR_A); + kvector_t a2 = GetVectorItem(*this, P_VECTOR_B); + kvector_t a3 = GetVectorItem(*this, P_VECTOR_C); return Lattice(a1, a2, a3); } diff --git a/GUI/coregui/Models/ParticleItem.cpp b/GUI/coregui/Models/ParticleItem.cpp index b23658520323e5af963d6554af99204211d2632f..79d903bf814b9a01998f779f86023024d19393db 100644 --- a/GUI/coregui/Models/ParticleItem.cpp +++ b/GUI/coregui/Models/ParticleItem.cpp @@ -25,6 +25,8 @@ #include "TransformToDomain.h" #include "VectorItem.h" +using SessionItemUtils::SetVectorItem; + namespace { const QString abundance_tooltip = "Proportion of this type of particles normalized to the \n" @@ -88,7 +90,7 @@ void ParticleItem::updatePropertiesAppearance(SessionItem* newParent) getItem(ParticleItem::P_ABUNDANCE)->setEnabled(false); if (isShellParticle()) { kvector_t zero_vector; - SessionItemUtils::SetVectorItem(*this, ParticleItem::P_POSITION, zero_vector); + SetVectorItem(*this, ParticleItem::P_POSITION, zero_vector); SessionItem *positionItem = getItem(ParticleItem::P_POSITION); positionItem->setEnabled(false); } diff --git a/GUI/coregui/Models/SessionModel.cpp b/GUI/coregui/Models/SessionModel.cpp index 29315f26be55b5ec7ecbe7c427a6409d1e60ed0c..3c137ce5578a0c6ab417decbb9193a34287b32c7 100644 --- a/GUI/coregui/Models/SessionModel.cpp +++ b/GUI/coregui/Models/SessionModel.cpp @@ -21,6 +21,8 @@ #include <QFile> #include <QMimeData> +using SessionItemUtils::ParentRow; + namespace { const int MaxCompression = 9; @@ -136,7 +138,7 @@ QModelIndex SessionModel::parent(const QModelIndex& child) const if (parent_item == m_root_item) return QModelIndex(); - return createIndex(SessionItemUtils::ParentRow(*parent_item), 0, parent_item); + return createIndex(ParentRow(*parent_item), 0, parent_item); } } return QModelIndex(); diff --git a/GUI/coregui/Models/TransformFromDomain.cpp b/GUI/coregui/Models/TransformFromDomain.cpp index 7d9b9c98e43d6c12e1b5ccec94e54eb1523dc37a..c3482d335c8b2a1cbf1f104ed42e66e34898c0f9 100644 --- a/GUI/coregui/Models/TransformFromDomain.cpp +++ b/GUI/coregui/Models/TransformFromDomain.cpp @@ -66,6 +66,7 @@ #include <limits> using namespace INodeUtils; +using SessionItemUtils::SetVectorItem; void SetPDF1D(SessionItem* item, const IFTDistribution1D* pdf, QString group_name); void setPDF2D(SessionItem* item, const IFTDistribution2D* pdf, QString group_name); @@ -238,7 +239,7 @@ void TransformFromDomain::setItemFromSample(BeamItem* beamItem, const GISASSimul } // polarization parameters - SessionItemUtils::SetVectorItem(*beamItem, BeamItem::P_POLARIZATION, beam.getBlochVector()); + SetVectorItem(*beamItem, BeamItem::P_POLARIZATION, beam.getBlochVector()); } void TransformFromDomain::setInstrumentDetectorFromSample(InstrumentItem* instrumentItem, @@ -298,7 +299,7 @@ void TransformFromDomain::setInstrumentDetectorFromSample(InstrumentItem* instru if (total_transmission>0.0) { kvector_t analyzer_dir = p_detector->analyzerDirection(); double efficiency = p_detector->analyzerEfficiency(); - SessionItemUtils::SetVectorItem(*detector_item, DetectorItem::P_ANALYZER_DIRECTION, + SetVectorItem(*detector_item, DetectorItem::P_ANALYZER_DIRECTION, analyzer_dir); detector_item->setItemValue(DetectorItem::P_ANALYZER_EFFICIENCY, efficiency); detector_item->setItemValue(DetectorItem::P_ANALYZER_TOTAL_TRANSMISSION, @@ -349,10 +350,10 @@ void TransformFromDomain::setItemFromSample(RectangularDetectorItem* detectorIte detectorItem->setDetectorAlignment(Constants::ALIGNMENT_GENERIC); kvector_t normal = detector.getNormalVector(); - SessionItemUtils::SetVectorItem(*detectorItem, RectangularDetectorItem::P_NORMAL, normal); + SetVectorItem(*detectorItem, RectangularDetectorItem::P_NORMAL, normal); kvector_t direction = detector.getDirectionVector(); - SessionItemUtils::SetVectorItem(*detectorItem, RectangularDetectorItem::P_DIRECTION, + SetVectorItem(*detectorItem, RectangularDetectorItem::P_DIRECTION, direction); detectorItem->setItemValue(RectangularDetectorItem::P_U0, detector.getU0()); diff --git a/GUI/coregui/Models/TransformToDomain.cpp b/GUI/coregui/Models/TransformToDomain.cpp index 87996ed027ca760cd417ed8608a00757cd91a710..fd7ff4aa7d5972cb3fa19516bc52ffe0b83f3a28 100644 --- a/GUI/coregui/Models/TransformToDomain.cpp +++ b/GUI/coregui/Models/TransformToDomain.cpp @@ -56,6 +56,8 @@ #include "Units.h" #include "VectorItem.h" +using SessionItemUtils::GetVectorItem; + std::unique_ptr<Material> TransformToDomain::createDomainMaterial(const SessionItem& item) { MaterialProperty material_property; @@ -81,7 +83,7 @@ std::unique_ptr<MultiLayer> TransformToDomain::createMultiLayer(const SessionIte = item.getItemValue(MultiLayerItem::P_CROSS_CORR_LENGTH).toDouble(); if (cross_corr_length > 0) P_multilayer->setCrossCorrLength(cross_corr_length); - auto external_field = SessionItemUtils::GetVectorItem(item, MultiLayerItem::P_EXTERNAL_FIELD); + auto external_field = GetVectorItem(item, MultiLayerItem::P_EXTERNAL_FIELD); P_multilayer->setExternalField(external_field); return P_multilayer; } @@ -216,7 +218,7 @@ void TransformToDomain::setTransformationInfo(IParticle* result, const SessionIt void TransformToDomain::setPositionInfo(IParticle* result, const SessionItem& item) { - kvector_t pos = SessionItemUtils::GetVectorItem(item, ParticleItem::P_POSITION); + kvector_t pos = GetVectorItem(item, ParticleItem::P_POSITION); result->setPosition(pos.x(), pos.y(), pos.z()); } diff --git a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorActions.cpp b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorActions.cpp index b875691d34fdc73de140a8b926d7c80ff2bb3b82..32cbd4cd8aed7112f326819de6d2d47d5e3001a3 100644 --- a/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorActions.cpp +++ b/GUI/coregui/Views/ImportDataWidgets/RealDataSelectorActions.cpp @@ -30,7 +30,7 @@ #include <QItemSelectionModel> #include <QMenu> -using namespace SessionItemUtils; +using SessionItemUtils::HasCHildren; namespace { bool openRotateWarningDialog(QWidget* parent) { diff --git a/Tests/UnitTests/GUI/TestMapperCases.h b/Tests/UnitTests/GUI/TestMapperCases.h index 4f62a5e77bdf26122f0c6de9236e8ee448ae816b..d936cc8085ca22e25fcce6b005ca4d05c2198acd 100644 --- a/Tests/UnitTests/GUI/TestMapperCases.h +++ b/Tests/UnitTests/GUI/TestMapperCases.h @@ -7,6 +7,8 @@ #include "SimulationOptionsItem.h" #include <QtTest> +using SessionItemUtils::ParentRow; + class TestMapperCases : public QObject { Q_OBJECT @@ -35,7 +37,7 @@ inline void TestMapperCases::test_ParticeleCompositionUpdate() = model.insertNewItem(Constants::ParticleCompositionType, distribution->index()); QVERIFY(composition->getItem(ParticleItem::P_ABUNDANCE)->isEnabled() == false); - composition = distribution->takeRow(SessionItemUtils::ParentRow(*composition)); + composition = distribution->takeRow(ParentRow(*composition)); QVERIFY(composition->getItem(ParticleItem::P_ABUNDANCE)->isEnabled()); delete composition; } diff --git a/Tests/UnitTests/GUI/TestMapperForItem.h b/Tests/UnitTests/GUI/TestMapperForItem.h index 5dadf3f884ba487dcffa7194e62f1ea9b5384b61..840e4cb0b76ac6adedc6c715cb85ee34ee1c063d 100644 --- a/Tests/UnitTests/GUI/TestMapperForItem.h +++ b/Tests/UnitTests/GUI/TestMapperForItem.h @@ -7,6 +7,7 @@ #include <memory> #include <QtTest> +using SessionItemUtils::ParentRow; //! Test Widget which logs calling activity of ModelMapper class Widget @@ -207,7 +208,7 @@ inline void TestMapperForItem::test_onParentChange() // Mapper is looking on child; changing child's parent setItem(layer, &w); QVERIFY(m_mapped_item == layer); - multilayer->takeRow(SessionItemUtils::ParentRow(*layer)); + multilayer->takeRow(ParentRow(*layer)); QCOMPARE(w.m_onPropertyChangeCount, 0); QCOMPARE(w.m_onChildPropertyChangeCount, 0); diff --git a/Tests/UnitTests/GUI/TestParticleCoreShell.h b/Tests/UnitTests/GUI/TestParticleCoreShell.h index 4fe48f59b31f11ec11bdeebb37dd6697cf67f917..604c087cbd89c7271b153a1791337cfd07d3f76e 100644 --- a/Tests/UnitTests/GUI/TestParticleCoreShell.h +++ b/Tests/UnitTests/GUI/TestParticleCoreShell.h @@ -7,6 +7,8 @@ #include "VectorItem.h" #include <QtTest> +using namespace SessionItemUtils; + class TestParticleCoreShell : public QObject { Q_OBJECT @@ -28,7 +30,7 @@ inline void TestParticleCoreShell::test_propertyAppearance() QVERIFY(coreshell->getItem(ParticleItem::P_ABUNDANCE)->isEnabled() == true); QCOMPARE(coreshell->getItemValue(ParticleItem::P_ABUNDANCE).toDouble(), 1.0); QVERIFY(coreshell->getItem(ParticleItem::P_POSITION)->isEnabled() == true); - kvector_t pos = SessionItemUtils::GetVectorItem(*coreshell, ParticleItem::P_POSITION); + kvector_t pos = GetVectorItem(*coreshell, ParticleItem::P_POSITION); QCOMPARE(pos.x(), 0.0); QCOMPARE(pos.y(), 0.0); QCOMPARE(pos.z(), 0.0); @@ -40,7 +42,7 @@ inline void TestParticleCoreShell::test_propertyAppearance() QVERIFY(core->getItem(ParticleItem::P_POSITION)->isEnabled() == true); // removing core, checking that abundance restored - coreshell->takeRow(SessionItemUtils::ParentRow(*core)); + coreshell->takeRow(ParentRow(*core)); QVERIFY(core->getItem(ParticleItem::P_ABUNDANCE)->isEnabled() == true); QVERIFY(core->getItem(ParticleItem::P_POSITION)->isEnabled() == true); delete core; @@ -61,7 +63,7 @@ inline void TestParticleCoreShell::test_propertyAppearance() QCOMPARE(shell->getItemValue(ParticleItem::P_ABUNDANCE).toDouble(), 1.0); // removing shell and checking abundance, position restored - coreshell->takeRow(SessionItemUtils::ParentRow(*shell)); + coreshell->takeRow(ParentRow(*shell)); QVERIFY(shell->getItem(ParticleItem::P_ABUNDANCE)->isEnabled() == true); QVERIFY(shell->getItem(ParticleItem::P_POSITION)->isEnabled() == true); delete shell; @@ -87,7 +89,7 @@ inline void TestParticleCoreShell::test_distributionContext() QCOMPARE(coreshell->getItemValue(ParticleItem::P_ABUNDANCE).toDouble(), 1.0); // removing coreshell - distribution->takeRow(SessionItemUtils::ParentRow(*coreshell)); + distribution->takeRow(ParentRow(*coreshell)); QVERIFY(coreshell->getItem(ParticleItem::P_ABUNDANCE)->isEnabled() == true); delete coreshell; } @@ -112,7 +114,7 @@ inline void TestParticleCoreShell::test_compositionContext() QCOMPARE(coreshell->getItemValue(ParticleItem::P_ABUNDANCE).toDouble(), 1.0); // removing coreshell - composition->takeRow(SessionItemUtils::ParentRow(*coreshell)); + composition->takeRow(ParentRow(*coreshell)); QVERIFY(coreshell->getItem(ParticleItem::P_ABUNDANCE)->isEnabled() == true); delete coreshell; } diff --git a/Tests/UnitTests/GUI/TestParticleItem.h b/Tests/UnitTests/GUI/TestParticleItem.h index cac8b087be44b3bd69419a25039e87829e9eeda0..be4089a2ddfa7e4f21efa858ad4ddf35a516f721 100644 --- a/Tests/UnitTests/GUI/TestParticleItem.h +++ b/Tests/UnitTests/GUI/TestParticleItem.h @@ -7,6 +7,8 @@ #include "SessionItemUtils.h" #include <QtTest> +using namespace SessionItemUtils; + class TestParticleItem : public QObject { Q_OBJECT @@ -48,7 +50,7 @@ inline void TestParticleItem::test_compositionContext() QCOMPARE(particle->getItemValue(ParticleItem::P_ABUNDANCE).toDouble(), 1.0); // removing particle, checking that abundance is enabled again - composition->takeRow(SessionItemUtils::ParentRow(*particle)); + composition->takeRow(ParentRow(*particle)); QVERIFY(particle->getItem(ParticleItem::P_ABUNDANCE)->isEnabled() == true); delete particle; } @@ -68,7 +70,7 @@ inline void TestParticleItem::test_distributionContext() QCOMPARE(particle->getItemValue(ParticleItem::P_ABUNDANCE).toDouble(), 1.0); // removing particle, checking that abundance is enabled again - distribution->takeRow(SessionItemUtils::ParentRow(*particle)); + distribution->takeRow(ParentRow(*particle)); QVERIFY(particle->getItem(ParticleItem::P_ABUNDANCE)->isEnabled() == true); delete particle; }