Skip to content
Snippets Groups Projects
Commit e14c0b4b authored by t.knopff's avatar t.knopff
Browse files

Merge branch 'overhaul_ui' into 'develop'

Overhaul UI: Instrument view: add a checkbox for the user to be able to enable and disable the analyzer & polarizer panel

See merge request !376
parents 7440988c 23315cb7
No related branches found
No related tags found
1 merge request!376Overhaul UI: Instrument view: add a checkbox for the user to be able to enable and disable the analyzer & polarizer panel
Pipeline #46041 passed
...@@ -131,6 +131,16 @@ bool InstrumentItem::alignedWith(const RealDataItem* item) const ...@@ -131,6 +131,16 @@ bool InstrumentItem::alignedWith(const RealDataItem* item) const
return shape() == item->shape(); return shape() == item->shape();
} }
bool InstrumentItem::withPolarizerAnalyzer() const
{
return getItemValue(P_WITH_POLARIZER_ANALYZER).toBool();
}
void InstrumentItem::setWithPolarizerAnalyzer(bool with)
{
setItemValue(P_WITH_POLARIZER_ANALYZER, with);
}
const R3 InstrumentItem::polarization() const const R3 InstrumentItem::polarization() const
{ {
return item<VectorItem>(P_POLARIZATION)->getVector(); return item<VectorItem>(P_POLARIZATION)->getVector();
...@@ -186,6 +196,7 @@ InstrumentItem::InstrumentItem(const QString& modelType) : SessionItem(modelType ...@@ -186,6 +196,7 @@ InstrumentItem::InstrumentItem(const QString& modelType) : SessionItem(modelType
setItemName(modelType); setItemName(modelType);
addProperty(P_IDENTIFIER, GUI::Helpers::createUuid())->setVisible(false); addProperty(P_IDENTIFIER, GUI::Helpers::createUuid())->setVisible(false);
addProperty(P_DESCRIPTION, QString())->setVisible(false); addProperty(P_DESCRIPTION, QString())->setVisible(false);
addProperty(P_WITH_POLARIZER_ANALYZER, false);
addProperty<VectorItem>(P_POLARIZATION); addProperty<VectorItem>(P_POLARIZATION);
addProperty<VectorItem>(P_ANALYZER_DIRECTION); addProperty<VectorItem>(P_ANALYZER_DIRECTION);
addProperty(P_ANALYZER_EFFICIENCY, 0.0)->setLimits(RealLimits::limitless()); addProperty(P_ANALYZER_EFFICIENCY, 0.0)->setLimits(RealLimits::limitless());
......
...@@ -35,6 +35,7 @@ private: ...@@ -35,6 +35,7 @@ private:
static constexpr auto P_BEAM{"Beam"}; static constexpr auto P_BEAM{"Beam"};
static constexpr auto P_BACKGROUND{"Background"}; static constexpr auto P_BACKGROUND{"Background"};
static constexpr auto P_DESCRIPTION{"Description"}; static constexpr auto P_DESCRIPTION{"Description"};
static constexpr auto P_WITH_POLARIZER_ANALYZER{"WithPolarizerAnalyzer"};
static constexpr auto P_POLARIZATION{"Polarization"}; static constexpr auto P_POLARIZATION{"Polarization"};
static constexpr auto P_ANALYZER_DIRECTION{"Analyzer direction"}; static constexpr auto P_ANALYZER_DIRECTION{"Analyzer direction"};
static constexpr auto P_ANALYZER_EFFICIENCY{"Efficiency"}; static constexpr auto P_ANALYZER_EFFICIENCY{"Efficiency"};
...@@ -66,6 +67,9 @@ public: ...@@ -66,6 +67,9 @@ public:
virtual ICoordSystem* createCoordSystem() const = 0; virtual ICoordSystem* createCoordSystem() const = 0;
bool withPolarizerAnalyzer() const;
void setWithPolarizerAnalyzer(bool with);
const R3 polarization() const; const R3 polarization() const;
void setPolarization(const R3& value); void setPolarization(const R3& value);
VectorItem* polarizationItem() const; VectorItem* polarizationItem() const;
......
...@@ -125,6 +125,7 @@ InstrumentListView::InstrumentListView(ProjectDocument* document, QWidget* paren ...@@ -125,6 +125,7 @@ InstrumentListView::InstrumentListView(ProjectDocument* document, QWidget* paren
updateFunctionalityNarrowing(); updateFunctionalityNarrowing();
updateActions(); updateActions();
ensureItemSelected();
} }
QSize InstrumentListView::sizeHint() const QSize InstrumentListView::sizeHint() const
...@@ -192,10 +193,7 @@ void InstrumentListView::onRemove() ...@@ -192,10 +193,7 @@ void InstrumentListView::onRemove()
if (!indexes.empty()) { if (!indexes.empty()) {
m_model->removeInstrument(indexes.front()); m_model->removeInstrument(indexes.front());
if (!m_listView->selectionModel()->hasSelection() && m_model->rowCount()) { ensureItemSelected();
QModelIndex last = m_model->index(m_model->rowCount() - 1, 0, QModelIndex());
m_listView->selectionModel()->select(last, QItemSelectionModel::ClearAndSelect);
}
} }
} }
...@@ -265,3 +263,11 @@ void InstrumentListView::updateActions() ...@@ -265,3 +263,11 @@ void InstrumentListView::updateActions()
m_copyAction->setEnabled(enabled); m_copyAction->setEnabled(enabled);
m_storeInLibraryAction->setEnabled(enabled); m_storeInLibraryAction->setEnabled(enabled);
} }
void InstrumentListView::ensureItemSelected()
{
if (!m_listView->selectionModel()->hasSelection() && m_model->rowCount()) {
QModelIndex last = m_model->index(m_model->rowCount() - 1, 0, QModelIndex());
m_listView->selectionModel()->select(last, QItemSelectionModel::ClearAndSelect);
}
}
...@@ -62,6 +62,7 @@ private: ...@@ -62,6 +62,7 @@ private:
void updateFunctionalityNarrowing(); void updateFunctionalityNarrowing();
void updateActions(); void updateActions();
void ensureItemSelected();
private: private:
ProjectDocument* m_document; ProjectDocument* m_document;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "GUI/Models/VectorItem.h" #include "GUI/Models/VectorItem.h"
#include "GUI/Views/InstrumentWidgets/VectorEditor.h" #include "GUI/Views/InstrumentWidgets/VectorEditor.h"
#include <QCheckBox>
#include <QDoubleSpinBox> #include <QDoubleSpinBox>
#include <QFormLayout> #include <QFormLayout>
#include <QGridLayout> #include <QGridLayout>
...@@ -117,22 +118,39 @@ void AnalyzerPropertiesEditor::onTransmissionValueChanged(double transmission) ...@@ -117,22 +118,39 @@ void AnalyzerPropertiesEditor::onTransmissionValueChanged(double transmission)
// PolarizationAnalysisEditor // PolarizationAnalysisEditor
//================================================================================================== //==================================================================================================
//--------------------------------------------------------------------------------------------------
// public member functions
//--------------------------------------------------------------------------------------------------
PolarizationAnalysisEditor::PolarizationAnalysisEditor(QWidget* parent, Qt::WindowFlags f) PolarizationAnalysisEditor::PolarizationAnalysisEditor(QWidget* parent, Qt::WindowFlags f)
: QWidget(parent, f), m_item(nullptr) : QWidget(parent, f), m_item(nullptr)
{ {
QGridLayout* grid = new QGridLayout(this); QVBoxLayout* layout = new QVBoxLayout(this);
m_checkbox = new QCheckBox("add polarizer and analyzer to instrument");
connect(m_checkbox, &QCheckBox::toggled, this, &PolarizationAnalysisEditor::onCheckBoxToggled);
layout->addWidget(m_checkbox);
m_polarizerAnalyzerWidget = new QWidget(this);
QGridLayout* grid = new QGridLayout(m_polarizerAnalyzerWidget);
grid->setMargin(0);
m_polarizerEditor = m_polarizerEditor =
new VectorEditor("Polarizer (Bloch vector)", new VectorEditor("Polarizer (Bloch vector)",
"Polarization of the beam, given as the Bloch vector (%1)", this); "Polarization of the beam, given as the Bloch vector (%1)",
m_polarizerAnalyzerWidget);
grid->addWidget(m_polarizerEditor, 0, 0); grid->addWidget(m_polarizerEditor, 0, 0);
m_analyzerEditor = new VectorEditor("Analyzer orientation", m_analyzerEditor = new VectorEditor("Analyzer orientation",
"Direction of the polarization analysis (%1)", this); "Direction of the polarization analysis (%1)",
m_polarizerAnalyzerWidget);
grid->addWidget(m_analyzerEditor, 0, 1); grid->addWidget(m_analyzerEditor, 0, 1);
m_propertiesEditor = new AnalyzerPropertiesEditor(this); m_propertiesEditor = new AnalyzerPropertiesEditor(m_polarizerAnalyzerWidget);
grid->addWidget(m_propertiesEditor, 0, 2); grid->addWidget(m_propertiesEditor, 0, 2);
layout->addWidget(m_polarizerAnalyzerWidget);
onCheckBoxToggled();
} }
void PolarizationAnalysisEditor::setItem(InstrumentItem* item) void PolarizationAnalysisEditor::setItem(InstrumentItem* item)
...@@ -140,12 +158,27 @@ void PolarizationAnalysisEditor::setItem(InstrumentItem* item) ...@@ -140,12 +158,27 @@ void PolarizationAnalysisEditor::setItem(InstrumentItem* item)
m_item = item; m_item = item;
setEnabled(m_item); setEnabled(m_item);
if (m_item) { if (m_item) {
m_checkbox->setChecked(m_item->withPolarizerAnalyzer());
m_polarizerEditor->setItem(m_item->polarizationItem()); m_polarizerEditor->setItem(m_item->polarizationItem());
m_analyzerEditor->setItem(m_item->analyzerDirectionItem()); m_analyzerEditor->setItem(m_item->analyzerDirectionItem());
m_propertiesEditor->setItem(m_item); m_propertiesEditor->setItem(m_item);
} else { } else {
m_checkbox->setChecked(false);
m_polarizerEditor->clearItem(); m_polarizerEditor->clearItem();
m_analyzerEditor->clearItem(); m_analyzerEditor->clearItem();
m_propertiesEditor->clearItem(); m_propertiesEditor->clearItem();
} }
} }
//--------------------------------------------------------------------------------------------------
// private slots
//--------------------------------------------------------------------------------------------------
void PolarizationAnalysisEditor::onCheckBoxToggled()
{
bool enabled = m_checkbox->isChecked();
m_polarizerAnalyzerWidget->setEnabled(enabled);
if (m_item)
m_item->setWithPolarizerAnalyzer(enabled);
}
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
class AnalyzerPropertiesEditor; class AnalyzerPropertiesEditor;
class DetectorItem; class DetectorItem;
class InstrumentItem; class InstrumentItem;
class QCheckBox;
class VectorEditor; class VectorEditor;
class VectorItem; class VectorItem;
...@@ -33,7 +34,12 @@ public: ...@@ -33,7 +34,12 @@ public:
PolarizationAnalysisEditor(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); PolarizationAnalysisEditor(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
void setItem(InstrumentItem* item); void setItem(InstrumentItem* item);
private slots:
void onCheckBoxToggled();
private: private:
QCheckBox* m_checkbox;
QWidget* m_polarizerAnalyzerWidget;
VectorEditor* m_polarizerEditor; VectorEditor* m_polarizerEditor;
VectorEditor* m_analyzerEditor; VectorEditor* m_analyzerEditor;
AnalyzerPropertiesEditor* m_propertiesEditor; AnalyzerPropertiesEditor* m_propertiesEditor;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment