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