14#include "MantidQtWidgets/Common/QtPropertyBrowser/DoubleDialogEditor.h"
15#include "MantidQtWidgets/Common/QtPropertyBrowser/qttreepropertybrowser.h"
23#include <QApplication>
36std::vector<WorkspaceIndex> convertToWorkspaceIndex(std::vector<int>
const &indices) {
37 std::vector<WorkspaceIndex> workspaceIndices;
38 workspaceIndices.reserve(indices.size());
39 std::transform(indices.cbegin(), indices.cend(), std::back_inserter(workspaceIndices),
40 [](
int index) { return WorkspaceIndex(index); });
41 return workspaceIndices;
44std::vector<std::string> convertToStdVector(QStringList
const &qList) {
45 std::vector<std::string> vec;
46 vec.reserve(
static_cast<std::size_t
>(qList.size()));
47 std::transform(qList.cbegin(), qList.cend(), std::back_inserter(vec),
48 [](QString
const &element) { return element.toStdString(); });
52template <
typename T> std::vector<T> convertQListToStdVector(
QList<T> const &qList) {
54 vec.reserve(
static_cast<std::size_t
>(qList.size()));
55 std::transform(qList.cbegin(), qList.cend(), std::back_inserter(vec), [](T
const &element) { return element; });
59QString toQString(std::string
const &str) {
return QString::fromStdString(str); }
65template <
typename Function,
typename T>
66QStringList convertToQStringList(
Function const &func, std::vector<T>
const &vec) {
68 qList.reserve(
static_cast<int>(vec.size()));
69 std::transform(vec.cbegin(), vec.cend(), std::back_inserter(qList), func);
73template <
typename T>
QList<T> convertToQList(std::vector<T>
const &vec) {
75 qList.reserve(
static_cast<int>(vec.size()));
76 std::transform(vec.cbegin(), vec.cend(), std::back_inserter(qList), [](T
const &element) { return element; });
80QString getDefaultScriptDirectory() {
82 if (previousDirectory.isEmpty())
84 return previousDirectory;
95 QMap<QString, QString>
const &fitOptions)
104 m_ui.splitterVertical->setSizes({360, 120});
134 connect(
m_functionTreeView.get(), SIGNAL(functionRemovedString(QString
const &)),
this,
142 connect(
m_functionTreeView.get(), SIGNAL(attributePropertyChanged(QString
const &)),
this,
144 connect(
m_functionTreeView.get(), SIGNAL(parameterTieChanged(QString
const &, QString
const &)),
this,
146 connect(
m_functionTreeView.get(), SIGNAL(parameterConstraintRemoved(QString
const &)),
this,
148 connect(
m_functionTreeView.get(), SIGNAL(parameterConstraintAdded(QString
const &, QString
const &)),
this,
154 connect(
m_functionTreeView.get(), SIGNAL(localParameterButtonClicked(QString
const &)),
this,
157 connect(
m_fitOptionsBrowser.get(), SIGNAL(outputBaseNameChanged(std::string
const &)),
this,
172 SLOT(closeEditor()));
190 if (QThread::currentThread() != QApplication::instance()->thread()) {
191 QMetaObject::invokeMethod(
this,
"notifyADSDeleteEvent", Qt::AutoConnection, Q_ARG(std::string
const &, wsName));
198 if (QThread::currentThread() != QApplication::instance()->thread()) {
199 QMetaObject::invokeMethod(
this,
"notifyADSClearEvent", Qt::AutoConnection);
206 if (QThread::currentThread() != QApplication::instance()->thread()) {
207 QMetaObject::invokeMethod(
this,
"notifyADSRenameEvent", Qt::AutoConnection, Q_ARG(std::string
const &, wsName),
208 Q_ARG(std::string
const &, newName));
231 if (column == ColumnIndex::StartX) {
234 }
else if (column == ColumnIndex::EndX) {
272 constraint.toStdString());
302 if (result == QDialog::Accepted)
355 double startX,
double endX) {
380 std::vector<MatrixWorkspace_const_sptr> workspaces;
383 if (workspaces.empty())
391 std::vector<WorkspaceIndex> workspaceIndices;
394 return workspaceIndices;
398 std::string
const ¶meter, std::vector<std::string>
const &workspaceNames,
399 std::vector<std::string>
const &domainNames, std::vector<double>
const &values, std::vector<bool>
const &fixes,
400 std::vector<std::string>
const &ties, std::vector<std::string>
const &constraints) {
402 this, QString::fromStdString(parameter), convertToQStringList(toQString, workspaceNames),
403 convertToQStringList(toQString, domainNames), convertToQList(values), convertToQList(fixes),
404 convertToQStringList(toQString, ties), convertToQStringList(toQString, constraints));
411std::tuple<std::string, std::vector<double>, std::vector<bool>, std::vector<std::string>, std::vector<std::string>>
420std::tuple<std::string, std::string, std::string, std::string, std::string, bool>
428 auto const defaultDirectory = getDefaultScriptDirectory();
429 auto const filePath = QFileDialog::getSaveFileName(this->parentWidget(), tr(
"Save Script As "), defaultDirectory,
430 tr(
"Script files (*.py)"));
432 if (!filePath.isEmpty())
435 return filePath.toStdString();
441 return m_ui.cbApplyFunctionChangesTo->currentText() ==
"All Domains";
447 m_dataTable->setFunctionPrefixVisible(simultaneousMode);
450 if (simultaneousMode)
468 m_functionTreeView->setGlobalParameters(convertToQStringList(globalToQString, globalParameters));
472 m_ui.lbMessage->setText(QString::fromStdString(text));
476 if (QClipboard *clipboard = QApplication::clipboard())
477 clipboard->setText(QString::fromStdString(text));
481 QMessageBox::warning(
this,
"Warning!", QString::fromStdString(message));
487 QWidget::closeEvent(event);
std::map< DeltaEMode::Type, std::string > index
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
static void showCustomInterface(const QString &name, const QString &area=QString(), const QString §ion=QString())
void observeRename(bool turnOn=true)
Function will add/remove the observer to the ADS for when a workspace is renamed.
void observeDelete(bool turnOn=true)
Function will add/remove the observer to the ADS for when a workspace is deleted.
void observeClear(bool turnOn=true)
Function will add/remove the observer to the ADS for when the ADS is cleared.
Attribute is a non-fitting parameter.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class