Mercurial > octave
diff libinterp/corefcn/graphics.in.h @ 25966:d85049849e88
improve plot position updates (bug #48273)
* graphics.cc (axes::properties::update_outerposition,
axes::properties::update_position,
axes::properties::update_looseinset): Move here from graphics.in.h.
Use intermediate variables in an attempt to improve clarity. Impose
limits on position to avoid generating bounding boxes with negative
widths.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 25 Oct 2018 16:08:49 -0400 |
parents | ae9d6a491c06 |
children | 63b3d5e4e5c3 |
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.in.h Wed Oct 24 15:20:43 2018 -0700 +++ b/libinterp/corefcn/graphics.in.h Thu Oct 25 16:08:49 2018 -0400 @@ -3999,85 +3999,9 @@ sync_positions (); } - void update_outerposition (void) - { - set_activepositionproperty ("outerposition"); - caseless_str old_units = get_units (); - set_units ("normalized"); - Matrix outerbox = outerposition.get ().matrix_value (); - Matrix innerbox = position.get ().matrix_value (); - Matrix linset = looseinset.get ().matrix_value (); - Matrix tinset = tightinset.get ().matrix_value (); - outerbox(2) = outerbox(2) + outerbox(0); - outerbox(3) = outerbox(3) + outerbox(1); - innerbox(0) = outerbox(0) + std::max (linset(0), tinset(0)); - innerbox(1) = outerbox(1) + std::max (linset(1), tinset(1)); - innerbox(2) = outerbox(2) - std::max (linset(2), tinset(2)); - innerbox(3) = outerbox(3) - std::max (linset(3), tinset(3)); - innerbox(2) = innerbox(2) - innerbox(0); - innerbox(3) = innerbox(3) - innerbox(1); - position = innerbox; - set_units (old_units); - update_transform (); - } - - void update_position (void) - { - set_activepositionproperty ("position"); - caseless_str old_units = get_units (); - set_units ("normalized"); - Matrix outerbox = outerposition.get ().matrix_value (); - Matrix innerbox = position.get ().matrix_value (); - Matrix linset = looseinset.get ().matrix_value (); - Matrix tinset = tightinset.get ().matrix_value (); - innerbox(2) = innerbox(2) + innerbox(0); - innerbox(3) = innerbox(3) + innerbox(1); - outerbox(0) = innerbox(0) - std::max (linset(0), tinset(0)); - outerbox(1) = innerbox(1) - std::max (linset(1), tinset(1)); - outerbox(2) = innerbox(2) + std::max (linset(2), tinset(2)); - outerbox(3) = innerbox(3) + std::max (linset(3), tinset(3)); - outerbox(2) = outerbox(2) - outerbox(0); - outerbox(3) = outerbox(3) - outerbox(1); - outerposition = outerbox; - set_units (old_units); - update_transform (); - } - - void update_looseinset (void) - { - caseless_str old_units = get_units (); - set_units ("normalized"); - Matrix innerbox = position.get ().matrix_value (); - innerbox(2) = innerbox(2) + innerbox(0); - innerbox(3) = innerbox(3) + innerbox(1); - Matrix outerbox = outerposition.get ().matrix_value (); - outerbox(2) = outerbox(2) + outerbox(0); - outerbox(3) = outerbox(3) + outerbox(1); - Matrix linset = looseinset.get ().matrix_value (); - Matrix tinset = tightinset.get ().matrix_value (); - if (activepositionproperty.is ("position")) - { - outerbox(0) = innerbox(0) - std::max (linset(0), tinset(0)); - outerbox(1) = innerbox(1) - std::max (linset(1), tinset(1)); - outerbox(2) = innerbox(2) + std::max (linset(2), tinset(2)); - outerbox(3) = innerbox(3) + std::max (linset(3), tinset(3)); - outerbox(2) = outerbox(2) - outerbox(0); - outerbox(3) = outerbox(3) - outerbox(1); - outerposition = outerbox; - } - else - { - innerbox(0) = outerbox(0) + std::max (linset(0), tinset(0)); - innerbox(1) = outerbox(1) + std::max (linset(1), tinset(1)); - innerbox(2) = outerbox(2) - std::max (linset(2), tinset(2)); - innerbox(3) = outerbox(3) - std::max (linset(3), tinset(3)); - innerbox(2) = innerbox(2) - innerbox(0); - innerbox(3) = innerbox(3) - innerbox(1); - position = innerbox; - } - set_units (old_units); - update_transform (); - } + void update_outerposition (void); + void update_position (void); + void update_looseinset (void); double calc_tick_sep (double minval, double maxval); void calc_ticks_and_lims (array_property& lims, array_property& ticks,