diff --git a/GUI/coregui/Models/BeamItem.cpp b/GUI/coregui/Models/BeamItem.cpp index 0106f998c6b7f1d14536f58d56e3d0afbdd2f76d..3a06699bcba052343002afee11d6e314f0d76316 100644 --- a/GUI/coregui/Models/BeamItem.cpp +++ b/GUI/coregui/Models/BeamItem.cpp @@ -23,10 +23,16 @@ #include "Units.h" #include "Beam.h" +namespace { +const QString polarization_tooltip = + "Polarization of the beam, given as the Bloch vector"; +} + const QString BeamItem::P_INTENSITY = QString::fromStdString(BornAgain::Intensity); const QString BeamItem::P_WAVELENGTH = QString::fromStdString(BornAgain::Wavelength); const QString BeamItem::P_INCLINATION_ANGLE = QString::fromStdString(BornAgain::Inclination); const QString BeamItem::P_AZIMUTHAL_ANGLE = QString::fromStdString(BornAgain::Azimuth); +const QString BeamItem::P_POLARIZATION = QString("Polarization"); BeamItem::BeamItem() : SessionItem(Constants::BeamType) { @@ -36,6 +42,7 @@ BeamItem::BeamItem() : SessionItem(Constants::BeamType) addGroupProperty(P_WAVELENGTH, Constants::BeamWavelengthType); addGroupProperty(P_INCLINATION_ANGLE, Constants::BeamInclinationAngleType); addGroupProperty(P_AZIMUTHAL_ANGLE, Constants::BeamAzimuthalAngleType); + addGroupProperty(P_POLARIZATION, Constants::VectorType)->setToolTip(polarization_tooltip); } BeamItem::~BeamItem(){} diff --git a/GUI/coregui/Models/BeamItem.h b/GUI/coregui/Models/BeamItem.h index 135c26683cc13ec77d4d1bfb885788d2c762ad7f..c9b32605f73f80500ed466cba4ab2297b0b446db 100644 --- a/GUI/coregui/Models/BeamItem.h +++ b/GUI/coregui/Models/BeamItem.h @@ -29,6 +29,7 @@ public: static const QString P_WAVELENGTH; static const QString P_INCLINATION_ANGLE; static const QString P_AZIMUTHAL_ANGLE; + static const QString P_POLARIZATION; BeamItem(); virtual ~BeamItem(); diff --git a/GUI/coregui/Models/DetectorItems.cpp b/GUI/coregui/Models/DetectorItems.cpp index faf46cf66b7bba08577940bddd3fa3fd9fd39707..7b55b29deab6881f0c0f23c0789e8cc2b64cd968 100644 --- a/GUI/coregui/Models/DetectorItems.cpp +++ b/GUI/coregui/Models/DetectorItems.cpp @@ -23,22 +23,32 @@ #include "ResolutionFunction2DGaussian.h" namespace { - const QString res_func_group_label = "Type"; +const QString res_func_group_label = "Type"; +const QString analyzer_direction_tooltip = "Direction of the polarization analysis"; +const QString analyzer_efficiency_tooltip = "Efficiency of the polarization analysis"; +const QString analyzer_transmission_tooltip = "Total transmission of the polarization analysis"; } const QString DetectorItem::T_MASKS = "Masks"; const QString DetectorItem::P_RESOLUTION_FUNCTION = "ResolutionFunctions"; +const QString DetectorItem::P_ANALYZER_DIRECTION = "Analyzer direction"; +const QString DetectorItem::P_ANALYZER_EFFICIENCY = "Analyzer efficiency"; +const QString DetectorItem::P_ANALYZER_TOTAL_TRANSMISSION = "Total transmission"; DetectorItem::DetectorItem(const QString& modelType) : SessionItem(modelType) { registerTag(T_MASKS, 0, -1, QStringList() << Constants::MaskContainerType); setDefaultTag(T_MASKS); + addGroupProperty(P_ANALYZER_DIRECTION, Constants::VectorType)->setToolTip( + analyzer_direction_tooltip); + addProperty(P_ANALYZER_EFFICIENCY, 0.0)->setToolTip(analyzer_efficiency_tooltip); + addProperty(P_ANALYZER_TOTAL_TRANSMISSION, 1.0)->setToolTip(analyzer_transmission_tooltip); + mapper()->setOnPropertyChange([this](const QString& name) { if (name == P_RESOLUTION_FUNCTION) update_resolution_function_tooltips(); }); - } std::unique_ptr<IDetector2D> DetectorItem::createDetector() const diff --git a/GUI/coregui/Models/DetectorItems.h b/GUI/coregui/Models/DetectorItems.h index 3583941a9a124f058690a048cc33acc8b294eec6..6f2b4cfda95f42134cd5a43a89c014252bffc9c7 100644 --- a/GUI/coregui/Models/DetectorItems.h +++ b/GUI/coregui/Models/DetectorItems.h @@ -29,6 +29,9 @@ class BA_CORE_API_ DetectorItem : public SessionItem public: static const QString T_MASKS; static const QString P_RESOLUTION_FUNCTION; + static const QString P_ANALYZER_DIRECTION; + static const QString P_ANALYZER_EFFICIENCY; + static const QString P_ANALYZER_TOTAL_TRANSMISSION; explicit DetectorItem(const QString& modelType); std::unique_ptr<IDetector2D> createDetector() const; diff --git a/GUI/coregui/Views/InstrumentWidgets/BeamEditorWidget.cpp b/GUI/coregui/Views/InstrumentWidgets/BeamEditorWidget.cpp index 532d138a4a4ffd1789965afc6d085d497d4bbc15..b5570be1bba35bb4ac50783946a42b9bfddb8442 100644 --- a/GUI/coregui/Views/InstrumentWidgets/BeamEditorWidget.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/BeamEditorWidget.cpp @@ -35,6 +35,7 @@ BeamEditorWidget::BeamEditorWidget(QWidget* parent) , m_wavelengthPresenter(new ComponentInfoBox(name_of_groupbox_wavenlength)) , m_inclinationAnglePresenter(new ComponentInfoBox(name_of_groupbox_inclination)) , m_azimuthalAnglePresenter(new ComponentInfoBox(name_of_groupbox_azimuthal)) + , m_polarizationPresenter(new ComponentBoxEditor) , m_gridLayout(new QGridLayout) , m_beamItem(nullptr) { @@ -45,6 +46,7 @@ BeamEditorWidget::BeamEditorWidget(QWidget* parent) m_gridLayout->addWidget(m_wavelengthPresenter, 1, 0); m_gridLayout->addWidget(m_inclinationAnglePresenter, 1, 1); m_gridLayout->addWidget(m_azimuthalAnglePresenter, 1, 2); + m_gridLayout->addWidget(m_polarizationPresenter, 1, 3); QGroupBox* groupBox = new QGroupBox(QStringLiteral("Beam Parameters")); QVBoxLayout* groupLayout = new QVBoxLayout; @@ -72,6 +74,7 @@ void BeamEditorWidget::setBeamItem(BeamItem* beamItem) m_wavelengthPresenter->clearEditor(); m_inclinationAnglePresenter->clearEditor(); m_azimuthalAnglePresenter->clearEditor(); + m_polarizationPresenter->clearEditor(); if (!m_beamItem) return; @@ -89,6 +92,10 @@ void BeamEditorWidget::setBeamItem(BeamItem* beamItem) SessionItem* azimuthalAngleItem = m_beamItem->getItem(BeamItem::P_AZIMUTHAL_ANGLE); m_azimuthalAnglePresenter->addPropertyItems( azimuthalAngleItem->getItem(BeamDistributionItem::P_DISTRIBUTION)); + + SessionItem* polarizationItem = m_beamItem->getItem(BeamItem::P_POLARIZATION); + m_polarizationPresenter->addPropertyItems( + polarizationItem, QStringLiteral("Polarization (Bloch vector)")); } void BeamEditorWidget::onDialogRequest(SessionItem* item, const QString& name) diff --git a/GUI/coregui/Views/InstrumentWidgets/BeamEditorWidget.h b/GUI/coregui/Views/InstrumentWidgets/BeamEditorWidget.h index 7d9fb29515c42b1a20f90d584091949c6ef8c872..2f75b8008e32a6372907b904484c3e6203c820bf 100644 --- a/GUI/coregui/Views/InstrumentWidgets/BeamEditorWidget.h +++ b/GUI/coregui/Views/InstrumentWidgets/BeamEditorWidget.h @@ -44,6 +44,7 @@ private: ComponentInfoBox* m_wavelengthPresenter; ComponentInfoBox* m_inclinationAnglePresenter; ComponentInfoBox* m_azimuthalAnglePresenter; + ComponentBoxEditor* m_polarizationPresenter; QGridLayout* m_gridLayout; BeamItem* m_beamItem; }; diff --git a/GUI/coregui/Views/InstrumentWidgets/SphericalDetectorWidget.cpp b/GUI/coregui/Views/InstrumentWidgets/SphericalDetectorWidget.cpp index 91335817179d1b64608b2a898053e4276b546bef..be9922b2112754ee69aa5be02b416aa8038f3515 100644 --- a/GUI/coregui/Views/InstrumentWidgets/SphericalDetectorWidget.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/SphericalDetectorWidget.cpp @@ -28,11 +28,13 @@ SphericalDetectorWidget::SphericalDetectorWidget(ColumnResizer* columnResizer, , m_phiAxisEditor(new ComponentBoxEditor) , m_alphaAxisEditor(new ComponentBoxEditor) , m_resolutionFunctionEditor(new ComponentBoxEditor) + , m_polarizationAnalysisEditor(new ComponentBoxEditor) , m_gridLayout(new QGridLayout) { m_gridLayout->addWidget(m_phiAxisEditor, 1, 0); m_gridLayout->addWidget(m_alphaAxisEditor, 1, 1); m_gridLayout->addWidget(m_resolutionFunctionEditor, 1, 2); + m_gridLayout->addWidget(m_polarizationAnalysisEditor, 1, 3); m_columnResizer->addWidgetsFromGridLayout(m_gridLayout, 0); m_columnResizer->addWidgetsFromGridLayout(m_gridLayout, 1); @@ -56,6 +58,7 @@ SphericalDetectorWidget::~SphericalDetectorWidget() m_phiAxisEditor->clearEditor(); m_alphaAxisEditor->clearEditor(); m_resolutionFunctionEditor->clearEditor(); + m_polarizationAnalysisEditor->clearEditor(); if (m_columnResizer) m_columnResizer->dropWidgetsFromGridLayout(m_gridLayout); } @@ -65,6 +68,7 @@ void SphericalDetectorWidget::setDetectorItem(SessionItem* detectorItem) m_phiAxisEditor->clearEditor(); m_alphaAxisEditor->clearEditor(); m_resolutionFunctionEditor->clearEditor(); + m_polarizationAnalysisEditor->clearEditor(); if (!detectorItem) return; @@ -80,6 +84,14 @@ void SphericalDetectorWidget::setDetectorItem(SessionItem* detectorItem) SessionItem* resFuncGroup = detectorItem->getItem(SphericalDetectorItem::P_RESOLUTION_FUNCTION); m_resolutionFunctionEditor->addPropertyItems(resFuncGroup, QStringLiteral("Resolution function")); + + SessionItem* analysisDirection = detectorItem->getItem(DetectorItem::P_ANALYZER_DIRECTION); + m_polarizationAnalysisEditor->addPropertyItems( + analysisDirection, QStringLiteral("Analyzer orientation")); + m_polarizationAnalysisEditor->addItem( + detectorItem->getItem(DetectorItem::P_ANALYZER_EFFICIENCY)); + m_polarizationAnalysisEditor->addItem( + detectorItem->getItem(DetectorItem::P_ANALYZER_TOTAL_TRANSMISSION)); } void SphericalDetectorWidget::onColumnResizerDestroyed(QObject* object) diff --git a/GUI/coregui/Views/InstrumentWidgets/SphericalDetectorWidget.h b/GUI/coregui/Views/InstrumentWidgets/SphericalDetectorWidget.h index ad441ece3761080405d07129c09844c535688ebc..b6c0370fd8d34eca3de82dda9fe94659973a7ba5 100644 --- a/GUI/coregui/Views/InstrumentWidgets/SphericalDetectorWidget.h +++ b/GUI/coregui/Views/InstrumentWidgets/SphericalDetectorWidget.h @@ -45,6 +45,7 @@ private: ComponentBoxEditor* m_phiAxisEditor; ComponentBoxEditor* m_alphaAxisEditor; ComponentBoxEditor* m_resolutionFunctionEditor; + ComponentBoxEditor* m_polarizationAnalysisEditor; QGridLayout* m_gridLayout; }; diff --git a/GUI/coregui/Views/PropertyEditor/ComponentBoxEditor.h b/GUI/coregui/Views/PropertyEditor/ComponentBoxEditor.h index 225e02abf80100ba334cd9cccd7e7f125e418124..5be48bb24a4d5cdce653a9778dc4edde7ea1e0d9 100644 --- a/GUI/coregui/Views/PropertyEditor/ComponentBoxEditor.h +++ b/GUI/coregui/Views/PropertyEditor/ComponentBoxEditor.h @@ -35,10 +35,9 @@ public: void updateItem(SessionItem *item, QtVariantProperty *parentProperty); public slots: - void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles); + void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, + const QVector<int> &roles); void onRowsInserted(const QModelIndex &, int, int); - }; - #endif // COMPONENTBOXEDITOR_H diff --git a/Tests/Functional/GUI/GUISpecial/GUITranslationTest.cpp b/Tests/Functional/GUI/GUISpecial/GUITranslationTest.cpp index ceb0957c59b7221af7c310421cefbb8b1512fdfe..bf616abee3df0a6f196611fff08315e5296f02a6 100644 --- a/Tests/Functional/GUI/GUISpecial/GUITranslationTest.cpp +++ b/Tests/Functional/GUI/GUISpecial/GUITranslationTest.cpp @@ -15,6 +15,7 @@ // ************************************************************************** // #include "GUITranslationTest.h" +#include "BeamItem.h" #include "SimulationFactory.h" #include "SampleBuilderFactory.h" #include "GISASSimulation.h" @@ -143,6 +144,14 @@ bool GUITranslationTest::isValidDomainName(const std::string& domainName) const return true; } +bool GUITranslationTest::isValidGUIName(const std::string& guiName) const +{ + std::string beam_polarization = BeamItem::P_POLARIZATION.toStdString(); + if(guiName.find(beam_polarization)!=std::string::npos) + return false; + return true; +} + //! Validates GUI translations against simulation parameters. Tries to retrieve fit parameter //! from domain parameter pool using translated name. @@ -155,6 +164,8 @@ bool GUITranslationTest::checkExistingTranslations() std::unique_ptr<ParameterPool> pool(m_simulation->createParameterTree()); std::vector<ParItem> wrong_translations; for(auto guiPar : m_translations) { + if (!isValidGUIName(guiPar.parPath)) + continue; try { pool->getMatchedParameters(guiPar.translatedName); } catch (const std::runtime_error &/*ex*/) { diff --git a/Tests/Functional/GUI/GUISpecial/GUITranslationTest.h b/Tests/Functional/GUI/GUISpecial/GUITranslationTest.h index f5d00b43b837b11a183034a5d64953b9fc896133..8a2b0b538fa3c1bf4305d3f68f189b5bbc579276 100644 --- a/Tests/Functional/GUI/GUISpecial/GUITranslationTest.h +++ b/Tests/Functional/GUI/GUISpecial/GUITranslationTest.h @@ -53,6 +53,7 @@ private: std::string translationResultsToString() const; bool isValidDomainName(const std::string& domainName) const; + bool isValidGUIName(const std::string& guiName) const; bool checkExistingTranslations(); bool checkMissedTranslations();