1 | >>>>>>>>>>>>> MatrixWSDataSource.h <<<<<<<<<<<<< |
---|
2 | 1,2c1,2 |
---|
3 | < #ifndef REF_MATRIX_WS_DATA_SOURCE_H |
---|
4 | < #define REF_MATRIX_WS_DATA_SOURCE_H |
---|
5 | --- |
---|
6 | > #ifndef MATRIX_WS_DATA_SOURCE_H |
---|
7 | > #define MATRIX_WS_DATA_SOURCE_H |
---|
8 | 6,8c6,9 |
---|
9 | < #include "MantidQtRefDetectorViewer/DataArray.h" |
---|
10 | < #include "MantidQtRefDetectorViewer/RefImageDataSource.h" |
---|
11 | < #include "MantidQtRefDetectorViewer/DllOptionIV.h" |
---|
12 | --- |
---|
13 | > #include "MantidQtImageViewer/DataArray.h" |
---|
14 | > #include "MantidQtImageViewer/ImageDataSource.h" |
---|
15 | > #include "MantidQtImageViewer/EModeHandler.h" |
---|
16 | > #include "MantidQtImageViewer/DllOptionIV.h" |
---|
17 | 13c14 |
---|
18 | < @class RefMatrixWSDataSource |
---|
19 | --- |
---|
20 | > @class MatrixWSDataSource |
---|
21 | 44c45 |
---|
22 | < namespace RefDetectorViewer |
---|
23 | --- |
---|
24 | > namespace ImageView |
---|
25 | 47c48 |
---|
26 | < class EXPORT_OPT_MANTIDQT_IMAGEVIEWER RefMatrixWSDataSource: public RefImageDataSource |
---|
27 | --- |
---|
28 | > class EXPORT_OPT_MANTIDQT_IMAGEVIEWER MatrixWSDataSource: public ImageDataSource |
---|
29 | 52c53 |
---|
30 | < RefMatrixWSDataSource( Mantid::API::MatrixWorkspace_sptr mat_ws ); |
---|
31 | --- |
---|
32 | > MatrixWSDataSource( Mantid::API::MatrixWorkspace_const_sptr mat_ws ); |
---|
33 | 54c55 |
---|
34 | < ~RefMatrixWSDataSource(); |
---|
35 | --- |
---|
36 | > ~MatrixWSDataSource(); |
---|
37 | 70c71 |
---|
38 | < |
---|
39 | --- |
---|
40 | > |
---|
41 | 79a81,83 |
---|
42 | > /// Set the class that gets the emode & efixed info from the user. |
---|
43 | > void SetEModeHandler( EModeHandler* emode_handler ); |
---|
44 | > |
---|
45 | 83a88,89 |
---|
46 | > |
---|
47 | > |
---|
48 | 85,86c91,92 |
---|
49 | < Mantid::API::MatrixWorkspace_sptr mat_ws; |
---|
50 | < |
---|
51 | --- |
---|
52 | > Mantid::API::MatrixWorkspace_const_sptr mat_ws; |
---|
53 | > EModeHandler* saved_emode_handler; |
---|
54 | 92c98 |
---|
55 | < #endif // REF_MATRIX_WS_DATA_SOURCE_H |
---|
56 | --- |
---|
57 | > #endif // MATRIX_WS_DATA_SOURCE_H |
---|
58 | >>>>>>>>>>>>> MatrixWSDataSource.cpp <<<<<<<<<<<<< |
---|
59 | /** /** |
---|
60 | * File: RefMatrixWSDataSource.cpp | * File: MatrixWSDataSource.cpp |
---|
61 | */ */ |
---|
62 | |
---|
63 | #include <iostream> #include <iostream> |
---|
64 | > #include <sstream> |
---|
65 | #include <math.h> #include <math.h> |
---|
66 | |
---|
67 | #include <QThread> #include <QThread> |
---|
68 | |
---|
69 | #include "MantidQtRefDetectorViewer/RefMatrixWSDataSource.h" | #include "MantidQtImageViewer/MatrixWSDataSource.h" |
---|
70 | #include "MantidQtRefDetectorViewer/IVUtils.h" | #include "MantidQtImageViewer/IVUtils.h" |
---|
71 | #include "MantidAPI/ISpectrum.h" #include "MantidAPI/ISpectrum.h" |
---|
72 | #include "MantidGeometry/Instrument/Detector.h" #include "MantidGeometry/Instrument/Detector.h" |
---|
73 | #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument.h" |
---|
74 | #include "MantidKernel/UnitFactory.h" #include "MantidKernel/UnitFactory.h" |
---|
75 | #include "MantidAPI/Run.h" #include "MantidAPI/Run.h" |
---|
76 | #include "MantidQtRefDetectorViewer/ErrorHandler.h" | #include "MantidQtImageViewer/ErrorHandler.h" |
---|
77 | #include "MantidQtRefDetectorViewer/ArrayDataSource.h" < |
---|
78 | #include "MantidQtRefDetectorViewer/IVUtils.h" < |
---|
79 | |
---|
80 | using namespace Mantid; using namespace Mantid; |
---|
81 | using namespace Kernel; using namespace Kernel; |
---|
82 | using namespace API; using namespace API; |
---|
83 | using namespace Geometry; using namespace Geometry; |
---|
84 | |
---|
85 | namespace MantidQt namespace MantidQt |
---|
86 | { { |
---|
87 | namespace RefDetectorViewer | namespace ImageView |
---|
88 | { { |
---|
89 | |
---|
90 | /** /** |
---|
91 | * Construct a DataSource object around the specifed MatrixWo * Construct a DataSource object around the specifed MatrixWo |
---|
92 | * * |
---|
93 | * @param mat_ws Shared pointer to the matrix workspace bein * @param mat_ws Shared pointer to the matrix workspace bein |
---|
94 | */ */ |
---|
95 | RefMatrixWSDataSource::RefMatrixWSDataSource( MatrixWorkspace | MatrixWSDataSource::MatrixWSDataSource( MatrixWorkspace_const |
---|
96 | :RefImageDataSource( 0.0, 1.0, 0.0, 1.0, 0, | :ImageDataSource( 0.0, 1.0, 0.0, 1.0, 0, 0 ) |
---|
97 | { { |
---|
98 | this->mat_ws = mat_ws; this->mat_ws = mat_ws; |
---|
99 | |
---|
100 | total_xmin = mat_ws->getXMin(); total_xmin = mat_ws->getXMin(); |
---|
101 | total_xmax = mat_ws->getXMax(); total_xmax = mat_ws->getXMax(); |
---|
102 | |
---|
103 | total_ymin = 0; // y direction is spectrum total_ymin = 0; // y direction is spectrum |
---|
104 | total_ymax = (double)mat_ws->getNumberHistograms(); total_ymax = (double)mat_ws->getNumberHistograms(); |
---|
105 | |
---|
106 | total_rows = mat_ws->getNumberHistograms(); total_rows = mat_ws->getNumberHistograms(); |
---|
107 | |
---|
108 | total_cols = 1000000; // Default data resoluti total_cols = 1000000; // Default data resoluti |
---|
109 | > |
---|
110 | > saved_emode_handler = 0; |
---|
111 | } } |
---|
112 | | |
---|
113 | RefMatrixWSDataSource::~RefMatrixWSDataSource() | |
---|
114 | > MatrixWSDataSource::~MatrixWSDataSource() |
---|
115 | { { |
---|
116 | } } |
---|
117 | |
---|
118 | |
---|
119 | /** /** |
---|
120 | * Get the smallest 'x' value covered by the data. Must over * Get the smallest 'x' value covered by the data. Must over |
---|
121 | * method, since the DataSource can be changed! * method, since the DataSource can be changed! |
---|
122 | */ */ |
---|
123 | double RefMatrixWSDataSource::GetXMin() | double MatrixWSDataSource::GetXMin() |
---|
124 | { { |
---|
125 | total_xmin = mat_ws->getXMin(); total_xmin = mat_ws->getXMin(); |
---|
126 | return total_xmin; return total_xmin; |
---|
127 | } } |
---|
128 | |
---|
129 | |
---|
130 | /** /** |
---|
131 | * Get the largest 'x' value covered by the data. Must overr * Get the largest 'x' value covered by the data. Must overr |
---|
132 | * method, since the DataSource can be changed! * method, since the DataSource can be changed! |
---|
133 | */ */ |
---|
134 | double RefMatrixWSDataSource::GetXMax() | double MatrixWSDataSource::GetXMax() |
---|
135 | { { |
---|
136 | total_xmax = mat_ws->getXMax(); total_xmax = mat_ws->getXMax(); |
---|
137 | return total_xmax; return total_xmax; |
---|
138 | } } |
---|
139 | |
---|
140 | |
---|
141 | /** /** |
---|
142 | * Get the largest 'y' value covered by the data. Must overr * Get the largest 'y' value covered by the data. Must overr |
---|
143 | * method, since the DataSource can be changed! * method, since the DataSource can be changed! |
---|
144 | */ */ |
---|
145 | double RefMatrixWSDataSource::GetYMax() | double MatrixWSDataSource::GetYMax() |
---|
146 | { { |
---|
147 | total_ymax = (double)mat_ws->getNumberHistograms(); total_ymax = (double)mat_ws->getNumberHistograms(); |
---|
148 | return total_ymax; return total_ymax; |
---|
149 | } } |
---|
150 | |
---|
151 | |
---|
152 | /** /** |
---|
153 | * Get the total number of rows the data is divided into. Mu * Get the total number of rows the data is divided into. Mu |
---|
154 | * class method, since the DataSource can be changed! * class method, since the DataSource can be changed! |
---|
155 | */ */ |
---|
156 | size_t RefMatrixWSDataSource::GetNRows() | size_t MatrixWSDataSource::GetNRows() |
---|
157 | { { |
---|
158 | total_ymax = (double)mat_ws->getNumberHistograms(); total_ymax = (double)mat_ws->getNumberHistograms(); |
---|
159 | return total_rows; return total_rows; |
---|
160 | } } |
---|
161 | |
---|
162 | |
---|
163 | /** /** |
---|
164 | * Get a data array covering the specified range of data, at * Get a data array covering the specified range of data, at |
---|
165 | * resolution. NOTE: The calling code is responsible for del * resolution. NOTE: The calling code is responsible for del |
---|
166 | * DataArray that is constructed in and returned by this meth * DataArray that is constructed in and returned by this meth |
---|
167 | * * |
---|
168 | * @param xmin Left edge of region to be covered. * @param xmin Left edge of region to be covered. |
---|
169 | * @param xmax Right edge of region to be covered. * @param xmax Right edge of region to be covered. |
---|
170 | * @param ymin Bottom edge of region to be covered. * @param ymin Bottom edge of region to be covered. |
---|
171 | * @param ymax Top edge of region to be covered. * @param ymax Top edge of region to be covered. |
---|
172 | * @param n_rows Number of rows to return. If the number o * @param n_rows Number of rows to return. If the number o |
---|
173 | * than the actual number of data rows in [y * than the actual number of data rows in [y |
---|
174 | * data will be subsampled, and only the spe * data will be subsampled, and only the spe |
---|
175 | * of rows will be returned. * of rows will be returned. |
---|
176 | * @param n_cols The specrum data will be rebinned using t * @param n_cols The specrum data will be rebinned using t |
---|
177 | * number of colums. * number of colums. |
---|
178 | * @param is_log_x Flag indicating whether or not the data s * @param is_log_x Flag indicating whether or not the data s |
---|
179 | * binned logarithmically. (NOT USED YET) | * binned logarithmically. |
---|
180 | */ */ |
---|
181 | DataArray* RefMatrixWSDataSource::GetDataArray( double xmin, | DataArray* MatrixWSDataSource::GetDataArray( double xmin, d |
---|
182 | double ymin, d double ymin, d |
---|
183 | size_t n_rows, s size_t n_rows, s |
---|
184 | bool is_log_x bool is_log_x |
---|
185 | { { |
---|
186 | /* /* |
---|
187 | std::cout << "Start MatrixWSDataSource::GetDataArray " << s std::cout << "Start MatrixWSDataSource::GetDataArray " << s |
---|
188 | std::cout << " xmin = " << xmin std::cout << " xmin = " << xmin |
---|
189 | << " xmax = " << xmax << " xmax = " << xmax |
---|
190 | << " ymin = " << ymin << " ymin = " << ymin |
---|
191 | << " ymax = " << ymax << " ymax = " << ymax |
---|
192 | << " n_rows = " << n_rows << " n_rows = " << n_rows |
---|
193 | << " n_cols = " << n_cols << std::endl; << " n_cols = " << n_cols << std::endl; |
---|
194 | */ */ |
---|
195 | // since we // since we |
---|
196 | // columns // columns |
---|
197 | // but rows // but rows |
---|
198 | // to get w // to get w |
---|
199 | size_t first_row; size_t first_row; |
---|
200 | IVUtils::CalculateInterval( total_ymin, total_ymax, total_r IVUtils::CalculateInterval( total_ymin, total_ymax, total_r |
---|
201 | first_row, ymin, ymax, n_rows ) first_row, ymin, ymax, n_rows ) |
---|
202 | |
---|
203 | float* new_data = new float[n_rows * n_cols]; // this arr float* new_data = new float[n_rows * n_cols]; // this arr |
---|
204 | // the Data // the Data |
---|
205 | MantidVec x_scale; MantidVec x_scale; |
---|
206 | x_scale.resize(n_cols+1); x_scale.resize(n_cols+1); |
---|
207 | if ( is_log_x ) if ( is_log_x ) |
---|
208 | { { |
---|
209 | for ( size_t i = 0; i < n_cols+1; i++ ) for ( size_t i = 0; i < n_cols+1; i++ ) |
---|
210 | { { |
---|
211 | x_scale[i] = xmin * exp ( (double)i / (double)n_cols * x_scale[i] = xmin * exp ( (double)i / (double)n_cols * |
---|
212 | } } |
---|
213 | } } |
---|
214 | else else |
---|
215 | { { |
---|
216 | double dx = (xmax - xmin)/((double)n_cols + 1.0); double dx = (xmax - xmin)/((double)n_cols + 1.0); |
---|
217 | for ( size_t i = 0; i < n_cols+1; i++ ) for ( size_t i = 0; i < n_cols+1; i++ ) |
---|
218 | { { |
---|
219 | x_scale[i] = xmin + (double)i * dx; x_scale[i] = xmin + (double)i * dx; |
---|
220 | } } |
---|
221 | } // choose } // choose |
---|
222 | // require // require |
---|
223 | // spectru // spectru |
---|
224 | double y_step = (ymax - ymin) / (double)n_rows; double y_step = (ymax - ymin) / (double)n_rows; |
---|
225 | double mid_y; double mid_y; |
---|
226 | double d_y_index; double d_y_index; |
---|
227 | size_t source_row; size_t source_row; |
---|
228 | |
---|
229 | MantidVec y_vals; MantidVec y_vals; |
---|
230 | MantidVec err; MantidVec err; |
---|
231 | y_vals.resize(n_cols); y_vals.resize(n_cols); |
---|
232 | err.resize(n_cols); err.resize(n_cols); |
---|
233 | size_t index = 0; size_t index = 0; |
---|
234 | for ( size_t i = 0; i < n_rows; i++ ) for ( size_t i = 0; i < n_rows; i++ ) |
---|
235 | { { |
---|
236 | mid_y = ymin + ((double)i + 0.5) * y_step; mid_y = ymin + ((double)i + 0.5) * y_step; |
---|
237 | IVUtils::Interpolate( total_ymin, total_ymax, mid_y, IVUtils::Interpolate( total_ymin, total_ymax, mid_y, |
---|
238 | 0.0, (double)total_rows, d_y 0.0, (double)total_rows, d_y |
---|
239 | source_row = (size_t)d_y_index; source_row = (size_t)d_y_index; |
---|
240 | y_vals.clear(); y_vals.clear(); |
---|
241 | err.clear(); err.clear(); |
---|
242 | y_vals.resize(n_cols,0); y_vals.resize(n_cols,0); |
---|
243 | err.resize(n_cols,0); err.resize(n_cols,0); |
---|
244 | |
---|
245 | mat_ws->generateHistogram( source_row, x_scale, y_vals, e mat_ws->generateHistogram( source_row, x_scale, y_vals, e |
---|
246 | for ( size_t col = 0; col < n_cols; col++ ) for ( size_t col = 0; col < n_cols; col++ ) |
---|
247 | { { |
---|
248 | new_data[index] = (float)y_vals[col]; new_data[index] = (float)y_vals[col]; |
---|
249 | index++; index++; |
---|
250 | } } |
---|
251 | } } |
---|
252 | // The calling code is respon // The calling code is respon |
---|
253 | // the DataArray when it is d // the DataArray when it is d |
---|
254 | DataArray* new_data_array = new DataArray( xmin, xmax, ymin DataArray* new_data_array = new DataArray( xmin, xmax, ymin |
---|
255 | is_log_x, is_log_x, |
---|
256 | n_rows, n_cols, n_rows, n_cols, |
---|
257 | return new_data_array; return new_data_array; |
---|
258 | } } |
---|
259 | |
---|
260 | |
---|
261 | /** /** |
---|
262 | * Get a data array covering the full range of data. * Get a data array covering the full range of data. |
---|
263 | * * |
---|
264 | * @param is_log_x Flag indicating whether or not the data s * @param is_log_x Flag indicating whether or not the data s |
---|
265 | * binned logarithmically. (NOT USED YET) | * binned logarithmically. |
---|
266 | */ */ |
---|
267 | DataArray * RefMatrixWSDataSource::GetDataArray( bool is_log_ | DataArray * MatrixWSDataSource::GetDataArray( bool is_log_x ) |
---|
268 | { { |
---|
269 | return GetDataArray( total_xmin, total_xmax, total_ymin, to return GetDataArray( total_xmin, total_xmax, total_ymin, to |
---|
270 | total_rows, total_cols, is_log_x ); total_rows, total_cols, is_log_x ); |
---|
271 | } } |
---|
272 | |
---|
273 | > |
---|
274 | > /** |
---|
275 | > * Set the class that gets the emode & efixed info from the u |
---|
276 | > * |
---|
277 | > * @param emode_handler Pointer to the user interface handle |
---|
278 | > * can provide user values for emode an |
---|
279 | > */ |
---|
280 | > void MatrixWSDataSource::SetEModeHandler( EModeHandler* emode |
---|
281 | > { |
---|
282 | > saved_emode_handler = emode_handler; |
---|
283 | > } |
---|
284 | > |
---|
285 | > |
---|
286 | /** /** |
---|
287 | * Clear the vector of strings and then add pairs of strings * Clear the vector of strings and then add pairs of strings |
---|
288 | * about the specified point, x, y. The first string in a pa * about the specified point, x, y. The first string in a pa |
---|
289 | * generally be a string describing the value being presented * generally be a string describing the value being presented |
---|
290 | * string should contain the value. * string should contain the value. |
---|
291 | * * |
---|
292 | * @param x The x-coordinate of the point of interest in t * @param x The x-coordinate of the point of interest in t |
---|
293 | * @param y The y-coordinate of the point of interest in t * @param y The y-coordinate of the point of interest in t |
---|
294 | * @param list Vector that will be filled out with the inform * @param list Vector that will be filled out with the inform |
---|
295 | */ */ |
---|
296 | void RefMatrixWSDataSource::GetInfoList( double x, | void MatrixWSDataSource::GetInfoList( double x, |
---|
297 | double y, double y, |
---|
298 | std::vector<std::string std::vector<std::string |
---|
299 | { { |
---|
300 | list.clear(); list.clear(); |
---|
301 | // first get the info // first get the info |
---|
302 | // available for any // available for any |
---|
303 | int row = (int)y; int row = (int)y; |
---|
304 | RestrictRow( row ); RestrictRow( row ); |
---|
305 | |
---|
306 | ISpectrum* spec = mat_ws->getSpectrum( row ); | const ISpectrum* spec = mat_ws->getSpectrum( row ); |
---|
307 | |
---|
308 | double spec_num = spec->getSpectrumNo(); double spec_num = spec->getSpectrumNo(); |
---|
309 | IVUtils::PushNameValue( "Spec Num", 8, 0, spec_num, list ); IVUtils::PushNameValue( "Spec Num", 8, 0, spec_num, list ); |
---|
310 | |
---|
311 | std::string x_label = ""; std::string x_label = ""; |
---|
312 | Unit_sptr& old_unit = mat_ws->getAxis(0)->unit(); Unit_sptr& old_unit = mat_ws->getAxis(0)->unit(); |
---|
313 | if ( old_unit != 0 ) if ( old_unit != 0 ) |
---|
314 | { { |
---|
315 | x_label = old_unit->caption(); x_label = old_unit->caption(); |
---|
316 | IVUtils::PushNameValue( x_label, 8, 3, x, list ); IVUtils::PushNameValue( x_label, 8, 3, x, list ); |
---|
317 | } } |
---|
318 | |
---|
319 | > double d_id = 0; |
---|
320 | std::set<detid_t> ids = spec->getDetectorIDs(); std::set<detid_t> ids = spec->getDetectorIDs(); |
---|
321 | if ( !ids.empty() ) if ( !ids.empty() ) |
---|
322 | { { |
---|
323 | std::set<detid_t>::iterator it = ids.begin(); std::set<detid_t>::iterator it = ids.begin(); |
---|
324 | double d_id = (double)*it; | d_id = (double)*it; |
---|
325 | IVUtils::PushNameValue( "Det ID", 8, 0, d_id, list ); IVUtils::PushNameValue( "Det ID", 8, 0, d_id, list ); |
---|
326 | } } |
---|
327 | |
---|
328 | // now try to do various | IDetector_const_sptr det; // now try to do various |
---|
329 | try // to get equivalent inf try // to get equivalent inf |
---|
330 | { // first make sure we ca { // first make sure we ca |
---|
331 | // information // information |
---|
332 | if ( old_unit == 0 ) if ( old_unit == 0 ) |
---|
333 | { { |
---|
334 | > ErrorHandler::Error("No UNITS on MatrixWorkspace X-axis |
---|
335 | return; return; |
---|
336 | } } |
---|
337 | |
---|
338 | Instrument_const_sptr instrument = mat_ws->getInstrument( Instrument_const_sptr instrument = mat_ws->getInstrument( |
---|
339 | if ( instrument == 0 ) if ( instrument == 0 ) |
---|
340 | { { |
---|
341 | > ErrorHandler::Error("No INSTRUMENT on MatrixWorkspace") |
---|
342 | return; return; |
---|
343 | } } |
---|
344 | |
---|
345 | IObjComponent_const_sptr source = instrument->getSource() IObjComponent_const_sptr source = instrument->getSource() |
---|
346 | if ( source == 0 ) if ( source == 0 ) |
---|
347 | { { |
---|
348 | > ErrorHandler::Error("No SOURCE on instrument in MatrixW |
---|
349 | return; return; |
---|
350 | } } |
---|
351 | |
---|
352 | IObjComponent_const_sptr sample = instrument->getSample() IObjComponent_const_sptr sample = instrument->getSample() |
---|
353 | if ( sample == 0 ) if ( sample == 0 ) |
---|
354 | { { |
---|
355 | > ErrorHandler::Error("No SAMPLE on instrument in MatrixW |
---|
356 | return; return; |
---|
357 | } } |
---|
358 | |
---|
359 | IDetector_const_sptr det = mat_ws->getDetector( row ); | det = mat_ws->getDetector( row ); |
---|
360 | if ( det == 0 ) if ( det == 0 ) |
---|
361 | { { |
---|
362 | > std::ostringstream message; |
---|
363 | > message << "No DETECTOR for row " << row << " in Matrix |
---|
364 | > ErrorHandler::Error( message.str() ); |
---|
365 | return; return; |
---|
366 | } } |
---|
367 | |
---|
368 | double l1 = source->getDistance(*sample); double l1 = source->getDistance(*sample); |
---|
369 | double l2 = 0; double l2 = 0; |
---|
370 | double two_theta = 0; double two_theta = 0; |
---|
371 | if ( det->isMonitor() ) if ( det->isMonitor() ) |
---|
372 | { { |
---|
373 | l2 = det->getDistance(*source); l2 = det->getDistance(*source); |
---|
374 | l2 = l2-l1; l2 = l2-l1; |
---|
375 | } } |
---|
376 | else else |
---|
377 | { { |
---|
378 | l2 = det->getDistance(*sample); l2 = det->getDistance(*sample); |
---|
379 | two_theta = mat_ws->detectorTwoTheta(det); two_theta = mat_ws->detectorTwoTheta(det); |
---|
380 | } } |
---|
381 | // For now, only support diffractomet // For now, only support diffractomet |
---|
382 | // We need a portable way to determin // We need a portable way to determin |
---|
383 | // and efixed that will work for any // and efixed that will work for any |
---|
384 | int emode = 0; int emode = 0; |
---|
385 | double efixed = 0; double efixed = 0; |
---|
386 | double delta = 0; double delta = 0; |
---|
387 | |
---|
388 | const API::Run & run = mat_ws->run(); // cases I checked | // std::cout << "Start of checks for emode" << std::endl; |
---|
389 | if ( run.hasProperty("Ei") ) | |
---|
390 | > // First try to get emode & efixed fr |
---|
391 | > if ( saved_emode_handler != 0 ) |
---|
392 | { { |
---|
393 | Kernel::Property* prop = run.getProperty("Ei"); | efixed = saved_emode_handler->GetEFixed(); |
---|
394 | efixed = boost::lexical_cast<double,std::string>(prop-> | if ( efixed != 0 ) |
---|
395 | emode = 1; // only correct for | { |
---|
396 | } // instruments | emode = saved_emode_handler->GetEMode(); |
---|
397 | | if ( emode == 0 ) |
---|
398 | > { |
---|
399 | > ErrorHandler::Error("EMode invalid, spectrometer ne |
---|
400 | > ErrorHandler::Error("Assuming Direct Geometry Spect |
---|
401 | > emode = 1; |
---|
402 | > } |
---|
403 | > } |
---|
404 | > } |
---|
405 | > |
---|
406 | > // std::cout << "Done with calls to GetEFixed and GetEMode" |
---|
407 | > // std::cout << "EMode = " << emode << std::endl; |
---|
408 | > // std::cout << "EFixed = " << efixed << std::endl; |
---|
409 | > |
---|
410 | > if ( efixed == 0 ) // Did NOT get emode & efixed from |
---|
411 | > { // direct geometry information from |
---|
412 | > const API::Run & run = mat_ws->run(); |
---|
413 | > if ( run.hasProperty("Ei") ) |
---|
414 | > { |
---|
415 | > Kernel::Property* prop = run.getProperty("Ei"); |
---|
416 | > efixed = boost::lexical_cast<double,std::string>(prop |
---|
417 | > emode = 1; // only correct i |
---|
418 | > } |
---|
419 | > else if ( run.hasProperty("EnergyRequested") ) |
---|
420 | > { |
---|
421 | > Kernel::Property* prop = run.getProperty("EnergyReque |
---|
422 | > efixed = boost::lexical_cast<double,std::string>(prop |
---|
423 | > emode = 1; |
---|
424 | > } |
---|
425 | > else if ( run.hasProperty("EnergyEstimate") ) |
---|
426 | > { |
---|
427 | > Kernel::Property* prop = run.getProperty("EnergyEstim |
---|
428 | > efixed = boost::lexical_cast<double,std::string>(prop |
---|
429 | > emode = 1; |
---|
430 | > } |
---|
431 | > } |
---|
432 | > |
---|
433 | > // std::cout << "Done with getting info from run" << std::en |
---|
434 | > // std::cout << "EMode = " << emode << std::endl; |
---|
435 | > // std::cout << "EFixed = " << efixed << std::endl; |
---|
436 | > |
---|
437 | > if ( efixed == 0 ) // finally, try getting indirect ge |
---|
438 | > { // from the detector object |
---|
439 | > if ( !(det->isMonitor() && det->hasParameter("Efixed")) |
---|
440 | > { |
---|
441 | > try |
---|
442 | > { |
---|
443 | > const ParameterMap& pmap = mat_ws->constInstrumentP |
---|
444 | > Parameter_sptr par = pmap.getRecursive(det.get(),"E |
---|
445 | > if (par) |
---|
446 | > { |
---|
447 | > efixed = par->value<double>(); |
---|
448 | > emode = 2; |
---|
449 | > } |
---|
450 | > } |
---|
451 | > catch ( std::runtime_error& ) |
---|
452 | > { |
---|
453 | > std::ostringstream message; |
---|
454 | > message << "Failed to get Efixed from detector ID: |
---|
455 | > << det->getID() << " in MatrixWSDataSource" |
---|
456 | > ErrorHandler::Error( message.str() ); |
---|
457 | > efixed = 0; |
---|
458 | > } |
---|
459 | > } |
---|
460 | > } |
---|
461 | > |
---|
462 | > // std::cout << "Done with getting info from detector" << st |
---|
463 | > // std::cout << "EMode = " << emode << std::endl; |
---|
464 | > // std::cout << "EFixed = " << efixed << std::endl; |
---|
465 | > |
---|
466 | > if ( efixed == 0 ) |
---|
467 | > { |
---|
468 | > emode = 0; |
---|
469 | > } |
---|
470 | > |
---|
471 | > if ( saved_emode_handler != 0 ) |
---|
472 | > { |
---|
473 | > saved_emode_handler -> SetEFixed( efixed ); |
---|
474 | > saved_emode_handler -> SetEMode ( emode ); |
---|
475 | > } |
---|
476 | > |
---|
477 | double tof = old_unit->convertSingleToTOF( x, l1, l2, two double tof = old_unit->convertSingleToTOF( x, l1, l2, two |
---|
478 | emode, efixed, emode, efixed, |
---|
479 | if ( ! (x_label == "Time-of-flight") ) if ( ! (x_label == "Time-of-flight") ) |
---|
480 | { { |
---|
481 | IVUtils::PushNameValue( "Time-of-flight", 8, 1, tof, li IVUtils::PushNameValue( "Time-of-flight", 8, 1, tof, li |
---|
482 | } } |
---|
483 | |
---|
484 | if ( ! (x_label == "Wavelength") ) if ( ! (x_label == "Wavelength") ) |
---|
485 | { { |
---|
486 | const Unit_sptr& wl_unit = UnitFactory::Instance().crea const Unit_sptr& wl_unit = UnitFactory::Instance().crea |
---|
487 | double wavelength = wl_unit->convertSingleFromTOF( tof, double wavelength = wl_unit->convertSingleFromTOF( tof, |
---|
488 | emod emod |
---|
489 | IVUtils::PushNameValue( "Wavelength", 8, 4, wavelength, IVUtils::PushNameValue( "Wavelength", 8, 4, wavelength, |
---|
490 | } } |
---|
491 | |
---|
492 | if ( ! (x_label == "Energy") ) if ( ! (x_label == "Energy") ) |
---|
493 | { { |
---|
494 | const Unit_sptr& e_unit = UnitFactory::Instance().creat const Unit_sptr& e_unit = UnitFactory::Instance().creat |
---|
495 | double energy = e_unit->convertSingleFromTOF( tof, l1, double energy = e_unit->convertSingleFromTOF( tof, l1, |
---|
496 | emode, ef emode, ef |
---|
497 | IVUtils::PushNameValue( "Energy", 8, 4, energy, list ); IVUtils::PushNameValue( "Energy", 8, 4, energy, list ); |
---|
498 | } } |
---|
499 | |
---|
500 | if ( (! (x_label == "d-Spacing")) && (two_theta != 0.0) & if ( (! (x_label == "d-Spacing")) && (two_theta != 0.0) & |
---|
501 | { { |
---|
502 | const Unit_sptr& d_unit = UnitFactory::Instance().creat const Unit_sptr& d_unit = UnitFactory::Instance().creat |
---|
503 | double d_spacing = d_unit->convertSingleFromTOF( tof, l double d_spacing = d_unit->convertSingleFromTOF( tof, l |
---|
504 | emode, emode, |
---|
505 | IVUtils::PushNameValue( "d-Spacing", 8, 4, d_spacing, l IVUtils::PushNameValue( "d-Spacing", 8, 4, d_spacing, l |
---|
506 | } } |
---|
507 | |
---|
508 | if ( (! (x_label == "q")) && (two_theta != 0.0) ) if ( (! (x_label == "q")) && (two_theta != 0.0) ) |
---|
509 | { { |
---|
510 | const Unit_sptr& q_unit=UnitFactory::Instance().create( const Unit_sptr& q_unit=UnitFactory::Instance().create( |
---|
511 | double mag_q = q_unit->convertSingleFromTOF( tof, l1, l double mag_q = q_unit->convertSingleFromTOF( tof, l1, l |
---|
512 | emode, efi emode, efi |
---|
513 | IVUtils::PushNameValue( "|Q|", 8, 4, mag_q, list ); IVUtils::PushNameValue( "|Q|", 8, 4, mag_q, list ); |
---|
514 | } } |
---|
515 | |
---|
516 | if ( (! (x_label == "DeltaE")) && (two_theta != 0.0) && ( if ( (! (x_label == "DeltaE")) && (two_theta != 0.0) && ( |
---|
517 | { { |
---|
518 | const Unit_sptr& deltaE_unit=UnitFactory::Instance().cr const Unit_sptr& deltaE_unit=UnitFactory::Instance().cr |
---|
519 | double delta_E = deltaE_unit->convertSingleFromTOF( tof double delta_E = deltaE_unit->convertSingleFromTOF( tof |
---|
520 | emo emo |
---|
521 | IVUtils::PushNameValue( "DeltaE", 8, 4, delta_E, list ) IVUtils::PushNameValue( "DeltaE", 8, 4, delta_E, list ) |
---|
522 | } } |
---|
523 | } } |
---|
524 | catch (std::exception & e) catch (std::exception & e) |
---|
525 | { { |
---|
526 | ErrorHandler::Notice("Failed to get information from Work ErrorHandler::Notice("Failed to get information from Work |
---|
527 | ErrorHandler::Notice( e.what() ); ErrorHandler::Notice( e.what() ); |
---|
528 | } } |
---|
529 | } } |
---|
530 | |
---|
531 | |
---|
532 | } // namespace MantidQt } // namespace MantidQt |
---|
533 | } // namespace ImageView } // namespace ImageView |
---|
534 | >>>>>>>>>>>>> GraphDisplay.h <<<<<<<<<<<<< |
---|
535 | 8,9c8,9 |
---|
536 | < #include "MantidQtRefDetectorViewer/RefImageDataSource.h" |
---|
537 | < #include "MantidQtRefDetectorViewer/DllOptionIV.h" |
---|
538 | --- |
---|
539 | > #include "MantidQtImageViewer/ImageDataSource.h" |
---|
540 | > #include "MantidQtImageViewer/DllOptionIV.h" |
---|
541 | 43c43 |
---|
542 | < namespace RefDetectorViewer |
---|
543 | --- |
---|
544 | > namespace ImageView |
---|
545 | 52c52 |
---|
546 | < // QTableWidget* graph_table, |
---|
547 | --- |
---|
548 | > QTableWidget* graph_table, |
---|
549 | 58c58 |
---|
550 | < void SetDataSource( RefImageDataSource* data_source ); |
---|
551 | --- |
---|
552 | > void SetDataSource( ImageDataSource* data_source ); |
---|
553 | 83,84c83,84 |
---|
554 | < // QTableWidget* graph_table; |
---|
555 | < RefImageDataSource* data_source; |
---|
556 | --- |
---|
557 | > QTableWidget* graph_table; |
---|
558 | > ImageDataSource* data_source; |
---|
559 | 98c98 |
---|
560 | < } // namespace RefDetectorViewer |
---|
561 | --- |
---|
562 | > } // namespace ImageView |
---|
563 | >>>>>>>>>>>>> GraphDisplay.cpp <<<<<<<<<<<<< |
---|
564 | |
---|
565 | #include <iostream> #include <iostream> |
---|
566 | #include <QtGui> #include <QtGui> |
---|
567 | #include <QVector> #include <QVector> |
---|
568 | #include <QString> #include <QString> |
---|
569 | #include <qwt_scale_engine.h> #include <qwt_scale_engine.h> |
---|
570 | |
---|
571 | #include "MantidQtRefDetectorViewer/GraphDisplay.h" | #include "MantidQtImageViewer/GraphDisplay.h" |
---|
572 | #include "MantidQtRefDetectorViewer/QtUtils.h" | #include "MantidQtImageViewer/QtUtils.h" |
---|
573 | #include "MantidQtRefDetectorViewer/IVUtils.h" | #include "MantidQtImageViewer/IVUtils.h" |
---|
574 | |
---|
575 | namespace MantidQt namespace MantidQt |
---|
576 | { { |
---|
577 | namespace RefDetectorViewer | namespace ImageView |
---|
578 | { { |
---|
579 | |
---|
580 | /** /** |
---|
581 | * Construct a GraphDisplay to display selected graph on the * Construct a GraphDisplay to display selected graph on the |
---|
582 | * and to disply information in the specified table. * and to disply information in the specified table. |
---|
583 | * * |
---|
584 | * @param graph_plot The QwtPlot where the graph will be * @param graph_plot The QwtPlot where the graph will be |
---|
585 | * @param graph_table The QTableWidget where information a * @param graph_table The QTableWidget where information a |
---|
586 | * pointed at location will be displaye * pointed at location will be displaye |
---|
587 | * @param is_vertical Flag indicating whether this graph d * @param is_vertical Flag indicating whether this graph d |
---|
588 | * vertical or horizontal cut through t * vertical or horizontal cut through t |
---|
589 | */ */ |
---|
590 | GraphDisplay::GraphDisplay( QwtPlot* graph_plot, GraphDisplay::GraphDisplay( QwtPlot* graph_plot, |
---|
591 | // QTableWidget* graph_table, | QTableWidget* graph_table, |
---|
592 | bool is_vertical ) bool is_vertical ) |
---|
593 | { { |
---|
594 | this->graph_plot = graph_plot; this->graph_plot = graph_plot; |
---|
595 | // this->graph_table = graph_table; | this->graph_table = graph_table; |
---|
596 | this->data_source = 0; this->data_source = 0; |
---|
597 | this->is_vertical = is_vertical; this->is_vertical = is_vertical; |
---|
598 | |
---|
599 | is_log_x = false; is_log_x = false; |
---|
600 | image_x = 0; image_x = 0; |
---|
601 | image_y = 0; image_y = 0; |
---|
602 | range_scale = 1.0; range_scale = 1.0; |
---|
603 | |
---|
604 | if ( is_vertical ) if ( is_vertical ) |
---|
605 | { { |
---|
606 | graph_plot->setAxisMaxMajor( QwtPlot::xBottom, 3 ); graph_plot->setAxisMaxMajor( QwtPlot::xBottom, 3 ); |
---|
607 | } } |
---|
608 | |
---|
609 | curve = new QwtPlotCurve("Curve 1"); curve = new QwtPlotCurve("Curve 1"); |
---|
610 | } } |
---|
611 | |
---|
612 | |
---|
613 | GraphDisplay::~GraphDisplay() GraphDisplay::~GraphDisplay() |
---|
614 | { { |
---|
615 | // std::cout << "GraphDisplay destructor called" << std::en // std::cout << "GraphDisplay destructor called" << std::en |
---|
616 | delete curve; delete curve; |
---|
617 | } } |
---|
618 | |
---|
619 | |
---|
620 | /** /** |
---|
621 | * Set the data source from which the table information will * Set the data source from which the table information will |
---|
622 | * (must be set to allow information to be displayed in the t * (must be set to allow information to be displayed in the t |
---|
623 | * * |
---|
624 | * @param data_source The ImageDataSource that provides infor * @param data_source The ImageDataSource that provides infor |
---|
625 | * the table. * the table. |
---|
626 | */ */ |
---|
627 | void GraphDisplay::SetDataSource( RefImageDataSource* data_so | void GraphDisplay::SetDataSource( ImageDataSource* data_sourc |
---|
628 | { { |
---|
629 | this->data_source = data_source; this->data_source = data_source; |
---|
630 | } } |
---|
631 | |
---|
632 | |
---|
633 | /** /** |
---|
634 | * Set flag indicating whether or not to use a log scale on t * Set flag indicating whether or not to use a log scale on t |
---|
635 | * * |
---|
636 | * @param is_log_x Pass in true to use a log scale on the x- * @param is_log_x Pass in true to use a log scale on the x- |
---|
637 | * to use a linear scale. * to use a linear scale. |
---|
638 | */ */ |
---|
639 | void GraphDisplay::SetLogX( bool is_log_x ) void GraphDisplay::SetLogX( bool is_log_x ) |
---|
640 | { { |
---|
641 | this->is_log_x = is_log_x; this->is_log_x = is_log_x; |
---|
642 | } } |
---|
643 | |
---|
644 | |
---|
645 | /** /** |
---|
646 | * Set the actual data that will be displayed on the graph an * Set the actual data that will be displayed on the graph an |
---|
647 | * coordinates on the image corresponding to this data. The * coordinates on the image corresponding to this data. The |
---|
648 | * coordinates are needed to determine the point of interest, * coordinates are needed to determine the point of interest, |
---|
649 | * user points at a location on the graph. * user points at a location on the graph. |
---|
650 | * * |
---|
651 | * @param xData Vector of x coordinates of points to plot * @param xData Vector of x coordinates of points to plot |
---|
652 | * @param yData Vector of y coordinates of points to plot. * @param yData Vector of y coordinates of points to plot. |
---|
653 | * be the same size as the xData vector. * be the same size as the xData vector. |
---|
654 | * @param image_x X-coordinate of point on image that genera * @param image_x X-coordinate of point on image that genera |
---|
655 | * data * data |
---|
656 | * @param image_y Y-coordinate of point on image that genera * @param image_y Y-coordinate of point on image that genera |
---|
657 | * data * data |
---|
658 | */ */ |
---|
659 | void GraphDisplay::SetData(const QVector<double> & xData, void GraphDisplay::SetData(const QVector<double> & xData, |
---|
660 | const QVector<double> & yData, const QVector<double> & yData, |
---|
661 | double cut_value double cut_value |
---|
662 | { { |
---|
663 | if ( xData.size() == 0 || // ignore invalid data v if ( xData.size() == 0 || // ignore invalid data v |
---|
664 | yData.size() == 0 || yData.size() == 0 || |
---|
665 | xData.size() != yData.size() ) xData.size() != yData.size() ) |
---|
666 | { { |
---|
667 | return; return; |
---|
668 | } } |
---|
669 | |
---|
670 | |
---|
671 | curve->attach(0); // detach from any plot, curve->attach(0); // detach from any plot, |
---|
672 | // the data and attaching // the data and attaching |
---|
673 | if ( is_vertical ) if ( is_vertical ) |
---|
674 | { { |
---|
675 | this->image_x = cut_value; this->image_x = cut_value; |
---|
676 | min_y = yData[0]; min_y = yData[0]; |
---|
677 | max_y = yData[yData.size()-1]; max_y = yData[yData.size()-1]; |
---|
678 | IVUtils::FindValidInterval( xData, min_x, max_x ); IVUtils::FindValidInterval( xData, min_x, max_x ); |
---|
679 | } } |
---|
680 | else else |
---|
681 | { { |
---|
682 | this->image_y = cut_value; this->image_y = cut_value; |
---|
683 | min_x = xData[0]; min_x = xData[0]; |
---|
684 | max_x = xData[xData.size()-1]; max_x = xData[xData.size()-1]; |
---|
685 | IVUtils::FindValidInterval( yData, min_y, max_y ); IVUtils::FindValidInterval( yData, min_y, max_y ); |
---|
686 | |
---|
687 | if ( is_log_x ) // only set log scale for if ( is_log_x ) // only set log scale for |
---|
688 | { { |
---|
689 | QwtLog10ScaleEngine* log_engine = new QwtLog10ScaleEngi QwtLog10ScaleEngine* log_engine = new QwtLog10ScaleEngi |
---|
690 | graph_plot->setAxisScaleEngine( QwtPlot::xBottom, log_e graph_plot->setAxisScaleEngine( QwtPlot::xBottom, log_e |
---|
691 | } } |
---|
692 | else else |
---|
693 | { { |
---|
694 | QwtLinearScaleEngine* linear_engine = new QwtLinearScal QwtLinearScaleEngine* linear_engine = new QwtLinearScal |
---|
695 | graph_plot->setAxisScaleEngine( QwtPlot::xBottom, linea graph_plot->setAxisScaleEngine( QwtPlot::xBottom, linea |
---|
696 | } } |
---|
697 | } } |
---|
698 | |
---|
699 | curve->setData( xData, yData ); curve->setData( xData, yData ); |
---|
700 | curve->attach( graph_plot ); curve->attach( graph_plot ); |
---|
701 | |
---|
702 | SetRangeScale( range_scale ); SetRangeScale( range_scale ); |
---|
703 | |
---|
704 | graph_plot->setAutoReplot(true); graph_plot->setAutoReplot(true); |
---|
705 | } } |
---|
706 | |
---|
707 | |
---|
708 | void GraphDisplay::Clear() void GraphDisplay::Clear() |
---|
709 | { { |
---|
710 | curve->attach(0); // detach from plot curve->attach(0); // detach from plot |
---|
711 | graph_plot->replot(); graph_plot->replot(); |
---|
712 | } } |
---|
713 | |
---|
714 | |
---|
715 | /** /** |
---|
716 | * Set up axes using the specified scale factor and replot t * Set up axes using the specified scale factor and replot t |
---|
717 | * This is useful for seeing low-level values, by clipping o * This is useful for seeing low-level values, by clipping o |
---|
718 | * magnitude values. * magnitude values. |
---|
719 | * * |
---|
720 | * @param range_scale Value between 0 and 1 indicating what * @param range_scale Value between 0 and 1 indicating what |
---|
721 | * graph value range should be plotted. * graph value range should be plotted. |
---|
722 | */ */ |
---|
723 | void GraphDisplay::SetRangeScale( double range_scale ) void GraphDisplay::SetRangeScale( double range_scale ) |
---|
724 | { { |
---|
725 | this->range_scale = range_scale; this->range_scale = range_scale; |
---|
726 | if ( is_vertical ) if ( is_vertical ) |
---|
727 | { { |
---|
728 | double axis_max = range_scale * ( max_x - min_x ) + min_x double axis_max = range_scale * ( max_x - min_x ) + min_x |
---|
729 | graph_plot->setAxisScale( QwtPlot::xBottom, min_x, axis_m graph_plot->setAxisScale( QwtPlot::xBottom, min_x, axis_m |
---|
730 | graph_plot->setAxisScale( QwtPlot::yLeft, min_y, max_y ); graph_plot->setAxisScale( QwtPlot::yLeft, min_y, max_y ); |
---|
731 | } } |
---|
732 | else else |
---|
733 | { { |
---|
734 | double axis_max = range_scale * ( max_y - min_y ) + min_y double axis_max = range_scale * ( max_y - min_y ) + min_y |
---|
735 | graph_plot->setAxisScale( QwtPlot::yLeft, min_y, axis_max graph_plot->setAxisScale( QwtPlot::yLeft, min_y, axis_max |
---|
736 | graph_plot->setAxisScale( QwtPlot::xBottom, min_x, max_x graph_plot->setAxisScale( QwtPlot::xBottom, min_x, max_x |
---|
737 | } } |
---|
738 | graph_plot->replot(); graph_plot->replot(); |
---|
739 | } } |
---|
740 | |
---|
741 | |
---|
742 | /** /** |
---|
743 | * Show information about the specified point. * Show information about the specified point. |
---|
744 | * * |
---|
745 | * @param point The point that the user is currently pointin * @param point The point that the user is currently pointin |
---|
746 | * the mouse. * the mouse. |
---|
747 | */ */ |
---|
748 | void GraphDisplay::SetPointedAtPoint( QPoint point ) void GraphDisplay::SetPointedAtPoint( QPoint point ) |
---|
749 | { { |
---|
750 | if ( data_source == 0 ) if ( data_source == 0 ) |
---|
751 | { { |
---|
752 | return; return; |
---|
753 | } } |
---|
754 | double x = graph_plot->invTransform( QwtPlot::xBottom, poin double x = graph_plot->invTransform( QwtPlot::xBottom, poin |
---|
755 | double y = graph_plot->invTransform( QwtPlot::yLeft, point. double y = graph_plot->invTransform( QwtPlot::yLeft, point. |
---|
756 | |
---|
757 | if ( is_vertical ) // x can be anywhere on grap if ( is_vertical ) // x can be anywhere on grap |
---|
758 | { // a valid data source posit { // a valid data source posit |
---|
759 | data_source->RestrictY( y ); data_source->RestrictY( y ); |
---|
760 | } } |
---|
761 | else // y can be anywhere on grap else // y can be anywhere on grap |
---|
762 | { // a valid data source posit { // a valid data source posit |
---|
763 | data_source->RestrictX( x ); data_source->RestrictX( x ); |
---|
764 | } } |
---|
765 | |
---|
766 | ShowInfoList( x, y ); ShowInfoList( x, y ); |
---|
767 | } } |
---|
768 | |
---|
769 | |
---|
770 | /** /** |
---|
771 | * Get the information about a pointed at location and show * Get the information about a pointed at location and show |
---|
772 | * table. NOTE: If this is the "horizontal" graph, the rele * table. NOTE: If this is the "horizontal" graph, the rele |
---|
773 | * are x and the image_y that generated the graph. If this * are x and the image_y that generated the graph. If this |
---|
774 | * graph, the relevant coordinates are y and the image_x tha * graph, the relevant coordinates are y and the image_x tha |
---|
775 | * the graph. * the graph. |
---|
776 | * * |
---|
777 | * @param x The x coordinate of the pointed at location on * @param x The x coordinate of the pointed at location on |
---|
778 | * @param y The y coordinate of the pointed at location on * @param y The y coordinate of the pointed at location on |
---|
779 | */ */ |
---|
780 | void GraphDisplay::ShowInfoList( double x, double y ) void GraphDisplay::ShowInfoList( double x, double y ) |
---|
781 | { { |
---|
782 | int n_infos = 0; int n_infos = 0; |
---|
783 | int n_rows = 1; int n_rows = 1; |
---|
784 | std::vector<std::string> info_list; std::vector<std::string> info_list; |
---|
785 | if ( data_source != 0 ) if ( data_source != 0 ) |
---|
786 | { { |
---|
787 | if ( is_vertical ) if ( is_vertical ) |
---|
788 | { { |
---|
789 | data_source->GetInfoList( image_x, y, info_list ); data_source->GetInfoList( image_x, y, info_list ); |
---|
790 | } } |
---|
791 | else else |
---|
792 | { { |
---|
793 | data_source->GetInfoList( x, image_y, info_list ); data_source->GetInfoList( x, image_y, info_list ); |
---|
794 | } } |
---|
795 | } } |
---|
796 | else else |
---|
797 | { { |
---|
798 | return; return; |
---|
799 | } } |
---|
800 | n_infos = (int)info_list.size()/2; n_infos = (int)info_list.size()/2; |
---|
801 | n_rows += n_infos; n_rows += n_infos; |
---|
802 | |
---|
803 | // graph_table->setRowCount(n_rows); | graph_table->setRowCount(n_rows); |
---|
804 | // graph_table->setColumnCount(2); | graph_table->setColumnCount(2); |
---|
805 | // graph_table->verticalHeader()->hide(); | graph_table->verticalHeader()->hide(); |
---|
806 | // graph_table->horizontalHeader()->hide(); | graph_table->horizontalHeader()->hide(); |
---|
807 | < |
---|
808 | // int width = 9; < |
---|
809 | // int prec = 3; < |
---|
810 | < |
---|
811 | // if ( is_vertical ) < |
---|
812 | // { < |
---|
813 | // QtUtils::SetTableEntry( 0, 0, "Value", graph_table ); < |
---|
814 | // QtUtils::SetTableEntry( 0, 1, width, prec, x, graph_tab < |
---|
815 | // } < |
---|
816 | // else < |
---|
817 | // { < |
---|
818 | // QtUtils::SetTableEntry( 0, 0, "Value", graph_table ); < |
---|
819 | // QtUtils::SetTableEntry( 0, 1, width, prec, y, graph_tab < |
---|
820 | // } < |
---|
821 | // < |
---|
822 | // for ( int i = 0; i < n_infos; i++ ) < |
---|
823 | // { < |
---|
824 | // QtUtils::SetTableEntry( i+1, 0, info_list[2*i], graph_t < |
---|
825 | // QtUtils::SetTableEntry( i+1, 1, info_list[2*i+1], graph < |
---|
826 | // } < |
---|
827 | |
---|
828 | // graph_table->resizeColumnsToContents(); | int width = 9; |
---|
829 | > int prec = 3; |
---|
830 | > |
---|
831 | > if ( is_vertical ) |
---|
832 | > { |
---|
833 | > QtUtils::SetTableEntry( 0, 0, "Value", graph_table ); |
---|
834 | > QtUtils::SetTableEntry( 0, 1, width, prec, x, graph_table |
---|
835 | > } |
---|
836 | > else |
---|
837 | > { |
---|
838 | > QtUtils::SetTableEntry( 0, 0, "Value", graph_table ); |
---|
839 | > QtUtils::SetTableEntry( 0, 1, width, prec, y, graph_table |
---|
840 | > } |
---|
841 | > |
---|
842 | > for ( int i = 0; i < n_infos; i++ ) |
---|
843 | > { |
---|
844 | > QtUtils::SetTableEntry( i+1, 0, info_list[2*i], graph_tab |
---|
845 | > QtUtils::SetTableEntry( i+1, 1, info_list[2*i+1], graph_t |
---|
846 | > } |
---|
847 | > |
---|
848 | > graph_table->resizeColumnsToContents(); |
---|
849 | } } |
---|
850 | |
---|
851 | } // namespace MantidQt } // namespace MantidQt |
---|
852 | } // namespace ImageView } // namespace ImageView |
---|
853 | >>>>>>>>>>>>> ImagePlotItem.h <<<<<<<<<<<<< |
---|
854 | 1,2c1,2 |
---|
855 | < #ifndef REF_IMAGE_PLOT_ITEM_H |
---|
856 | < #define REF_IMAGE_PLOT_ITEM_H |
---|
857 | --- |
---|
858 | > #ifndef IMAGE_PLOT_ITEM_H |
---|
859 | > #define IMAGE_PLOT_ITEM_H |
---|
860 | 10,11c10,11 |
---|
861 | < #include "MantidQtRefDetectorViewer/DataArray.h" |
---|
862 | < #include "MantidQtRefDetectorViewer/DllOptionIV.h" |
---|
863 | --- |
---|
864 | > #include "MantidQtImageViewer/DataArray.h" |
---|
865 | > #include "MantidQtImageViewer/DllOptionIV.h" |
---|
866 | 45c45 |
---|
867 | < namespace RefDetectorViewer |
---|
868 | --- |
---|
869 | > namespace ImageView |
---|
870 | 49c49 |
---|
871 | < class EXPORT_OPT_MANTIDQT_IMAGEVIEWER RefImagePlotItem : public QwtPlotItem |
---|
872 | --- |
---|
873 | > class EXPORT_OPT_MANTIDQT_IMAGEVIEWER ImagePlotItem : public QwtPlotItem |
---|
874 | 55c55 |
---|
875 | < RefImagePlotItem(); |
---|
876 | --- |
---|
877 | > ImagePlotItem(); |
---|
878 | 57c57 |
---|
879 | < ~RefImagePlotItem(); |
---|
880 | --- |
---|
881 | > ~ImagePlotItem(); |
---|
882 | 88,89d87 |
---|
883 | < |
---|
884 | < |
---|
885 | 94c92 |
---|
886 | < #endif // REF_IMAGE_PLOT_ITEM_H |
---|
887 | --- |
---|
888 | > #endif // IMAGE_PLOT_ITEM_H |
---|
889 | >>>>>>>>>>>>> ImagePlotItem.cpp <<<<<<<<<<<<< |
---|
890 | 4,5c4 |
---|
891 | < #include "MantidQtRefDetectorViewer/RefImagePlotItem.h" |
---|
892 | < #include "MantidQtRefDetectorViewer/RefImageDisplay.h" |
---|
893 | --- |
---|
894 | > #include "MantidQtImageViewer/ImagePlotItem.h" |
---|
895 | 9c8 |
---|
896 | < namespace RefDetectorViewer |
---|
897 | --- |
---|
898 | > namespace ImageView |
---|
899 | 11c10,11 |
---|
900 | < |
---|
901 | --- |
---|
902 | > |
---|
903 | > |
---|
904 | 15c15 |
---|
905 | < RefImagePlotItem::RefImagePlotItem() |
---|
906 | --- |
---|
907 | > ImagePlotItem::ImagePlotItem() |
---|
908 | 26c26 |
---|
909 | < RefImagePlotItem::~RefImagePlotItem() |
---|
910 | --- |
---|
911 | > ImagePlotItem::~ImagePlotItem() |
---|
912 | 54c54 |
---|
913 | < void RefImagePlotItem::SetData( DataArray* data_array, |
---|
914 | --- |
---|
915 | > void ImagePlotItem::SetData( DataArray* data_array, |
---|
916 | 94c94 |
---|
917 | < void RefImagePlotItem::SetIntensityTable( std::vector<double>* intensity_table ) |
---|
918 | --- |
---|
919 | > void ImagePlotItem::SetIntensityTable( std::vector<double>* intensity_table ) |
---|
920 | 114c114 |
---|
921 | < void RefImagePlotItem::draw( QPainter * painter, |
---|
922 | --- |
---|
923 | > void ImagePlotItem::draw( QPainter * painter, |
---|
924 | 119c119 |
---|
925 | < if ( !positive_color_table ) // if no color table, the data is not yet |
---|
926 | --- |
---|
927 | > if ( !positive_color_table ) // if no color table, the data is not yet |
---|
928 | 149,154d148 |
---|
929 | < // std::cout << "x_min: " << x_min << std::endl; |
---|
930 | < // std::cout << "x_max: " << x_max << std::endl; |
---|
931 | < // std::cout << "y_min: " << y_min << std::endl; |
---|
932 | < // std::cout << "y_max: " << y_max << std::endl; |
---|
933 | < |
---|
934 | < |
---|
935 | 163,167d156 |
---|
936 | < // std::cout << "pix_x_min: " << pix_x_min << std::endl; |
---|
937 | < // std::cout << "pix_x_max: " << pix_x_max << std::endl; |
---|
938 | < // std::cout << "pix_y_min: " << pix_y_min << std::endl; |
---|
939 | < // std::cout << "pix_y_max: " << pix_y_max << std::endl; |
---|
940 | < |
---|
941 | 253,268d241 |
---|
942 | < |
---|
943 | < float coeff_left = (float(y_max) - float(y_min)) / (float(pix_y_min) - float(pix_y_max)); |
---|
944 | < float coeff_top_right; |
---|
945 | < int pixel_value; |
---|
946 | < |
---|
947 | < //for the peak selection |
---|
948 | < painter->setPen(Qt::blue); |
---|
949 | < |
---|
950 | < //peak1 |
---|
951 | < float peakLeft = float(RefImageDisplay::getPeakLeft()); |
---|
952 | < |
---|
953 | < if (peakLeft != 0) { |
---|
954 | < coeff_top_right = float(y_max) - float(peakLeft); |
---|
955 | < pixel_value = int((coeff_top_right / coeff_left) + float(pix_y_max)); |
---|
956 | < painter->drawLine(QPoint(pix_x_min,pixel_value), QPoint(pix_x_max,pixel_value)); |
---|
957 | < } |
---|
958 | 270,319d242 |
---|
959 | < //peak2 |
---|
960 | < float peakRight = float(RefImageDisplay::getPeakRight()); |
---|
961 | < if (peakRight != 0) { |
---|
962 | < coeff_top_right = float(y_max) - float(peakRight); |
---|
963 | < pixel_value = int((coeff_top_right / coeff_left) + float(pix_y_max)); |
---|
964 | < painter->drawLine(QPoint(pix_x_min,pixel_value), QPoint(pix_x_max,pixel_value)); |
---|
965 | < } |
---|
966 | < |
---|
967 | < //for the background selection |
---|
968 | < painter->setPen(Qt::red); |
---|
969 | < |
---|
970 | < //back1 |
---|
971 | < float backLeft = float(RefImageDisplay::getBackLeft()); |
---|
972 | < if (backLeft != 0) { |
---|
973 | < coeff_top_right = float(y_max) - float(backLeft); |
---|
974 | < pixel_value = int((coeff_top_right / coeff_left) + float(pix_y_max)); |
---|
975 | < painter->drawLine(QPoint(pix_x_min,pixel_value), QPoint(pix_x_max,pixel_value)); |
---|
976 | < } |
---|
977 | < |
---|
978 | < //back2 |
---|
979 | < float backRight = float(RefImageDisplay::getBackRight()); |
---|
980 | < if (backRight != 0) { |
---|
981 | < coeff_top_right = float(y_max) - float(backRight); |
---|
982 | < pixel_value = int((coeff_top_right / coeff_left) + float(pix_y_max)); |
---|
983 | < painter->drawLine(QPoint(pix_x_min,pixel_value), QPoint(pix_x_max,pixel_value)); |
---|
984 | < } |
---|
985 | < |
---|
986 | < //tof selection |
---|
987 | < painter->setPen(Qt::green); |
---|
988 | < |
---|
989 | < coeff_left = (float(pix_x_max) - float(pix_x_min)) / (float(x_max) - float(x_min)); |
---|
990 | < int tof_value; |
---|
991 | < float coeff_bottom_right; |
---|
992 | < |
---|
993 | < //tof min |
---|
994 | < float TOFmin = float(RefImageDisplay::getTOFmin()); |
---|
995 | < if (TOFmin != 0) { |
---|
996 | < coeff_bottom_right = float(TOFmin) - float(x_min); |
---|
997 | < tof_value = int(coeff_left * coeff_bottom_right + static_cast<float>(pix_x_min)); |
---|
998 | < painter->drawLine(QPoint(tof_value,pix_y_min), QPoint(tof_value,pix_y_max)); |
---|
999 | < } |
---|
1000 | < |
---|
1001 | < //tof max |
---|
1002 | < float TOFmax = float(RefImageDisplay::getTOFmax()); |
---|
1003 | < if (TOFmax != 0) { |
---|
1004 | < coeff_bottom_right = float(TOFmax) - float(x_min); |
---|
1005 | < tof_value = int(coeff_left * coeff_bottom_right + float(pix_x_min)); |
---|
1006 | < painter->drawLine(QPoint(tof_value,pix_y_min), QPoint(tof_value,pix_y_max)); |
---|
1007 | < } |
---|
1008 | < |
---|
1009 | 321c244,245 |
---|
1010 | < // not earlier since the image // and/or pixmap is using it |
---|
1011 | --- |
---|
1012 | > // not earlier since the image |
---|
1013 | > // and/or pixmap is using it |
---|
1014 | 324,325d247 |
---|
1015 | < |
---|
1016 | < |
---|
1017 | >>>>>>>>>>>>> ImageDisplay.h <<<<<<<<<<<<< |
---|
1018 | 1,2c1,2 |
---|
1019 | < #ifndef REF_IMAGE_DISPLAY_H |
---|
1020 | < #define REF_IMAGE_DISPLAY_H |
---|
1021 | --- |
---|
1022 | > #ifndef IMAGE_DISPLAY_H |
---|
1023 | > #define IMAGE_DISPLAY_H |
---|
1024 | 10,15c10,15 |
---|
1025 | < #include "MantidQtRefDetectorViewer/RefImageDataSource.h" |
---|
1026 | < #include "MantidQtRefDetectorViewer/GraphDisplay.h" |
---|
1027 | < #include "MantidQtRefDetectorViewer/RefImagePlotItem.h" |
---|
1028 | < #include "MantidQtRefDetectorViewer/SliderHandler.h" |
---|
1029 | < #include "MantidQtRefDetectorViewer/RangeHandler.h" |
---|
1030 | < #include "MantidQtRefDetectorViewer/DllOptionIV.h" |
---|
1031 | --- |
---|
1032 | > #include "MantidQtImageViewer/ImageDataSource.h" |
---|
1033 | > #include "MantidQtImageViewer/GraphDisplay.h" |
---|
1034 | > #include "MantidQtImageViewer/ImagePlotItem.h" |
---|
1035 | > #include "MantidQtImageViewer/SliderHandler.h" |
---|
1036 | > #include "MantidQtImageViewer/RangeHandler.h" |
---|
1037 | > #include "MantidQtImageViewer/DllOptionIV.h" |
---|
1038 | 18c18 |
---|
1039 | < @class RefImageDisplay |
---|
1040 | --- |
---|
1041 | > @class ImageDisplay |
---|
1042 | 49c49 |
---|
1043 | < namespace RefDetectorViewer |
---|
1044 | --- |
---|
1045 | > namespace ImageView |
---|
1046 | 53c53 |
---|
1047 | < class EXPORT_OPT_MANTIDQT_IMAGEVIEWER RefImageDisplay |
---|
1048 | --- |
---|
1049 | > class EXPORT_OPT_MANTIDQT_IMAGEVIEWER ImageDisplay |
---|
1050 | 58c58 |
---|
1051 | < RefImageDisplay( QwtPlot* image_plot, |
---|
1052 | --- |
---|
1053 | > ImageDisplay( QwtPlot* image_plot, |
---|
1054 | 63,75c63 |
---|
1055 | < QTableWidget* table_widget, |
---|
1056 | < QRadioButton* radioButtonPeakLeft, |
---|
1057 | < QRadioButton* radioButtonPeakRight, |
---|
1058 | < QRadioButton* radioButtonBackLeft, |
---|
1059 | < QRadioButton* radioButtonBackRight, |
---|
1060 | < QRadioButton* radioButtonTOFmin, |
---|
1061 | < QRadioButton* radioButtonTOFmax, |
---|
1062 | < QLineEdit* lineEditPeakLeft, |
---|
1063 | < QLineEdit* lineEditPeakRight, |
---|
1064 | < QLineEdit* lineEditBackLeft, |
---|
1065 | < QLineEdit* lineEditBackRight, |
---|
1066 | < QLineEdit* lineEditTOFmin, |
---|
1067 | < QLineEdit* lineEditTOFmax); |
---|
1068 | --- |
---|
1069 | > QTableWidget* table_widget ); |
---|
1070 | 77c65 |
---|
1071 | < ~RefImageDisplay(); |
---|
1072 | --- |
---|
1073 | > ~ImageDisplay(); |
---|
1074 | 80c68 |
---|
1075 | < void SetDataSource( RefImageDataSource* data_source ); |
---|
1076 | --- |
---|
1077 | > void SetDataSource( ImageDataSource* data_source ); |
---|
1078 | 96,97c84 |
---|
1079 | < /// default right click (mouseClick = 2) |
---|
1080 | < void SetPointedAtPoint( QPoint point, int mouseClick = 2 ); |
---|
1081 | --- |
---|
1082 | > void SetPointedAtPoint( QPoint point ); |
---|
1083 | 104,120c91,92 |
---|
1084 | < |
---|
1085 | < /// get peak, back and tof values |
---|
1086 | < static int getPeakLeft(); |
---|
1087 | < static int getPeakRight(); |
---|
1088 | < static int getBackLeft(); |
---|
1089 | < static int getBackRight(); |
---|
1090 | < static int getTOFmin(); |
---|
1091 | < static int getTOFmax(); |
---|
1092 | < |
---|
1093 | < static void setPeakLeft(int value); |
---|
1094 | < static void setPeakRight(int value); |
---|
1095 | < static void setBackLeft(int value); |
---|
1096 | < static void setBackRight(int value); |
---|
1097 | < static void setTOFmin(int value); |
---|
1098 | < static void setTOFmax(int value); |
---|
1099 | < |
---|
1100 | < private: |
---|
1101 | --- |
---|
1102 | > |
---|
1103 | > private: |
---|
1104 | 130,132d101 |
---|
1105 | < // Show information about the x and y values selected in peak/back/tof/left/right boxes |
---|
1106 | < void ShowPeakBackSelectionValue(double x, double y ); |
---|
1107 | < |
---|
1108 | 137c106 |
---|
1109 | < RefImageDataSource* data_source; |
---|
1110 | --- |
---|
1111 | > ImageDataSource* data_source; |
---|
1112 | 141c110 |
---|
1113 | < RefImagePlotItem* image_plot_item; |
---|
1114 | --- |
---|
1115 | > ImagePlotItem* image_plot_item; |
---|
1116 | 152,173c121 |
---|
1117 | < //to update peak and back left and right infos |
---|
1118 | < QRadioButton* radioButtonPeakLeft; |
---|
1119 | < QRadioButton* radioButtonPeakRight; |
---|
1120 | < QRadioButton* radioButtonBackLeft; |
---|
1121 | < QRadioButton* radioButtonBackRight; |
---|
1122 | < QRadioButton* radioButtonTOFmin; |
---|
1123 | < QRadioButton* radioButtonTOFmax; |
---|
1124 | < QLineEdit* lineEditPeakLeft; |
---|
1125 | < QLineEdit* lineEditPeakRight; |
---|
1126 | < QLineEdit* lineEditBackLeft; |
---|
1127 | < QLineEdit* lineEditBackRight; |
---|
1128 | < QLineEdit* lineEditTOFmin; |
---|
1129 | < QLineEdit* lineEditTOFmax; |
---|
1130 | < |
---|
1131 | < static int peakLeft; |
---|
1132 | < static int peakRight; |
---|
1133 | < static int backLeft; |
---|
1134 | < static int backRight; |
---|
1135 | < static int TOFmin; |
---|
1136 | < static int TOFmax; |
---|
1137 | < |
---|
1138 | < QTableWidget* image_table; |
---|
1139 | --- |
---|
1140 | > QTableWidget* image_table; |
---|
1141 | 186c134,135 |
---|
1142 | < #endif // REF_IMAGE_DISPLAY_H |
---|
1143 | --- |
---|
1144 | > |
---|
1145 | > #endif // IMAGE_DISPLAY_H |
---|
1146 | >>>>>>>>>>>>> ImageDisplay.cpp <<<<<<<<<<<<< |
---|
1147 | #include <iostream> #include <iostream> |
---|
1148 | #include <sstream> #include <sstream> |
---|
1149 | #include <cfloat> #include <cfloat> |
---|
1150 | |
---|
1151 | #include <QtGui> #include <QtGui> |
---|
1152 | #include <QVector> #include <QVector> |
---|
1153 | #include <QString> #include <QString> |
---|
1154 | #include <qimage.h> #include <qimage.h> |
---|
1155 | #include <qwt_scale_engine.h> #include <qwt_scale_engine.h> |
---|
1156 | |
---|
1157 | #include "MantidQtRefDetectorViewer/RefImageDisplay.h" | #include "MantidQtImageViewer/ImageDisplay.h" |
---|
1158 | #include "MantidQtRefDetectorViewer/RefImageDataSource.h" | #include "MantidQtImageViewer/ImageDataSource.h" |
---|
1159 | #include "MantidQtRefDetectorViewer/DataArray.h" | #include "MantidQtImageViewer/DataArray.h" |
---|
1160 | #include "MantidQtRefDetectorViewer/ColorMaps.h" | #include "MantidQtImageViewer/ColorMaps.h" |
---|
1161 | #include "MantidQtRefDetectorViewer/QtUtils.h" | #include "MantidQtImageViewer/QtUtils.h" |
---|
1162 | #include "MantidQtRefDetectorViewer/IVUtils.h" | #include "MantidQtImageViewer/IVUtils.h" |
---|
1163 | #include "MantidQtRefDetectorViewer/RefImagePlotItem.h" < |
---|
1164 | |
---|
1165 | namespace MantidQt namespace MantidQt |
---|
1166 | { { |
---|
1167 | namespace RefDetectorViewer | namespace ImageView |
---|
1168 | { { |
---|
1169 | |
---|
1170 | /** /** |
---|
1171 | * Make an RefImageDisplay to display with the given widgets | * Make an ImageDisplay to display with the given widgets and |
---|
1172 | * * |
---|
1173 | * @param image_plot The QwtPlot that will hold the imag * @param image_plot The QwtPlot that will hold the imag |
---|
1174 | * @param slider_handler The object that manages interaction * @param slider_handler The object that manages interaction |
---|
1175 | * horizontal and vertical scroll bars * horizontal and vertical scroll bars |
---|
1176 | * @param h_graph The GraphDisplay for the graph show * @param h_graph The GraphDisplay for the graph show |
---|
1177 | * cuts through the image at the botto * cuts through the image at the botto |
---|
1178 | * @param v_graph The GraphDisplay for the graph show * @param v_graph The GraphDisplay for the graph show |
---|
1179 | * cuts through the image at the left * cuts through the image at the left |
---|
1180 | * @param table_widget The widget where the information ab * @param table_widget The widget where the information ab |
---|
1181 | * at location will be displayed. * at location will be displayed. |
---|
1182 | */ */ |
---|
1183 | RefImageDisplay::RefImageDisplay( QwtPlot* image_plot, | ImageDisplay::ImageDisplay( QwtPlot* image_plot, |
---|
1184 | SliderHandler* slider_handler, SliderHandler* slider_handler, |
---|
1185 | RangeHandler* range_handler, RangeHandler* range_handler, |
---|
1186 | GraphDisplay* h_graph, GraphDisplay* h_graph, |
---|
1187 | GraphDisplay* v_graph, GraphDisplay* v_graph, |
---|
1188 | QTableWidget* table_widget, | QTableWidget* table_widget ) |
---|
1189 | QRadioButton* radioPeakLeft, < |
---|
1190 | QRadioButton* radioPeakRight, < |
---|
1191 | QRadioButton* radioBackLeft, < |
---|
1192 | QRadioButton* radioBackRight, < |
---|
1193 | QRadioButton* radioTOFmin, < |
---|
1194 | QRadioButton* radioTOFmax, < |
---|
1195 | QLineEdit* linePeakLeft, < |
---|
1196 | QLineEdit* linePeakRight, < |
---|
1197 | QLineEdit* lineBackLeft, < |
---|
1198 | QLineEdit* lineBackRight, < |
---|
1199 | QLineEdit* lineTOFmin, < |
---|
1200 | QLineEdit* lineTOFmax) < |
---|
1201 | { { |
---|
1202 | ColorMaps::GetColorMap( ColorMaps::HEAT, ColorMaps::GetColorMap( ColorMaps::HEAT, |
---|
1203 | 256, 256, |
---|
1204 | positive_color_table ); positive_color_table ); |
---|
1205 | ColorMaps::GetColorMap( ColorMaps::GRAY, ColorMaps::GetColorMap( ColorMaps::GRAY, |
---|
1206 | 256, 256, |
---|
1207 | negative_color_table ); negative_color_table ); |
---|
1208 | |
---|
1209 | this->image_plot = image_plot; this->image_plot = image_plot; |
---|
1210 | this->slider_handler = slider_handler; this->slider_handler = slider_handler; |
---|
1211 | this->range_handler = range_handler; this->range_handler = range_handler; |
---|
1212 | |
---|
1213 | image_plot_item = new RefImagePlotItem; | image_plot_item = new ImagePlotItem; |
---|
1214 | image_plot_item->setXAxis( QwtPlot::xBottom ); image_plot_item->setXAxis( QwtPlot::xBottom ); |
---|
1215 | image_plot_item->setYAxis( QwtPlot::yLeft ); image_plot_item->setYAxis( QwtPlot::yLeft ); |
---|
1216 | |
---|
1217 | image_plot_item->attach( image_plot ); image_plot_item->attach( image_plot ); |
---|
1218 | |
---|
1219 | h_graph_display = h_graph; h_graph_display = h_graph; |
---|
1220 | v_graph_display = v_graph; v_graph_display = v_graph; |
---|
1221 | image_table = table_widget; image_table = table_widget; |
---|
1222 | |
---|
1223 | lineEditPeakLeft = linePeakLeft; < |
---|
1224 | lineEditPeakRight = linePeakRight; < |
---|
1225 | lineEditBackLeft = lineBackLeft; < |
---|
1226 | lineEditBackRight = lineBackRight; < |
---|
1227 | lineEditTOFmin = lineTOFmin; < |
---|
1228 | lineEditTOFmax = lineTOFmax; < |
---|
1229 | radioButtonPeakLeft = radioPeakLeft; < |
---|
1230 | radioButtonPeakRight = radioPeakRight; < |
---|
1231 | radioButtonBackLeft = radioBackLeft; < |
---|
1232 | radioButtonBackRight = radioBackRight; < |
---|
1233 | radioButtonTOFmin = radioTOFmin; < |
---|
1234 | radioButtonTOFmax = radioTOFmax; < |
---|
1235 | < |
---|
1236 | data_source = 0; data_source = 0; |
---|
1237 | |
---|
1238 | double DEFAULT_INTENSITY = 30; double DEFAULT_INTENSITY = 30; |
---|
1239 | SetIntensity( DEFAULT_INTENSITY ); SetIntensity( DEFAULT_INTENSITY ); |
---|
1240 | } } |
---|
1241 | |
---|
1242 | |
---|
1243 | RefImageDisplay::~RefImageDisplay() | ImageDisplay::~ImageDisplay() |
---|
1244 | { { |
---|
1245 | > // std::cout << "ImageDisplay destructor called" << std::en |
---|
1246 | delete image_plot_item; delete image_plot_item; |
---|
1247 | } } |
---|
1248 | |
---|
1249 | |
---|
1250 | /** /** |
---|
1251 | * Set the data source from which the image and data table in * Set the data source from which the image and data table in |
---|
1252 | * be obtained. * be obtained. |
---|
1253 | * * |
---|
1254 | * @param data_source The ImageDataSource that provides the a * @param data_source The ImageDataSource that provides the a |
---|
1255 | * and information for the table. * and information for the table. |
---|
1256 | */ */ |
---|
1257 | void RefImageDisplay::SetDataSource( RefImageDataSource* data | void ImageDisplay::SetDataSource( ImageDataSource* data_sourc |
---|
1258 | { { |
---|
1259 | this->data_source = data_source; this->data_source = data_source; |
---|
1260 | h_graph_display->SetDataSource( data_source ); h_graph_display->SetDataSource( data_source ); |
---|
1261 | v_graph_display->SetDataSource( data_source ); v_graph_display->SetDataSource( data_source ); |
---|
1262 | |
---|
1263 | total_y_min = data_source->GetYMin(); total_y_min = data_source->GetYMin(); |
---|
1264 | total_y_max = data_source->GetYMax(); total_y_max = data_source->GetYMax(); |
---|
1265 | |
---|
1266 | total_x_min = data_source->GetXMin(); total_x_min = data_source->GetXMin(); |
---|
1267 | total_x_max = data_source->GetXMax(); total_x_max = data_source->GetXMax(); |
---|
1268 | |
---|
1269 | pointed_at_x = DBL_MAX; pointed_at_x = DBL_MAX; |
---|
1270 | pointed_at_y = DBL_MAX; pointed_at_y = DBL_MAX; |
---|
1271 | |
---|
1272 | int n_rows = 500; // get reasonable size initial int n_rows = 500; // get reasonable size initial |
---|
1273 | int n_cols = 500; int n_cols = 500; |
---|
1274 | // data_array is deleted in th // data_array is deleted in th |
---|
1275 | data_array = data_source->GetDataArray( total_x_min, total_ data_array = data_source->GetDataArray( total_x_min, total_ |
---|
1276 | total_y_min, total_ total_y_min, total_ |
---|
1277 | n_rows, n_cols, n_rows, n_cols, |
---|
1278 | false ); false ); |
---|
1279 | |
---|
1280 | image_plot->setAxisScale( QwtPlot::xBottom, data_array->Get image_plot->setAxisScale( QwtPlot::xBottom, data_array->Get |
---|
1281 | data_array->Get data_array->Get |
---|
1282 | image_plot->setAxisScale( QwtPlot::yLeft, data_array->GetYM image_plot->setAxisScale( QwtPlot::yLeft, data_array->GetYM |
---|
1283 | data_array->GetYM data_array->GetYM |
---|
1284 | |
---|
1285 | | image_plot_item->SetData( data_array, |
---|
1286 | image_plot_item->SetData(data_array, < |
---|
1287 | &positive_color_table, &positive_color_table, |
---|
1288 | &negative_color_table ); &negative_color_table ); |
---|
1289 | | |
---|
1290 | range_handler->ConfigureRangeControls( data_source ); range_handler->ConfigureRangeControls( data_source ); |
---|
1291 | |
---|
1292 | QRect draw_area; QRect draw_area; |
---|
1293 | GetDisplayRectangle( draw_area ); GetDisplayRectangle( draw_area ); |
---|
1294 | slider_handler->ConfigureSliders( draw_area, data_source ); slider_handler->ConfigureSliders( draw_area, data_source ); |
---|
1295 | } } |
---|
1296 | |
---|
1297 | /** /** |
---|
1298 | * Rebuild the scrollbars and image due to a change in the r * Rebuild the scrollbars and image due to a change in the r |
---|
1299 | * or step size. It should be invoked when the user changes * or step size. It should be invoked when the user changes |
---|
1300 | * the xmin, xmax or step controls. It should not be called * the xmin, xmax or step controls. It should not be called |
---|
1301 | * other threads. * other threads. |
---|
1302 | */ */ |
---|
1303 | void RefImageDisplay::UpdateRange() | void ImageDisplay::UpdateRange() |
---|
1304 | { { |
---|
1305 | if ( data_source == 0 ) if ( data_source == 0 ) |
---|
1306 | { { |
---|
1307 | return; // no image data to update return; // no image data to update |
---|
1308 | } } |
---|
1309 | |
---|
1310 | if ( DataSourceRangeChanged() ) if ( DataSourceRangeChanged() ) |
---|
1311 | { { |
---|
1312 | SetDataSource( data_source ); // re-initialize with the SetDataSource( data_source ); // re-initialize with the |
---|
1313 | } } |
---|
1314 | |
---|
1315 | QRect display_rect; QRect display_rect; |
---|
1316 | GetDisplayRectangle( display_rect ); GetDisplayRectangle( display_rect ); |
---|
1317 | // range controls // range controls |
---|
1318 | // the number of b | // the number of |
---|
1319 | double min = total_x_min; double min = total_x_min; |
---|
1320 | double max = total_x_max; double max = total_x_max; |
---|
1321 | double step = (total_x_max - total_x_min)/2000; double step = (total_x_max - total_x_min)/2000; |
---|
1322 | range_handler->GetRange( min, max, step ); range_handler->GetRange( min, max, step ); |
---|
1323 | | |
---|
1324 | int n_bins = IVUtils::NumSteps( min, max, step ); int n_bins = IVUtils::NumSteps( min, max, step ); |
---|
1325 | if ( n_bins == 0 ) if ( n_bins == 0 ) |
---|
1326 | { { |
---|
1327 | return; return; |
---|
1328 | } } |
---|
1329 | |
---|
1330 | slider_handler->ConfigureHSlider( n_bins, display_rect.widt slider_handler->ConfigureHSlider( n_bins, display_rect.widt |
---|
1331 | |
---|
1332 | UpdateImage(); UpdateImage(); |
---|
1333 | } } |
---|
1334 | |
---|
1335 | /** /** |
---|
1336 | * This will rebuild the image from the data source. It sho * This will rebuild the image from the data source. It sho |
---|
1337 | * when the scroll bar is moved, the plot area is resize or * when the scroll bar is moved, the plot area is resize or |
---|
1338 | * intensity tables are changed. It should not be called di * intensity tables are changed. It should not be called di |
---|
1339 | * other threads. * other threads. |
---|
1340 | */ */ |
---|
1341 | void RefImageDisplay::UpdateImage() | void ImageDisplay::UpdateImage() |
---|
1342 | { { |
---|
1343 | if ( data_source == 0 ) if ( data_source == 0 ) |
---|
1344 | { { |
---|
1345 | return; // no image data to update return; // no image data to update |
---|
1346 | } } |
---|
1347 | |
---|
1348 | if ( DataSourceRangeChanged() ) if ( DataSourceRangeChanged() ) |
---|
1349 | { { |
---|
1350 | SetDataSource( data_source ); // re-initialize with the SetDataSource( data_source ); // re-initialize with the |
---|
1351 | } } |
---|
1352 | |
---|
1353 | QRect display_rect; QRect display_rect; |
---|
1354 | GetDisplayRectangle( display_rect ); GetDisplayRectangle( display_rect ); |
---|
1355 | |
---|
1356 | double scale_y_min = data_source->GetYMin(); double scale_y_min = data_source->GetYMin(); |
---|
1357 | double scale_y_max = data_source->GetYMax(); double scale_y_max = data_source->GetYMax(); |
---|
1358 | |
---|
1359 | double scale_x_min = total_x_min; double scale_x_min = total_x_min; |
---|
1360 | double scale_x_max = total_x_max; double scale_x_max = total_x_max; |
---|
1361 | double x_step = (total_x_max - total_x_min)/2000; double x_step = (total_x_max - total_x_min)/2000; |
---|
1362 | > |
---|
1363 | range_handler->GetRange( scale_x_min, scale_x_max, x_step ) range_handler->GetRange( scale_x_min, scale_x_max, x_step ) |
---|
1364 | |
---|
1365 | int n_rows = (int)data_source->GetNRows(); int n_rows = (int)data_source->GetNRows(); |
---|
1366 | int n_cols = IVUtils::NumSteps( scale_x_min, scale_x_max, x int n_cols = IVUtils::NumSteps( scale_x_min, scale_x_max, x |
---|
1367 | // This works for linear < |
---|
1368 | |
---|
1369 | > // This works for linear |
---|
1370 | if ( n_rows == 0 || n_cols == 0 ) if ( n_rows == 0 || n_cols == 0 ) |
---|
1371 | { { |
---|
1372 | return; // can't draw empty imag return; // can't draw empty imag |
---|
1373 | } } |
---|
1374 | |
---|
1375 | if ( slider_handler->VSliderOn() ) if ( slider_handler->VSliderOn() ) |
---|
1376 | { { |
---|
1377 | int y_min; int y_min; |
---|
1378 | int y_max; int y_max; |
---|
1379 | slider_handler->GetVSliderInterval( y_min, y_max ); slider_handler->GetVSliderInterval( y_min, y_max ); |
---|
1380 | |
---|
1381 | double new_y_min = 0; double new_y_min = 0; |
---|
1382 | double new_y_max = 0; double new_y_max = 0; |
---|
1383 | |
---|
1384 | IVUtils::Interpolate( 0, n_rows, y_min, IVUtils::Interpolate( 0, n_rows, y_min, |
---|
1385 | scale_y_min, scale_y_max, new_y_min scale_y_min, scale_y_max, new_y_min |
---|
1386 | IVUtils::Interpolate( 0, n_rows, y_max, IVUtils::Interpolate( 0, n_rows, y_max, |
---|
1387 | scale_y_min, scale_y_max, new_y_max scale_y_min, scale_y_max, new_y_max |
---|
1388 | |
---|
1389 | scale_y_min = new_y_min; scale_y_min = new_y_min; |
---|
1390 | scale_y_max = new_y_max; scale_y_max = new_y_max; |
---|
1391 | } } |
---|
1392 | |
---|
1393 | if ( slider_handler->HSliderOn() ) if ( slider_handler->HSliderOn() ) |
---|
1394 | { { |
---|
1395 | int x_min; int x_min; |
---|
1396 | int x_max; int x_max; |
---|
1397 | slider_handler->GetHSliderInterval( x_min, x_max ); slider_handler->GetHSliderInterval( x_min, x_max ); |
---|
1398 | // NOTE: The interval [xmin,xmax] // NOTE: The interval [xmin,xmax] |
---|
1399 | // found linearly. For log_x, we // found linearly. For log_x, we |
---|
1400 | > |
---|
1401 | double new_x_min = 0; double new_x_min = 0; |
---|
1402 | double new_x_max = 0; double new_x_max = 0; |
---|
1403 | |
---|
1404 | if ( x_step > 0 ) // linear scale, so interpolate l if ( x_step > 0 ) // linear scale, so interpolate l |
---|
1405 | { { |
---|
1406 | IVUtils::Interpolate( 0, n_cols, x_min, IVUtils::Interpolate( 0, n_cols, x_min, |
---|
1407 | scale_x_min, scale_x_max, new_x_m scale_x_min, scale_x_max, new_x_m |
---|
1408 | IVUtils::Interpolate( 0, n_cols, x_max, IVUtils::Interpolate( 0, n_cols, x_max, |
---|
1409 | scale_x_min, scale_x_max, new_x_m scale_x_min, scale_x_max, new_x_m |
---|
1410 | } } |
---|
1411 | else // log scale, so interpolate "log else // log scale, so interpolate "log |
---|
1412 | { { |
---|
1413 | IVUtils::LogInterpolate( 0, n_cols, x_min, IVUtils::LogInterpolate( 0, n_cols, x_min, |
---|
1414 | scale_x_min, scale_x_max, new_ scale_x_min, scale_x_max, new_ |
---|
1415 | IVUtils::LogInterpolate( 0, n_cols, x_max, IVUtils::LogInterpolate( 0, n_cols, x_max, |
---|
1416 | scale_x_min, scale_x_max, new_ scale_x_min, scale_x_max, new_ |
---|
1417 | } } |
---|
1418 | |
---|
1419 | scale_x_min = new_x_min; scale_x_min = new_x_min; |
---|
1420 | scale_x_max = new_x_max; scale_x_max = new_x_max; |
---|
1421 | } } |
---|
1422 | |
---|
1423 | if ( n_rows > display_rect.height() ) if ( n_rows > display_rect.height() ) |
---|
1424 | { { |
---|
1425 | n_rows = display_rect.height(); n_rows = display_rect.height(); |
---|
1426 | } } |
---|
1427 | |
---|
1428 | if ( n_cols > display_rect.width() ) if ( n_cols > display_rect.width() ) |
---|
1429 | { { |
---|
1430 | n_cols = display_rect.width(); n_cols = display_rect.width(); |
---|
1431 | } } |
---|
1432 | |
---|
1433 | bool is_log_x = ( x_step < 0 ); bool is_log_x = ( x_step < 0 ); |
---|
1434 | // NOTE: The DataArr // NOTE: The DataArr |
---|
1435 | // in the Imag // in the Imag |
---|
1436 | data_array = data_source->GetDataArray( scale_x_min, scale_ data_array = data_source->GetDataArray( scale_x_min, scale_ |
---|
1437 | scale_y_min, scale_ scale_y_min, scale_ |
---|
1438 | n_rows, n_cols, n_rows, n_cols, |
---|
1439 | is_log_x ); is_log_x ); |
---|
1440 | |
---|
1441 | is_log_x = data_array->IsLogX(); // Data source might is_log_x = data_array->IsLogX(); // Data source might |
---|
1442 | // provide log binne // provide log binne |
---|
1443 | // if log binned dat // if log binned dat |
---|
1444 | |
---|
1445 | image_plot->setAxisScale( QwtPlot::xBottom, data_array->Get image_plot->setAxisScale( QwtPlot::xBottom, data_array->Get |
---|
1446 | data_array->Get data_array->Get |
---|
1447 | if ( is_log_x ) if ( is_log_x ) |
---|
1448 | { { |
---|
1449 | QwtLog10ScaleEngine* log_engine = new QwtLog10ScaleEngine QwtLog10ScaleEngine* log_engine = new QwtLog10ScaleEngine |
---|
1450 | image_plot->setAxisScaleEngine( QwtPlot::xBottom, log_eng image_plot->setAxisScaleEngine( QwtPlot::xBottom, log_eng |
---|
1451 | } } |
---|
1452 | else else |
---|
1453 | { { |
---|
1454 | QwtLinearScaleEngine* linear_engine = new QwtLinearScaleE QwtLinearScaleEngine* linear_engine = new QwtLinearScaleE |
---|
1455 | image_plot->setAxisScaleEngine( QwtPlot::xBottom, linear_ image_plot->setAxisScaleEngine( QwtPlot::xBottom, linear_ |
---|
1456 | } } |
---|
1457 | |
---|
1458 | image_plot->setAxisScale( QwtPlot::yLeft, data_array->GetYM image_plot->setAxisScale( QwtPlot::yLeft, data_array->GetYM |
---|
1459 | data_array->GetYM data_array->GetYM |
---|
1460 | |
---|
1461 | image_plot_item->SetData( data_array, image_plot_item->SetData( data_array, |
---|
1462 | &positive_color_table, &positive_color_table, |
---|
1463 | &negative_color_table ); &negative_color_table ); |
---|
1464 | | image_plot->replot(); |
---|
1465 | //Where I need to add the code that plot the selection < |
---|
1466 | |
---|
1467 | image_plot->replot(); < |
---|
1468 | < |
---|
1469 | SetVGraph( pointed_at_x ); SetVGraph( pointed_at_x ); |
---|
1470 | SetHGraph( pointed_at_y ); SetHGraph( pointed_at_y ); |
---|
1471 | } } |
---|
1472 | |
---|
1473 | |
---|
1474 | /** /** |
---|
1475 | * Change the color tables used to map intensity to color. T * Change the color tables used to map intensity to color. T |
---|
1476 | * used to allow psuedo-log scaling based on the magnitude o * used to allow psuedo-log scaling based on the magnitude o |
---|
1477 | * Typically if the positive color table is colorful, such a * Typically if the positive color table is colorful, such a |
---|
1478 | * scale, the negative color table should be a gray scale to * scale, the negative color table should be a gray scale to |
---|
1479 | * distinguish between positive and negative values. * distinguish between positive and negative values. |
---|
1480 | * * |
---|
1481 | * @param positive_color_table The new color table used to * @param positive_color_table The new color table used to |
---|
1482 | * values to an RGB color. Thi * values to an RGB color. Thi |
---|
1483 | * positive number of values, b * positive number of values, b |
---|
1484 | * have 256 entries. * have 256 entries. |
---|
1485 | * @param negative_color_table The new color table used to * @param negative_color_table The new color table used to |
---|
1486 | * values to an RGB color. Thi * values to an RGB color. Thi |
---|
1487 | * same number of entries as th * same number of entries as th |
---|
1488 | * color table. * color table. |
---|
1489 | */ */ |
---|
1490 | void RefImageDisplay::SetColorScales( std::vector<QRgb> & pos | void ImageDisplay::SetColorScales( std::vector<QRgb> & positi |
---|
1491 | std::vector<QRgb> & negati std::vector<QRgb> & negati |
---|
1492 | { { |
---|
1493 | this->positive_color_table.resize( positive_color_table.siz this->positive_color_table.resize( positive_color_table.siz |
---|
1494 | for ( size_t i = 0; i < positive_color_table.size(); i++ ) for ( size_t i = 0; i < positive_color_table.size(); i++ ) |
---|
1495 | { { |
---|
1496 | this->positive_color_table[i] = positive_color_table[i]; this->positive_color_table[i] = positive_color_table[i]; |
---|
1497 | } } |
---|
1498 | |
---|
1499 | this->negative_color_table.resize( negative_color_table.siz this->negative_color_table.resize( negative_color_table.siz |
---|
1500 | for ( size_t i = 0; i < negative_color_table.size(); i++ ) for ( size_t i = 0; i < negative_color_table.size(); i++ ) |
---|
1501 | { { |
---|
1502 | this->negative_color_table[i] = negative_color_table[i]; this->negative_color_table[i] = negative_color_table[i]; |
---|
1503 | } } |
---|
1504 | |
---|
1505 | UpdateImage(); UpdateImage(); |
---|
1506 | } } |
---|
1507 | |
---|
1508 | |
---|
1509 | /** /** |
---|
1510 | * Change the control parameter (0...100) used to brighten t * Change the control parameter (0...100) used to brighten t |
---|
1511 | * If the control parameter is 0, the mapping from data valu * If the control parameter is 0, the mapping from data valu |
---|
1512 | * table index will be linear. As the control parameter is * table index will be linear. As the control parameter is |
---|
1513 | * the mapping becomes more and more non-linear in a way tha * the mapping becomes more and more non-linear in a way tha |
---|
1514 | * the lower level values. This is similar to a log intensi * the lower level values. This is similar to a log intensi |
---|
1515 | * * |
---|
1516 | * @param control_parameter This is clamped between 0 (line * @param control_parameter This is clamped between 0 (line |
---|
1517 | * 100 (most emphasis on low inten * 100 (most emphasis on low inten |
---|
1518 | */ */ |
---|
1519 | void RefImageDisplay::SetIntensity( double control_parameter | void ImageDisplay::SetIntensity( double control_parameter ) |
---|
1520 | { { |
---|
1521 | size_t DEFAULT_SIZE = 100000; size_t DEFAULT_SIZE = 100000; |
---|
1522 | ColorMaps::GetIntensityMap( control_parameter, DEFAULT_SIZE ColorMaps::GetIntensityMap( control_parameter, DEFAULT_SIZE |
---|
1523 | image_plot_item->SetIntensityTable( &intensity_table ); image_plot_item->SetIntensityTable( &intensity_table ); |
---|
1524 | UpdateImage(); UpdateImage(); |
---|
1525 | } } |
---|
1526 | |
---|
1527 | |
---|
1528 | /** /** |
---|
1529 | * Extract data from horizontal and vertical cuts across the * Extract data from horizontal and vertical cuts across the |
---|
1530 | * show those as graphs in the horizontal and vertical graphs * show those as graphs in the horizontal and vertical graphs |
---|
1531 | * information about the specified point. * information about the specified point. |
---|
1532 | * * |
---|
1533 | * @param point The point that the user is currently pointin * @param point The point that the user is currently pointin |
---|
1534 | * the mouse. * the mouse. |
---|
1535 | */ */ |
---|
1536 | void RefImageDisplay::SetPointedAtPoint( QPoint point, int mo | void ImageDisplay::SetPointedAtPoint( QPoint point ) |
---|
1537 | { { |
---|
1538 | if ( data_source == 0 || data_array == 0 ) if ( data_source == 0 || data_array == 0 ) |
---|
1539 | { { |
---|
1540 | return; return; |
---|
1541 | } } |
---|
1542 | |
---|
1543 | double x = image_plot->invTransform( QwtPlot::xBottom, poin double x = image_plot->invTransform( QwtPlot::xBottom, poin |
---|
1544 | double y = image_plot->invTransform( QwtPlot::yLeft, point. double y = image_plot->invTransform( QwtPlot::yLeft, point. |
---|
1545 | |
---|
1546 | SetHGraph( y ); SetHGraph( y ); |
---|
1547 | SetVGraph( x ); SetVGraph( x ); |
---|
1548 | |
---|
1549 | ShowInfoList( x, y ); ShowInfoList( x, y ); |
---|
1550 | if (mouseClick == 1) //left click < |
---|
1551 | { < |
---|
1552 | ShowPeakBackSelectionValue(x, y); < |
---|
1553 | } < |
---|
1554 | < |
---|
1555 | } } |
---|
1556 | |
---|
1557 | /* /* |
---|
1558 | * Extract data for Horizontal graph from the image at the s * Extract data for Horizontal graph from the image at the s |
---|
1559 | * If the y value is NOT in the y-interval covered by the da * If the y value is NOT in the y-interval covered by the da |
---|
1560 | * return. * return. |
---|
1561 | * * |
---|
1562 | * @param y The y-value of the horizontal cut through the * @param y The y-value of the horizontal cut through the |
---|
1563 | */ */ |
---|
1564 | void RefImageDisplay::SetHGraph( double y ) | void ImageDisplay::SetHGraph( double y ) |
---|
1565 | { { |
---|
1566 | if ( y < data_array->GetYMin() || y > data_array->GetYMax() if ( y < data_array->GetYMin() || y > data_array->GetYMax() |
---|
1567 | { { |
---|
1568 | h_graph_display->Clear(); h_graph_display->Clear(); |
---|
1569 | return; return; |
---|
1570 | } } |
---|
1571 | |
---|
1572 | pointed_at_y = y; pointed_at_y = y; |
---|
1573 | |
---|
1574 | float *data = data_array->GetData(); float *data = data_array->GetData(); |
---|
1575 | |
---|
1576 | size_t n_cols = data_array->GetNCols(); size_t n_cols = data_array->GetNCols(); |
---|
1577 | |
---|
1578 | double x_min = data_array->GetXMin(); double x_min = data_array->GetXMin(); |
---|
1579 | double x_max = data_array->GetXMax(); double x_max = data_array->GetXMax(); |
---|
1580 | |
---|
1581 | size_t row = data_array->RowOfY( y ); size_t row = data_array->RowOfY( y ); |
---|
1582 | |
---|
1583 | QVector<double> xData; QVector<double> xData; |
---|
1584 | QVector<double> yData; QVector<double> yData; |
---|
1585 | |
---|
1586 | double x_val; double x_val; |
---|
1587 | xData.push_back( x_min ); // s xData.push_back( x_min ); // s |
---|
1588 | yData.push_back( data[ row * n_cols ] ); yData.push_back( data[ row * n_cols ] ); |
---|
1589 | for ( size_t col = 0; col < n_cols; col++ ) for ( size_t col = 0; col < n_cols; col++ ) |
---|
1590 | { { |
---|
1591 | x_val = data_array->XOfColumn( col ); x_val = data_array->XOfColumn( col ); |
---|
1592 | xData.push_back( x_val ); // ma xData.push_back( x_val ); // ma |
---|
1593 | yData.push_back( data[ row * n_cols + col ] ); // ce yData.push_back( data[ row * n_cols + col ] ); // ce |
---|
1594 | } } |
---|
1595 | xData.push_back( x_max ); // en xData.push_back( x_max ); // en |
---|
1596 | yData.push_back( data[ row * n_cols + n_cols-1 ] ); yData.push_back( data[ row * n_cols + n_cols-1 ] ); |
---|
1597 | |
---|
1598 | h_graph_display->SetLogX( data_array->IsLogX() ); h_graph_display->SetLogX( data_array->IsLogX() ); |
---|
1599 | h_graph_display->SetData( xData, yData, y ); h_graph_display->SetData( xData, yData, y ); |
---|
1600 | } } |
---|
1601 | |
---|
1602 | |
---|
1603 | /* /* |
---|
1604 | * Extract data for vertical graph from the image at the spe * Extract data for vertical graph from the image at the spe |
---|
1605 | * If the x value is NOT in the x-interval covered by the da * If the x value is NOT in the x-interval covered by the da |
---|
1606 | * return. * return. |
---|
1607 | * * |
---|
1608 | * @param x The x-value of the vertical cut through the im * @param x The x-value of the vertical cut through the im |
---|
1609 | */ */ |
---|
1610 | void RefImageDisplay::SetVGraph( double x ) | void ImageDisplay::SetVGraph( double x ) |
---|
1611 | { { |
---|
1612 | if ( x < data_array->GetXMin() || x > data_array->GetXMax() if ( x < data_array->GetXMin() || x > data_array->GetXMax() |
---|
1613 | { { |
---|
1614 | v_graph_display->Clear(); v_graph_display->Clear(); |
---|
1615 | return; return; |
---|
1616 | } } |
---|
1617 | |
---|
1618 | pointed_at_x = x; pointed_at_x = x; |
---|
1619 | |
---|
1620 | float *data = data_array->GetData(); float *data = data_array->GetData(); |
---|
1621 | |
---|
1622 | size_t n_rows = data_array->GetNRows(); size_t n_rows = data_array->GetNRows(); |
---|
1623 | size_t n_cols = data_array->GetNCols(); size_t n_cols = data_array->GetNCols(); |
---|
1624 | |
---|
1625 | double y_min = data_array->GetYMin(); double y_min = data_array->GetYMin(); |
---|
1626 | double y_max = data_array->GetYMax(); double y_max = data_array->GetYMax(); |
---|
1627 | |
---|
1628 | size_t col = data_array->ColumnOfX( x ); size_t col = data_array->ColumnOfX( x ); |
---|
1629 | |
---|
1630 | QVector<double> v_xData; QVector<double> v_xData; |
---|
1631 | QVector<double> v_yData; QVector<double> v_yData; |
---|
1632 | |
---|
1633 | double y_val; double y_val; |
---|
1634 | v_yData.push_back( y_min ); // start at v_yData.push_back( y_min ); // start at |
---|
1635 | v_xData.push_back( data[col] ); v_xData.push_back( data[col] ); |
---|
1636 | for ( size_t row = 0; row < n_rows; row++ ) // mark dat for ( size_t row = 0; row < n_rows; row++ ) // mark dat |
---|
1637 | { { |
---|
1638 | y_val = data_array->YOfRow( row ); y_val = data_array->YOfRow( row ); |
---|
1639 | v_yData.push_back( y_val ); v_yData.push_back( y_val ); |
---|
1640 | v_xData.push_back( data[ row * n_cols + col ] ); v_xData.push_back( data[ row * n_cols + col ] ); |
---|
1641 | } } |
---|
1642 | v_yData.push_back( y_max ); // end at y v_yData.push_back( y_max ); // end at y |
---|
1643 | v_xData.push_back( data[ (n_rows-1) * n_cols + col] ); v_xData.push_back( data[ (n_rows-1) * n_cols + col] ); |
---|
1644 | |
---|
1645 | v_graph_display->SetData( v_xData, v_yData, x ); v_graph_display->SetData( v_xData, v_yData, x ); |
---|
1646 | } } |
---|
1647 | |
---|
1648 | |
---|
1649 | /** /** |
---|
1650 | * Get the information about a pointed at location and show * Get the information about a pointed at location and show |
---|
1651 | * table. * table. |
---|
1652 | * * |
---|
1653 | * @param x The x coordinate of the pointed at location on * @param x The x coordinate of the pointed at location on |
---|
1654 | * @param y The y coordinate of the pointed at location on * @param y The y coordinate of the pointed at location on |
---|
1655 | */ */ |
---|
1656 | void RefImageDisplay::ShowInfoList( double x, double y ) | void ImageDisplay::ShowInfoList( double x, double y ) |
---|
1657 | { { |
---|
1658 | std::vector<std::string> info_list; std::vector<std::string> info_list; |
---|
1659 | data_source->GetInfoList( x, y, info_list ); data_source->GetInfoList( x, y, info_list ); |
---|
1660 | int n_infos = (int)info_list.size() / 2; int n_infos = (int)info_list.size() / 2; |
---|
1661 | |
---|
1662 | image_table->setRowCount(n_infos + 1); image_table->setRowCount(n_infos + 1); |
---|
1663 | image_table->setColumnCount(2); image_table->setColumnCount(2); |
---|
1664 | image_table->verticalHeader()->hide(); image_table->verticalHeader()->hide(); |
---|
1665 | image_table->horizontalHeader()->hide(); image_table->horizontalHeader()->hide(); |
---|
1666 | |
---|
1667 | int width = 9; int width = 9; |
---|
1668 | int prec = 3; int prec = 3; |
---|
1669 | |
---|
1670 | double value = data_array->GetValue( x, y ); double value = data_array->GetValue( x, y ); |
---|
1671 | QtUtils::SetTableEntry( 0, 0, "Value", image_table ); QtUtils::SetTableEntry( 0, 0, "Value", image_table ); |
---|
1672 | QtUtils::SetTableEntry( 0, 1, width, prec, value, image_tab QtUtils::SetTableEntry( 0, 1, width, prec, value, image_tab |
---|
1673 | |
---|
1674 | for ( int i = 0; i < n_infos; i++ ) for ( int i = 0; i < n_infos; i++ ) |
---|
1675 | { { |
---|
1676 | QtUtils::SetTableEntry( i+1, 0, info_list[2*i], image_tab QtUtils::SetTableEntry( i+1, 0, info_list[2*i], image_tab |
---|
1677 | QtUtils::SetTableEntry( i+1, 1, info_list[2*i+1], image_t QtUtils::SetTableEntry( i+1, 1, info_list[2*i+1], image_t |
---|
1678 | } } |
---|
1679 | |
---|
1680 | image_table->resizeColumnsToContents(); image_table->resizeColumnsToContents(); |
---|
1681 | } } |
---|
1682 | |
---|
1683 | /** < |
---|
1684 | * Get the information about a pointed at location and show i < |
---|
1685 | * peak and background boxes < |
---|
1686 | * < |
---|
1687 | * @param y The y coordinate of the pointed at location on t < |
---|
1688 | */ < |
---|
1689 | void RefImageDisplay::ShowPeakBackSelectionValue(double x, do < |
---|
1690 | { < |
---|
1691 | < |
---|
1692 | // QString yValue = QString::number(int(y)); < |
---|
1693 | QString yValue = QString("%1").arg(int(y)); < |
---|
1694 | if (radioButtonPeakLeft->isChecked()) { //peak left selec < |
---|
1695 | lineEditPeakLeft->setText(yValue); < |
---|
1696 | RefImageDisplay::peakLeft = static_cast<int>(y); < |
---|
1697 | } < |
---|
1698 | if (radioButtonPeakRight->isChecked()) { //peak right sel < |
---|
1699 | lineEditPeakRight->setText(yValue); < |
---|
1700 | RefImageDisplay::peakRight = static_cast<int>(y); < |
---|
1701 | } < |
---|
1702 | if (radioButtonBackLeft->isChecked()) { //back left selec < |
---|
1703 | lineEditBackLeft->setText(yValue); < |
---|
1704 | RefImageDisplay::backLeft = static_cast<int>(y); < |
---|
1705 | } < |
---|
1706 | if (radioButtonBackRight->isChecked()) { //back right sel < |
---|
1707 | lineEditBackRight->setText(yValue); < |
---|
1708 | RefImageDisplay::backRight = static_cast<int>(y); < |
---|
1709 | } < |
---|
1710 | < |
---|
1711 | QString xValue = QString("%1").arg(int(x)); < |
---|
1712 | if (radioButtonTOFmin->isChecked()) { //tof min selected < |
---|
1713 | lineEditTOFmin->setText(xValue); < |
---|
1714 | RefImageDisplay::TOFmin = static_cast<int>(x); < |
---|
1715 | } < |
---|
1716 | if (radioButtonTOFmax->isChecked()) { // tof max selected < |
---|
1717 | lineEditTOFmax->setText(xValue); < |
---|
1718 | RefImageDisplay::TOFmax = static_cast<int>(x); < |
---|
1719 | } < |
---|
1720 | < |
---|
1721 | UpdateImage(); //force refresh of the plot < |
---|
1722 | } < |
---|
1723 | < |
---|
1724 | int RefImageDisplay::peakLeft = 0; < |
---|
1725 | int RefImageDisplay::peakRight = 0; < |
---|
1726 | int RefImageDisplay::backLeft = 0; < |
---|
1727 | int RefImageDisplay::backRight = 0; < |
---|
1728 | int RefImageDisplay::TOFmin = 0; < |
---|
1729 | int RefImageDisplay::TOFmax = 0; < |
---|
1730 | < |
---|
1731 | /** < |
---|
1732 | * set the peak left < |
---|
1733 | */ < |
---|
1734 | void RefImageDisplay::setPeakLeft(int value) < |
---|
1735 | { < |
---|
1736 | peakLeft = value; < |
---|
1737 | } < |
---|
1738 | < |
---|
1739 | /** < |
---|
1740 | * set the peak right < |
---|
1741 | */ < |
---|
1742 | void RefImageDisplay::setPeakRight(int value) < |
---|
1743 | { < |
---|
1744 | peakRight = value; < |
---|
1745 | } < |
---|
1746 | < |
---|
1747 | /** < |
---|
1748 | * set the back left < |
---|
1749 | */ < |
---|
1750 | void RefImageDisplay::setBackLeft(int value) < |
---|
1751 | { < |
---|
1752 | backLeft = value; < |
---|
1753 | } < |
---|
1754 | < |
---|
1755 | /** < |
---|
1756 | * set the back right < |
---|
1757 | */ < |
---|
1758 | void RefImageDisplay::setBackRight(int value) < |
---|
1759 | { < |
---|
1760 | backRight = value; < |
---|
1761 | } < |
---|
1762 | < |
---|
1763 | /** < |
---|
1764 | * set the TOF min < |
---|
1765 | */ < |
---|
1766 | void RefImageDisplay::setTOFmin(int value) < |
---|
1767 | { < |
---|
1768 | TOFmin = value; < |
---|
1769 | } < |
---|
1770 | < |
---|
1771 | /** < |
---|
1772 | * set the TOF max < |
---|
1773 | */ < |
---|
1774 | void RefImageDisplay::setTOFmax(int value) < |
---|
1775 | { < |
---|
1776 | TOFmax = value; < |
---|
1777 | } < |
---|
1778 | < |
---|
1779 | /** < |
---|
1780 | * return the value of the peak left < |
---|
1781 | **/ < |
---|
1782 | int RefImageDisplay::getPeakLeft() < |
---|
1783 | { < |
---|
1784 | return peakLeft; < |
---|
1785 | } < |
---|
1786 | < |
---|
1787 | /** < |
---|
1788 | * return the value of the peak right < |
---|
1789 | **/ < |
---|
1790 | int RefImageDisplay::getPeakRight() < |
---|
1791 | { < |
---|
1792 | return peakRight; < |
---|
1793 | } < |
---|
1794 | < |
---|
1795 | /** < |
---|
1796 | * return the value of the back left < |
---|
1797 | **/ < |
---|
1798 | int RefImageDisplay::getBackLeft() < |
---|
1799 | { < |
---|
1800 | return backLeft; < |
---|
1801 | } < |
---|
1802 | < |
---|
1803 | /** < |
---|
1804 | * return the value of the back right < |
---|
1805 | **/ < |
---|
1806 | int RefImageDisplay::getBackRight() < |
---|
1807 | { < |
---|
1808 | return backRight; < |
---|
1809 | } < |
---|
1810 | < |
---|
1811 | /** < |
---|
1812 | * return the value of the TOF min < |
---|
1813 | **/ < |
---|
1814 | int RefImageDisplay::getTOFmin() < |
---|
1815 | { < |
---|
1816 | return TOFmin; < |
---|
1817 | } < |
---|
1818 | < |
---|
1819 | /** < |
---|
1820 | * return the value of the TOF max < |
---|
1821 | **/ < |
---|
1822 | int RefImageDisplay::getTOFmax() < |
---|
1823 | { < |
---|
1824 | return TOFmax; < |
---|
1825 | } < |
---|
1826 | |
---|
1827 | /** /** |
---|
1828 | * Get the rectangle currently covered by the image in pixel * Get the rectangle currently covered by the image in pixel |
---|
1829 | * * |
---|
1830 | * @param rect A QRect object that will be filled out with * @param rect A QRect object that will be filled out with |
---|
1831 | * and height of the pixel region covered by th * and height of the pixel region covered by th |
---|
1832 | */ */ |
---|
1833 | void RefImageDisplay::GetDisplayRectangle( QRect &rect ) | void ImageDisplay::GetDisplayRectangle( QRect &rect ) |
---|
1834 | { { |
---|
1835 | QwtScaleMap xMap = image_plot->canvasMap( QwtPlot::xBottom QwtScaleMap xMap = image_plot->canvasMap( QwtPlot::xBottom |
---|
1836 | QwtScaleMap yMap = image_plot->canvasMap( QwtPlot::yLeft ); QwtScaleMap yMap = image_plot->canvasMap( QwtPlot::yLeft ); |
---|
1837 | |
---|
1838 | double x_min = data_array->GetXMin(); double x_min = data_array->GetXMin(); |
---|
1839 | double x_max = data_array->GetXMax(); double x_max = data_array->GetXMax(); |
---|
1840 | double y_min = data_array->GetYMin(); double y_min = data_array->GetYMin(); |
---|
1841 | double y_max = data_array->GetYMax(); double y_max = data_array->GetYMax(); |
---|
1842 | |
---|
1843 | int pix_x_min = (int)xMap.transform( x_min ); int pix_x_min = (int)xMap.transform( x_min ); |
---|
1844 | int pix_x_max = (int)xMap.transform( x_max ); int pix_x_max = (int)xMap.transform( x_max ); |
---|
1845 | int pix_y_min = (int)yMap.transform( y_min ); int pix_y_min = (int)yMap.transform( y_min ); |
---|
1846 | int pix_y_max = (int)yMap.transform( y_max ); int pix_y_max = (int)yMap.transform( y_max ); |
---|
1847 | |
---|
1848 | rect.setLeft ( pix_x_min ); rect.setLeft ( pix_x_min ); |
---|
1849 | rect.setRight ( pix_x_max ); rect.setRight ( pix_x_max ); |
---|
1850 | rect.setBottom( pix_y_min ); rect.setBottom( pix_y_min ); |
---|
1851 | rect.setTop ( pix_y_max ); rect.setTop ( pix_y_max ); |
---|
1852 | |
---|
1853 | if ( rect.height() <= 1 || // must not have been dra if ( rect.height() <= 1 || // must not have been dra |
---|
1854 | rect.width() <= 1 ) // some reasonable defaul rect.width() <= 1 ) // some reasonable defaul |
---|
1855 | { { |
---|
1856 | rect.setLeft ( 6 ); rect.setLeft ( 6 ); |
---|
1857 | rect.setRight ( 440 ); rect.setRight ( 440 ); |
---|
1858 | rect.setBottom( 440 ); rect.setBottom( 440 ); |
---|
1859 | rect.setTop ( 6 ); rect.setTop ( 6 ); |
---|
1860 | } } |
---|
1861 | } } |
---|
1862 | |
---|
1863 | |
---|
1864 | bool RefImageDisplay::DataSourceRangeChanged() | bool ImageDisplay::DataSourceRangeChanged() |
---|
1865 | { { |
---|
1866 | if ( total_y_min != data_source->GetYMin() || if ( total_y_min != data_source->GetYMin() || |
---|
1867 | total_y_max != data_source->GetYMax() || total_y_max != data_source->GetYMax() || |
---|
1868 | total_x_min != data_source->GetXMin() || total_x_min != data_source->GetXMin() || |
---|
1869 | total_x_max != data_source->GetXMax() ) total_x_max != data_source->GetXMax() ) |
---|
1870 | { { |
---|
1871 | return true; return true; |
---|
1872 | } } |
---|
1873 | else else |
---|
1874 | { { |
---|
1875 | return false; return false; |
---|
1876 | } } |
---|
1877 | } } |
---|
1878 | |
---|
1879 | > |
---|
1880 | } // namespace MantidQt } // namespace MantidQt |
---|
1881 | } // namespace ImageView } // namespace ImageView |
---|
1882 | >>>>>>>>>>>>> SliderHandler.h <<<<<<<<<<<<< |
---|
1883 | 6,8c6,8 |
---|
1884 | < #include "ui_RefImageView.h" |
---|
1885 | < #include "MantidQtRefDetectorViewer/RefImageDataSource.h" |
---|
1886 | < #include "MantidQtRefDetectorViewer/DllOptionIV.h" |
---|
1887 | --- |
---|
1888 | > #include "ui_ImageView.h" |
---|
1889 | > #include "MantidQtImageViewer/ImageDataSource.h" |
---|
1890 | > #include "MantidQtImageViewer/DllOptionIV.h" |
---|
1891 | 42c42 |
---|
1892 | < namespace RefDetectorViewer |
---|
1893 | --- |
---|
1894 | > namespace ImageView |
---|
1895 | 51c51 |
---|
1896 | < SliderHandler( Ui_RefImageViewer* iv_ui ); |
---|
1897 | --- |
---|
1898 | > SliderHandler( Ui_ImageViewer* iv_ui ); |
---|
1899 | 55c55 |
---|
1900 | < RefImageDataSource* data_source ); |
---|
1901 | --- |
---|
1902 | > ImageDataSource* data_source ); |
---|
1903 | 80c80 |
---|
1904 | < Ui_RefImageViewer* iv_ui; |
---|
1905 | --- |
---|
1906 | > Ui_ImageViewer* iv_ui; |
---|
1907 | >>>>>>>>>>>>> SliderHandler.cpp <<<<<<<<<<<<< |
---|
1908 | 5c5 |
---|
1909 | < #include "MantidQtRefDetectorViewer/SliderHandler.h" |
---|
1910 | --- |
---|
1911 | > #include "MantidQtImageViewer/SliderHandler.h" |
---|
1912 | 9c9 |
---|
1913 | < namespace RefDetectorViewer |
---|
1914 | --- |
---|
1915 | > namespace ImageView |
---|
1916 | 16c16 |
---|
1917 | < SliderHandler::SliderHandler( Ui_RefImageViewer* iv_ui ) |
---|
1918 | --- |
---|
1919 | > SliderHandler::SliderHandler( Ui_ImageViewer* iv_ui ) |
---|
1920 | 30c30 |
---|
1921 | < RefImageDataSource* data_source ) |
---|
1922 | --- |
---|
1923 | > ImageDataSource* data_source ) |
---|
1924 | >>>>>>>>>>>>> RangeHandler.h <<<<<<<<<<<<< |
---|
1925 | 4,6c4,6 |
---|
1926 | < #include "ui_RefImageView.h" |
---|
1927 | < #include "MantidQtRefDetectorViewer/RefImageDataSource.h" |
---|
1928 | < #include "MantidQtRefDetectorViewer/DllOptionIV.h" |
---|
1929 | --- |
---|
1930 | > #include "ui_ImageView.h" |
---|
1931 | > #include "MantidQtImageViewer/ImageDataSource.h" |
---|
1932 | > #include "MantidQtImageViewer/DllOptionIV.h" |
---|
1933 | 40c40 |
---|
1934 | < namespace RefDetectorViewer |
---|
1935 | --- |
---|
1936 | > namespace ImageView |
---|
1937 | 49c49 |
---|
1938 | < RangeHandler( Ui_RefImageViewer* iv_ui ); |
---|
1939 | --- |
---|
1940 | > RangeHandler( Ui_ImageViewer* iv_ui ); |
---|
1941 | 52c52 |
---|
1942 | < void ConfigureRangeControls( RefImageDataSource* data_source ); |
---|
1943 | --- |
---|
1944 | > void ConfigureRangeControls( ImageDataSource* data_source ); |
---|
1945 | 58c58 |
---|
1946 | < void SetRange( double min, double max, double step, char type ); |
---|
1947 | --- |
---|
1948 | > void SetRange( double min, double max, double step ); |
---|
1949 | 61c61 |
---|
1950 | < Ui_RefImageViewer* iv_ui; |
---|
1951 | --- |
---|
1952 | > Ui_ImageViewer* iv_ui; |
---|
1953 | 64,65d63 |
---|
1954 | < double total_max_y; |
---|
1955 | < double total_min_y; |
---|
1956 | >>>>>>>>>>>>> RangeHandler.cpp <<<<<<<<<<<<< |
---|
1957 | |
---|
1958 | #include <iostream> #include <iostream> |
---|
1959 | #include <QLineEdit> #include <QLineEdit> |
---|
1960 | |
---|
1961 | #include "MantidQtRefDetectorViewer/RangeHandler.h" | #include "MantidQtImageViewer/RangeHandler.h" |
---|
1962 | #include "MantidQtRefDetectorViewer/QtUtils.h" | #include "MantidQtImageViewer/QtUtils.h" |
---|
1963 | #include "MantidQtRefDetectorViewer/IVUtils.h" | #include "MantidQtImageViewer/IVUtils.h" |
---|
1964 | #include "MantidQtRefDetectorViewer/ErrorHandler.h" | #include "MantidQtImageViewer/ErrorHandler.h" |
---|
1965 | |
---|
1966 | namespace MantidQt namespace MantidQt |
---|
1967 | { { |
---|
1968 | namespace RefDetectorViewer | namespace ImageView |
---|
1969 | { { |
---|
1970 | |
---|
1971 | /** /** |
---|
1972 | * Construct a RangeHandler object to manage min, max and st * Construct a RangeHandler object to manage min, max and st |
---|
1973 | * in the specified UI * in the specified UI |
---|
1974 | */ */ |
---|
1975 | RangeHandler::RangeHandler( Ui_RefImageViewer* iv_ui ) | RangeHandler::RangeHandler( Ui_ImageViewer* iv_ui ) |
---|
1976 | { { |
---|
1977 | this->iv_ui = iv_ui; this->iv_ui = iv_ui; |
---|
1978 | } } |
---|
1979 | |
---|
1980 | |
---|
1981 | /** /** |
---|
1982 | * Configure the min, max and step controls for the specified * Configure the min, max and step controls for the specified |
---|
1983 | * * |
---|
1984 | * @param data_source ImageDataSource that provides the data * @param data_source ImageDataSource that provides the data |
---|
1985 | */ */ |
---|
1986 | void RangeHandler::ConfigureRangeControls( RefImageDataSource | void RangeHandler::ConfigureRangeControls( ImageDataSource* d |
---|
1987 | { { |
---|
1988 | |
---|
1989 | //x axis < |
---|
1990 | total_min_x = data_source->GetXMin(); total_min_x = data_source->GetXMin(); |
---|
1991 | total_max_x = data_source->GetXMax(); total_max_x = data_source->GetXMax(); |
---|
1992 | total_n_steps = data_source->GetNCols(); total_n_steps = data_source->GetNCols(); |
---|
1993 | total_min_y = data_source->GetYMin(); < |
---|
1994 | total_max_y = data_source->GetYMax(); < |
---|
1995 | |
---|
1996 | double defaultx_step = (total_max_x - total_min_x)/(double) | double default_step = (total_max_x - total_min_x)/(double)t |
---|
1997 | if ( total_n_steps > 2000 ) if ( total_n_steps > 2000 ) |
---|
1998 | { { |
---|
1999 | defaultx_step = (total_max_x - total_min_x)/2000.0; | default_step = (total_max_x - total_min_x)/2000.0; |
---|
2000 | } } |
---|
2001 | |
---|
2002 | SetRange( total_min_x, total_max_x, defaultx_step, 'x'); | SetRange( total_min_x, total_max_x, default_step ); |
---|
2003 | < |
---|
2004 | //y axis < |
---|
2005 | total_min_y = data_source->GetYMin(); < |
---|
2006 | total_max_y = data_source->GetYMax(); < |
---|
2007 | total_n_steps = data_source->GetNCols(); < |
---|
2008 | < |
---|
2009 | double defaulty_step = (total_max_y - total_min_y)/(doubl < |
---|
2010 | if ( total_n_steps > 2000 ) < |
---|
2011 | { < |
---|
2012 | defaulty_step = (total_max_y - total_min_y)/2000.0; < |
---|
2013 | } < |
---|
2014 | < |
---|
2015 | SetRange( total_min_y, total_max_y, defaulty_step, 'y' ); < |
---|
2016 | < |
---|
2017 | < |
---|
2018 | } } |
---|
2019 | |
---|
2020 | |
---|
2021 | /** /** |
---|
2022 | * Get the interval of values and the step size to use for re * Get the interval of values and the step size to use for re |
---|
2023 | * spectra. The range values are validated and adjusted if n * spectra. The range values are validated and adjusted if n |
---|
2024 | * range values that are returned by this method will also be * range values that are returned by this method will also be |
---|
2025 | * the controls. * the controls. |
---|
2026 | * * |
---|
2027 | * @param min On input, this should be the default value * @param min On input, this should be the default value |
---|
2028 | * min should be set to, if getting the range * min should be set to, if getting the range |
---|
2029 | * On output this is will be set to the x valu * On output this is will be set to the x valu |
---|
2030 | * left edge of the first bin to display, if g * left edge of the first bin to display, if g |
---|
2031 | * range succeeds. * range succeeds. |
---|
2032 | * @param max On input, this should be the default value * @param max On input, this should be the default value |
---|
2033 | * max should be set to if getting the range f * max should be set to if getting the range f |
---|
2034 | * On output, if getting the range succeeds, t * On output, if getting the range succeeds, t |
---|
2035 | * be set an x value at the right edge of the * be set an x value at the right edge of the |
---|
2036 | * to display. This will be adjusted so that * to display. This will be adjusted so that |
---|
2037 | * than min by an integer number of steps. * than min by an integer number of steps. |
---|
2038 | * @param step On input this should be the default number * @param step On input this should be the default number |
---|
2039 | * to use if getting the range information fai * to use if getting the range information fai |
---|
2040 | * On output, this is size of the step to use * On output, this is size of the step to use |
---|
2041 | * min and max. If it is less than zero, a lo * min and max. If it is less than zero, a lo |
---|
2042 | * is requested. * is requested. |
---|
2043 | */ */ |
---|
2044 | void RangeHandler::GetRange( double &min, double &max, double void RangeHandler::GetRange( double &min, double &max, double |
---|
2045 | { | { |
---|
2046 | double original_min = min; | double original_min = min; |
---|
2047 | double original_max = max; double original_max = max; |
---|
2048 | double original_step = step; double original_step = step; |
---|
2049 | |
---|
2050 | QLineEdit* min_control = iv_ui->x_min_input; QLineEdit* min_control = iv_ui->x_min_input; |
---|
2051 | QLineEdit* max_control = iv_ui->x_max_input; QLineEdit* max_control = iv_ui->x_max_input; |
---|
2052 | // QLineEdit* step_control = iv_ui->step_input; | QLineEdit* step_control = iv_ui->step_input; |
---|
2053 | |
---|
2054 | if ( !IVUtils::StringToDouble( min_control->text().toStdSt if ( !IVUtils::StringToDouble( min_control->text().toStdSt |
---|
2055 | { { |
---|
2056 | ErrorHandler::Error("X Min is not a NUMBER! Value reset." ErrorHandler::Error("X Min is not a NUMBER! Value reset." |
---|
2057 | min = original_min; min = original_min; |
---|
2058 | } } |
---|
2059 | if ( !IVUtils::StringToDouble( max_control->text().toStdSt if ( !IVUtils::StringToDouble( max_control->text().toStdSt |
---|
2060 | { { |
---|
2061 | ErrorHandler::Error("X Max is not a NUMBER! Value reset." ErrorHandler::Error("X Max is not a NUMBER! Value reset." |
---|
2062 | max = original_max; max = original_max; |
---|
2063 | } } |
---|
2064 | // if ( !IVUtils::StringToDouble( step_control->text().toSt | if ( !IVUtils::StringToDouble( step_control->text().toStdS |
---|
2065 | // { | { |
---|
2066 | // ErrorHandler::Error("Step is not a NUMBER! Value reset. | ErrorHandler::Error("Step is not a NUMBER! Value reset.") |
---|
2067 | // step = original_step; | step = original_step; |
---|
2068 | // } | } |
---|
2069 | |
---|
2070 | // just require step to be n // just require step to be n |
---|
2071 | // bounds. If zero, take a d // bounds. If zero, take a d |
---|
2072 | if ( step == 0 ) if ( step == 0 ) |
---|
2073 | { { |
---|
2074 | ErrorHandler::Error("Step = 0, resetting to default step" ErrorHandler::Error("Step = 0, resetting to default step" |
---|
2075 | step = original_step; step = original_step; |
---|
2076 | } } |
---|
2077 | |
---|
2078 | if ( step > 0 ) if ( step > 0 ) |
---|
2079 | { { |
---|
2080 | if ( !IVUtils::FindValidInterval( min, max ) ) if ( !IVUtils::FindValidInterval( min, max ) ) |
---|
2081 | { { |
---|
2082 | ErrorHandler::Warning( ErrorHandler::Warning( |
---|
2083 | "In GetRange: [Min,Max] interval invalid, values "In GetRange: [Min,Max] interval invalid, values |
---|
2084 | min = original_min; min = original_min; |
---|
2085 | max = original_max; max = original_max; |
---|
2086 | step = original_step; step = original_step; |
---|
2087 | } } |
---|
2088 | } } |
---|
2089 | else else |
---|
2090 | { { |
---|
2091 | if ( !IVUtils::FindValidLogInterval( min, max ) ) if ( !IVUtils::FindValidLogInterval( min, max ) ) |
---|
2092 | { { |
---|
2093 | ErrorHandler::Warning( ErrorHandler::Warning( |
---|
2094 | "In GetRange: [Min,Max] log interval invalid, value "In GetRange: [Min,Max] log interval invalid, value |
---|
2095 | min = original_min; min = original_min; |
---|
2096 | max = original_max; max = original_max; |
---|
2097 | step = original_step; step = original_step; |
---|
2098 | } } |
---|
2099 | } } |
---|
2100 | |
---|
2101 | SetRange( min, max, step, 'x' ); | SetRange( min, max, step ); |
---|
2102 | } } |
---|
2103 | |
---|
2104 | |
---|
2105 | /** /** |
---|
2106 | * Adjust the values to be consistent with the available data * Adjust the values to be consistent with the available data |
---|
2107 | * diplay them in the controls. * diplay them in the controls. |
---|
2108 | * * |
---|
2109 | * @param min This is the x value at the left edge of the * @param min This is the x value at the left edge of the |
---|
2110 | * @param max This is an x value at the right edge of the * @param max This is an x value at the right edge of the |
---|
2111 | * @param step This is size of the step to use between min * @param step This is size of the step to use between min |
---|
2112 | * If it is less than zero, a log scale is req * If it is less than zero, a log scale is req |
---|
2113 | */ */ |
---|
2114 | void RangeHandler::SetRange( double min, double max, double s | void RangeHandler::SetRange( double min, double max, double s |
---|
2115 | { { |
---|
2116 | if (type == 'x') { < |
---|
2117 | < |
---|
2118 | if ( !IVUtils::FindValidInterval( min, max ) ) if ( !IVUtils::FindValidInterval( min, max ) ) |
---|
2119 | { { |
---|
2120 | ErrorHandler::Warning( ErrorHandler::Warning( |
---|
2121 | "In SetRange: [XMin,XMax] interval invalid, value | "In SetRange: [Min,Max] interval invalid, values |
---|
2122 | } } |
---|
2123 | |
---|
2124 | if ( min < total_min_x || min > total_max_x ) if ( min < total_min_x || min > total_max_x ) |
---|
2125 | { { |
---|
2126 | // ErrorHandler::Warning("X Min out of range, resetting to // ErrorHandler::Warning("X Min out of range, resetting to |
---|
2127 | min = total_min_x; min = total_min_x; |
---|
2128 | } } |
---|
2129 | |
---|
2130 | if ( max < total_min_x || max > total_max_x ) if ( max < total_min_x || max > total_max_x ) |
---|
2131 | { { |
---|
2132 | // ErrorHandler::Warning("X Max out of range, resetting to // ErrorHandler::Warning("X Max out of range, resetting to |
---|
2133 | max = total_max_x; max = total_max_x; |
---|
2134 | } } |
---|
2135 | |
---|
2136 | if ( step == 0 ) if ( step == 0 ) |
---|
2137 | { { |
---|
2138 | ErrorHandler::Error("Step = 0, resetting to default step" ErrorHandler::Error("Step = 0, resetting to default step" |
---|
2139 | step = (max-min)/2000.0; step = (max-min)/2000.0; |
---|
2140 | } } |
---|
2141 | |
---|
2142 | QtUtils::SetText( 8, 2, min, iv_ui->x_min_input ); QtUtils::SetText( 8, 2, min, iv_ui->x_min_input ); |
---|
2143 | QtUtils::SetText( 8, 2, max, iv_ui->x_max_input ); QtUtils::SetText( 8, 2, max, iv_ui->x_max_input ); |
---|
2144 | // QtUtils::SetText( 8, 4, step, iv_ui->step_input ); | QtUtils::SetText( 8, 6, step, iv_ui->step_input ); |
---|
2145 | < |
---|
2146 | } < |
---|
2147 | < |
---|
2148 | if (type == 'y') { < |
---|
2149 | < |
---|
2150 | if ( !IVUtils::FindValidInterval( min, max ) ) < |
---|
2151 | { < |
---|
2152 | ErrorHandler::Warning( < |
---|
2153 | "In SetRange: [YMin,YMax] i < |
---|
2154 | } < |
---|
2155 | < |
---|
2156 | if ( min < total_min_y || min > total_max_y ) < |
---|
2157 | { < |
---|
2158 | // ErrorHandler::Warning("Y Min out of range, < |
---|
2159 | min = total_min_y; < |
---|
2160 | } < |
---|
2161 | < |
---|
2162 | if ( max < total_min_y || max > total_max_y ) < |
---|
2163 | { < |
---|
2164 | // ErrorHandler::Warning("Y Max out of range, < |
---|
2165 | max = total_max_y; < |
---|
2166 | } < |
---|
2167 | < |
---|
2168 | if ( step == 0 ) < |
---|
2169 | { < |
---|
2170 | ErrorHandler::Error("Step = 0, resetting to defau < |
---|
2171 | step = (max-min)/2000.0; < |
---|
2172 | } < |
---|
2173 | < |
---|
2174 | QtUtils::SetText( 8, 2, min, iv_ui->y_min_input ); < |
---|
2175 | QtUtils::SetText( 8, 2, max, iv_ui->y_max_input ); < |
---|
2176 | // QtUtils::SetText( 8, 4, step, iv_ui->step_input ) < |
---|
2177 | < |
---|
2178 | } < |
---|
2179 | < |
---|
2180 | } } |
---|
2181 | |
---|
2182 | |
---|
2183 | } // namespace MantidQt } // namespace MantidQt |
---|
2184 | } // namespace ImageView } // namespace ImageView |
---|