1 2 /* 3 Provides the calling sequences for all the basic PetscDraw routines. 4 */ 5 #include <petsc/private/drawimpl.h> /*I "petscdraw.h" I*/ 6 7 #undef __FUNCT__ 8 #define __FUNCT__ "PetscDrawGetBoundingBox" 9 /*@ 10 PetscDrawGetBoundingBox - Gets the bounding box of all PetscDrawStringBoxed() commands 11 12 Not collective 13 14 Input Parameter: 15 . draw - the drawing context 16 17 Output Parameters: 18 . xl,yl,xr,yr - coordinates of lower left and upper right corners of bounding box 19 20 Level: intermediate 21 22 .seealso: PetscDrawPushCurrentPoint(), PetscDrawPopCurrentPoint(), PetscDrawSetCurrentPoint() 23 @*/ 24 PetscErrorCode PetscDrawGetBoundingBox(PetscDraw draw,PetscReal *xl,PetscReal *yl,PetscReal *xr,PetscReal *yr) 25 { 26 PetscFunctionBegin; 27 PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 28 if (xl) *xl = draw->boundbox_xl; 29 if (yl) *yl = draw->boundbox_yl; 30 if (xr) *xr = draw->boundbox_xr; 31 if (yr) *yr = draw->boundbox_yr; 32 PetscFunctionReturn(0); 33 } 34 35 #undef __FUNCT__ 36 #define __FUNCT__ "PetscDrawGetCurrentPoint" 37 /*@ 38 PetscDrawGetCurrentPoint - Gets the current draw point, some codes use this point to determine where to draw next 39 40 Not collective 41 42 Input Parameter: 43 . draw - the drawing context 44 45 Output Parameters: 46 . x,y - the current point 47 48 Level: intermediate 49 50 .seealso: PetscDrawPushCurrentPoint(), PetscDrawPopCurrentPoint(), PetscDrawSetCurrentPoint() 51 @*/ 52 PetscErrorCode PetscDrawGetCurrentPoint(PetscDraw draw,PetscReal *x,PetscReal *y) 53 { 54 PetscFunctionBegin; 55 PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 56 *x = draw->currentpoint_x[draw->currentpoint]; 57 *y = draw->currentpoint_y[draw->currentpoint]; 58 PetscFunctionReturn(0); 59 } 60 61 #undef __FUNCT__ 62 #define __FUNCT__ "PetscDrawSetCurrentPoint" 63 /*@ 64 PetscDrawSetCurrentPoint - Sets the current draw point, some codes use this point to determine where to draw next 65 66 Not collective 67 68 Input Parameters: 69 + draw - the drawing context 70 - x,y - the location of the current point 71 72 Level: intermediate 73 74 .seealso: PetscDrawPushCurrentPoint(), PetscDrawPopCurrentPoint(), PetscDrawGetCurrentPoint() 75 @*/ 76 PetscErrorCode PetscDrawSetCurrentPoint(PetscDraw draw,PetscReal x,PetscReal y) 77 { 78 PetscFunctionBegin; 79 PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 80 draw->currentpoint_x[draw->currentpoint] = x; 81 draw->currentpoint_y[draw->currentpoint] = y; 82 PetscFunctionReturn(0); 83 } 84 85 #undef __FUNCT__ 86 #define __FUNCT__ "PetscDrawPushCurrentPoint" 87 /*@ 88 PetscDrawPushCurrentPoint - Pushes a new current draw point, retaining the old one, some codes use this point to determine where to draw next 89 90 Not collective 91 92 Input Parameters: 93 + draw - the drawing context 94 - x,y - the location of the current point 95 96 Level: intermediate 97 98 .seealso: PetscDrawPushCurrentPoint(), PetscDrawPopCurrentPoint(), PetscDrawGetCurrentPoint() 99 @*/ 100 PetscErrorCode PetscDrawPushCurrentPoint(PetscDraw draw,PetscReal x,PetscReal y) 101 { 102 PetscFunctionBegin; 103 PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 104 if (draw->currentpoint > 19) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"You have pushed too many current points"); 105 draw->currentpoint_x[++draw->currentpoint] = x; 106 draw->currentpoint_y[draw->currentpoint] = y; 107 PetscFunctionReturn(0); 108 } 109 110 #undef __FUNCT__ 111 #define __FUNCT__ "PetscDrawPopCurrentPoint" 112 /*@ 113 PetscDrawPopCurrentPoint - Pops a current draw point (discarding it) 114 115 Not collective 116 117 Input Parameter: 118 . draw - the drawing context 119 120 Level: intermediate 121 122 .seealso: PetscDrawPushCurrentPoint(), PetscDrawSetCurrentPoint(), PetscDrawGetCurrentPoint() 123 @*/ 124 PetscErrorCode PetscDrawPopCurrentPoint(PetscDraw draw) 125 { 126 PetscFunctionBegin; 127 PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 128 if (draw->currentpoint-- == 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_SUP,"You have popped too many current points"); 129 PetscFunctionReturn(0); 130 } 131 132 #undef __FUNCT__ 133 #define __FUNCT__ "PetscDrawLine" 134 /*@ 135 PetscDrawLine - PetscDraws a line onto a drawable. 136 137 Not collective 138 139 Input Parameters: 140 + draw - the drawing context 141 . xl,yl,xr,yr - the coordinates of the line endpoints 142 - cl - the colors of the endpoints 143 144 Level: beginner 145 146 Concepts: line^drawing 147 Concepts: drawing^line 148 149 @*/ 150 PetscErrorCode PetscDrawLine(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int cl) 151 { 152 PetscErrorCode ierr; 153 PetscBool isdrawnull; 154 155 PetscFunctionBegin; 156 PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 157 ierr = PetscObjectTypeCompare((PetscObject)draw,PETSC_DRAW_NULL,&isdrawnull);CHKERRQ(ierr); 158 if (isdrawnull) PetscFunctionReturn(0); 159 if (!draw->ops->line) SETERRQ(PetscObjectComm((PetscObject)draw),PETSC_ERR_SUP,"No support for drawing lines"); 160 ierr = (*draw->ops->line)(draw,xl,yl,xr,yr,cl);CHKERRQ(ierr); 161 PetscFunctionReturn(0); 162 } 163 164 #undef __FUNCT__ 165 #define __FUNCT__ "PetscDrawArrow" 166 /*@ 167 PetscDrawArrow - PetscDraws a line with arrow head at end if the line is long enough 168 169 Not collective 170 171 Input Parameters: 172 + draw - the drawing context 173 . xl,yl,xr,yr - the coordinates of the line endpoints 174 - cl - the colors of the endpoints 175 176 Level: beginner 177 178 Concepts: line^drawing 179 Concepts: drawing^line 180 181 @*/ 182 PetscErrorCode PetscDrawArrow(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int cl) 183 { 184 PetscErrorCode ierr; 185 PetscBool isdrawnull; 186 187 PetscFunctionBegin; 188 PetscValidHeaderSpecific(draw,PETSC_DRAW_CLASSID,1); 189 ierr = PetscObjectTypeCompare((PetscObject)draw,PETSC_DRAW_NULL,&isdrawnull);CHKERRQ(ierr); 190 if (isdrawnull) PetscFunctionReturn(0); 191 if (!draw->ops->arrow) SETERRQ(PetscObjectComm((PetscObject)draw),PETSC_ERR_SUP,"No support for drawing arrows"); 192 ierr = (*draw->ops->arrow)(draw,xl,yl,xr,yr,cl);CHKERRQ(ierr); 193 PetscFunctionReturn(0); 194 } 195 196