CARMA C++
PgUtil.h
Go to the documentation of this file.
1 // $Id: PgUtil.h,v 1.4 2014/04/30 23:38:57 eml Exp $
2 
3 #ifndef SZA_UTIL_PGUTIL_H
4 #define SZA_UTIL_PGUTIL_H
5 
15 #include "carma/szapgutil/color_tab.h"
16 
17 #include <string>
18 #include <vector>
19 
20 namespace sza {
21  namespace util {
22 
23  class PgUtil {
24  public:
25 
29  PgUtil();
30 
34  virtual ~PgUtil();
35 
36  enum {
37  BLACK = 0,
38  WHITE = 1,
39  RED = 2,
40  GREEN = 3,
41  DEEP_BLUE = 4,
42  PALE_BLUE = 5,
43  MAGENTA = 6,
44  YELLOW = 7,
45  ORANGE = 8,
46  YELLOW_GREEN = 9,
47  SAGE_GREEN = 10,
48  SLATE_BLUE = 11,
49  PURPLE = 12,
50  PINK = 13,
51  DARK_GRAY = 14,
52  DARK_GREY = 14,
53  LIGHT_GRAY = 15,
54  LIGHT_GREY = 15,
55  };
56 
57  static int open(std::string device);
58  static void close();
59  static void subplot(int nx, int ny);
60  static void advance();
61 
62  static void setInteractive(bool inter);
63  static void useXaxisTimeLabeling(bool use);
64 
65  static void greyScale(std::vector<double>& zdata, int nx, int ny,
66  double xmina=0, double xmaxa=1, double ymina=0, double ymaxa=1,
67  double *flag=0,double z1=0, double z2=0,
68  char *xlab="", char *ylab="", char *title="", char *unit="");
69 
70  static void greyScale(int ndata, double *zdata, int nx, int ny,
71  double xmina=0, double xmaxa=1, double ymina=0, double ymaxa=1,
72  double *flag=0,double z1=0, double z2=0,
73  char *xlab="", char *ylab="", char *title="", char *unit="");
74 
75  static void greyScale(int ndata, float *zdata, int nx, int ny,
76  float xmina=0, float xmaxa=1, float ymina=0, float ymaxa=1,
77  float *flag=0,float z1=0, float z2=0,
78  char *xlab="", char *ylab="", char *title="", char *unit="");
79 
80  static void grayScale(int ndata, float *zdata, int nx,int ny,
81  float xmina=0, float xmaxa=1, float ymina=0, float ymaxa=1,
82  float *flag=0,float z1=0, float z2=0,
83  char *xlab="", char *ylab="", char *title="", char *unit="");
84 
85  // Plot a simple line plot.
86 
87  static void linePlot(std::vector<double>& xarr, std::vector<double>& yarr,
88  char* xlab="", char* ylab="", char* title="",
89  bool doLine=true);
90 
91  static void linePlot(int narr, double* xarr, double* yarr,
92  char* xlab="", char* ylab="", char* title="",
93  bool doLine=true);
94 
95  static void linePlot(int narr, float* xarr, float* yarr,
96  char* xlab="", char* ylab="", char* title="",
97  bool doLine=true);
98 
99  static void linePlot(std::vector<double>& yarr, bool doLine=true);
100 
101  static void setOverplot(bool overplot) {
102  overplot_ = overplot;
103  }
104 
105  static void setWnad(bool wnad) {
106  wnad_ = wnad;
107  }
108 
109  static void setWin(bool win) {
110  win_ = win;
111  }
112 
113  static void setBox(bool box) {
114  box_ = box;
115  }
116 
117  static void setVp(bool vp) {
118  vp_ = vp;
119  }
120 
121  static void setTick(bool tick) {
122  tick_ = tick;
123  }
124 
125  static void setLabel(bool label) {
126  label_ = label;
127  }
128 
129  static void setWedge(bool wedge) {
130  wedge_ = wedge;
131  }
132 
133  static void plotPoints(bool plot) {
134  plotPoints_ = plot;
135  }
136 
137  static void setViewport(float xleft, float xright, float ybot, float ytop);
138 
139  static void setUsedefs(bool usedefs) {
140  usedefs_ = usedefs;
141  }
142 
143  static void setXmin(float xmin) {
144  xmin_ = xmin;
145  }
146 
147  static void setXmax(float xmax) {
148  xmax_ = xmax;
149  }
150 
151  static void setYmin(float ymin) {
152  ymin_ = ymin;
153  }
154 
155  static void setYmax(float ymax) {
156  ymax_ = ymax;
157  }
158 
159  static void setColormap(std::string cmap);
160 
161  static void queryDevice(bool& wasopen);
162  static bool haveCursor();
163 
164  static void wnad(float xmin, float xmax, float ymin, float ymax);
165 
166  static void setMarkerColor(int colorIndex) {
167  markerColor_ = colorIndex;
168  }
169 
170  static int getMarkerColor() {
171  return markerColor_;
172  }
173 
174  static void setMarkerSymbol(int markerSymbol) {
175  markerSymbol_ = markerSymbol;
176  }
177 
178  static void setMarkerSize(float markerSize) {
179  markerSize_ = markerSize;
180  }
181 
182  public:
183 
184  static int markerColor_;
185  static int markerSymbol_;
186  static float markerSize_;
187  static bool xaxisTimeLabeling_;
188  static bool interactive_;
189  static Cmap* cmap_;
190  static bool overplot_;
191  static bool plotPoints_;
192  static bool vp_;
193  static bool box_;
194  static bool win_;
195  static bool wnad_;
196  static bool tick_;
197  static bool label_;
198  static bool wedge_;
199  static bool usedefs_;
200  static float xmin_, xmax_;
201  static float ymin_, ymax_;
202 
203  // Make a gray scale plot
204 
205  static int v_grey2(int ndata, float *zdata, int nx,int ny,
206  float xmina=0, float xmaxa=1, float ymina=0, float ymaxa=1,
207  float* flag=0,float z1=0, float z2=0,
208  char* xlab="", char* ylab="", char* title="", char* unit="");
209 
210  // Plot a simple line plot.
211 
212  static int v_lplot(int narr, float* xarr, float* yarr,
213  char* xlab="", char* ylab="", char* title="",
214  bool doLine=true, bool doErr=false);
215 
216  static int v_radplot(float data[],int nbin, float rmin, float rmax,
217  float xmin, float xmax, float ymin, float ymax, int nx, int ny);
218 
219 
220  // Module for v_lplot.
221 
222  static int v_lnewx(float xmins, float xmaxs, float ymins, float ymaxs,
223  float *xmin, float *xmax, float *ymin, float *ymax,
224  int narr,float xarr[], float yarr[]);
225 
226  // Module for v_lplot.
227 
228  static int v_lwrite(int narr, float xarr[], float yarr[], float xmin,
229  float xmax, float ymin, float ymax);
230 
231  // Module for v_lplot.
232 
233  static int v_lnum(int narr, float xarr[], float yarr[], float xmin,
234  float xmax, float ymin, float ymax);
235 
236  // Module for v_lplot.
237 
238  static int v_lten(int narr, float xarr[], float yarr[], float xmin,
239  float xmax, float ymin, float ymax);
240 
241  // Module for v_hist.
242 
243  static int v_lzoom(float xmins, float xmaxs, float ymins, float ymaxs,
244  float *xmin, float *xmax, float *ymin, float *ymax);
245 
246  // Module for v_lplot -- Draw the line plot.
247 
248  static int v_ldraw(int narr, float xarr[], float yarr[],
249  std::string xlab, std::string ylab, std::string title,
250  bool doLine, bool doErr,
251  double xmin, double xmax, double ymin, double ymax);
252 
253  static void pgpTxt(float x, float y, float angle, float fjust, std::string text);
254 
255 
256  }; // End class PgUtil
257 
258  } // End namespace util
259 } // End namespace sza
260 
261 
262 
263 #endif // End #ifndef SZA_UTIL_PGUTIL_H
264 
265 /* LocalWords: useTimeLabeling
266  */