xref: /petsc/src/sys/classes/draw/utils/lgc.c (revision a6404fbfb1cfbf30d2bac9856cef3bf7411483d5)
1 
2 #include <petscviewer.h>
3 #include <../src/sys/classes/draw/utils/lgimpl.h>  /*I   "petscdraw.h"  I*/
4 PetscClassId PETSC_DRAWLG_CLASSID = 0;
5 
6 #undef __FUNCT__
7 #define __FUNCT__ "PetscDrawLGGetAxis"
8 /*@
9    PetscDrawLGGetAxis - Gets the axis context associated with a line graph.
10    This is useful if one wants to change some axis property, such as
11    labels, color, etc. The axis context should not be destroyed by the
12    application code.
13 
14    Not Collective, if PetscDrawLG is parallel then PetscDrawAxis is parallel
15 
16    Input Parameter:
17 .  lg - the line graph context
18 
19    Output Parameter:
20 .  axis - the axis context
21 
22    Level: advanced
23 
24 @*/
25 PetscErrorCode  PetscDrawLGGetAxis(PetscDrawLG lg,PetscDrawAxis *axis)
26 {
27   PetscFunctionBegin;
28   PetscValidPointer(axis,2);
29   if (!lg) {*axis = NULL; PetscFunctionReturn(0);}
30   PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,1);
31   *axis = lg->axis;
32   PetscFunctionReturn(0);
33 }
34 
35 #undef __FUNCT__
36 #define __FUNCT__ "PetscDrawLGGetDraw"
37 /*@
38    PetscDrawLGGetDraw - Gets the draw context associated with a line graph.
39 
40    Not Collective, if PetscDrawLG is parallel then PetscDraw is parallel
41 
42    Input Parameter:
43 .  lg - the line graph context
44 
45    Output Parameter:
46 .  draw - the draw context
47 
48    Level: intermediate
49 
50 @*/
51 PetscErrorCode  PetscDrawLGGetDraw(PetscDrawLG lg,PetscDraw *draw)
52 {
53   PetscFunctionBegin;
54   PetscValidPointer(draw,2);
55   if (!lg) {*draw = NULL; PetscFunctionReturn(0);}
56   PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,1);
57   *draw = lg->win;
58   PetscFunctionReturn(0);
59 }
60 
61 
62 #undef __FUNCT__
63 #define __FUNCT__ "PetscDrawLGSPDraw"
64 /*@
65    PetscDrawLGSPDraw - Redraws a line graph.
66 
67    Not Collective,but ignored by all processors except processor 0 in PetscDrawLG
68 
69    Input Parameter:
70 .  lg - the line graph context
71 
72    Level: intermediate
73 
74 .seealso: PetscDrawLGDraw(), PetscDrawSPDraw()
75 
76    Developer Notes: This code cheats and uses the fact that the LG and SP structs are the same
77 
78 @*/
79 PetscErrorCode  PetscDrawLGSPDraw(PetscDrawLG lg,PetscDrawSP spin)
80 {
81   PetscDrawLG    sp = (PetscDrawLG)spin;
82   PetscReal      xmin,xmax,ymin,ymax;
83   PetscErrorCode ierr;
84   PetscBool      isnull;
85   PetscMPIInt    rank;
86   PetscDraw      draw;
87 
88   PetscFunctionBegin;
89   if (!lg || !spin) {PetscFunctionReturn(0);}
90   PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,1);
91   PetscValidHeaderSpecific(sp,PETSC_DRAWSP_CLASSID,2);
92 
93   draw = lg->win;
94   ierr = PetscDrawIsNull(draw,&isnull);CHKERRQ(ierr);
95   if (isnull) PetscFunctionReturn(0);
96   ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)lg),&rank);CHKERRQ(ierr);
97 
98   ierr = PetscDrawCheckResizedWindow(draw);CHKERRQ(ierr);
99   ierr = PetscDrawSynchronizedClear(draw);CHKERRQ(ierr);
100   ierr = PetscDrawCollectiveBegin(draw);CHKERRQ(ierr);
101 
102   xmin = PetscMin(lg->xmin,sp->xmin); ymin = PetscMin(lg->ymin,sp->ymin);
103   xmax = PetscMax(lg->xmax,sp->xmax); ymax = PetscMax(lg->ymax,sp->ymax);
104   ierr = PetscDrawAxisSetLimits(lg->axis,xmin,xmax,ymin,ymax);CHKERRQ(ierr);
105   ierr = PetscDrawAxisDraw(lg->axis);CHKERRQ(ierr);
106 
107   if (!rank) {
108     int i,j,dim,nopts;
109     dim   = lg->dim;
110     nopts = lg->nopts;
111     for (i=0; i<dim; i++) {
112       for (j=1; j<nopts; j++) {
113         ierr = PetscDrawLine(draw,lg->x[(j-1)*dim+i],lg->y[(j-1)*dim+i],lg->x[j*dim+i],lg->y[j*dim+i],PETSC_DRAW_BLACK+i);CHKERRQ(ierr);
114         if (lg->use_markers) {
115           ierr = PetscDrawMarker(draw,lg->x[j*dim+i],lg->y[j*dim+i],PETSC_DRAW_RED);CHKERRQ(ierr);
116         }
117       }
118     }
119     dim   = sp->dim;
120     nopts = sp->nopts;
121     for (i=0; i<dim; i++) {
122       for (j=0; j<nopts; j++) {
123         ierr = PetscDrawMarker(draw,sp->x[j*dim+i],sp->y[j*dim+i],PETSC_DRAW_RED);CHKERRQ(ierr);
124       }
125     }
126   }
127 
128   ierr = PetscDrawCollectiveEnd(draw);CHKERRQ(ierr);
129   ierr = PetscDrawSynchronizedFlush(lg->win);CHKERRQ(ierr);
130   ierr = PetscDrawPause(lg->win);CHKERRQ(ierr);
131   PetscFunctionReturn(0);
132 }
133 
134 
135 #undef __FUNCT__
136 #define __FUNCT__ "PetscDrawLGCreate"
137 /*@
138     PetscDrawLGCreate - Creates a line graph data structure.
139 
140     Collective over PetscDraw
141 
142     Input Parameters:
143 +   draw - the window where the graph will be made.
144 -   dim - the number of curves which will be drawn
145 
146     Output Parameters:
147 .   outlg - the line graph context
148 
149     Level: intermediate
150 
151     Concepts: line graph^creating
152 
153 .seealso:  PetscDrawLGDestroy()
154 @*/
155 PetscErrorCode  PetscDrawLGCreate(PetscDraw draw,PetscInt dim,PetscDrawLG *outlg)
156 {
157   PetscBool      isnull;
158   PetscDrawLG    lg;
159   PetscErrorCode ierr;
160 
161   PetscFunctionBegin;
162   PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1);
163   PetscValidLogicalCollectiveInt(draw,dim,2);
164   PetscValidPointer(outlg,3);
165 
166   ierr = PetscDrawIsNull(draw,&isnull);CHKERRQ(ierr);
167   if (isnull) {*outlg = NULL; PetscFunctionReturn(0);}
168 
169   ierr = PetscHeaderCreate(lg,PETSC_DRAWLG_CLASSID,"PetscDrawLG","Line graph","Draw",PetscObjectComm((PetscObject)draw),PetscDrawLGDestroy,NULL);CHKERRQ(ierr);
170   ierr = PetscLogObjectParent((PetscObject)draw,(PetscObject)lg);CHKERRQ(ierr);
171 
172   ierr = PetscObjectReference((PetscObject)draw);CHKERRQ(ierr);
173   lg->win = draw;
174 
175   lg->view    = NULL;
176   lg->destroy = NULL;
177   lg->nopts   = 0;
178   lg->dim     = dim;
179   lg->xmin    = 1.e20;
180   lg->ymin    = 1.e20;
181   lg->xmax    = -1.e20;
182   lg->ymax    = -1.e20;
183 
184   ierr = PetscMalloc2(dim*CHUNCKSIZE,&lg->x,dim*CHUNCKSIZE,&lg->y);CHKERRQ(ierr);
185   ierr = PetscLogObjectMemory((PetscObject)lg,2*dim*CHUNCKSIZE*sizeof(PetscReal));CHKERRQ(ierr);
186 
187   lg->len     = dim*CHUNCKSIZE;
188   lg->loc     = 0;
189   lg->use_markers= PETSC_FALSE;
190 
191   ierr = PetscDrawAxisCreate(draw,&lg->axis);CHKERRQ(ierr);
192   ierr = PetscLogObjectParent((PetscObject)lg,(PetscObject)lg->axis);CHKERRQ(ierr);
193 
194   *outlg = lg;
195   PetscFunctionReturn(0);
196 }
197 
198 #undef __FUNCT__
199 #define __FUNCT__ "PetscDrawLGSetColors"
200 /*@
201    PetscDrawLGSetColors - Sets the color of each line graph drawn
202 
203    Logically Collective over PetscDrawLG
204 
205    Input Parameter:
206 +  lg - the line graph context.
207 -  colors - the colors
208 
209    Level: intermediate
210 
211    Concepts: line graph^setting number of lines
212 
213 @*/
214 PetscErrorCode  PetscDrawLGSetColors(PetscDrawLG lg,const int *colors)
215 {
216   PetscErrorCode ierr;
217 
218   PetscFunctionBegin;
219   if (!lg) PetscFunctionReturn(0);
220   PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,1);
221 
222   ierr = PetscFree(lg->colors);CHKERRQ(ierr);
223   ierr = PetscMalloc1(lg->dim,&lg->colors);CHKERRQ(ierr);
224   ierr = PetscMemcpy(lg->colors,colors,lg->dim*sizeof(int));CHKERRQ(ierr);
225   PetscFunctionReturn(0);
226 }
227 
228 #undef __FUNCT__
229 #undef __FUNCT__
230 #define __FUNCT__ "PetscDrawLGSetLegend"
231 /*@C
232    PetscDrawLGSetLegend - sets the names of each curve plotted
233 
234    Logically Collective over PetscDrawLG
235 
236    Input Parameter:
237 +  lg - the line graph context.
238 -  names - the names for each curve
239 
240    Level: intermediate
241 
242    Concepts: line graph^setting number of lines
243 
244 @*/
245 PetscErrorCode  PetscDrawLGSetLegend(PetscDrawLG lg,const char *const *names)
246 {
247   PetscErrorCode ierr;
248   PetscInt       i;
249 
250   PetscFunctionBegin;
251   if (!lg) PetscFunctionReturn(0);
252   PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,1);
253 
254   if (lg->legend) {
255     for (i=0; i<lg->dim; i++) {
256       ierr = PetscFree(lg->legend[i]);CHKERRQ(ierr);
257     }
258     ierr = PetscFree(lg->legend);CHKERRQ(ierr);
259   }
260   if (names) {
261     ierr = PetscMalloc1(lg->dim,&lg->legend);CHKERRQ(ierr);
262     for (i=0; i<lg->dim; i++) {
263       ierr = PetscStrallocpy(names[i],&lg->legend[i]);CHKERRQ(ierr);
264     }
265   }
266   PetscFunctionReturn(0);
267 }
268 
269 #undef __FUNCT__
270 #define __FUNCT__ "PetscDrawLGGetDimension"
271 /*@
272    PetscDrawLGGetDimension - Change the number of lines that are to be drawn.
273 
274    Logically Collective over PetscDrawLG
275 
276    Input Parameter:
277 .  lg - the line graph context.
278 
279    Output Parameter:
280 .  dim - the number of curves.
281 
282    Level: intermediate
283 
284    Concepts: line graph^setting number of lines
285 
286 @*/
287 PetscErrorCode  PetscDrawLGGetDimension(PetscDrawLG lg,PetscInt *dim)
288 {
289   PetscFunctionBegin;
290   if (!lg) PetscFunctionReturn(0);
291   PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,1);
292 
293   *dim = lg->dim;
294   PetscFunctionReturn(0);
295 }
296 
297 #undef __FUNCT__
298 #define __FUNCT__ "PetscDrawLGSetDimension"
299 /*@
300    PetscDrawLGSetDimension - Change the number of lines that are to be drawn.
301 
302    Logically Collective over PetscDrawLG
303 
304    Input Parameter:
305 +  lg - the line graph context.
306 -  dim - the number of curves.
307 
308    Level: intermediate
309 
310    Concepts: line graph^setting number of lines
311 
312 @*/
313 PetscErrorCode  PetscDrawLGSetDimension(PetscDrawLG lg,PetscInt dim)
314 {
315   PetscErrorCode ierr;
316   PetscInt       i;
317 
318   PetscFunctionBegin;
319   if (!lg) PetscFunctionReturn(0);
320   PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,1);
321   PetscValidLogicalCollectiveInt(lg,dim,2);
322   if (lg->dim == dim) PetscFunctionReturn(0);
323 
324   ierr = PetscFree2(lg->x,lg->y);CHKERRQ(ierr);
325   if (lg->legend) {
326     for (i=0; i<lg->dim; i++) {
327       ierr = PetscFree(lg->legend[i]);CHKERRQ(ierr);
328     }
329     ierr = PetscFree(lg->legend);CHKERRQ(ierr);
330   }
331   ierr    = PetscFree(lg->colors);CHKERRQ(ierr);
332   lg->dim = dim;
333   ierr    = PetscMalloc2(dim*CHUNCKSIZE,&lg->x,dim*CHUNCKSIZE,&lg->y);CHKERRQ(ierr);
334   ierr    = PetscLogObjectMemory((PetscObject)lg,2*dim*CHUNCKSIZE*sizeof(PetscReal));CHKERRQ(ierr);
335   lg->len = dim*CHUNCKSIZE;
336   PetscFunctionReturn(0);
337 }
338 
339 #undef __FUNCT__
340 #define __FUNCT__ "PetscDrawLGReset"
341 /*@
342    PetscDrawLGReset - Clears line graph to allow for reuse with new data.
343 
344    Logically Collective over PetscDrawLG
345 
346    Input Parameter:
347 .  lg - the line graph context.
348 
349    Level: intermediate
350 
351    Concepts: line graph^restarting
352 
353 @*/
354 PetscErrorCode  PetscDrawLGReset(PetscDrawLG lg)
355 {
356   PetscFunctionBegin;
357   if (!lg) PetscFunctionReturn(0);
358   PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,1);
359   lg->xmin  = 1.e20;
360   lg->ymin  = 1.e20;
361   lg->xmax  = -1.e20;
362   lg->ymax  = -1.e20;
363   lg->loc   = 0;
364   lg->nopts = 0;
365   PetscFunctionReturn(0);
366 }
367 
368 #undef __FUNCT__
369 #define __FUNCT__ "PetscDrawLGDestroy"
370 /*@
371    PetscDrawLGDestroy - Frees all space taken up by line graph data structure.
372 
373    Collective over PetscDrawLG
374 
375    Input Parameter:
376 .  lg - the line graph context
377 
378    Level: intermediate
379 
380 .seealso:  PetscDrawLGCreate()
381 @*/
382 PetscErrorCode  PetscDrawLGDestroy(PetscDrawLG *lg)
383 {
384   PetscErrorCode ierr;
385   PetscInt       i;
386 
387   PetscFunctionBegin;
388   if (!*lg) PetscFunctionReturn(0);
389   PetscValidHeaderSpecific(*lg,PETSC_DRAWLG_CLASSID,1);
390   if (--((PetscObject)(*lg))->refct > 0) {*lg = NULL; PetscFunctionReturn(0);}
391 
392   if ((*lg)->legend) {
393     for (i=0; i<(*lg)->dim; i++) {
394       ierr = PetscFree((*lg)->legend[i]);CHKERRQ(ierr);
395     }
396     ierr = PetscFree((*lg)->legend);CHKERRQ(ierr);
397   }
398   ierr = PetscFree((*lg)->colors);CHKERRQ(ierr);
399   ierr = PetscFree2((*lg)->x,(*lg)->y);CHKERRQ(ierr);
400   ierr = PetscDrawAxisDestroy(&(*lg)->axis);CHKERRQ(ierr);
401   ierr = PetscDrawDestroy(&(*lg)->win);CHKERRQ(ierr);
402   ierr = PetscHeaderDestroy(lg);CHKERRQ(ierr);
403   PetscFunctionReturn(0);
404 }
405 #undef __FUNCT__
406 #define __FUNCT__ "PetscDrawLGSetUseMarkers"
407 /*@
408    PetscDrawLGSetUseMarkers - Causes LG to draw a marker for each data-point.
409 
410    Logically Collective over PetscDrawLG
411 
412    Input Parameters:
413 +  lg - the linegraph context
414 -  flg - should mark each data point
415 
416    Options Database:
417 .  -lg_use_markers  <true,false>
418 
419    Level: intermediate
420 
421    Concepts: line graph^showing points
422 
423 @*/
424 PetscErrorCode  PetscDrawLGSetUseMarkers(PetscDrawLG lg,PetscBool flg)
425 {
426   PetscFunctionBegin;
427   if (!lg) PetscFunctionReturn(0);
428   PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,1);
429 
430   lg->use_markers = flg;
431   PetscFunctionReturn(0);
432 }
433 
434 #undef __FUNCT__
435 #define __FUNCT__ "PetscDrawLGDraw"
436 /*@
437    PetscDrawLGDraw - Redraws a line graph.
438 
439    Collective, but ignored by all processors except processor 0 in PetscDrawLG
440 
441    Input Parameter:
442 .  lg - the line graph context
443 
444    Level: intermediate
445 
446 .seealso: PetscDrawSPDraw(), PetscDrawLGSPDraw()
447 
448 @*/
449 PetscErrorCode  PetscDrawLGDraw(PetscDrawLG lg)
450 {
451   PetscReal      xmin,xmax,ymin,ymax;
452   PetscErrorCode ierr;
453   PetscMPIInt    rank;
454   PetscDraw      draw;
455   PetscBool      isnull;
456 
457   PetscFunctionBegin;
458   if (!lg) PetscFunctionReturn(0);
459   PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,1);
460 
461   draw = lg->win;
462   ierr = PetscDrawIsNull(draw,&isnull);CHKERRQ(ierr);
463   if (isnull) PetscFunctionReturn(0);
464   ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)lg),&rank);CHKERRQ(ierr);
465 
466   ierr = PetscDrawCheckResizedWindow(draw);CHKERRQ(ierr);
467   ierr = PetscDrawSynchronizedClear(draw);CHKERRQ(ierr);
468   ierr = PetscDrawCollectiveBegin(draw);CHKERRQ(ierr);
469 
470   xmin = lg->xmin; xmax = lg->xmax; ymin = lg->ymin; ymax = lg->ymax;
471   ierr = PetscDrawAxisSetLimits(lg->axis,xmin,xmax,ymin,ymax);CHKERRQ(ierr);
472   ierr = PetscDrawAxisDraw(lg->axis);CHKERRQ(ierr);
473 
474   if (!rank) {
475     int i,j,dim=lg->dim,nopts=lg->nopts,cl;
476     for (i=0; i<dim; i++) {
477       for (j=1; j<nopts; j++) {
478         if (lg->colors) cl = lg->colors[i];
479         else cl = PETSC_DRAW_BLACK+i;
480         ierr = PetscDrawLine(draw,lg->x[(j-1)*dim+i],lg->y[(j-1)*dim+i],lg->x[j*dim+i],lg->y[j*dim+i],cl);CHKERRQ(ierr);
481         if (lg->use_markers) {
482           ierr = PetscDrawMarker(draw,lg->x[j*dim+i],lg->y[j*dim+i],cl);CHKERRQ(ierr);
483         }
484       }
485     }
486   }
487   if (!rank && lg->legend) {
488     int       i,dim=lg->dim,cl;
489     PetscReal xl,yl,xr,yr,tw,th;
490     size_t    len,mlen = 0;
491     ierr = PetscDrawGetCoordinates(draw,&xl,&yl,&xr,&yr);CHKERRQ(ierr);
492     ierr = PetscDrawStringGetSize(draw,&tw,&th);CHKERRQ(ierr);
493     for (i=0; i<dim; i++) {
494       ierr = PetscStrlen(lg->legend[i],&len);CHKERRQ(ierr);
495       mlen = PetscMax(mlen,len);
496     }
497     ierr = PetscDrawLine(draw,xr - (mlen + 8)*tw,yr - 3*th,xr - 2*tw,yr - 3*th,PETSC_DRAW_BLACK);CHKERRQ(ierr);
498     ierr = PetscDrawLine(draw,xr - (mlen + 8)*tw,yr - 3*th,xr - (mlen + 8)*tw,yr - (4+lg->dim)*th,PETSC_DRAW_BLACK);CHKERRQ(ierr);
499     for  (i=0; i<dim; i++) {
500       cl   = (lg->colors ? lg->colors[i] : i + 1);
501       ierr = PetscDrawLine(draw,xr - (mlen + 6.7)*tw,yr - (4 + i)*th,xr - (mlen + 3.2)*tw,yr - (4 + i)*th,cl);CHKERRQ(ierr);
502       ierr = PetscDrawString(draw,xr - (mlen + 3)*tw,yr - (4.5 + i)*th,PETSC_DRAW_BLACK,lg->legend[i]);CHKERRQ(ierr);
503     }
504     ierr = PetscDrawLine(draw,xr - 2*tw,yr - 3*th,xr - 2*tw,yr - (4+lg->dim)*th,PETSC_DRAW_BLACK);CHKERRQ(ierr);
505     ierr = PetscDrawLine(draw,xr - (mlen + 8)*tw,yr - (4+lg->dim)*th,xr - 2*tw,yr - (4+lg->dim)*th,PETSC_DRAW_BLACK);CHKERRQ(ierr);
506   }
507 
508   ierr = PetscDrawCollectiveEnd(draw);CHKERRQ(ierr);
509   ierr = PetscDrawSynchronizedFlush(draw);CHKERRQ(ierr);
510   ierr = PetscDrawPause(draw);CHKERRQ(ierr);
511   PetscFunctionReturn(0);
512 }
513 
514 #undef __FUNCT__
515 #define __FUNCT__ "PetscDrawLGView"
516 /*@
517   PetscDrawLGView - Prints a line graph.
518 
519   Not collective
520 
521   Input Parameter:
522 . lg - the line graph context
523 
524   Level: beginner
525 
526 .keywords:  draw, line, graph
527 @*/
528 PetscErrorCode  PetscDrawLGView(PetscDrawLG lg,PetscViewer viewer)
529 {
530   PetscReal      xmin=lg->xmin, xmax=lg->xmax, ymin=lg->ymin, ymax=lg->ymax;
531   PetscInt       i, j, dim = lg->dim, nopts = lg->nopts;
532   PetscErrorCode ierr;
533 
534   PetscFunctionBegin;
535   if (!lg) PetscFunctionReturn(0);
536   PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,1);
537 
538   if (nopts < 1)                  PetscFunctionReturn(0);
539   if (xmin > xmax || ymin > ymax) PetscFunctionReturn(0);
540 
541   if (!viewer){
542     ierr = PetscViewerASCIIGetStdout(PetscObjectComm((PetscObject)lg),&viewer);CHKERRQ(ierr);
543   }
544   ierr = PetscObjectPrintClassNamePrefixType((PetscObject)lg,viewer);CHKERRQ(ierr);
545   for (i = 0; i < dim; i++) {
546     ierr = PetscViewerASCIIPrintf(viewer, "Line %D>\n", i);CHKERRQ(ierr);
547     for (j = 0; j < nopts; j++) {
548       ierr = PetscViewerASCIIPrintf(viewer, "  X: %g Y: %g\n", (double)lg->x[j*dim+i], (double)lg->y[j*dim+i]);CHKERRQ(ierr);
549     }
550   }
551   PetscFunctionReturn(0);
552 }
553 
554 #undef __FUNCT__
555 #define __FUNCT__ "PetscDrawLGSetFromOptions"
556 /*@
557     PetscDrawLGSetFromOptions - Sets options related to the PetscDrawLG
558 
559     Collective over PetscDrawLG
560 
561     Options Database:
562 
563     Level: intermediate
564 
565     Concepts: line graph^creating
566 
567 .seealso:  PetscDrawLGDestroy(), PetscDrawLGCreate()
568 @*/
569 PetscErrorCode  PetscDrawLGSetFromOptions(PetscDrawLG lg)
570 {
571   PetscErrorCode ierr;
572   PetscBool      flg=PETSC_FALSE, set;
573 
574   PetscFunctionBegin;
575   if (!lg) PetscFunctionReturn(0);
576   PetscValidHeaderSpecific(lg,PETSC_DRAWLG_CLASSID,1);
577 
578   ierr = PetscOptionsGetBool(NULL,"-lg_use_markers",&flg,&set);CHKERRQ(ierr);
579   if (set) {ierr = PetscDrawLGSetUseMarkers(lg,flg);CHKERRQ(ierr);}
580   PetscFunctionReturn(0);
581 }
582