Mantid
Loading...
Searching...
No Matches
MantidWSIndexDialog.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2009 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//----------------------------------
10// Includes
11//----------------------------------
14#include <QCheckBox>
15#include <QComboBox>
16#include <QDialog>
17#include <QGroupBox>
18#include <QLabel>
19#include <QLineEdit>
20#include <QList>
21#include <QMap>
22#include <QString>
23#include <QVBoxLayout>
24#include <QValidator>
25
26#include <optional>
27#include <set>
28
29namespace MantidQt {
30namespace MantidWidgets {
31//----------------------------------
32// Forward declarations
33//----------------------------------
34class IntervalList;
35
70public:
72 explicit Interval(int single);
74 Interval(int start, int end);
76 explicit Interval(const QString & /*intervalString*/);
78 Interval(const Interval & /*copy*/);
79
81 bool merge(const Interval & /*other*/);
84 bool canMerge(const Interval & /*other*/) const;
86 int start() const;
88 int end() const;
90 int length() const;
91
93 std::set<int> getIntSet() const;
94
98 bool contains(const Interval & /*other*/) const;
99
101 std::string toStdString() const;
103 QString toQString() const;
104
105private:
107 void init(int /*start*/, int /*end*/);
108
110 int m_start, m_end;
111};
112
114public:
118 explicit IntervalList(const QString & /*intervals*/);
120 explicit IntervalList(const Interval & /*interval*/);
121
123 const QList<Interval> &getList() const;
125 int totalIntervalLength() const;
126
129 std::string toStdString(int numOfIntervals = 6) const;
133 QString toQString(int numOfIntervals = 6) const;
134
136 void addInterval(int single);
138 void addInterval(Interval /*interval*/);
140 void addInterval(int start, int end);
142 void addIntervals(QString /*intervals*/);
144 void addIntervalList(const IntervalList & /*intervals*/);
148 void setIntervalList(const IntervalList & /*intervals*/);
150 void clear();
151
153 std::set<int> getIntSet() const;
154
158 bool contains(const Interval & /*other*/) const;
162 bool contains(const IntervalList & /*other*/) const;
163
166 static bool isParsable(const QString & /*input*/);
171 static bool isParsable(const QString & /*input*/, const IntervalList & /*container*/);
172
175 static IntervalList intersect(const IntervalList & /*aList*/, const Interval & /*bInterval*/);
178 static IntervalList intersect(const IntervalList & /*a*/, const IntervalList & /*b*/);
179
180private:
183};
184
186 Q_OBJECT
187
188public:
191 IntervalListValidator(QObject *parent, IntervalList intervals);
192
194 State validate(QString & /*unused*/, int & /*unused*/) const override;
195
196private:
199};
200
202 Q_OBJECT
203
207 class QLineEditWithErrorMark : public QWidget {
208 public:
212 explicit QLineEditWithErrorMark(QWidget *parent = nullptr);
216 QLineEdit *lineEdit() { return _lineEdit; };
219 void setError(const QString &error);
220
221 private:
222 QLineEdit *_lineEdit;
223 QLabel *m_validLbl;
224 };
225
226public:
240
241 struct UserInput {
243 bool simple;
245 bool tiled;
246 bool errors;
250 std::optional<UserInputAdvanced> advanced;
251 };
252
254 static const QString WORKSPACE_NAME;
255 static const QString WORKSPACE_INDEX;
257 static const QString CUSTOM;
259 static const QString SIMPLE_PLOT;
260 static const QString WATERFALL_PLOT;
261 static const QString SURFACE_PLOT;
262 static const QString CONTOUR_PLOT;
263
267 MantidWSIndexWidget(QWidget *parent, const Qt::WindowFlags &flags, const QList<QString> &wsNames,
268 const bool showWaterfallOption = false, const bool showTiledOption = false,
269 const bool isAdvanced = false);
270
272 UserInput getSelections();
276 QMultiMap<QString, std::set<int>> getPlots() const;
278 bool is1DPlotSelected() const;
280 bool isWaterfallPlotSelected() const;
282 bool plotRequested();
284 bool plotAllRequested();
286 bool validatePlotOptions();
288 bool isTiledPlotSelected() const;
290 bool isSurfacePlotSelected() const;
292 bool isContourPlotSelected() const;
294 bool isErrorBarsSelected() const;
295
296private slots:
298 void editedWsField();
300 void editedSpectraField();
302 void onLogSelected(const QString &logName);
304 void onPlotOptionChanged(const QString &logName);
305
306private:
308 void init();
310 void initWorkspaceBox();
312 void initSpectraBox();
314 void initOptionsBoxes();
316 void initLogs();
318 void populateLogComboBox();
320 Mantid::API::MatrixWorkspace_const_sptr getWorkspace(const QString &workspaceName) const;
322 bool isSuitableForContourOrSurfacePlot() const;
324 bool isSuitableForLogValues(const QString &plotOption) const;
326 const QString getAxisName() const;
328 const QString getLogName() const;
330 const std::set<double> getCustomLogValues() const;
332 void showPlotOptionsError(const QString &message);
334 int getPlotIndex() const;
335
337 void checkForSpectraAxes();
338
341 void generateWsIndexIntervals();
344 void generateSpectraNumIntervals();
345
347 bool usingSpectraNumbers() const;
348
351
354
357
360
362 QLabel *m_wsMessage, *m_spectraMessage, *m_orMessage, *m_plotOptionLabel, *m_logLabel, *m_customLogLabel,
364 QLineEditWithErrorMark *m_wsField, *m_spectraField, *m_logValues;
366 QVBoxLayout *m_outer, *m_wsBox, *m_spectraBox, *m_logBox, *m_optionsBox;
367 QComboBox *m_plotOptions, *m_logSelector;
368 QCheckBox *m_showErrorBars;
370
379 bool m_usingWsIndexChoice = false, m_usingSprectraNumChoice = false;
380};
381
383 Q_OBJECT
384
385public:
387 MantidWSIndexDialog(QWidget *parent, const Qt::WindowFlags &flags, const QList<QString> &wsNames,
388 const bool showWaterfallOption = false, const bool showPlotAll = true,
389 const bool showTiledOption = false, const bool isAdvanced = false);
391 MantidWSIndexWidget::UserInput getSelections();
395 QMultiMap<QString, std::set<int>> getPlots() const;
397 bool is1DPlotSelected() const;
399 bool isWaterfallPlotSelected() const;
401 bool isTiledPlotSelected() const;
403 bool isSurfacePlotSelected() const;
405 bool isContourPlotSelected() const;
407 bool isErrorBarsSelected() const;
408private slots:
410 void plot();
412 void plotAll();
413
414private:
417 void init(bool isAdvanced);
419 void initButtons();
423 QPushButton *m_okButton, *m_cancelButton, *m_plotAllButton;
424 QHBoxLayout *m_buttonBox;
425 QVBoxLayout *m_outer;
426};
427} // namespace MantidWidgets
428} // namespace MantidQt
#define EXPORT_OPT_MANTIDQT_COMMON
Definition DllOption.h:15
double error
IntervalList m_intervalList
The IntervalList against which to validate.
IntervalList(void)
Constructor - with empty list.
QList< Interval > m_list
A list of all the Intervals in this IntervalList.
bool m_plotAll
Do we allow the display of the "Plot all" button.
Auxiliary class to wrap the QLineEdit allowing warning to the user for invalid inputs.
~QLineEditWithErrorMark() override
virtual destructor to allow Qt to deallocate all objects
QList< QString > m_wsNames
A list of names of workspaces which are to be plotted.
bool m_waterfall
Do we allow the display of the waterfall option.
static const QString CUSTOM
The string "Custom".
static const QString SIMPLE_PLOT
Strings for plot types.
bool m_spectra
Do we allow the user to ask for a range of spectra IDs or not?
bool m_tiled
Do we allow the display of the tiled option.
static const QString WORKSPACE_NAME
The string "Workspace index".
The AlgorithmProgressDialogPresenter keeps track of the running algorithms and displays a progress ba...
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
Plain old data structures to hold all user-selected input.