qse  0.5.4
qsenormalizerui.cpp
Go to the documentation of this file.
1 #include "qsenormalizerui.h"
2 #include "qsenormalizer.h"
3 #include "qsenormalizermodel.h"
4 #include "qsegraphcontroller.h"
5 #include "qsedatasetmodel.h"
6 #include "qsegraphscansmodel.h"
7 
8 #include <QMenu>
9 
11 (QseNormalizer* normalizer, QWidget* parent)
12  : QseEXAFSOperatorUI(normalizer, parent),
13  m_Normalizer(normalizer),
14 // m_NormalizerTable(NULL),
15  m_NormalizerModel(NULL),
16  m_ScanPatternEditor(this, &m_Normalizer->m_ScanPattern, NULL),
17  m_EnergyPatternEditor(this, &m_Normalizer->m_EnergyPattern, NULL),
18  m_DetectorPatternEditor(this, &m_Normalizer->m_DetectorPattern, NULL),
19  m_NormalizationPatternEditor(this, &m_Normalizer->m_NormalizationPattern, NULL),
20  m_SecondsPatternEditor(this, &m_Normalizer->m_SecondsPattern, NULL),
21  m_CopyPatternEditor(this, &m_Normalizer->m_CopyPattern, NULL),
22  m_CopyNormalizedPatternEditor(this, &m_Normalizer->m_CopyNormalizedPattern, NULL),
23  m_CopyRatePatternEditor(this, &m_Normalizer->m_CopyRatePattern, NULL),
24  m_CopyTotalCountsPatternEditor(this, &m_Normalizer->m_CopyTotalCountsPattern, NULL),
25  m_MinScanRowCountEditor(this, &m_Normalizer->m_MinScanRowCount, NULL),
26  m_MaxScanRowCountEditor(this, &m_Normalizer->m_MaxScanRowCount, NULL),
27  m_MinScanColumnCountEditor(this, &m_Normalizer->m_MinScanColumnCount, NULL),
28  m_MaxScanColumnCountEditor(this, &m_Normalizer->m_MaxScanColumnCount, NULL),
29  m_InputEnergyUnitsEditor(this, &m_Normalizer->m_InputEnergyUnits, NULL),
30  m_OutputEnergyUnitsEditor(this, &m_Normalizer->m_OutputEnergyUnits, NULL)
31 {
32  setupUi(this);
33 
34  m_ScanPatternEditor.setEditors
35  (scanPatternEdit,scanRegexp,patternApply,patternCancel);
36 
37  m_EnergyPatternEditor.setEditors
38  (energyPatternEdit,energyRegexp,patternApply,patternCancel,
39  m_EnergyColumnsButton, m_Normalizer->colorForRole(QseNormalizer::EnergyRole), m_Normalizer->backgroundColorForRole(QseNormalizer::EnergyRole));
40 
41  m_DetectorPatternEditor.setEditors
42  (detectorPatternEdit,detectorRegexp,patternApply,patternCancel,
43  m_DetectorColumnsButton, m_Normalizer->colorForRole(QseNormalizer::DetectorRole), m_Normalizer->backgroundColorForRole(QseNormalizer::DetectorRole));
44 
45  m_NormalizationPatternEditor.setEditors
46  (normalizationPatternEdit,normalizationRegexp,patternApply,patternCancel,
47  m_NormalizationColumnsButton, m_Normalizer->colorForRole(QseNormalizer::NormalizationRole), m_Normalizer->backgroundColorForRole(QseNormalizer::NormalizationRole));
48 
49  m_SecondsPatternEditor.setEditors
50  (secondsPatternEdit,secondsRegexp,patternApply,patternCancel,
51  m_SecondsColumnsButton, m_Normalizer->colorForRole(QseNormalizer::SecondsRole), m_Normalizer->backgroundColorForRole(QseNormalizer::SecondsRole));
52 
53  m_CopyPatternEditor.setEditors
54  (copyPatternEdit,copyRegexp,patternApply,patternCancel,
55  m_CopyColumnsButton, m_Normalizer->colorForRole(QseNormalizer::CopyRole), m_Normalizer->backgroundColorForRole(QseNormalizer::CopyRole));
56 
57  m_CopyNormalizedPatternEditor.setEditors
58  (copyNormalizedPatternEdit,copyNormalizedRegexp,patternApply,patternCancel,
59  m_CopyNormalizedColumnsButton, m_Normalizer->colorForRole(QseNormalizer::CopyNormalizedRole), m_Normalizer->backgroundColorForRole(QseNormalizer::CopyNormalizedRole));
60 
61  m_CopyRatePatternEditor.setEditors
62  (copyRatePatternEdit,copyRateRegexp,patternApply,patternCancel,
63  m_CopyRateColumnsButton, m_Normalizer->colorForRole(QseNormalizer::CopyRateRole), m_Normalizer->backgroundColorForRole(QseNormalizer::CopyRateRole));
64 
65  m_CopyTotalCountsPatternEditor.setEditors
66  (copyTotalCountsPatternEdit,copyTotalCountsRegexp,patternApply,patternCancel,
67  m_CopyTotalCountsColumnsButton, m_Normalizer->colorForRole(QseNormalizer::CopyTotalCountsRole), m_Normalizer->backgroundColorForRole(QseNormalizer::CopyTotalCountsRole));
68 
69  m_MinScanRowCountEditor.setEditors
70  (minScanRowCount,patternApply,patternCancel);
71 
72  m_MaxScanRowCountEditor.setEditors
73  (maxScanRowCount,patternApply,patternCancel);
74 
75  m_MinScanColumnCountEditor.setEditors
76  (minScanColumnCount,patternApply,patternCancel);
77 
78  m_MaxScanColumnCountEditor.setEditors
79  (maxScanColumnCount,patternApply,patternCancel);
80 
81  m_InputEnergyUnitsEditor.setEditors
82  (inputUnits,patternApply,patternCancel);
83 
84  m_OutputEnergyUnitsEditor.setEditors
85  (outputUnits,patternApply,patternCancel);
86 
87  connect(patternApply, SIGNAL(clicked()), this, SLOT(dialogApply()));
88  connect(patternCancel, SIGNAL(clicked()), this, SLOT(dialogCancel()));
89  connect(normalizeButton, SIGNAL(clicked()), this, SLOT(normalize()));
90 
91  m_NormalizerModel = new QseNormalizerModel(m_Normalizer, m_NormalizerTable, this);
92  m_NormalizerTable -> setModel(m_NormalizerModel);
93 
94  m_NormalizerTable -> setContextMenuPolicy(Qt::CustomContextMenu);
95  connect(m_NormalizerTable, SIGNAL(customContextMenuRequested(const QPoint&)),
96  this, SLOT(normalizerTableContextMenu(const QPoint&)));
97 
98  connect(m_UseScansButton, SIGNAL(clicked()),
99  this,SLOT(setScansUsed()));
100  connect(m_ExcludeScansButton, SIGNAL(clicked()),
101  this,SLOT(setScansUnused()));
102  connect(m_DefaultScansButton, SIGNAL(clicked()),
103  this,SLOT(setScansDefault()));
104 
105  connect(m_EnergyColumnsButton, SIGNAL(clicked()),
106  this,SLOT(setEnergyColumns()));
107  connect(m_DetectorColumnsButton, SIGNAL(clicked()),
108  this,SLOT(setDetectorColumns()));
109  connect(m_NormalizationColumnsButton, SIGNAL(clicked()),
110  this,SLOT(setNormalizationColumns()));
111  connect(m_SecondsColumnsButton, SIGNAL(clicked()),
112  this,SLOT(setSecondsColumns()));
113  connect(m_CopyColumnsButton, SIGNAL(clicked()),
114  this,SLOT(setCopyColumns()));
115  connect(m_CopyNormalizedColumnsButton, SIGNAL(clicked()),
116  this,SLOT(setCopyNormalizedColumns()));
117  connect(m_CopyRateColumnsButton, SIGNAL(clicked()),
118  this,SLOT(setCopyRateColumns()));
119  connect(m_CopyTotalCountsColumnsButton, SIGNAL(clicked()),
120  this,SLOT(setCopyTotalCountsColumns()));
121  connect(m_ExcludeColumnsButton, SIGNAL(clicked()),
122  this,SLOT(setExcludeColumns()));
123  connect(m_DefaultColumnsButton, SIGNAL(clicked()),
124  this,SLOT(setDefaultsColumns()));
125 }
126 
128 {
130 }
131 
133 {
135 }
136 
138 {
140 }
141 
143 {
145 }
146 
148 {
150 }
151 
153 {
155 }
156 
158 {
160 }
161 
163 {
165 }
166 
168 {
170 }
171 
173 {
175 }
176 
178 {
180 }
181 
183 {
185 }
186 
188 {
190 }
191 
193 {
194  QMenu menu(NULL, NULL);
195 
196  QAction* excludeScan = menu.addAction(QString("Exclude Scans"));
197  QAction* includeScan = menu.addAction(QString("Include Scans"));
198  QAction* defaultScan = menu.addAction(QString("Return Scans to default usage"));
199 
200  QAction* separator = menu.addSeparator();
201 
202  QAction* energyColumn = menu.addAction(QString("Use columns as Energy"));
203  QAction* detectorColumn = menu.addAction(QString("Use columns as Detector"));
204  QAction* normalizeColumn =
205  menu.addAction(QString("Use columns for normalization"));
206  QAction* secondsColumn =
207  menu.addAction(QString("Use columns for counting time"));
208  QAction* copyColumn =
209  menu.addAction(QString("Copy columns to output"));
210  QAction* copyNormalizedColumn =
211  menu.addAction(QString("Copy columns to output normalized by 'normalization'"));
212  QAction* copyRateColumn =
213  menu.addAction(QString("Copy columns to output divided by 'seconds'"));
214  QAction* copyTotalCountsColumn =
215  menu.addAction(QString("Copy columns to output multiplied by 'seconds'"));
216  QAction* excludeColumn =
217  menu.addAction(QString("Do not use columns"));
218  QAction* defaultColumn =
219  menu.addAction(QString("Return columns to default usage"));
220 
221  menu.setMouseTracking(true);
222 
223  QAction* id = menu.exec(QCursor::pos() + QPoint( -40, -10), separator);
224 
225  if (id == excludeScan) {
226  setScansUnused();
227  } else if (id == includeScan) {
228  setScansUsed();
229  } else if (id == defaultScan) {
230  setScansDefault();
231  } else if (id == energyColumn) {
233  } else if (id == detectorColumn) {
235  } else if (id == normalizeColumn) {
237  } else if (id == secondsColumn) {
239  } else if (id == copyColumn) {
240  setCopyColumns();
241  } else if (id == copyNormalizedColumn) {
243  } else if (id == copyRateColumn) {
245  } else if (id == copyTotalCountsColumn) {
247  } else if (id == excludeColumn) {
249  } else if (id == defaultColumn) {
251  }
252 }
253 
255 {
256  QItemSelectionModel *s = m_NormalizerTable -> selectionModel();
257 
259 
260  m_NormalizerModel -> operationCompleted();
261 }
262 
264 {
265  QItemSelectionModel *s = m_NormalizerTable -> selectionModel();
266 
268 
269  m_NormalizerModel -> operationCompleted();
270 }
271 
273 {
274  if (editorValidate()) {
275  editorApply();
276 
277  patternApply -> setEnabled(false);
278  patternCancel-> setEnabled(false);
279  normalizeButton-> setEnabled(true);
280 
281  m_NormalizerModel -> operationCompleted();
282  }
283 }
284 
286 {
287  editorCancel();
288 
289  patternApply -> setEnabled(false);
290  patternCancel-> setEnabled(false);
291  normalizeButton-> setEnabled(true);
292 
293  m_NormalizerModel -> operationCompleted();
294 }
295 
297 {
298  dialogApply();
299 
300  m_Normalizer -> exec();
301 }
void setNormalizationColumns()
void normalizerTableContextMenu(const QPoint &pos)
void setScanExceptions(QseNormalizer::QseScanRole r)
void setColumnExceptions(QseNormalizer::QseColumnRole r)
void setCopyTotalCountsColumns()
void setCopyNormalizedColumns()
QseNormalizerModel * m_NormalizerModel
QseNormalizer * m_Normalizer
QseNormalizerUI(QseNormalizer *normalizer, QWidget *parent=0)