Mantid
Loading...
Searching...
No Matches
FitScriptGeneratorView.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2020 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9#include "DllOption.h"
10#include "ui_FitScriptGenerator.h"
11
13#include "MantidAPI/IFunction.h"
21
22#include <memory>
23#include <string>
24#include <tuple>
25#include <vector>
26
27#include <QCloseEvent>
28#include <QMap>
29#include <QString>
30#include <QStringList>
31#include <QWidget>
32
33namespace MantidQt {
34namespace MantidWidgets {
35
36class FitScriptGeneratorDataTable;
37class EditLocalParameterDialog;
38class IFitScriptGeneratorPresenter;
39struct GlobalParameter;
40struct GlobalTie;
41
44 Q_OBJECT
45
46public:
47 FitScriptGeneratorView(QWidget *parent = nullptr, FittingMode fittingMode = FittingMode::SEQUENTIAL,
48 QMap<QString, QString> const &fitOptions = QMap<QString, QString>());
49 ~FitScriptGeneratorView() override;
50
51 void subscribePresenter(IFitScriptGeneratorPresenter *presenter) override;
52
53 void deleteHandle(std::string const &wsName, [[maybe_unused]] Workspace_sptr const &ws) override;
54 void clearHandle() override;
55 void renameHandle(std::string const &wsName, std::string const &newName) override;
56
57 [[nodiscard]] std::string workspaceName(FitDomainIndex index) const override;
58 [[nodiscard]] WorkspaceIndex workspaceIndex(FitDomainIndex index) const override;
59 [[nodiscard]] double startX(FitDomainIndex index) const override;
60 [[nodiscard]] double endX(FitDomainIndex index) const override;
61
62 [[nodiscard]] std::vector<FitDomainIndex> allRows() const override;
63 [[nodiscard]] std::vector<FitDomainIndex> selectedRows() const override;
64 [[nodiscard]] FitDomainIndex currentRow() const override;
65
66 [[nodiscard]] bool hasLoadedData() const override;
67
68 [[nodiscard]] double parameterValue(std::string const &parameter) const override;
69 [[nodiscard]] Mantid::API::IFunction::Attribute attributeValue(std::string const &attribute) const override;
70
71 void renameWorkspace(std::string const &workspaceName, std::string const &newName) override;
72
73 void removeDomain(FitDomainIndex domainIndex) override;
74 void addWorkspaceDomain(std::string const &workspaceName, WorkspaceIndex workspaceIndex, double startX,
75 double endX) override;
76
77 void openAddWorkspaceDialog() override;
78 [[nodiscard]] std::vector<Mantid::API::MatrixWorkspace_const_sptr> getDialogWorkspaces() override;
79 [[nodiscard]] std::vector<WorkspaceIndex> getDialogWorkspaceIndices() const override;
80
81 void openEditLocalParameterDialog(std::string const &parameter, std::vector<std::string> const &workspaceNames,
82 std::vector<std::string> const &domainNames, std::vector<double> const &values,
83 std::vector<bool> const &fixes, std::vector<std::string> const &ties,
84 std::vector<std::string> const &constraints) override;
85 std::tuple<std::string, std::vector<double>, std::vector<bool>, std::vector<std::string>, std::vector<std::string>>
86 getEditLocalParameterResults() const override;
87
88 [[nodiscard]] std::tuple<std::string, std::string, std::string, std::string, std::string, bool>
89 fitOptions() const override;
90 [[nodiscard]] std::string filepath() const override;
91
92 void resetSelection() override;
93
94 bool applyFunctionChangesToAll() const override;
95
96 void clearFunction() override;
97 void setFunction(Mantid::API::IFunction_sptr const &function) const override;
98
99 void setSimultaneousMode(bool simultaneousMode) override;
100
101 void setGlobalTies(std::vector<GlobalTie> const &globalTies) override;
102 void setGlobalParameters(std::vector<GlobalParameter> const &globalParameter) override;
103
104 void displayWarning(std::string const &message) override;
105
106 void setSuccessText(std::string const &text) override;
107 void saveTextToClipboard(std::string const &text) const override;
108
109public:
111 FitScriptGeneratorDataTable *tableWidget() const override { return m_dataTable.get(); }
112 QPushButton *removeButton() const override { return m_ui.pbRemoveDomain; }
113 QPushButton *addWorkspaceButton() const override { return m_ui.pbAddDomain; }
114 AddWorkspaceDialog *addWorkspaceDialog() const override { return m_addWorkspaceDialog.get(); }
115 QPushButton *generateScriptToFileButton() const override { return m_ui.pbGenerateScriptToFile; }
116 QPushButton *generateScriptToClipboardButton() const override { return m_ui.pbGenerateScriptToClipboard; }
117
118public slots:
119 void closeEvent(QCloseEvent *event) override;
120
121private slots:
122 void notifyADSDeleteEvent(std::string const &workspaceName);
123 void notifyADSClearEvent();
124 void notifyADSRenameEvent(std::string const &workspaceName, std::string const &newName);
125
126 void closeAddWorkspaceDialog();
127 void addWorkspaceDialogAccepted(bool close);
128
129 void onRemoveDomainClicked();
130 void onAddDomainClicked();
131 void onCellChanged(int row, int column);
132 void onItemSelected();
133 void onFunctionRemoved(QString const &function);
134 void onFunctionAdded(QString const &function);
135 void onFunctionReplaced(QString const &function);
136 void onParameterChanged(QString const &parameter);
137 void onAttributeChanged(QString const &attribute);
138 void onParameterTieChanged(QString const &parameter, QString const &tie);
139 void onParameterConstraintRemoved(QString const &parameter);
140 void onParameterConstraintChanged(QString const &functionIndex, QString const &constraint);
141 void onGlobalParametersChanged(QStringList const &globalParameters);
142 void onCopyFunctionToClipboard();
143 void onFunctionHelpRequested();
144 void onOutputBaseNameChanged(std::string const &outputBaseName);
145 void onFittingModeChanged(FittingMode fittingMode);
146 void onEditLocalParameterClicked(QString const &parameter);
147 void onEditLocalParameterFinished(int result);
148 void onGenerateScriptToFileClicked();
149 void onGenerateScriptToClipboardClicked();
150 void onHelpClicked();
151
152private:
153 void connectUiSignals();
154
155 void setFitBrowserOptions(QMap<QString, QString> const &fitOptions);
156 void setFittingMode(FittingMode fittingMode);
157
159 std::unique_ptr<AddWorkspaceDialog> m_addWorkspaceDialog;
160 std::unique_ptr<FitScriptGeneratorDataTable> m_dataTable;
161 std::unique_ptr<FunctionTreeView> m_functionTreeView;
162 std::unique_ptr<FitScriptOptionsBrowser> m_fitOptionsBrowser;
164 Ui::FitScriptGenerator m_ui;
165};
166
167} // namespace MantidWidgets
168} // namespace MantidQt
#define EXPORT_OPT_MANTIDQT_COMMON
Definition: DllOption.h:15
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
A dialog for selecting a workspace from the ADS.
A dialog for displaying and editing values of local parameters.
This class represents the table widget which holds domain data for the FitScriptGenerator interface.
std::unique_ptr< FitScriptOptionsBrowser > m_fitOptionsBrowser
std::unique_ptr< FunctionTreeView > m_functionTreeView
QPushButton * generateScriptToFileButton() const override
std::unique_ptr< AddWorkspaceDialog > m_addWorkspaceDialog
QPushButton * generateScriptToClipboardButton() const override
FitScriptGeneratorDataTable * tableWidget() const override
Testing accessors.
AddWorkspaceDialog * addWorkspaceDialog() const override
std::unique_ptr< FitScriptGeneratorDataTable > m_dataTable
Attribute is a non-fitting parameter.
Definition: IFunction.h:282
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
Definition: Workspace_fwd.h:20
std::shared_ptr< IFunction > IFunction_sptr
shared pointer to the function base class
Definition: IFunction.h:732
void renameWorkspace(const IAlgorithm_sptr &renamer, const Workspace_sptr &workspace, const std::string &newName)
A struct to impliment strongly typed integers, without implicit conversion.
Definition: IndexTypes.h:24