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;}");
118 FrameworkManager::Instance();
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());
259 connect(widget, SIGNAL(valueChanged(
const QString &)),
this, SLOT(
propertyChanged(
const QString &)));
262 connect(widget, SIGNAL(replaceWorkspaceName(
const QString &)),
this, SLOT(
replaceWSClicked(
const QString &)));
266 if (hasInputWS && !prop->disableReplaceWSButton())
286 const std::string &propertyName =
property->
name();
287 return propertyName ==
"InputWorkspace" || propertyName ==
"LHSWorkspace";
299 using CollectionOfPropertyWidget = std::vector<PropertyWidget *>;
300 CollectionOfPropertyWidget candidateReplacementSources;
307 if (otherWidget && wsProp) {
310 QString wsName = otherWidget->
getValue();
311 if (!wsName.isEmpty()) {
313 candidateReplacementSources.emplace_back(otherWidget);
321 if (candidateReplacementSources.size() > 0) {
322 const auto selectedIt = std::find_if(candidateReplacementSources.cbegin(), candidateReplacementSources.cend(),
324 if (selectedIt != candidateReplacementSources.end()) {
327 propWidget->
setValue((*selectedIt)->getValue());
331 propWidget->
setValue(candidateReplacementSources.front()->getValue());
346 if (propName.isEmpty())
365 return property->getSettings()->isEnabled(
m_algo.get());
381 auto const *changedPropWidget = !changedPropName.isEmpty() ?
m_propWidgets[changedPropName] :
nullptr;
384 const QString propName = QString::fromStdString(prop->
name());
395 prop =
m_algo->getPointerToProperty(propName.toStdString());
397 widget->setVisible(
false);
401 auto *oldWidget = widget;
402 int row = widget->getGridRow();
403 QGridLayout *layout = widget->getGridLayout();
405 widget->transferHistoryState(oldWidget, changedPropWidget);
408 oldWidget->deleteLater();
412 connect(widget, SIGNAL(valueChanged(
const QString &)),
this, SLOT(
propertyChanged(
const QString &)));
422 auto const &propName = QString::fromStdString(prop->
name());
441 if (
error.length() != 0)
445 widget->setEnabled(enabled);
446 widget->setVisible(visible);
461 QString
const &propName = pitr.key();
464 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.
Interface for modifiers to Property's that specify if they should be enabled or visible in a GUI.
virtual bool applyChanges(const IPropertyManager *algo, const std::string ¤tPropName)
Overload this virtual function in order to modify the current property based on changes to other prop...
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.
const IPropertySettings * 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)
bool haveInputWS(const std::vector< Property * > &prop_list)
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.