WXP C++ Library Version 6.74.9
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 inline int getNumFill(){ return colormap.getNumFill(); };
135 int allocColor( int ind );
136 int setColorMap( ColorMap &cmap );
137 int getColorRGB( int ind, float &r, float &g, float &b );
138 int getColorValue( const char *name );
139
140 int cropLine( Point &pt1, Point &pt2 );
141 int cropLine( Points &pts );
142 int drawLine( float x1, float y1, float x2, float y2 );
143 int drawLine( Point &pt1, Point &pt2 );
144 int drawLine( EarthPoint &ept1, EarthPoint &ept2 );
145 int drawLine( GridPoint &gpt1, GridPoint &gpt2 );
146 int drawLine( Points &pts );
147 int drawLine( EarthPoints &data );
148 int drawSpline( Points &data );
149 int drawSpline( EarthPoints &data );
150 int drawRect( float x1, float y1, float x2, float y2 );
151 int drawRect( Rect &rect );
152 int drawCircle( Point &pt, float rad );
153 int drawCircle( EarthPoint &ept, float rad );
154 int setLineColor( const char *name );
155 int setLineColor( int ind );
156 int setLineWidth( float width );
157 int setLineStyle( int style );
158 int setLine();
159 int setLine( PlotAttr &plot );
160 int setLine( const char *str );
161
162 int drawFill( Points &pts );
163 int drawFill( EarthPoints &data );
164 int drawFill( Rect &data );
165 int drawFillarea( Points &data );
166 int setFillColor( const char *name );
167 int setFillColor( int ind );
168 int setFillStyle( int index );
169 int setFill();
170 int setFill( PlotAttr &plot );
171 int setFill( const char *str );
172
173 int drawText( float x, float y, const char *text );
174 int drawText( Point &pt, const char *text );
175 int drawText( EarthPoint &ept, const char *text );
176 int drawText( GridPoint &gpt, const char *text );
177 int drawFormText( Point &pt, const char *format, ... );
178 int drawFormText( EarthPoint &ept, const char *format, ... );
179 int setTextHeight( float height );
180 int setTextWeight( float weight );
181 int setTextAlign( int hor, int vert );
182 int setTextColor( const char *name );
183 int setTextColor( int ind );
184 int setTextExpansion( float expansion );
185 int setTextSpacing( float space );
186 int setTextCharWidth( float width );
187 int setTextDirection( float x, float y );
188 int setFont( const char *str );
189 inline int setDropShadow( int val ){ return graph.setDropShadow( val ); };
190 inline int getDropShadow(){ return graph.getDropShadow(); };
191 int setText();
192 int setText( PlotAttr &plot );
193 int setText( PlotAttr &plot, float scale );
194 int setText( const char *str );
195
196 int drawMark( float x, float y );
197 int drawMark( Point &pt );
198 int drawMark( EarthPoint &ept );
199 int drawMark( GridPoint &gpt );
200 int setMarkColor( const char *name );
201 int setMarkColor( int ind );
202 int setMarkType( const char *type );
203 int setMarkType( int type );
204 int setMarkSize( float size );
205 int setMarkWeight( float weight );
206 int setMark();
207 int setMark( PlotAttr &plot );
208 int setMark( PlotAttr &plot, float scale );
209 int setMark( const char *str );
210
211 inline int setSymbol( const char *symbol ){
212 return graph.setSymbol( symbol );
213 }
214
215 inline int drawSymbol( Point pt, const char *string, float size ){
216 return graph.drawSymbol( pt, string, size );
217 }
218
219 int setImageAlign( int h, int v );
220 int drawImage( Image &image );
221 int drawImage( Image &image, int bgcolor );
222
223 inline int drawImage( Image &image, float x, float y ){
224 return graph.drawImage( image, x, y );
225 }
226
227 inline int drawImage( Image &image, int bgcolor, float x, float y ){
228 return graph.drawImage( image, bgcolor, x, y );
229 }
230
231 int drawImage( const char *file, float x, float y );
232 int drawImage( const char *file, float x, float y, const char *option );
233
234 inline int getTran(){
235 return graph.getTran();
236 }
237
238 inline int activateTran( int val ){
239 return graph.activateTran( val );
240 }
241
242 inline int setViewport( int num, Rect rect ){
243 return graph.setViewport( num, rect );
244 }
245
246 inline int getViewport( Rect &lim ){
247 return graph.getViewport( lim );
248 }
249
250 inline int setWindow( int num, Rect rect ){
251 return graph.setWindow( num, rect );
252 }
253
254 inline int getWindow( Rect &lim ){
255 return graph.getWindow( lim );
256 }
257
258 inline int tran( EarthPoint &ept, Point &pt ){
259 return panels[cur_panel].domain.tran( ept, pt );
260 }
261
262 inline int tran( Point &pt, EarthPoint &ept ){
263 return panels[cur_panel].domain.tran( pt, ept );
264 }
265
266 inline int tran( GridPoint &gpt, Point &pt ){
267 return panels[cur_panel].domain.tran( gpt, pt );
268 }
269
270 inline int tran( Point &pt, GridPoint &gpt ){
271 return panels[cur_panel].domain.tran( pt, gpt );
272 }
273
274 inline int tran( EarthPoint &ept, GridPoint &gpt ){
275 return panels[cur_panel].domain.tran( ept, gpt );
276 }
277
278 inline int tran( GridPoint &gpt, EarthPoint &ept ){
279 return panels[cur_panel].domain.tran( gpt, ept );
280 }
281
282 inline int tran( int val, Point &pt ){
283 return panels[cur_panel].domain.tran( val, pt );
284 }
285
286 inline int tran( int val, GridPoint &gpt ){
287 return panels[cur_panel].domain.tran( val, gpt );
288 }
289
290 inline int tran( int val, EarthPoint &ept ){
291 return panels[cur_panel].domain.tran( val, ept );
292 }
293
294 inline int tran( Domain &dom, Point &pt1, Point &pt2 ){
295 return Domain::translate( dom, panels[cur_panel].domain, pt1, pt2 );
296 }
297
298 int tranPlotWindow( float x1, float y1, float &x2, float &y2 );
299
300 inline int tranWindow( int tran1, Point &pt1, int tran2, Point &pt2 ){
301 return graph.tranWindow( tran1, pt1, tran2, pt2 );
302 }
303
304 inline int adjustDom( Point &pt ){
305 return panels[cur_panel].domain.adjust( pt );
306 }
307
308 inline int adjustDom( Points &pts ){
309 return panels[cur_panel].domain.adjust( pts );
310 }
311
312 inline float adjustDir( float dir, Point &pt ){
313 return panels[cur_panel].domain.adjustDir( dir, pt );
314 }
315
316 inline int offsetPoint( Point pt, float dir, float rad, Point &opt ){
317 return panels[cur_panel].domain.offset( pt, dir, rad, opt );
318 }
319
320 inline int offsetPoint( EarthPoint pt, float dir, float rad, EarthPoint &opt ){
321 return panels[cur_panel].domain.offsetLatLon( pt, dir, rad, opt );
322 }
323
324 inline float getMapFactor( EarthPoint ept ){
325 return panels[cur_panel].domain.getMapFactor( ept );
326 }
327
328 inline int getInverse(){
329 return graph.getInverse();
330 }
331
332 int addCallback( const char *ev, Listener *list, const void *data );
333 int message( const char *str, ... );
334
335 int getViewDomain( Domain &domain );
336 int drawBorder();
337 int saveImage(const char *file, const char *type);
338 int saveImage(const char *file);
339 int getImage(Image &image);
340 int setLabelColor( const char *str );
341 int setLabelFormat( const char *str );
342 int addLabel( const char *loc, const char *label );
343 int setLabel( const char *loc, const char *label );
344 int getLabelPosIndex( const char *str );
345 int printLabels();
346 int formatLabel( const char *form, char *str, int len );
347 int clearLabels();
348 int drawLabels();
349 int setBarLocate( const char *str );
350 int setBarRange( Range &rrange );
351 int setBar( ColorFill &rfile, Range &rrange );
352 int setBar( ColorFill &rfill );
353 int setBar( Enhance &renh );
354 int drawBar( Range &rrange );
355 int drawEnhBar();
356 int drawBar();
357 int setCursor( int type );
358 int done();
359 int newFrame();
360 int clearFrame();
361 int deleteFrame( int ind );
362 int deleteAllFrames();
363 int setFull( int val );
364 int getFull();
365 int setDrawing( const char *str );
366 bool isDrawing( int ind );
367 int printDrawing();
368 inline int wrapLine( Points &pts ){ return panels[cur_panel].domain.wrapLine( pts ); };
369 inline int offsetLine( Points &pts, int flag ){ return panels[cur_panel].domain.offsetLine( pts, flag ); };
370
371 inline int printTran(){ graph.printTran(); return 1; };
372 inline int printDomain(){ panels[cur_panel].domain.print(); return 1; };
373
374 static int decodeGeometryStr( const char *str, GeomBox &geom );
375 static int decodePanelStr( Rect rect, const char *str, GeomBox &geom );
376
377 /*
378 Output types
379 */
380 enum Output {
381 WINDOW,
382 IMAGE,
383 PRINT
384 };
385 enum DrawingType {
386 DRAW_PLOT,
387 DRAW_DATA,
388 DRAW_MAP,
389 DRAW_TEXT_UL,
390 DRAW_TEXT_UC,
391 DRAW_TEXT_UR,
392 DRAW_TEXT_LL,
393 DRAW_TEXT_LC,
394 DRAW_TEXT_LR,
395 DRAW_BORD
396 };
397 enum TranType {
398 TRAN_BASE,
399 TRAN_PROJ,
400 TRAN_OVER
401 };
402
403 };
404}
405#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
int getNumFill()
Definition ColorMap.h:38
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:2035
int offsetLine(Point &pt1, Point &pt2, int flag)
Definition Domain.cc:1932
int tran(EarthPoint &ept, Point &pt)
Definition Domain.cc:440
int offset(Point &pt, float dir, float rad, Point &opt)
Definition Domain.cc:1768
int wrapLine(Point &pt1, Point &pt2)
Definition Domain.cc:1861
float getMapFactor(EarthPoint &ept)
Definition Domain.cc:1830
float adjustDir(float dir, Point &pt)
Definition Domain.cc:1562
static int translate(Domain &dom1, Domain &dom2, Point &pt1, Point &pt2)
Definition Domain.cc:1466
static int offsetLatLon(EarthPoint &ept, float dir, float rad, EarthPoint &opt)
Definition Domain.cc:1784
int adjust(Point &pt)
Definition Domain.cc:1511
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:599
int getDropShadow()
Definition Graph.cc:1365
int setDropShadow(int val)
Definition Graph.cc:1356
int getTran()
Definition Graph.cc:591
int setWindow(int num, Rect &rect)
Definition Graph.cc:553
int drawSymbol(float ox, float oy, const char *string, float size)
Definition Graph.cc:1724
int setSymbol(const char *file)
Definition Graph.cc:1707
int printTran()
Definition Graph.cc:1915
int getWindow(Rect &rect)
Definition Graph.cc:572
int drawImage(Image &image, float x, float y)
Definition Graph.cc:1801
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:662
bool getInverse()
Definition Graph.cc:332
int setViewport(int num, Rect &rect)
Definition Graph.cc:479
int getViewport(Rect &rect)
Definition Graph.cc:498
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:1465
int drawLine(float x1, float y1, float x2, float y2)
Definition Plot.cc:1096
int update()
Definition Plot.cc:879
int setLineStyle(int style)
Definition Plot.cc:1473
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:1867
int setTextColor(const char *name)
Definition Plot.cc:1740
int setLine()
Definition Plot.cc:1480
int drawCircle(Point &pt, float rad)
Definition Plot.cc:1400
int setText()
Definition Plot.cc:1808
int drawFillarea(Points &data)
Definition Plot.cc:1561
int setLabelFormat(const char *str)
Definition Plot.cc:2199
int setFill()
Definition Plot.cc:1628
int open()
Definition Plot.cc:234
int setColorMap(ColorMap &cmap)
Definition Plot.cc:944
int end()
Definition Plot.cc:869
int drawSpline(Points &data)
Definition Plot.cc:1265
int setFillColor(const char *name)
Definition Plot.cc:1589
int setFillStyle(int index)
Definition Plot.cc:1621
int manage()
Definition Plot.cc:889
int allocColor(int ind)
Definition Plot.cc:927
int addLabel(const char *loc, const char *label)
Definition Plot.cc:2209
int setTextDirection(float x, float y)
Definition Plot.cc:1797
ColorMap getColorMap()
Definition Plot.cc:912
int drawText(float x, float y, const char *text)
Definition Plot.cc:1670
int drawRect(float x1, float y1, float x2, float y2)
Definition Plot.cc:1379
int drawFill(Points &pts)
Definition Plot.cc:1529
int setLabelColor(const char *str)
Definition Plot.cc:2190
int setLineColor(const char *name)
Definition Plot.cc:1433
int setLabel(const char *loc, const char *label)
Definition Plot.cc:2224
Plot()
Definition Plot.cc:45
int drawFormText(Point &pt, const char *format,...)
Definition Plot.cc:1704
int setMark()
Definition Plot.cc:1938
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