Skip to content
Snippets Groups Projects
Commit 72bd83e8 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

SourceItem.Footprint using PolyPtr

parent 1e57e6c7
No related branches found
No related tags found
1 merge request!2696PolyItem -> PolyPtr, with BaseItem as separate template parameter
......@@ -17,7 +17,7 @@
#include "GUI/Model/Beam/FootprintCatalog.h"
#include "GUI/Model/Descriptor/DoubleProperty.h"
#include "GUI/Model/Descriptor/PolyItem.h"
#include "GUI/Model/Descriptor/PolyPtr.h"
#include <functional>
#include <heinz/Vectors3D.h>
......@@ -43,7 +43,7 @@ public:
BeamDistributionItem* azimuthalAngleItem() const;
void setAzimuthalAngle(double value);
PolyItem<FootprintCatalog>& footprintSelection() { return m_footprint; }
PolyPtr<FootprintItem, FootprintCatalog>& footprintSelection() { return m_footprint; }
void setFootprintItem(const IFootprint* footprint);
void setGaussianFootprint(double value);
void setSquareFootprint(double value);
......@@ -60,7 +60,7 @@ protected:
DoubleProperty m_intensity;
std::unique_ptr<BeamDistributionItem> m_wavelength_item;
std::unique_ptr<BeamDistributionItem> m_azimuthal_angle_item;
PolyItem<FootprintCatalog> m_footprint;
PolyPtr<FootprintItem, FootprintCatalog> m_footprint;
};
class BeamItem : public SourceItem {
......
......@@ -28,7 +28,7 @@ FootprintForm::FootprintForm(QWidget* parent, SourceItem* item)
{
m_form_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
ASSERT(item->footprintSelection().certainItem());
auto* typeCombo = GUI::Util::createComboBoxFromPolyitem(
auto* typeCombo = GUI::Util::createComboBoxFromPolyPtr(
item->footprintSelection(),
[this](int) {
updateFootprintWidgets();
......
......@@ -16,6 +16,7 @@
#define BORNAGAIN_GUI_VIEW_NUMERIC_COMBOUTIL_H
#include "GUI/Model/Descriptor/PolyItem.h"
#include "GUI/Model/Descriptor/PolyPtr.h"
#include "GUI/View/Base/CustomEventFilters.h"
#include <QComboBox>
......@@ -46,8 +47,8 @@ QComboBox* createComboBox(std::function<ComboProperty()> comboFunction,
//!
//! Changes in the combobox will be notified to the PolyItem already. The additional (and
//! optional) slot can be used to be notified about an already executed change.
template <typename T>
QComboBox* createComboBoxFromPolyitem(PolyItem<T>& d, std::function<void(int)> slot,
template <typename C>
QComboBox* createComboBoxFromPolyitem(PolyItem<C>& d, std::function<void(int)> slot,
bool inScrollArea)
{
auto* combo = new QComboBox;
......@@ -68,6 +69,28 @@ QComboBox* createComboBoxFromPolyitem(PolyItem<T>& d, std::function<void(int)> s
return combo;
}
template <typename B, typename C>
QComboBox* createComboBoxFromPolyPtr(PolyPtr<B, C>& d, std::function<void(int)> slot,
bool inScrollArea)
{
auto* combo = new QComboBox;
combo->addItems(d.menuEntries());
combo->setMaxCount(d.menuEntries().size());
combo->setToolTip(d.piTooltip());
combo->setCurrentIndex(d.currentIndex());
if (inScrollArea)
WheelEventEater::install(combo);
QObject::connect(combo, &QComboBox::currentIndexChanged, [&d, slot](int index) {
d.setCurrentIndex(index);
if (slot)
slot(index);
});
return combo;
}
} // namespace GUI::Util
#endif // BORNAGAIN_GUI_VIEW_NUMERIC_COMBOUTIL_H
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