| 2346 | } |
| 2347 | |
| 2348 | GMT_LOCAL void gmtplot_map_tickitem (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL, double w, double e, double s, double n, unsigned int item) { |
| 2349 | unsigned int i, nx = 0, ny = 0; |
| 2350 | bool do_x, do_y; |
| 2351 | double dx, dy, *val = NULL, len, shift = 0.0; |
| 2352 | |
| 2353 | if (! (GMT->current.map.frame.axis[GMT_X].item[item].active || GMT->current.map.frame.axis[GMT_Y].item[item].active)) return; |
| 2354 | |
| 2355 | dx = (GMT->current.map.frame.axis[GMT_X].file_custom) ? 1.0 : gmtlib_get_map_interval (GMT, GMT->current.map.frame.axis[GMT_X].type, &GMT->current.map.frame.axis[GMT_X].item[item]); |
| 2356 | dy = (GMT->current.map.frame.axis[GMT_Y].file_custom) ? 1.0 : gmtlib_get_map_interval (GMT, GMT->current.map.frame.axis[GMT_Y].type, &GMT->current.map.frame.axis[GMT_Y].item[item]); |
| 2357 | |
| 2358 | if (dx <= 0.0 && dy <= 0.0) return; |
| 2359 | |
| 2360 | do_x = dx > 0.0 && GMT->current.map.frame.axis[GMT_X].item[item].active && (item == GMT_ANNOT_UPPER || |
| 2361 | (item == GMT_TICK_UPPER && dx != gmtlib_get_map_interval (GMT, GMT->current.map.frame.axis[GMT_X].type, &GMT->current.map.frame.axis[GMT_X].item[GMT_ANNOT_UPPER])) || |
| 2362 | (item == GMT_TICK_LOWER && dx != gmtlib_get_map_interval (GMT, GMT->current.map.frame.axis[GMT_X].type, &GMT->current.map.frame.axis[GMT_X].item[GMT_ANNOT_LOWER]))); |
| 2363 | do_y = dy > 0.0 && GMT->current.map.frame.axis[GMT_Y].item[item].active && (item == GMT_ANNOT_UPPER || |
| 2364 | (item == GMT_TICK_UPPER && dy != gmtlib_get_map_interval (GMT, GMT->current.map.frame.axis[GMT_Y].type, &GMT->current.map.frame.axis[GMT_Y].item[GMT_ANNOT_UPPER])) || |
| 2365 | (item == GMT_TICK_LOWER && dy != gmtlib_get_map_interval (GMT, GMT->current.map.frame.axis[GMT_Y].type, &GMT->current.map.frame.axis[GMT_Y].item[GMT_ANNOT_LOWER]))); |
| 2366 | len = GMT->current.setting.map_tick_length[item]; |
| 2367 | if (GMT->current.setting.map_frame_type & GMT_IS_INSIDE) len = -fabs (len); /* Negative to become inside */ |
| 2368 | |
| 2369 | GMT->current.map.on_border_is_outside = true; /* Temporarily, points on the border are outside */ |
| 2370 | |
| 2371 | if (do_x) { /* Draw grid lines that go E to W */ |
| 2372 | if (GMT->current.map.frame.axis[GMT_X].file_custom) |
| 2373 | nx = gmtlib_coordinate_array (GMT, w, e, &GMT->current.map.frame.axis[GMT_X].item[item], &val, NULL); |
| 2374 | else |
| 2375 | nx = gmtlib_linear_array (GMT, w, e, dx, GMT->current.map.frame.axis[GMT_X].phase, &val); |
| 2376 | for (i = 0; i < nx; i++) { |
| 2377 | shift = gmtplot_shift_gridline (GMT, val[i], GMT_X); |
| 2378 | gmtplot_map_lontick (GMT, PSL, val[i] + shift, s, n, len); |
| 2379 | } |
| 2380 | if (nx) gmt_M_free (GMT, val); |
| 2381 | } |
| 2382 | |
| 2383 | if (do_y) { /* Draw grid lines that go S to N */ |
| 2384 | if (GMT->current.proj.z_down) { |
| 2385 | if (GMT->current.map.frame.axis[GMT_Y].file_custom) |
| 2386 | ny = gmtlib_coordinate_array (GMT, 0.0, GMT->current.proj.z_radius-s, &GMT->current.map.frame.axis[GMT_Y].item[item], &val, NULL); |
| 2387 | else if (GMT->current.proj.z_down == GMT_ZDOWN_Z) /* z = n - r */ |
| 2388 | ny = gmtlib_linear_array (GMT, 0.0, GMT->current.proj.z_radius-s, dy, GMT->current.map.frame.axis[GMT_Y].phase, &val); |
| 2389 | else if (GMT->current.proj.z_down == GMT_ZDOWN_ZP) /* r = rp - z */ |
| 2390 | ny = gmtlib_linear_array (GMT, GMT->current.proj.z_radius-n, GMT->current.proj.z_radius-s, dy, GMT->current.map.frame.axis[GMT_Y].phase, &val); |
| 2391 | for (i = 0; i < ny; i++) { |
| 2392 | if (GMT->current.proj.z_down == GMT_ZDOWN_ZP) |
| 2393 | val[i] = GMT->current.proj.z_radius - val[i]; /* These are the z values needed for positioning */ |
| 2394 | else |
| 2395 | val[i] = GMT->common.R.wesn[YHI] - val[i]; /* These are the radial values needed for positioning */ |
| 2396 | } |
| 2397 | } |
| 2398 | else { |
| 2399 | if (GMT->current.map.frame.axis[GMT_Y].file_custom) |
| 2400 | ny = gmtlib_coordinate_array (GMT, s, n, &GMT->current.map.frame.axis[GMT_Y].item[item], &val, NULL); |
| 2401 | else |
| 2402 | ny = gmtlib_linear_array (GMT, s, n, dy, GMT->current.map.frame.axis[GMT_Y].phase, &val); |
| 2403 | } |
| 2404 | for (i = 0; i < ny; i++) { |
| 2405 | if (gmtplot_skip_polar_apex_annotation (GMT, i, val, ny)) continue; |
no test coverage detected