xref: /petsc/src/sys/classes/viewer/impls/draw/drawv.c (revision 28b400f66ebc7ae0049166a2294dfcd3df27e64b)
15c6c1daeSBarry Smith 
25c6c1daeSBarry Smith #include <../src/sys/classes/viewer/impls/draw/vdraw.h> /*I "petscdraw.h" I*/
3665c2dedSJed Brown #include <petscviewer.h>                                /*I "petscviewer.h" I*/
45c6c1daeSBarry Smith 
5e0877f53SBarry Smith static PetscErrorCode PetscViewerDestroy_Draw(PetscViewer v)
65c6c1daeSBarry Smith {
75c6c1daeSBarry Smith   PetscInt         i;
85c6c1daeSBarry Smith   PetscViewer_Draw *vdraw = (PetscViewer_Draw*)v->data;
95c6c1daeSBarry Smith 
105c6c1daeSBarry Smith   PetscFunctionBegin;
11*28b400f6SJacob Faibussowitsch   PetscCheck(!vdraw->singleton_made,PETSC_COMM_SELF,PETSC_ERR_ORDER,"Destroying PetscViewer without first restoring singleton");
125c6c1daeSBarry Smith   for (i=0; i<vdraw->draw_max; i++) {
135f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscDrawAxisDestroy(&vdraw->drawaxis[i]));
145f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscDrawLGDestroy(&vdraw->drawlg[i]));
155f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscDrawDestroy(&vdraw->draw[i]));
165c6c1daeSBarry Smith   }
175f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscFree(vdraw->display));
185f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscFree(vdraw->title));
195f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscFree3(vdraw->draw,vdraw->drawlg,vdraw->drawaxis));
205f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscFree(vdraw->bounds));
215f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscFree(vdraw->drawtype));
225f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscFree(v->data));
235c6c1daeSBarry Smith   PetscFunctionReturn(0);
245c6c1daeSBarry Smith }
255c6c1daeSBarry Smith 
26e0877f53SBarry Smith static PetscErrorCode PetscViewerFlush_Draw(PetscViewer v)
275c6c1daeSBarry Smith {
285c6c1daeSBarry Smith   PetscInt         i;
295c6c1daeSBarry Smith   PetscViewer_Draw *vdraw = (PetscViewer_Draw*)v->data;
305c6c1daeSBarry Smith 
315c6c1daeSBarry Smith   PetscFunctionBegin;
325c6c1daeSBarry Smith   for (i=0; i<vdraw->draw_max; i++) {
335f80ce2aSJacob Faibussowitsch     if (vdraw->draw[i]) CHKERRQ(PetscDrawFlush(vdraw->draw[i]));
345c6c1daeSBarry Smith   }
355c6c1daeSBarry Smith   PetscFunctionReturn(0);
365c6c1daeSBarry Smith }
375c6c1daeSBarry Smith 
385c6c1daeSBarry Smith /*@C
395c6c1daeSBarry Smith     PetscViewerDrawGetDraw - Returns PetscDraw object from PetscViewer object.
405c6c1daeSBarry Smith     This PetscDraw object may then be used to perform graphics using
415c6c1daeSBarry Smith     PetscDrawXXX() commands.
425c6c1daeSBarry Smith 
43d94959e9SLisandro Dalcin     Collective on PetscViewer
445c6c1daeSBarry Smith 
455c6c1daeSBarry Smith     Input Parameters:
465c6c1daeSBarry Smith +   viewer - the PetscViewer (created with PetscViewerDrawOpen())
475c6c1daeSBarry Smith -   windownumber - indicates which subwindow (usually 0)
485c6c1daeSBarry Smith 
4901d2d390SJose E. Roman     Output Parameter:
505c6c1daeSBarry Smith .   draw - the draw object
515c6c1daeSBarry Smith 
525c6c1daeSBarry Smith     Level: intermediate
535c6c1daeSBarry Smith 
545c6c1daeSBarry Smith .seealso: PetscViewerDrawGetLG(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen()
555c6c1daeSBarry Smith @*/
565c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawGetDraw(PetscViewer viewer,PetscInt windownumber,PetscDraw *draw)
575c6c1daeSBarry Smith {
58e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
595c6c1daeSBarry Smith   PetscBool        isdraw;
605c6c1daeSBarry Smith 
615c6c1daeSBarry Smith   PetscFunctionBegin;
625c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
63e5ab1681SLisandro Dalcin   PetscValidLogicalCollectiveInt(viewer,windownumber,2);
645c6c1daeSBarry Smith   if (draw) PetscValidPointer(draw,3);
655f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw));
66*28b400f6SJacob Faibussowitsch   PetscCheck(isdraw,PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer");
672c71b3e2SJacob Faibussowitsch   PetscCheckFalse(windownumber < 0,PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Window number cannot be negative");
68e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
69e5ab1681SLisandro Dalcin 
705c6c1daeSBarry Smith   windownumber += vdraw->draw_base;
715c6c1daeSBarry Smith   if (windownumber >= vdraw->draw_max) {
725c6c1daeSBarry Smith     /* allocate twice as many slots as needed */
735c6c1daeSBarry Smith     PetscInt      draw_max  = vdraw->draw_max;
745c6c1daeSBarry Smith     PetscDraw     *tdraw    = vdraw->draw;
755c6c1daeSBarry Smith     PetscDrawLG   *drawlg   = vdraw->drawlg;
765c6c1daeSBarry Smith     PetscDrawAxis *drawaxis = vdraw->drawaxis;
775c6c1daeSBarry Smith 
785c6c1daeSBarry Smith     vdraw->draw_max = 2*windownumber;
79a297a907SKarl Rupp 
805f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscCalloc3(vdraw->draw_max,&vdraw->draw,vdraw->draw_max,&vdraw->drawlg,vdraw->draw_max,&vdraw->drawaxis));
815f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscArraycpy(vdraw->draw,tdraw,draw_max));
825f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscArraycpy(vdraw->drawlg,drawlg,draw_max));
835f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscArraycpy(vdraw->drawaxis,drawaxis,draw_max));
845f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscFree3(tdraw,drawlg,drawaxis));
855c6c1daeSBarry Smith   }
865c6c1daeSBarry Smith 
875c6c1daeSBarry Smith   if (!vdraw->draw[windownumber]) {
88e5ab1681SLisandro Dalcin     char *title = vdraw->title, tmp_str[128];
8910f3a0f4SLisandro Dalcin     if (windownumber) {
905f80ce2aSJacob Faibussowitsch       CHKERRQ(PetscSNPrintf(tmp_str,sizeof(tmp_str),"%s:%" PetscInt_FMT,vdraw->title?vdraw->title:"",windownumber));
915c6c1daeSBarry Smith       title = tmp_str;
925c6c1daeSBarry Smith     }
935f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscDrawCreate(PetscObjectComm((PetscObject)viewer),vdraw->display,title,PETSC_DECIDE,PETSC_DECIDE,vdraw->w,vdraw->h,&vdraw->draw[windownumber]));
945f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscLogObjectParent((PetscObject)viewer,(PetscObject)vdraw->draw[windownumber]));
95d1da0b69SBarry Smith     if (vdraw->drawtype) {
965f80ce2aSJacob Faibussowitsch       CHKERRQ(PetscDrawSetType(vdraw->draw[windownumber],vdraw->drawtype));
97d1da0b69SBarry Smith     }
985f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscDrawSetPause(vdraw->draw[windownumber],vdraw->pause));
995f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscDrawSetOptionsPrefix(vdraw->draw[windownumber],((PetscObject)viewer)->prefix));
1005f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscDrawSetFromOptions(vdraw->draw[windownumber]));
1015c6c1daeSBarry Smith   }
1025c6c1daeSBarry Smith   if (draw) *draw = vdraw->draw[windownumber];
103064a246eSJacob Faibussowitsch   if (draw) PetscValidHeaderSpecific(*draw,PETSC_DRAW_CLASSID,3);
1045c6c1daeSBarry Smith   PetscFunctionReturn(0);
1055c6c1daeSBarry Smith }
1065c6c1daeSBarry Smith 
1075c6c1daeSBarry Smith /*@C
1085c6c1daeSBarry Smith     PetscViewerDrawBaseAdd - add to the base integer that is added to the windownumber passed to PetscViewerDrawGetDraw()
1095c6c1daeSBarry Smith 
110d94959e9SLisandro Dalcin     Logically Collective on PetscViewer
1115c6c1daeSBarry Smith 
1125c6c1daeSBarry Smith     Input Parameters:
1135c6c1daeSBarry Smith +  viewer - the PetscViewer (created with PetscViewerDrawOpen())
1145c6c1daeSBarry Smith -   windownumber - how much to add to the base
1155c6c1daeSBarry Smith 
1165c6c1daeSBarry Smith     Level: developer
1175c6c1daeSBarry Smith 
1185c6c1daeSBarry Smith .seealso: PetscViewerDrawGetLG(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen(), PetscViewerDrawGetDraw(), PetscViewerDrawBaseSet()
1195c6c1daeSBarry Smith @*/
1205c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawBaseAdd(PetscViewer viewer,PetscInt windownumber)
1215c6c1daeSBarry Smith {
122e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
1235c6c1daeSBarry Smith   PetscBool        isdraw;
1245c6c1daeSBarry Smith 
1255c6c1daeSBarry Smith   PetscFunctionBegin;
1265c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
127e5ab1681SLisandro Dalcin   PetscValidLogicalCollectiveInt(viewer,windownumber,2);
1285f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw));
129*28b400f6SJacob Faibussowitsch   PetscCheck(isdraw,PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer");
130e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
131e5ab1681SLisandro Dalcin 
1322c71b3e2SJacob Faibussowitsch   PetscCheckFalse(windownumber + vdraw->draw_base < 0,PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Resulting base %" PetscInt_FMT " cannot be negative",windownumber+vdraw->draw_base);
1335c6c1daeSBarry Smith   vdraw->draw_base += windownumber;
1345c6c1daeSBarry Smith   PetscFunctionReturn(0);
1355c6c1daeSBarry Smith }
1365c6c1daeSBarry Smith 
1375c6c1daeSBarry Smith /*@C
1385c6c1daeSBarry Smith     PetscViewerDrawBaseSet - sets the base integer that is added to the windownumber passed to PetscViewerDrawGetDraw()
1395c6c1daeSBarry Smith 
140d94959e9SLisandro Dalcin     Logically Collective on PetscViewer
1415c6c1daeSBarry Smith 
1425c6c1daeSBarry Smith     Input Parameters:
1435c6c1daeSBarry Smith +   viewer - the PetscViewer (created with PetscViewerDrawOpen())
1445c6c1daeSBarry Smith -   windownumber - value to set the base
1455c6c1daeSBarry Smith 
1465c6c1daeSBarry Smith     Level: developer
1475c6c1daeSBarry Smith 
1485c6c1daeSBarry Smith .seealso: PetscViewerDrawGetLG(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen(), PetscViewerDrawGetDraw(), PetscViewerDrawBaseAdd()
1495c6c1daeSBarry Smith @*/
1505c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawBaseSet(PetscViewer viewer,PetscInt windownumber)
1515c6c1daeSBarry Smith {
152e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
1535c6c1daeSBarry Smith   PetscBool        isdraw;
1545c6c1daeSBarry Smith 
1555c6c1daeSBarry Smith   PetscFunctionBegin;
1565c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
157e5ab1681SLisandro Dalcin   PetscValidLogicalCollectiveInt(viewer,windownumber,2);
1585f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw));
159*28b400f6SJacob Faibussowitsch   PetscCheck(isdraw,PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer");
160e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
161e5ab1681SLisandro Dalcin 
1622c71b3e2SJacob Faibussowitsch   PetscCheckFalse(windownumber < 0,PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Resulting base %" PetscInt_FMT " cannot be negative",windownumber);
1635c6c1daeSBarry Smith   vdraw->draw_base = windownumber;
1645c6c1daeSBarry Smith   PetscFunctionReturn(0);
1655c6c1daeSBarry Smith }
1665c6c1daeSBarry Smith 
1675c6c1daeSBarry Smith /*@C
1685c6c1daeSBarry Smith     PetscViewerDrawGetDrawLG - Returns PetscDrawLG object from PetscViewer object.
1695c6c1daeSBarry Smith     This PetscDrawLG object may then be used to perform graphics using
1705c6c1daeSBarry Smith     PetscDrawLGXXX() commands.
1715c6c1daeSBarry Smith 
172d94959e9SLisandro Dalcin     Collective on PetscViewer
1735c6c1daeSBarry Smith 
174d8d19677SJose E. Roman     Input Parameters:
1755c6c1daeSBarry Smith +   PetscViewer - the PetscViewer (created with PetscViewerDrawOpen())
1765c6c1daeSBarry Smith -   windownumber - indicates which subwindow (usually 0)
1775c6c1daeSBarry Smith 
17801d2d390SJose E. Roman     Output Parameter:
1795c6c1daeSBarry Smith .   draw - the draw line graph object
1805c6c1daeSBarry Smith 
1815c6c1daeSBarry Smith     Level: intermediate
1825c6c1daeSBarry Smith 
1835c6c1daeSBarry Smith .seealso: PetscViewerDrawGetDraw(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen()
1845c6c1daeSBarry Smith @*/
1855c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawGetDrawLG(PetscViewer viewer,PetscInt windownumber,PetscDrawLG *drawlg)
1865c6c1daeSBarry Smith {
1875c6c1daeSBarry Smith   PetscBool        isdraw;
188e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
1895c6c1daeSBarry Smith 
1905c6c1daeSBarry Smith   PetscFunctionBegin;
1915c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
192e5ab1681SLisandro Dalcin   PetscValidLogicalCollectiveInt(viewer,windownumber,2);
1935c6c1daeSBarry Smith   PetscValidPointer(drawlg,3);
1945f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw));
195*28b400f6SJacob Faibussowitsch   PetscCheck(isdraw,PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer");
1962c71b3e2SJacob Faibussowitsch   PetscCheckFalse(windownumber < 0,PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Window number cannot be negative");
197e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
1985c6c1daeSBarry Smith 
1995c6c1daeSBarry Smith   if (windownumber+vdraw->draw_base >= vdraw->draw_max || !vdraw->draw[windownumber+vdraw->draw_base]) {
2005f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscViewerDrawGetDraw(viewer,windownumber,NULL));
2015c6c1daeSBarry Smith   }
2025c6c1daeSBarry Smith   if (!vdraw->drawlg[windownumber+vdraw->draw_base]) {
2035f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscDrawLGCreate(vdraw->draw[windownumber+vdraw->draw_base],1,&vdraw->drawlg[windownumber+vdraw->draw_base]));
2045f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscLogObjectParent((PetscObject)viewer,(PetscObject)vdraw->drawlg[windownumber+vdraw->draw_base]));
2055f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscDrawLGSetFromOptions(vdraw->drawlg[windownumber+vdraw->draw_base]));
2065c6c1daeSBarry Smith   }
2075c6c1daeSBarry Smith   *drawlg = vdraw->drawlg[windownumber+vdraw->draw_base];
2085c6c1daeSBarry Smith   PetscFunctionReturn(0);
2095c6c1daeSBarry Smith }
2105c6c1daeSBarry Smith 
2115c6c1daeSBarry Smith /*@C
2125c6c1daeSBarry Smith     PetscViewerDrawGetDrawAxis - Returns PetscDrawAxis object from PetscViewer object.
2135c6c1daeSBarry Smith     This PetscDrawAxis object may then be used to perform graphics using
2145c6c1daeSBarry Smith     PetscDrawAxisXXX() commands.
2155c6c1daeSBarry Smith 
216d94959e9SLisandro Dalcin     Collective on PetscViewer
2175c6c1daeSBarry Smith 
218d8d19677SJose E. Roman     Input Parameters:
2195c6c1daeSBarry Smith +   viewer - the PetscViewer (created with PetscViewerDrawOpen()
2205c6c1daeSBarry Smith -   windownumber - indicates which subwindow (usually 0)
2215c6c1daeSBarry Smith 
22201d2d390SJose E. Roman     Output Parameter:
2235c6c1daeSBarry Smith .   drawaxis - the draw axis object
2245c6c1daeSBarry Smith 
2255c6c1daeSBarry Smith     Level: advanced
2265c6c1daeSBarry Smith 
2275c6c1daeSBarry Smith .seealso: PetscViewerDrawGetDraw(), PetscViewerDrawGetLG(), PetscViewerDrawOpen()
2285c6c1daeSBarry Smith @*/
2295c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawGetDrawAxis(PetscViewer viewer,PetscInt windownumber,PetscDrawAxis *drawaxis)
2305c6c1daeSBarry Smith {
2315c6c1daeSBarry Smith   PetscBool        isdraw;
232e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
2335c6c1daeSBarry Smith 
2345c6c1daeSBarry Smith   PetscFunctionBegin;
2355c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
236e5ab1681SLisandro Dalcin   PetscValidLogicalCollectiveInt(viewer,windownumber,2);
2375c6c1daeSBarry Smith   PetscValidPointer(drawaxis,3);
2385f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw));
239*28b400f6SJacob Faibussowitsch   PetscCheck(isdraw,PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer");
2402c71b3e2SJacob Faibussowitsch   PetscCheckFalse(windownumber < 0,PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Window number cannot be negative");
241e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
2425c6c1daeSBarry Smith 
2435c6c1daeSBarry Smith   if (windownumber+vdraw->draw_base >= vdraw->draw_max || !vdraw->draw[windownumber+vdraw->draw_base]) {
2445f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscViewerDrawGetDraw(viewer,windownumber,NULL));
2455c6c1daeSBarry Smith   }
2465c6c1daeSBarry Smith   if (!vdraw->drawaxis[windownumber+vdraw->draw_base]) {
2475f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscDrawAxisCreate(vdraw->draw[windownumber+vdraw->draw_base],&vdraw->drawaxis[windownumber+vdraw->draw_base]));
2485f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscLogObjectParent((PetscObject)viewer,(PetscObject)vdraw->drawaxis[windownumber+vdraw->draw_base]));
2495c6c1daeSBarry Smith   }
2505c6c1daeSBarry Smith   *drawaxis = vdraw->drawaxis[windownumber+vdraw->draw_base];
2515c6c1daeSBarry Smith   PetscFunctionReturn(0);
2525c6c1daeSBarry Smith }
2535c6c1daeSBarry Smith 
2545c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawResize(PetscViewer v,int w,int h)
2555c6c1daeSBarry Smith {
256e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
257e5ab1681SLisandro Dalcin   PetscBool        isdraw;
2585c6c1daeSBarry Smith 
2595c6c1daeSBarry Smith   PetscFunctionBegin;
260e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1);
2615f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscObjectTypeCompare((PetscObject)v,PETSCVIEWERDRAW,&isdraw));
262e5ab1681SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
263e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)v->data;
264e5ab1681SLisandro Dalcin 
265e5ab1681SLisandro Dalcin   if (w >= 1) vdraw->w = w;
266e5ab1681SLisandro Dalcin   if (h >= 1) vdraw->h = h;
2675c6c1daeSBarry Smith   PetscFunctionReturn(0);
2685c6c1daeSBarry Smith }
2695c6c1daeSBarry Smith 
2705c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawSetInfo(PetscViewer v,const char display[],const char title[],int x,int y,int w,int h)
2715c6c1daeSBarry Smith {
272e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
273e5ab1681SLisandro Dalcin   PetscBool        isdraw;
2745c6c1daeSBarry Smith 
2755c6c1daeSBarry Smith   PetscFunctionBegin;
276e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1);
2775f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscObjectTypeCompare((PetscObject)v,PETSCVIEWERDRAW,&isdraw));
278e5ab1681SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
279e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)v->data;
280e5ab1681SLisandro Dalcin 
2815f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscStrallocpy(display,&vdraw->display));
2825f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscStrallocpy(title,&vdraw->title));
283e5ab1681SLisandro Dalcin   if (w >= 1) vdraw->w = w;
284e5ab1681SLisandro Dalcin   if (h >= 1) vdraw->h = h;
2855c6c1daeSBarry Smith   PetscFunctionReturn(0);
2865c6c1daeSBarry Smith }
2875c6c1daeSBarry Smith 
288d1da0b69SBarry Smith PetscErrorCode  PetscViewerDrawSetDrawType(PetscViewer v,PetscDrawType drawtype)
289d1da0b69SBarry Smith {
290e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
291e5ab1681SLisandro Dalcin   PetscBool        isdraw;
292d1da0b69SBarry Smith 
293d1da0b69SBarry Smith   PetscFunctionBegin;
294e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1);
2955f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscObjectTypeCompare((PetscObject)v,PETSCVIEWERDRAW,&isdraw));
296e5ab1681SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
297e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)v->data;
298e5ab1681SLisandro Dalcin 
2995f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscFree(vdraw->drawtype));
3005f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscStrallocpy(drawtype,(char**)&vdraw->drawtype));
301d1da0b69SBarry Smith   PetscFunctionReturn(0);
302d1da0b69SBarry Smith }
303d1da0b69SBarry Smith 
3041f49e1f7SLisandro Dalcin PetscErrorCode PetscViewerDrawGetDrawType(PetscViewer v,PetscDrawType *drawtype)
3051f49e1f7SLisandro Dalcin {
3061f49e1f7SLisandro Dalcin   PetscViewer_Draw *vdraw;
3071f49e1f7SLisandro Dalcin   PetscBool        isdraw;
3081f49e1f7SLisandro Dalcin 
3091f49e1f7SLisandro Dalcin   PetscFunctionBegin;
3101f49e1f7SLisandro Dalcin   PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1);
3115f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscObjectTypeCompare((PetscObject)v,PETSCVIEWERDRAW,&isdraw));
312*28b400f6SJacob Faibussowitsch   PetscCheck(isdraw,PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer");
3131f49e1f7SLisandro Dalcin   vdraw = (PetscViewer_Draw*)v->data;
3141f49e1f7SLisandro Dalcin 
3151f49e1f7SLisandro Dalcin   *drawtype = vdraw->drawtype;
3161f49e1f7SLisandro Dalcin   PetscFunctionReturn(0);
3171f49e1f7SLisandro Dalcin }
3181f49e1f7SLisandro Dalcin 
319f55236e4SLisandro Dalcin PetscErrorCode PetscViewerDrawSetTitle(PetscViewer v,const char title[])
320f55236e4SLisandro Dalcin {
321f55236e4SLisandro Dalcin   PetscViewer_Draw *vdraw;
322f55236e4SLisandro Dalcin   PetscBool        isdraw;
323f55236e4SLisandro Dalcin 
324f55236e4SLisandro Dalcin   PetscFunctionBegin;
325f55236e4SLisandro Dalcin   PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1);
3265f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscObjectTypeCompare((PetscObject)v,PETSCVIEWERDRAW,&isdraw));
327f55236e4SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
328f55236e4SLisandro Dalcin   vdraw = (PetscViewer_Draw*)v->data;
329f55236e4SLisandro Dalcin 
3305f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscFree(vdraw->title));
3315f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscStrallocpy(title,&vdraw->title));
332f55236e4SLisandro Dalcin   PetscFunctionReturn(0);
333f55236e4SLisandro Dalcin }
334f55236e4SLisandro Dalcin 
335f55236e4SLisandro Dalcin PetscErrorCode PetscViewerDrawGetTitle(PetscViewer v,const char *title[])
336f55236e4SLisandro Dalcin {
337f55236e4SLisandro Dalcin   PetscViewer_Draw *vdraw;
338f55236e4SLisandro Dalcin   PetscBool        isdraw;
339f55236e4SLisandro Dalcin 
340f55236e4SLisandro Dalcin   PetscFunctionBegin;
341f55236e4SLisandro Dalcin   PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1);
3425f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscObjectTypeCompare((PetscObject)v,PETSCVIEWERDRAW,&isdraw));
343*28b400f6SJacob Faibussowitsch   PetscCheck(isdraw,PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer");
344f55236e4SLisandro Dalcin   vdraw = (PetscViewer_Draw*)v->data;
345f55236e4SLisandro Dalcin 
346f55236e4SLisandro Dalcin   *title = vdraw->title;
347f55236e4SLisandro Dalcin   PetscFunctionReturn(0);
348f55236e4SLisandro Dalcin }
349f55236e4SLisandro Dalcin 
3505c6c1daeSBarry Smith /*@C
3515c6c1daeSBarry Smith    PetscViewerDrawOpen - Opens a window for use as a PetscViewer. If you want to
3525c6c1daeSBarry Smith    do graphics in this window, you must call PetscViewerDrawGetDraw() and
3535c6c1daeSBarry Smith    perform the graphics on the PetscDraw object.
3545c6c1daeSBarry Smith 
355d083f849SBarry Smith    Collective
3565c6c1daeSBarry Smith 
3575c6c1daeSBarry Smith    Input Parameters:
3585c6c1daeSBarry Smith +  comm - communicator that will share window
3595c6c1daeSBarry Smith .  display - the X display on which to open, or null for the local machine
3605c6c1daeSBarry Smith .  title - the title to put in the title bar, or null for no title
3615c6c1daeSBarry Smith .  x, y - the screen coordinates of the upper left corner of window, or use PETSC_DECIDE
3625c6c1daeSBarry Smith -  w, h - window width and height in pixels, or may use PETSC_DECIDE or PETSC_DRAW_FULL_SIZE, PETSC_DRAW_HALF_SIZE,
3635c6c1daeSBarry Smith           PETSC_DRAW_THIRD_SIZE, PETSC_DRAW_QUARTER_SIZE
3645c6c1daeSBarry Smith 
365f899ff85SJose E. Roman    Output Parameter:
3665c6c1daeSBarry Smith . viewer - the PetscViewer
3675c6c1daeSBarry Smith 
3685c6c1daeSBarry Smith    Format Options:
3695c6c1daeSBarry Smith +  PETSC_VIEWER_DRAW_BASIC - displays with basic format
3705c6c1daeSBarry Smith -  PETSC_VIEWER_DRAW_LG    - displays using a line graph
3715c6c1daeSBarry Smith 
3725c6c1daeSBarry Smith    Options Database Keys:
37310699b91SBarry Smith +  -draw_type - use x or null
3745c6c1daeSBarry Smith .  -nox - Disables all x-windows output
3755c6c1daeSBarry Smith .  -display <name> - Specifies name of machine for the X display
3765c6c1daeSBarry Smith .  -geometry <x,y,w,h> - allows setting the window location and size
3775c6c1daeSBarry Smith -  -draw_pause <pause> - Sets time (in seconds) that the
3785c6c1daeSBarry Smith      program pauses after PetscDrawPause() has been called
3795c6c1daeSBarry Smith      (0 is default, -1 implies until user input).
3805c6c1daeSBarry Smith 
3815c6c1daeSBarry Smith    Level: beginner
3825c6c1daeSBarry Smith 
38310699b91SBarry Smith    Notes:
38410699b91SBarry Smith      PetscViewerDrawOpen() calls PetscDrawCreate(), so see the manual pages for PetscDrawCreate()
38510699b91SBarry Smith 
3865c6c1daeSBarry Smith    Note for Fortran Programmers:
3875c6c1daeSBarry Smith    Whenever indicating null character data in a Fortran code,
388cf90aa19SBarry Smith    PETSC_NULL_CHARACTER must be employed; using NULL is not
389cf90aa19SBarry Smith    correct for character data!  Thus, PETSC_NULL_CHARACTER can be
3905c6c1daeSBarry Smith    used for the display and title input parameters.
3915c6c1daeSBarry Smith 
3925c6c1daeSBarry Smith .seealso: PetscDrawCreate(), PetscViewerDestroy(), PetscViewerDrawGetDraw(), PetscViewerCreate(), PETSC_VIEWER_DRAW_,
3935c6c1daeSBarry Smith           PETSC_VIEWER_DRAW_WORLD, PETSC_VIEWER_DRAW_SELF
3945c6c1daeSBarry Smith @*/
3955c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawOpen(MPI_Comm comm,const char display[],const char title[],int x,int y,int w,int h,PetscViewer *viewer)
3965c6c1daeSBarry Smith {
3975c6c1daeSBarry Smith   PetscFunctionBegin;
3985f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscViewerCreate(comm,viewer));
3995f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscViewerSetType(*viewer,PETSCVIEWERDRAW));
4005f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscViewerDrawSetInfo(*viewer,display,title,x,y,w,h));
4015c6c1daeSBarry Smith   PetscFunctionReturn(0);
4025c6c1daeSBarry Smith }
4035c6c1daeSBarry Smith 
404a9db196aSBarry Smith #include <petsc/private/drawimpl.h>
405a9db196aSBarry Smith 
4063f08860eSBarry Smith PetscErrorCode PetscViewerGetSubViewer_Draw(PetscViewer viewer,MPI_Comm comm,PetscViewer *sviewer)
4075c6c1daeSBarry Smith {
4085c6c1daeSBarry Smith   PetscMPIInt      rank;
4095c6c1daeSBarry Smith   PetscInt         i;
410c6228bbaSLisandro Dalcin   PetscViewer_Draw *vdraw = (PetscViewer_Draw*)viewer->data,*svdraw;
4115c6c1daeSBarry Smith 
4125c6c1daeSBarry Smith   PetscFunctionBegin;
413*28b400f6SJacob Faibussowitsch   PetscCheck(!vdraw->singleton_made,PETSC_COMM_SELF,PETSC_ERR_ORDER,"Trying to get SubViewer without first restoring previous");
4145c6c1daeSBarry Smith   /* only processor zero can use the PetscViewer draw singleton */
415fefe69c3SStefano Zampini   if (sviewer) *sviewer = NULL;
4165f80ce2aSJacob Faibussowitsch   CHKERRMPI(MPI_Comm_rank(PetscObjectComm((PetscObject)viewer),&rank));
417dd400576SPatrick Sanan   if (rank == 0) {
418e5afcf28SBarry Smith     PetscMPIInt flg;
419a9db196aSBarry Smith     PetscDraw   draw,sdraw;
420e5afcf28SBarry Smith 
4215f80ce2aSJacob Faibussowitsch     CHKERRMPI(MPI_Comm_compare(PETSC_COMM_SELF,comm,&flg));
4222c71b3e2SJacob Faibussowitsch     PetscCheckFalse(flg != MPI_IDENT && flg != MPI_CONGRUENT,PETSC_COMM_SELF,PETSC_ERR_SUP,"PetscViewerGetSubViewer() for PETSCVIEWERDRAW requires a singleton MPI_Comm");
4235f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscViewerCreate(comm,sviewer));
4245f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscViewerSetType(*sviewer,PETSCVIEWERDRAW));
425c6228bbaSLisandro Dalcin     svdraw = (PetscViewer_Draw*)(*sviewer)->data;
426c6228bbaSLisandro Dalcin     (*sviewer)->format = viewer->format;
427c6228bbaSLisandro Dalcin     for (i=0; i<vdraw->draw_max; i++) { /* XXX this is wrong if svdraw->draw_max (initially 5) < vdraw->draw_max */
4285f80ce2aSJacob Faibussowitsch       if (vdraw->draw[i]) CHKERRQ(PetscDrawGetSingleton(vdraw->draw[i],&svdraw->draw[i]));
4295c6c1daeSBarry Smith     }
4305f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscViewerDrawGetDraw(viewer,0,&draw));
4315f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscViewerDrawGetDraw(*sviewer,0,&sdraw));
432a9db196aSBarry Smith     if (draw->savefilename) {
4335f80ce2aSJacob Faibussowitsch       CHKERRQ(PetscDrawSetSave(sdraw,draw->savefilename));
434a9db196aSBarry Smith       sdraw->savefilecount = draw->savefilecount;
435a9db196aSBarry Smith       sdraw->savesinglefile = draw->savesinglefile;
436a9db196aSBarry Smith       sdraw->savemoviefps = draw->savemoviefps;
437a9db196aSBarry Smith       sdraw->saveonclear = draw->saveonclear;
438a9db196aSBarry Smith       sdraw->saveonflush = draw->saveonflush;
439a9db196aSBarry Smith     }
4405f80ce2aSJacob Faibussowitsch     if (draw->savefinalfilename) CHKERRQ(PetscDrawSetSaveFinalImage(sdraw,draw->savefinalfilename));
441a9db196aSBarry Smith   } else {
442a9db196aSBarry Smith     PetscDraw draw;
4435f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscViewerDrawGetDraw(viewer,0,&draw));
4445c6c1daeSBarry Smith   }
4455c6c1daeSBarry Smith   vdraw->singleton_made = PETSC_TRUE;
4465c6c1daeSBarry Smith   PetscFunctionReturn(0);
4475c6c1daeSBarry Smith }
4485c6c1daeSBarry Smith 
4493f08860eSBarry Smith PetscErrorCode PetscViewerRestoreSubViewer_Draw(PetscViewer viewer,MPI_Comm comm,PetscViewer *sviewer)
4505c6c1daeSBarry Smith {
4515c6c1daeSBarry Smith   PetscMPIInt      rank;
4525c6c1daeSBarry Smith   PetscInt         i;
453c6228bbaSLisandro Dalcin   PetscViewer_Draw *vdraw = (PetscViewer_Draw*)viewer->data,*svdraw;
4545c6c1daeSBarry Smith 
4555c6c1daeSBarry Smith   PetscFunctionBegin;
456*28b400f6SJacob Faibussowitsch   PetscCheck(vdraw->singleton_made,PETSC_COMM_SELF,PETSC_ERR_ORDER,"Trying to restore a singleton that was not gotten");
4575f80ce2aSJacob Faibussowitsch   CHKERRMPI(MPI_Comm_rank(PetscObjectComm((PetscObject)viewer),&rank));
458dd400576SPatrick Sanan   if (rank == 0) {
459a9db196aSBarry Smith     PetscDraw draw,sdraw;
460a9db196aSBarry Smith 
4615f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscViewerDrawGetDraw(viewer,0,&draw));
4625f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscViewerDrawGetDraw(*sviewer,0,&sdraw));
463a9db196aSBarry Smith     if (draw->savefilename) {
464a9db196aSBarry Smith       draw->savefilecount = sdraw->savefilecount;
4655f80ce2aSJacob Faibussowitsch       CHKERRMPI(MPI_Bcast(&draw->savefilecount,1,MPIU_INT,0,PetscObjectComm((PetscObject)draw)));
466a9db196aSBarry Smith     }
467c6228bbaSLisandro Dalcin     svdraw = (PetscViewer_Draw*)(*sviewer)->data;
4685c6c1daeSBarry Smith     for (i=0; i<vdraw->draw_max; i++) {
469c6228bbaSLisandro Dalcin       if (vdraw->draw[i] && svdraw->draw[i]) {
4705f80ce2aSJacob Faibussowitsch         CHKERRQ(PetscDrawRestoreSingleton(vdraw->draw[i],&svdraw->draw[i]));
4715c6c1daeSBarry Smith       }
4725c6c1daeSBarry Smith     }
4735f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscFree3(svdraw->draw,svdraw->drawlg,svdraw->drawaxis));
4745f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscFree((*sviewer)->data));
4755f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscHeaderDestroy(sviewer));
476a9db196aSBarry Smith   } else {
477a9db196aSBarry Smith     PetscDraw draw;
478a9db196aSBarry Smith 
4795f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscViewerDrawGetDraw(viewer,0,&draw));
480a9db196aSBarry Smith     if (draw->savefilename) {
4815f80ce2aSJacob Faibussowitsch       CHKERRMPI(MPI_Bcast(&draw->savefilecount,1,MPIU_INT,0,PetscObjectComm((PetscObject)draw)));
4825c6c1daeSBarry Smith     }
483a9db196aSBarry Smith   }
484a9db196aSBarry Smith 
4855c6c1daeSBarry Smith   vdraw->singleton_made = PETSC_FALSE;
4865c6c1daeSBarry Smith   PetscFunctionReturn(0);
4875c6c1daeSBarry Smith }
4885c6c1daeSBarry Smith 
4894416b707SBarry Smith PetscErrorCode PetscViewerSetFromOptions_Draw(PetscOptionItems *PetscOptionsObject,PetscViewer v)
490e9457bf7SBarry Smith {
491e9457bf7SBarry Smith   PetscReal      bounds[16];
492e9457bf7SBarry Smith   PetscInt       nbounds = 16;
493e9457bf7SBarry Smith   PetscBool      flg;
494e9457bf7SBarry Smith 
495e9457bf7SBarry Smith   PetscFunctionBegin;
4965f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscOptionsHead(PetscOptionsObject,"Draw PetscViewer Options"));
4975f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscOptionsRealArray("-draw_bounds","Bounds to put on plots axis","PetscViewerDrawSetBounds",bounds,&nbounds,&flg));
498e9457bf7SBarry Smith   if (flg) {
4995f80ce2aSJacob Faibussowitsch     CHKERRQ(PetscViewerDrawSetBounds(v,nbounds/2,bounds));
500e9457bf7SBarry Smith   }
5015f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscOptionsTail());
502e9457bf7SBarry Smith   PetscFunctionReturn(0);
503e9457bf7SBarry Smith }
504e9457bf7SBarry Smith 
5050076e027SBarry Smith PetscErrorCode PetscViewerView_Draw(PetscViewer viewer,PetscViewer v)
5060076e027SBarry Smith {
5070076e027SBarry Smith   PetscDraw        draw;
5080076e027SBarry Smith   PetscInt         i;
5090076e027SBarry Smith   PetscViewer_Draw *vdraw = (PetscViewer_Draw*)viewer->data;
5100076e027SBarry Smith 
5110076e027SBarry Smith   PetscFunctionBegin;
5120076e027SBarry Smith   /*  If the PetscViewer has just been created then no vdraw->draw yet
5130076e027SBarry Smith       exists so this will not actually call the viewer on any draws. */
5140076e027SBarry Smith   for (i=0; i<vdraw->draw_base; i++) {
5150076e027SBarry Smith     if (vdraw->draw[i]) {
5165f80ce2aSJacob Faibussowitsch       CHKERRQ(PetscViewerDrawGetDraw(viewer,i,&draw));
5175f80ce2aSJacob Faibussowitsch       CHKERRQ(PetscDrawView(draw,v));
5180076e027SBarry Smith     }
5190076e027SBarry Smith   }
5200076e027SBarry Smith   PetscFunctionReturn(0);
5210076e027SBarry Smith }
5220076e027SBarry Smith 
5238556b5ebSBarry Smith /*MC
5248556b5ebSBarry Smith    PETSCVIEWERDRAW - A viewer that generates graphics, either to the screen or a file
5258556b5ebSBarry Smith 
5268556b5ebSBarry Smith .seealso:  PetscViewerDrawOpen(), PetscViewerDrawGetDraw(), PETSC_VIEWER_DRAW_(),PETSC_VIEWER_DRAW_SELF, PETSC_VIEWER_DRAW_WORLD,
5278556b5ebSBarry Smith            PetscViewerCreate(), PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), PETSCVIEWERBINARY,
5288556b5ebSBarry Smith            PetscViewerMatlabOpen(), VecView(), DMView(), PetscViewerMatlabPutArray(), PETSCVIEWERASCII, PETSCVIEWERMATLAB,
5298556b5ebSBarry Smith            PetscViewerFileSetName(), PetscViewerFileSetMode(), PetscViewerFormat, PetscViewerType, PetscViewerSetType()
5308556b5ebSBarry Smith 
5311b266c99SBarry Smith   Level: beginner
5321b266c99SBarry Smith 
5338556b5ebSBarry Smith M*/
5348cc058d9SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerCreate_Draw(PetscViewer viewer)
5355c6c1daeSBarry Smith {
5365c6c1daeSBarry Smith   PetscViewer_Draw *vdraw;
5375c6c1daeSBarry Smith 
5385c6c1daeSBarry Smith   PetscFunctionBegin;
5395f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscNewLog(viewer,&vdraw));
5405c6c1daeSBarry Smith   viewer->data = (void*)vdraw;
5415c6c1daeSBarry Smith 
5425c6c1daeSBarry Smith   viewer->ops->flush            = PetscViewerFlush_Draw;
5430076e027SBarry Smith   viewer->ops->view             = PetscViewerView_Draw;
5445c6c1daeSBarry Smith   viewer->ops->destroy          = PetscViewerDestroy_Draw;
545e9457bf7SBarry Smith   viewer->ops->setfromoptions   = PetscViewerSetFromOptions_Draw;
546559f443fSBarry Smith   viewer->ops->getsubviewer     = PetscViewerGetSubViewer_Draw;
547559f443fSBarry Smith   viewer->ops->restoresubviewer = PetscViewerRestoreSubViewer_Draw;
5485c6c1daeSBarry Smith 
5495c6c1daeSBarry Smith   /* these are created on the fly if requested */
5505c6c1daeSBarry Smith   vdraw->draw_max  = 5;
5515c6c1daeSBarry Smith   vdraw->draw_base = 0;
552ccad63c3SBarry Smith   vdraw->w         = PETSC_DECIDE;
553ccad63c3SBarry Smith   vdraw->h         = PETSC_DECIDE;
554a297a907SKarl Rupp 
5555f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscCalloc3(vdraw->draw_max,&vdraw->draw,vdraw->draw_max,&vdraw->drawlg,vdraw->draw_max,&vdraw->drawaxis));
5565c6c1daeSBarry Smith   vdraw->singleton_made = PETSC_FALSE;
5575c6c1daeSBarry Smith   PetscFunctionReturn(0);
5585c6c1daeSBarry Smith }
5595c6c1daeSBarry Smith 
5605c6c1daeSBarry Smith /*@
5615c6c1daeSBarry Smith     PetscViewerDrawClear - Clears a PetscDraw graphic associated with a PetscViewer.
5625c6c1daeSBarry Smith 
5635c6c1daeSBarry Smith     Not Collective
5645c6c1daeSBarry Smith 
5655c6c1daeSBarry Smith     Input Parameter:
5665c6c1daeSBarry Smith .  viewer - the PetscViewer
5675c6c1daeSBarry Smith 
5685c6c1daeSBarry Smith     Level: intermediate
5695c6c1daeSBarry Smith 
5705c6c1daeSBarry Smith .seealso: PetscViewerDrawOpen(), PetscViewerDrawGetDraw(),
5715c6c1daeSBarry Smith 
5725c6c1daeSBarry Smith @*/
5735c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawClear(PetscViewer viewer)
5745c6c1daeSBarry Smith {
5755c6c1daeSBarry Smith   PetscViewer_Draw *vdraw;
576e5ab1681SLisandro Dalcin   PetscBool        isdraw;
577e5ab1681SLisandro Dalcin   PetscInt         i;
5785c6c1daeSBarry Smith 
5795c6c1daeSBarry Smith   PetscFunctionBegin;
580e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
5815f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw));
582e5ab1681SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
5835c6c1daeSBarry Smith   vdraw = (PetscViewer_Draw*)viewer->data;
584e5ab1681SLisandro Dalcin 
5855c6c1daeSBarry Smith   for (i=0; i<vdraw->draw_max; i++) {
5865f80ce2aSJacob Faibussowitsch     if (vdraw->draw[i]) CHKERRQ(PetscDrawClear(vdraw->draw[i]));
5875c6c1daeSBarry Smith   }
5885c6c1daeSBarry Smith   PetscFunctionReturn(0);
5895c6c1daeSBarry Smith }
5905c6c1daeSBarry Smith 
5915c6c1daeSBarry Smith /*@
5925c6c1daeSBarry Smith     PetscViewerDrawGetPause - Gets a pause for the first present draw
5935c6c1daeSBarry Smith 
5945c6c1daeSBarry Smith     Not Collective
5955c6c1daeSBarry Smith 
5965c6c1daeSBarry Smith     Input Parameter:
5975c6c1daeSBarry Smith .  viewer - the PetscViewer
5985c6c1daeSBarry Smith 
5995c6c1daeSBarry Smith     Output Parameter:
6005c6c1daeSBarry Smith .  pause - the pause value
6015c6c1daeSBarry Smith 
6025c6c1daeSBarry Smith     Level: intermediate
6035c6c1daeSBarry Smith 
6045c6c1daeSBarry Smith .seealso: PetscViewerDrawOpen(), PetscViewerDrawGetDraw(),
6055c6c1daeSBarry Smith 
6065c6c1daeSBarry Smith @*/
6075c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawGetPause(PetscViewer viewer,PetscReal *pause)
6085c6c1daeSBarry Smith {
6095c6c1daeSBarry Smith   PetscViewer_Draw *vdraw;
610e5ab1681SLisandro Dalcin   PetscBool        isdraw;
611e5ab1681SLisandro Dalcin   PetscInt         i;
6125c6c1daeSBarry Smith   PetscDraw        draw;
6135c6c1daeSBarry Smith 
6145c6c1daeSBarry Smith   PetscFunctionBegin;
615e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
6165f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw));
617e5ab1681SLisandro Dalcin   if (!isdraw) {*pause = 0.0; PetscFunctionReturn(0);}
6185c6c1daeSBarry Smith   vdraw = (PetscViewer_Draw*)viewer->data;
619e5ab1681SLisandro Dalcin 
6205c6c1daeSBarry Smith   for (i=0; i<vdraw->draw_max; i++) {
6215c6c1daeSBarry Smith     if (vdraw->draw[i]) {
6225f80ce2aSJacob Faibussowitsch       CHKERRQ(PetscDrawGetPause(vdraw->draw[i],pause));
6235c6c1daeSBarry Smith       PetscFunctionReturn(0);
6245c6c1daeSBarry Smith     }
6255c6c1daeSBarry Smith   }
6265c6c1daeSBarry Smith   /* none exist yet so create one and get its pause */
6275f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscViewerDrawGetDraw(viewer,0,&draw));
6285f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscDrawGetPause(draw,pause));
6295c6c1daeSBarry Smith   PetscFunctionReturn(0);
6305c6c1daeSBarry Smith }
6315c6c1daeSBarry Smith 
6325c6c1daeSBarry Smith /*@
6335c6c1daeSBarry Smith     PetscViewerDrawSetPause - Sets a pause for each PetscDraw in the viewer
6345c6c1daeSBarry Smith 
6355c6c1daeSBarry Smith     Not Collective
6365c6c1daeSBarry Smith 
6375c6c1daeSBarry Smith     Input Parameters:
6385c6c1daeSBarry Smith +  viewer - the PetscViewer
6395c6c1daeSBarry Smith -  pause - the pause value
6405c6c1daeSBarry Smith 
6415c6c1daeSBarry Smith     Level: intermediate
6425c6c1daeSBarry Smith 
6435c6c1daeSBarry Smith .seealso: PetscViewerDrawOpen(), PetscViewerDrawGetDraw(),
6445c6c1daeSBarry Smith 
6455c6c1daeSBarry Smith @*/
6465c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawSetPause(PetscViewer viewer,PetscReal pause)
6475c6c1daeSBarry Smith {
648e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
6495c6c1daeSBarry Smith   PetscBool        isdraw;
650e5ab1681SLisandro Dalcin   PetscInt         i;
6515c6c1daeSBarry Smith 
6525c6c1daeSBarry Smith   PetscFunctionBegin;
653e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
6545f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw));
655e5ab1681SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
656e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
657afe78b3cSBarry Smith 
658afe78b3cSBarry Smith   vdraw->pause = pause;
6595c6c1daeSBarry Smith   for (i=0; i<vdraw->draw_max; i++) {
6605f80ce2aSJacob Faibussowitsch     if (vdraw->draw[i]) CHKERRQ(PetscDrawSetPause(vdraw->draw[i],pause));
6615c6c1daeSBarry Smith   }
6625c6c1daeSBarry Smith   PetscFunctionReturn(0);
6635c6c1daeSBarry Smith }
6645c6c1daeSBarry Smith 
6655c6c1daeSBarry Smith /*@
6665c6c1daeSBarry Smith     PetscViewerDrawSetHold - Holds previous image when drawing new image
6675c6c1daeSBarry Smith 
6685c6c1daeSBarry Smith     Not Collective
6695c6c1daeSBarry Smith 
6705c6c1daeSBarry Smith     Input Parameters:
6715c6c1daeSBarry Smith +  viewer - the PetscViewer
6725c6c1daeSBarry Smith -  hold - indicates to hold or not
6735c6c1daeSBarry Smith 
6745c6c1daeSBarry Smith     Level: intermediate
6755c6c1daeSBarry Smith 
6765c6c1daeSBarry Smith .seealso: PetscViewerDrawOpen(), PetscViewerDrawGetDraw(),
6775c6c1daeSBarry Smith 
6785c6c1daeSBarry Smith @*/
6795c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawSetHold(PetscViewer viewer,PetscBool hold)
6805c6c1daeSBarry Smith {
6815c6c1daeSBarry Smith   PetscViewer_Draw *vdraw;
6825c6c1daeSBarry Smith   PetscBool        isdraw;
6835c6c1daeSBarry Smith 
6845c6c1daeSBarry Smith   PetscFunctionBegin;
685e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
6865f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw));
687e5ab1681SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
6885c6c1daeSBarry Smith   vdraw = (PetscViewer_Draw*)viewer->data;
689e5ab1681SLisandro Dalcin 
6905c6c1daeSBarry Smith   vdraw->hold = hold;
6915c6c1daeSBarry Smith   PetscFunctionReturn(0);
6925c6c1daeSBarry Smith }
6935c6c1daeSBarry Smith 
6945c6c1daeSBarry Smith /*@
695d97d059aSBarry Smith     PetscViewerDrawGetHold - Checks if holds previous image when drawing new image
6965c6c1daeSBarry Smith 
6975c6c1daeSBarry Smith     Not Collective
6985c6c1daeSBarry Smith 
6995c6c1daeSBarry Smith     Input Parameter:
7005c6c1daeSBarry Smith .  viewer - the PetscViewer
7015c6c1daeSBarry Smith 
7025c6c1daeSBarry Smith     Output Parameter:
7035c6c1daeSBarry Smith .  hold - indicates to hold or not
7045c6c1daeSBarry Smith 
7055c6c1daeSBarry Smith     Level: intermediate
7065c6c1daeSBarry Smith 
7075c6c1daeSBarry Smith .seealso: PetscViewerDrawOpen(), PetscViewerDrawGetDraw(),
7085c6c1daeSBarry Smith 
7095c6c1daeSBarry Smith @*/
7105c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawGetHold(PetscViewer viewer,PetscBool *hold)
7115c6c1daeSBarry Smith {
7125c6c1daeSBarry Smith   PetscViewer_Draw *vdraw;
7135c6c1daeSBarry Smith   PetscBool        isdraw;
7145c6c1daeSBarry Smith 
7155c6c1daeSBarry Smith   PetscFunctionBegin;
716e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
7175f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw));
718e5ab1681SLisandro Dalcin   if (!isdraw) {*hold = PETSC_FALSE; PetscFunctionReturn(0);}
7195c6c1daeSBarry Smith   vdraw = (PetscViewer_Draw*)viewer->data;
720e5ab1681SLisandro Dalcin 
7215c6c1daeSBarry Smith   *hold = vdraw->hold;
7225c6c1daeSBarry Smith   PetscFunctionReturn(0);
7235c6c1daeSBarry Smith }
7245c6c1daeSBarry Smith 
7255c6c1daeSBarry Smith /* ---------------------------------------------------------------------*/
7265c6c1daeSBarry Smith /*
7275c6c1daeSBarry Smith     The variable Petsc_Viewer_Draw_keyval is used to indicate an MPI attribute that
7285c6c1daeSBarry Smith   is attached to a communicator, in this case the attribute is a PetscViewer.
7295c6c1daeSBarry Smith */
730d4c7638eSBarry Smith PetscMPIInt Petsc_Viewer_Draw_keyval = MPI_KEYVAL_INVALID;
7315c6c1daeSBarry Smith 
7325c6c1daeSBarry Smith /*@C
7335c6c1daeSBarry Smith     PETSC_VIEWER_DRAW_ - Creates a window PetscViewer shared by all processors
7345c6c1daeSBarry Smith                      in a communicator.
7355c6c1daeSBarry Smith 
736d083f849SBarry Smith      Collective
7375c6c1daeSBarry Smith 
7385c6c1daeSBarry Smith      Input Parameter:
7395c6c1daeSBarry Smith .    comm - the MPI communicator to share the window PetscViewer
7405c6c1daeSBarry Smith 
7415c6c1daeSBarry Smith      Level: intermediate
7425c6c1daeSBarry Smith 
7435c6c1daeSBarry Smith      Notes:
7445c6c1daeSBarry Smith      Unlike almost all other PETSc routines, PETSC_VIEWER_DRAW_ does not return
7455c6c1daeSBarry Smith      an error code.  The window is usually used in the form
7465c6c1daeSBarry Smith $       XXXView(XXX object,PETSC_VIEWER_DRAW_(comm));
7475c6c1daeSBarry Smith 
7485c6c1daeSBarry Smith .seealso: PETSC_VIEWER_DRAW_WORLD, PETSC_VIEWER_DRAW_SELF, PetscViewerDrawOpen(),
7495c6c1daeSBarry Smith @*/
7505c6c1daeSBarry Smith PetscViewer  PETSC_VIEWER_DRAW_(MPI_Comm comm)
7515c6c1daeSBarry Smith {
7525c6c1daeSBarry Smith   PetscErrorCode ierr;
7535c6c1daeSBarry Smith   PetscMPIInt    flag;
7545c6c1daeSBarry Smith   PetscViewer    viewer;
7555c6c1daeSBarry Smith   MPI_Comm       ncomm;
7565c6c1daeSBarry Smith 
7575c6c1daeSBarry Smith   PetscFunctionBegin;
75802c9f0b5SLisandro Dalcin   ierr = PetscCommDuplicate(comm,&ncomm,NULL);if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_INITIAL," ");PetscFunctionReturn(NULL);}
7595c6c1daeSBarry Smith   if (Petsc_Viewer_Draw_keyval == MPI_KEYVAL_INVALID) {
76002c9f0b5SLisandro Dalcin     ierr = MPI_Comm_create_keyval(MPI_COMM_NULL_COPY_FN,MPI_COMM_NULL_DELETE_FN,&Petsc_Viewer_Draw_keyval,NULL);
76102c9f0b5SLisandro Dalcin     if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_INITIAL," ");PetscFunctionReturn(NULL);}
7625c6c1daeSBarry Smith   }
76347435625SJed Brown   ierr = MPI_Comm_get_attr(ncomm,Petsc_Viewer_Draw_keyval,(void**)&viewer,&flag);
76402c9f0b5SLisandro Dalcin   if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_INITIAL," ");PetscFunctionReturn(NULL);}
7655c6c1daeSBarry Smith   if (!flag) { /* PetscViewer not yet created */
76602c9f0b5SLisandro Dalcin     ierr = PetscViewerDrawOpen(ncomm,NULL,NULL,PETSC_DECIDE,PETSC_DECIDE,300,300,&viewer);
7672cb5e1ccSBarry Smith     if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_REPEAT," ");PetscFunctionReturn(NULL);}
7685c6c1daeSBarry Smith     ierr = PetscObjectRegisterDestroy((PetscObject)viewer);
7692cb5e1ccSBarry Smith     if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_REPEAT," ");PetscFunctionReturn(NULL);}
77047435625SJed Brown     ierr = MPI_Comm_set_attr(ncomm,Petsc_Viewer_Draw_keyval,(void*)viewer);
77102c9f0b5SLisandro Dalcin     if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_INITIAL," ");PetscFunctionReturn(NULL);}
7725c6c1daeSBarry Smith   }
7735c6c1daeSBarry Smith   ierr = PetscCommDestroy(&ncomm);
7742cb5e1ccSBarry Smith   if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_REPEAT," ");PetscFunctionReturn(NULL);}
7755c6c1daeSBarry Smith   PetscFunctionReturn(viewer);
7765c6c1daeSBarry Smith }
7775c6c1daeSBarry Smith 
7785c6c1daeSBarry Smith /*@
7795c6c1daeSBarry Smith     PetscViewerDrawSetBounds - sets the upper and lower bounds to be used in plotting
7805c6c1daeSBarry Smith 
7815c6c1daeSBarry Smith     Collective on PetscViewer
7825c6c1daeSBarry Smith 
7835c6c1daeSBarry Smith     Input Parameters:
7845c6c1daeSBarry Smith +   viewer - the PetscViewer (created with PetscViewerDrawOpen())
7855c6c1daeSBarry Smith .   nbounds - number of plots that can be made with this viewer, for example the dof passed to DMDACreate()
7865c6c1daeSBarry Smith -   bounds - the actual bounds, the size of this is 2*nbounds, the values are stored in the order min F_0, max F_0, min F_1, max F_1, .....
7875c6c1daeSBarry Smith 
788e9457bf7SBarry Smith     Options Database:
78910699b91SBarry Smith .   -draw_bounds  minF0,maxF0,minF1,maxF1 - the lower left and upper right bounds
790e9457bf7SBarry Smith 
7915c6c1daeSBarry Smith     Level: intermediate
7925c6c1daeSBarry Smith 
79395452b02SPatrick Sanan     Notes:
79495452b02SPatrick Sanan     this determines the colors used in 2d contour plots generated with VecView() for DMDA in 2d. Any values in the vector below or above the
795f3f0eb19SBarry Smith       bounds are moved to the bound value before plotting. In this way the color index from color to physical value remains the same for all plots generated with
796f3f0eb19SBarry Smith       this viewer. Otherwise the color to physical value meaning changes with each new image if this is not set.
797f3f0eb19SBarry Smith 
7985c6c1daeSBarry Smith .seealso: PetscViewerDrawGetLG(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen()
7995c6c1daeSBarry Smith @*/
8005c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawSetBounds(PetscViewer viewer,PetscInt nbounds,const PetscReal *bounds)
8015c6c1daeSBarry Smith {
802e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
803e5ab1681SLisandro Dalcin   PetscBool        isdraw;
8045c6c1daeSBarry Smith 
8055c6c1daeSBarry Smith   PetscFunctionBegin;
8065c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
8075f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw));
808e5ab1681SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
809e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
810a297a907SKarl Rupp 
811e5ab1681SLisandro Dalcin   vdraw->nbounds = nbounds;
8125f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscFree(vdraw->bounds));
8135f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscMalloc1(2*nbounds,&vdraw->bounds));
8145f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscArraycpy(vdraw->bounds,bounds,2*nbounds));
8155c6c1daeSBarry Smith   PetscFunctionReturn(0);
8165c6c1daeSBarry Smith }
8175c6c1daeSBarry Smith 
8185c6c1daeSBarry Smith /*@C
8195c6c1daeSBarry Smith     PetscViewerDrawGetBounds - gets the upper and lower bounds to be used in plotting set with PetscViewerDrawSetBounds()
8205c6c1daeSBarry Smith 
8215c6c1daeSBarry Smith     Collective on PetscViewer
8225c6c1daeSBarry Smith 
8235c6c1daeSBarry Smith     Input Parameter:
8245c6c1daeSBarry Smith .   viewer - the PetscViewer (created with PetscViewerDrawOpen())
8255c6c1daeSBarry Smith 
826fd292e60Sprj-     Output Parameters:
8275c6c1daeSBarry Smith +   nbounds - number of plots that can be made with this viewer, for example the dof passed to DMDACreate()
8285c6c1daeSBarry Smith -   bounds - the actual bounds, the size of this is 2*nbounds, the values are stored in the order min F_0, max F_0, min F_1, max F_1, .....
8295c6c1daeSBarry Smith 
8305c6c1daeSBarry Smith     Level: intermediate
8315c6c1daeSBarry Smith 
832f3f0eb19SBarry Smith .seealso: PetscViewerDrawGetLG(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen(), PetscViewerDrawSetBounds()
8335c6c1daeSBarry Smith @*/
8345c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawGetBounds(PetscViewer viewer,PetscInt *nbounds,const PetscReal **bounds)
8355c6c1daeSBarry Smith {
836e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
837e5ab1681SLisandro Dalcin   PetscBool        isdraw;
8385c6c1daeSBarry Smith 
8395c6c1daeSBarry Smith   PetscFunctionBegin;
8405c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
8415f80ce2aSJacob Faibussowitsch   CHKERRQ(PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw));
842e5ab1681SLisandro Dalcin   if (!isdraw) {if (nbounds) *nbounds = 0; if (bounds) *bounds = NULL; PetscFunctionReturn(0);}
843e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
844e5ab1681SLisandro Dalcin 
845e5ab1681SLisandro Dalcin   if (nbounds) *nbounds = vdraw->nbounds;
846e5ab1681SLisandro Dalcin   if (bounds)  *bounds  = vdraw->bounds;
8475c6c1daeSBarry Smith   PetscFunctionReturn(0);
8485c6c1daeSBarry Smith }
849