casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlotData.h
Go to the documentation of this file.
1 //# PlotData.h: Classes to represent data for plots.
2 //# Copyright (C) 2008
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: $
27 #ifndef PLOTDATA_H_
28 #define PLOTDATA_H_
29 
31 
32 #include <casa/Arrays/Matrix.h>
33 #include <casa/Arrays/Vector.h>
34 
35 #include <casa/BasicSL/String.h>
37 
38 namespace casa {
39 
40 // Typedef for a point, which is two doubles (x and y).
41 typedef std::pair<double, double> ppoint_t;
42 
44 // ABSTRACT CLASSES //
46 
47 // Deliberately vague to be general enough to allow for many different types
48 // of data, but is it too vague to be useful? Since the interface is meant
49 // to be a simple plotter, it may be better to restrict PlotData to be more
50 // like PlotPointData, which would eliminate possibilities for data like
51 // functions but would also eliminate a lot of vaguery.
52 class PlotData {
53 public:
54  PlotData() { }
55 
56  virtual ~PlotData() { }
57 
58 
59  // ABSTRACT METHODS //
60 
61  // Returns whether the contained data is valid or not.
62  virtual bool isValid() const = 0;
63 
64  // Returns whether this object will delete its underlying data structures
65  // upon deconstruction or not.
66  virtual bool willDeleteData() const = 0;
67 
68  // Sets whether this object will delete its underlying data structures upon
69  // deconstruction or not.
70  virtual void setDeleteData(bool del = true) = 0;
71 };
73 
74 
75 // A single source of data that basically provides indexing of its values.
76 class PlotSingleData : public virtual PlotData {
77 public:
79 
80  virtual ~PlotSingleData() { }
81 
82 
83  // ABSTRACT METHODS //
84 
85  // Returns the number of points.
86  virtual unsigned int size() const = 0;
87 
88  // Returns the value at given index.
89  virtual double at(unsigned int i) const = 0;
90 
91  // Gets the minimum and maximum values. Returns false for error.
92  virtual bool minMax(double& min, double& max) = 0;
93 };
94 INHERITANCE_POINTER2(PlotSingleData, PlotSingleDataPtr, PlotData, PlotDataPtr)
95 
96 
97 // A source of data used to supply x and y values. Basically consists of
98 // indexing its values.
99 class PlotPointData : public virtual PlotData {
100 public:
102 
103  virtual ~PlotPointData() { }
104 
105 
106  // ABSTRACT METHODS //
107 
108  // Returns the number of points.
109  virtual unsigned int size() const = 0;
110 
111  // Returns the x value at the given index.
112  virtual double xAt(unsigned int i) const = 0;
113 
114  // Returns the y value at the given index.
115  virtual double yAt(unsigned int i) const = 0;
116 
117  // Gets the minimum and maximum values. Returns false for error.
118  virtual bool minsMaxes(double& xMin, double& xMax, double& yMin,
119  double& yMax) = 0;
120 
121 
122  // IMPLEMENTED METHODS //
123 
124  // Gets the x and y values at the given index. Default implementation
125  // just calls xAt and yAt, but in subclasses where performance could be
126  // gained, this method should be overridden. Implementations for plots
127  // that use PlotPointData should use this method by default in case there
128  // are performance gains.
129  virtual void xAndYAt(unsigned int index, double& x, double& y) const;
130 };
131 INHERITANCE_POINTER2(PlotPointData, PlotPointDataPtr, PlotData, PlotDataPtr)
132 
133 
134 // casacore::Data that adds masking functionality on top of normal point data.
135 class PlotMaskedPointData : public virtual PlotPointData {
136 public:
138 
139  virtual ~PlotMaskedPointData() { }
140 
141 
142  // ABSTRACT METHODS //
143 
144  // Returns the number of masked points.
145  virtual unsigned int sizeMasked() const = 0;
146 
147  // Returns the number of unmasked points.
148  virtual unsigned int sizeUnmasked() const = 0;
149 
150  // Returns whether the data is masked at the given point or not.
151  virtual bool maskedAt(unsigned int index) const = 0;
152 
153  // Gets the mins/maxes for just the masked points.
154  virtual bool maskedMinsMaxes(double& xMin, double& xMax, double& yMin,
155  double& yMax) = 0;
156 
157  // Gets the mins/maxes for just the unmasked points.
158  virtual bool unmaskedMinsMaxes(double& xMin, double& xMax, double& yMin,
159  double& yMax) = 0;
160 
161  // Returns whether data is plotted in reverse order (right to left),
162  // needed when connecting points
163  virtual bool reverseConnect(unsigned int index) const = 0;
164 
165  // Returns whether to plot conjugate data (e.g. UV plots)
166  virtual bool plotConjugates() const = 0;
167 
168  // IMPLEMENTED METHODS //
169 
170  // Gets the x and y values and the mask at the given index. See
171  // PlotPointData::xAndYAt().
172  virtual void xyAndMaskAt(unsigned int index, double& x, double& y,
173  bool& mask) const;
174 };
176  PlotPointDataPtr, PlotData, PlotDataPtr)
177 
178 
179 // casacore::Data that adds error functionality on top of normal plot data.
180 class PlotErrorData : public virtual PlotPointData {
181 public:
182  PlotErrorData() { }
183 
184  virtual ~PlotErrorData() { }
185 
186 
187  // ABSTRACT METHODS //
188 
189  // Returns the "left" error for x at the given index.
190  virtual double xLeftErrorAt(unsigned int i) const = 0;
191 
192  // Returns the "right" error for x at the given index.
193  virtual double xRightErrorAt(unsigned int i) const = 0;
194 
195  // Returns the "bottom" error for y at the given index.
196  virtual double yBottomErrorAt(unsigned int i) const = 0;
197 
198  // Returns the "top" error for y at the given index.
199  virtual double yTopErrorAt(unsigned int i) const = 0;
200 
201  // Gets the maximum errors for the four sides.
202  virtual bool errorMaxes(double& xLeft, double& xRight, double& yBottom,
203  double& yTop) = 0;
204 
205 
206  // IMPLEMENTED METHODS //
207 
208  // Gets the x and y values and error data at the given index. See
209  // PlotPointData::xAndYAt().
210  virtual void xyAndErrorsAt(unsigned int index, double& x, double& y,
211  double& xLeftError, double& xRightError, double& yBottomError,
212  double& yTopError) const;
213 };
214 INHERITANCE_POINTER(PlotErrorData, PlotErrorDataPtr, PlotPointData,
216 
217 
218 // casacore::Data that differentiates different points into different "bins" on top of
219 // normal point data functionality.
220 class PlotBinnedData : public virtual PlotPointData {
221 public:
222  // Constructor.
223  PlotBinnedData() { }
224 
225  // Destructor.
226  virtual ~PlotBinnedData() { }
227 
228 
229  // ABSTRACT METHODS //
230 
231  // Returns the total number of bins that the data is in.
232  virtual unsigned int numBins() const = 0;
233 
234  // Returns the bin index number for the given index. MUST be between 0 and
235  // numBins().
236  virtual unsigned int binAt(unsigned int i) const = 0;
237  virtual unsigned int connectBinAt(unsigned int i) const {
238  return binAt(i); };
239 
240 
241  // IMPLEMENTED METHODS //
242 
243  // Returns true if the data is binned, false otherwise.
244  virtual bool isBinned() const { return numBins() > 1; }
245 };
246 INHERITANCE_POINTER(PlotBinnedData, PlotBinnedDataPtr, PlotPointData,
247  PlotDataPtr, PlotData, PlotDataPtr)
248 
249 
250 // casacore::Data for raster plots, which can be thought of as three-dimensional. Used
251 // for images, with the values being in one of the givne formats.
252 class PlotRasterData : public virtual PlotData {
253 public:
254  // casacore::Format that the data is in
255  enum Format {
256  RGB32, // data is an RBG integer, like 0x60A0C0
257  ARGB32, // data is an ARGB integer, like 0xFF60A0C0
258  SPECTROGRAM // data is meant for a spectrogram, not specific colors
259  };
260 
261  // Origin point of the data - in other words, where (0,0) is located
262  // visually on the canvas. Default is LLEFT.
263  enum Origin {
265  };
266 
267 
269 
270  virtual ~PlotRasterData() { }
271 
272 
273  // ABSTRACT METHODS //
274 
275  // Returns the data origin.
276  virtual Origin origin() const = 0;
277 
278  // Sets the data origin.
279  virtual void setOrigin(Origin o) = 0;
280 
281  // Returns the range of x.
282  virtual prange_t xRange() const = 0;
283 
284  // Returns the range of y.
285  virtual prange_t yRange() const = 0;
286 
287  // Sets the range of x.
288  virtual void setXRange(double from, double to) = 0;
289 
290  // Sets the range of y.
291  virtual void setYRange(double from, double to) = 0;
292 
293  // Returns the range of the data values.
294  virtual prange_t valueRange() const = 0;
295 
296  // Returns the data value at the given (x,y) coordinate.
297  virtual double valueAt(double x, double y) const = 0;
298 
299  // Gets color bar values.
300  virtual std::vector<double>* colorBarValues(unsigned int max = 1000) const = 0;
301 };
302 INHERITANCE_POINTER2(PlotRasterData, PlotRasterDataPtr, PlotData, PlotDataPtr)
303 
304 
305 // DEFAULT IMPLEMENTATIONS //
308 
309 // Default implementation of PlotSingleData that supports raw arrays, vectors,
310 // and CASA Vectors. The class is templated, but since data sources are
311 // expected in doubles it should be a numeric type that can be casted to a
312 // double.
313 template <class T>
314 class PlotSingleDataImpl : public virtual PlotSingleData {
315 public:
316  // Invalid data constructor.
317  PlotSingleDataImpl(): m_vector(NULL), m_cvector(NULL), m_array(NULL),
318  m_arraySize(0), m_shouldDelete(false) { }
319 
320  // casacore::Data using different standard containers.
321  // <group>
322  PlotSingleDataImpl(std::vector<T>& value, bool shouldDelete = false):
323  m_vector(&value), m_cvector(NULL), m_array(NULL), m_arraySize(0),
324  m_shouldDelete(shouldDelete) {
325  recalculateMinMax(); }
326  PlotSingleDataImpl(casacore::Vector<T>& value, bool shouldDelete = false):
327  m_vector(NULL), m_cvector(&value), m_array(NULL), m_arraySize(0),
328  m_shouldDelete(shouldDelete) {
329  recalculateMinMax(); }
330  PlotSingleDataImpl(T*& value, unsigned int size, bool shouldDelete= false):
331  m_vector(NULL), m_cvector(NULL), m_array(value), m_arraySize(size),
332  m_shouldDelete(shouldDelete) {
333  recalculateMinMax(); }
334  // </group>
335 
336  // Destructor.
338  if(m_shouldDelete) {
339  if(m_vector != NULL) delete m_vector;
340  if(m_cvector != NULL) delete m_cvector;
341  if(m_array != NULL) delete m_array;
342  }
343  }
344 
345 
346  // Implements PlotData::isValid().
347  bool isValid() const {
348  return m_vector != NULL || m_cvector != NULL || m_array != NULL; }
349 
350  // Implements PlotData::willDeleteData().
351  bool willDeleteData() const { return m_shouldDelete; }
352 
353  // Implements PlotData::setDeleteData().
354  void setDeleteData(bool del = true) { m_shouldDelete = del; }
355 
356  // Implements PlotSingleData::size().
357  unsigned int size() const {
358  if(m_vector != NULL) return m_vector->size();
359  if(m_cvector != NULL) return m_cvector->size();
360  if(m_array != NULL) return m_arraySize;
361  return 0;
362  }
363 
364  // Implements PlotSingleData::at().
365  double at(unsigned int i) const {
366  if(m_vector != NULL) return (double)(*m_vector)[i];
367  if(m_cvector != NULL) return (double)(*m_cvector)[i];
368  if(m_array != NULL) return (double)m_array[i];
369  return 0;
370  }
371 
372  // Implements PlotSingleData::minMax().
373  bool minMax(double& min, double& max) {
374  if(!isValid() || size() == 0) return false;
375  min = m_min; max = m_max;
376  return true;
377  }
378 
379  // Recalculates the cached min and max. Should be used if the underlying
380  // data structure changes.
382  if(!isValid()) return;
383  unsigned int n = size();
384  if(n == 0) return;
385  double temp = (double)at(0);
386  m_min = m_max = temp;
387  if(m_vector != NULL) {
388  for(unsigned int i = 1; i < n; i++) {
389  temp = (double)(*m_vector)[i];
390  if(temp < m_min) m_min = temp;
391  if(temp > m_max) m_max = temp;
392  }
393  } else if(m_cvector != NULL) {
394  for(unsigned int i = 1; i < n; i++) {
395  temp = (double)(*m_cvector)[i];
396  if(temp < m_min) m_min = temp;
397  if(temp > m_max) m_max = temp;
398  }
399  } else if(m_array != NULL) {
400  for(unsigned int i = 1; i < n; i++) {
401  temp = (double)m_array[i];
402  if(temp < m_min) m_min = temp;
403  if(temp > m_max) m_max = temp;
404  }
405  }
406  }
407 
408 private:
409  std::vector<T>* m_vector;
412  unsigned int m_arraySize;
414  double m_min, m_max;
415 };
416 
421 
422 
423 // Default implementation of PlotPointData that supports raw arrays, vectors,
424 // and CASA Vectors. The class is templated, but since data sources are
425 // expected in doubles it should be a numeric type that can be casted to a
426 // double. It can either be both x and y data, or just y data (where x is the
427 // index).
428 template <class T>
429 class PlotPointDataImpl : public virtual PlotPointData {
430 public:
431  // X/Y constructors.
432  // <group>
433  PlotPointDataImpl(std::vector<T>& x, std::vector<T>& y, bool shouldDelete = false) :
434  m_xData(x, shouldDelete), m_yData(y, shouldDelete) { }
435  PlotPointDataImpl(casacore::Vector<T>& x, casacore::Vector<T>& y, bool shouldDelete = false) :
436  m_xData(x, shouldDelete), m_yData(y, shouldDelete) { }
437  PlotPointDataImpl(T*& x, T*& y, unsigned int size, bool shouldDel = false):
438  m_xData(x, size, shouldDel), m_yData(y, size, shouldDel) { }
439  // </group>
440 
441  // Y constructors.
442  // <group>
443  PlotPointDataImpl(std::vector<T>& y, bool shouldDelete = false) :
444  m_yData(y, shouldDelete) { }
445  PlotPointDataImpl(casacore::Vector<T>& y, bool shouldDelete = false) :
446  m_yData(y, shouldDelete) { }
447  PlotPointDataImpl(T*& y, unsigned int size, bool shouldDel = false):
448  m_yData(y, size, shouldDel) { }
449  // </group>
450 
451  virtual ~PlotPointDataImpl() { }
452 
453 
454  // Implements PlotData::isValid().
455  bool isValid() const { return m_yData.isValid(); }
456 
457  // Implements PlotData::willDeleteData().
458  virtual bool willDeleteData() const {
459  return (m_yData.isValid() && m_yData.willDeleteData()) &&
460  (!m_xData.isValid() || m_xData.willDeleteData());
461  }
462 
463  // Implements PlotData::setDeleteData().
464  virtual void setDeleteData(bool del = true) {
465  if(m_xData.isValid()) m_xData.setDeleteData(del);
466  if(m_yData.isValid()) m_yData.setDeleteData(del);
467  }
468 
469  // Implements PlotPointData::size().
470  unsigned int size() const {
471  if(!m_xData.isValid()) return m_yData.size();
472  else return casacore::min(m_xData.size(), m_yData.size());
473  }
474 
475  // Implements PlotPointData::xAt(). If no x data is given, the index is
476  // returned.
477  double xAt(unsigned int i) const {
478  if(m_xData.isValid()) return m_xData.at(i);
479  else return i;
480  }
481 
482  // Implements PlotPointData::yAt().
483  double yAt(unsigned int i) const { return m_yData.at(i); }
484 
485  // Implements PlotPointData::minsMaxes().
486  bool minsMaxes(double& xMin, double& xMax, double& yMin, double& yMax) {
487  if(!m_xData.isValid()) {
488  xMin = 0;
489  xMax = m_yData.size();
490  return m_yData.minMax(yMin, yMax);
491  } else {
492  return m_xData.minMax(xMin, xMax) && m_yData.minMax(yMin, yMax);
493  }
494  }
495 
496 private:
499 };
500 
505 
506 
507 // Specialized subclass of PlotPointData that creates histogram data from
508 // single point data. A histogram divides up the data into a number of "bins"
509 // and then counts the number of data that falls into each bin. This class can
510 // act as both an interface for specializations or a concrete subclass of
511 // PlotPointData in itself.
512 class PlotHistogramData : public virtual PlotPointData {
513 public:
514  // Constructor which takes data and number of bins.
515  PlotHistogramData(PlotSingleDataPtr data, unsigned int numBins);
516 
517  // Destructor.
518  virtual ~PlotHistogramData();
519 
520 
521  // Implements PlotData::isValid().
522  virtual bool isValid() const;
523 
524  // Implements PlotData::willDeleteData().
525  virtual bool willDeleteData() const;
526 
527  // Implements PlotData::setDeleteData().
528  virtual void setDeleteData(bool del = true);
529 
530 
531  // Implements PlotPointData::size().
532  virtual unsigned int size() const { return numBins(); }
533 
534  // Implements PlotPointData::xAt().
535  virtual double xAt(unsigned int i) const;
536 
537  // Implements PlotPointData::yAt().
538  virtual double yAt(unsigned int i) const;
539 
540  // Implements PlotPointData::minsMaxes().
541  virtual bool minsMaxes(double& xMin, double& xMax, double& yMin,
542  double& yMax);
543 
544 
545  // Recalculates the histogram data into the given number of bins.
546  virtual void recalculateBins(unsigned int numBins);
547 
548  // Returns the current number of histogram bins.
549  virtual unsigned int numBins() const;
550 
551  // Returns the range at the given index.
552  virtual prange_t rangeAt(unsigned int i) const;
553 
554 private:
555  PlotSingleDataPtr m_data; // Data.
556  std::vector<unsigned int> m_bins; // Bins with count.
557  std::vector<prange_t> m_ranges; // Cached bin ranges.
558  unsigned int m_max; // Highest bin count.
559 };
560 
561 
562 // Default implementation of PlotMaskedPointData using default containers.
563 template <class T>
565  public PlotPointDataImpl<T> {
566 public:
567  // X/Y constructors.
568  // <group>
569  PlotMaskedPointDataImpl(std::vector<T>& x, std::vector<T>& y, std::vector<bool>& mask,
570  bool shouldDelete = false) :
571  PlotPointDataImpl<T>(x, y, shouldDelete), m_maskVector(&mask),
572  m_maskCVector(NULL), m_maskArray(NULL), m_maskArraySize(0),
573  m_shouldDeleteMask(shouldDelete) { }
575  bool shouldDelete = false) :
576  PlotPointDataImpl<T>(x, y, shouldDelete), m_maskVector(NULL),
577  m_maskCVector(&mask), m_maskArray(NULL), m_maskArraySize(0),
578  m_shouldDeleteMask(shouldDelete) { }
579  PlotMaskedPointDataImpl(T*& x, T*& y, bool*& mask, unsigned int size,
580  bool shouldDel = false) :
581  PlotPointDataImpl<T>(x, y, size, shouldDel), m_maskVector(NULL),
582  m_maskCVector(NULL), m_maskArray(mask), m_maskArraySize(size),
583  m_shouldDeleteMask(shouldDel) { }
584  // </group>
585 
586  // Y constructors.
587  // <group>
588  PlotMaskedPointDataImpl(std::vector<T>& y, std::vector<bool>& mask,
589  bool shouldDelete = false) :
590  PlotPointDataImpl<T>(y, shouldDelete), m_maskVector(&mask),
591  m_maskCVector(NULL), m_maskArray(NULL), m_maskArraySize(0),
592  m_shouldDeleteMask(shouldDelete) { }
594  bool shouldDelete = false) :
595  PlotPointDataImpl<T>(y, shouldDelete), m_maskVector(NULL),
596  m_maskCVector(&mask), m_maskArray(NULL), m_maskArraySize(0),
597  m_shouldDeleteMask(shouldDelete) { }
598  PlotMaskedPointDataImpl(T*& y, bool*& mask, unsigned int size,
599  bool shouldDel = false) :
600  PlotPointDataImpl<T>(y, size, shouldDel), m_maskVector(NULL),
601  m_maskCVector(NULL), m_maskArray(mask), m_maskArraySize(size),
602  m_shouldDeleteMask(shouldDel) { }
603  // </group>
604 
605  // Destructor.
607  if(m_shouldDeleteMask) {
608  if(m_maskVector != NULL) delete m_maskVector;
609  if(m_maskCVector != NULL) delete m_maskCVector;
610  if(m_maskArray != NULL) delete m_maskArray;
611  }
612  }
613 
614  virtual bool reverseConnect(unsigned int /*index*/) const { return false; };
615  virtual bool plotConjugates() const { return false; };
616 
617  // Overrides PlotPointDataImpl::willDeleteData().
618  bool willDeleteData() const {
620 
621  // Overrides PlotPointDataImpl::setDeleteData().
622  void setDeleteData(bool del = true) {
624  m_shouldDeleteMask = del;
625  }
626 
627  // Implements PlotMaskedPointData::sizeMasked().
628  unsigned int sizeMasked() const { return sizeMaskedOrUnmasked(true); }
629 
630  // Implements PlotMaskedPointData::sizeUnmasked().
631  unsigned int sizeUnmasked() const { return sizeMaskedOrUnmasked(false); }
632 
633  // Implements PlotMaskedPointData::maskedAt().
634  bool maskedAt(unsigned int index) const {
635  if(m_maskVector != NULL) return (*m_maskVector)[index];
636  if(m_maskCVector != NULL) return (*m_maskCVector)[index];
637  if(m_maskArray != NULL) return m_maskArray[index];
638  return false;
639  }
640 
641  // Implements PlotMaskedPointData::maskedMinsMaxes().
642  bool maskedMinsMaxes(double& xMin, double& xMax, double& yMin,
643  double& yMax) {
644  return getMaskedOrUnmaskedMinsMaxes(xMin, xMax, yMin, yMax, true); }
645 
646  // Implements PlotMaskedPointData::unmaskedMinsMaxes().
647  bool unmaskedMinsMaxes(double& xMin, double& xMax, double& yMin,
648  double& yMax) {
649  return getMaskedOrUnmaskedMinsMaxes(xMin, xMax, yMin, yMax, false); }
650 
651 private:
652  std::vector<bool>* m_maskVector;
654  bool* m_maskArray;
655  unsigned int m_maskArraySize;
657 
658  // Helper for size.
659  unsigned int sizeMaskedOrUnmasked(bool masked) const {
660  unsigned int n = size();
661  unsigned int count = 0;
662  if(m_maskArray != NULL) {
663  for(unsigned int i = 0; i < m_maskArraySize; i++)
664  if(m_maskArray[i]) count++;
665  } else if(m_maskVector != NULL) {
666  for(unsigned int i = 0; i < m_maskVector->size(); i++)
667  if((*m_maskVector)[i]) count++;
668  } else if(m_maskCVector != NULL) {
669  for(unsigned int i = 0; i < m_maskCVector->size(); i++)
670  if((*m_maskCVector)[i]) count++;
671  } else return n;
672  if(masked) return casacore::min(count, n);
673  else return casacore::min(n - count, n);
674  }
675 
676  // Helper for mins/maxes.
677  bool getMaskedOrUnmaskedMinsMaxes(double& xMin, double& xMax, double& yMin,
678  double& yMax, bool masked) {
679  if(!isValid()) return false;
680  unsigned int n = size();
681  if(n == 0) return false;
682  if(m_maskArray == NULL && m_maskVector == NULL &&
683  m_maskCVector == NULL) return minsMaxes(xMin, xMax, yMin, yMax);
684 
685  unsigned int i = 0;
686  bool m;
687  for(; i < n; i++) {
688  m = maskedAt(i);
689  if((masked && m) || (!masked && !m)) {
690  xMin = xMax = xAt(i);
691  yMin = yMax = yAt(i);
692  break;
693  }
694  }
695  if(i == n) return false;
696  double temp;
697  for(; i < n; i++) {
698  m = maskedAt(i);
699  if((masked && m) || (!masked && !m)) {
700  temp = xAt(i);
701  if(temp < xMin) xMin = temp;
702  if(temp > xMax) xMax = temp;
703  temp = yAt(i);
704  if(temp < yMin) yMin = temp;
705  if(temp > yMax) yMax = temp;
706  }
707  }
708  return true;
709  }
710 };
711 
716 
717 
718 // Default implementation of PlotErrorData using standard containers, plus
719 // scalars for the four errors.
720 template <class T>
721 class PlotScalarErrorDataImpl : public virtual PlotErrorData,
722  public PlotPointDataImpl<T> {
723 public:
724  // Scalar error for top, bottom, left, and right.
725  // <group>
726  PlotScalarErrorDataImpl(std::vector<T>& x, std::vector<T>& y, T xLeftError,
727  T xRightError, T yBottomError, T yTopError,
728  bool shouldDelete=false): PlotPointDataImpl<T>(x, y, shouldDelete),
729  m_xLeftError(xLeftError), m_xRightError(xRightError),
730  m_yBottomError(yBottomError), m_yTopError(yTopError) { }
732  T xRightError, T yBottomError, T yTopError,
733  bool shouldDelete=false): PlotPointDataImpl<T>(x, y, shouldDelete),
734  m_xLeftError(xLeftError), m_xRightError(xRightError),
735  m_yBottomError(yBottomError), m_yTopError(yTopError) { }
736  PlotScalarErrorDataImpl(T*& x, T*& y, unsigned int size, T xLeftError,
737  T xRightError, T yBottomError, T yTopError,
738  bool shouldDelete = false) :
739  PlotPointDataImpl<T>(x, y, size, shouldDelete),
740  m_xLeftError(xLeftError), m_xRightError(xRightError),
741  m_yBottomError(yBottomError), m_yTopError(yTopError) { }
742  // </group>
743 
744  // Single error for x and y.
745  // <group>
746  PlotScalarErrorDataImpl(std::vector<T>& x, std::vector<T>& y, T xError, T yError,
747  bool shouldDelete=false): PlotPointDataImpl<T>(x, y, shouldDelete),
748  m_xLeftError(xError), m_xRightError(xError),
749  m_yBottomError(yError), m_yTopError(yError) { }
751  bool shouldDelete=false): PlotPointDataImpl<T>(x, y, shouldDelete),
752  m_xLeftError(xError), m_xRightError(xError),
753  m_yBottomError(yError), m_yTopError(yError) { }
754  PlotScalarErrorDataImpl(T*& x, T*& y,unsigned int size, T xError, T yError,
755  bool shouldDelete = false) :
756  PlotPointDataImpl<T>(x, y, size, shouldDelete),
757  m_xLeftError(xError), m_xRightError(xError),
758  m_yBottomError(yError), m_yTopError(yError) { }
759  // </group>
760 
761  // Single error for all values.
762  // <group>
763  PlotScalarErrorDataImpl(std::vector<T>& x, std::vector<T>& y, T error,
764  bool shouldDelete=false): PlotPointDataImpl<T>(x, y, shouldDelete),
765  m_xLeftError(error), m_xRightError(error), m_yBottomError(error),
766  m_yTopError(error) { }
768  bool shouldDelete=false): PlotPointDataImpl<T>(x, y, shouldDelete),
769  m_xLeftError(error), m_xRightError(error), m_yBottomError(error),
770  m_yTopError(error) { }
771  PlotScalarErrorDataImpl(T*& x, T*& y, unsigned int size, T error,
772  bool shouldDelete = false) :
773  PlotPointDataImpl<T>(x, y, size, shouldDelete),
774  m_xLeftError(error), m_xRightError(error), m_yBottomError(error),
775  m_yTopError(error) { }
776  // </group>
777 
778  // Destructor.
780 
781  // Implements PlotErrorData getter methods.
782  // <group>
783  double xLeftErrorAt(unsigned int ) const { return m_xLeftError; }
784  double xRightErrorAt(unsigned int ) const { return m_xRightError; }
785  double yBottomErrorAt(unsigned int ) const { return m_yBottomError; }
786  double yTopErrorAt(unsigned int ) const { return m_yTopError; }
787  // </group>
788 
789  // Implements PlotErrorData::errorMaxes().
790  bool errorMaxes(double& xLeft, double& xRight, double& yBottom,
791  double& yTop) {
792  xLeft = m_xLeftError;
793  xRight = m_xRightError;
794  yBottom = m_yBottomError;
795  yTop = m_yTopError;
796  return true;
797  }
798 
799 private:
801 };
802 
807 
808 
809 // Default implementation of PlotErrorData using standard containers, plus
810 // PlotPointDataImpls for the errors.
811 template <class T>
812 class PlotErrorDataImpl : public virtual PlotErrorData,
813  public PlotPointDataImpl<T> {
814 public:
815  // Symmetric error constructors.
816  // <group>
817  PlotErrorDataImpl(T*& x, T*& y, T*& xError, T*& yError, unsigned int size,
818  bool shouldDelete = true) :
819  PlotPointDataImpl<T>(x, y, size, shouldDelete),
820  m_xError(xError, xError, size, shouldDelete),
821  m_yError(yError, yError, size, shouldDelete) { }
822  PlotErrorDataImpl(std::vector<T>& x, std::vector<T>& y, std::vector<T>& xError,
823  std::vector<T>& yError, bool shouldDelete = false) :
824  PlotPointDataImpl<T>(x, y, shouldDelete),
825  m_xError(xError, xError, shouldDelete),
826  m_yError(yError, yError, shouldDelete) { }
828  casacore::Vector<T>& yError, bool shouldDelete = false) :
829  PlotPointDataImpl<T>(x, y, shouldDelete),
830  m_xError(xError, xError, shouldDelete),
831  m_yError(yError, yError, shouldDelete) { }
832  // </group>
833 
834  // Asymmetric error constructors.
835  // <group>
836  PlotErrorDataImpl(T*& x, T*& y, T*& xLeftError, T*& xRightError,
837  T*& yBottomError, T*& yTopError, unsigned int size,
838  bool shouldDelete = true) :
839  PlotPointDataImpl<T>(x, y, size, shouldDelete),
840  m_xError(xLeftError, xRightError, size, shouldDelete),
841  m_yError(yBottomError, yTopError, size, shouldDelete) { }
842  PlotErrorDataImpl(std::vector<T>& x, std::vector<T>& y, std::vector<T>& xLeftError,
843  std::vector<T>& xRightError, std::vector<T>& yBottomError,
844  std::vector<T>& yTopError, bool shouldDelete = false) :
845  PlotPointDataImpl<T>(x, y, shouldDelete),
846  m_xError(xLeftError, xRightError, shouldDelete),
847  m_yError(yBottomError, yTopError, shouldDelete) { }
849  casacore::Vector<T>& xRightError, casacore::Vector<T>& yBottomError,
850  casacore::Vector<T>& yTopError, bool shouldDelete = false) :
851  PlotPointDataImpl<T>(x, y, shouldDelete),
852  m_xError(xLeftError, xRightError, shouldDelete),
853  m_yError(yBottomError, yTopError, shouldDelete) { }
854  // </group>
855 
857 
858  // Overrides PlotPointDataImpl::willDeleteData().
859  bool willDeleteData() const {
861  m_xError.willDeleteData() && m_yError.willDeleteData();
862  }
863 
864  // Overrides PlotPointDataImpl::setDeleteData().
865  void setDeleteData(bool del = true) {
866  m_xError.setDeleteData(del);
867  m_yError.setDeleteData(del);
869  }
870 
871  // Implements PlotErrorData getter methods.
872  // <group>
873  double xLeftErrorAt(unsigned int i) const { return m_xError.xAt(i); }
874  double xRightErrorAt(unsigned int i) const { return m_xError.yAt(i); }
875  double yBottomErrorAt(unsigned int i) const { return m_yError.xAt(i); }
876  double yTopErrorAt(unsigned int i) const { return m_yError.yAt(i); }
877  // </group>
878 
879  // Implements PlotErrorData::errorMaxes().
880  bool errorMaxes(double& xLeft, double& xRight, double& yBottom,
881  double& yTop) {
882  double temp;
883  return m_xError.minsMaxes(temp, xLeft, temp, xRight) &&
884  m_yError.minsMaxes(temp, yBottom, temp, yTop);
885  }
886 
887 private:
889 };
890 
895 
896 
897 // Implementation of raster data using casa::Matrix.
898 template <class T>
899 class PlotRasterMatrixData : public virtual PlotRasterData {
900 public:
901  // Whether the indexing is (row,col) or (x,y). Default is (row,col).
902  enum Indexing {
904  };
905 
906  PlotRasterMatrixData(casacore::Matrix<T>& data, bool shouldDelete = false) :
908  m_shouldDelete(shouldDelete) {
910  unsigned int n0 = shape[0] - 1, n1 = shape[1] - 1;
911 
912  m_0From = 0;
913  m_0To = n0 + 1;
914  m_1From = 0;
915  m_1To = n1 + 1;
916  m_0Pieces = (n0 + 1) / (m_0To - m_0From);
917  m_1Pieces = (n1 + 1) / (m_1To - m_1From);
918 
919  double val = static_cast<double>(data(0, 0));
920  m_valFrom = m_valTo = val;
921  for(casacore::uInt i = 0; i < data.nrow(); i++) {
922  for(casacore::uInt j = 0; j < data.ncolumn(); j++) {
923  val = static_cast<double>(data(i, j));
924  if(val < m_valFrom) m_valFrom = val;
925  if(val > m_valTo) m_valTo = val;
926  }
927  }
928  }
929 
931 
932  // Implements PlotData::isValid().
933  bool isValid() const { return true; }
934 
935  // Implements PlotData::willDeleteData().
936  bool willDeleteData() const { return m_shouldDelete; }
937 
938  // Implements PlotData::setDeleteData().
939  void setDeleteData(bool del = true) { m_shouldDelete = del; }
940 
941  // Implements PlotRasterData::origin().
942  Origin origin() const { return m_origin; }
943 
944  // Implements PlotRasterData::setOrigin().
945  void setOrigin(Origin o) {
946  if(m_origin != o) {
947  m_origin = o;
948  }
949  }
950 
951  // Implements PlotRasterData::xRange().
952  prange_t xRange() const {
953  if(m_indexing == X_Y) return prange_t(m_0From, m_0To);
954  else return prange_t(m_1From, m_1To);
955  }
956 
957  // Implements PlotRasterData::yRange().
958  prange_t yRange() const {
959  if(m_indexing == X_Y) return prange_t(m_1From, m_1To);
960  else return prange_t(m_0From, m_0To);
961  }
962 
963  // Implements PlotRasterData::setXRange().
964  void setXRange(double from, double to) {
965  if(from == to) return;
966  if(from > to) {
967  double temp = from;
968  from = to;
969  to = temp;
970  }
971 
972  if(m_indexing == X_Y) {
973  m_0From = from;
974  m_0To = to;
975  m_0Pieces = (m_data->shape()[0]) / (m_0To - m_0From);
976  } else {
977  m_1From = from;
978  m_1To = to;
979  m_1Pieces = (m_data->shape()[1]) / (m_1To - m_1From);
980  }
981  }
982 
983  // Implements PlotRasterData::setYRange().
984  void setYRange(double from, double to) {
985  if(from == to) return;
986  if(from > to) {
987  double temp = from;
988  from = to;
989  to = temp;
990  }
991 
992  if(m_indexing == X_Y) {
993  m_1From = from;
994  m_1To = to;
995  m_1Pieces = (m_data->shape()[1]) / (m_1To - m_1From);
996  } else {
997  m_0From = from;
998  m_0To = to;
999  m_0Pieces = (m_data->shape()[0]) / (m_0To - m_0From);
1000  }
1001  }
1002 
1003  // Implements PlotRasterData::valueRange().
1005 
1006  // Implements PlotRasterData::valueAt().
1007  double valueAt(double x, double y) const {
1008  if(m_indexing == X_Y) {
1009  if(x < m_0From || x > m_0To || y < m_1From || y > m_1To) return 0;
1010 
1011  int xi = (int)((x - m_0From) * m_0Pieces);
1012  int yi = (int)((y - m_1From) * m_1Pieces);
1013  if(xi >= m_data->shape()[0]) xi = m_data->shape()[0] - 1;
1014  if(yi >= m_data->shape()[1]) yi = m_data->shape()[1] - 1;
1015 
1016  return static_cast<double>((*m_data)(xi, yi));
1017 
1018  } else {
1019  if(x < m_1From || x > m_1To || y < m_0From || y > m_0To) return 0;
1020 
1021  int xi = (int)((x - m_1From) * m_1Pieces);
1022  int yi = (int)((y - m_0From) * m_0Pieces);
1023  if(xi >= m_data->shape()[1]) xi = m_data->shape()[1] - 1;
1024  if(yi >= m_data->shape()[0]) yi = m_data->shape()[0] - 1;
1025 
1026  return static_cast<double>((*m_data)(yi, xi));
1027  }
1028  }
1029 
1030  // Implements PlotRasterData::colorBarValues().
1031  std::vector<double>* colorBarValues(unsigned int max = 1000) const {
1032  std::vector<double>* v = new std::vector<double>();
1033 
1034  double val;
1035  bool found;
1036  for(unsigned int i = 0; i < m_data->nrow() && v->size() <= max; i++) {
1037  for(unsigned int j = 0; j < m_data->ncolumn() && v->size() <= max;
1038  j++) {
1039  val = static_cast<double>((*m_data)(i, j));
1040  found = false;
1041  for(unsigned int k = 0; k < v->size() && !found; k++)
1042  if(v->at(k) == val) found = true;
1043  if(!found) v->push_back(val);
1044  }
1045  }
1046 
1047  return v;
1048  }
1049 
1050  // Gets/sets the indexing used for the matrix.
1051  // <group>
1052  Indexing indexing() const { return m_indexing; }
1054  // </group>
1055 
1056  // Gets/sets the matrix.
1057  // <group>
1059  void setMatrix(casacore::Matrix<T>* m, bool shouldDelete = true) {
1060  if(m_shouldDelete) delete m_data;
1061  m_data = m;
1062  m_shouldDelete = shouldDelete;
1063  }
1064  // </group>
1065 
1066 private:
1068  double m_0From, m_0To;
1069  double m_1From, m_1To;
1075 };
1076 
1077 }
1078 
1079 #endif /*PLOTDATA_H_*/
Specialized subclass of PlotPointData that creates histogram data from single point data...
Definition: PlotData.h:512
double yAt(unsigned int i) const
Implements PlotPointData::yAt().
Definition: PlotData.h:483
std::vector< prange_t > m_ranges
Definition: PlotData.h:557
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
void setDeleteData(bool del=true)
Overrides PlotPointDataImpl::setDeleteData().
Definition: PlotData.h:865
A single source of data that basically provides indexing of its values.
Definition: PlotData.h:76
A 1-D Specialization of the Array class.
PlotSingleDataImpl()
Invalid data constructor.
Definition: PlotData.h:317
PlotErrorDataImpl< float > PlotErrorFloatData
Definition: PlotData.h:893
PlotMaskedPointDataImpl(std::vector< T > &x, std::vector< T > &y, std::vector< bool > &mask, bool shouldDelete=false)
X/Y constructors.
Definition: PlotData.h:569
bool errorMaxes(double &xLeft, double &xRight, double &yBottom, double &yTop)
Implements PlotErrorData::errorMaxes().
Definition: PlotData.h:880
virtual double xAt(unsigned int i) const
Implements PlotPointData::xAt().
casacore::Matrix< T > * matrix()
Gets/sets the matrix.
Definition: PlotData.h:1058
PlotScalarErrorDataImpl(T *&x, T *&y, unsigned int size, T error, bool shouldDelete=false)
Definition: PlotData.h:771
virtual prange_t rangeAt(unsigned int i) const
Returns the range at the given index.
virtual double valueAt(double x, double y) const =0
Returns the data value at the given (x,y) coordinate.
size_t nrow() const
The number of rows in the Matrix, i.e.
Definition: Matrix.h:301
bool isValid() const
Implements PlotData::isValid().
Definition: PlotData.h:347
double xRightErrorAt(unsigned int) const
Definition: PlotData.h:784
PlotErrorDataImpl< double > PlotErrorDoubleData
Definition: PlotData.h:894
const IPosition & shape() const
The length of each axis of the Matrix.
Definition: Matrix.h:295
#define max(a, b)
Definition: hio.h:44
virtual prange_t xRange() const =0
Returns the range of x.
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
casacore::Vector< T > * m_cvector
Definition: PlotData.h:410
Indexing
Whether the indexing is (row,col) or (x,y).
Definition: PlotData.h:902
Implementation of raster data using casa::Matrix.
Definition: PlotData.h:899
prange_t valueRange() const
Implements PlotRasterData::valueRange().
Definition: PlotData.h:1004
PlotPointDataImpl< float > PlotPointFloatData
Definition: PlotData.h:503
void setDeleteData(bool del=true)
Implements PlotData::setDeleteData().
Definition: PlotData.h:354
#define min(a, b)
Definition: hio.h:45
double xLeftErrorAt(unsigned int) const
Implements PlotErrorData getter methods.
Definition: PlotData.h:783
~PlotScalarErrorDataImpl()
Destructor.
Definition: PlotData.h:779
A source of data used to supply x and y values.
Definition: PlotData.h:99
PlotSingleDataImpl< T > m_yData
Definition: PlotData.h:498
virtual void setDeleteData(bool del=true)
Implements PlotData::setDeleteData().
PlotMaskedPointDataImpl(casacore::Vector< T > &x, casacore::Vector< T > &y, casacore::Vector< bool > &mask, bool shouldDelete=false)
Definition: PlotData.h:574
PlotScalarErrorDataImpl(casacore::Vector< T > &x, casacore::Vector< T > &y, T xError, T yError, bool shouldDelete=false)
Definition: PlotData.h:750
casacore::Vector< bool > * m_maskCVector
Definition: PlotData.h:653
PlotSingleDataPtr m_data
Definition: PlotData.h:555
PlotErrorDataImpl(std::vector< T > &x, std::vector< T > &y, std::vector< T > &xError, std::vector< T > &yError, bool shouldDelete=false)
Definition: PlotData.h:822
PlotSingleDataImpl(std::vector< T > &value, bool shouldDelete=false)
casacore::Data using different standard containers.
Definition: PlotData.h:322
virtual ~PlotData()
Definition: PlotData.h:56
PlotPointDataImpl(T *&y, unsigned int size, bool shouldDel=false)
Definition: PlotData.h:447
virtual void setDeleteData(bool del=true)
Implements PlotData::setDeleteData().
Definition: PlotData.h:464
PlotErrorDataImpl< int > PlotErrorIntData
Definition: PlotData.h:891
virtual unsigned int binAt(unsigned int i) const =0
Returns the bin index number for the given index.
unsigned int m_arraySize
Definition: PlotData.h:412
virtual ~PlotRasterData()
Definition: PlotData.h:270
unsigned int size() const
Implements PlotSingleData::size().
Definition: PlotData.h:357
casacore::Matrix< T > * m_data
Definition: PlotData.h:1067
void setMatrix(casacore::Matrix< T > *m, bool shouldDelete=true)
Definition: PlotData.h:1059
PlotScalarErrorDataImpl< float > PlotScalarErrorFloatData
Definition: PlotData.h:805
PlotPointDataImpl< T > m_xError
Definition: PlotData.h:888
A 2-D Specialization of the Array class.
virtual unsigned int size() const
Implements PlotPointData::size().
Definition: PlotData.h:532
unsigned int sizeMaskedOrUnmasked(bool masked) const
Helper for size.
Definition: PlotData.h:659
PlotSingleDataImpl(T *&value, unsigned int size, bool shouldDelete=false)
Definition: PlotData.h:330
PlotPointDataImpl< double > PlotPointDoubleData
Definition: PlotData.h:504
virtual prange_t valueRange() const =0
Returns the range of the data values.
Default implementation of PlotErrorData using standard containers, plus PlotPointDataImpls for the er...
Definition: PlotData.h:812
virtual double yAt(unsigned int i) const
Implements PlotPointData::yAt().
void setDeleteData(bool del=true)
Implements PlotData::setDeleteData().
Definition: PlotData.h:939
size_t size() const
virtual double xLeftErrorAt(unsigned int i) const =0
ABSTRACT METHODS //.
PlotScalarErrorDataImpl(casacore::Vector< T > &x, casacore::Vector< T > &y, T xLeftError, T xRightError, T yBottomError, T yTopError, bool shouldDelete=false)
Definition: PlotData.h:731
PlotErrorDataImpl< unsigned int > PlotErrorUIntData
Definition: PlotData.h:892
void setXRange(double from, double to)
Implements PlotRasterData::setXRange().
Definition: PlotData.h:964
Default implementation of PlotPointData that supports raw arrays, vectors, and CASA Vectors...
Definition: PlotData.h:429
virtual bool willDeleteData() const =0
Returns whether this object will delete its underlying data structures upon deconstruction or not...
virtual bool isBinned() const
IMPLEMENTED METHODS //.
Definition: PlotData.h:244
Default implementation of PlotMaskedPointData using default containers.
Definition: PlotData.h:564
PlotPointDataImpl< int > PlotPointIntData
Definition: PlotData.h:501
unsigned int m_max
Definition: PlotData.h:558
PlotSingleDataImpl< double > PlotSingleDoubleData
Definition: PlotData.h:420
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
Definition: PlotData.h:48
virtual bool isValid() const =0
ABSTRACT METHODS //.
bool getMaskedOrUnmaskedMinsMaxes(double &xMin, double &xMax, double &yMin, double &yMax, bool masked)
Helper for mins/maxes.
Definition: PlotData.h:677
virtual unsigned int size() const =0
ABSTRACT METHODS //.
PlotSingleDataImpl< float > PlotSingleFloatData
Definition: PlotData.h:419
virtual bool plotConjugates() const
Returns whether to plot conjugate data (e.g.
Definition: PlotData.h:615
PlotErrorDataImpl(std::vector< T > &x, std::vector< T > &y, std::vector< T > &xLeftError, std::vector< T > &xRightError, std::vector< T > &yBottomError, std::vector< T > &yTopError, bool shouldDelete=false)
Definition: PlotData.h:842
Indexing indexing() const
Gets/sets the indexing used for the matrix.
Definition: PlotData.h:1052
PlotPointDataImpl(casacore::Vector< T > &x, casacore::Vector< T > &y, bool shouldDelete=false)
Definition: PlotData.h:435
bool isValid() const
Implements PlotData::isValid().
Definition: PlotData.h:933
~PlotMaskedPointDataImpl()
Destructor.
Definition: PlotData.h:606
virtual void setYRange(double from, double to)=0
Sets the range of y.
casacore::CountedPtr< PlotData > PlotDataPtr
Definition: PlotData.h:72
PlotMaskedPointDataImpl< unsigned int > PlotMaskedPointUIntData
Definition: PlotData.h:713
void setDeleteData(bool del=true)
Overrides PlotPointDataImpl::setDeleteData().
Definition: PlotData.h:622
virtual bool reverseConnect(unsigned int) const
Returns whether data is plotted in reverse order (right to left), needed when connecting points...
Definition: PlotData.h:614
unsigned int sizeUnmasked() const
Implements PlotMaskedPointData::sizeUnmasked().
Definition: PlotData.h:631
bool minMax(double &min, double &max)
Implements PlotSingleData::minMax().
Definition: PlotData.h:373
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
LatticeExprNode min(const LatticeExprNode &left, const LatticeExprNode &right)
prange_t xRange() const
Implements PlotRasterData::xRange().
Definition: PlotData.h:952
PlotPointDataImpl(std::vector< T > &x, std::vector< T > &y, bool shouldDelete=false)
X/Y constructors.
Definition: PlotData.h:433
PlotErrorDataImpl(T *&x, T *&y, T *&xLeftError, T *&xRightError, T *&yBottomError, T *&yTopError, unsigned int size, bool shouldDelete=true)
Asymmetric error constructors.
Definition: PlotData.h:836
bool minsMaxes(double &xMin, double &xMax, double &yMin, double &yMax)
Implements PlotPointData::minsMaxes().
Definition: PlotData.h:486
virtual ~PlotHistogramData()
Destructor.
virtual bool minMax(double &min, double &max)=0
Gets the minimum and maximum values.
virtual void recalculateBins(unsigned int numBins)
Recalculates the histogram data into the given number of bins.
virtual prange_t yRange() const =0
Returns the range of y.
PlotSingleDataImpl< T > m_xData
Definition: PlotData.h:497
std::vector< double > * colorBarValues(unsigned int max=1000) const
Implements PlotRasterData::colorBarValues().
Definition: PlotData.h:1031
double xAt(unsigned int i) const
Implements PlotPointData::xAt().
Definition: PlotData.h:477
virtual ~PlotBinnedData()
Destructor.
Definition: PlotData.h:226
PlotScalarErrorDataImpl(std::vector< T > &x, std::vector< T > &y, T error, bool shouldDelete=false)
Single error for all values.
Definition: PlotData.h:763
PlotScalarErrorDataImpl(std::vector< T > &x, std::vector< T > &y, T xError, T yError, bool shouldDelete=false)
Single error for x and y.
Definition: PlotData.h:746
virtual bool willDeleteData() const
Implements PlotData::willDeleteData().
double yBottomErrorAt(unsigned int) const
Definition: PlotData.h:785
virtual unsigned int numBins() const
Returns the current number of histogram bins.
PlotMaskedPointDataImpl(std::vector< T > &y, std::vector< bool > &mask, bool shouldDelete=false)
Y constructors.
Definition: PlotData.h:588
PlotPointDataImpl< T > m_yError
Definition: PlotData.h:888
PlotPointDataImpl< unsigned int > PlotPointUIntData
Definition: PlotData.h:502
PlotSingleDataImpl< int > PlotSingleIntData
Definition: PlotData.h:417
PlotErrorDataImpl(T *&x, T *&y, T *&xError, T *&yError, unsigned int size, bool shouldDelete=true)
Symmetric error constructors.
Definition: PlotData.h:817
bool maskedMinsMaxes(double &xMin, double &xMax, double &yMin, double &yMax)
Implements PlotMaskedPointData::maskedMinsMaxes().
Definition: PlotData.h:642
Origin
casacore::Data for raster plots, which can be thought of as three-dimensional.
Definition: PlotData.h:263
virtual ~PlotErrorData()
Definition: PlotData.h:184
virtual double at(unsigned int i) const =0
Returns the value at given index.
PlotScalarErrorDataImpl< int > PlotScalarErrorIntData
Definition: PlotData.h:803
size_t ncolumn() const
The number of columns in the Matrix, i.e.
Definition: Matrix.h:305
PlotSingleDataImpl< unsigned int > PlotSingleUIntData
Definition: PlotData.h:418
PlotMaskedPointDataImpl< float > PlotMaskedPointFloatData
Definition: PlotData.h:714
virtual void setDeleteData(bool del=true)=0
Sets whether this object will delete its underlying data structures upon deconstruction or not...
double yTopErrorAt(unsigned int i) const
Definition: PlotData.h:876
virtual ~PlotPointData()
Definition: PlotData.h:103
virtual double yBottomErrorAt(unsigned int i) const =0
Returns the &quot;bottom&quot; error for y at the given index.
PlotErrorDataImpl(casacore::Vector< T > &x, casacore::Vector< T > &y, casacore::Vector< T > &xError, casacore::Vector< T > &yError, bool shouldDelete=false)
Definition: PlotData.h:827
virtual void setXRange(double from, double to)=0
Sets the range of x.
virtual void setOrigin(Origin o)=0
Sets the data origin.
virtual void xyAndErrorsAt(unsigned int index, double &x, double &y, double &xLeftError, double &xRightError, double &yBottomError, double &yTopError) const
IMPLEMENTED METHODS //.
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1944
unsigned int size() const
Implements PlotPointData::size().
Definition: PlotData.h:470
std::vector< unsigned int > m_bins
Definition: PlotData.h:556
INHERITANCE_POINTER2(PlotLayoutSingle, PlotLayoutSinglePtr, PlotCanvasLayout, PlotCanvasLayoutPtr) INHERITANCE_POINTER2(PlotLayoutGrid
virtual Origin origin() const =0
ABSTRACT METHODS //.
prange_t yRange() const
Implements PlotRasterData::yRange().
Definition: PlotData.h:958
std::pair< double, double > ppoint_t
Typedef for a point, which is two doubles (x and y).
Definition: PlotData.h:41
PlotPointDataImpl(std::vector< T > &y, bool shouldDelete=false)
Y constructors.
Definition: PlotData.h:443
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of but is it too vague to be useful Since the interface is meant to be a simple it may be better to restrict PlotData to be more like PlotPointData
Definition: PlotData.h:48
std::pair< double, double > prange_t
Typedef for range, which is two doubles (min and max).
Definition: PlotOptions.h:41
PlotScalarErrorDataImpl(T *&x, T *&y, unsigned int size, T xLeftError, T xRightError, T yBottomError, T yTopError, bool shouldDelete=false)
Definition: PlotData.h:736
PlotSingleDataImpl(casacore::Vector< T > &value, bool shouldDelete=false)
Definition: PlotData.h:326
virtual ~PlotSingleData()
Definition: PlotData.h:80
PlotMaskedPointDataImpl< double > PlotMaskedPointDoubleData
Definition: PlotData.h:715
virtual double xRightErrorAt(unsigned int i) const =0
Returns the &quot;right&quot; error for x at the given index.
Origin origin() const
Implements PlotRasterData::origin().
Definition: PlotData.h:942
std::vector< T > * m_vector
Definition: PlotData.h:409
virtual double yTopErrorAt(unsigned int i) const =0
Returns the &quot;top&quot; error for y at the given index.
PlotScalarErrorDataImpl(casacore::Vector< T > &x, casacore::Vector< T > &y, T error, bool shouldDelete=false)
Definition: PlotData.h:767
virtual bool isValid() const
Implements PlotData::isValid().
bool isValid() const
Implements PlotData::isValid().
Definition: PlotData.h:455
void recalculateMinMax()
Recalculates the cached min and max.
Definition: PlotData.h:381
PlotMaskedPointDataImpl< int > PlotMaskedPointIntData
Definition: PlotData.h:712
PlotPointDataImpl(casacore::Vector< T > &y, bool shouldDelete=false)
Definition: PlotData.h:445
PlotHistogramData(PlotSingleDataPtr data, unsigned int numBins)
Constructor which takes data and number of bins.
PlotErrorDataImpl(casacore::Vector< T > &x, casacore::Vector< T > &y, casacore::Vector< T > &xLeftError, casacore::Vector< T > &xRightError, casacore::Vector< T > &yBottomError, casacore::Vector< T > &yTopError, bool shouldDelete=false)
Definition: PlotData.h:848
double yTopErrorAt(unsigned int) const
Definition: PlotData.h:786
PlotScalarErrorDataImpl(std::vector< T > &x, std::vector< T > &y, T xLeftError, T xRightError, T yBottomError, T yTopError, bool shouldDelete=false)
Scalar error for top, bottom, left, and right.
Definition: PlotData.h:726
virtual std::vector< double > * colorBarValues(unsigned int max=1000) const =0
Gets color bar values.
Default implementation of PlotErrorData using standard containers, plus scalars for the four errors...
Definition: PlotData.h:721
void setIndexing(Indexing i)
Definition: PlotData.h:1053
void setYRange(double from, double to)
Implements PlotRasterData::setYRange().
Definition: PlotData.h:984
double xLeftErrorAt(unsigned int i) const
Implements PlotErrorData getter methods.
Definition: PlotData.h:873
void setOrigin(Origin o)
Implements PlotRasterData::setOrigin().
Definition: PlotData.h:945
bool willDeleteData() const
Implements PlotData::willDeleteData().
Definition: PlotData.h:936
double yBottomErrorAt(unsigned int i) const
Definition: PlotData.h:875
PlotScalarErrorDataImpl(T *&x, T *&y, unsigned int size, T xError, T yError, bool shouldDelete=false)
Definition: PlotData.h:754
virtual ~PlotMaskedPointData()
Definition: PlotData.h:139
unsigned int sizeMasked() const
Implements PlotMaskedPointData::sizeMasked().
Definition: PlotData.h:628
virtual bool minsMaxes(double &xMin, double &xMax, double &yMin, double &yMax)
Implements PlotPointData::minsMaxes().
PlotRasterData()
Definition: PlotData.h:268
size_t size() const
Definition: ArrayBase.h:101
PlotRasterMatrixData(casacore::Matrix< T > &data, bool shouldDelete=false)
Definition: PlotData.h:906
bool willDeleteData() const
Implements PlotData::willDeleteData().
Definition: PlotData.h:351
PlotPointDataImpl(T *&x, T *&y, unsigned int size, bool shouldDel=false)
Definition: PlotData.h:437
virtual unsigned int connectBinAt(unsigned int i) const
Definition: PlotData.h:237
virtual bool willDeleteData() const
Implements PlotData::willDeleteData().
Definition: PlotData.h:458
casacore::Data that adds masking functionality on top of normal point data.
Definition: PlotData.h:135
PlotMaskedPointDataImpl(T *&y, bool *&mask, unsigned int size, bool shouldDel=false)
Definition: PlotData.h:598
std::vector< bool > * m_maskVector
Definition: PlotData.h:652
INHERITANCE_POINTER(PlotFlagAllTool, PlotFlagAllToolPtr, PlotMouseTool, PlotMouseToolPtr, PlotTool, PlotToolPtr) TOOL NOTIFICATION CLASSESInterface for objects that want to be notified when the selection tool changes.*/class PlotSelectToolNotifier
Definition: PlotTool.h:675
PlotScalarErrorDataImpl< unsigned int > PlotScalarErrorUIntData
Definition: PlotData.h:804
bool willDeleteData() const
Overrides PlotPointDataImpl::willDeleteData().
Definition: PlotData.h:618
PlotMaskedPointDataImpl(casacore::Vector< T > &y, casacore::Vector< bool > &mask, bool shouldDelete=false)
Definition: PlotData.h:593
bool unmaskedMinsMaxes(double &xMin, double &xMax, double &yMin, double &yMax)
Implements PlotMaskedPointData::unmaskedMinsMaxes().
Definition: PlotData.h:647
virtual unsigned int numBins() const =0
ABSTRACT METHODS //.
bool willDeleteData() const
Overrides PlotPointDataImpl::willDeleteData().
Definition: PlotData.h:859
~PlotSingleDataImpl()
Destructor.
Definition: PlotData.h:337
double xRightErrorAt(unsigned int i) const
Definition: PlotData.h:874
PlotMaskedPointDataImpl(T *&x, T *&y, bool *&mask, unsigned int size, bool shouldDel=false)
Definition: PlotData.h:579
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
PlotScalarErrorDataImpl< double > PlotScalarErrorDoubleData
Definition: PlotData.h:806
bool errorMaxes(double &xLeft, double &xRight, double &yBottom, double &yTop)
Implements PlotErrorData::errorMaxes().
Definition: PlotData.h:790
unsigned int uInt
Definition: aipstype.h:51
virtual bool errorMaxes(double &xLeft, double &xRight, double &yBottom, double &yTop)=0
Gets the maximum errors for the four sides.
bool maskedAt(unsigned int index) const
Implements PlotMaskedPointData::maskedAt().
Definition: PlotData.h:634
double at(unsigned int i) const
Implements PlotSingleData::at().
Definition: PlotData.h:365
double valueAt(double x, double y) const
Implements PlotRasterData::valueAt().
Definition: PlotData.h:1007
virtual ~PlotPointDataImpl()
Definition: PlotData.h:451
unsigned int m_maskArraySize
Definition: PlotData.h:655