19#include <QCoreApplication>
41 : QWidget(parent), m_algoName(
""), m_algo(), m_inputHistory(nullptr) {
49 auto *mainLay =
new QVBoxLayout();
54 mainLay->addStretch(1);
59 m_scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
60 m_scroll->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
63 m_scroll->setAlignment(Qt::Alignment(Qt::AlignLeft & Qt::AlignTop));
66 auto *dialog_layout =
new QVBoxLayout();
68 setLayout(dialog_layout);
74 setObjectName(
"AlgorithmPropertiesWidget");
75 setStyleSheet(
"#AlgorithmPropertiesWidget {min-width: 25em;}");
126 }
catch (std::runtime_error &) {
145 std::vector<Property *>::const_iterator pEnd = prop_list.end();
146 for (std::vector<Property *>::const_iterator pIter = prop_list.begin(); pIter != pEnd; ++pIter) {
165 while ((child =
m_inputGrid->takeAt(0)) !=
nullptr) {
167 child->widget()->deleteLater();
175 propWidget->deleteLater();
176 QCoreApplication::processEvents();
180 const std::vector<Property *> &prop_list =
getAlgorithm()->getProperties();
183 if (!prop_list.empty()) {
187 std::string group =
"";
192 for (
auto prop : prop_list) {
193 QString propName = QString::fromStdString(prop->name());
196 if (prop->getGroup() != group) {
197 group = prop->getGroup();
204 QGroupBox *grpBox =
new QGroupBox(QString::fromStdString(group));
205 grpBox->setAutoFillBackground(
true);
206 grpBox->setStyleSheet(
"QGroupBox { border: 1px solid gray; border-radius: 4px; "
207 "font-weight: bold; margin-top: 4px; margin-bottom: 4px; "
208 "padding-top: 16px; }"
209 "QGroupBox::title { background-color: transparent; "
210 "subcontrol-position: top center; padding-top:4px; "
211 "padding-bottom:4px; } ");
212 QPalette pal = grpBox->palette();
213 pal.setColor(grpBox->backgroundRole(), pal.alternateBase().color());
214 grpBox->setPalette(pal);
241 if (!oldValue.isEmpty()) {
242 auto error = prop->setValue(oldValue.toStdString());
251 connect(widget, SIGNAL(valueChanged(
const QString &)),
this, SLOT(
propertyChanged(
const QString &)));
254 connect(widget, SIGNAL(replaceWorkspaceName(
const QString &)),
this, SLOT(
replaceWSClicked(
const QString &)));
278 const std::string &propertyName =
property->
name();
279 return propertyName ==
"InputWorkspace";
289 using CollectionOfPropertyWidget = std::vector<PropertyWidget *>;
290 CollectionOfPropertyWidget candidateReplacementSources;
300 if (otherWidget && wsProp) {
304 if (!wsName.isEmpty()) {
306 candidateReplacementSources.emplace_back(otherWidget);
314 if (candidateReplacementSources.size() > 0) {
315 CollectionOfPropertyWidget::iterator selectedIt = std::find_if(
317 if (selectedIt != candidateReplacementSources.end()) {
320 propWidget->
setValue((*selectedIt)->getValue());
324 propWidget->
setValue(candidateReplacementSources.front()->getValue());
339 if (propName.isEmpty())
358 return property->getSettings()->isEnabled(
m_algo.get());
386 int row = widget->getGridRow();
387 QGridLayout *layout = widget->getGridLayout();
388 widget->setVisible(
false);
389 widget->deleteLater();
396 connect(widget, SIGNAL(valueChanged(
const QString &)),
this, SLOT(
propertyChanged(
const QString &)));
405 const auto &propName = QString::fromStdString(prop->
name());
424 if (
error.length() != 0)
428 widget->setEnabled(enabled);
429 widget->setVisible(visible);
443 const QString &propName = pitr.key();
double value
The value of the point.
This abstract class deals with the loading and saving of previous algorithm property values to/from M...
QString previousInput(const QString &algName, const QString &propName) const
Retrieve an old parameter value.
void storeNewValue(const QString &algName, const QPair< QString, QString > &property)
Update the old values that are stored here.
An interface that is implemented by WorkspaceProperty.
Interface for modifiers to Property's that specify if they should be enabled or visible in a GUI.
virtual void applyChanges(const IPropertyManager *, Property *const)
The function user have to overload it in their custom code to modify the property according to the ch...
virtual bool isConditionChanged(const IPropertyManager *algo, const std::string &changedPropName="") const
to verify if the properties, this one depends on have changed or other special condition occurs which...
virtual bool isVisible(const IPropertyManager *algo) const
Is the property to be shown in the GUI? Default true.
Base class for properties.
IPropertySettings * getSettings()
unsigned int direction() const
returns the direction of the property
const std::string & name() const
Get the property's name.
virtual std::string value() const =0
Returns the value of the property as a string.
Manage the lifetime of a class intended to be a singleton.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
bool isCalledInputWorkspace(PropertyWidget *const candidate)
bool haveInputWS(const std::vector< Property * > &prop_list)
std::shared_ptr< IAlgorithm > IAlgorithm_sptr
shared pointer to Mantid::API::IAlgorithm
std::shared_ptr< Algorithm > Algorithm_sptr
Typedef for a shared pointer to an Algorithm.
@ Input
An input workspace.
@ Output
An output workspace.