47 : QWidget(parent), m_fitDialog(parent), m_domainIndex(domainIndex), m_wsPropName("InputWorkspace"),
48 m_workspaceName(new QComboBox(this)), m_dynamicProperties(
nullptr), m_layout(new QVBoxLayout(this)) {
49 if (domainIndex > 0) {
50 m_wsPropName +=
"_" + QString::number(domainIndex);
52 m_layout->addWidget(m_workspaceName);
54 QStringList allowedValues = getAllowedPropertyValues(m_wsPropName);
55 m_workspaceName->clear();
56 m_workspaceName->insertItems(0, allowedValues);
57 connect(m_workspaceName, SIGNAL(currentIndexChanged(
int)),
this, SLOT(setDynamicProperties()));
59 setDynamicProperties();
67 return !wsName.isEmpty();
78 auto ws = Mantid::API::AnalysisDataService::Instance().retrieve(wsName.toStdString());
93 auto ws = Mantid::API::AnalysisDataService::Instance().retrieve(wsName.toStdString());
114 QWidget *w = item->widget();
126 m_layout->insertWidget(1,
new QLabel(
"MD Workspace is expected"));
132 m_layout->insertWidget(1,
new QLabel(
"Workspace of this type is not supported"));
177 m_endX =
new QLineEdit(
this);
179 auto layout =
new QGridLayout(
this);
180 layout->addWidget(
new QLabel(
"Workspace index"), 0, 0);
182 layout->addWidget(
new QLabel(
"StartX"), 1, 0);
184 layout->addWidget(
new QLabel(
"EndX"), 2, 0);
185 layout->addWidget(
m_endX, 2, 1);
190 m_maxSize->setMaximum(std::numeric_limits<int>::max());
191 layout->addWidget(
new QLabel(
"Maximum size"), 3, 0);
198 if (wsName.isEmpty())
202 Mantid::API::AnalysisDataService::Instance().retrieve(wsName.toStdString()).get());
207 m_startX->setText(QString::number(x.front()));
208 m_endX->setText(QString::number(x.back()));
224 QString wsIndexName =
"WorkspaceIndex";
225 QString startXName =
"StartX";
226 QString endXName =
"EndX";
227 QString maxSizeName =
"MaxSize";
230 if (domainIndex > 0) {
231 QString suffix =
"_" + QString::number(domainIndex);
232 wsIndexName += suffix;
233 startXName += suffix;
235 maxSizeName += suffix;
239 if (!
value.isEmpty()) {
243 if (!
value.isEmpty()) {
247 if (!
value.isEmpty()) {
266 auto layout =
new QGridLayout(
this);
269 m_maxSize->setMaximum(std::numeric_limits<int>::max());
270 layout->addWidget(
new QLabel(
"Maximum size"), 3, 0);
281 QString maxSizeName =
"MaxSize";
284 if (domainIndex > 0) {
285 QString suffix =
"_" + QString::number(domainIndex);
286 maxSizeName += suffix;
315 QString funStr = QString::fromStdString(
m_form.function->getFunctionString());
316 if (!funStr.isEmpty()) {
329 auto funStr =
m_form.function->getFunctionString();
330 if (!funStr.empty()) {
337 foreach (QWidget *t,
m_tabs) {
351 if (!funValue.isEmpty()) {
352 m_form.function->setFunction(funValue.toStdString());
355 tie(
m_form.chbCreateOutput,
"CreateOutput",
m_form.staticLayout, readHistory);
357 tie(
m_form.leMaxIterations,
"MaxIterations",
m_form.staticLayout, readHistory);
360 tie(
m_form.cbCostFunction,
"CostFunction",
m_form.staticLayout, readHistory);
365 allowedDomainTypes.removeAll(
"Sequential");
366 allowedDomainTypes.removeAll(
"Parallel");
367 m_form.cbDomainType->addItems(allowedDomainTypes);
371 if (!domainTypeValue.isEmpty()) {
372 m_form.cbDomainType->setItemText(-1, domainTypeValue);
380 tie(
m_form.cbMinimizer,
"Minimizer",
m_form.staticLayout, readHistory);
393 minimizerList.removeAll(
"Levenberg-Marquardt");
395 QString currentMinimizer =
m_form.cbMinimizer->currentText();
396 m_form.cbMinimizer->clear();
397 m_form.cbMinimizer->addItems(minimizerList);
398 int index =
m_form.cbMinimizer->findText(currentMinimizer);
400 m_form.cbMinimizer->setItemText(-1, currentMinimizer);
409 m_form.tabWidget->clear();
411 foreach (QWidget *t,
m_tabs) {
422 if (!wsNames.isEmpty()) {
423 tab->setWorkspaceName(wsNames[0]);
425 m_form.tabWidget->addTab(tab,
"InputWorkspace");
428 auto fun =
m_form.function->getFunction();
431 auto multid = std::dynamic_pointer_cast<Mantid::API::MultiDomainFunction>(fun);
434 size_t nd = multid->getMaxIndex();
435 for (
int i = 1; i < static_cast<int>(nd); ++i) {
436 QString propName =
"InputWorkspace_" + QString::number(i);
438 if (wsNames.size() > (i)) {
439 tab->setWorkspaceName(wsNames[i]);
441 m_form.tabWidget->addTab(t, propName);
453 if (i < 0 || i >=
m_form.tabWidget->count())
475 for (std::vector<std::string>::const_iterator itr = workspaces.begin(); itr != workspaces.end(); ++itr) {
476 out << QString::fromStdString(*itr);
487 auto cf = std::dynamic_pointer_cast<Mantid::API::CompositeFunction>(fun);
489 return static_cast<bool>(std::dynamic_pointer_cast<Mantid::API::IFunctionMD>(fun));
490 for (
size_t i = 0; i < cf->nFunctions(); ++i) {
491 bool yes = isFunctionMD(cf->getFunction(i));
503 auto fun =
m_form.function->getFunction();
504 return isFunctionMD(fun);
511 QString type =
m_form.cbDomainType->currentText();
512 if (type ==
"Simple") {
514 }
else if (type ==
"Sequential") {
516 }
else if (type ==
"Parallel") {
#define DECLARE_DIALOG(classname)
double value
The value of the point.
std::map< DeltaEMode::Type, std::string > index
This class should be the basis for all customised algorithm dialogs.
bool setPropertyValues(const QStringList &skipList=QStringList())
Set properties on this algorithm by pulling values from the tied widgets.
QString getPreviousValue(const QString &propName) const
Get the property value from either the previous input store or from Python argument.
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.
void storePropertyValue(const QString &name, const QString &value)
Adds a property (name,value) pair to the stored map.
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.
Mantid::Kernel::Property * getAlgorithmProperty(const QString &propName) const
Get a pointer to the named property.
virtual void saveInput()
Save the input history of an accepted dialog.
This class gives specialised dialog for the Load algorithm.
void initLayout() override
Initialize the layout.
QString getDomainTypeString() const
Get the domain type: Simple, Sequential, or Parallel.
void setWorkspaceName(int i, const QString &wsName)
Set i-th workspace name.
QList< QWidget * > m_tabs
bool isMD() const
Is the function MD?
void parseInput() override
Parse input.
void workspaceChanged(const QString &)
Override the help button clicked method.
void saveInput() override
Save the input history.
FitDialog(QWidget *parent=nullptr)
Default constructor.
Ui::FitDialog m_form
Form.
int getDomainType() const
Get the domain type: Simple, Sequential, or Parallel.
void domainTypeChanged()
Update user interface when domain type changes.
void createInputWorkspaceWidgets()
Create InputWorkspaceWidgets and populate the tabs of the tab widget.
QStringList getAllowedPropertyValues(const QString &propName) const
Get allowed values for a property.
friend class InputWorkspaceWidget
void tieStaticWidgets(const bool readHistory)
Tie static widgets to their properties.
Basic MD Workspace Abstract Class.
Base MatrixWorkspace Abstract Class.
virtual std::vector< std::string > allowedValues() const
Returns the set of valid values for this property, if such a set exists.
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
std::vector< double > MantidVec
typedef for the data storage used in Mantid matrix workspaces