xref: /petsc/src/sys/classes/viewer/impls/draw/drawv.c (revision 8556b5eb6d24048282742bdd6ce397a5c8264fe5)
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 
55c6c1daeSBarry Smith #undef __FUNCT__
65c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerDestroy_Draw"
7e0877f53SBarry Smith static PetscErrorCode PetscViewerDestroy_Draw(PetscViewer v)
85c6c1daeSBarry Smith {
95c6c1daeSBarry Smith   PetscErrorCode   ierr;
105c6c1daeSBarry Smith   PetscInt         i;
115c6c1daeSBarry Smith   PetscViewer_Draw *vdraw = (PetscViewer_Draw*)v->data;
125c6c1daeSBarry Smith 
135c6c1daeSBarry Smith   PetscFunctionBegin;
145c6c1daeSBarry Smith   if (vdraw->singleton_made) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ORDER,"Destroying PetscViewer without first restoring singleton");
155c6c1daeSBarry Smith   for (i=0; i<vdraw->draw_max; i++) {
165c6c1daeSBarry Smith     ierr = PetscDrawAxisDestroy(&vdraw->drawaxis[i]);CHKERRQ(ierr);
175c6c1daeSBarry Smith     ierr = PetscDrawLGDestroy(&vdraw->drawlg[i]);CHKERRQ(ierr);
185c6c1daeSBarry Smith     ierr = PetscDrawDestroy(&vdraw->draw[i]);CHKERRQ(ierr);
195c6c1daeSBarry Smith   }
205c6c1daeSBarry Smith   ierr = PetscFree(vdraw->display);CHKERRQ(ierr);
215c6c1daeSBarry Smith   ierr = PetscFree(vdraw->title);CHKERRQ(ierr);
225c6c1daeSBarry Smith   ierr = PetscFree3(vdraw->draw,vdraw->drawlg,vdraw->drawaxis);CHKERRQ(ierr);
235c6c1daeSBarry Smith   ierr = PetscFree(vdraw->bounds);CHKERRQ(ierr);
24d1da0b69SBarry Smith   ierr = PetscFree(vdraw->drawtype);CHKERRQ(ierr);
25e5ab1681SLisandro Dalcin   ierr = PetscFree(v->data);CHKERRQ(ierr);
265c6c1daeSBarry Smith   PetscFunctionReturn(0);
275c6c1daeSBarry Smith }
285c6c1daeSBarry Smith 
295c6c1daeSBarry Smith #undef __FUNCT__
305c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerFlush_Draw"
31e0877f53SBarry Smith static PetscErrorCode PetscViewerFlush_Draw(PetscViewer v)
325c6c1daeSBarry Smith {
335c6c1daeSBarry Smith   PetscErrorCode   ierr;
345c6c1daeSBarry Smith   PetscInt         i;
355c6c1daeSBarry Smith   PetscViewer_Draw *vdraw = (PetscViewer_Draw*)v->data;
365c6c1daeSBarry Smith 
375c6c1daeSBarry Smith   PetscFunctionBegin;
385c6c1daeSBarry Smith   for (i=0; i<vdraw->draw_max; i++) {
395b399a63SLisandro Dalcin     if (vdraw->draw[i]) {ierr = PetscDrawFlush(vdraw->draw[i]);CHKERRQ(ierr);}
405c6c1daeSBarry Smith   }
415c6c1daeSBarry Smith   PetscFunctionReturn(0);
425c6c1daeSBarry Smith }
435c6c1daeSBarry Smith 
445c6c1daeSBarry Smith #undef __FUNCT__
455c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerDrawGetDraw"
465c6c1daeSBarry Smith /*@C
475c6c1daeSBarry Smith     PetscViewerDrawGetDraw - Returns PetscDraw object from PetscViewer object.
485c6c1daeSBarry Smith     This PetscDraw object may then be used to perform graphics using
495c6c1daeSBarry Smith     PetscDrawXXX() commands.
505c6c1daeSBarry Smith 
51d94959e9SLisandro Dalcin     Collective on PetscViewer
525c6c1daeSBarry Smith 
535c6c1daeSBarry Smith     Input Parameters:
545c6c1daeSBarry Smith +   viewer - the PetscViewer (created with PetscViewerDrawOpen())
555c6c1daeSBarry Smith -   windownumber - indicates which subwindow (usually 0)
565c6c1daeSBarry Smith 
575c6c1daeSBarry Smith     Ouput Parameter:
585c6c1daeSBarry Smith .   draw - the draw object
595c6c1daeSBarry Smith 
605c6c1daeSBarry Smith     Level: intermediate
615c6c1daeSBarry Smith 
625c6c1daeSBarry Smith    Concepts: drawing^accessing PetscDraw context from PetscViewer
635c6c1daeSBarry Smith    Concepts: graphics
645c6c1daeSBarry Smith 
655c6c1daeSBarry Smith .seealso: PetscViewerDrawGetLG(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen()
665c6c1daeSBarry Smith @*/
675c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawGetDraw(PetscViewer viewer,PetscInt windownumber,PetscDraw *draw)
685c6c1daeSBarry Smith {
69e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
705c6c1daeSBarry Smith   PetscErrorCode   ierr;
715c6c1daeSBarry Smith   PetscBool        isdraw;
725c6c1daeSBarry Smith 
735c6c1daeSBarry Smith   PetscFunctionBegin;
745c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
75e5ab1681SLisandro Dalcin   PetscValidLogicalCollectiveInt(viewer,windownumber,2);
765c6c1daeSBarry Smith   if (draw) PetscValidPointer(draw,3);
775c6c1daeSBarry Smith   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
785c6c1daeSBarry Smith   if (!isdraw) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer");
795c6c1daeSBarry Smith   if (windownumber < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Window number cannot be negative");
80e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
81e5ab1681SLisandro Dalcin 
825c6c1daeSBarry Smith   windownumber += vdraw->draw_base;
835c6c1daeSBarry Smith   if (windownumber >= vdraw->draw_max) {
845c6c1daeSBarry Smith     /* allocate twice as many slots as needed */
855c6c1daeSBarry Smith     PetscInt      draw_max  = vdraw->draw_max;
865c6c1daeSBarry Smith     PetscDraw     *tdraw    = vdraw->draw;
875c6c1daeSBarry Smith     PetscDrawLG   *drawlg   = vdraw->drawlg;
885c6c1daeSBarry Smith     PetscDrawAxis *drawaxis = vdraw->drawaxis;
895c6c1daeSBarry Smith 
905c6c1daeSBarry Smith     vdraw->draw_max = 2*windownumber;
91a297a907SKarl Rupp 
921795a4d1SJed Brown     ierr = PetscCalloc3(vdraw->draw_max,&vdraw->draw,vdraw->draw_max,&vdraw->drawlg,vdraw->draw_max,&vdraw->drawaxis);CHKERRQ(ierr);
935c6c1daeSBarry Smith 
945c6c1daeSBarry Smith     ierr = PetscMemcpy(vdraw->draw,tdraw,draw_max*sizeof(PetscDraw));CHKERRQ(ierr);
955c6c1daeSBarry Smith     ierr = PetscMemcpy(vdraw->drawlg,drawlg,draw_max*sizeof(PetscDrawLG));CHKERRQ(ierr);
965c6c1daeSBarry Smith     ierr = PetscMemcpy(vdraw->drawaxis,drawaxis,draw_max*sizeof(PetscDrawAxis));CHKERRQ(ierr);
975c6c1daeSBarry Smith 
985c6c1daeSBarry Smith     ierr = PetscFree3(tdraw,drawlg,drawaxis);CHKERRQ(ierr);
995c6c1daeSBarry Smith   }
1005c6c1daeSBarry Smith 
1015c6c1daeSBarry Smith   if (!vdraw->draw[windownumber]) {
102e5ab1681SLisandro Dalcin     char *title = vdraw->title, tmp_str[128];
10310f3a0f4SLisandro Dalcin     if (windownumber) {
10410f3a0f4SLisandro Dalcin       ierr = PetscSNPrintf(tmp_str,sizeof(tmp_str),"%s:%d",vdraw->title?vdraw->title:"",windownumber);CHKERRQ(ierr);
1055c6c1daeSBarry Smith       title = tmp_str;
1065c6c1daeSBarry Smith     }
107ce94432eSBarry Smith     ierr = PetscDrawCreate(PetscObjectComm((PetscObject)viewer),vdraw->display,title,PETSC_DECIDE,PETSC_DECIDE,vdraw->w,vdraw->h,&vdraw->draw[windownumber]);CHKERRQ(ierr);
108e5ab1681SLisandro Dalcin     ierr = PetscLogObjectParent((PetscObject)viewer,(PetscObject)vdraw->draw[windownumber]);CHKERRQ(ierr);
109d1da0b69SBarry Smith     if (vdraw->drawtype) {
110d1da0b69SBarry Smith       ierr = PetscDrawSetType(vdraw->draw[windownumber],vdraw->drawtype);CHKERRQ(ierr);
111d1da0b69SBarry Smith     }
112afe78b3cSBarry Smith     ierr = PetscDrawSetPause(vdraw->draw[windownumber],vdraw->pause);CHKERRQ(ierr);
113d94959e9SLisandro Dalcin     ierr = PetscDrawSetOptionsPrefix(vdraw->draw[windownumber],((PetscObject)viewer)->prefix);CHKERRQ(ierr);
1145c6c1daeSBarry Smith     ierr = PetscDrawSetFromOptions(vdraw->draw[windownumber]);CHKERRQ(ierr);
1155c6c1daeSBarry Smith   }
1165c6c1daeSBarry Smith   if (draw) *draw = vdraw->draw[windownumber];
1175c6c1daeSBarry Smith   if (draw) PetscValidHeaderSpecific(*draw,PETSC_DRAW_CLASSID,-1);
1185c6c1daeSBarry Smith   PetscFunctionReturn(0);
1195c6c1daeSBarry Smith }
1205c6c1daeSBarry Smith 
1215c6c1daeSBarry Smith #undef __FUNCT__
1225c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerDrawBaseAdd"
1235c6c1daeSBarry Smith /*@C
1245c6c1daeSBarry Smith     PetscViewerDrawBaseAdd - add to the base integer that is added to the windownumber passed to PetscViewerDrawGetDraw()
1255c6c1daeSBarry Smith 
126d94959e9SLisandro Dalcin     Logically Collective on PetscViewer
1275c6c1daeSBarry Smith 
1285c6c1daeSBarry Smith     Input Parameters:
1295c6c1daeSBarry Smith +  viewer - the PetscViewer (created with PetscViewerDrawOpen())
1305c6c1daeSBarry Smith -   windownumber - how much to add to the base
1315c6c1daeSBarry Smith 
1325c6c1daeSBarry Smith     Level: developer
1335c6c1daeSBarry Smith 
1345c6c1daeSBarry Smith    Concepts: drawing^accessing PetscDraw context from PetscViewer
1355c6c1daeSBarry Smith    Concepts: graphics
1365c6c1daeSBarry Smith 
1375c6c1daeSBarry Smith .seealso: PetscViewerDrawGetLG(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen(), PetscViewerDrawGetDraw(), PetscViewerDrawBaseSet()
1385c6c1daeSBarry Smith @*/
1395c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawBaseAdd(PetscViewer viewer,PetscInt windownumber)
1405c6c1daeSBarry Smith {
141e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
1425c6c1daeSBarry Smith   PetscErrorCode   ierr;
1435c6c1daeSBarry Smith   PetscBool        isdraw;
1445c6c1daeSBarry Smith 
1455c6c1daeSBarry Smith   PetscFunctionBegin;
1465c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
147e5ab1681SLisandro Dalcin   PetscValidLogicalCollectiveInt(viewer,windownumber,2);
1485c6c1daeSBarry Smith   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
1495c6c1daeSBarry Smith   if (!isdraw) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer");
150e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
151e5ab1681SLisandro Dalcin 
1525c6c1daeSBarry Smith   if (windownumber + vdraw->draw_base < 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Resulting base %D cannot be negative",windownumber+vdraw->draw_base);
1535c6c1daeSBarry Smith   vdraw->draw_base += windownumber;
1545c6c1daeSBarry Smith   PetscFunctionReturn(0);
1555c6c1daeSBarry Smith }
1565c6c1daeSBarry Smith 
1575c6c1daeSBarry Smith #undef __FUNCT__
1585c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerDrawBaseSet"
1595c6c1daeSBarry Smith /*@C
1605c6c1daeSBarry Smith     PetscViewerDrawBaseSet - sets the base integer that is added to the windownumber passed to PetscViewerDrawGetDraw()
1615c6c1daeSBarry Smith 
162d94959e9SLisandro Dalcin     Logically Collective on PetscViewer
1635c6c1daeSBarry Smith 
1645c6c1daeSBarry Smith     Input Parameters:
1655c6c1daeSBarry Smith +   viewer - the PetscViewer (created with PetscViewerDrawOpen())
1665c6c1daeSBarry Smith -   windownumber - value to set the base
1675c6c1daeSBarry Smith 
1685c6c1daeSBarry Smith     Level: developer
1695c6c1daeSBarry Smith 
1705c6c1daeSBarry Smith    Concepts: drawing^accessing PetscDraw context from PetscViewer
1715c6c1daeSBarry Smith    Concepts: graphics
1725c6c1daeSBarry Smith 
1735c6c1daeSBarry Smith .seealso: PetscViewerDrawGetLG(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen(), PetscViewerDrawGetDraw(), PetscViewerDrawBaseAdd()
1745c6c1daeSBarry Smith @*/
1755c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawBaseSet(PetscViewer viewer,PetscInt windownumber)
1765c6c1daeSBarry Smith {
177e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
1785c6c1daeSBarry Smith   PetscErrorCode   ierr;
1795c6c1daeSBarry Smith   PetscBool        isdraw;
1805c6c1daeSBarry Smith 
1815c6c1daeSBarry Smith   PetscFunctionBegin;
1825c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
183e5ab1681SLisandro Dalcin   PetscValidLogicalCollectiveInt(viewer,windownumber,2);
1845c6c1daeSBarry Smith   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
1855c6c1daeSBarry Smith   if (!isdraw) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer");
186e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
187e5ab1681SLisandro Dalcin 
1885c6c1daeSBarry Smith   if (windownumber < 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Resulting base %D cannot be negative",windownumber);
1895c6c1daeSBarry Smith   vdraw->draw_base = windownumber;
1905c6c1daeSBarry Smith   PetscFunctionReturn(0);
1915c6c1daeSBarry Smith }
1925c6c1daeSBarry Smith 
1935c6c1daeSBarry Smith #undef __FUNCT__
1945c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerDrawGetDrawLG"
1955c6c1daeSBarry Smith /*@C
1965c6c1daeSBarry Smith     PetscViewerDrawGetDrawLG - Returns PetscDrawLG object from PetscViewer object.
1975c6c1daeSBarry Smith     This PetscDrawLG object may then be used to perform graphics using
1985c6c1daeSBarry Smith     PetscDrawLGXXX() commands.
1995c6c1daeSBarry Smith 
200d94959e9SLisandro Dalcin     Collective on PetscViewer
2015c6c1daeSBarry Smith 
2025c6c1daeSBarry Smith     Input Parameter:
2035c6c1daeSBarry Smith +   PetscViewer - the PetscViewer (created with PetscViewerDrawOpen())
2045c6c1daeSBarry Smith -   windownumber - indicates which subwindow (usually 0)
2055c6c1daeSBarry Smith 
2065c6c1daeSBarry Smith     Ouput Parameter:
2075c6c1daeSBarry Smith .   draw - the draw line graph object
2085c6c1daeSBarry Smith 
2095c6c1daeSBarry Smith     Level: intermediate
2105c6c1daeSBarry Smith 
2115c6c1daeSBarry Smith   Concepts: line graph^accessing context
2125c6c1daeSBarry Smith 
2135c6c1daeSBarry Smith .seealso: PetscViewerDrawGetDraw(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen()
2145c6c1daeSBarry Smith @*/
2155c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawGetDrawLG(PetscViewer viewer,PetscInt windownumber,PetscDrawLG *drawlg)
2165c6c1daeSBarry Smith {
2175c6c1daeSBarry Smith   PetscErrorCode   ierr;
2185c6c1daeSBarry Smith   PetscBool        isdraw;
219e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
2205c6c1daeSBarry Smith 
2215c6c1daeSBarry Smith   PetscFunctionBegin;
2225c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
223e5ab1681SLisandro Dalcin   PetscValidLogicalCollectiveInt(viewer,windownumber,2);
2245c6c1daeSBarry Smith   PetscValidPointer(drawlg,3);
2255c6c1daeSBarry Smith   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
2265c6c1daeSBarry Smith   if (!isdraw) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer");
2275c6c1daeSBarry Smith   if (windownumber < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Window number cannot be negative");
228e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
2295c6c1daeSBarry Smith 
2305c6c1daeSBarry Smith   if (windownumber+vdraw->draw_base >= vdraw->draw_max || !vdraw->draw[windownumber+vdraw->draw_base]) {
2310298fd71SBarry Smith     ierr = PetscViewerDrawGetDraw(viewer,windownumber,NULL);CHKERRQ(ierr);
2325c6c1daeSBarry Smith   }
2335c6c1daeSBarry Smith   if (!vdraw->drawlg[windownumber+vdraw->draw_base]) {
2345c6c1daeSBarry Smith     ierr = PetscDrawLGCreate(vdraw->draw[windownumber+vdraw->draw_base],1,&vdraw->drawlg[windownumber+vdraw->draw_base]);CHKERRQ(ierr);
2353bb1ff40SBarry Smith     ierr = PetscLogObjectParent((PetscObject)viewer,(PetscObject)vdraw->drawlg[windownumber+vdraw->draw_base]);CHKERRQ(ierr);
236de1a4edeSLisandro Dalcin     ierr = PetscDrawLGSetFromOptions(vdraw->drawlg[windownumber+vdraw->draw_base]);CHKERRQ(ierr);
2375c6c1daeSBarry Smith   }
2385c6c1daeSBarry Smith   *drawlg = vdraw->drawlg[windownumber+vdraw->draw_base];
2395c6c1daeSBarry Smith   PetscFunctionReturn(0);
2405c6c1daeSBarry Smith }
2415c6c1daeSBarry Smith 
2425c6c1daeSBarry Smith #undef __FUNCT__
2435c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerDrawGetDrawAxis"
2445c6c1daeSBarry Smith /*@C
2455c6c1daeSBarry Smith     PetscViewerDrawGetDrawAxis - Returns PetscDrawAxis object from PetscViewer object.
2465c6c1daeSBarry Smith     This PetscDrawAxis object may then be used to perform graphics using
2475c6c1daeSBarry Smith     PetscDrawAxisXXX() commands.
2485c6c1daeSBarry Smith 
249d94959e9SLisandro Dalcin     Collective on PetscViewer
2505c6c1daeSBarry Smith 
2515c6c1daeSBarry Smith     Input Parameter:
2525c6c1daeSBarry Smith +   viewer - the PetscViewer (created with PetscViewerDrawOpen()
2535c6c1daeSBarry Smith -   windownumber - indicates which subwindow (usually 0)
2545c6c1daeSBarry Smith 
2555c6c1daeSBarry Smith     Ouput Parameter:
2565c6c1daeSBarry Smith .   drawaxis - the draw axis object
2575c6c1daeSBarry Smith 
2585c6c1daeSBarry Smith     Level: advanced
2595c6c1daeSBarry Smith 
2605c6c1daeSBarry Smith   Concepts: line graph^accessing context
2615c6c1daeSBarry Smith 
2625c6c1daeSBarry Smith .seealso: PetscViewerDrawGetDraw(), PetscViewerDrawGetLG(), PetscViewerDrawOpen()
2635c6c1daeSBarry Smith @*/
2645c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawGetDrawAxis(PetscViewer viewer,PetscInt windownumber,PetscDrawAxis *drawaxis)
2655c6c1daeSBarry Smith {
2665c6c1daeSBarry Smith   PetscErrorCode   ierr;
2675c6c1daeSBarry Smith   PetscBool        isdraw;
268e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
2695c6c1daeSBarry Smith 
2705c6c1daeSBarry Smith   PetscFunctionBegin;
2715c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
272e5ab1681SLisandro Dalcin   PetscValidLogicalCollectiveInt(viewer,windownumber,2);
2735c6c1daeSBarry Smith   PetscValidPointer(drawaxis,3);
2745c6c1daeSBarry Smith   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
2755c6c1daeSBarry Smith   if (!isdraw) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer");
2765c6c1daeSBarry Smith   if (windownumber < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Window number cannot be negative");
277e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
2785c6c1daeSBarry Smith 
2795c6c1daeSBarry Smith   if (windownumber+vdraw->draw_base >= vdraw->draw_max || !vdraw->draw[windownumber+vdraw->draw_base]) {
2800298fd71SBarry Smith     ierr = PetscViewerDrawGetDraw(viewer,windownumber,NULL);CHKERRQ(ierr);
2815c6c1daeSBarry Smith   }
2825c6c1daeSBarry Smith   if (!vdraw->drawaxis[windownumber+vdraw->draw_base]) {
2835c6c1daeSBarry Smith     ierr = PetscDrawAxisCreate(vdraw->draw[windownumber+vdraw->draw_base],&vdraw->drawaxis[windownumber+vdraw->draw_base]);CHKERRQ(ierr);
2843bb1ff40SBarry Smith     ierr = PetscLogObjectParent((PetscObject)viewer,(PetscObject)vdraw->drawaxis[windownumber+vdraw->draw_base]);CHKERRQ(ierr);
2855c6c1daeSBarry Smith   }
2865c6c1daeSBarry Smith   *drawaxis = vdraw->drawaxis[windownumber+vdraw->draw_base];
2875c6c1daeSBarry Smith   PetscFunctionReturn(0);
2885c6c1daeSBarry Smith }
2895c6c1daeSBarry Smith 
2905c6c1daeSBarry Smith #undef __FUNCT__
2915c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerDrawResize"
2925c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawResize(PetscViewer v,int w,int h)
2935c6c1daeSBarry Smith {
294e5ab1681SLisandro Dalcin   PetscErrorCode   ierr;
295e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
296e5ab1681SLisandro Dalcin   PetscBool        isdraw;
2975c6c1daeSBarry Smith 
2985c6c1daeSBarry Smith   PetscFunctionBegin;
299e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1);
300e5ab1681SLisandro Dalcin   ierr = PetscObjectTypeCompare((PetscObject)v,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
301e5ab1681SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
302e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)v->data;
303e5ab1681SLisandro Dalcin 
304e5ab1681SLisandro Dalcin   if (w >= 1) vdraw->w = w;
305e5ab1681SLisandro Dalcin   if (h >= 1) vdraw->h = h;
3065c6c1daeSBarry Smith   PetscFunctionReturn(0);
3075c6c1daeSBarry Smith }
3085c6c1daeSBarry Smith 
3095c6c1daeSBarry Smith #undef __FUNCT__
3105c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerDrawSetInfo"
3115c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawSetInfo(PetscViewer v,const char display[],const char title[],int x,int y,int w,int h)
3125c6c1daeSBarry Smith {
3135c6c1daeSBarry Smith   PetscErrorCode   ierr;
314e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
315e5ab1681SLisandro Dalcin   PetscBool        isdraw;
3165c6c1daeSBarry Smith 
3175c6c1daeSBarry Smith   PetscFunctionBegin;
318e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1);
319e5ab1681SLisandro Dalcin   ierr = PetscObjectTypeCompare((PetscObject)v,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
320e5ab1681SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
321e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)v->data;
322e5ab1681SLisandro Dalcin 
3235c6c1daeSBarry Smith   ierr = PetscStrallocpy(display,&vdraw->display);CHKERRQ(ierr);
3245c6c1daeSBarry Smith   ierr = PetscStrallocpy(title,&vdraw->title);CHKERRQ(ierr);
325e5ab1681SLisandro Dalcin   if (w >= 1) vdraw->w = w;
326e5ab1681SLisandro Dalcin   if (h >= 1) vdraw->h = h;
3275c6c1daeSBarry Smith   PetscFunctionReturn(0);
3285c6c1daeSBarry Smith }
3295c6c1daeSBarry Smith 
3305c6c1daeSBarry Smith #undef __FUNCT__
331d1da0b69SBarry Smith #define __FUNCT__ "PetscViewerDrawSetDrawType"
332d1da0b69SBarry Smith PetscErrorCode  PetscViewerDrawSetDrawType(PetscViewer v,PetscDrawType drawtype)
333d1da0b69SBarry Smith {
334d1da0b69SBarry Smith   PetscErrorCode   ierr;
335e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
336e5ab1681SLisandro Dalcin   PetscBool        isdraw;
337d1da0b69SBarry Smith 
338d1da0b69SBarry Smith   PetscFunctionBegin;
339e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1);
340e5ab1681SLisandro Dalcin   ierr = PetscObjectTypeCompare((PetscObject)v,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
341e5ab1681SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
342e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)v->data;
343e5ab1681SLisandro Dalcin 
344d1da0b69SBarry Smith   ierr = PetscFree(vdraw->drawtype);CHKERRQ(ierr);
345d1da0b69SBarry Smith   ierr = PetscStrallocpy(drawtype,(char**)&vdraw->drawtype);CHKERRQ(ierr);
346d1da0b69SBarry Smith   PetscFunctionReturn(0);
347d1da0b69SBarry Smith }
348d1da0b69SBarry Smith 
349d1da0b69SBarry Smith #undef __FUNCT__
3505c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerDrawOpen"
3515c6c1daeSBarry Smith /*@C
3525c6c1daeSBarry Smith    PetscViewerDrawOpen - Opens a window for use as a PetscViewer. If you want to
3535c6c1daeSBarry Smith    do graphics in this window, you must call PetscViewerDrawGetDraw() and
3545c6c1daeSBarry Smith    perform the graphics on the PetscDraw object.
3555c6c1daeSBarry Smith 
3565c6c1daeSBarry Smith    Collective on MPI_Comm
3575c6c1daeSBarry Smith 
3585c6c1daeSBarry Smith    Input Parameters:
3595c6c1daeSBarry Smith +  comm - communicator that will share window
3605c6c1daeSBarry Smith .  display - the X display on which to open, or null for the local machine
3615c6c1daeSBarry Smith .  title - the title to put in the title bar, or null for no title
3625c6c1daeSBarry Smith .  x, y - the screen coordinates of the upper left corner of window, or use PETSC_DECIDE
3635c6c1daeSBarry Smith -  w, h - window width and height in pixels, or may use PETSC_DECIDE or PETSC_DRAW_FULL_SIZE, PETSC_DRAW_HALF_SIZE,
3645c6c1daeSBarry Smith           PETSC_DRAW_THIRD_SIZE, PETSC_DRAW_QUARTER_SIZE
3655c6c1daeSBarry Smith 
3665c6c1daeSBarry Smith    Output Parameters:
3675c6c1daeSBarry Smith . viewer - the PetscViewer
3685c6c1daeSBarry Smith 
3695c6c1daeSBarry Smith    Format Options:
3705c6c1daeSBarry Smith +  PETSC_VIEWER_DRAW_BASIC - displays with basic format
3715c6c1daeSBarry Smith -  PETSC_VIEWER_DRAW_LG    - displays using a line graph
3725c6c1daeSBarry Smith 
3735c6c1daeSBarry Smith    Options Database Keys:
3745c6c1daeSBarry Smith    PetscViewerDrawOpen() calls PetscDrawCreate(), so see the manual page for
3755c6c1daeSBarry Smith    PetscDrawCreate() for runtime options, including
3765c6c1daeSBarry Smith +  -draw_type x or null
3775c6c1daeSBarry Smith .  -nox - Disables all x-windows output
3785c6c1daeSBarry Smith .  -display <name> - Specifies name of machine for the X display
3795c6c1daeSBarry Smith .  -geometry <x,y,w,h> - allows setting the window location and size
3805c6c1daeSBarry Smith -  -draw_pause <pause> - Sets time (in seconds) that the
3815c6c1daeSBarry Smith      program pauses after PetscDrawPause() has been called
3825c6c1daeSBarry Smith      (0 is default, -1 implies until user input).
3835c6c1daeSBarry Smith 
3845c6c1daeSBarry Smith    Level: beginner
3855c6c1daeSBarry Smith 
3865c6c1daeSBarry Smith    Note for Fortran Programmers:
3875c6c1daeSBarry Smith    Whenever indicating null character data in a Fortran code,
3880298fd71SBarry Smith    NULL_CHARACTER must be employed; using NULL is not
3890298fd71SBarry Smith    correct for character data!  Thus, NULL_CHARACTER can be
3905c6c1daeSBarry Smith    used for the display and title input parameters.
3915c6c1daeSBarry Smith 
3925c6c1daeSBarry Smith   Concepts: graphics^opening PetscViewer
3935c6c1daeSBarry Smith   Concepts: drawing^opening PetscViewer
3945c6c1daeSBarry Smith 
3955c6c1daeSBarry Smith 
3965c6c1daeSBarry Smith .seealso: PetscDrawCreate(), PetscViewerDestroy(), PetscViewerDrawGetDraw(), PetscViewerCreate(), PETSC_VIEWER_DRAW_,
3975c6c1daeSBarry Smith           PETSC_VIEWER_DRAW_WORLD, PETSC_VIEWER_DRAW_SELF
3985c6c1daeSBarry Smith @*/
3995c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawOpen(MPI_Comm comm,const char display[],const char title[],int x,int y,int w,int h,PetscViewer *viewer)
4005c6c1daeSBarry Smith {
4015c6c1daeSBarry Smith   PetscErrorCode ierr;
4025c6c1daeSBarry Smith 
4035c6c1daeSBarry Smith   PetscFunctionBegin;
4045c6c1daeSBarry Smith   ierr = PetscViewerCreate(comm,viewer);CHKERRQ(ierr);
4055c6c1daeSBarry Smith   ierr = PetscViewerSetType(*viewer,PETSCVIEWERDRAW);CHKERRQ(ierr);
4065c6c1daeSBarry Smith   ierr = PetscViewerDrawSetInfo(*viewer,display,title,x,y,w,h);CHKERRQ(ierr);
4075c6c1daeSBarry Smith   PetscFunctionReturn(0);
4085c6c1daeSBarry Smith }
4095c6c1daeSBarry Smith 
4105c6c1daeSBarry Smith #undef __FUNCT__
4113f08860eSBarry Smith #define __FUNCT__ "PetscViewerGetSubViewer_Draw"
4123f08860eSBarry Smith PetscErrorCode PetscViewerGetSubViewer_Draw(PetscViewer viewer,MPI_Comm comm,PetscViewer *sviewer)
4135c6c1daeSBarry Smith {
4145c6c1daeSBarry Smith   PetscErrorCode   ierr;
4155c6c1daeSBarry Smith   PetscMPIInt      rank;
4165c6c1daeSBarry Smith   PetscInt         i;
417c6228bbaSLisandro Dalcin   PetscViewer_Draw *vdraw = (PetscViewer_Draw*)viewer->data,*svdraw;
4185c6c1daeSBarry Smith 
4195c6c1daeSBarry Smith   PetscFunctionBegin;
4203f08860eSBarry Smith   if (vdraw->singleton_made) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ORDER,"Trying to get SubViewer without first restoring previous");
4215c6c1daeSBarry Smith   /* only processor zero can use the PetscViewer draw singleton */
422c6228bbaSLisandro Dalcin   if (*sviewer) *sviewer = NULL;
423ce94432eSBarry Smith   ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)viewer),&rank);CHKERRQ(ierr);
4245c6c1daeSBarry Smith   if (!rank) {
4255c6c1daeSBarry Smith     ierr = PetscViewerCreate(PETSC_COMM_SELF,sviewer);CHKERRQ(ierr);
4265c6c1daeSBarry Smith     ierr = PetscViewerSetType(*sviewer,PETSCVIEWERDRAW);CHKERRQ(ierr);
427c6228bbaSLisandro Dalcin     svdraw = (PetscViewer_Draw*)(*sviewer)->data;
428c6228bbaSLisandro Dalcin     (*sviewer)->format = viewer->format;
429c6228bbaSLisandro Dalcin     for (i=0; i<vdraw->draw_max; i++) { /* XXX this is wrong if svdraw->draw_max (initially 5) < vdraw->draw_max */
430c6228bbaSLisandro Dalcin       if (vdraw->draw[i]) {ierr = PetscDrawGetSingleton(vdraw->draw[i],&svdraw->draw[i]);CHKERRQ(ierr);}
4315c6c1daeSBarry Smith     }
4325c6c1daeSBarry Smith   }
4335c6c1daeSBarry Smith   vdraw->singleton_made = PETSC_TRUE;
4345c6c1daeSBarry Smith   PetscFunctionReturn(0);
4355c6c1daeSBarry Smith }
4365c6c1daeSBarry Smith 
4375c6c1daeSBarry Smith #undef __FUNCT__
4383f08860eSBarry Smith #define __FUNCT__ "PetscViewerRestoreSubViewer_Draw"
4393f08860eSBarry Smith PetscErrorCode PetscViewerRestoreSubViewer_Draw(PetscViewer viewer,MPI_Comm comm,PetscViewer *sviewer)
4405c6c1daeSBarry Smith {
4415c6c1daeSBarry Smith   PetscErrorCode   ierr;
4425c6c1daeSBarry Smith   PetscMPIInt      rank;
4435c6c1daeSBarry Smith   PetscInt         i;
444c6228bbaSLisandro Dalcin   PetscViewer_Draw *vdraw = (PetscViewer_Draw*)viewer->data,*svdraw;
4455c6c1daeSBarry Smith 
4465c6c1daeSBarry Smith   PetscFunctionBegin;
4475c6c1daeSBarry Smith   if (!vdraw->singleton_made) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ORDER,"Trying to restore a singleton that was not gotten");
448ce94432eSBarry Smith   ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)viewer),&rank);CHKERRQ(ierr);
4495c6c1daeSBarry Smith   if (!rank) {
450c6228bbaSLisandro Dalcin     svdraw = (PetscViewer_Draw*)(*sviewer)->data;
4515c6c1daeSBarry Smith     for (i=0; i<vdraw->draw_max; i++) {
452c6228bbaSLisandro Dalcin       if (vdraw->draw[i] && svdraw->draw[i]) {
453c6228bbaSLisandro Dalcin         ierr = PetscDrawRestoreSingleton(vdraw->draw[i],&svdraw->draw[i]);CHKERRQ(ierr);
4545c6c1daeSBarry Smith       }
4555c6c1daeSBarry Smith     }
456c6228bbaSLisandro Dalcin     ierr = PetscFree3(svdraw->draw,svdraw->drawlg,svdraw->drawaxis);CHKERRQ(ierr);
4575c6c1daeSBarry Smith     ierr = PetscFree((*sviewer)->data);CHKERRQ(ierr);
4585c6c1daeSBarry Smith     ierr = PetscHeaderDestroy(sviewer);CHKERRQ(ierr);
4595c6c1daeSBarry Smith   }
4605c6c1daeSBarry Smith   vdraw->singleton_made = PETSC_FALSE;
4615c6c1daeSBarry Smith   PetscFunctionReturn(0);
4625c6c1daeSBarry Smith }
4635c6c1daeSBarry Smith 
464e9457bf7SBarry Smith #undef __FUNCT__
465e9457bf7SBarry Smith #define __FUNCT__ "PetscViewerSetFromOptions_Draw"
4664416b707SBarry Smith PetscErrorCode PetscViewerSetFromOptions_Draw(PetscOptionItems *PetscOptionsObject,PetscViewer v)
467e9457bf7SBarry Smith {
468e9457bf7SBarry Smith   PetscErrorCode ierr;
469e9457bf7SBarry Smith   PetscReal      bounds[16];
470e9457bf7SBarry Smith   PetscInt       nbounds = 16;
471e9457bf7SBarry Smith   PetscBool      flg;
472e9457bf7SBarry Smith 
473e9457bf7SBarry Smith   PetscFunctionBegin;
474e55864a3SBarry Smith   ierr = PetscOptionsHead(PetscOptionsObject,"Draw PetscViewer Options");CHKERRQ(ierr);
475e9457bf7SBarry Smith   ierr = PetscOptionsRealArray("-draw_bounds","Bounds to put on plots axis","PetscViewerDrawSetBounds",bounds,&nbounds,&flg);CHKERRQ(ierr);
476e9457bf7SBarry Smith   if (flg) {
477e9457bf7SBarry Smith     ierr = PetscViewerDrawSetBounds(v,nbounds/2,bounds);CHKERRQ(ierr);
478e9457bf7SBarry Smith   }
479e9457bf7SBarry Smith   ierr = PetscOptionsTail();CHKERRQ(ierr);
480e9457bf7SBarry Smith   PetscFunctionReturn(0);
481e9457bf7SBarry Smith }
482e9457bf7SBarry Smith 
4835c6c1daeSBarry Smith #undef __FUNCT__
4840076e027SBarry Smith #define __FUNCT__ "PetscViewerView_Draw"
4850076e027SBarry Smith PetscErrorCode PetscViewerView_Draw(PetscViewer viewer,PetscViewer v)
4860076e027SBarry Smith {
4870076e027SBarry Smith   PetscErrorCode   ierr;
4880076e027SBarry Smith   PetscDraw        draw;
4890076e027SBarry Smith   PetscInt         i;
4900076e027SBarry Smith   PetscViewer_Draw *vdraw = (PetscViewer_Draw*)viewer->data;
4910076e027SBarry Smith 
4920076e027SBarry Smith   PetscFunctionBegin;
4930076e027SBarry Smith   /*  If the PetscViewer has just been created then no vdraw->draw yet
4940076e027SBarry Smith       exists so this will not actually call the viewer on any draws. */
4950076e027SBarry Smith   for (i=0; i<vdraw->draw_base; i++) {
4960076e027SBarry Smith     if (vdraw->draw[i]) {
4970076e027SBarry Smith       ierr = PetscViewerDrawGetDraw(viewer,i,&draw);CHKERRQ(ierr);
4980076e027SBarry Smith       ierr = PetscDrawView(draw,v);CHKERRQ(ierr);
4990076e027SBarry Smith     }
5000076e027SBarry Smith   }
5010076e027SBarry Smith   PetscFunctionReturn(0);
5020076e027SBarry Smith }
5030076e027SBarry Smith 
504*8556b5ebSBarry Smith /*MC
505*8556b5ebSBarry Smith    PETSCVIEWERDRAW - A viewer that generates graphics, either to the screen or a file
506*8556b5ebSBarry Smith 
507*8556b5ebSBarry Smith 
508*8556b5ebSBarry Smith .seealso:  PetscViewerDrawOpen(), PetscViewerDrawGetDraw(), PETSC_VIEWER_DRAW_(),PETSC_VIEWER_DRAW_SELF, PETSC_VIEWER_DRAW_WORLD,
509*8556b5ebSBarry Smith            PetscViewerCreate(), PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), PETSCVIEWERBINARY,
510*8556b5ebSBarry Smith            PetscViewerMatlabOpen(), VecView(), DMView(), PetscViewerMatlabPutArray(), PETSCVIEWERASCII, PETSCVIEWERMATLAB,
511*8556b5ebSBarry Smith            PetscViewerFileSetName(), PetscViewerFileSetMode(), PetscViewerFormat, PetscViewerType, PetscViewerSetType()
512*8556b5ebSBarry Smith 
513*8556b5ebSBarry Smith M*/
5140076e027SBarry Smith #undef __FUNCT__
5155c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerCreate_Draw"
5168cc058d9SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerCreate_Draw(PetscViewer viewer)
5175c6c1daeSBarry Smith {
5185c6c1daeSBarry Smith   PetscErrorCode   ierr;
5195c6c1daeSBarry Smith   PetscViewer_Draw *vdraw;
5205c6c1daeSBarry Smith 
5215c6c1daeSBarry Smith   PetscFunctionBegin;
522b00a9115SJed Brown   ierr = PetscNewLog(viewer,&vdraw);CHKERRQ(ierr);
5235c6c1daeSBarry Smith   viewer->data = (void*)vdraw;
5245c6c1daeSBarry Smith 
5255c6c1daeSBarry Smith   viewer->ops->flush            = PetscViewerFlush_Draw;
5260076e027SBarry Smith   viewer->ops->view             = PetscViewerView_Draw;
5275c6c1daeSBarry Smith   viewer->ops->destroy          = PetscViewerDestroy_Draw;
528e9457bf7SBarry Smith   viewer->ops->setfromoptions   = PetscViewerSetFromOptions_Draw;
529559f443fSBarry Smith   viewer->ops->getsubviewer     = PetscViewerGetSubViewer_Draw;
530559f443fSBarry Smith   viewer->ops->restoresubviewer = PetscViewerRestoreSubViewer_Draw;
5315c6c1daeSBarry Smith 
5325c6c1daeSBarry Smith   /* these are created on the fly if requested */
5335c6c1daeSBarry Smith   vdraw->draw_max  = 5;
5345c6c1daeSBarry Smith   vdraw->draw_base = 0;
535ccad63c3SBarry Smith   vdraw->w         = PETSC_DECIDE;
536ccad63c3SBarry Smith   vdraw->h         = PETSC_DECIDE;
537a297a907SKarl Rupp 
5381795a4d1SJed Brown   ierr = PetscCalloc3(vdraw->draw_max,&vdraw->draw,vdraw->draw_max,&vdraw->drawlg,vdraw->draw_max,&vdraw->drawaxis);CHKERRQ(ierr);
5395c6c1daeSBarry Smith   vdraw->singleton_made = PETSC_FALSE;
5405c6c1daeSBarry Smith   PetscFunctionReturn(0);
5415c6c1daeSBarry Smith }
5425c6c1daeSBarry Smith 
5435c6c1daeSBarry Smith #undef __FUNCT__
5445c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerDrawClear"
5455c6c1daeSBarry Smith /*@
5465c6c1daeSBarry Smith     PetscViewerDrawClear - Clears a PetscDraw graphic associated with a PetscViewer.
5475c6c1daeSBarry Smith 
5485c6c1daeSBarry Smith     Not Collective
5495c6c1daeSBarry Smith 
5505c6c1daeSBarry Smith     Input Parameter:
5515c6c1daeSBarry Smith .  viewer - the PetscViewer
5525c6c1daeSBarry Smith 
5535c6c1daeSBarry Smith     Level: intermediate
5545c6c1daeSBarry Smith 
5555c6c1daeSBarry Smith .seealso: PetscViewerDrawOpen(), PetscViewerDrawGetDraw(),
5565c6c1daeSBarry Smith 
5575c6c1daeSBarry Smith @*/
5585c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawClear(PetscViewer viewer)
5595c6c1daeSBarry Smith {
5605c6c1daeSBarry Smith   PetscErrorCode   ierr;
5615c6c1daeSBarry Smith   PetscViewer_Draw *vdraw;
562e5ab1681SLisandro Dalcin   PetscBool        isdraw;
563e5ab1681SLisandro Dalcin   PetscInt         i;
5645c6c1daeSBarry Smith 
5655c6c1daeSBarry Smith   PetscFunctionBegin;
566e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
5675c6c1daeSBarry Smith   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
568e5ab1681SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
5695c6c1daeSBarry Smith   vdraw = (PetscViewer_Draw*)viewer->data;
570e5ab1681SLisandro Dalcin 
5715c6c1daeSBarry Smith   for (i=0; i<vdraw->draw_max; i++) {
5725c6c1daeSBarry Smith     if (vdraw->draw[i]) {ierr = PetscDrawClear(vdraw->draw[i]);CHKERRQ(ierr);}
5735c6c1daeSBarry Smith   }
5745c6c1daeSBarry Smith   PetscFunctionReturn(0);
5755c6c1daeSBarry Smith }
5765c6c1daeSBarry Smith 
5775c6c1daeSBarry Smith #undef __FUNCT__
5785c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerDrawGetPause"
5795c6c1daeSBarry Smith /*@
5805c6c1daeSBarry Smith     PetscViewerDrawGetPause - Gets a pause for the first present draw
5815c6c1daeSBarry Smith 
5825c6c1daeSBarry Smith     Not Collective
5835c6c1daeSBarry Smith 
5845c6c1daeSBarry Smith     Input Parameter:
5855c6c1daeSBarry Smith .  viewer - the PetscViewer
5865c6c1daeSBarry Smith 
5875c6c1daeSBarry Smith     Output Parameter:
5885c6c1daeSBarry Smith .  pause - the pause value
5895c6c1daeSBarry Smith 
5905c6c1daeSBarry Smith     Level: intermediate
5915c6c1daeSBarry Smith 
5925c6c1daeSBarry Smith .seealso: PetscViewerDrawOpen(), PetscViewerDrawGetDraw(),
5935c6c1daeSBarry Smith 
5945c6c1daeSBarry Smith @*/
5955c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawGetPause(PetscViewer viewer,PetscReal *pause)
5965c6c1daeSBarry Smith {
5975c6c1daeSBarry Smith   PetscErrorCode   ierr;
5985c6c1daeSBarry Smith   PetscViewer_Draw *vdraw;
599e5ab1681SLisandro Dalcin   PetscBool        isdraw;
600e5ab1681SLisandro Dalcin   PetscInt         i;
6015c6c1daeSBarry Smith   PetscDraw        draw;
6025c6c1daeSBarry Smith 
6035c6c1daeSBarry Smith   PetscFunctionBegin;
604e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
6055c6c1daeSBarry Smith   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
606e5ab1681SLisandro Dalcin   if (!isdraw) {*pause = 0.0; PetscFunctionReturn(0);}
6075c6c1daeSBarry Smith   vdraw = (PetscViewer_Draw*)viewer->data;
608e5ab1681SLisandro Dalcin 
6095c6c1daeSBarry Smith   for (i=0; i<vdraw->draw_max; i++) {
6105c6c1daeSBarry Smith     if (vdraw->draw[i]) {
6115c6c1daeSBarry Smith       ierr = PetscDrawGetPause(vdraw->draw[i],pause);CHKERRQ(ierr);
6125c6c1daeSBarry Smith       PetscFunctionReturn(0);
6135c6c1daeSBarry Smith     }
6145c6c1daeSBarry Smith   }
6155c6c1daeSBarry Smith   /* none exist yet so create one and get its pause */
6165c6c1daeSBarry Smith   ierr = PetscViewerDrawGetDraw(viewer,0,&draw);CHKERRQ(ierr);
617e5ab1681SLisandro Dalcin   ierr = PetscDrawGetPause(draw,pause);CHKERRQ(ierr);
6185c6c1daeSBarry Smith   PetscFunctionReturn(0);
6195c6c1daeSBarry Smith }
6205c6c1daeSBarry Smith 
6215c6c1daeSBarry Smith #undef __FUNCT__
6225c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerDrawSetPause"
6235c6c1daeSBarry Smith /*@
6245c6c1daeSBarry Smith     PetscViewerDrawSetPause - Sets a pause for each PetscDraw in the viewer
6255c6c1daeSBarry Smith 
6265c6c1daeSBarry Smith     Not Collective
6275c6c1daeSBarry Smith 
6285c6c1daeSBarry Smith     Input Parameters:
6295c6c1daeSBarry Smith +  viewer - the PetscViewer
6305c6c1daeSBarry Smith -  pause - the pause value
6315c6c1daeSBarry Smith 
6325c6c1daeSBarry Smith     Level: intermediate
6335c6c1daeSBarry Smith 
6345c6c1daeSBarry Smith .seealso: PetscViewerDrawOpen(), PetscViewerDrawGetDraw(),
6355c6c1daeSBarry Smith 
6365c6c1daeSBarry Smith @*/
6375c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawSetPause(PetscViewer viewer,PetscReal pause)
6385c6c1daeSBarry Smith {
6395c6c1daeSBarry Smith   PetscErrorCode   ierr;
640e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
6415c6c1daeSBarry Smith   PetscBool        isdraw;
642e5ab1681SLisandro Dalcin   PetscInt         i;
6435c6c1daeSBarry Smith 
6445c6c1daeSBarry Smith   PetscFunctionBegin;
645e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
6465c6c1daeSBarry Smith   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
647e5ab1681SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
648e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
649afe78b3cSBarry Smith 
650afe78b3cSBarry Smith   vdraw->pause = pause;
6515c6c1daeSBarry Smith   for (i=0; i<vdraw->draw_max; i++) {
6525c6c1daeSBarry Smith     if (vdraw->draw[i]) {ierr = PetscDrawSetPause(vdraw->draw[i],pause);CHKERRQ(ierr);}
6535c6c1daeSBarry Smith   }
6545c6c1daeSBarry Smith   PetscFunctionReturn(0);
6555c6c1daeSBarry Smith }
6565c6c1daeSBarry Smith 
6575c6c1daeSBarry Smith 
6585c6c1daeSBarry Smith #undef __FUNCT__
6595c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerDrawSetHold"
6605c6c1daeSBarry Smith /*@
6615c6c1daeSBarry Smith     PetscViewerDrawSetHold - Holds previous image when drawing new image
6625c6c1daeSBarry Smith 
6635c6c1daeSBarry Smith     Not Collective
6645c6c1daeSBarry Smith 
6655c6c1daeSBarry Smith     Input Parameters:
6665c6c1daeSBarry Smith +  viewer - the PetscViewer
6675c6c1daeSBarry Smith -  hold - indicates to hold or not
6685c6c1daeSBarry Smith 
6695c6c1daeSBarry Smith     Level: intermediate
6705c6c1daeSBarry Smith 
6715c6c1daeSBarry Smith .seealso: PetscViewerDrawOpen(), PetscViewerDrawGetDraw(),
6725c6c1daeSBarry Smith 
6735c6c1daeSBarry Smith @*/
6745c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawSetHold(PetscViewer viewer,PetscBool hold)
6755c6c1daeSBarry Smith {
6765c6c1daeSBarry Smith   PetscErrorCode   ierr;
6775c6c1daeSBarry Smith   PetscViewer_Draw *vdraw;
6785c6c1daeSBarry Smith   PetscBool        isdraw;
6795c6c1daeSBarry Smith 
6805c6c1daeSBarry Smith   PetscFunctionBegin;
681e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
6825c6c1daeSBarry Smith   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
683e5ab1681SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
6845c6c1daeSBarry Smith   vdraw = (PetscViewer_Draw*)viewer->data;
685e5ab1681SLisandro Dalcin 
6865c6c1daeSBarry Smith   vdraw->hold = hold;
6875c6c1daeSBarry Smith   PetscFunctionReturn(0);
6885c6c1daeSBarry Smith }
6895c6c1daeSBarry Smith 
6905c6c1daeSBarry Smith #undef __FUNCT__
6915c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerDrawGetHold"
6925c6c1daeSBarry Smith /*@
693d97d059aSBarry Smith     PetscViewerDrawGetHold - Checks if holds previous image when drawing new image
6945c6c1daeSBarry Smith 
6955c6c1daeSBarry Smith     Not Collective
6965c6c1daeSBarry Smith 
6975c6c1daeSBarry Smith     Input Parameter:
6985c6c1daeSBarry Smith .  viewer - the PetscViewer
6995c6c1daeSBarry Smith 
7005c6c1daeSBarry Smith     Output Parameter:
7015c6c1daeSBarry Smith .  hold - indicates to hold or not
7025c6c1daeSBarry Smith 
7035c6c1daeSBarry Smith     Level: intermediate
7045c6c1daeSBarry Smith 
7055c6c1daeSBarry Smith .seealso: PetscViewerDrawOpen(), PetscViewerDrawGetDraw(),
7065c6c1daeSBarry Smith 
7075c6c1daeSBarry Smith @*/
7085c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawGetHold(PetscViewer viewer,PetscBool *hold)
7095c6c1daeSBarry Smith {
7105c6c1daeSBarry Smith   PetscErrorCode   ierr;
7115c6c1daeSBarry Smith   PetscViewer_Draw *vdraw;
7125c6c1daeSBarry Smith   PetscBool        isdraw;
7135c6c1daeSBarry Smith 
7145c6c1daeSBarry Smith   PetscFunctionBegin;
715e5ab1681SLisandro Dalcin   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
7165c6c1daeSBarry Smith   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
717e5ab1681SLisandro Dalcin   if (!isdraw) {*hold = PETSC_FALSE; PetscFunctionReturn(0);}
7185c6c1daeSBarry Smith   vdraw = (PetscViewer_Draw*)viewer->data;
719e5ab1681SLisandro Dalcin 
7205c6c1daeSBarry Smith   *hold = vdraw->hold;
7215c6c1daeSBarry Smith   PetscFunctionReturn(0);
7225c6c1daeSBarry Smith }
7235c6c1daeSBarry Smith 
7245c6c1daeSBarry Smith /* ---------------------------------------------------------------------*/
7255c6c1daeSBarry Smith /*
7265c6c1daeSBarry Smith     The variable Petsc_Viewer_Draw_keyval is used to indicate an MPI attribute that
7275c6c1daeSBarry Smith   is attached to a communicator, in this case the attribute is a PetscViewer.
7285c6c1daeSBarry Smith */
7295c6c1daeSBarry Smith static PetscMPIInt Petsc_Viewer_Draw_keyval = MPI_KEYVAL_INVALID;
7305c6c1daeSBarry Smith 
7315c6c1daeSBarry Smith #undef __FUNCT__
7325c6c1daeSBarry Smith #define __FUNCT__ "PETSC_VIEWER_DRAW_"
7335c6c1daeSBarry Smith /*@C
7345c6c1daeSBarry Smith     PETSC_VIEWER_DRAW_ - Creates a window PetscViewer shared by all processors
7355c6c1daeSBarry Smith                      in a communicator.
7365c6c1daeSBarry Smith 
7375c6c1daeSBarry Smith      Collective on MPI_Comm
7385c6c1daeSBarry Smith 
7395c6c1daeSBarry Smith      Input Parameter:
7405c6c1daeSBarry Smith .    comm - the MPI communicator to share the window PetscViewer
7415c6c1daeSBarry Smith 
7425c6c1daeSBarry Smith      Level: intermediate
7435c6c1daeSBarry Smith 
7445c6c1daeSBarry Smith      Notes:
7455c6c1daeSBarry Smith      Unlike almost all other PETSc routines, PETSC_VIEWER_DRAW_ does not return
7465c6c1daeSBarry Smith      an error code.  The window is usually used in the form
7475c6c1daeSBarry Smith $       XXXView(XXX object,PETSC_VIEWER_DRAW_(comm));
7485c6c1daeSBarry Smith 
7495c6c1daeSBarry Smith .seealso: PETSC_VIEWER_DRAW_WORLD, PETSC_VIEWER_DRAW_SELF, PetscViewerDrawOpen(),
7505c6c1daeSBarry Smith @*/
7515c6c1daeSBarry Smith PetscViewer  PETSC_VIEWER_DRAW_(MPI_Comm comm)
7525c6c1daeSBarry Smith {
7535c6c1daeSBarry Smith   PetscErrorCode ierr;
7545c6c1daeSBarry Smith   PetscMPIInt    flag;
7555c6c1daeSBarry Smith   PetscViewer    viewer;
7565c6c1daeSBarry Smith   MPI_Comm       ncomm;
7575c6c1daeSBarry Smith 
7585c6c1daeSBarry Smith   PetscFunctionBegin;
759efca3c55SSatish Balay   ierr = PetscCommDuplicate(comm,&ncomm,NULL);if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_INITIAL," ");PetscFunctionReturn(0);}
7605c6c1daeSBarry Smith   if (Petsc_Viewer_Draw_keyval == MPI_KEYVAL_INVALID) {
7615c6c1daeSBarry Smith     ierr = MPI_Keyval_create(MPI_NULL_COPY_FN,MPI_NULL_DELETE_FN,&Petsc_Viewer_Draw_keyval,0);
762efca3c55SSatish Balay     if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_INITIAL," ");PetscFunctionReturn(0);}
7635c6c1daeSBarry Smith   }
7645c6c1daeSBarry Smith   ierr = MPI_Attr_get(ncomm,Petsc_Viewer_Draw_keyval,(void**)&viewer,&flag);
765efca3c55SSatish Balay   if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_INITIAL," ");PetscFunctionReturn(0);}
7665c6c1daeSBarry Smith   if (!flag) { /* PetscViewer not yet created */
7675c6c1daeSBarry Smith     ierr = PetscViewerDrawOpen(ncomm,0,0,PETSC_DECIDE,PETSC_DECIDE,300,300,&viewer);
768efca3c55SSatish Balay     if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_INITIAL," ");PetscFunctionReturn(0);}
7695c6c1daeSBarry Smith     ierr = PetscObjectRegisterDestroy((PetscObject)viewer);
770efca3c55SSatish Balay     if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_INITIAL," ");PetscFunctionReturn(0);}
7715c6c1daeSBarry Smith     ierr = MPI_Attr_put(ncomm,Petsc_Viewer_Draw_keyval,(void*)viewer);
772efca3c55SSatish Balay     if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_INITIAL," ");PetscFunctionReturn(0);}
7735c6c1daeSBarry Smith   }
7745c6c1daeSBarry Smith   ierr = PetscCommDestroy(&ncomm);
775efca3c55SSatish Balay   if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_INITIAL," ");PetscFunctionReturn(0);}
7765c6c1daeSBarry Smith   PetscFunctionReturn(viewer);
7775c6c1daeSBarry Smith }
7785c6c1daeSBarry Smith 
7795c6c1daeSBarry Smith #undef __FUNCT__
7805c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerDrawSetBounds"
7815c6c1daeSBarry Smith /*@
7825c6c1daeSBarry Smith     PetscViewerDrawSetBounds - sets the upper and lower bounds to be used in plotting
7835c6c1daeSBarry Smith 
7845c6c1daeSBarry Smith     Collective on PetscViewer
7855c6c1daeSBarry Smith 
7865c6c1daeSBarry Smith     Input Parameters:
7875c6c1daeSBarry Smith +   viewer - the PetscViewer (created with PetscViewerDrawOpen())
7885c6c1daeSBarry Smith .   nbounds - number of plots that can be made with this viewer, for example the dof passed to DMDACreate()
7895c6c1daeSBarry 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, .....
7905c6c1daeSBarry Smith 
791e9457bf7SBarry Smith 
792e9457bf7SBarry Smith     Options Database:
793e9457bf7SBarry Smith .   -draw_bounds  minF0,maxF0,minF1,maxF1
794e9457bf7SBarry Smith 
7955c6c1daeSBarry Smith     Level: intermediate
7965c6c1daeSBarry Smith 
797f3f0eb19SBarry Smith     Notes: 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
798f3f0eb19SBarry 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
799f3f0eb19SBarry Smith       this viewer. Otherwise the color to physical value meaning changes with each new image if this is not set.
800f3f0eb19SBarry Smith 
8015c6c1daeSBarry Smith    Concepts: drawing^accessing PetscDraw context from PetscViewer
8025c6c1daeSBarry Smith    Concepts: graphics
8035c6c1daeSBarry Smith 
8045c6c1daeSBarry Smith .seealso: PetscViewerDrawGetLG(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen()
8055c6c1daeSBarry Smith @*/
8065c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawSetBounds(PetscViewer viewer,PetscInt nbounds,const PetscReal *bounds)
8075c6c1daeSBarry Smith {
808e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
809e5ab1681SLisandro Dalcin   PetscBool        isdraw;
8105c6c1daeSBarry Smith   PetscErrorCode   ierr;
8115c6c1daeSBarry Smith 
8125c6c1daeSBarry Smith 
8135c6c1daeSBarry Smith   PetscFunctionBegin;
8145c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
815e5ab1681SLisandro Dalcin   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
816e5ab1681SLisandro Dalcin   if (!isdraw) PetscFunctionReturn(0);
817e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
818a297a907SKarl Rupp 
819e5ab1681SLisandro Dalcin   vdraw->nbounds = nbounds;
820e5ab1681SLisandro Dalcin   ierr = PetscFree(vdraw->bounds);CHKERRQ(ierr);
821785e854fSJed Brown   ierr = PetscMalloc1(2*nbounds,&vdraw->bounds);CHKERRQ(ierr);
8225c6c1daeSBarry Smith   ierr = PetscMemcpy(vdraw->bounds,bounds,2*nbounds*sizeof(PetscReal));CHKERRQ(ierr);
8235c6c1daeSBarry Smith   PetscFunctionReturn(0);
8245c6c1daeSBarry Smith }
8255c6c1daeSBarry Smith 
8265c6c1daeSBarry Smith #undef __FUNCT__
8275c6c1daeSBarry Smith #define __FUNCT__ "PetscViewerDrawGetBounds"
8285c6c1daeSBarry Smith /*@C
8295c6c1daeSBarry Smith     PetscViewerDrawGetBounds - gets the upper and lower bounds to be used in plotting set with PetscViewerDrawSetBounds()
8305c6c1daeSBarry Smith 
8315c6c1daeSBarry Smith     Collective on PetscViewer
8325c6c1daeSBarry Smith 
8335c6c1daeSBarry Smith     Input Parameter:
8345c6c1daeSBarry Smith .   viewer - the PetscViewer (created with PetscViewerDrawOpen())
8355c6c1daeSBarry Smith 
8365c6c1daeSBarry Smith     Output Paramters:
8375c6c1daeSBarry Smith +   nbounds - number of plots that can be made with this viewer, for example the dof passed to DMDACreate()
8385c6c1daeSBarry 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, .....
8395c6c1daeSBarry Smith 
8405c6c1daeSBarry Smith     Level: intermediate
8415c6c1daeSBarry Smith 
8425c6c1daeSBarry Smith    Concepts: drawing^accessing PetscDraw context from PetscViewer
8435c6c1daeSBarry Smith    Concepts: graphics
8445c6c1daeSBarry Smith 
845f3f0eb19SBarry Smith .seealso: PetscViewerDrawGetLG(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen(), PetscViewerDrawSetBounds()
8465c6c1daeSBarry Smith @*/
8475c6c1daeSBarry Smith PetscErrorCode  PetscViewerDrawGetBounds(PetscViewer viewer,PetscInt *nbounds,const PetscReal **bounds)
8485c6c1daeSBarry Smith {
849e5ab1681SLisandro Dalcin   PetscViewer_Draw *vdraw;
850e5ab1681SLisandro Dalcin   PetscBool        isdraw;
851e5ab1681SLisandro Dalcin   PetscErrorCode   ierr;
8525c6c1daeSBarry Smith 
8535c6c1daeSBarry Smith   PetscFunctionBegin;
8545c6c1daeSBarry Smith   PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1);
855e5ab1681SLisandro Dalcin   ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr);
856e5ab1681SLisandro Dalcin   if (!isdraw) {if (nbounds) *nbounds = 0; if (bounds) *bounds = NULL; PetscFunctionReturn(0);}
857e5ab1681SLisandro Dalcin   vdraw = (PetscViewer_Draw*)viewer->data;
858e5ab1681SLisandro Dalcin 
859e5ab1681SLisandro Dalcin   if (nbounds) *nbounds = vdraw->nbounds;
860e5ab1681SLisandro Dalcin   if (bounds)  *bounds  = vdraw->bounds;
8615c6c1daeSBarry Smith   PetscFunctionReturn(0);
8625c6c1daeSBarry Smith }
863