WXP C++ Library Version 6.74.6
Loading...
Searching...
No Matches
Plot.h
1#ifndef _WINC_PLOT
2#define _WINC_PLOT
3
4#include <WXP/ColorBar.h>
5#include <WXP/ColorMap.h>
6#include <WXP/Date.h>
7#include <WXP/Domain.h>
8#include <WXP/DomainVal.h>
9#include <WXP/EarthPoint.h>
10#include <WXP/EarthPoints.h>
11#include <WXP/GeomBox.h>
12#include <WXP/Graph.h>
13#include <WXP/GridPoint.h>
14#include <WXP/Image.h>
15#include <WXP/Listener.h>
16#include <WXP/Panel.h>
17#include <WXP/PlotAttr.h>
18#include <WXP/PlotLabel.h>
19#include <WXP/Point.h>
20#include <WXP/Points.h>
21#include <WXP/Rect.h>
22#include <WXP/String.h>
23#include <WXP/Timezone.h>
24
25namespace WXP {
26 class Plot : public Listener {
27 Graph graph;
28 ColorMap colormap;
29 String color_label;
30
31 static const int max_panel = 16;
32 char def_panel[50];
33 Panel panels[max_panel];
34 int cur_panel;
35 int num_panel;
36
37 int full;
38 int output;
39 int permit_callbacks;
40 bool draw[13];
41 char title[80];
42
43 int line_color;
44 int fill_color;
45 int text_color;
46 int mark_color;
47
48 int layer;
49 char trans_color[20];
50
51 static const int max_label = 30;
52 PlotLabel label[30];
53 int num_label;
54 char label_format[100];
55 int bar;
56 ColorBar cbar;
57 String logo;
58 bool time_sync;
59 char source[10];
60 float fore_hour;
61 Date date;
62 Timezone tz;
63
64 public:
65 Plot();
66 Plot( const char *param );
67 ~Plot();
68 int init();
69 int open( const char *param );
70 int open();
71 int close();
72 int setParam( const char *param );
73 int setLogo( const char *rlogo );
74 inline int setFixed( bool val ){ return graph.setFixed( val ); };
75 int getDevice( String &str );
76 void callback( const char *ev_str, const char *ev_data, const void *data );
77 inline int permitCallbacks( int val ){ permit_callbacks = val; return 1; };
78 int initPanel();
79 inline int setDefaultPanel( const char *str ){ StrLib::copy( def_panel, 30, str ); return 1 ;};
80 int setPanel( Rect &offset, float aspect, int halign, int valign );
81 int setPanel( Rect &offset, float aspect );
82 int setPanel( Rect &offset, Domain &ndomain );
83 int setPanel( Domain &domain );
84 int setPanel( Rect &offset );
85 int setPanel();
86 int setPanel( int ind );
87 int setPanelDomain( int ind, Domain &dom );
88 int getPanelDomain( int ind, Domain &dom );
89 int setDomain( Rect &offset, float aspect, int halign, int valign );
90 int setDomain( Rect &offset, float aspect );
91 int setDomain( Rect &offset, Domain &ndomain );
92 int setDomain( Domain &domain );
93 int setDomain( DomainVal &dv );
94 int setDomain( Rect &offset );
95 int setDomain();
96 DomainVal getDomainVal();
97 Domain getDomain();
98 int getProj();
99 float getPLat();
100 float getPLon();
101 float getDomVert();
102 float getDomAspect();
103 float getDomCLat();
104 float getDomCLon();
105 int getDomNx();
106 int getDomNy();
107 float getDomDx();
108 float getDomDy();
109 float getVert();
110 bool withinDomain( Point &pt );
111 bool withinDomain( EarthPoint &ept );
112 bool withinDomainExt( Point &pt, int ext );
113 bool withinDomainExt( EarthPoint &ept, int ext );
114 int whereDomain( Point &pt );
115 int whereDomain( EarthPoint &ept );
116
117 int newPanel( const char *params );
118 int clear();
119 int clearRect( Rect &rect );
120 int update();
121 int manage();
122 inline bool isManaged(){ return graph.isManaged(); };
123 int end();
124
125 inline bool isTimeSync(){ return time_sync; };
126 inline int setTimeSync( bool val ){ time_sync = val; return 1; };
127 inline int setDate( Date &rdate ){ date = rdate; return 1; };
128 inline bool isDateSet(){ return date.isSet(); };
129 inline int setForeHour( float val ){ fore_hour = val; return 1; };
130 int setDataSource( const char *str );
131
133 int getColorMap( ColorMap &map );
134 int allocColor( int ind );
135 int setColorMap( ColorMap &cmap );
136 int getColorRGB( int ind, float &r, float &g, float &b );
137 int getColorValue( const char *name );
138
139 int cropLine( Point &pt1, Point &pt2 );
140 int cropLine( Points &pts );
141 int drawLine( float x1, float y1, float x2, float y2 );
142 int drawLine( Point &pt1, Point &pt2 );
143 int drawLine( EarthPoint &ept1, EarthPoint &ept2 );
144 int drawLine( GridPoint &gpt1, GridPoint &gpt2 );
145 int drawLine( Points &pts );
146 int drawLine( EarthPoints &data );
147 int drawSpline( Points &data );
148 int drawSpline( EarthPoints &data );
149 int drawRect( float x1, float y1, float x2, float y2 );
150 int drawRect( Rect &rect );
151 int drawCircle( Point &pt, float rad );
152 int drawCircle( EarthPoint &ept, float rad );
153 int setLineColor( const char *name );
154 int setLineColor( int ind );
155 int setLineWidth( float width );
156 int setLineStyle( int style );
157 int setLine();
158 int setLine( PlotAttr &plot );
159 int setLine( const char *str );
160
161 int drawFill( Points &pts );
162 int drawFill( EarthPoints &data );
163 int drawFill( Rect &data );
164 int drawFillarea( Points &data );
165 int setFillColor( const char *name );
166 int setFillColor( int ind );
167 int setFillStyle( int index );
168 int setFill();
169 int setFill( PlotAttr &plot );
170 int setFill( const char *str );
171
172 int drawText( float x, float y, const char *text );
173 int drawText( Point &pt, const char *text );
174 int drawText( EarthPoint &ept, const char *text );
175 int drawText( GridPoint &gpt, const char *text );
176 int drawFormText( Point &pt, const char *format, ... );
177 int drawFormText( EarthPoint &ept, const char *format, ... );
178 int setTextHeight( float height );
179 int setTextWeight( float weight );
180 int setTextAlign( int hor, int vert );
181 int setTextColor( const char *name );
182 int setTextColor( int ind );
183 int setTextExpansion( float expansion );
184 int setTextSpacing( float space );
185 int setTextCharWidth( float width );
186 int setTextDirection( float x, float y );
187 int setFont( const char *str );
188 inline int setDropShadow( int val ){ return graph.setDropShadow( val ); };
189 inline int getDropShadow(){ return graph.getDropShadow(); };
190 int setText();
191 int setText( PlotAttr &plot );
192 int setText( PlotAttr &plot, float scale );
193 int setText( const char *str );
194
195 int drawMark( float x, float y );
196 int drawMark( Point &pt );
197 int drawMark( EarthPoint &ept );
198 int drawMark( GridPoint &gpt );
199 int setMarkColor( const char *name );
200 int setMarkColor( int ind );
201 int setMarkType( const char *type );
202 int setMarkType( int type );
203 int setMarkSize( float size );
204 int setMarkWeight( float weight );
205 int setMark();
206 int setMark( PlotAttr &plot );
207 int setMark( PlotAttr &plot, float scale );
208 int setMark( const char *str );
209
210 inline int setSymbol( const char *symbol ){
211 return graph.setSymbol( symbol );
212 }
213
214 inline int drawSymbol( Point pt, const char *string, float size ){
215 return graph.drawSymbol( pt, string, size );
216 }
217
218 int setImageAlign( int h, int v );
219 int drawImage( Image &image );
220 int drawImage( Image &image, int bgcolor );
221
222 inline int drawImage( Image &image, float x, float y ){
223 return graph.drawImage( image, x, y );
224 }
225
226 inline int drawImage( Image &image, int bgcolor, float x, float y ){
227 return graph.drawImage( image, bgcolor, x, y );
228 }
229
230 int drawImage( const char *file, float x, float y );
231 int drawImage( const char *file, float x, float y, const char *option );
232
233 inline int getTran(){
234 return graph.getTran();
235 }
236
237 inline int activateTran( int val ){
238 return graph.activateTran( val );
239 }
240
241 inline int setViewport( int num, Rect rect ){
242 return graph.setViewport( num, rect );
243 }
244
245 inline int getViewport( Rect &lim ){
246 return graph.getViewport( lim );
247 }
248
249 inline int setWindow( int num, Rect rect ){
250 return graph.setWindow( num, rect );
251 }
252
253 inline int getWindow( Rect &lim ){
254 return graph.getWindow( lim );
255 }
256
257 inline int tran( EarthPoint &ept, Point &pt ){
258 return panels[cur_panel].domain.tran( ept, pt );
259 }
260
261 inline int tran( Point &pt, EarthPoint &ept ){
262 return panels[cur_panel].domain.tran( pt, ept );
263 }
264
265 inline int tran( GridPoint &gpt, Point &pt ){
266 return panels[cur_panel].domain.tran( gpt, pt );
267 }
268
269 inline int tran( Point &pt, GridPoint &gpt ){
270 return panels[cur_panel].domain.tran( pt, gpt );
271 }
272
273 inline int tran( EarthPoint &ept, GridPoint &gpt ){
274 return panels[cur_panel].domain.tran( ept, gpt );
275 }
276
277 inline int tran( GridPoint &gpt, EarthPoint &ept ){
278 return panels[cur_panel].domain.tran( gpt, ept );
279 }
280
281 inline int tran( int val, Point &pt ){
282 return panels[cur_panel].domain.tran( val, pt );
283 }
284
285 inline int tran( int val, GridPoint &gpt ){
286 return panels[cur_panel].domain.tran( val, gpt );
287 }
288
289 inline int tran( int val, EarthPoint &ept ){
290 return panels[cur_panel].domain.tran( val, ept );
291 }
292
293 inline int tran( Domain &dom, Point &pt1, Point &pt2 ){
294 return Domain::translate( dom, panels[cur_panel].domain, pt1, pt2 );
295 }
296
297 int tranPlotWindow( float x1, float y1, float &x2, float &y2 );
298
299 inline int tranWindow( int tran1, Point &pt1, int tran2, Point &pt2 ){
300 return graph.tranWindow( tran1, pt1, tran2, pt2 );
301 }
302
303 inline int adjustDom( Point &pt ){
304 return panels[cur_panel].domain.adjust( pt );
305 }
306
307 inline int adjustDom( Points &pts ){
308 return panels[cur_panel].domain.adjust( pts );
309 }
310
311 inline float adjustDir( float dir, Point &pt ){
312 return panels[cur_panel].domain.adjustDir( dir, pt );
313 }
314
315 inline int offsetPoint( Point pt, float dir, float rad, Point &opt ){
316 return panels[cur_panel].domain.offset( pt, dir, rad, opt );
317 }
318
319 inline int offsetPoint( EarthPoint pt, float dir, float rad, EarthPoint &opt ){
320 return panels[cur_panel].domain.offsetLatLon( pt, dir, rad, opt );
321 }
322
323 inline float getMapFactor( EarthPoint ept ){
324 return panels[cur_panel].domain.getMapFactor( ept );
325 }
326
327 inline int getInverse(){
328 return graph.getInverse();
329 }
330
331 int addCallback( const char *ev, Listener *list, const void *data );
332 int message( const char *str, ... );
333
334 int getViewDomain( Domain &domain );
335 int drawBorder();
336 int saveImage(const char *file, const char *type);
337 int saveImage(const char *file);
338 int getImage(Image &image);
339 int setLabelColor( const char *str );
340 int setLabelFormat( const char *str );
341 int addLabel( const char *loc, const char *label );
342 int setLabel( const char *loc, const char *label );
343 int getLabelPosIndex( const char *str );
344 int printLabels();
345 int formatLabel( const char *form, char *str, int len );
346 int clearLabels();
347 int drawLabels();
348 int setBarLocate( const char *str );
349 int setBarRange( Range &rrange );
350 int setBar( ColorFill &rfile, Range &rrange );
351 int setBar( ColorFill &rfill );
352 int setBar( Enhance &renh );
353 int drawBar( Range &rrange );
354 int drawEnhBar();
355 int drawBar();
356 int setCursor( int type );
357 int done();
358 int newFrame();
359 int clearFrame();
360 int deleteFrame( int ind );
361 int deleteAllFrames();
362 int setFull( int val );
363 int getFull();
364 int setDrawing( const char *str );
365 bool isDrawing( int ind );
366 int printDrawing();
367 inline int wrapLine( Points &pts ){ return panels[cur_panel].domain.wrapLine( pts ); };
368 inline int offsetLine( Points &pts, int flag ){ return panels[cur_panel].domain.offsetLine( pts, flag ); };
369
370 inline int printTran(){ graph.printTran(); return 1; };
371 inline int printDomain(){ panels[cur_panel].domain.print(); return 1; };
372
373 static int decodeGeometryStr( const char *str, GeomBox &geom );
374 static int decodePanelStr( Rect rect, const char *str, GeomBox &geom );
375
376 /*
377 Output types
378 */
379 enum Output {
380 WINDOW,
381 IMAGE,
382 PRINT
383 };
384 enum DrawingType {
385 DRAW_PLOT,
386 DRAW_DATA,
387 DRAW_MAP,
388 DRAW_TEXT_UL,
389 DRAW_TEXT_UC,
390 DRAW_TEXT_UR,
391 DRAW_TEXT_LL,
392 DRAW_TEXT_LC,
393 DRAW_TEXT_LR,
394 DRAW_BORD
395 };
396 enum TranType {
397 TRAN_BASE,
398 TRAN_PROJ,
399 TRAN_OVER
400 };
401
402 };
403}
404#endif
This class sets up color fill parameters.
Definition: ColorFill.h:8
This class defines a specific color map. This is a mapping between color indices, color names and RGB...
Definition: ColorMap.h:8
This class stores date and time information.
Definition: Date.h:8
bool isSet()
Definition: Date.cc:100
This class stores and manipulates domain data.
Definition: Domain.h:19
int print()
Definition: Domain.cc:2015
int offsetLine(Point &pt1, Point &pt2, int flag)
Definition: Domain.cc:1912
int tran(EarthPoint &ept, Point &pt)
Definition: Domain.cc:422
int offset(Point &pt, float dir, float rad, Point &opt)
Definition: Domain.cc:1748
int wrapLine(Point &pt1, Point &pt2)
Definition: Domain.cc:1841
float getMapFactor(EarthPoint &ept)
Definition: Domain.cc:1810
float adjustDir(float dir, Point &pt)
Definition: Domain.cc:1542
static int translate(Domain &dom1, Domain &dom2, Point &pt1, Point &pt2)
Definition: Domain.cc:1446
static int offsetLatLon(EarthPoint &ept, float dir, float rad, EarthPoint &opt)
Definition: Domain.cc:1764
int adjust(Point &pt)
Definition: Domain.cc:1491
This class creates an array a earth points (lat, lon)
Definition: EarthPoints.h:9
This class creates and accesses satellite enhancement files.
Definition: Enhance.h:7
This structure sets size and location of a geometric box.
Definition: GeomBox.h:5
This class plots to a device independent graphics interface.
Definition: Graph.h:18
int activateTran()
Definition: Graph.cc:593
int getDropShadow()
Definition: Graph.cc:1359
int setDropShadow(int val)
Definition: Graph.cc:1350
int getTran()
Definition: Graph.cc:585
int setWindow(int num, Rect &rect)
Definition: Graph.cc:547
int drawSymbol(float ox, float oy, const char *string, float size)
Definition: Graph.cc:1718
int setSymbol(const char *file)
Definition: Graph.cc:1701
int printTran()
Definition: Graph.cc:1909
int getWindow(Rect &rect)
Definition: Graph.cc:566
int drawImage(Image &image, float x, float y)
Definition: Graph.cc:1795
bool isManaged()
Definition: Graph.h:83
int setFixed(bool val)
Definition: Graph.cc:289
int tranWindow(int tran1, float x1, float y1, int tran2, float &x2, float &y2)
Definition: Graph.cc:656
bool getInverse()
Definition: Graph.cc:332
int setViewport(int num, Rect &rect)
Definition: Graph.cc:473
int getViewport(Rect &rect)
Definition: Graph.cc:492
This class defines an image.
Definition: Image.h:19
This virtual class defines the callback method for use with plotting.
Definition: Listener.h:11
This class stores plot attributes.
Definition: PlotAttr.h:8
This class defines mid-level graphics commands. Calls the Graph object for actual graphics output.
Definition: Plot.h:26
int setLineWidth(float width)
Definition: Plot.cc:1464
int drawLine(float x1, float y1, float x2, float y2)
Definition: Plot.cc:1095
int update()
Definition: Plot.cc:878
int setLineStyle(int style)
Definition: Plot.cc:1472
void callback(const char *ev_str, const char *ev_data, const void *data)
Definition: Plot.cc:300
~Plot()
Definition: Plot.cc:248
int drawMark(float x, float y)
Definition: Plot.cc:1866
int setTextColor(const char *name)
Definition: Plot.cc:1739
int setLine()
Definition: Plot.cc:1479
int drawCircle(Point &pt, float rad)
Definition: Plot.cc:1399
int setText()
Definition: Plot.cc:1807
int drawFillarea(Points &data)
Definition: Plot.cc:1560
int setLabelFormat(const char *str)
Definition: Plot.cc:2198
int setFill()
Definition: Plot.cc:1627
int open()
Definition: Plot.cc:234
int setColorMap(ColorMap &cmap)
Definition: Plot.cc:943
int end()
Definition: Plot.cc:868
int drawSpline(Points &data)
Definition: Plot.cc:1264
int setFillColor(const char *name)
Definition: Plot.cc:1588
int setFillStyle(int index)
Definition: Plot.cc:1620
int manage()
Definition: Plot.cc:888
int allocColor(int ind)
Definition: Plot.cc:926
int addLabel(const char *loc, const char *label)
Definition: Plot.cc:2208
int setTextDirection(float x, float y)
Definition: Plot.cc:1796
ColorMap getColorMap()
Definition: Plot.cc:911
int drawText(float x, float y, const char *text)
Definition: Plot.cc:1669
int drawRect(float x1, float y1, float x2, float y2)
Definition: Plot.cc:1378
int drawFill(Points &pts)
Definition: Plot.cc:1528
int setLabelColor(const char *str)
Definition: Plot.cc:2189
int setLineColor(const char *name)
Definition: Plot.cc:1432
int setLabel(const char *loc, const char *label)
Definition: Plot.cc:2223
Plot()
Definition: Plot.cc:45
int drawFormText(Point &pt, const char *format,...)
Definition: Plot.cc:1703
int setMark()
Definition: Plot.cc:1937
int close()
Definition: Plot.cc:241
This class creates an array a 2D points (x, y)
Definition: Points.h:8
static int copy(char *s1, int len1, const char s2)
Definition: StrLib.cc:506
This is a variable length string class.
Definition: String.h:5
This class manipulates timezones.
Definition: Timezone.h:5
All WXP classes fall under the WXP namespace.
Definition: Angle.h:4
This class holds data to plot a color bar.
Definition: ColorBar.h:9
This struct defines basic domain parameters.
Definition: DomainVal.h:5
This struct defines earth point values (lat, lon, elev)
Definition: EarthPoint.h:5
This struct defines basic gridpoint values.
Definition: GridPoint.h:5
This defines a plotting region and its attributes.
Definition: Panel.h:8
This struct stores labels for plot annotation.
Definition: PlotLabel.h:5
This struct sets a 3D point (x, y, z)
Definition: Point.h:5
This struct defines a simple range of values.
Definition: Range.h:5
This structure defines rectangle coordinates.
Definition: Rect.h:5