Mantid
Loading...
Searching...
No Matches
SmoothNeighboursDialog.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
11
12#include <QGroupBox>
13
14using namespace Mantid::API;
15using namespace Mantid::Geometry;
16using namespace MantidQt::API;
17
18// Register the class with the factory
20
21// As defined in algorithm. Make sure you change them in SmoothNeighbours.cpp as
22// well.
23const QString SmoothNeighboursDialog::NON_UNIFORM_GROUP = "NonUniform Detectors";
24const QString SmoothNeighboursDialog::RECTANGULAR_GROUP = "Rectangular Detectors";
25const QString SmoothNeighboursDialog::INPUT_WORKSPACE = "InputWorkspace";
26
28 : AlgorithmDialog(parent), m_propertiesWidget(nullptr), m_dialogLayout(nullptr) {}
29
31 // Create main layout
32 m_dialogLayout = new QVBoxLayout();
33
34 this->setLayout(m_dialogLayout);
35
36 // Set to size which fits all the possible widget changes
37 this->resize(475, 545);
38
39 // Create yellow information box
41
43
45
46 // Mark the properties that will be forced enabled or disabled
48
49 // Tie all the widgets to properties
50 for (auto it = m_propertiesWidget->m_propWidgets.begin(); it != m_propertiesWidget->m_propWidgets.end(); it++)
51 this->tie(it.value(), it.key());
52
54
56
57 connect(inputWorkspaceWidget, SIGNAL(valueChanged(const QString &)), this,
58 SLOT(inputWorkspaceChanged(const QString &)));
59
61
62 // Create and add the OK/Cancel/Help. buttons
63 m_dialogLayout->addLayout(this->createDefaultButtonLayout());
64
65 // Explicitly call, to hide/show property group from the beginning
66 inputWorkspaceWidget->valueChangedSlot();
67}
68
70 UNUSED_ARG(pName);
71
74
75 std::string inWsName = INPUT_WORKSPACE.toStdString();
76
77 // Workspace should have been set by PropertyWidget before emitting
78 // valueChanged
79 MatrixWorkspace_sptr inWs = this->getAlgorithm()->getProperty(inWsName);
80
81 if (!inWs) {
82 // Workspace groups are NOT returned by IWP->getWorkspace(), as they are not
83 // MatrixWorkspace,
84 // so check the ADS for the GroupWorkspace with the same name
85 std::string inWsValue = this->getAlgorithm()->getPointerToProperty(inWsName)->value();
86
87 // If it really doesn't exist, don't do anything
88 if (!AnalysisDataService::Instance().doesExist(inWsValue))
89 return;
90
91 WorkspaceGroup_sptr inGroupWs = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(inWsValue);
92
93 if (inGroupWs)
94 // If is a group workspace, use the first workspace to determine the
95 // instrument type,
96 // as most of the times it will be the same for all the workspaces
97 inWs = std::dynamic_pointer_cast<MatrixWorkspace>(inGroupWs->getItem(0));
98 else
99 // If is not a GroupWorkspace as well, do nothing
100 return;
101 }
102 Instrument::ContainsState containsRectDetectors = inWs->getInstrument()->containsRectDetectors();
103
104 if (containsRectDetectors == Instrument::ContainsState::Full)
106 else
108}
109
112
113 // If got there, there were errors
114 for (auto it = m_errors.begin(); it != m_errors.end(); it++)
115 m_propertiesWidget->m_propWidgets[it.key()]->updateIconVisibility(it.value());
116}
#define DECLARE_DIALOG(classname)
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
Definition: System.h:64
This class should be the basis for all customised algorithm dialogs.
QStringList m_enabled
A list of property names that should have their widgets enabled.
QStringList m_python_arguments
A list of property names that have been passed from Python.
QStringList m_disabled
A list of property names that the user has requested to be disabled (overrides those in enabled)
QHash< QString, QString > m_errors
A map where key = property name; value = the error for this property (i.e.
QLayout * createDefaultButtonLayout(const QString &helpText=QString("?"), const QString &loadText=QString("Run"), const QString &cancelText=QString("Close"), const QString &keepOpenText=QString("Keep Open"))
Create a row layout of buttons with specified text.
QWidget * tie(QWidget *widget, const QString &property, QLayout *parent_layout=nullptr, bool readHistory=true)
Tie a widget to a property.
Mantid::API::IAlgorithm_sptr getAlgorithm() const
Get the algorithm pointer.
void addOptionalMessage(QVBoxLayout *mainLay)
Add the optional message to the given layout.
void accept() override
A default slot that can be used for an OK button.
Widget that contains dynamically generated PropertyWidget's for each property of an algorithm,...
QHash< QString, QGroupBox * > m_groupWidgets
Mapping between group and it's dynamically created widget.
void setAlgorithm(const Mantid::API::IAlgorithm_sptr &algo)
Directly set the algorithm to view.
void hideOrDisableProperties(const QString &changedPropName="")
Go through all the properties, and check their validators to determine whether they should be made di...
void addEnabledAndDisableLists(const QStringList &enabled, const QStringList &disabled)
Sets the properties to force as enabled/disabled.
QHash< QString, PropertyWidget * > m_propWidgets
Each dynamically created PropertyWidget.
Base class for widgets that will set Mantid::Kernel::Property* types.
void valueChangedSlot()
Emits a signal that the value of the property was changed.
Class to hold a set of workspaces.
ContainsState
To determine whether the instrument contains elements of some type.
Definition: Instrument.h:203
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
void initLayout() override
Initialize the layout.
static const QString RECTANGULAR_GROUP
Rectangular detector group name.
SmoothNeighboursDialog(QWidget *parent=nullptr)
Constructor.
void inputWorkspaceChanged(const QString &pName)
Called when input workspace get changed.
static const QString INPUT_WORKSPACE
Input workspace name.
void accept() override
Overridden to enable validators.
static const QString NON_UNIFORM_GROUP
Non rectangular detector group name.
QVBoxLayout * m_dialogLayout
Main layout for the dialog.
MantidQt::API::AlgorithmPropertiesWidget * m_propertiesWidget
Widget for all the PropertyWidgets.
std::shared_ptr< WorkspaceGroup > WorkspaceGroup_sptr
shared pointer to Mantid::API::WorkspaceGroup
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class