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

Make SphericalDetectorEditor a regular widget and not derived from SessionItemWidget

parent d217c3b9
No related branches found
No related tags found
1 merge request!279Overhaul UI: instrument view (cont.)
......@@ -89,7 +89,7 @@ void DetectorEditor::onDetectorSelected(int)
m_editor_rectangular->setItem(polymorphic_downcast<RectangularDetectorItem*>(detector));
m_stack->setCurrentWidget(m_editor_rectangular);
} else {
m_editor_spherical->setItem(detector);
m_editor_spherical->setItem(polymorphic_downcast<SphericalDetectorItem*>(detector));
m_stack->setCurrentWidget(m_editor_spherical);
}
}
......@@ -143,52 +143,36 @@ void SphericalAxisEditor::onMaximumValueChanged(double value)
// SphericalDetectorEditor
//==================================================================================================
SphericalDetectorEditor::SphericalDetectorEditor(QWidget* parent)
: SessionItemWidget(parent)
, m_gridLayout(new QGridLayout)
SphericalDetectorEditor::SphericalDetectorEditor(QWidget* parent, Qt::WindowFlags f)
: QWidget(parent, f)
{
QGridLayout* grid = new QGridLayout(this);
grid->setColumnStretch(0, 1);
grid->setColumnStretch(1, 1);
grid->setColumnStretch(2, 1);
m_phiAxisEditor = new SphericalAxisEditor(SphericalAxisEditor::Phi_Axis, this);
m_gridLayout->addWidget(m_phiAxisEditor, 1, 0);
grid->addWidget(m_phiAxisEditor, 1, 0);
m_alphaAxisEditor = new SphericalAxisEditor(SphericalAxisEditor::Alpha_Axis, this);
m_gridLayout->addWidget(m_alphaAxisEditor, 1, 1);
grid->addWidget(m_alphaAxisEditor, 1, 1);
m_resolutionFunctionEditor =
new ResolutionFunctionEditor(ResolutionFunctionEditor::Degree, this);
m_gridLayout->addWidget(m_resolutionFunctionEditor, 1, 2);
grid->addWidget(m_resolutionFunctionEditor, 1, 2);
m_gridLayout->setColumnStretch(0, 1);
m_gridLayout->setColumnStretch(1, 1);
m_gridLayout->setColumnStretch(2, 1);
auto mainLayout = new QVBoxLayout;
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->addLayout(m_gridLayout);
mainLayout->addStretch();
setLayout(mainLayout);
grid->setRowStretch(2, 1);
}
void SphericalDetectorEditor::subscribeToItem()
void SphericalDetectorEditor::setItem(SphericalDetectorItem* item)
{
auto phiAxisItem = detectorItem()->phiAxisItem();
m_phiAxisEditor->setItem(phiAxisItem);
auto alphaAxisItem = detectorItem()->alphaAxisItem();
m_alphaAxisEditor->setItem(alphaAxisItem);
m_resolutionFunctionEditor->setItem(detectorItem());
}
void SphericalDetectorEditor::unsubscribeFromItem()
{
m_phiAxisEditor->clearItem();
m_alphaAxisEditor->clearItem();
m_resolutionFunctionEditor->clearItem();
}
SphericalDetectorItem* SphericalDetectorEditor::detectorItem()
{
auto result = dynamic_cast<SphericalDetectorItem*>(currentItem());
ASSERT(result);
return result;
if (item) {
m_phiAxisEditor->setItem(item->phiAxisItem());
m_alphaAxisEditor->setItem(item->alphaAxisItem());
m_resolutionFunctionEditor->setItem(item);
} else {
m_phiAxisEditor->clearItem();
m_alphaAxisEditor->clearItem();
m_resolutionFunctionEditor->clearItem();
}
}
......@@ -15,28 +15,23 @@
#ifndef BORNAGAIN_GUI_VIEWS_INSTRUMENTWIDGETS_SPHERICALDETECTOREDITOR_H
#define BORNAGAIN_GUI_VIEWS_INSTRUMENTWIDGETS_SPHERICALDETECTOREDITOR_H
#include "GUI/Views/CommonWidgets/SessionItemWidget.h"
class SphericalDetectorItem;
class QGridLayout;
#include <QWidget>
class ResolutionFunctionEditor;
class SphericalAxisEditor;
class SphericalDetectorItem;
class SphericalDetectorEditor : public SessionItemWidget {
class SphericalDetectorEditor : public QWidget {
Q_OBJECT
public:
SphericalDetectorEditor(QWidget* parent = nullptr);
protected:
void subscribeToItem();
void unsubscribeFromItem();
SphericalDetectorItem* detectorItem();
SphericalDetectorEditor(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
void setItem(SphericalDetectorItem* item);
private:
SphericalAxisEditor* m_phiAxisEditor;
SphericalAxisEditor* m_alphaAxisEditor;
ResolutionFunctionEditor* m_resolutionFunctionEditor;
QGridLayout* m_gridLayout;
};
#endif // BORNAGAIN_GUI_VIEWS_INSTRUMENTWIDGETS_SPHERICALDETECTOREDITOR_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment