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

Function gmtplot_rounded_framecorners

src/gmt_plot.c:1200–1248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1198}
1199
1200GMT_LOCAL void gmtplot_rounded_framecorners (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL, double w, double e, double s, double n, bool secondary_too) {
1201 unsigned int k, kn, item[2] = {GMT_TICK_UPPER, GMT_TICK_LOWER};
1202 double x1, y1, x2, y2, anglew, anglee, x, y, width;
1203 struct GMT_PLOT_AXIS_ITEM *Tx = NULL, *Ty = NULL;
1204
1205 if (GMT->current.setting.map_frame_type != GMT_IS_ROUNDED) return; /* Only do this if rounded corners are requested */
1206
1207 gmt_geo_to_xy (GMT, w, n, &x1, &y1);
1208 gmt_geo_to_xy (GMT, w, s, &x2, &y2);
1209 anglew = d_atan2d (y2 - y1, x2 - x1);
1210
1211 gmt_geo_to_xy (GMT, e, s, &x1, &y1);
1212 gmt_geo_to_xy (GMT, e, n, &x2, &y2);
1213 anglee = d_atan2d (y2 - y1, x2 - x1);
1214
1215 width = ((secondary_too) ? 0.5 : 1.0) * fabs (GMT->current.setting.map_frame_width);
1216 kn = (secondary_too) ? 2 : 1;
1217 for (k = 0; k < kn; k++) {
1218 Tx = &GMT->current.map.frame.axis[GMT_X].item[item[k]];
1219 Ty = &GMT->current.map.frame.axis[GMT_Y].item[item[k]];
1220 if (!(Tx->active && Ty->active)) continue;
1221 if (GMT->current.map.frame.side[S_SIDE] && GMT->current.map.frame.side[E_SIDE]) {
1222 gmt_geo_to_xy (GMT, e, s, &x, &y);
1223 PSL_plotarc (PSL, x, y, (k+1)*width, 180.0+anglee, 270.0+anglee, PSL_MOVE|PSL_STROKE);
1224 }
1225 if (GMT->current.map.frame.side[E_SIDE] && GMT->current.map.frame.side[N_SIDE]) {
1226 gmt_geo_to_xy (GMT, e, n, &x, &y);
1227 PSL_plotarc (PSL, x, y, (k+1)*width, 270.0+anglee, 360.0+anglee, PSL_MOVE|PSL_STROKE);
1228 }
1229 if (GMT->current.map.frame.side[N_SIDE] && GMT->current.map.frame.side[W_SIDE]) {
1230 gmt_geo_to_xy (GMT, w, n, &x, &y);
1231 PSL_plotarc (PSL, x, y, (k+1)*width, 180.0+anglew, 270.0+anglew, PSL_MOVE|PSL_STROKE);
1232 }
1233 if (GMT->current.map.frame.side[W_SIDE] && GMT->current.map.frame.side[S_SIDE]) {
1234 gmt_geo_to_xy (GMT, w, s, &x, &y);
1235 PSL_plotarc (PSL, x, y, (k+1)*width, 270.0+anglew, 360.0+anglew, PSL_MOVE|PSL_STROKE);
1236 }
1237 if ((gmt_M_is_azimuthal(GMT) || gmt_M_is_conical(GMT)) && GMT->current.map.frame.side[W_SIDE] && GMT->current.map.frame.side[E_SIDE]) { /* Round off the pointy head? */
1238 if (doubleAlmostEqual (GMT->common.R.wesn[YHI], 90.0)) {
1239 gmt_geo_to_xy (GMT, w, n, &x, &y);
1240 PSL_plotarc (PSL, x, y, (k+1)*width, anglee, 180.0+anglew, PSL_MOVE|PSL_STROKE);
1241 }
1242 else if (doubleAlmostEqual (GMT->common.R.wesn[YLO], -90.0)) {
1243 gmt_geo_to_xy (GMT, w, s, &x, &y);
1244 PSL_plotarc (PSL, x, y, (k+1)*width, anglew-90.0, anglee-90.0, PSL_MOVE|PSL_STROKE);
1245 }
1246 }
1247 }
1248}
1249
1250#if 0
1251/* Nov-11-2014 PW: For reference until we know there are no side effects with the new one below */

Callers 3

Calls 2

gmt_geo_to_xyFunction · 0.85
PSL_plotarcFunction · 0.85

Tested by

no test coverage detected