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 <set>
27
28namespace MantidQt {
29namespace MantidWidgets {
30//----------------------------------
31// Forward declarations
32//----------------------------------
33class IntervalList;
34
69public:
71 explicit Interval(int single);
73 Interval(int start, int end);
75 explicit Interval(const QString & /*intervalString*/);
77 Interval(const Interval & /*copy*/);
78
80 bool merge(const Interval & /*other*/);
83 bool canMerge(const Interval & /*other*/) const;
85 int start() const;
87 int end() const;
89 int length() const;
90
92 std::set<int> getIntSet() const;
93
97 bool contains(const Interval & /*other*/) const;
98
100 std::string toStdString() const;
102 QString toQString() const;
103
104private:
106 void init(int /*start*/, int /*end*/);
107
109 int m_start, m_end;
110};
111
113public:
117 explicit IntervalList(const QString & /*intervals*/);
119 explicit IntervalList(const Interval & /*interval*/);
120
122 const QList<Interval> &getList() const;
124 int totalIntervalLength() const;
125
128 std::string toStdString(int numOfIntervals = 6) const;
132 QString toQString(int numOfIntervals = 6) const;
133
135 void addInterval(int single);
137 void addInterval(Interval /*interval*/);
139 void addInterval(int start, int end);
141 void addIntervals(QString /*intervals*/);
143 void addIntervalList(const IntervalList & /*intervals*/);
147 void setIntervalList(const IntervalList & /*intervals*/);
149 void clear();
150
152 std::set<int> getIntSet() const;
153
157 bool contains(const Interval & /*other*/) const;
161 bool contains(const IntervalList & /*other*/) const;
162
165 static bool isParsable(const QString & /*input*/);
170 static bool isParsable(const QString & /*input*/, const IntervalList & /*container*/);
171
174 static IntervalList intersect(const IntervalList & /*aList*/, const Interval & /*bInterval*/);
177 static IntervalList intersect(const IntervalList & /*a*/, const IntervalList & /*b*/);
178
179private:
182};
183
185 Q_OBJECT
186
187public:
190 IntervalListValidator(QObject *parent, IntervalList intervals);
191
193 State validate(QString & /*unused*/, int & /*unused*/) const override;
194
195private:
198};
199
201 Q_OBJECT
202
206 class QLineEditWithErrorMark : public QWidget {
207 public:
211 explicit QLineEditWithErrorMark(QWidget *parent = nullptr);
215 QLineEdit *lineEdit() { return _lineEdit; };
218 void setError(const QString &error);
219
220 private:
221 QLineEdit *_lineEdit;
222 QLabel *m_validLbl;
223 };
224
225public:
234 QString axisName;
235 QString logName;
236 std::set<double> customLogValues;
238 };
239
240 struct UserInput {
242 bool simple;
244 bool tiled;
245 bool errors;
250 };
251
253 static const QString WORKSPACE_NAME;
254 static const QString WORKSPACE_INDEX;
256 static const QString CUSTOM;
258 static const QString SIMPLE_PLOT;
259 static const QString WATERFALL_PLOT;
260 static const QString SURFACE_PLOT;
261 static const QString CONTOUR_PLOT;
262
266 MantidWSIndexWidget(QWidget *parent, const Qt::WindowFlags &flags, const QList<QString> &wsNames,
267 const bool showWaterfallOption = false, const bool showTiledOption = false,
268 const bool isAdvanced = false);
269
271 UserInput getSelections();
275 QMultiMap<QString, std::set<int>> getPlots() const;
277 bool is1DPlotSelected() const;
279 bool isWaterfallPlotSelected() const;
281 bool plotRequested();
283 bool plotAllRequested();
285 bool validatePlotOptions();
287 bool isTiledPlotSelected() const;
289 bool isSurfacePlotSelected() const;
291 bool isContourPlotSelected() const;
293 bool isErrorBarsSelected() const;
294
295private slots:
297 void editedWsField();
299 void editedSpectraField();
301 void onLogSelected(const QString &logName);
303 void onPlotOptionChanged(const QString &logName);
304
305private:
307 void init();
309 void initWorkspaceBox();
311 void initSpectraBox();
313 void initOptionsBoxes();
315 void initLogs();
317 void populateLogComboBox();
319 Mantid::API::MatrixWorkspace_const_sptr getWorkspace(const QString &workspaceName) const;
321 bool isSuitableForContourOrSurfacePlot() const;
323 bool isSuitableForLogValues(const QString &plotOption) const;
325 const QString getAxisName() const;
327 const QString getLogName() const;
329 const std::set<double> getCustomLogValues() const;
331 void showPlotOptionsError(const QString &message);
333 int getPlotIndex() const;
334
336 void checkForSpectraAxes();
337
340 void generateWsIndexIntervals();
343 void generateSpectraNumIntervals();
344
346 bool usingSpectraNumbers() const;
347
350
353
356
359
361 QLabel *m_wsMessage, *m_spectraMessage, *m_orMessage, *m_plotOptionLabel, *m_logLabel, *m_customLogLabel,
363 QLineEditWithErrorMark *m_wsField, *m_spectraField, *m_logValues;
365 QVBoxLayout *m_outer, *m_wsBox, *m_spectraBox, *m_logBox, *m_optionsBox;
366 QComboBox *m_plotOptions, *m_logSelector;
367 QCheckBox *m_showErrorBars;
369
378 bool m_usingWsIndexChoice = false, m_usingSprectraNumChoice = false;
379};
380
382 Q_OBJECT
383
384public:
386 MantidWSIndexDialog(QWidget *parent, const Qt::WindowFlags &flags, const QList<QString> &wsNames,
387 const bool showWaterfallOption = false, const bool showPlotAll = true,
388 const bool showTiledOption = false, const bool isAdvanced = false);
390 MantidWSIndexWidget::UserInput getSelections();
394 QMultiMap<QString, std::set<int>> getPlots() const;
396 bool is1DPlotSelected() const;
398 bool isWaterfallPlotSelected() const;
400 bool isTiledPlotSelected() const;
402 bool isSurfacePlotSelected() const;
404 bool isContourPlotSelected() const;
406 bool isErrorBarsSelected() const;
407private slots:
409 void plot();
411 void plotAll();
412
413private:
416 void init(bool isAdvanced);
418 void initButtons();
422 QPushButton *m_okButton, *m_cancelButton, *m_plotAllButton;
423 QHBoxLayout *m_buttonBox;
424 QVBoxLayout *m_outer;
425};
426} // namespace MantidWidgets
427} // namespace MantidQt
#define EXPORT_OPT_MANTIDQT_COMMON
Definition: DllOption.h:15
double error
Definition: IndexPeaks.cpp:133
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.