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 PetscErrorCode ierr; 85c6c1daeSBarry Smith PetscInt i; 95c6c1daeSBarry Smith PetscViewer_Draw *vdraw = (PetscViewer_Draw*)v->data; 105c6c1daeSBarry Smith 115c6c1daeSBarry Smith PetscFunctionBegin; 125c6c1daeSBarry Smith if (vdraw->singleton_made) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ORDER,"Destroying PetscViewer without first restoring singleton"); 135c6c1daeSBarry Smith for (i=0; i<vdraw->draw_max; i++) { 145c6c1daeSBarry Smith ierr = PetscDrawAxisDestroy(&vdraw->drawaxis[i]);CHKERRQ(ierr); 155c6c1daeSBarry Smith ierr = PetscDrawLGDestroy(&vdraw->drawlg[i]);CHKERRQ(ierr); 165c6c1daeSBarry Smith ierr = PetscDrawDestroy(&vdraw->draw[i]);CHKERRQ(ierr); 175c6c1daeSBarry Smith } 185c6c1daeSBarry Smith ierr = PetscFree(vdraw->display);CHKERRQ(ierr); 195c6c1daeSBarry Smith ierr = PetscFree(vdraw->title);CHKERRQ(ierr); 205c6c1daeSBarry Smith ierr = PetscFree3(vdraw->draw,vdraw->drawlg,vdraw->drawaxis);CHKERRQ(ierr); 215c6c1daeSBarry Smith ierr = PetscFree(vdraw->bounds);CHKERRQ(ierr); 22d1da0b69SBarry Smith ierr = PetscFree(vdraw->drawtype);CHKERRQ(ierr); 23e5ab1681SLisandro Dalcin ierr = PetscFree(v->data);CHKERRQ(ierr); 245c6c1daeSBarry Smith PetscFunctionReturn(0); 255c6c1daeSBarry Smith } 265c6c1daeSBarry Smith 27e0877f53SBarry Smith static PetscErrorCode PetscViewerFlush_Draw(PetscViewer v) 285c6c1daeSBarry Smith { 295c6c1daeSBarry Smith PetscErrorCode ierr; 305c6c1daeSBarry Smith PetscInt i; 315c6c1daeSBarry Smith PetscViewer_Draw *vdraw = (PetscViewer_Draw*)v->data; 325c6c1daeSBarry Smith 335c6c1daeSBarry Smith PetscFunctionBegin; 345c6c1daeSBarry Smith for (i=0; i<vdraw->draw_max; i++) { 355b399a63SLisandro Dalcin if (vdraw->draw[i]) {ierr = PetscDrawFlush(vdraw->draw[i]);CHKERRQ(ierr);} 365c6c1daeSBarry Smith } 375c6c1daeSBarry Smith PetscFunctionReturn(0); 385c6c1daeSBarry Smith } 395c6c1daeSBarry Smith 405c6c1daeSBarry Smith /*@C 415c6c1daeSBarry Smith PetscViewerDrawGetDraw - Returns PetscDraw object from PetscViewer object. 425c6c1daeSBarry Smith This PetscDraw object may then be used to perform graphics using 435c6c1daeSBarry Smith PetscDrawXXX() commands. 445c6c1daeSBarry Smith 45d94959e9SLisandro Dalcin Collective on PetscViewer 465c6c1daeSBarry Smith 475c6c1daeSBarry Smith Input Parameters: 485c6c1daeSBarry Smith + viewer - the PetscViewer (created with PetscViewerDrawOpen()) 495c6c1daeSBarry Smith - windownumber - indicates which subwindow (usually 0) 505c6c1daeSBarry Smith 5101d2d390SJose E. Roman Output Parameter: 525c6c1daeSBarry Smith . draw - the draw object 535c6c1daeSBarry Smith 545c6c1daeSBarry Smith Level: intermediate 555c6c1daeSBarry Smith 565c6c1daeSBarry Smith .seealso: PetscViewerDrawGetLG(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen() 575c6c1daeSBarry Smith @*/ 585c6c1daeSBarry Smith PetscErrorCode PetscViewerDrawGetDraw(PetscViewer viewer,PetscInt windownumber,PetscDraw *draw) 595c6c1daeSBarry Smith { 60e5ab1681SLisandro Dalcin PetscViewer_Draw *vdraw; 615c6c1daeSBarry Smith PetscErrorCode ierr; 625c6c1daeSBarry Smith PetscBool isdraw; 635c6c1daeSBarry Smith 645c6c1daeSBarry Smith PetscFunctionBegin; 655c6c1daeSBarry Smith PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); 66e5ab1681SLisandro Dalcin PetscValidLogicalCollectiveInt(viewer,windownumber,2); 675c6c1daeSBarry Smith if (draw) PetscValidPointer(draw,3); 685c6c1daeSBarry Smith ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); 695c6c1daeSBarry Smith if (!isdraw) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer"); 705c6c1daeSBarry Smith if (windownumber < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Window number cannot be negative"); 71e5ab1681SLisandro Dalcin vdraw = (PetscViewer_Draw*)viewer->data; 72e5ab1681SLisandro Dalcin 735c6c1daeSBarry Smith windownumber += vdraw->draw_base; 745c6c1daeSBarry Smith if (windownumber >= vdraw->draw_max) { 755c6c1daeSBarry Smith /* allocate twice as many slots as needed */ 765c6c1daeSBarry Smith PetscInt draw_max = vdraw->draw_max; 775c6c1daeSBarry Smith PetscDraw *tdraw = vdraw->draw; 785c6c1daeSBarry Smith PetscDrawLG *drawlg = vdraw->drawlg; 795c6c1daeSBarry Smith PetscDrawAxis *drawaxis = vdraw->drawaxis; 805c6c1daeSBarry Smith 815c6c1daeSBarry Smith vdraw->draw_max = 2*windownumber; 82a297a907SKarl Rupp 831795a4d1SJed Brown ierr = PetscCalloc3(vdraw->draw_max,&vdraw->draw,vdraw->draw_max,&vdraw->drawlg,vdraw->draw_max,&vdraw->drawaxis);CHKERRQ(ierr); 84580bdb30SBarry Smith ierr = PetscArraycpy(vdraw->draw,tdraw,draw_max);CHKERRQ(ierr); 85580bdb30SBarry Smith ierr = PetscArraycpy(vdraw->drawlg,drawlg,draw_max);CHKERRQ(ierr); 86580bdb30SBarry Smith ierr = PetscArraycpy(vdraw->drawaxis,drawaxis,draw_max);CHKERRQ(ierr); 875c6c1daeSBarry Smith ierr = PetscFree3(tdraw,drawlg,drawaxis);CHKERRQ(ierr); 885c6c1daeSBarry Smith } 895c6c1daeSBarry Smith 905c6c1daeSBarry Smith if (!vdraw->draw[windownumber]) { 91e5ab1681SLisandro Dalcin char *title = vdraw->title, tmp_str[128]; 9210f3a0f4SLisandro Dalcin if (windownumber) { 9310f3a0f4SLisandro Dalcin ierr = PetscSNPrintf(tmp_str,sizeof(tmp_str),"%s:%d",vdraw->title?vdraw->title:"",windownumber);CHKERRQ(ierr); 945c6c1daeSBarry Smith title = tmp_str; 955c6c1daeSBarry Smith } 96ce94432eSBarry Smith ierr = PetscDrawCreate(PetscObjectComm((PetscObject)viewer),vdraw->display,title,PETSC_DECIDE,PETSC_DECIDE,vdraw->w,vdraw->h,&vdraw->draw[windownumber]);CHKERRQ(ierr); 97e5ab1681SLisandro Dalcin ierr = PetscLogObjectParent((PetscObject)viewer,(PetscObject)vdraw->draw[windownumber]);CHKERRQ(ierr); 98d1da0b69SBarry Smith if (vdraw->drawtype) { 99d1da0b69SBarry Smith ierr = PetscDrawSetType(vdraw->draw[windownumber],vdraw->drawtype);CHKERRQ(ierr); 100d1da0b69SBarry Smith } 101afe78b3cSBarry Smith ierr = PetscDrawSetPause(vdraw->draw[windownumber],vdraw->pause);CHKERRQ(ierr); 102d94959e9SLisandro Dalcin ierr = PetscDrawSetOptionsPrefix(vdraw->draw[windownumber],((PetscObject)viewer)->prefix);CHKERRQ(ierr); 1035c6c1daeSBarry Smith ierr = PetscDrawSetFromOptions(vdraw->draw[windownumber]);CHKERRQ(ierr); 1045c6c1daeSBarry Smith } 1055c6c1daeSBarry Smith if (draw) *draw = vdraw->draw[windownumber]; 106064a246eSJacob Faibussowitsch if (draw) PetscValidHeaderSpecific(*draw,PETSC_DRAW_CLASSID,3); 1075c6c1daeSBarry Smith PetscFunctionReturn(0); 1085c6c1daeSBarry Smith } 1095c6c1daeSBarry Smith 1105c6c1daeSBarry Smith /*@C 1115c6c1daeSBarry Smith PetscViewerDrawBaseAdd - add to the base integer that is added to the windownumber passed to PetscViewerDrawGetDraw() 1125c6c1daeSBarry Smith 113d94959e9SLisandro Dalcin Logically Collective on PetscViewer 1145c6c1daeSBarry Smith 1155c6c1daeSBarry Smith Input Parameters: 1165c6c1daeSBarry Smith + viewer - the PetscViewer (created with PetscViewerDrawOpen()) 1175c6c1daeSBarry Smith - windownumber - how much to add to the base 1185c6c1daeSBarry Smith 1195c6c1daeSBarry Smith Level: developer 1205c6c1daeSBarry Smith 1215c6c1daeSBarry Smith .seealso: PetscViewerDrawGetLG(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen(), PetscViewerDrawGetDraw(), PetscViewerDrawBaseSet() 1225c6c1daeSBarry Smith @*/ 1235c6c1daeSBarry Smith PetscErrorCode PetscViewerDrawBaseAdd(PetscViewer viewer,PetscInt windownumber) 1245c6c1daeSBarry Smith { 125e5ab1681SLisandro Dalcin PetscViewer_Draw *vdraw; 1265c6c1daeSBarry Smith PetscErrorCode ierr; 1275c6c1daeSBarry Smith PetscBool isdraw; 1285c6c1daeSBarry Smith 1295c6c1daeSBarry Smith PetscFunctionBegin; 1305c6c1daeSBarry Smith PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); 131e5ab1681SLisandro Dalcin PetscValidLogicalCollectiveInt(viewer,windownumber,2); 1325c6c1daeSBarry Smith ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); 1335c6c1daeSBarry Smith if (!isdraw) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer"); 134e5ab1681SLisandro Dalcin vdraw = (PetscViewer_Draw*)viewer->data; 135e5ab1681SLisandro Dalcin 1365c6c1daeSBarry 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); 1375c6c1daeSBarry Smith vdraw->draw_base += windownumber; 1385c6c1daeSBarry Smith PetscFunctionReturn(0); 1395c6c1daeSBarry Smith } 1405c6c1daeSBarry Smith 1415c6c1daeSBarry Smith /*@C 1425c6c1daeSBarry Smith PetscViewerDrawBaseSet - sets the base integer that is added to the windownumber passed to PetscViewerDrawGetDraw() 1435c6c1daeSBarry Smith 144d94959e9SLisandro Dalcin Logically Collective on PetscViewer 1455c6c1daeSBarry Smith 1465c6c1daeSBarry Smith Input Parameters: 1475c6c1daeSBarry Smith + viewer - the PetscViewer (created with PetscViewerDrawOpen()) 1485c6c1daeSBarry Smith - windownumber - value to set the base 1495c6c1daeSBarry Smith 1505c6c1daeSBarry Smith Level: developer 1515c6c1daeSBarry Smith 1525c6c1daeSBarry Smith .seealso: PetscViewerDrawGetLG(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen(), PetscViewerDrawGetDraw(), PetscViewerDrawBaseAdd() 1535c6c1daeSBarry Smith @*/ 1545c6c1daeSBarry Smith PetscErrorCode PetscViewerDrawBaseSet(PetscViewer viewer,PetscInt windownumber) 1555c6c1daeSBarry Smith { 156e5ab1681SLisandro Dalcin PetscViewer_Draw *vdraw; 1575c6c1daeSBarry Smith PetscErrorCode ierr; 1585c6c1daeSBarry Smith PetscBool isdraw; 1595c6c1daeSBarry Smith 1605c6c1daeSBarry Smith PetscFunctionBegin; 1615c6c1daeSBarry Smith PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); 162e5ab1681SLisandro Dalcin PetscValidLogicalCollectiveInt(viewer,windownumber,2); 1635c6c1daeSBarry Smith ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); 1645c6c1daeSBarry Smith if (!isdraw) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer"); 165e5ab1681SLisandro Dalcin vdraw = (PetscViewer_Draw*)viewer->data; 166e5ab1681SLisandro Dalcin 1675c6c1daeSBarry Smith if (windownumber < 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Resulting base %D cannot be negative",windownumber); 1685c6c1daeSBarry Smith vdraw->draw_base = windownumber; 1695c6c1daeSBarry Smith PetscFunctionReturn(0); 1705c6c1daeSBarry Smith } 1715c6c1daeSBarry Smith 1725c6c1daeSBarry Smith /*@C 1735c6c1daeSBarry Smith PetscViewerDrawGetDrawLG - Returns PetscDrawLG object from PetscViewer object. 1745c6c1daeSBarry Smith This PetscDrawLG object may then be used to perform graphics using 1755c6c1daeSBarry Smith PetscDrawLGXXX() commands. 1765c6c1daeSBarry Smith 177d94959e9SLisandro Dalcin Collective on PetscViewer 1785c6c1daeSBarry Smith 179*d8d19677SJose E. Roman Input Parameters: 1805c6c1daeSBarry Smith + PetscViewer - the PetscViewer (created with PetscViewerDrawOpen()) 1815c6c1daeSBarry Smith - windownumber - indicates which subwindow (usually 0) 1825c6c1daeSBarry Smith 18301d2d390SJose E. Roman Output Parameter: 1845c6c1daeSBarry Smith . draw - the draw line graph object 1855c6c1daeSBarry Smith 1865c6c1daeSBarry Smith Level: intermediate 1875c6c1daeSBarry Smith 1885c6c1daeSBarry Smith .seealso: PetscViewerDrawGetDraw(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen() 1895c6c1daeSBarry Smith @*/ 1905c6c1daeSBarry Smith PetscErrorCode PetscViewerDrawGetDrawLG(PetscViewer viewer,PetscInt windownumber,PetscDrawLG *drawlg) 1915c6c1daeSBarry Smith { 1925c6c1daeSBarry Smith PetscErrorCode ierr; 1935c6c1daeSBarry Smith PetscBool isdraw; 194e5ab1681SLisandro Dalcin PetscViewer_Draw *vdraw; 1955c6c1daeSBarry Smith 1965c6c1daeSBarry Smith PetscFunctionBegin; 1975c6c1daeSBarry Smith PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); 198e5ab1681SLisandro Dalcin PetscValidLogicalCollectiveInt(viewer,windownumber,2); 1995c6c1daeSBarry Smith PetscValidPointer(drawlg,3); 2005c6c1daeSBarry Smith ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); 2015c6c1daeSBarry Smith if (!isdraw) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer"); 2025c6c1daeSBarry Smith if (windownumber < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Window number cannot be negative"); 203e5ab1681SLisandro Dalcin vdraw = (PetscViewer_Draw*)viewer->data; 2045c6c1daeSBarry Smith 2055c6c1daeSBarry Smith if (windownumber+vdraw->draw_base >= vdraw->draw_max || !vdraw->draw[windownumber+vdraw->draw_base]) { 2060298fd71SBarry Smith ierr = PetscViewerDrawGetDraw(viewer,windownumber,NULL);CHKERRQ(ierr); 2075c6c1daeSBarry Smith } 2085c6c1daeSBarry Smith if (!vdraw->drawlg[windownumber+vdraw->draw_base]) { 2095c6c1daeSBarry Smith ierr = PetscDrawLGCreate(vdraw->draw[windownumber+vdraw->draw_base],1,&vdraw->drawlg[windownumber+vdraw->draw_base]);CHKERRQ(ierr); 2103bb1ff40SBarry Smith ierr = PetscLogObjectParent((PetscObject)viewer,(PetscObject)vdraw->drawlg[windownumber+vdraw->draw_base]);CHKERRQ(ierr); 211de1a4edeSLisandro Dalcin ierr = PetscDrawLGSetFromOptions(vdraw->drawlg[windownumber+vdraw->draw_base]);CHKERRQ(ierr); 2125c6c1daeSBarry Smith } 2135c6c1daeSBarry Smith *drawlg = vdraw->drawlg[windownumber+vdraw->draw_base]; 2145c6c1daeSBarry Smith PetscFunctionReturn(0); 2155c6c1daeSBarry Smith } 2165c6c1daeSBarry Smith 2175c6c1daeSBarry Smith /*@C 2185c6c1daeSBarry Smith PetscViewerDrawGetDrawAxis - Returns PetscDrawAxis object from PetscViewer object. 2195c6c1daeSBarry Smith This PetscDrawAxis object may then be used to perform graphics using 2205c6c1daeSBarry Smith PetscDrawAxisXXX() commands. 2215c6c1daeSBarry Smith 222d94959e9SLisandro Dalcin Collective on PetscViewer 2235c6c1daeSBarry Smith 224*d8d19677SJose E. Roman Input Parameters: 2255c6c1daeSBarry Smith + viewer - the PetscViewer (created with PetscViewerDrawOpen() 2265c6c1daeSBarry Smith - windownumber - indicates which subwindow (usually 0) 2275c6c1daeSBarry Smith 22801d2d390SJose E. Roman Output Parameter: 2295c6c1daeSBarry Smith . drawaxis - the draw axis object 2305c6c1daeSBarry Smith 2315c6c1daeSBarry Smith Level: advanced 2325c6c1daeSBarry Smith 2335c6c1daeSBarry Smith .seealso: PetscViewerDrawGetDraw(), PetscViewerDrawGetLG(), PetscViewerDrawOpen() 2345c6c1daeSBarry Smith @*/ 2355c6c1daeSBarry Smith PetscErrorCode PetscViewerDrawGetDrawAxis(PetscViewer viewer,PetscInt windownumber,PetscDrawAxis *drawaxis) 2365c6c1daeSBarry Smith { 2375c6c1daeSBarry Smith PetscErrorCode ierr; 2385c6c1daeSBarry Smith PetscBool isdraw; 239e5ab1681SLisandro Dalcin PetscViewer_Draw *vdraw; 2405c6c1daeSBarry Smith 2415c6c1daeSBarry Smith PetscFunctionBegin; 2425c6c1daeSBarry Smith PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); 243e5ab1681SLisandro Dalcin PetscValidLogicalCollectiveInt(viewer,windownumber,2); 2445c6c1daeSBarry Smith PetscValidPointer(drawaxis,3); 2455c6c1daeSBarry Smith ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); 2465c6c1daeSBarry Smith if (!isdraw) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer"); 2475c6c1daeSBarry Smith if (windownumber < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Window number cannot be negative"); 248e5ab1681SLisandro Dalcin vdraw = (PetscViewer_Draw*)viewer->data; 2495c6c1daeSBarry Smith 2505c6c1daeSBarry Smith if (windownumber+vdraw->draw_base >= vdraw->draw_max || !vdraw->draw[windownumber+vdraw->draw_base]) { 2510298fd71SBarry Smith ierr = PetscViewerDrawGetDraw(viewer,windownumber,NULL);CHKERRQ(ierr); 2525c6c1daeSBarry Smith } 2535c6c1daeSBarry Smith if (!vdraw->drawaxis[windownumber+vdraw->draw_base]) { 2545c6c1daeSBarry Smith ierr = PetscDrawAxisCreate(vdraw->draw[windownumber+vdraw->draw_base],&vdraw->drawaxis[windownumber+vdraw->draw_base]);CHKERRQ(ierr); 2553bb1ff40SBarry Smith ierr = PetscLogObjectParent((PetscObject)viewer,(PetscObject)vdraw->drawaxis[windownumber+vdraw->draw_base]);CHKERRQ(ierr); 2565c6c1daeSBarry Smith } 2575c6c1daeSBarry Smith *drawaxis = vdraw->drawaxis[windownumber+vdraw->draw_base]; 2585c6c1daeSBarry Smith PetscFunctionReturn(0); 2595c6c1daeSBarry Smith } 2605c6c1daeSBarry Smith 2615c6c1daeSBarry Smith PetscErrorCode PetscViewerDrawResize(PetscViewer v,int w,int h) 2625c6c1daeSBarry Smith { 263e5ab1681SLisandro Dalcin PetscErrorCode ierr; 264e5ab1681SLisandro Dalcin PetscViewer_Draw *vdraw; 265e5ab1681SLisandro Dalcin PetscBool isdraw; 2665c6c1daeSBarry Smith 2675c6c1daeSBarry Smith PetscFunctionBegin; 268e5ab1681SLisandro Dalcin PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1); 269e5ab1681SLisandro Dalcin ierr = PetscObjectTypeCompare((PetscObject)v,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); 270e5ab1681SLisandro Dalcin if (!isdraw) PetscFunctionReturn(0); 271e5ab1681SLisandro Dalcin vdraw = (PetscViewer_Draw*)v->data; 272e5ab1681SLisandro Dalcin 273e5ab1681SLisandro Dalcin if (w >= 1) vdraw->w = w; 274e5ab1681SLisandro Dalcin if (h >= 1) vdraw->h = h; 2755c6c1daeSBarry Smith PetscFunctionReturn(0); 2765c6c1daeSBarry Smith } 2775c6c1daeSBarry Smith 2785c6c1daeSBarry Smith PetscErrorCode PetscViewerDrawSetInfo(PetscViewer v,const char display[],const char title[],int x,int y,int w,int h) 2795c6c1daeSBarry Smith { 2805c6c1daeSBarry Smith PetscErrorCode ierr; 281e5ab1681SLisandro Dalcin PetscViewer_Draw *vdraw; 282e5ab1681SLisandro Dalcin PetscBool isdraw; 2835c6c1daeSBarry Smith 2845c6c1daeSBarry Smith PetscFunctionBegin; 285e5ab1681SLisandro Dalcin PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1); 286e5ab1681SLisandro Dalcin ierr = PetscObjectTypeCompare((PetscObject)v,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); 287e5ab1681SLisandro Dalcin if (!isdraw) PetscFunctionReturn(0); 288e5ab1681SLisandro Dalcin vdraw = (PetscViewer_Draw*)v->data; 289e5ab1681SLisandro Dalcin 2905c6c1daeSBarry Smith ierr = PetscStrallocpy(display,&vdraw->display);CHKERRQ(ierr); 2915c6c1daeSBarry Smith ierr = PetscStrallocpy(title,&vdraw->title);CHKERRQ(ierr); 292e5ab1681SLisandro Dalcin if (w >= 1) vdraw->w = w; 293e5ab1681SLisandro Dalcin if (h >= 1) vdraw->h = h; 2945c6c1daeSBarry Smith PetscFunctionReturn(0); 2955c6c1daeSBarry Smith } 2965c6c1daeSBarry Smith 297d1da0b69SBarry Smith PetscErrorCode PetscViewerDrawSetDrawType(PetscViewer v,PetscDrawType drawtype) 298d1da0b69SBarry Smith { 299d1da0b69SBarry Smith PetscErrorCode ierr; 300e5ab1681SLisandro Dalcin PetscViewer_Draw *vdraw; 301e5ab1681SLisandro Dalcin PetscBool isdraw; 302d1da0b69SBarry Smith 303d1da0b69SBarry Smith PetscFunctionBegin; 304e5ab1681SLisandro Dalcin PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1); 305e5ab1681SLisandro Dalcin ierr = PetscObjectTypeCompare((PetscObject)v,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); 306e5ab1681SLisandro Dalcin if (!isdraw) PetscFunctionReturn(0); 307e5ab1681SLisandro Dalcin vdraw = (PetscViewer_Draw*)v->data; 308e5ab1681SLisandro Dalcin 309d1da0b69SBarry Smith ierr = PetscFree(vdraw->drawtype);CHKERRQ(ierr); 310d1da0b69SBarry Smith ierr = PetscStrallocpy(drawtype,(char**)&vdraw->drawtype);CHKERRQ(ierr); 311d1da0b69SBarry Smith PetscFunctionReturn(0); 312d1da0b69SBarry Smith } 313d1da0b69SBarry Smith 3141f49e1f7SLisandro Dalcin PetscErrorCode PetscViewerDrawGetDrawType(PetscViewer v,PetscDrawType *drawtype) 3151f49e1f7SLisandro Dalcin { 3161f49e1f7SLisandro Dalcin PetscErrorCode ierr; 3171f49e1f7SLisandro Dalcin PetscViewer_Draw *vdraw; 3181f49e1f7SLisandro Dalcin PetscBool isdraw; 3191f49e1f7SLisandro Dalcin 3201f49e1f7SLisandro Dalcin PetscFunctionBegin; 3211f49e1f7SLisandro Dalcin PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1); 3221f49e1f7SLisandro Dalcin ierr = PetscObjectTypeCompare((PetscObject)v,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); 3231f49e1f7SLisandro Dalcin if (!isdraw) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer"); 3241f49e1f7SLisandro Dalcin vdraw = (PetscViewer_Draw*)v->data; 3251f49e1f7SLisandro Dalcin 3261f49e1f7SLisandro Dalcin *drawtype = vdraw->drawtype; 3271f49e1f7SLisandro Dalcin PetscFunctionReturn(0); 3281f49e1f7SLisandro Dalcin } 3291f49e1f7SLisandro Dalcin 330f55236e4SLisandro Dalcin PetscErrorCode PetscViewerDrawSetTitle(PetscViewer v,const char title[]) 331f55236e4SLisandro Dalcin { 332f55236e4SLisandro Dalcin PetscErrorCode ierr; 333f55236e4SLisandro Dalcin PetscViewer_Draw *vdraw; 334f55236e4SLisandro Dalcin PetscBool isdraw; 335f55236e4SLisandro Dalcin 336f55236e4SLisandro Dalcin PetscFunctionBegin; 337f55236e4SLisandro Dalcin PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1); 338f55236e4SLisandro Dalcin ierr = PetscObjectTypeCompare((PetscObject)v,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); 339f55236e4SLisandro Dalcin if (!isdraw) PetscFunctionReturn(0); 340f55236e4SLisandro Dalcin vdraw = (PetscViewer_Draw*)v->data; 341f55236e4SLisandro Dalcin 342f55236e4SLisandro Dalcin ierr = PetscFree(vdraw->title);CHKERRQ(ierr); 343f55236e4SLisandro Dalcin ierr = PetscStrallocpy(title,&vdraw->title);CHKERRQ(ierr); 344f55236e4SLisandro Dalcin PetscFunctionReturn(0); 345f55236e4SLisandro Dalcin } 346f55236e4SLisandro Dalcin 347f55236e4SLisandro Dalcin PetscErrorCode PetscViewerDrawGetTitle(PetscViewer v,const char *title[]) 348f55236e4SLisandro Dalcin { 349f55236e4SLisandro Dalcin PetscErrorCode ierr; 350f55236e4SLisandro Dalcin PetscViewer_Draw *vdraw; 351f55236e4SLisandro Dalcin PetscBool isdraw; 352f55236e4SLisandro Dalcin 353f55236e4SLisandro Dalcin PetscFunctionBegin; 354f55236e4SLisandro Dalcin PetscValidHeaderSpecific(v,PETSC_VIEWER_CLASSID,1); 355f55236e4SLisandro Dalcin ierr = PetscObjectTypeCompare((PetscObject)v,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); 356f55236e4SLisandro Dalcin if (!isdraw) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Must be draw type PetscViewer"); 357f55236e4SLisandro Dalcin vdraw = (PetscViewer_Draw*)v->data; 358f55236e4SLisandro Dalcin 359f55236e4SLisandro Dalcin *title = vdraw->title; 360f55236e4SLisandro Dalcin PetscFunctionReturn(0); 361f55236e4SLisandro Dalcin } 362f55236e4SLisandro Dalcin 3635c6c1daeSBarry Smith /*@C 3645c6c1daeSBarry Smith PetscViewerDrawOpen - Opens a window for use as a PetscViewer. If you want to 3655c6c1daeSBarry Smith do graphics in this window, you must call PetscViewerDrawGetDraw() and 3665c6c1daeSBarry Smith perform the graphics on the PetscDraw object. 3675c6c1daeSBarry Smith 368d083f849SBarry Smith Collective 3695c6c1daeSBarry Smith 3705c6c1daeSBarry Smith Input Parameters: 3715c6c1daeSBarry Smith + comm - communicator that will share window 3725c6c1daeSBarry Smith . display - the X display on which to open, or null for the local machine 3735c6c1daeSBarry Smith . title - the title to put in the title bar, or null for no title 3745c6c1daeSBarry Smith . x, y - the screen coordinates of the upper left corner of window, or use PETSC_DECIDE 3755c6c1daeSBarry Smith - w, h - window width and height in pixels, or may use PETSC_DECIDE or PETSC_DRAW_FULL_SIZE, PETSC_DRAW_HALF_SIZE, 3765c6c1daeSBarry Smith PETSC_DRAW_THIRD_SIZE, PETSC_DRAW_QUARTER_SIZE 3775c6c1daeSBarry Smith 3785c6c1daeSBarry Smith Output Parameters: 3795c6c1daeSBarry Smith . viewer - the PetscViewer 3805c6c1daeSBarry Smith 3815c6c1daeSBarry Smith Format Options: 3825c6c1daeSBarry Smith + PETSC_VIEWER_DRAW_BASIC - displays with basic format 3835c6c1daeSBarry Smith - PETSC_VIEWER_DRAW_LG - displays using a line graph 3845c6c1daeSBarry Smith 3855c6c1daeSBarry Smith Options Database Keys: 38610699b91SBarry Smith + -draw_type - use x or null 3875c6c1daeSBarry Smith . -nox - Disables all x-windows output 3885c6c1daeSBarry Smith . -display <name> - Specifies name of machine for the X display 3895c6c1daeSBarry Smith . -geometry <x,y,w,h> - allows setting the window location and size 3905c6c1daeSBarry Smith - -draw_pause <pause> - Sets time (in seconds) that the 3915c6c1daeSBarry Smith program pauses after PetscDrawPause() has been called 3925c6c1daeSBarry Smith (0 is default, -1 implies until user input). 3935c6c1daeSBarry Smith 3945c6c1daeSBarry Smith Level: beginner 3955c6c1daeSBarry Smith 39610699b91SBarry Smith Notes: 39710699b91SBarry Smith PetscViewerDrawOpen() calls PetscDrawCreate(), so see the manual pages for PetscDrawCreate() 39810699b91SBarry Smith 3995c6c1daeSBarry Smith Note for Fortran Programmers: 4005c6c1daeSBarry Smith Whenever indicating null character data in a Fortran code, 401cf90aa19SBarry Smith PETSC_NULL_CHARACTER must be employed; using NULL is not 402cf90aa19SBarry Smith correct for character data! Thus, PETSC_NULL_CHARACTER can be 4035c6c1daeSBarry Smith used for the display and title input parameters. 4045c6c1daeSBarry Smith 4055c6c1daeSBarry Smith .seealso: PetscDrawCreate(), PetscViewerDestroy(), PetscViewerDrawGetDraw(), PetscViewerCreate(), PETSC_VIEWER_DRAW_, 4065c6c1daeSBarry Smith PETSC_VIEWER_DRAW_WORLD, PETSC_VIEWER_DRAW_SELF 4075c6c1daeSBarry Smith @*/ 4085c6c1daeSBarry Smith PetscErrorCode PetscViewerDrawOpen(MPI_Comm comm,const char display[],const char title[],int x,int y,int w,int h,PetscViewer *viewer) 4095c6c1daeSBarry Smith { 4105c6c1daeSBarry Smith PetscErrorCode ierr; 4115c6c1daeSBarry Smith 4125c6c1daeSBarry Smith PetscFunctionBegin; 4135c6c1daeSBarry Smith ierr = PetscViewerCreate(comm,viewer);CHKERRQ(ierr); 4145c6c1daeSBarry Smith ierr = PetscViewerSetType(*viewer,PETSCVIEWERDRAW);CHKERRQ(ierr); 4155c6c1daeSBarry Smith ierr = PetscViewerDrawSetInfo(*viewer,display,title,x,y,w,h);CHKERRQ(ierr); 4165c6c1daeSBarry Smith PetscFunctionReturn(0); 4175c6c1daeSBarry Smith } 4185c6c1daeSBarry Smith 419a9db196aSBarry Smith #include <petsc/private/drawimpl.h> 420a9db196aSBarry Smith 4213f08860eSBarry Smith PetscErrorCode PetscViewerGetSubViewer_Draw(PetscViewer viewer,MPI_Comm comm,PetscViewer *sviewer) 4225c6c1daeSBarry Smith { 4235c6c1daeSBarry Smith PetscErrorCode ierr; 4245c6c1daeSBarry Smith PetscMPIInt rank; 4255c6c1daeSBarry Smith PetscInt i; 426c6228bbaSLisandro Dalcin PetscViewer_Draw *vdraw = (PetscViewer_Draw*)viewer->data,*svdraw; 4275c6c1daeSBarry Smith 4285c6c1daeSBarry Smith PetscFunctionBegin; 4293f08860eSBarry Smith if (vdraw->singleton_made) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ORDER,"Trying to get SubViewer without first restoring previous"); 4305c6c1daeSBarry Smith /* only processor zero can use the PetscViewer draw singleton */ 431fefe69c3SStefano Zampini if (sviewer) *sviewer = NULL; 432ffc4695bSBarry Smith ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)viewer),&rank);CHKERRMPI(ierr); 4335c6c1daeSBarry Smith if (!rank) { 434e5afcf28SBarry Smith PetscMPIInt flg; 435a9db196aSBarry Smith PetscDraw draw,sdraw; 436e5afcf28SBarry Smith 437ffc4695bSBarry Smith ierr = MPI_Comm_compare(PETSC_COMM_SELF,comm,&flg);CHKERRMPI(ierr); 438e5afcf28SBarry Smith if (flg != MPI_IDENT && flg != MPI_CONGRUENT) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"PetscViewerGetSubViewer() for PETSCVIEWERDRAW requires a singleton MPI_Comm"); 439e5afcf28SBarry Smith ierr = PetscViewerCreate(comm,sviewer);CHKERRQ(ierr); 4405c6c1daeSBarry Smith ierr = PetscViewerSetType(*sviewer,PETSCVIEWERDRAW);CHKERRQ(ierr); 441c6228bbaSLisandro Dalcin svdraw = (PetscViewer_Draw*)(*sviewer)->data; 442c6228bbaSLisandro Dalcin (*sviewer)->format = viewer->format; 443c6228bbaSLisandro Dalcin for (i=0; i<vdraw->draw_max; i++) { /* XXX this is wrong if svdraw->draw_max (initially 5) < vdraw->draw_max */ 444c6228bbaSLisandro Dalcin if (vdraw->draw[i]) {ierr = PetscDrawGetSingleton(vdraw->draw[i],&svdraw->draw[i]);CHKERRQ(ierr);} 4455c6c1daeSBarry Smith } 446a9db196aSBarry Smith ierr = PetscViewerDrawGetDraw(viewer,0,&draw);CHKERRQ(ierr); 447a9db196aSBarry Smith ierr = PetscViewerDrawGetDraw(*sviewer,0,&sdraw);CHKERRQ(ierr); 448a9db196aSBarry Smith if (draw->savefilename) { 449a9db196aSBarry Smith ierr = PetscDrawSetSave(sdraw,draw->savefilename);CHKERRQ(ierr); 450a9db196aSBarry Smith sdraw->savefilecount = draw->savefilecount; 451a9db196aSBarry Smith sdraw->savesinglefile = draw->savesinglefile; 452a9db196aSBarry Smith sdraw->savemoviefps = draw->savemoviefps; 453a9db196aSBarry Smith sdraw->saveonclear = draw->saveonclear; 454a9db196aSBarry Smith sdraw->saveonflush = draw->saveonflush; 455a9db196aSBarry Smith } 456a9db196aSBarry Smith if (draw->savefinalfilename) {ierr = PetscDrawSetSaveFinalImage(sdraw,draw->savefinalfilename);CHKERRQ(ierr);} 457a9db196aSBarry Smith } else { 458a9db196aSBarry Smith PetscDraw draw; 459a9db196aSBarry Smith ierr = PetscViewerDrawGetDraw(viewer,0,&draw);CHKERRQ(ierr); 4605c6c1daeSBarry Smith } 4615c6c1daeSBarry Smith vdraw->singleton_made = PETSC_TRUE; 4625c6c1daeSBarry Smith PetscFunctionReturn(0); 4635c6c1daeSBarry Smith } 4645c6c1daeSBarry Smith 4653f08860eSBarry Smith PetscErrorCode PetscViewerRestoreSubViewer_Draw(PetscViewer viewer,MPI_Comm comm,PetscViewer *sviewer) 4665c6c1daeSBarry Smith { 4675c6c1daeSBarry Smith PetscErrorCode ierr; 4685c6c1daeSBarry Smith PetscMPIInt rank; 4695c6c1daeSBarry Smith PetscInt i; 470c6228bbaSLisandro Dalcin PetscViewer_Draw *vdraw = (PetscViewer_Draw*)viewer->data,*svdraw; 4715c6c1daeSBarry Smith 4725c6c1daeSBarry Smith PetscFunctionBegin; 4735c6c1daeSBarry Smith if (!vdraw->singleton_made) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ORDER,"Trying to restore a singleton that was not gotten"); 474ffc4695bSBarry Smith ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)viewer),&rank);CHKERRMPI(ierr); 4755c6c1daeSBarry Smith if (!rank) { 476a9db196aSBarry Smith PetscDraw draw,sdraw; 477a9db196aSBarry Smith 478a9db196aSBarry Smith ierr = PetscViewerDrawGetDraw(viewer,0,&draw);CHKERRQ(ierr); 479a9db196aSBarry Smith ierr = PetscViewerDrawGetDraw(*sviewer,0,&sdraw);CHKERRQ(ierr); 480a9db196aSBarry Smith if (draw->savefilename) { 481a9db196aSBarry Smith draw->savefilecount = sdraw->savefilecount; 48255b25c41SPierre Jolivet ierr = MPI_Bcast(&draw->savefilecount,1,MPIU_INT,0,PetscObjectComm((PetscObject)draw));CHKERRMPI(ierr); 483a9db196aSBarry Smith } 484c6228bbaSLisandro Dalcin svdraw = (PetscViewer_Draw*)(*sviewer)->data; 4855c6c1daeSBarry Smith for (i=0; i<vdraw->draw_max; i++) { 486c6228bbaSLisandro Dalcin if (vdraw->draw[i] && svdraw->draw[i]) { 487c6228bbaSLisandro Dalcin ierr = PetscDrawRestoreSingleton(vdraw->draw[i],&svdraw->draw[i]);CHKERRQ(ierr); 4885c6c1daeSBarry Smith } 4895c6c1daeSBarry Smith } 490c6228bbaSLisandro Dalcin ierr = PetscFree3(svdraw->draw,svdraw->drawlg,svdraw->drawaxis);CHKERRQ(ierr); 4915c6c1daeSBarry Smith ierr = PetscFree((*sviewer)->data);CHKERRQ(ierr); 4925c6c1daeSBarry Smith ierr = PetscHeaderDestroy(sviewer);CHKERRQ(ierr); 493a9db196aSBarry Smith } else { 494a9db196aSBarry Smith PetscDraw draw; 495a9db196aSBarry Smith 496a9db196aSBarry Smith ierr = PetscViewerDrawGetDraw(viewer,0,&draw);CHKERRQ(ierr); 497a9db196aSBarry Smith if (draw->savefilename) { 49855b25c41SPierre Jolivet ierr = MPI_Bcast(&draw->savefilecount,1,MPIU_INT,0,PetscObjectComm((PetscObject)draw));CHKERRMPI(ierr); 4995c6c1daeSBarry Smith } 500a9db196aSBarry Smith } 501a9db196aSBarry Smith 5025c6c1daeSBarry Smith vdraw->singleton_made = PETSC_FALSE; 5035c6c1daeSBarry Smith PetscFunctionReturn(0); 5045c6c1daeSBarry Smith } 5055c6c1daeSBarry Smith 5064416b707SBarry Smith PetscErrorCode PetscViewerSetFromOptions_Draw(PetscOptionItems *PetscOptionsObject,PetscViewer v) 507e9457bf7SBarry Smith { 508e9457bf7SBarry Smith PetscErrorCode ierr; 509e9457bf7SBarry Smith PetscReal bounds[16]; 510e9457bf7SBarry Smith PetscInt nbounds = 16; 511e9457bf7SBarry Smith PetscBool flg; 512e9457bf7SBarry Smith 513e9457bf7SBarry Smith PetscFunctionBegin; 514e55864a3SBarry Smith ierr = PetscOptionsHead(PetscOptionsObject,"Draw PetscViewer Options");CHKERRQ(ierr); 515e9457bf7SBarry Smith ierr = PetscOptionsRealArray("-draw_bounds","Bounds to put on plots axis","PetscViewerDrawSetBounds",bounds,&nbounds,&flg);CHKERRQ(ierr); 516e9457bf7SBarry Smith if (flg) { 517e9457bf7SBarry Smith ierr = PetscViewerDrawSetBounds(v,nbounds/2,bounds);CHKERRQ(ierr); 518e9457bf7SBarry Smith } 519e9457bf7SBarry Smith ierr = PetscOptionsTail();CHKERRQ(ierr); 520e9457bf7SBarry Smith PetscFunctionReturn(0); 521e9457bf7SBarry Smith } 522e9457bf7SBarry Smith 5230076e027SBarry Smith PetscErrorCode PetscViewerView_Draw(PetscViewer viewer,PetscViewer v) 5240076e027SBarry Smith { 5250076e027SBarry Smith PetscErrorCode ierr; 5260076e027SBarry Smith PetscDraw draw; 5270076e027SBarry Smith PetscInt i; 5280076e027SBarry Smith PetscViewer_Draw *vdraw = (PetscViewer_Draw*)viewer->data; 5290076e027SBarry Smith 5300076e027SBarry Smith PetscFunctionBegin; 5310076e027SBarry Smith /* If the PetscViewer has just been created then no vdraw->draw yet 5320076e027SBarry Smith exists so this will not actually call the viewer on any draws. */ 5330076e027SBarry Smith for (i=0; i<vdraw->draw_base; i++) { 5340076e027SBarry Smith if (vdraw->draw[i]) { 5350076e027SBarry Smith ierr = PetscViewerDrawGetDraw(viewer,i,&draw);CHKERRQ(ierr); 5360076e027SBarry Smith ierr = PetscDrawView(draw,v);CHKERRQ(ierr); 5370076e027SBarry Smith } 5380076e027SBarry Smith } 5390076e027SBarry Smith PetscFunctionReturn(0); 5400076e027SBarry Smith } 5410076e027SBarry Smith 5428556b5ebSBarry Smith /*MC 5438556b5ebSBarry Smith PETSCVIEWERDRAW - A viewer that generates graphics, either to the screen or a file 5448556b5ebSBarry Smith 5458556b5ebSBarry Smith .seealso: PetscViewerDrawOpen(), PetscViewerDrawGetDraw(), PETSC_VIEWER_DRAW_(),PETSC_VIEWER_DRAW_SELF, PETSC_VIEWER_DRAW_WORLD, 5468556b5ebSBarry Smith PetscViewerCreate(), PetscViewerASCIIOpen(), PetscViewerBinaryOpen(), PETSCVIEWERBINARY, 5478556b5ebSBarry Smith PetscViewerMatlabOpen(), VecView(), DMView(), PetscViewerMatlabPutArray(), PETSCVIEWERASCII, PETSCVIEWERMATLAB, 5488556b5ebSBarry Smith PetscViewerFileSetName(), PetscViewerFileSetMode(), PetscViewerFormat, PetscViewerType, PetscViewerSetType() 5498556b5ebSBarry Smith 5501b266c99SBarry Smith Level: beginner 5511b266c99SBarry Smith 5528556b5ebSBarry Smith M*/ 5538cc058d9SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerCreate_Draw(PetscViewer viewer) 5545c6c1daeSBarry Smith { 5555c6c1daeSBarry Smith PetscErrorCode ierr; 5565c6c1daeSBarry Smith PetscViewer_Draw *vdraw; 5575c6c1daeSBarry Smith 5585c6c1daeSBarry Smith PetscFunctionBegin; 559b00a9115SJed Brown ierr = PetscNewLog(viewer,&vdraw);CHKERRQ(ierr); 5605c6c1daeSBarry Smith viewer->data = (void*)vdraw; 5615c6c1daeSBarry Smith 5625c6c1daeSBarry Smith viewer->ops->flush = PetscViewerFlush_Draw; 5630076e027SBarry Smith viewer->ops->view = PetscViewerView_Draw; 5645c6c1daeSBarry Smith viewer->ops->destroy = PetscViewerDestroy_Draw; 565e9457bf7SBarry Smith viewer->ops->setfromoptions = PetscViewerSetFromOptions_Draw; 566559f443fSBarry Smith viewer->ops->getsubviewer = PetscViewerGetSubViewer_Draw; 567559f443fSBarry Smith viewer->ops->restoresubviewer = PetscViewerRestoreSubViewer_Draw; 5685c6c1daeSBarry Smith 5695c6c1daeSBarry Smith /* these are created on the fly if requested */ 5705c6c1daeSBarry Smith vdraw->draw_max = 5; 5715c6c1daeSBarry Smith vdraw->draw_base = 0; 572ccad63c3SBarry Smith vdraw->w = PETSC_DECIDE; 573ccad63c3SBarry Smith vdraw->h = PETSC_DECIDE; 574a297a907SKarl Rupp 5751795a4d1SJed Brown ierr = PetscCalloc3(vdraw->draw_max,&vdraw->draw,vdraw->draw_max,&vdraw->drawlg,vdraw->draw_max,&vdraw->drawaxis);CHKERRQ(ierr); 5765c6c1daeSBarry Smith vdraw->singleton_made = PETSC_FALSE; 5775c6c1daeSBarry Smith PetscFunctionReturn(0); 5785c6c1daeSBarry Smith } 5795c6c1daeSBarry Smith 5805c6c1daeSBarry Smith /*@ 5815c6c1daeSBarry Smith PetscViewerDrawClear - Clears a PetscDraw graphic associated with a PetscViewer. 5825c6c1daeSBarry Smith 5835c6c1daeSBarry Smith Not Collective 5845c6c1daeSBarry Smith 5855c6c1daeSBarry Smith Input Parameter: 5865c6c1daeSBarry Smith . viewer - the PetscViewer 5875c6c1daeSBarry Smith 5885c6c1daeSBarry Smith Level: intermediate 5895c6c1daeSBarry Smith 5905c6c1daeSBarry Smith .seealso: PetscViewerDrawOpen(), PetscViewerDrawGetDraw(), 5915c6c1daeSBarry Smith 5925c6c1daeSBarry Smith @*/ 5935c6c1daeSBarry Smith PetscErrorCode PetscViewerDrawClear(PetscViewer viewer) 5945c6c1daeSBarry Smith { 5955c6c1daeSBarry Smith PetscErrorCode ierr; 5965c6c1daeSBarry Smith PetscViewer_Draw *vdraw; 597e5ab1681SLisandro Dalcin PetscBool isdraw; 598e5ab1681SLisandro Dalcin PetscInt i; 5995c6c1daeSBarry Smith 6005c6c1daeSBarry Smith PetscFunctionBegin; 601e5ab1681SLisandro Dalcin PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); 6025c6c1daeSBarry Smith ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); 603e5ab1681SLisandro Dalcin if (!isdraw) PetscFunctionReturn(0); 6045c6c1daeSBarry Smith vdraw = (PetscViewer_Draw*)viewer->data; 605e5ab1681SLisandro Dalcin 6065c6c1daeSBarry Smith for (i=0; i<vdraw->draw_max; i++) { 6075c6c1daeSBarry Smith if (vdraw->draw[i]) {ierr = PetscDrawClear(vdraw->draw[i]);CHKERRQ(ierr);} 6085c6c1daeSBarry Smith } 6095c6c1daeSBarry Smith PetscFunctionReturn(0); 6105c6c1daeSBarry Smith } 6115c6c1daeSBarry Smith 6125c6c1daeSBarry Smith /*@ 6135c6c1daeSBarry Smith PetscViewerDrawGetPause - Gets a pause for the first present draw 6145c6c1daeSBarry Smith 6155c6c1daeSBarry Smith Not Collective 6165c6c1daeSBarry Smith 6175c6c1daeSBarry Smith Input Parameter: 6185c6c1daeSBarry Smith . viewer - the PetscViewer 6195c6c1daeSBarry Smith 6205c6c1daeSBarry Smith Output Parameter: 6215c6c1daeSBarry Smith . pause - the pause value 6225c6c1daeSBarry Smith 6235c6c1daeSBarry Smith Level: intermediate 6245c6c1daeSBarry Smith 6255c6c1daeSBarry Smith .seealso: PetscViewerDrawOpen(), PetscViewerDrawGetDraw(), 6265c6c1daeSBarry Smith 6275c6c1daeSBarry Smith @*/ 6285c6c1daeSBarry Smith PetscErrorCode PetscViewerDrawGetPause(PetscViewer viewer,PetscReal *pause) 6295c6c1daeSBarry Smith { 6305c6c1daeSBarry Smith PetscErrorCode ierr; 6315c6c1daeSBarry Smith PetscViewer_Draw *vdraw; 632e5ab1681SLisandro Dalcin PetscBool isdraw; 633e5ab1681SLisandro Dalcin PetscInt i; 6345c6c1daeSBarry Smith PetscDraw draw; 6355c6c1daeSBarry Smith 6365c6c1daeSBarry Smith PetscFunctionBegin; 637e5ab1681SLisandro Dalcin PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); 6385c6c1daeSBarry Smith ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); 639e5ab1681SLisandro Dalcin if (!isdraw) {*pause = 0.0; PetscFunctionReturn(0);} 6405c6c1daeSBarry Smith vdraw = (PetscViewer_Draw*)viewer->data; 641e5ab1681SLisandro Dalcin 6425c6c1daeSBarry Smith for (i=0; i<vdraw->draw_max; i++) { 6435c6c1daeSBarry Smith if (vdraw->draw[i]) { 6445c6c1daeSBarry Smith ierr = PetscDrawGetPause(vdraw->draw[i],pause);CHKERRQ(ierr); 6455c6c1daeSBarry Smith PetscFunctionReturn(0); 6465c6c1daeSBarry Smith } 6475c6c1daeSBarry Smith } 6485c6c1daeSBarry Smith /* none exist yet so create one and get its pause */ 6495c6c1daeSBarry Smith ierr = PetscViewerDrawGetDraw(viewer,0,&draw);CHKERRQ(ierr); 650e5ab1681SLisandro Dalcin ierr = PetscDrawGetPause(draw,pause);CHKERRQ(ierr); 6515c6c1daeSBarry Smith PetscFunctionReturn(0); 6525c6c1daeSBarry Smith } 6535c6c1daeSBarry Smith 6545c6c1daeSBarry Smith /*@ 6555c6c1daeSBarry Smith PetscViewerDrawSetPause - Sets a pause for each PetscDraw in the viewer 6565c6c1daeSBarry Smith 6575c6c1daeSBarry Smith Not Collective 6585c6c1daeSBarry Smith 6595c6c1daeSBarry Smith Input Parameters: 6605c6c1daeSBarry Smith + viewer - the PetscViewer 6615c6c1daeSBarry Smith - pause - the pause value 6625c6c1daeSBarry Smith 6635c6c1daeSBarry Smith Level: intermediate 6645c6c1daeSBarry Smith 6655c6c1daeSBarry Smith .seealso: PetscViewerDrawOpen(), PetscViewerDrawGetDraw(), 6665c6c1daeSBarry Smith 6675c6c1daeSBarry Smith @*/ 6685c6c1daeSBarry Smith PetscErrorCode PetscViewerDrawSetPause(PetscViewer viewer,PetscReal pause) 6695c6c1daeSBarry Smith { 6705c6c1daeSBarry Smith PetscErrorCode ierr; 671e5ab1681SLisandro Dalcin PetscViewer_Draw *vdraw; 6725c6c1daeSBarry Smith PetscBool isdraw; 673e5ab1681SLisandro Dalcin PetscInt i; 6745c6c1daeSBarry Smith 6755c6c1daeSBarry Smith PetscFunctionBegin; 676e5ab1681SLisandro Dalcin PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); 6775c6c1daeSBarry Smith ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); 678e5ab1681SLisandro Dalcin if (!isdraw) PetscFunctionReturn(0); 679e5ab1681SLisandro Dalcin vdraw = (PetscViewer_Draw*)viewer->data; 680afe78b3cSBarry Smith 681afe78b3cSBarry Smith vdraw->pause = pause; 6825c6c1daeSBarry Smith for (i=0; i<vdraw->draw_max; i++) { 6835c6c1daeSBarry Smith if (vdraw->draw[i]) {ierr = PetscDrawSetPause(vdraw->draw[i],pause);CHKERRQ(ierr);} 6845c6c1daeSBarry Smith } 6855c6c1daeSBarry Smith PetscFunctionReturn(0); 6865c6c1daeSBarry Smith } 6875c6c1daeSBarry Smith 6885c6c1daeSBarry Smith /*@ 6895c6c1daeSBarry Smith PetscViewerDrawSetHold - Holds previous image when drawing new image 6905c6c1daeSBarry Smith 6915c6c1daeSBarry Smith Not Collective 6925c6c1daeSBarry Smith 6935c6c1daeSBarry Smith Input Parameters: 6945c6c1daeSBarry Smith + viewer - the PetscViewer 6955c6c1daeSBarry Smith - hold - indicates to hold or not 6965c6c1daeSBarry Smith 6975c6c1daeSBarry Smith Level: intermediate 6985c6c1daeSBarry Smith 6995c6c1daeSBarry Smith .seealso: PetscViewerDrawOpen(), PetscViewerDrawGetDraw(), 7005c6c1daeSBarry Smith 7015c6c1daeSBarry Smith @*/ 7025c6c1daeSBarry Smith PetscErrorCode PetscViewerDrawSetHold(PetscViewer viewer,PetscBool hold) 7035c6c1daeSBarry Smith { 7045c6c1daeSBarry Smith PetscErrorCode ierr; 7055c6c1daeSBarry Smith PetscViewer_Draw *vdraw; 7065c6c1daeSBarry Smith PetscBool isdraw; 7075c6c1daeSBarry Smith 7085c6c1daeSBarry Smith PetscFunctionBegin; 709e5ab1681SLisandro Dalcin PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); 7105c6c1daeSBarry Smith ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); 711e5ab1681SLisandro Dalcin if (!isdraw) PetscFunctionReturn(0); 7125c6c1daeSBarry Smith vdraw = (PetscViewer_Draw*)viewer->data; 713e5ab1681SLisandro Dalcin 7145c6c1daeSBarry Smith vdraw->hold = hold; 7155c6c1daeSBarry Smith PetscFunctionReturn(0); 7165c6c1daeSBarry Smith } 7175c6c1daeSBarry Smith 7185c6c1daeSBarry Smith /*@ 719d97d059aSBarry Smith PetscViewerDrawGetHold - Checks if holds previous image when drawing new image 7205c6c1daeSBarry Smith 7215c6c1daeSBarry Smith Not Collective 7225c6c1daeSBarry Smith 7235c6c1daeSBarry Smith Input Parameter: 7245c6c1daeSBarry Smith . viewer - the PetscViewer 7255c6c1daeSBarry Smith 7265c6c1daeSBarry Smith Output Parameter: 7275c6c1daeSBarry Smith . hold - indicates to hold or not 7285c6c1daeSBarry Smith 7295c6c1daeSBarry Smith Level: intermediate 7305c6c1daeSBarry Smith 7315c6c1daeSBarry Smith .seealso: PetscViewerDrawOpen(), PetscViewerDrawGetDraw(), 7325c6c1daeSBarry Smith 7335c6c1daeSBarry Smith @*/ 7345c6c1daeSBarry Smith PetscErrorCode PetscViewerDrawGetHold(PetscViewer viewer,PetscBool *hold) 7355c6c1daeSBarry Smith { 7365c6c1daeSBarry Smith PetscErrorCode ierr; 7375c6c1daeSBarry Smith PetscViewer_Draw *vdraw; 7385c6c1daeSBarry Smith PetscBool isdraw; 7395c6c1daeSBarry Smith 7405c6c1daeSBarry Smith PetscFunctionBegin; 741e5ab1681SLisandro Dalcin PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); 7425c6c1daeSBarry Smith ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); 743e5ab1681SLisandro Dalcin if (!isdraw) {*hold = PETSC_FALSE; PetscFunctionReturn(0);} 7445c6c1daeSBarry Smith vdraw = (PetscViewer_Draw*)viewer->data; 745e5ab1681SLisandro Dalcin 7465c6c1daeSBarry Smith *hold = vdraw->hold; 7475c6c1daeSBarry Smith PetscFunctionReturn(0); 7485c6c1daeSBarry Smith } 7495c6c1daeSBarry Smith 7505c6c1daeSBarry Smith /* ---------------------------------------------------------------------*/ 7515c6c1daeSBarry Smith /* 7525c6c1daeSBarry Smith The variable Petsc_Viewer_Draw_keyval is used to indicate an MPI attribute that 7535c6c1daeSBarry Smith is attached to a communicator, in this case the attribute is a PetscViewer. 7545c6c1daeSBarry Smith */ 755d4c7638eSBarry Smith PetscMPIInt Petsc_Viewer_Draw_keyval = MPI_KEYVAL_INVALID; 7565c6c1daeSBarry Smith 7575c6c1daeSBarry Smith /*@C 7585c6c1daeSBarry Smith PETSC_VIEWER_DRAW_ - Creates a window PetscViewer shared by all processors 7595c6c1daeSBarry Smith in a communicator. 7605c6c1daeSBarry Smith 761d083f849SBarry Smith Collective 7625c6c1daeSBarry Smith 7635c6c1daeSBarry Smith Input Parameter: 7645c6c1daeSBarry Smith . comm - the MPI communicator to share the window PetscViewer 7655c6c1daeSBarry Smith 7665c6c1daeSBarry Smith Level: intermediate 7675c6c1daeSBarry Smith 7685c6c1daeSBarry Smith Notes: 7695c6c1daeSBarry Smith Unlike almost all other PETSc routines, PETSC_VIEWER_DRAW_ does not return 7705c6c1daeSBarry Smith an error code. The window is usually used in the form 7715c6c1daeSBarry Smith $ XXXView(XXX object,PETSC_VIEWER_DRAW_(comm)); 7725c6c1daeSBarry Smith 7735c6c1daeSBarry Smith .seealso: PETSC_VIEWER_DRAW_WORLD, PETSC_VIEWER_DRAW_SELF, PetscViewerDrawOpen(), 7745c6c1daeSBarry Smith @*/ 7755c6c1daeSBarry Smith PetscViewer PETSC_VIEWER_DRAW_(MPI_Comm comm) 7765c6c1daeSBarry Smith { 7775c6c1daeSBarry Smith PetscErrorCode ierr; 7785c6c1daeSBarry Smith PetscMPIInt flag; 7795c6c1daeSBarry Smith PetscViewer viewer; 7805c6c1daeSBarry Smith MPI_Comm ncomm; 7815c6c1daeSBarry Smith 7825c6c1daeSBarry Smith PetscFunctionBegin; 78302c9f0b5SLisandro 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);} 7845c6c1daeSBarry Smith if (Petsc_Viewer_Draw_keyval == MPI_KEYVAL_INVALID) { 78502c9f0b5SLisandro Dalcin ierr = MPI_Comm_create_keyval(MPI_COMM_NULL_COPY_FN,MPI_COMM_NULL_DELETE_FN,&Petsc_Viewer_Draw_keyval,NULL); 78602c9f0b5SLisandro Dalcin if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_INITIAL," ");PetscFunctionReturn(NULL);} 7875c6c1daeSBarry Smith } 78847435625SJed Brown ierr = MPI_Comm_get_attr(ncomm,Petsc_Viewer_Draw_keyval,(void**)&viewer,&flag); 78902c9f0b5SLisandro Dalcin if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_INITIAL," ");PetscFunctionReturn(NULL);} 7905c6c1daeSBarry Smith if (!flag) { /* PetscViewer not yet created */ 79102c9f0b5SLisandro Dalcin ierr = PetscViewerDrawOpen(ncomm,NULL,NULL,PETSC_DECIDE,PETSC_DECIDE,300,300,&viewer); 7922cb5e1ccSBarry Smith if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_REPEAT," ");PetscFunctionReturn(NULL);} 7935c6c1daeSBarry Smith ierr = PetscObjectRegisterDestroy((PetscObject)viewer); 7942cb5e1ccSBarry Smith if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_REPEAT," ");PetscFunctionReturn(NULL);} 79547435625SJed Brown ierr = MPI_Comm_set_attr(ncomm,Petsc_Viewer_Draw_keyval,(void*)viewer); 79602c9f0b5SLisandro Dalcin if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_INITIAL," ");PetscFunctionReturn(NULL);} 7975c6c1daeSBarry Smith } 7985c6c1daeSBarry Smith ierr = PetscCommDestroy(&ncomm); 7992cb5e1ccSBarry Smith if (ierr) {PetscError(PETSC_COMM_SELF,__LINE__,"PETSC_VIEWER_DRAW_",__FILE__,PETSC_ERR_PLIB,PETSC_ERROR_REPEAT," ");PetscFunctionReturn(NULL);} 8005c6c1daeSBarry Smith PetscFunctionReturn(viewer); 8015c6c1daeSBarry Smith } 8025c6c1daeSBarry Smith 8035c6c1daeSBarry Smith /*@ 8045c6c1daeSBarry Smith PetscViewerDrawSetBounds - sets the upper and lower bounds to be used in plotting 8055c6c1daeSBarry Smith 8065c6c1daeSBarry Smith Collective on PetscViewer 8075c6c1daeSBarry Smith 8085c6c1daeSBarry Smith Input Parameters: 8095c6c1daeSBarry Smith + viewer - the PetscViewer (created with PetscViewerDrawOpen()) 8105c6c1daeSBarry Smith . nbounds - number of plots that can be made with this viewer, for example the dof passed to DMDACreate() 8115c6c1daeSBarry 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, ..... 8125c6c1daeSBarry Smith 813e9457bf7SBarry Smith Options Database: 81410699b91SBarry Smith . -draw_bounds minF0,maxF0,minF1,maxF1 - the lower left and upper right bounds 815e9457bf7SBarry Smith 8165c6c1daeSBarry Smith Level: intermediate 8175c6c1daeSBarry Smith 81895452b02SPatrick Sanan Notes: 81995452b02SPatrick 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 820f3f0eb19SBarry 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 821f3f0eb19SBarry Smith this viewer. Otherwise the color to physical value meaning changes with each new image if this is not set. 822f3f0eb19SBarry Smith 8235c6c1daeSBarry Smith .seealso: PetscViewerDrawGetLG(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen() 8245c6c1daeSBarry Smith @*/ 8255c6c1daeSBarry Smith PetscErrorCode PetscViewerDrawSetBounds(PetscViewer viewer,PetscInt nbounds,const PetscReal *bounds) 8265c6c1daeSBarry Smith { 827e5ab1681SLisandro Dalcin PetscViewer_Draw *vdraw; 828e5ab1681SLisandro Dalcin PetscBool isdraw; 8295c6c1daeSBarry Smith PetscErrorCode ierr; 8305c6c1daeSBarry Smith 8315c6c1daeSBarry Smith PetscFunctionBegin; 8325c6c1daeSBarry Smith PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); 833e5ab1681SLisandro Dalcin ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); 834e5ab1681SLisandro Dalcin if (!isdraw) PetscFunctionReturn(0); 835e5ab1681SLisandro Dalcin vdraw = (PetscViewer_Draw*)viewer->data; 836a297a907SKarl Rupp 837e5ab1681SLisandro Dalcin vdraw->nbounds = nbounds; 838e5ab1681SLisandro Dalcin ierr = PetscFree(vdraw->bounds);CHKERRQ(ierr); 839785e854fSJed Brown ierr = PetscMalloc1(2*nbounds,&vdraw->bounds);CHKERRQ(ierr); 840580bdb30SBarry Smith ierr = PetscArraycpy(vdraw->bounds,bounds,2*nbounds);CHKERRQ(ierr); 8415c6c1daeSBarry Smith PetscFunctionReturn(0); 8425c6c1daeSBarry Smith } 8435c6c1daeSBarry Smith 8445c6c1daeSBarry Smith /*@C 8455c6c1daeSBarry Smith PetscViewerDrawGetBounds - gets the upper and lower bounds to be used in plotting set with PetscViewerDrawSetBounds() 8465c6c1daeSBarry Smith 8475c6c1daeSBarry Smith Collective on PetscViewer 8485c6c1daeSBarry Smith 8495c6c1daeSBarry Smith Input Parameter: 8505c6c1daeSBarry Smith . viewer - the PetscViewer (created with PetscViewerDrawOpen()) 8515c6c1daeSBarry Smith 852fd292e60Sprj- Output Parameters: 8535c6c1daeSBarry Smith + nbounds - number of plots that can be made with this viewer, for example the dof passed to DMDACreate() 8545c6c1daeSBarry 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, ..... 8555c6c1daeSBarry Smith 8565c6c1daeSBarry Smith Level: intermediate 8575c6c1daeSBarry Smith 858f3f0eb19SBarry Smith .seealso: PetscViewerDrawGetLG(), PetscViewerDrawGetAxis(), PetscViewerDrawOpen(), PetscViewerDrawSetBounds() 8595c6c1daeSBarry Smith @*/ 8605c6c1daeSBarry Smith PetscErrorCode PetscViewerDrawGetBounds(PetscViewer viewer,PetscInt *nbounds,const PetscReal **bounds) 8615c6c1daeSBarry Smith { 862e5ab1681SLisandro Dalcin PetscViewer_Draw *vdraw; 863e5ab1681SLisandro Dalcin PetscBool isdraw; 864e5ab1681SLisandro Dalcin PetscErrorCode ierr; 8655c6c1daeSBarry Smith 8665c6c1daeSBarry Smith PetscFunctionBegin; 8675c6c1daeSBarry Smith PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,1); 868e5ab1681SLisandro Dalcin ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERDRAW,&isdraw);CHKERRQ(ierr); 869e5ab1681SLisandro Dalcin if (!isdraw) {if (nbounds) *nbounds = 0; if (bounds) *bounds = NULL; PetscFunctionReturn(0);} 870e5ab1681SLisandro Dalcin vdraw = (PetscViewer_Draw*)viewer->data; 871e5ab1681SLisandro Dalcin 872e5ab1681SLisandro Dalcin if (nbounds) *nbounds = vdraw->nbounds; 873e5ab1681SLisandro Dalcin if (bounds) *bounds = vdraw->bounds; 8745c6c1daeSBarry Smith PetscFunctionReturn(0); 8755c6c1daeSBarry Smith } 876