-
Notifications
You must be signed in to change notification settings - Fork 122
/
InstrumentWindowPickTab.h
146 lines (133 loc) · 5.58 KB
/
InstrumentWindowPickTab.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#ifndef INSTRUMENTWINDOWPICKTAB_H_
#define INSTRUMENTWINDOWPICKTAB_H_
#include "InstrumentWindowTab.h"
#include "MantidGLWidget.h"
#include "MantidGeometry/ICompAssembly.h"
#include "MantidAPI/MatrixWorkspace.h"
class Instrument3DWidget;
class InstrumentActor;
class CollapsiblePanel;
class OneCurvePlot;
class QPushButton;
class QTextEdit;
class QComboBox;
class QCheckBox;
class QLabel;
class QActionGroup;
class QSignalMapper;
class QMenu;
/**
* Implements the Pick tab in InstrumentWindow.
* Contains a set of tools which allow one to:
*
* - pick a detector or a tube and display the data in it and some info
* - add a peak to a peaks workspace and display an overlay of markers
* - select and remove peaks
*
*/
class InstrumentWindowPickTab: public InstrumentWindowTab
{
Q_OBJECT
public:
/// Activity type the tab can be in:
/// Single: select and display info for a single detector when pointed by the mouse
/// Tube: select and display info for a tube of detectors. The immediate parent
/// of a detector is considered a tube
/// AddPeak: Click on a detector and then on the miniplot to add a peak marker and
/// a peak to the attached peaks workspace
/// SelectPeak: click on a peak marker or draw a rubber-band selector to select peak
/// markers. Selected peaks can be deleted by pressing the Delete key.
enum SelectionType {Single=0,AddPeak,ErasePeak,SingleDetectorSelection,Tube, Draw};
enum ToolType {Zoom,PixelSelect,TubeSelect,PeakSelect,PeakErase, DrawEllipse, DrawRectangle, EditShape};
enum TubeXUnits {DETECTOR_ID = 0,LENGTH,PHI,OUT_OF_PLANE_ANGLE,NUMBER_OF_UNITS};
InstrumentWindowPickTab(InstrumentWindow* instrWindow);
void updatePick(int detid);
bool canUpdateTouchedDetector()const;
TubeXUnits getTubeXUnits() const {return m_tubeXUnits;}
void mouseLeftInstrmentDisplay();
void initSurface();
void saveSettings(QSettings& settings) const;
void loadSettings(const QSettings& settings);
bool addToDisplayContextMenu(QMenu&) const;
void selectTool(const ToolType tool);
public slots:
void setTubeXUnits(int units);
void changedIntegrationRange(double,double);
private slots:
void plotContextMenu();
void sumDetectors();
void integrateTimeBins();
void setPlotCaption();
void setSelectionType();
void addPeak(double,double);
void storeCurve();
void removeCurve(const QString &);
void savePlotToWorkspace();
void singleDetectorTouched(int detid);
void singleDetectorPicked(int detid);
void updateSelectionInfoDisplay();
void shapeCreated();
void updatePlotMultipleDetectors();
private:
void showEvent (QShowEvent *);
void updatePlot(int detid);
void updateSelectionInfo(int detid);
void plotSingle(int detid);
void plotTube(int detid);
void plotTubeSums(int detid);
void plotTubeIntegrals(int detid);
void prepareDataForSinglePlot(
int detid,
std::vector<double>&x,
std::vector<double>&y,
std::vector<double>* err = NULL);
void prepareDataForSumsPlot(
int detid,
std::vector<double>&x,
std::vector<double>&y,
std::vector<double>* err = NULL);
void prepareDataForIntegralsPlot(
int detid,
std::vector<double>&x,
std::vector<double>&y,
std::vector<double>* err = NULL);
QString getTubeXUnitsName(TubeXUnits unit) const;
QString getNonDetectorInfo();
QColor getShapeBorderColor() const;
static double getOutOfPlaneAngle(const Mantid::Kernel::V3D& pos, const Mantid::Kernel::V3D& origin, const Mantid::Kernel::V3D& normal);
/* Pick tab controls */
OneCurvePlot* m_plot; ///< Miniplot to display data in the detectors
QLabel *m_activeTool; ///< Displays a tip on which tool is currently selected
QPushButton *m_zoom; ///< Button switching on navigation mode
QPushButton *m_one; ///< Button switching on single detector selection mode
QPushButton *m_tube; ///< Button switching on detector's parent selection mode
QPushButton *m_peak; ///< Button switching on peak creation mode
QPushButton *m_peakSelect; ///< Button switching on peak selection mode
QPushButton *m_rectangle; ///< Button switching on drawing a rectangular selection region
QPushButton *m_ellipse; ///< Button switching on drawing a elliptical selection region
QPushButton *m_ring_ellipse; ///< Button switching on drawing a elliptical ring selection region
QPushButton *m_ring_rectangle; ///< Button switching on drawing a rectangular ring selection region
QPushButton *m_edit; ///< Button switching on edditing the selection region
bool m_plotSum;
// Actions to set integration option for the detector's parent selection mode
QAction *m_sumDetectors; ///< Sets summation over detectors (m_plotSum = true)
QAction *m_integrateTimeBins; ///< Sets integration over time bins (m_plotSum = false)
QActionGroup *m_summationType;
QAction *m_logY;
QAction *m_linearY;
QActionGroup *m_yScale;
QActionGroup* m_unitsGroup;
QAction *m_detidUnits,*m_lengthUnits,*m_phiUnits,*m_outOfPlaneAngleUnits;
QSignalMapper *m_unitsMapper;
// Instrument display context menu actions
QAction *m_storeCurve; ///< add the current curve to the list of permanently displayed curves
QAction *m_savePlotToWorkspace; ///< Save data plotted on the miniplot into a MatrixWorkspace
CollapsiblePanel* m_plotPanel;
QTextEdit* m_selectionInfoDisplay; ///< Text control for displaying selection information
CollapsiblePanel* m_infoPanel;
SelectionType m_selectionType;
int m_currentDetID;
TubeXUnits m_tubeXUnits; ///< quantity the time bin integrals to be plotted against
mutable bool m_freezePlot;
};
#endif /*INSTRUMENTWINDOWPICKTAB_H_*/