| 1910 | } |
| 1911 | |
| 1912 | GMT_LOCAL void gmtplot_z_gridlines (struct GMT_CTRL *GMT, struct PSL_CTRL *PSL, double zmin, double zmax, int plane, unsigned int mode3d, int quadrant) { |
| 1913 | unsigned int k, i, nz, n, item[2] = {GMT_GRID_UPPER, GMT_GRID_LOWER}; |
| 1914 | int qplane = 1 - plane; |
| 1915 | double dz, zz, dd, min, max, z0, z1, xx, dummy, value, *z = NULL, *d = NULL; |
| 1916 | char *plane_name[2] = {"y-z", "x-z"}; |
| 1917 | |
| 1918 | if (qplane == GMT_X) { |
| 1919 | value = (quadrant == 4) ? GMT->common.R.wesn[YHI] : GMT->common.R.wesn[YLO]; |
| 1920 | min = GMT->current.proj.rect[XLO]; max = GMT->current.proj.rect[XHI]; |
| 1921 | } |
| 1922 | else { |
| 1923 | value = (quadrant == 3) ? GMT->common.R.wesn[XHI] : GMT->common.R.wesn[XLO]; |
| 1924 | min = GMT->current.proj.rect[YLO]; max = GMT->current.proj.rect[YHI]; |
| 1925 | } |
| 1926 | |
| 1927 | for (k = 0; k < 2; k++) { |
| 1928 | if (fabs (GMT->current.setting.map_grid_cross_size[k]) > 0.0) continue; |
| 1929 | |
| 1930 | dz = gmtlib_get_map_interval (GMT, GMT->current.map.frame.axis[GMT_Z].type, &GMT->current.map.frame.axis[GMT_Z].item[item[k]]); /* Gridline spacing in z */ |
| 1931 | |
| 1932 | if (!GMT->current.map.frame.axis[GMT_Z].item[item[k]].active || fabs(dz) == 0.0) continue; |
| 1933 | |
| 1934 | PSL_comment (PSL, "%s gridlines %s\n", plane_name[plane], k ? "(secondary)" : "(primary)"); |
| 1935 | |
| 1936 | gmt_setpen (GMT, &GMT->current.setting.map_grid_pen[k]); |
| 1937 | |
| 1938 | nz = gmtlib_coordinate_array (GMT, zmin, zmax, &GMT->current.map.frame.axis[GMT_Z].item[item[k]], &z, NULL); |
| 1939 | for (i = 0; i < nz; i++) { /* Here z acts as y and x|y acts as x */ |
| 1940 | /* Draw one horizontal line */ |
| 1941 | zz = gmt_z_to_zz (GMT, z[i]); |
| 1942 | PSL_plotsegment (PSL, min, zz, max, zz); |
| 1943 | } |
| 1944 | z0 = gmt_z_to_zz (GMT, zmin); /* These are the projected min and max z values, i.e., the ends of vertical gridlines on the back walls */ |
| 1945 | z1 = gmt_z_to_zz (GMT, zmax); |
| 1946 | |
| 1947 | dd = gmtlib_get_map_interval (GMT, GMT->current.map.frame.axis[qplane].type, &GMT->current.map.frame.axis[qplane].item[item[k]]); |
| 1948 | if (!GMT->current.map.frame.axis[qplane].item[item[k]].active || fabs(dd) == 0.0) continue; |
| 1949 | n = gmtlib_coordinate_array (GMT, GMT->common.R.wesn[2*qplane], GMT->common.R.wesn[2*qplane+1], &GMT->current.map.frame.axis[qplane].item[item[k]], &d, NULL); |
| 1950 | for (i = 0; i < n; i++) { /* Here z acts as y and x|y acts as x */ |
| 1951 | /* Draw one horizontal line */ |
| 1952 | if (qplane == GMT_X) /* The "x" are projection x or longitude */ |
| 1953 | gmt_geo_to_xy (GMT, d[i], value, &xx, &dummy); |
| 1954 | else /* The "x" are projection y or latitude */ |
| 1955 | gmt_geo_to_xy (GMT, value, d[i], &dummy, &xx); |
| 1956 | |
| 1957 | PSL_plotsegment (PSL, xx, z0, xx, z1); |
| 1958 | } |
| 1959 | gmt_M_free (GMT, d); |
| 1960 | |
| 1961 | PSL_setdash (PSL, NULL, 0); |
| 1962 | } |
| 1963 | if (!GMT->current.map.frame.draw_wall && z && (mode3d & GMT_3D_BOX) == 0) { |
| 1964 | PSL_plotsegment (PSL, min, z0, min, z1); |
| 1965 | PSL_plotsegment (PSL, max, z0, max, z1); |
| 1966 | } |
| 1967 | gmt_M_free (GMT, z); |
| 1968 | } |
| 1969 |
no test coverage detected