15c6c1daeSBarry Smith /*
25c6c1daeSBarry Smith Provides the calling sequences for all the basic PetscDraw routines.
35c6c1daeSBarry Smith */
4af0996ceSBarry Smith #include <petsc/private/drawimpl.h> /*I "petscdraw.h" I*/
55c6c1daeSBarry Smith
65c6c1daeSBarry Smith /*@
7811af0c4SBarry Smith PetscDrawGetBoundingBox - Gets the bounding box of all `PetscDrawStringBoxed()` commands
85c6c1daeSBarry Smith
920f4b53cSBarry Smith Not Collective
105c6c1daeSBarry Smith
115c6c1daeSBarry Smith Input Parameter:
125c6c1daeSBarry Smith . draw - the drawing context
135c6c1daeSBarry Smith
145c6c1daeSBarry Smith Output Parameters:
152fe279fdSBarry Smith + xl - horizontal coordinate of lower left corner of bounding box
162fe279fdSBarry Smith . yl - vertical coordinate of lower left corner of bounding box
172fe279fdSBarry Smith . xr - horizontal coordinate of upper right corner of bounding box
182fe279fdSBarry Smith - yr - vertical coordinate of upper right corner of bounding box
195c6c1daeSBarry Smith
205c6c1daeSBarry Smith Level: intermediate
215c6c1daeSBarry Smith
22811af0c4SBarry Smith .seealso: `PetscDraw`, `PetscDrawPushCurrentPoint()`, `PetscDrawPopCurrentPoint()`, `PetscDrawSetCurrentPoint()`
235c6c1daeSBarry Smith @*/
PetscDrawGetBoundingBox(PetscDraw draw,PetscReal * xl,PetscReal * yl,PetscReal * xr,PetscReal * yr)24d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscDrawGetBoundingBox(PetscDraw draw, PetscReal *xl, PetscReal *yl, PetscReal *xr, PetscReal *yr)
25d71ae5a4SJacob Faibussowitsch {
265c6c1daeSBarry Smith PetscFunctionBegin;
275c6c1daeSBarry Smith PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1);
284f572ea9SToby Isaac if (xl) PetscAssertPointer(xl, 2);
294f572ea9SToby Isaac if (yl) PetscAssertPointer(yl, 3);
304f572ea9SToby Isaac if (xr) PetscAssertPointer(xr, 4);
314f572ea9SToby Isaac if (yr) PetscAssertPointer(yr, 5);
325c6c1daeSBarry Smith if (xl) *xl = draw->boundbox_xl;
335c6c1daeSBarry Smith if (yl) *yl = draw->boundbox_yl;
345c6c1daeSBarry Smith if (xr) *xr = draw->boundbox_xr;
355c6c1daeSBarry Smith if (yr) *yr = draw->boundbox_yr;
363ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
375c6c1daeSBarry Smith }
385c6c1daeSBarry Smith
395c6c1daeSBarry Smith /*@
405c6c1daeSBarry Smith PetscDrawGetCurrentPoint - Gets the current draw point, some codes use this point to determine where to draw next
415c6c1daeSBarry Smith
4220f4b53cSBarry Smith Not Collective
435c6c1daeSBarry Smith
445c6c1daeSBarry Smith Input Parameter:
455c6c1daeSBarry Smith . draw - the drawing context
465c6c1daeSBarry Smith
475c6c1daeSBarry Smith Output Parameters:
482fe279fdSBarry Smith + x - horizontal coordinate of the current point
492fe279fdSBarry Smith - y - vertical coordinate of the current point
505c6c1daeSBarry Smith
515c6c1daeSBarry Smith Level: intermediate
525c6c1daeSBarry Smith
53811af0c4SBarry Smith .seealso: `PetscDraw`, `PetscDrawPushCurrentPoint()`, `PetscDrawPopCurrentPoint()`, `PetscDrawSetCurrentPoint()`
545c6c1daeSBarry Smith @*/
PetscDrawGetCurrentPoint(PetscDraw draw,PetscReal * x,PetscReal * y)55d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscDrawGetCurrentPoint(PetscDraw draw, PetscReal *x, PetscReal *y)
56d71ae5a4SJacob Faibussowitsch {
575c6c1daeSBarry Smith PetscFunctionBegin;
585c6c1daeSBarry Smith PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1);
594f572ea9SToby Isaac PetscAssertPointer(x, 2);
604f572ea9SToby Isaac PetscAssertPointer(y, 3);
615c6c1daeSBarry Smith *x = draw->currentpoint_x[draw->currentpoint];
625c6c1daeSBarry Smith *y = draw->currentpoint_y[draw->currentpoint];
633ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
645c6c1daeSBarry Smith }
655c6c1daeSBarry Smith
665c6c1daeSBarry Smith /*@
675c6c1daeSBarry Smith PetscDrawSetCurrentPoint - Sets the current draw point, some codes use this point to determine where to draw next
685c6c1daeSBarry Smith
6920f4b53cSBarry Smith Not Collective
705c6c1daeSBarry Smith
715c6c1daeSBarry Smith Input Parameters:
725c6c1daeSBarry Smith + draw - the drawing context
732fe279fdSBarry Smith . x - horizontal coordinate of the current point
742fe279fdSBarry Smith - y - vertical coordinate of the current point
755c6c1daeSBarry Smith
765c6c1daeSBarry Smith Level: intermediate
775c6c1daeSBarry Smith
78811af0c4SBarry Smith .seealso: `PetscDraw`, `PetscDrawPushCurrentPoint()`, `PetscDrawPopCurrentPoint()`, `PetscDrawGetCurrentPoint()`
795c6c1daeSBarry Smith @*/
PetscDrawSetCurrentPoint(PetscDraw draw,PetscReal x,PetscReal y)80d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscDrawSetCurrentPoint(PetscDraw draw, PetscReal x, PetscReal y)
81d71ae5a4SJacob Faibussowitsch {
825c6c1daeSBarry Smith PetscFunctionBegin;
835c6c1daeSBarry Smith PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1);
845c6c1daeSBarry Smith draw->currentpoint_x[draw->currentpoint] = x;
855c6c1daeSBarry Smith draw->currentpoint_y[draw->currentpoint] = y;
863ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
875c6c1daeSBarry Smith }
885c6c1daeSBarry Smith
895c6c1daeSBarry Smith /*@
905c6c1daeSBarry Smith PetscDrawPushCurrentPoint - Pushes a new current draw point, retaining the old one, some codes use this point to determine where to draw next
915c6c1daeSBarry Smith
9220f4b53cSBarry Smith Not Collective
935c6c1daeSBarry Smith
945c6c1daeSBarry Smith Input Parameters:
955c6c1daeSBarry Smith + draw - the drawing context
962fe279fdSBarry Smith . x - horizontal coordinate of the current point
972fe279fdSBarry Smith - y - vertical coordinate of the current point
985c6c1daeSBarry Smith
995c6c1daeSBarry Smith Level: intermediate
1005c6c1daeSBarry Smith
101*42747ad1SJacob Faibussowitsch .seealso: `PetscDraw`, `PetscDrawPopCurrentPoint()`, `PetscDrawGetCurrentPoint()`
1025c6c1daeSBarry Smith @*/
PetscDrawPushCurrentPoint(PetscDraw draw,PetscReal x,PetscReal y)103d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscDrawPushCurrentPoint(PetscDraw draw, PetscReal x, PetscReal y)
104d71ae5a4SJacob Faibussowitsch {
1055c6c1daeSBarry Smith PetscFunctionBegin;
1065c6c1daeSBarry Smith PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1);
10708401ef6SPierre Jolivet PetscCheck(draw->currentpoint <= 19, PETSC_COMM_SELF, PETSC_ERR_SUP, "You have pushed too many current points");
1085c6c1daeSBarry Smith draw->currentpoint_x[++draw->currentpoint] = x;
1095c6c1daeSBarry Smith draw->currentpoint_y[draw->currentpoint] = y;
1103ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
1115c6c1daeSBarry Smith }
1125c6c1daeSBarry Smith
1135c6c1daeSBarry Smith /*@
1145c6c1daeSBarry Smith PetscDrawPopCurrentPoint - Pops a current draw point (discarding it)
1155c6c1daeSBarry Smith
11620f4b53cSBarry Smith Not Collective
1175c6c1daeSBarry Smith
1185c6c1daeSBarry Smith Input Parameter:
1195c6c1daeSBarry Smith . draw - the drawing context
1205c6c1daeSBarry Smith
1215c6c1daeSBarry Smith Level: intermediate
1225c6c1daeSBarry Smith
123811af0c4SBarry Smith .seealso: `PetscDraw`, `PetscDrawPushCurrentPoint()`, `PetscDrawSetCurrentPoint()`, `PetscDrawGetCurrentPoint()`
1245c6c1daeSBarry Smith @*/
PetscDrawPopCurrentPoint(PetscDraw draw)125d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscDrawPopCurrentPoint(PetscDraw draw)
126d71ae5a4SJacob Faibussowitsch {
1275c6c1daeSBarry Smith PetscFunctionBegin;
1285c6c1daeSBarry Smith PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1);
129cc73adaaSBarry Smith PetscCheck(draw->currentpoint-- > 0, PETSC_COMM_SELF, PETSC_ERR_SUP, "You have popped too many current points");
1303ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
1315c6c1daeSBarry Smith }
1325c6c1daeSBarry Smith
1335c6c1daeSBarry Smith /*@
134811af0c4SBarry Smith PetscDrawLine - draws a line onto a drawable.
1355c6c1daeSBarry Smith
13620f4b53cSBarry Smith Not Collective
1375c6c1daeSBarry Smith
1385c6c1daeSBarry Smith Input Parameters:
1395c6c1daeSBarry Smith + draw - the drawing context
1402fe279fdSBarry Smith . xl - horizontal coordinate of first end point
1412fe279fdSBarry Smith . yl - vertical coordinate of first end point
1422fe279fdSBarry Smith . xr - horizontal coordinate of second end point
1432fe279fdSBarry Smith . yr - vertical coordinate of second end point
1445c6c1daeSBarry Smith - cl - the colors of the endpoints
1455c6c1daeSBarry Smith
1465c6c1daeSBarry Smith Level: beginner
1475c6c1daeSBarry Smith
148811af0c4SBarry Smith .seealso: `PetscDraw`, `PetscDrawArrow()`, `PetscDrawLineSetWidth()`, `PetscDrawLineGetWidth()`, `PetscDrawRectangle()`, `PetscDrawTriangle()`, `PetscDrawEllipse()`,
149db781477SPatrick Sanan `PetscDrawMarker()`, `PetscDrawPoint()`
1505c6c1daeSBarry Smith @*/
PetscDrawLine(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int cl)151d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscDrawLine(PetscDraw draw, PetscReal xl, PetscReal yl, PetscReal xr, PetscReal yr, int cl)
152d71ae5a4SJacob Faibussowitsch {
1535c6c1daeSBarry Smith PetscFunctionBegin;
1545c6c1daeSBarry Smith PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1);
155dbbe0bcdSBarry Smith PetscUseTypeMethod(draw, line, xl, yl, xr, yr, cl);
1563ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
1575c6c1daeSBarry Smith }
1585c6c1daeSBarry Smith
1595c6c1daeSBarry Smith /*@
160811af0c4SBarry Smith PetscDrawArrow - draws a line with arrow head at end if the line is long enough
1615c6c1daeSBarry Smith
16220f4b53cSBarry Smith Not Collective
1635c6c1daeSBarry Smith
1645c6c1daeSBarry Smith Input Parameters:
1655c6c1daeSBarry Smith + draw - the drawing context
1662fe279fdSBarry Smith . xl - horizontal coordinate of first end point
1672fe279fdSBarry Smith . yl - vertical coordinate of first end point
1682fe279fdSBarry Smith . xr - horizontal coordinate of second end point
1692fe279fdSBarry Smith . yr - vertical coordinate of second end point
1705c6c1daeSBarry Smith - cl - the colors of the endpoints
1715c6c1daeSBarry Smith
1725c6c1daeSBarry Smith Level: beginner
1735c6c1daeSBarry Smith
174811af0c4SBarry Smith .seealso: `PetscDraw`, `PetscDrawLine()`, `PetscDrawLineSetWidth()`, `PetscDrawLineGetWidth()`, `PetscDrawRectangle()`, `PetscDrawTriangle()`, `PetscDrawEllipse()`,
175db781477SPatrick Sanan `PetscDrawMarker()`, `PetscDrawPoint()`
1765c6c1daeSBarry Smith @*/
PetscDrawArrow(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int cl)177d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscDrawArrow(PetscDraw draw, PetscReal xl, PetscReal yl, PetscReal xr, PetscReal yr, int cl)
178d71ae5a4SJacob Faibussowitsch {
1795c6c1daeSBarry Smith PetscFunctionBegin;
1805c6c1daeSBarry Smith PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1);
181dbbe0bcdSBarry Smith PetscUseTypeMethod(draw, arrow, xl, yl, xr, yr, cl);
1823ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
1835c6c1daeSBarry Smith }
1845c6c1daeSBarry Smith
1858f69470aSLisandro Dalcin /*@
1868f69470aSLisandro Dalcin PetscDrawLineSetWidth - Sets the line width for future draws. The width is
1878f69470aSLisandro Dalcin relative to the user coordinates of the window; 0.0 denotes the natural
1888f69470aSLisandro Dalcin width; 1.0 denotes the entire viewport.
1898f69470aSLisandro Dalcin
19020f4b53cSBarry Smith Not Collective
1918f69470aSLisandro Dalcin
1928f69470aSLisandro Dalcin Input Parameters:
1938f69470aSLisandro Dalcin + draw - the drawing context
1948f69470aSLisandro Dalcin - width - the width in user coordinates
1958f69470aSLisandro Dalcin
1968f69470aSLisandro Dalcin Level: advanced
1978f69470aSLisandro Dalcin
198811af0c4SBarry Smith .seealso: `PetscDraw`, `PetscDrawLineGetWidth()`, `PetscDrawLine()`, `PetscDrawArrow()`
1998f69470aSLisandro Dalcin @*/
PetscDrawLineSetWidth(PetscDraw draw,PetscReal width)200d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscDrawLineSetWidth(PetscDraw draw, PetscReal width)
201d71ae5a4SJacob Faibussowitsch {
2028f69470aSLisandro Dalcin PetscFunctionBegin;
2038f69470aSLisandro Dalcin PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1);
204dbbe0bcdSBarry Smith PetscTryTypeMethod(draw, linesetwidth, width);
2053ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
2068f69470aSLisandro Dalcin }
2078f69470aSLisandro Dalcin
2088f69470aSLisandro Dalcin /*@
2098f69470aSLisandro Dalcin PetscDrawLineGetWidth - Gets the line width for future draws. The width is
2108f69470aSLisandro Dalcin relative to the user coordinates of the window; 0.0 denotes the natural
2118f69470aSLisandro Dalcin width; 1.0 denotes the interior viewport.
2128f69470aSLisandro Dalcin
21320f4b53cSBarry Smith Not Collective
2148f69470aSLisandro Dalcin
2158f69470aSLisandro Dalcin Input Parameter:
2168f69470aSLisandro Dalcin . draw - the drawing context
2178f69470aSLisandro Dalcin
2188f69470aSLisandro Dalcin Output Parameter:
2198f69470aSLisandro Dalcin . width - the width in user coordinates
2208f69470aSLisandro Dalcin
2218f69470aSLisandro Dalcin Level: advanced
2228f69470aSLisandro Dalcin
223811af0c4SBarry Smith Note:
2248f69470aSLisandro Dalcin Not currently implemented.
2258f69470aSLisandro Dalcin
226811af0c4SBarry Smith .seealso: `PetscDraw`, `PetscDrawLineSetWidth()`, `PetscDrawLine()`, `PetscDrawArrow()`
2278f69470aSLisandro Dalcin @*/
PetscDrawLineGetWidth(PetscDraw draw,PetscReal * width)228d71ae5a4SJacob Faibussowitsch PetscErrorCode PetscDrawLineGetWidth(PetscDraw draw, PetscReal *width)
229d71ae5a4SJacob Faibussowitsch {
2308f69470aSLisandro Dalcin PetscFunctionBegin;
2318f69470aSLisandro Dalcin PetscValidHeaderSpecific(draw, PETSC_DRAW_CLASSID, 1);
2324f572ea9SToby Isaac PetscAssertPointer(width, 2);
233dbbe0bcdSBarry Smith PetscUseTypeMethod(draw, linegetwidth, width);
2343ba16761SJacob Faibussowitsch PetscFunctionReturn(PETSC_SUCCESS);
2358f69470aSLisandro Dalcin }
236