15#include <QDesktopWidget>
48 : QWidget(parent), m_fitDialog(parent), m_domainIndex(domainIndex), m_wsPropName("InputWorkspace"),
49 m_workspaceName(new QComboBox(this)), m_dynamicProperties(
nullptr), m_layout(new QVBoxLayout(this)) {
50 if (domainIndex > 0) {
51 m_wsPropName +=
"_" + QString::number(domainIndex);
53 m_layout->addWidget(m_workspaceName);
55 QStringList allowedValues = getAllowedPropertyValues(m_wsPropName);
56 m_workspaceName->clear();
57 m_workspaceName->insertItems(0, allowedValues);
58 connect(m_workspaceName, SIGNAL(currentIndexChanged(
int)),
this, SLOT(setDynamicProperties()));
60 setDynamicProperties();
68 return !wsName.isEmpty();
115 QWidget *w = item->widget();
127 m_layout->insertWidget(1,
new QLabel(
"MD Workspace is expected"));
133 m_layout->insertWidget(1,
new QLabel(
"Workspace of this type is not supported"));
178 m_endX =
new QLineEdit(
this);
180 auto layout =
new QGridLayout(
this);
181 layout->addWidget(
new QLabel(
"Workspace index"), 0, 0);
183 layout->addWidget(
new QLabel(
"StartX"), 1, 0);
185 layout->addWidget(
new QLabel(
"EndX"), 2, 0);
186 layout->addWidget(
m_endX, 2, 1);
191 m_maxSize->setMaximum(std::numeric_limits<int>::max());
192 layout->addWidget(
new QLabel(
"Maximum size"), 3, 0);
199 if (wsName.isEmpty())
208 m_startX->setText(QString::number(x.front()));
209 m_endX->setText(QString::number(x.back()));
225 QString wsIndexName =
"WorkspaceIndex";
226 QString startXName =
"StartX";
227 QString endXName =
"EndX";
228 QString maxSizeName =
"MaxSize";
231 if (domainIndex > 0) {
232 QString suffix =
"_" + QString::number(domainIndex);
233 wsIndexName += suffix;
234 startXName += suffix;
236 maxSizeName += suffix;
240 if (!
value.isEmpty()) {
244 if (!
value.isEmpty()) {
248 if (!
value.isEmpty()) {
267 auto layout =
new QGridLayout(
this);
270 m_maxSize->setMaximum(std::numeric_limits<int>::max());
271 layout->addWidget(
new QLabel(
"Maximum size"), 3, 0);
282 QString maxSizeName =
"MaxSize";
285 if (domainIndex > 0) {
286 QString suffix =
"_" + QString::number(domainIndex);
287 maxSizeName += suffix;
316 QString funStr =
m_form.function->getFunctionString();
317 if (!funStr.isEmpty()) {
330 QString funStr =
m_form.function->getFunctionString();
331 if (!funStr.isEmpty()) {
333 getAlgorithm()->setPropertyValue(
"Function", funStr.toStdString());
338 foreach (QWidget *t,
m_tabs) {
352 if (!funValue.isEmpty()) {
353 m_form.function->setFunction(funValue);
356 tie(
m_form.chbCreateOutput,
"CreateOutput",
m_form.staticLayout, readHistory);
358 tie(
m_form.leMaxIterations,
"MaxIterations",
m_form.staticLayout, readHistory);
361 tie(
m_form.cbCostFunction,
"CostFunction",
m_form.staticLayout, readHistory);
366 allowedDomainTypes.removeAll(
"Sequential");
367 allowedDomainTypes.removeAll(
"Parallel");
368 m_form.cbDomainType->addItems(allowedDomainTypes);
372 if (!domainTypeValue.isEmpty()) {
373 m_form.cbDomainType->setItemText(-1, domainTypeValue);
381 tie(
m_form.cbMinimizer,
"Minimizer",
m_form.staticLayout, readHistory);
394 minimizerList.removeAll(
"Levenberg-Marquardt");
396 QString currentMinimizer =
m_form.cbMinimizer->currentText();
397 m_form.cbMinimizer->clear();
398 m_form.cbMinimizer->addItems(minimizerList);
399 int index =
m_form.cbMinimizer->findText(currentMinimizer);
401 m_form.cbMinimizer->setItemText(-1, currentMinimizer);
410 m_form.tabWidget->clear();
412 foreach (QWidget *t,
m_tabs) {
423 if (!wsNames.isEmpty()) {
424 tab->setWorkspaceName(wsNames[0]);
426 m_form.tabWidget->addTab(tab,
"InputWorkspace");
429 auto fun =
m_form.function->getFunction();
432 auto multid = std::dynamic_pointer_cast<Mantid::API::MultiDomainFunction>(fun);
435 size_t nd = multid->getMaxIndex();
436 for (
int i = 1; i < static_cast<int>(nd); ++i) {
437 QString propName =
"InputWorkspace_" + QString::number(i);
439 if (wsNames.size() > (i)) {
440 tab->setWorkspaceName(wsNames[i]);
442 m_form.tabWidget->addTab(t, propName);
454 if (i < 0 || i >=
m_form.tabWidget->count())
476 for (std::vector<std::string>::const_iterator itr = workspaces.begin(); itr != workspaces.end(); ++itr) {
477 out << QString::fromStdString(*itr);
488 auto cf = std::dynamic_pointer_cast<Mantid::API::CompositeFunction>(fun);
490 return static_cast<bool>(std::dynamic_pointer_cast<Mantid::API::IFunctionMD>(fun));
491 for (
size_t i = 0; i < cf->nFunctions(); ++i) {
492 bool yes = isFunctionMD(cf->getFunction(i));
504 auto fun =
m_form.function->getFunction();
505 return isFunctionMD(fun);
512 QString type =
m_form.cbDomainType->currentText();
513 if (type ==
"Simple") {
515 }
else if (type ==
"Sequential") {
517 }
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.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
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