casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlotMSRegions.h
Go to the documentation of this file.
1 //# PlotMSRegions.h: Properties of selected regions for a PlotMSPlot.
2 //# Copyright (C) 2009
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 PLOTMSREGIONS_H_
28 #define PLOTMSREGIONS_H_
29 
31 
32 #include <map>
33 
34 namespace casa {
35 
36 // A single region; basically just a container class for four doubles.
37 class PlotMSRegion {
38 public:
39  // Default constructor, which creates an invalid region in which all four
40  // values are zero.
41  PlotMSRegion();
42 
43  // Constructor that takes the four values of the region.
44  PlotMSRegion(double xMin, double xMax, double yMin, double yMax);
45 
46  // Copy constructor (see operator=()).
48 
49  // Destructor.
50  ~PlotMSRegion();
51 
52 
53  // Returns whether or not this region is valid. A region is invalid if
54  // either of its maxes are <= its mins.
55  bool isValid() const;
56 
57  // Returns whether or not this region contains the given (x, y) pair. If
58  // exclusive is true, then the borders are not included.
59  bool contains(double x, double y, bool exclusive = true) const;
60 
61  // Returns the region values.
62  // <group>
63  double left() const { return xMin(); }
64  double right() const { return xMax(); }
65  double bottom() const { return yMin(); }
66  double top() const { return yMax(); }
67 
68  double xMin() const;
69  double xMax() const;
70  double yMin() const;
71  double yMax() const;
72  // </group>
73 
74  // Sets the region values.
75  // <group>
76  void setValues(double xMin, double xMax, double yMin, double yMax);
77  void setX(double min, double max);
78  void setY(double min, double max);
79  void setXMin(double val);
80  void setXMax(double val);
81  void setYMin(double val);
82  void setYMax(double val);
83  void setLeft(double val) { setXMin(val); }
84  void setRight(double val) { setXMax(val); }
85  void setBottom(double val) { setYMin(val); }
86  void setTop(double val) { setYMax(val); }
87  // </group>
88 
89 
90  // Equality operators.
91  // <group>
92  bool operator==(const PlotMSRegion& region) const;
93  bool operator!=(const PlotMSRegion& region) const {
94  return !(operator==(region)); }
95  // </group>
96 
97  // Copy operator.
98  PlotMSRegion& operator=(const PlotMSRegion& copy);
99 
100 private:
101  // Values.
103 };
104 
105 // PlotMSRegions is a class that holds information about selected regions for a
106 // single PlotMSPlot. Because PlotMSPlot can have potentially many different
107 // plots across potentially many different canvases, it is important that
108 // PlotMSRegions be general enough to handle many different cases.
110 public:
111  // Constructor, which creates an empty selection.
112  PlotMSRegions();
113 
114  // Destructor.
115  ~PlotMSRegions();
116 
117 
118  // Returns all axis pairs that have regions.
120 
121  // Returns whether or not there are regions for the given (x, y) axis pair.
122  bool hasRegionsFor(PMS::Axis x, PMS::Axis y) const;
123 
124  // Returns a copy of the regions for the given (x, y) axis pair.
125  casacore::Vector<PlotMSRegion> regionsFor(PMS::Axis x, PMS::Axis y) const;
126 
127  // Adds the given regions for the given (x, y) axis pair. Will not remove
128  // any existing regions for that pair. Only adds unique regions.
129  // <group>
130  void addRegions(PMS::Axis x, PMS::Axis y, const std::vector<PlotMSRegion>& r) {
132  void addRegions(PMS::Axis x, PMS::Axis y, const casacore::Vector<PlotMSRegion>& r);
133  // </group>
134 
135  // Convenience method for adding all selected regions using the standard
136  // select tool on the given canvas for the given (x, y) axis pair.
137  void addRegions(PMS::Axis x, PMS::Axis y, PlotCanvasPtr canvas);
138 
139  // Sets the regions for the given (x, y) axis pair to the given. Removes
140  // any existing regions for that pair. Only adds unique regions.
141  // <group>
142  void setRegions(PMS::Axis x, PMS::Axis y, const std::vector<PlotMSRegion>& r) {
144  void setRegions(PMS::Axis x, PMS::Axis y, const casacore::Vector<PlotMSRegion>& r);
145  // </group>
146 
147  // Convenience method for setting the regions for the given (x, y) axis
148  // pair using the standard select tool on the given canvas.
149  void setRegions(PMS::Axis x, PMS::Axis y, PlotCanvasPtr canvas);
150 
151  // Clears the regions for the given (x, y) axis pair.
152  void clearRegions(PMS::Axis x, PMS::Axis y);
153 
154 private:
155  // Convenience macro for map type.
156  typedef std::map<std::pair<PMS::Axis, PMS::Axis>, casacore::Vector<PlotMSRegion> > PMSRMap;
157 
158  // casacore::Map from (x, y) to selected regions.
160 };
161 
162 }
163 
164 #endif /* PLOTMSREGIONS_H_ */
A 1-D Specialization of the Array class.
double top() const
Definition: PlotMSRegions.h:66
double right() const
Definition: PlotMSRegions.h:64
PlotMSRegion()
Default constructor, which creates an invalid region in which all four values are zero...
bool operator!=(const PlotMSRegion &region) const
Definition: PlotMSRegions.h:93
bool operator==(const PlotMSRegion &region) const
Equality operators.
void setLeft(double val)
Definition: PlotMSRegions.h:83
StatsData< AccumType > copy(const StatsData< AccumType > &stats)
void setRegions(PMS::Axis x, PMS::Axis y, const std::vector< PlotMSRegion > &r)
Sets the regions for the given (x, y) axis pair to the given.
#define max(a, b)
Definition: hio.h:44
void setYMax(double val)
#define min(a, b)
Definition: hio.h:45
PlotMSRegions()
Constructor, which creates an empty selection.
~PlotMSRegion()
Destructor.
void setXMin(double val)
void setRight(double val)
Definition: PlotMSRegions.h:84
double itsXMin_
Values.
double left() const
Returns the region values.
Definition: PlotMSRegions.h:63
std::map< std::pair< PMS::Axis, PMS::Axis >, casacore::Vector< PlotMSRegion > > PMSRMap
Convenience macro for map type.
void setXMax(double val)
PlotMSRegions is a class that holds information about selected regions for a single PlotMSPlot...
PlotMSRegion & operator=(const PlotMSRegion &copy)
Copy operator.
bool isValid() const
Returns whether or not this region is valid.
void setTop(double val)
Definition: PlotMSRegions.h:86
casacore::Vector< std::pair< PMS::Axis, PMS::Axis > > allAxisPairs() const
Returns all axis pairs that have regions.
void setYMin(double val)
void addRegions(PMS::Axis x, PMS::Axis y, const std::vector< PlotMSRegion > &r)
Adds the given regions for the given (x, y) axis pair.
void setBottom(double val)
Definition: PlotMSRegions.h:85
bool contains(double x, double y, bool exclusive=true) const
Returns whether or not this region contains the given (x, y) pair.
A single region; basically just a container class for four doubles.
Definition: PlotMSRegions.h:37
bool hasRegionsFor(PMS::Axis x, PMS::Axis y) const
Returns whether or not there are regions for the given (x, y) axis pair.
void setY(double min, double max)
void setValues(double xMin, double xMax, double yMin, double yMax)
Sets the region values.
void clearRegions(PMS::Axis x, PMS::Axis y)
Clears the regions for the given (x, y) axis pair.
double bottom() const
Definition: PlotMSRegions.h:65
double xMin() const
double xMax() const
double yMax() const
~PlotMSRegions()
Destructor.
casacore::Vector< PlotMSRegion > regionsFor(PMS::Axis x, PMS::Axis y) const
Returns a copy of the regions for the given (x, y) axis pair.
double yMin() const
PMSRMap itsRegions_
casacore::Map from (x, y) to selected regions.
void setX(double min, double max)