Summary: | supression of axes can cause axis numbers to be cut off | ||
---|---|---|---|
Product: | [Applications] kst | Reporter: | Matthew Truch <matt> |
Component: | general | Assignee: | kst |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | 1.x | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | kst exported png showing axis numbers cut off |
Description
Matthew Truch
2005-08-21 03:19:02 UTC
Created attachment 12291 [details]
kst exported png showing axis numbers cut off
A png showing some of the axis numbers being partially cut off when axis
supression is turned on. Specifically the 2.005 on T_m3 and the 1.905 on T_m4
are nearly cut in half. Also the 1.88 of T_m4 is 'dangerously close' to the
3.85 of T_lhe_filt.
SVN commit 482138 by arwalker: BUG:111178 Prevent labels from overlapping when axis suppression is used. At present this only applies for non-rotated labels. This also fixes a bug in the border positions for some cases. M +55 -34 kst2dplot.cpp --- trunk/extragear/graphics/kst/kst/kst2dplot.cpp #482137:482138 @@ -1917,7 +1917,7 @@ // calculate the top border if (_suppressTop) { - ytop_bdr_px = 0; + ytop_bdr_px = 0.0; } else { ytop_bdr_px = 1.1 * _topLabel->size().height(); // height include super/subscripts @@ -1926,14 +1926,14 @@ ytop_bdr_px += tpx.oppMaxHeight; } - if (ytop_bdr_px < 1) { + if (ytop_bdr_px < 1.0) { ytop_bdr_px = 0.5 * _xTickLabel->lineSpacing(); } } // calculate the bottom border if (_suppressBottom) { - ybot_bdr_px = 0; + ybot_bdr_px = 0.0; } else { ybot_bdr_px = tpx.maxHeight; ybot_bdr_px += _xLabel->lineSpacing(); @@ -1943,19 +1943,19 @@ genAxisTickLabels(tpy, y_min, y_max, _yLog, _yAxisInterpretation, _yAxisDisplay, false, _isYAxisInterpreted, _yOffsetMode); if (_suppressLeft) { - xleft_bdr_px = 0; + xleft_bdr_px = 0.0; } else { xleft_bdr_px = tpy.maxWidth; - xleft_bdr_px += 5 * _yLabel->lineSpacing() / 4; - xleft_bdr_px += _yTickLabel->lineSpacing() / 4; + xleft_bdr_px += 5.0 * _yLabel->lineSpacing() / 4.0; + xleft_bdr_px += _yTickLabel->lineSpacing() / 4.0; //printf("mw: %g yls: %d lfls: %d xlbp: %g\n", tpy.maxWidth, _yLabel->lineSpacing(), _tickLabel->lineSpacing(), xleft_bdr_px); } // calculate the right border if (_suppressRight) { - xright_bdr_px = 0; + xright_bdr_px = 0.0; } else { - xright_bdr_px = x_px / 30; + xright_bdr_px = x_px / 30.0; // if right axis is transformed, leave space for the numbers if (_yTransformed) { xright_bdr_px += tpy.oppMaxWidth; @@ -2019,6 +2019,19 @@ xright_bdr_px += 2.0 * ytick_len_px; } + if (_suppressLeft) { + xleft_bdr_px = 0.0; + } + if (_suppressRight) { + xright_bdr_px = 0.0; + } + if (_suppressTop) { + ytop_bdr_px = 0.0; + } + if (_suppressBottom) { + ybot_bdr_px = 0.0; + } + // round off all the border values xleft_bdr_px = ceil(xleft_bdr_px); xright_bdr_px = ceil(xright_bdr_px); @@ -5496,43 +5509,46 @@ xTickPos = x_px - xright_bdr_px - (xTickPos - xleft_bdr_px); } + p.save(); _xTickLabel->setText(tpx.labels[i - tpx.iLo]); if (_xTickLabel->rotation() == 0) { - p.save(); - p.translate(d2i(xTickPos) - _xTickLabel->size().width() / 2, yTickPos); - _xTickLabel->paint(p); - p.restore(); + if (!((_suppressLeft && d2i(xTickPos) - _xTickLabel->size().width() / 2 < xleft_bdr_px ) || + (_suppressRight && d2i(xTickPos) - _xTickLabel->size().width() / 2 > x_px - xright_bdr_px ) ) ) { + p.translate(d2i(xTickPos) - _xTickLabel->size().width() / 2, yTickPos); + _xTickLabel->paint(p); + } } else if (_xTickLabel->rotation() > 0) { - p.save(); p.translate(xTickPos-0.5*_xTickLabel->lineSpacing()*sin(_xTickLabel->rotation()*M_PI/180.0), yTickPos); _xTickLabel->paint(p); - p.restore(); } else if (_xTickLabel->rotation() < 0) { - p.save(); p.translate(xTickPos - _xTickLabel->size().width()-0.5*_xTickLabel->lineSpacing()*sin(_xTickLabel->rotation()*M_PI/180.0), yTickPos); _xTickLabel->paint(p); - p.restore(); } + p.restore(); } } // if top axis is transformed, plot top axis numbers as well // FIXME: inefficient. We keep reparsing and re-rendering tpx.oppLabels[.] if (_xTransformed && !_suppressTop) { + double xTickPos; int yTopTickPos = d2i(ytop_bdr_px); if (xTicksOutPlot()) { yTopTickPos -= d2i(2.0 * xtick_len_px); } for (i = tpx.iLo; i < tpx.iHi; i++) { - double xTickPos = x_orig_px + (double)i * xtick_px; + xTickPos = x_orig_px + (double)i * xtick_px; if (_xReversed) { xTickPos = x_px - xright_bdr_px - (xTickPos - xleft_bdr_px); } _xTickLabel->setText(tpx.oppLabels[i - tpx.iLo]); - p.save(); - p.translate(d2i(xTickPos) - _xTickLabel->size().width() / 2, yTopTickPos - _xTickLabel->size().height()); - _xTickLabel->paint(p); - p.restore(); + if (!((_suppressLeft && d2i(xTickPos) - _xTickLabel->size().width() / 2 < xleft_bdr_px ) || + (_suppressRight && d2i(xTickPos) - _xTickLabel->size().width() / 2 > x_px - xright_bdr_px ) ) ) { + p.save(); + p.translate(d2i(xTickPos) - _xTickLabel->size().width() / 2, yTopTickPos - _xTickLabel->size().height()); + _xTickLabel->paint(p); + p.restore(); + } } } @@ -5562,41 +5578,46 @@ yTickPos = y_px - ybot_bdr_px - (yTickPos - ytop_bdr_px); } _yTickLabel->setText(tpy.labels[i - tpy.iLo]); + p.save(); - if (_yTickLabel->rotation() == 0 || _yTickLabel->rotation() <-89 || _yTickLabel->rotation() > 89) { - p.translate(xTickPos - _yTickLabel->size().width(), d2i(yTickPos) - _yTickLabel->size().height() / 2); - _yTickLabel->paint(p); - p.restore(); + if (!((_suppressBottom && d2i(yTickPos) + _yTickLabel->size().height() / 2 > y_px - ybot_bdr_px ) || + (_suppressTop && d2i(yTickPos) - _yTickLabel->size().height() / 2 < ytop_bdr_px ) ) ) { + p.translate(d2i(xTickPos) - _yTickLabel->size().width(), d2i(yTickPos) - _yTickLabel->size().height() / 2); + _yTickLabel->paint(p); + } } else if (_yTickLabel->rotation() < 0) { - p.translate(xTickPos - _yTickLabel->size().width(), d2i(yTickPos) - _yTickLabel->lineSpacing()/2); + p.translate(d2i(xTickPos) - _yTickLabel->size().width(), d2i(yTickPos) - _yTickLabel->lineSpacing()/2); _yTickLabel->paint(p); - p.restore(); } else if (_yTickLabel->rotation() > 0) { - p.translate(xTickPos - _yTickLabel->size().width(), d2i(yTickPos) - _yTickLabel->size().height() + _yTickLabel->lineSpacing()/2); + p.translate(d2i(xTickPos) - _yTickLabel->size().width(), d2i(yTickPos) - _yTickLabel->size().height() + _yTickLabel->lineSpacing()/2); _yTickLabel->paint(p); - p.restore(); } + p.restore(); } } // if right axis is transformed, plot right axis numbers as well if (_yTransformed && !_suppressRight) { + double yTickPos; int xTopTickPos = d2i(x_px - xright_bdr_px + _yTickLabel->lineSpacing()*0.15); if (yTicksOutPlot()) { xTopTickPos += d2i(2.0 * ytick_len_px); } // FIXME: inefficient. We keep reparsing and re-rendering tpy.oppLabels[.] for (i = tpy.iLo; i < tpy.iHi; i++) { - double yTickPos = y_orig_px - (double)i * ytick_px; + yTickPos = y_orig_px - (double)i * ytick_px; if (_yReversed) { yTickPos = y_px - ybot_bdr_px - (yTickPos - ytop_bdr_px); } _yTickLabel->setText(tpy.oppLabels[i - tpy.iLo]); - p.save(); - p.translate(xTopTickPos, d2i(yTickPos) - _yTickLabel->size().height() / 2); - _yTickLabel->paint(p); - p.restore(); + if (!((_suppressBottom && d2i(yTickPos) + _yTickLabel->size().height() / 2 > y_px - ybot_bdr_px ) || + (_suppressTop && d2i(yTickPos) - _yTickLabel->size().height() / 2 < ytop_bdr_px ) ) ) { + p.save(); + p.translate(xTopTickPos, d2i(yTickPos) - _yTickLabel->size().height() / 2); + _yTickLabel->paint(p); + p.restore(); + } } } } |