MCPcopy Create free account
hub / github.com/GenericMappingTools/gmt / gmt_draw_map_panel

Function gmt_draw_map_panel

src/gmt_plot.c:7420–7458  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7418}
7419
7420void gmt_draw_map_panel (struct GMT_CTRL *GMT, double x, double y, unsigned int mode, struct GMT_MAP_PANEL *P) {
7421 /* Draw a rectangular backpanel behind things like logos, scales, legends, images.
7422 * Here, (x,y) is the center-point of the panel.
7423 * mode is a bit flag that can be 1,2, or 3:
7424 * mode = 1. Lay down fills for background (if any fills) but no outlines
7425 * mode = 2. Just draw any outlines requested
7426 * mode = 3. Do both at the same time. */
7427 double dim[3] = {0.0, 0.0, 0.0};
7428 int outline;
7429 struct GMT_FILL *fill = NULL; /* Default is no fill */
7430 if (!P) return; /* No panel given */
7431 outline = ((P->mode & GMT_PANEL_OUTLINE) == GMT_PANEL_OUTLINE) ? 1 : 0; /* Does the panel have an outline? */
7432 GMT_Report (GMT->parent, GMT_MSG_INFORMATION, "Place rectangular back panel\n");
7433 GMT_Report (GMT->parent, GMT_MSG_DEBUG, "Clearance: %g/%g/%g/%g\n", P->padding[XLO], P->padding[XLO], P->padding[YLO], P->padding[YHI]);
7434 dim[GMT_X] = P->width + P->padding[XLO] + P->padding[XHI]; /* Rectangle width */
7435 dim[GMT_Y] = P->height + P->padding[YLO] + P->padding[YHI]; /* Rectangle height */
7436 dim[GMT_Z] = P->radius; /* Corner radius, or zero */
7437 /* In case clearances are not symmetric we need to shift the symbol center accordingly */
7438 x += 0.5 * (P->padding[XHI] - P->padding[XLO]);
7439 y += 0.5 * (P->padding[YHI] - P->padding[YLO]);
7440 if (mode == 1) outline = 0; /* Do not draw outlines (even if requested) at this time since mode == 1*/
7441 if ((mode & 1) && (P->mode & GMT_PANEL_SHADOW)) { /* Draw offset background shadow first */
7442 gmt_setfill (GMT, &P->sfill, 0); /* The shadow has no outline */
7443 PSL_plotsymbol (GMT->PSL, x + P->off[GMT_X], y + P->off[GMT_Y], dim, (P->mode & GMT_PANEL_ROUNDED) ? PSL_RNDRECT : PSL_RECT);
7444 }
7445 if ((mode & 2) && outline) gmt_setpen (GMT, &P->pen1); /* Need to set frame outline pen */
7446 if (mode & 1) fill = &P->fill; /* Select fill (which may be NULL) unless we are just doing outlines */
7447 if (fill || outline) gmt_setfill (GMT, fill, outline); /* Activate frame fill, with optional outline */
7448 if ((mode&1 && (P->mode & GMT_PANEL_FILL)) || (mode&2 && (P->mode & GMT_PANEL_OUTLINE))) PSL_plotsymbol (GMT->PSL, x, y, dim, (P->mode & GMT_PANEL_ROUNDED) ? PSL_RNDRECT : PSL_RECT);
7449 if ((mode & 2) && (P->mode & GMT_PANEL_INNER)) { /* Also draw secondary frame on the inside */
7450 dim[GMT_X] -= 2.0 * P->gap; /* Shrink dimension of panel by the uniform gap on all sides */
7451 dim[GMT_Y] -= 2.0 * P->gap;
7452 gmt_setpen (GMT, &P->pen2); /* Set inner border pen */
7453 gmt_setfill (GMT, NULL, 1); /* Never fill for inner frame */
7454 PSL_plotsymbol (GMT->PSL, x, y, dim, (P->mode & GMT_PANEL_ROUNDED) ? PSL_RNDRECT : PSL_RECT);
7455 }
7456 /* Reset color */
7457 PSL_setcolor (GMT->PSL, GMT->current.setting.map_frame_pen.rgb, PSL_IS_STROKE);
7458}
7459
7460void gmt_setpen (struct GMT_CTRL *GMT, struct GMT_PEN *pen) {
7461 /* gmt_setpen issues PostScript code to set the specified pen. */

Callers 8

gmt_draw_map_insetFunction · 0.85
gmt_draw_map_scaleFunction · 0.85
gmt_draw_vertical_scaleFunction · 0.85
gmt_draw_map_roseFunction · 0.85
GMT_gmtlogoFunction · 0.85
psscale_draw_colorbarFunction · 0.85
GMT_psimageFunction · 0.85
GMT_pslegendFunction · 0.85

Calls 5

GMT_ReportFunction · 0.85
gmt_setfillFunction · 0.85
PSL_plotsymbolFunction · 0.85
gmt_setpenFunction · 0.85
PSL_setcolorFunction · 0.85

Tested by

no test coverage detected