Mercurial > hg > octave-lyh
comparison libinterp/interp-core/gl-render.cc @ 16855:359ac80ecb30
Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
* libinterp/interp-core/gl-render.cc(render_ticktexts): Trim spaces from labels.
Use % operator to repeat labels as necessary to fill number of ticks.
* libinterp/interpfcn/graphics.cc(get_ticklabel_extents): Trim spaces from labels
before calculating extent of text.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 26 Jun 2013 15:49:57 -0700 |
parents | 049e8bbff782 |
children |
comparison
equal
deleted
inserted
replaced
16854:563f8f0a7e29 | 16855:359ac80ecb30 |
---|---|
752 double lim1, double lim2, | 752 double lim1, double lim2, |
753 double p1, double p2, | 753 double p1, double p2, |
754 int xyz, int ha, int va, | 754 int xyz, int ha, int va, |
755 int& wmax, int& hmax) | 755 int& wmax, int& hmax) |
756 { | 756 { |
757 int n = std::min (ticklabels.numel (), ticks.numel ()); | 757 int nticks = ticks.numel (); |
758 | 758 int nlabels = ticklabels.numel (); |
759 for (int i = 0; i < n; i++) | 759 |
760 if (nlabels == 0) | |
761 return; | |
762 | |
763 for (int i = 0; i < nticks; i++) | |
760 { | 764 { |
761 double val = ticks(i); | 765 double val = ticks(i); |
762 | 766 |
763 if (lim1 <= val && val <= lim2) | 767 if (lim1 <= val && val <= lim2) |
764 { | 768 { |
765 Matrix b; | 769 Matrix b; |
766 // FIXME: as tick text is transparent, shouldn't be | 770 |
771 std::string label (ticklabels(i % nlabels)); | |
772 label.erase (0, label.find_first_not_of (" ")); | |
773 label = label.substr (0, label.find_last_not_of (" ")+1); | |
774 | |
775 // FIXME: as tick text is transparent, shouldn't it be | |
767 // drawn after axes object, for correct rendering? | 776 // drawn after axes object, for correct rendering? |
768 if (xyz == 0) // X | 777 if (xyz == 0) // X |
769 { | 778 { |
770 b = render_text (ticklabels(i), val, p1, p2, ha, va); | 779 b = render_text (label, val, p1, p2, ha, va); |
771 } | 780 } |
772 else if (xyz == 1) // Y | 781 else if (xyz == 1) // Y |
773 { | 782 { |
774 b = render_text (ticklabels(i), p1, val, p2, ha, va); | 783 b = render_text (label, p1, val, p2, ha, va); |
775 } | 784 } |
776 else if (xyz == 2) // Z | 785 else if (xyz == 2) // Z |
777 { | 786 { |
778 b = render_text (ticklabels(i), p1, p2, val, ha, va); | 787 b = render_text (label, p1, p2, val, ha, va); |
779 } | 788 } |
780 | 789 |
781 wmax = std::max (wmax, static_cast<int> (b(2))); | 790 wmax = std::max (wmax, static_cast<int> (b(2))); |
782 hmax = std::max (hmax, static_cast<int> (b(3))); | 791 hmax = std::max (hmax, static_cast<int> (b(3))); |
783 } | 792 } |