Mercurial > hg > octave-lyh
changeset 14391:c9ec21bef97a
Fix ticklength updating (bug # 35438).
* graphics.cc: (axes::properties::update_ticklengths): include ticklength
property value.
* graphics.cc, graphics.h.in: Change update_ticklengths to update_ticklength.
* graphics.h.in: Add "u" qualifier to axes ticklength property.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Wed, 22 Feb 2012 20:06:05 -0500 |
parents | 1928af0f641b |
children | d17237256856 |
files | src/graphics.cc src/graphics.h.in |
diffstat | 2 files changed, 34 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -4933,11 +4933,11 @@ Matrix viewmat = get_view ().matrix_value (); nearhoriz = std::abs(viewmat(1)) <= 5; - update_ticklengths (); -} - -void -axes::properties::update_ticklengths (void) + update_ticklength (); +} + +void +axes::properties::update_ticklength (void) { bool mode2d = (((xstate > AXE_DEPTH_DIR ? 1 : 0) + (ystate > AXE_DEPTH_DIR ? 1 : 0) + @@ -4955,10 +4955,15 @@ double ticksign = (tickdirmode_is ("auto") ? (mode2d ? -1 : 1) : (tickdir_is ("in") ? -1 : 1)); - // FIXME: use ticklength property - xticklen = ticksign*7; - yticklen = ticksign*7; - zticklen = ticksign*7; + + Matrix bbox = get_boundingbox (true); + Matrix ticklen = get_ticklength ().matrix_value (); + ticklen(0) = ticklen(0) * std::max (bbox(2), bbox(3)); + ticklen(1) = ticklen(1) * std::max (bbox(2), bbox(3)); + + xticklen = ticksign * (mode2d ? ticklen(0) : ticklen(1)); + yticklen = ticksign * (mode2d ? ticklen(0) : ticklen(1)); + zticklen = ticksign * (mode2d ? ticklen(0) : ticklen(1)); xtickoffset = (mode2d ? std::max (0., xticklen) : std::abs (xticklen)) + 5; ytickoffset = (mode2d ? std::max (0., yticklen) : std::abs (yticklen)) + 5; @@ -4970,6 +4975,22 @@ update_title_position (); } +/* +%!demo +%! clf +%! subplot (2, 1, 1) +%! plot (rand (3)) +%! xlabel xlabel +%! ylabel ylabel +%! title title +%! subplot (2, 1, 2) +%! plot (rand (3)) +%! set (gca, "ticklength", get (gca, "ticklength") * 2, "tickdir", "out") +%! xlabel xlabel +%! ylabel ylabel +%! title title +*/ + static bool updating_xlabel_position = false; void
--- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -3824,7 +3824,7 @@ radio_property projection , "{orthographic}|perpective" radio_property tickdir mu , "{in}|out" radio_property tickdirmode u , "{auto}|manual" - array_property ticklength , default_axes_ticklength () + array_property ticklength u , default_axes_ticklength () array_property tightinset r , Matrix (1, 4, 0.0) // FIXME -- uicontextmenu should be moved here. radio_property units SU , "{normalized}|inches|centimeters|points|pixels|characters" @@ -3897,9 +3897,9 @@ void update_ydir (void) { update_camera (); update_axes_layout (); } void update_zdir (void) { update_camera (); update_axes_layout (); } - void update_ticklengths (void); - void update_tickdir (void) { update_ticklengths (); } - void update_tickdirmode (void) { update_ticklengths (); } + void update_ticklength (void); + void update_tickdir (void) { update_ticklength (); } + void update_tickdirmode (void) { update_ticklength (); } void update_xtick (void) {