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) {
167 while ((child =
m_inputGrid->takeAt(0)) !=
nullptr) {
169 child->widget()->deleteLater();
177 propWidget->deleteLater();
178 QCoreApplication::processEvents();
182 const std::vector<Property *> &prop_list =
getAlgorithm()->getProperties();
185 if (!prop_list.empty()) {
189 std::string
group =
"";
194 for (
auto prop : prop_list) {
195 QString propName = QString::fromStdString(prop->name());
198 if (prop->getGroup() !=
group) {
199 group = prop->getGroup();
206 QGroupBox *grpBox =
new QGroupBox(QString::fromStdString(
group));
207 grpBox->setAutoFillBackground(
true);
208 grpBox->setStyleSheet(
"QGroupBox { border: 1px solid gray; border-radius: 4px; "
209 "font-weight: bold; margin-top: 4px; margin-bottom: 4px; "
210 "padding-top: 16px; }"
211 "QGroupBox::title { background-color: transparent; "
212 "subcontrol-position: top center; padding-top:4px; "
213 "padding-bottom:4px; } ");
214 QPalette pal = grpBox->palette();
215 pal.setColor(grpBox->backgroundRole(), pal.alternateBase().color());
216 grpBox->setPalette(pal);
243 if (!oldValue.isEmpty()) {
244 auto error = prop->setValue(oldValue.toStdString());
261 connect(widget, SIGNAL(valueChanged(
const QString &)),
this, SLOT(
propertyChanged(
const QString &)));
264 connect(widget, SIGNAL(replaceWorkspaceName(
const QString &)),
this, SLOT(
replaceWSClicked(
const QString &)));
268 if (hasInputWS_ && !prop->disableReplaceWSButton())
288 const std::string &propertyName =
property->
name();
289 return propertyName ==
"InputWorkspace" || propertyName ==
"LHSWorkspace";
301 using CollectionOfPropertyWidget = std::vector<PropertyWidget *>;
302 CollectionOfPropertyWidget candidateReplacementSources;
309 if (otherWidget && wsProp) {
312 QString wsName = otherWidget->
getValue();
313 if (!wsName.isEmpty()) {
315 candidateReplacementSources.emplace_back(otherWidget);
323 if (candidateReplacementSources.size() > 0) {
324 const auto selectedIt = std::find_if(candidateReplacementSources.cbegin(), candidateReplacementSources.cend(),
326 if (selectedIt != candidateReplacementSources.end()) {
329 propWidget->
setValue((*selectedIt)->getValue());
333 propWidget->
setValue(candidateReplacementSources.front()->getValue());
347 throw std::runtime_error(
"`AlgorithmPropertiesWidget::isWidgetEnabled` called with null property pointer");
348 const std::string &propName = prop->
name();
351 if (
m_enabled.contains(QString::fromStdString(propName)))
358 if (
m_disabled.contains(QString::fromStdString(propName)))
361 return m_algo->isPropertyEnabled(propName);
371 throw std::runtime_error(
"`AlgorithmPropertiesWidget::isWidgetVisible` called with null property pointer");
372 const std::string &propName = prop->
name();
374 bool visible =
m_algo->isPropertyVisible(propName);
377 if (
m_errors && !
m_errors->value(QString::fromStdString(propName)).isEmpty())
393 auto const *changedPropWidget = !changedPropName.isEmpty() ?
m_propWidgets[changedPropName] :
nullptr;
396 const QString propName = QString::fromStdString(prop->
name());
399 if (!settings.empty()) {
404 for (
auto const &setting : settings)
405 if (setting->isConditionChanged(
m_algo.get(), changedPropName.toStdString())) {
406 if (setting->applyChanges(
m_algo.get(), prop->
name())) {
408 prop =
m_algo->getPointerToProperty(propName.toStdString());
410 widget->setVisible(
false);
414 auto *oldWidget = widget;
415 int row = widget->getGridRow();
416 QGridLayout *layout = widget->getGridLayout();
418 widget->transferHistoryState(oldWidget, changedPropWidget);
421 oldWidget->deleteLater();
425 connect(widget, SIGNAL(valueChanged(
const QString &)),
this, SLOT(
propertyChanged(
const QString &)));
440 widget->setEnabled(enabled);
441 widget->setVisible(visible);
456 QString
const &propName = pitr.key();
459 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.