BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ExtendedDetectorDialog.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Views/InstrumentWidgets/ExtendedDetectorDialog.cpp
6 //! @brief Implements class DistributionDialog
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
20 #include <QPushButton>
21 #include <QSettings>
22 #include <QVBoxLayout>
23 
25  : QDialog(parent), m_maskEditor(new MaskEditor), m_maskDelegate(new DetectorMaskDelegate(this))
26 {
27  setMinimumSize(256, 256);
28 
29  readSettings();
30 
31  setWindowTitle("Mask Editor");
32  setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
33  setAttribute(Qt::WA_DeleteOnClose, true);
34  setModal(true);
35 
36  QVBoxLayout* layout = new QVBoxLayout;
37  QPushButton* button = new QPushButton("Close", this);
38  connect(button, &QPushButton::clicked, this, &ExtendedDetectorDialog::close);
39 
40  QHBoxLayout* buttonLayout = new QHBoxLayout;
41  buttonLayout->addStretch(1);
42  buttonLayout->setContentsMargins(4, 4, 4, 4);
43  buttonLayout->addWidget(button);
44 
45  layout->addWidget(m_maskEditor);
46  layout->addLayout(buttonLayout);
47 
48  layout->setContentsMargins(0, 0, 0, 0);
49  setLayout(layout);
50 
51  // hadling keyboar focus policies
52  button->setDefault(false);
53  button->setAutoDefault(false);
54  setFocusProxy(m_maskEditor);
55 
56  SpaceKeyEater* filter = new SpaceKeyEater(this);
57  installEventFilter(filter);
58  button->installEventFilter(filter);
59 }
60 
62  DetectorItem* detectorItem)
63 {
64  m_maskDelegate->initMaskEditorContext(m_maskEditor, instrumentModel, detectorItem);
65 }
66 
68 {
69  writeSettings();
70  QDialog::reject();
71 }
72 
74 {
75  QSettings settings;
76  if (settings.childGroups().contains(Constants::S_MASKEDITOR)) {
77  settings.beginGroup(Constants::S_MASKEDITOR);
78  resize(settings.value(Constants::S_WINDOWSIZE, QSize(750, 650)).toSize());
79  move(settings.value(Constants::S_WINDOWPOSITION, QPoint(200, 200)).toPoint());
80  } else {
81  resize(750, 650);
82  }
83 }
84 
86 {
87  QSettings settings;
88  settings.beginGroup(Constants::S_MASKEDITOR);
89  settings.setValue(Constants::S_WINDOWSIZE, this->size());
90  settings.setValue(Constants::S_WINDOWPOSITION, this->pos());
91  settings.endGroup();
92 }
Defines classes releted to event filtering.
Defines class DetectorMaskDelegate.
Defines class DistributionDialog.
Defines class MaskEditor.
The DetectorMaskDelegate class provides synchronization between DetectorItem (defined in InstrumentMo...
void initMaskEditorContext(MaskEditor *maskEditor, InstrumentModel *instrumentModel, DetectorItem *detectorItem)
void setDetectorContext(InstrumentModel *instrumentModel, DetectorItem *detectorItem)
DetectorMaskDelegate * m_maskDelegate
ExtendedDetectorDialog(QWidget *parent=nullptr)
Main class to draw masks on top of intensity data map.
Definition: MaskEditor.h:31
Filter out space bar key events, which is special case for dialog windows.
Defines namespace Constants.
const char S_MASKEDITOR[]
const char S_WINDOWPOSITION[]
const char S_WINDOWSIZE[]