/
ReflMainViewPresenter.h
100 lines (89 loc) · 3.9 KB
/
ReflMainViewPresenter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#ifndef MANTID_CUSTOMINTERFACES_REFLMAINVIEWPRESENTER_H
#define MANTID_CUSTOMINTERFACES_REFLMAINVIEWPRESENTER_H
#include "MantidKernel/System.h"
#include "MantidAPI/ITableWorkspace.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidQtCustomInterfaces/ReflMainView.h"
#include "MantidQtCustomInterfaces/IReflPresenter.h"
namespace MantidQt
{
namespace CustomInterfaces
{
/** @class ReflMainViewPresenter
ReflMainViewPresenter is a presenter class for teh Reflectometry Interface. It handles any interface functionality and model manipulation.
Copyright © 2011-14 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport ReflMainViewPresenter: public IReflPresenter
{
public:
ReflMainViewPresenter(Mantid::API::ITableWorkspace_sptr model, ReflMainView* view);
ReflMainViewPresenter(ReflMainView* view);
virtual ~ReflMainViewPresenter() = 0;
virtual void notify(int flag);
//Public for the purposes of unit testing
static std::map<std::string,std::string> parseKeyValueString(const std::string& str);
protected:
//The model and backup copy of the original model
Mantid::API::ITableWorkspace_sptr m_model;
Mantid::API::ITableWorkspace_sptr m_cache;
std::string m_cache_name;
//the view
ReflMainView* m_view;
//Load the model into the view
virtual void load();
//process selected rows
virtual void process();
//load a run into the ADS, or re-use one in the ADS if possible
Mantid::API::Workspace_sptr loadRun(const std::string& run, const std::string& instrument);
//get the run number of a TOF workspace
std::string getRunNumber(const Mantid::API::Workspace_sptr& ws);
//get an unused group id
int getUnusedGroup(std::vector<size_t> ignoredRows = std::vector<size_t>()) const;
//make a transmission workspace
Mantid::API::MatrixWorkspace_sptr makeTransWS(const std::string& transString);
//Validate a row
void validateRow(size_t rowNo) const;
//Autofill a row with sensible values
void autofillRow(size_t rowNo);
//calculates qmin and qmax
static std::vector<double> calcQRange(Mantid::API::MatrixWorkspace_sptr ws, double theta);
//Process a row
void processRow(size_t rowNo);
//Stitch some rows
void stitchRows(std::vector<size_t> rows);
//add row(s) to the model
virtual void addRow();
//delete row(s) from the model
virtual void deleteRow();
//group selected rows together
virtual void groupRows();
//virtual save methods
virtual void save() = 0;
virtual void saveAs() = 0;
public:
static const int COL_RUNS = 0;
static const int COL_ANGLE = 1;
static const int COL_TRANSMISSION = 2;
static const int COL_QMIN = 3;
static const int COL_QMAX = 4;
static const int COL_DQQ = 5;
static const int COL_SCALE = 6;
static const int COL_GROUP = 7;
static const int COL_OPTIONS = 8;
};
}
}
#endif