19#include <QCoreApplication>
41 : QWidget(parent), m_algoName(
""), m_algo(), m_errors(nullptr), 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;}");
118 FrameworkManager::Instance();
126 }
catch (std::runtime_error &) {
147 std::vector<Property *>::const_iterator pEnd = prop_list.end();
148 for (std::vector<Property *>::const_iterator pIter = prop_list.begin(); pIter != pEnd; ++pIter) {
168 propWidget->deleteLater();
172 while ((child =
m_inputGrid->takeAt(0)) !=
nullptr) {
174 child->widget()->deleteLater();
179 QCoreApplication::processEvents();
183 const std::vector<Property *> &prop_list =
getAlgorithm()->getProperties();
186 if (!prop_list.empty()) {
190 std::string
group =
"";
195 for (
auto prop : prop_list) {
196 QString propName = QString::fromStdString(prop->name());
199 if (prop->getGroup() !=
group) {
200 group = prop->getGroup();
207 QGroupBox *grpBox =
new QGroupBox(QString::fromStdString(
group));
208 grpBox->setAutoFillBackground(
true);
209 grpBox->setStyleSheet(
"QGroupBox { border: 1px solid gray; border-radius: 4px; "
210 "font-weight: bold; margin-top: 4px; margin-bottom: 4px; "
211 "padding-top: 16px; }"
212 "QGroupBox::title { background-color: transparent; "
213 "subcontrol-position: top center; padding-top:4px; "
214 "padding-bottom:4px; } ");
215 QPalette pal = grpBox->palette();
216 pal.setColor(grpBox->backgroundRole(), pal.alternateBase().color());
217 grpBox->setPalette(pal);
244 if (!oldValue.isEmpty()) {
245 auto error = prop->setValue(oldValue.toStdString());
262 connect(widget, SIGNAL(valueChanged(
const QString &)),
this, SLOT(
propertyChanged(
const QString &)));
265 connect(widget, SIGNAL(replaceWorkspaceName(
const QString &)),
this, SLOT(
replaceWSClicked(
const QString &)));
269 if (hasInputWS_ && !prop->disableReplaceWSButton())
289 const std::string &propertyName =
property->
name();
290 return propertyName ==
"InputWorkspace" || propertyName ==
"LHSWorkspace";
302 using CollectionOfPropertyWidget = std::vector<PropertyWidget *>;
303 CollectionOfPropertyWidget candidateReplacementSources;
310 if (otherWidget && wsProp) {
313 QString wsName = otherWidget->
getValue();
314 if (!wsName.isEmpty()) {
316 candidateReplacementSources.emplace_back(otherWidget);
324 if (candidateReplacementSources.size() > 0) {
325 const auto selectedIt = std::find_if(candidateReplacementSources.cbegin(), candidateReplacementSources.cend(),
327 if (selectedIt != candidateReplacementSources.end()) {
330 propWidget->
setValue((*selectedIt)->getValue());
334 propWidget->
setValue(candidateReplacementSources.front()->getValue());
348 throw std::runtime_error(
"`AlgorithmPropertiesWidget::isWidgetEnabled` called with null property pointer");
349 const std::string &propName = prop->
name();
352 if (
m_enabled.contains(QString::fromStdString(propName)))
359 if (
m_disabled.contains(QString::fromStdString(propName)))
362 return m_algo->isPropertyEnabled(propName);
372 throw std::runtime_error(
"`AlgorithmPropertiesWidget::isWidgetVisible` called with null property pointer");
373 const std::string &propName = prop->
name();
375 bool visible =
m_algo->isPropertyVisible(propName);
378 if (
m_errors && !
m_errors->value(QString::fromStdString(propName)).isEmpty())
394 auto const *changedPropWidget = !changedPropName.isEmpty() ?
m_propWidgets[changedPropName] :
nullptr;
397 const QString propName = QString::fromStdString(prop->
name());
400 if (!settings.empty()) {
405 for (
auto const &setting : settings)
406 if (setting->isConditionChanged(
m_algo.get(), changedPropName.toStdString())) {
407 if (setting->applyChanges(
m_algo.get(), prop->
name())) {
409 prop =
m_algo->getPointerToProperty(propName.toStdString());
411 widget->setVisible(
false);
415 auto *oldWidget = widget;
416 int row = widget->getGridRow();
417 QGridLayout *layout = widget->getGridLayout();
419 widget->transferHistoryState(oldWidget, changedPropWidget);
422 oldWidget->deleteLater();
426 connect(widget, SIGNAL(valueChanged(
const QString &)),
this, SLOT(
propertyChanged(
const QString &)));
441 widget->setEnabled(enabled);
442 widget->setVisible(visible);
457 QString
const &propName = pitr.key();
460 QString
value = (prop->isDefault() || prop->isDynamicDefault() ?
"" : widget->
getValue());
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.
Base class for properties.
std::vector< std::unique_ptr< IPropertySettings const > > const & getSettings() const
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.
bool isCalledInputWorkspaceOrLHSWorkspace(PropertyWidget *const candidate)
std::shared_ptr< IAlgorithm > IAlgorithm_sptr
shared pointer to Mantid::API::IAlgorithm
Mantid::Kernel::SingletonHolder< FrameworkManagerImpl > FrameworkManager
Mantid::Kernel::SingletonHolder< AlgorithmManagerImpl > AlgorithmManager
std::shared_ptr< Algorithm > Algorithm_sptr
Typedef for a shared pointer to an Algorithm.
@ Input
An input workspace.
@ Output
An output workspace.