Mercurial > octave
changeset 32116:7e774d71c491
Add support for "none" option to axes graphic property "TickDir".
* NEWS.9.md: Document new value for "TickDir" property.
* genpropdoc.m: Add "none" to documentation for "TickDir" property.
* graphics.in.h (BEGIN_PROPERTIES (axes)): Add new options "none" and "both" as
possible values for "TickDir" property.
* graphics.cc (draw_axes_[xyz]_grid): New boolean variable do_[xyz]tick to
determine whether ticks should be drawn. Simplify calculation of variable
do_[xyz]minortick by using do_[xyz]tick. Condition calling render_tickmarks()
on value of do_[xyz]tick being true.
* gl-render.cc (update_ticklength): New if/else if/else tree to decode
value of "TickDir" and set local variable "ticksign" appropriately.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 12 Jun 2023 14:18:08 -0700 |
parents | 40686c90cec3 |
children | 5e207c861831 |
files | doc/interpreter/genpropdoc.m etc/NEWS.9.md libinterp/corefcn/gl-render.cc libinterp/corefcn/graphics.cc libinterp/corefcn/graphics.in.h |
diffstat | 5 files changed, 82 insertions(+), 57 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/interpreter/genpropdoc.m Sun Jun 11 21:32:21 2023 -0700 +++ b/doc/interpreter/genpropdoc.m Mon Jun 12 14:18:08 2023 -0700 @@ -859,7 +859,8 @@ case "tickdir" s.doc = "Control whether axes tick marks project \"in\" to the plot \ -box or \"out\". __modemsg__."; +box or \"out\". The value \"none\" means no tick marks will be drawn, \ +although tick labels will still be rendered. __modemsg__."; case "tickdirmode"
--- a/etc/NEWS.9.md Sun Jun 11 21:32:21 2023 -0700 +++ b/etc/NEWS.9.md Mon Jun 12 14:18:08 2023 -0700 @@ -45,6 +45,9 @@ state the resulting value is now displayed in the Command Window for informational purposes. +* The axes graphics property "TickDir" now accepts the option "none" which +will not draw tick marks, but will still draw tick labels. + ### Matlab compatibility - The `inputParser` function now implements the `PartialMatching` property
--- a/libinterp/corefcn/gl-render.cc Sun Jun 11 21:32:21 2023 -0700 +++ b/libinterp/corefcn/gl-render.cc Mon Jun 12 14:18:08 2023 -0700 @@ -1586,7 +1586,8 @@ // X ticks and grid properties Matrix xticks = m_xform.xscale (props.get_xtick ().matrix_value ()); Matrix xmticks = m_xform.xscale (props.get_xminortickvalues ().matrix_value ()); - bool do_xminortick = props.is_xminortick () && ! xticks.isempty (); + bool do_xtick = ! props.tickdir_is ("none") && ! xticks.isempty (); + bool do_xminortick = do_xtick && props.is_xminortick (); string_vector xticklabels = props.get_xticklabel ().string_vector_value (); int wmax = 0; int hmax = 0; @@ -1687,20 +1688,23 @@ } // tick marks - if (tick_along_z) - render_tickmarks (xticks, x_min, x_max, - is_origin ? y_axis_pos : ypTick, ypTick, - zpTick, zpTickN, 0., 0., - (is_origin_low ? -1. : 1.) * - math::signum (zpTick-zpTickN)*fz*xticklen, - 0, ! is_origin && mirror); - else - render_tickmarks (xticks, x_min, x_max, - is_origin ? y_axis_pos : ypTick, ypTickN, - zpTick, zpTick, 0., - (is_origin_low ? -1. : 1.) * - math::signum (ypTick-ypTickN)*fy*xticklen, - 0., 0, ! is_origin && mirror); + if (do_xtick) + { + if (tick_along_z) + render_tickmarks (xticks, x_min, x_max, + is_origin ? y_axis_pos : ypTick, ypTick, + zpTick, zpTickN, 0., 0., + (is_origin_low ? -1. : 1.) * + math::signum (zpTick-zpTickN)*fz*xticklen, + 0, ! is_origin && mirror); + else + render_tickmarks (xticks, x_min, x_max, + is_origin ? y_axis_pos : ypTick, ypTickN, + zpTick, zpTick, 0., + (is_origin_low ? -1. : 1.) * + math::signum (ypTick-ypTickN)*fy*xticklen, + 0., 0, ! is_origin && mirror); + } // tick texts if (xticklabels.numel () > 0) @@ -1782,7 +1786,8 @@ // Y ticks and grid properties Matrix yticks = m_xform.yscale (props.get_ytick ().matrix_value ()); Matrix ymticks = m_xform.yscale (props.get_yminortickvalues ().matrix_value ()); - bool do_yminortick = props.is_yminortick () && ! yticks.isempty (); + bool do_ytick = ! props.tickdir_is ("none") && ! yticks.isempty (); + bool do_yminortick = do_ytick && props.is_yminortick (); string_vector yticklabels = props.get_yticklabel ().string_vector_value (); int wmax = 0; int hmax = 0; @@ -1884,20 +1889,23 @@ } // tick marks - if (tick_along_z) - render_tickmarks (yticks, y_min, y_max, - is_origin ? x_axis_pos : xpTick, xpTick, - zpTick, zpTickN, 0., 0., - (is_origin_low ? -1. : 1.) * - math::signum (zpTick-zpTickN)*fz*yticklen, - 1, ! is_origin && mirror); - else - render_tickmarks (yticks, y_min, y_max, - is_origin ? x_axis_pos : xpTick, xpTickN, - zpTick, zpTick, - (is_origin_low ? -1. : 1.) * - math::signum (xPlaneN-xPlane)*fx*yticklen, - 0., 0., 1, ! is_origin && mirror); + if (do_ytick) + { + if (tick_along_z) + render_tickmarks (yticks, y_min, y_max, + is_origin ? x_axis_pos : xpTick, xpTick, + zpTick, zpTickN, 0., 0., + (is_origin_low ? -1. : 1.) * + math::signum (zpTick-zpTickN)*fz*yticklen, + 1, ! is_origin && mirror); + else + render_tickmarks (yticks, y_min, y_max, + is_origin ? x_axis_pos : xpTick, xpTickN, + zpTick, zpTick, + (is_origin_low ? -1. : 1.) * + math::signum (xPlaneN-xPlane)*fx*yticklen, + 0., 0., 1, ! is_origin && mirror); + } // tick texts if (yticklabels.numel () > 0) @@ -1968,7 +1976,8 @@ // Z ticks and grid properties Matrix zticks = m_xform.zscale (props.get_ztick ().matrix_value ()); Matrix zmticks = m_xform.zscale (props.get_zminortickvalues ().matrix_value ()); - bool do_zminortick = props.is_zminortick () && ! zticks.isempty (); + bool do_ztick = ! props.tickdir_is ("none") && ! zticks.isempty (); + bool do_zminortick = do_ztick && props.is_zminortick (); string_vector zticklabels = props.get_zticklabel ().string_vector_value (); int wmax = 0; int hmax = 0; @@ -2063,31 +2072,34 @@ } // tick marks - if (xySym) + if (do_ztick) { - if (math::isinf (fy)) - render_tickmarks (zticks, z_min, z_max, xPlaneN, xPlane, - yPlane, yPlane, - math::signum (xPlaneN-xPlane)*fx*zticklen, - 0., 0., 2, mirror); + if (xySym) + { + if (math::isinf (fy)) + render_tickmarks (zticks, z_min, z_max, xPlaneN, xPlane, + yPlane, yPlane, + math::signum (xPlaneN-xPlane)*fx*zticklen, + 0., 0., 2, mirror); + else + render_tickmarks (zticks, z_min, z_max, xPlaneN, xPlaneN, + yPlane, yPlane, 0., + math::signum (yPlane-yPlaneN)*fy*zticklen, + 0., 2, false); + } else - render_tickmarks (zticks, z_min, z_max, xPlaneN, xPlaneN, - yPlane, yPlane, 0., - math::signum (yPlane-yPlaneN)*fy*zticklen, - 0., 2, false); - } - else - { - if (math::isinf (fx)) - render_tickmarks (zticks, z_min, z_max, xPlaneN, xPlane, - yPlaneN, yPlane, 0., - math::signum (yPlaneN-yPlane)*fy*zticklen, - 0., 2, mirror); - else - render_tickmarks (zticks, z_min, z_max, xPlane, xPlane, - yPlaneN, yPlane, - math::signum (xPlane-xPlaneN)*fx*zticklen, - 0., 0., 2, false); + { + if (math::isinf (fx)) + render_tickmarks (zticks, z_min, z_max, xPlaneN, xPlane, + yPlaneN, yPlane, 0., + math::signum (yPlaneN-yPlane)*fy*zticklen, + 0., 2, mirror); + else + render_tickmarks (zticks, z_min, z_max, xPlane, xPlane, + yPlaneN, yPlane, + math::signum (xPlane-xPlaneN)*fx*zticklen, + 0., 0., 2, false); + } } // tick texts
--- a/libinterp/corefcn/graphics.cc Sun Jun 11 21:32:21 2023 -0700 +++ b/libinterp/corefcn/graphics.cc Mon Jun 12 14:18:08 2023 -0700 @@ -5978,7 +5978,16 @@ if (tickdirmode_is ("auto")) m_tickdir.set (mode2D ? "in" : "out", true); - double ticksign = (tickdir_is ("in") ? -1 : 1); + double ticksign; + std::string tickdir = get_tickdir (); + if (tickdir == "in") + ticksign = -1; + else if (tickdir == "out") + ticksign = 1; + else if (tickdir == "both") + ticksign = 2; + else // tickdir == "none" + ticksign = 0; Matrix bbox = get_boundingbox (true); Matrix ticklen = get_ticklength ().matrix_value ();
--- a/libinterp/corefcn/graphics.in.h Sun Jun 11 21:32:21 2023 -0700 +++ b/libinterp/corefcn/graphics.in.h Mon Jun 12 14:18:08 2023 -0700 @@ -3863,7 +3863,7 @@ radio_property positionconstraint , "{outerposition}|innerposition" radio_property projection , "{orthographic}|perspective" radio_property sortmethod , "{depth}|childorder" - radio_property tickdir mu , "{in}|out" + radio_property tickdir mu , "{in}|out|both|none" radio_property tickdirmode u , "{auto}|manual" // FIXME: Added recently to Matlab, should replace interpreter property. radio_property ticklabelinterpreter u , "{tex}|latex|none"