CARMA C++
ConfigPlotter.h
Go to the documentation of this file.
1 // $Id: ConfigPlotter.h,v 1.1 2012/06/27 18:05:07 eml Exp $
2 
3 #ifndef SZA_UTIL_CONFIGPLOTTER_H
4 #define SZA_UTIL_CONFIGPLOTTER_H
5 
16 
17 #include <vector>
18 
19 namespace sza {
20  namespace util {
21 
22  enum FillStyle {
23  FILL_SOLID = 1,
24  FILL_OUTLINE = 2,
25  FILL_HATCHED = 3,
26  FILL_CROSS_HATCHED = 4,
27  };
28 
29  class ConfigPlotter {
30  public:
31 
35  class Circle {
36  public:
37 
38  Circle(double x, double y, double r) {
39  x_ = x;
40  y_ = y;
41  r_ = r;
42  };
43 
44  friend std::ostream& operator<<(std::ostream& os, Circle& c);
45 
46  double x_;
47  double y_;
48  double r_;
49  };
50 
54  class Rectangle {
55  public:
56 
57  Rectangle(double xCenter, double yCenter, double xWidth, double yWidth) {
58  x_ = xCenter;
59  y_ = yCenter;
60  xWidth_ = xWidth;
61  yWidth_ = yWidth;
62  };
63 
64  friend std::ostream& operator<<(std::ostream& os, Rectangle& r);
65 
66  bool overlaps(Circle& c);
67  bool overlaps(Rectangle& r);
68 
69  double xLeft() {
70  return x_ - xWidth_/2;
71  }
72 
73  double xRight() {
74  return x_ + xWidth_/2;
75  }
76 
77  double yTop() {
78  return y_ + yWidth_/2;
79  }
80 
81  double yBottom() {
82  return y_ - yWidth_/2;
83  }
84 
85  double x_;
86  double y_;
87  double xWidth_;
88  double yWidth_;
89  };
90 
94  ConfigPlotter();
95 
99  virtual ~ConfigPlotter();
100 
101  void plotConfiguration(std::vector<CarmaConfig::PadLocation>& pads);
102 
103  void openDevice(std::string device);
104 
105  int pgplotId_;
106 
107  void setFixedLimits(double xmin, double xmax, double ymin, double ymax);
108 
109  void useFixedLimits(bool use);
110 
111  CarmaConfig::PadLocation mark(std::vector<CarmaConfig::PadLocation>& pads,
112  double x, double y);
113 
114  void clearMarks();
115 
116  void getLabelLocation(CarmaConfig::PadLocation& pad, std::vector<CarmaConfig::PadLocation>& pads, std::string label,
117  double& x, double& y, double& xNear, double& yNear, std::vector<Rectangle>& labels, double thetaDeg=400);
118 
119  void getCoords(double theta, double xCurr, double yCurr, double antRadius, double strHalfWidth, double strHalfHeight,
120  double& xCenter, double& yCenter, double& xNear, double& yNear);
121 
122  void useLabels(bool label);
123  void overplot(bool doOverplot);
124  void useFillFlags(bool use);
125  void setFillStyle(FillStyle style);
126  void setFillFlags(std::vector<bool> fillFlags);
127  void setAz(std::vector<Angle> az);
128  void setEl(std::vector<Angle> el);
129 
130  private:
131 
132  FillStyle fillStyle_;
133  bool overplot_;
134  bool useLabels_;
135  bool fixedLims_;
136  bool useFillFlags_;
137 
138  double fixXmin_, fixXmax_;
139  double fixYmin_, fixYmax_;
140 
141  double currXmin_, currXmax_;
142  double currYmin_, currYmax_;
143 
144  std::vector<double> xMarks_, yMarks_;
145  bool useMarks_;
146 
147  std::vector<bool> fillFlags_;
148  std::vector<Angle> az_;
149  std::vector<Angle> el_;
150 
151  void getPlotLimits(std::vector<CarmaConfig::PadLocation>& pads,
152  double& xmin, double& xmax, double& ymin, double& ymax,
153  double frac);
154 
155  int getColor(CarmaConfig::PadLocation& pad);
156  int getLineStyle(CarmaConfig::PadLocation& pad);
157 
158  bool rectangleOverlapsCircle(double xCenterRect, double yCenterRect, double rectWidth, double rectHeight,
159  double xCenterCircle, double yCenterCircle, double circleRadius);
160 
161  }; // End class ConfigPlotter
162 
163  std::ostream& operator<<(std::ostream& os, ConfigPlotter::Circle& c);
164  std::ostream& operator<<(std::ostream& os, ConfigPlotter::Rectangle& r);
165 
166  } // End namespace util
167 } // End namespace sza
168 
169 
170 
171 #endif // End #ifndef SZA_UTIL_CONFIGPLOTTER_H
Tagged: Thu Aug 28 15:18:31 PDT 2008.
......................................................................
Definition: ConfigPlotter.h:54
......................................................................
Definition: ConfigPlotter.h:35