mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-25 10:01:38 +08:00
partly fixed issue #99: for horizontal axes, additional space at the left and/or right of the plot is allowed so labels are no longer clipped (thanks to user:allenbarnett5 for reporting)
This commit is contained in:
parent
3bd49100fe
commit
22d8bdd674
@ -39,6 +39,7 @@ Changes, compared to \ref page_whatsnew_V4_0_0 "v4.0.0" include:
|
|||||||
<li>FIXED: fixes strange rendering with distortions (especially in text!), by correcting size calculation of internal image buffer</li>
|
<li>FIXED: fixes strange rendering with distortions (especially in text!), by correcting size calculation of internal image buffer</li>
|
||||||
<li>FIXED: exporting gridPrinting plots when using only a JKQTBasePlotter</li>
|
<li>FIXED: exporting gridPrinting plots when using only a JKQTBasePlotter</li>
|
||||||
<li>FIXED: fixed impleentations of JKQTPlotter::beginGraphs(), which actually returned the end-iterator (COPY-PASTE-ERROR!!!)</li>
|
<li>FIXED: fixed impleentations of JKQTPlotter::beginGraphs(), which actually returned the end-iterator (COPY-PASTE-ERROR!!!)</li>
|
||||||
|
<li>partly FIXED issue <a href="https://github.com/jkriege2/JKQtPlotter/pull/99">#99: Clipping of Tick Labels</a>: for horizontal axes, additional space at the left and/or right of the plot is allowed so labels are no longer clipped (thanks to <a href="https://github.com/allenbarnett5">user:allenbarnett5/a> for reporting)</li>
|
||||||
<li>FIXED/NEW: placement of plot-title (was not centerd in its box, but glued to the bottom) by adding a plotstyle parameter JKQTBasePlotterStyle::plotLabelOffset</li>
|
<li>FIXED/NEW: placement of plot-title (was not centerd in its box, but glued to the bottom) by adding a plotstyle parameter JKQTBasePlotterStyle::plotLabelOffset</li>
|
||||||
<li>REORGANIZED: separated line-graphs from jkqtpscatter.h/.cpp into jkqtplines.h/.cpp</li>
|
<li>REORGANIZED: separated line-graphs from jkqtpscatter.h/.cpp into jkqtplines.h/.cpp</li>
|
||||||
<li>IMPROVED: QT6-compatibility by removing deprecated warnings</li>
|
<li>IMPROVED: QT6-compatibility by removing deprecated warnings</li>
|
||||||
|
@ -874,8 +874,12 @@ void JKQTBasePlotter::calcPlotScaling(JKQTPEnhancedPainter& painter){
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
// read additional size required for coordinate axes
|
// read additional size required for coordinate axes
|
||||||
QSizeF s=xAxis->getSize1(painter);
|
double elongateLeft=0,elongateRight=0;
|
||||||
|
double elongateMin=0,elongateMax=0;
|
||||||
|
QSizeF s=xAxis->getSize1(painter, &elongateMin, &elongateMax);
|
||||||
internalPlotBorderBottom+=s.height();
|
internalPlotBorderBottom+=s.height();
|
||||||
|
if (elongateMin>0) elongateLeft=qMax(elongateLeft,elongateMin);
|
||||||
|
if (elongateMax>0) elongateRight=qMax(elongateRight,elongateMax);
|
||||||
s=xAxis->getSize2(painter);
|
s=xAxis->getSize2(painter);
|
||||||
internalPlotBorderTop+=s.height();
|
internalPlotBorderTop+=s.height();
|
||||||
|
|
||||||
@ -900,6 +904,9 @@ void JKQTBasePlotter::calcPlotScaling(JKQTPEnhancedPainter& painter){
|
|||||||
internalPlotBorderTop+=ax->getSize2(painter).height()+plotterStyle.secondaryAxisSeparation;
|
internalPlotBorderTop+=ax->getSize2(painter).height()+plotterStyle.secondaryAxisSeparation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (internalPlotBorderRight<elongateRight) internalPlotBorderRight=elongateRight;
|
||||||
|
if (internalPlotBorderLeft<elongateLeft) internalPlotBorderLeft=elongateLeft;
|
||||||
|
|
||||||
internalPlotBorderTop_notIncludingOutsidePlotSections=internalPlotBorderTop;
|
internalPlotBorderTop_notIncludingOutsidePlotSections=internalPlotBorderTop;
|
||||||
internalPlotBorderLeft_notIncludingOutsidePlotSections=internalPlotBorderLeft;
|
internalPlotBorderLeft_notIncludingOutsidePlotSections=internalPlotBorderLeft;
|
||||||
internalPlotBorderBottom_notIncludingOutsidePlotSections=internalPlotBorderBottom;
|
internalPlotBorderBottom_notIncludingOutsidePlotSections=internalPlotBorderBottom;
|
||||||
|
@ -1332,7 +1332,7 @@ std::pair<QSizeF,QSizeF> JKQTPVerticalAxisBase::getSize0(JKQTPEnhancedPainter& p
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QSizeF JKQTPVerticalAxisBase::getSize1(JKQTPEnhancedPainter& painter) {
|
QSizeF JKQTPVerticalAxisBase::getSize1(JKQTPEnhancedPainter& painter, double* elongateBottom, double *elongateTop) {
|
||||||
if (axisStyle.drawMode1==JKQTPCADMnone) return QSize(0,0);
|
if (axisStyle.drawMode1==JKQTPCADMnone) return QSize(0,0);
|
||||||
double ptwidth=axisStyle.axisLineOffset;
|
double ptwidth=axisStyle.axisLineOffset;
|
||||||
const double arrowSize=((axisStyle.drawMode1&(JKQTPCADMMinArrow|JKQTPCADMMinFilledArrow|JKQTPCADMMaxArrow|JKQTPCADMMaxFilledArrow))!=int(0))?(axisStyle.getArrowSize(painter, parent)/2.0):0.0;
|
const double arrowSize=((axisStyle.drawMode1&(JKQTPCADMMinArrow|JKQTPCADMMinFilledArrow|JKQTPCADMMaxArrow|JKQTPCADMMaxFilledArrow))!=int(0))?(axisStyle.getArrowSize(painter, parent)/2.0):0.0;
|
||||||
@ -2070,7 +2070,7 @@ std::pair<QSizeF,QSizeF> JKQTPHorizontalAxisBase::getSize0(JKQTPEnhancedPainter&
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF JKQTPHorizontalAxisBase::getSize1(JKQTPEnhancedPainter& painter) {
|
QSizeF JKQTPHorizontalAxisBase::getSize1(JKQTPEnhancedPainter& painter, double *elongateLeft, double *elongateRight) {
|
||||||
if (axisStyle.drawMode1==JKQTPCADMnone) return QSize(0,0);
|
if (axisStyle.drawMode1==JKQTPCADMnone) return QSize(0,0);
|
||||||
double ptheight=axisStyle.axisLineOffset;
|
double ptheight=axisStyle.axisLineOffset;
|
||||||
const double arrowSize=((axisStyle.drawMode1&(JKQTPCADMMinArrow|JKQTPCADMMinFilledArrow|JKQTPCADMMaxArrow|JKQTPCADMMaxFilledArrow))!=int(0))?(axisStyle.getArrowSize(painter, parent)/2.0):0.0;
|
const double arrowSize=((axisStyle.drawMode1&(JKQTPCADMMinArrow|JKQTPCADMMinFilledArrow|JKQTPCADMMaxArrow|JKQTPCADMMaxFilledArrow))!=int(0))?(axisStyle.getArrowSize(painter, parent)/2.0):0.0;
|
||||||
@ -2079,7 +2079,20 @@ QSizeF JKQTPHorizontalAxisBase::getSize1(JKQTPEnhancedPainter& painter) {
|
|||||||
if (axisStyle.drawMode1.testFlag(JKQTPCADMTickLabels)) {
|
if (axisStyle.drawMode1.testFlag(JKQTPCADMTickLabels)) {
|
||||||
ptheight+=axisStyle.tickLabelDistance;
|
ptheight+=axisStyle.tickLabelDistance;
|
||||||
// find out the maximum width over all visible plot labels
|
// find out the maximum width over all visible plot labels
|
||||||
labheight+=getMaxTickLabelSize(painter).height();
|
const QSizeF maxLabelSize=getMaxTickLabelSize(painter);
|
||||||
|
if (elongateLeft) {
|
||||||
|
if (getTickLabelAngle()<-0.0000001)
|
||||||
|
*elongateLeft=maxLabelSize.width();
|
||||||
|
else if (getTickLabelAngle()<0.0000001)
|
||||||
|
*elongateLeft=maxLabelSize.width()/2.0;
|
||||||
|
}
|
||||||
|
if (elongateRight) {
|
||||||
|
if (getTickLabelAngle()>0.0000001)
|
||||||
|
*elongateRight=maxLabelSize.width();
|
||||||
|
else if (getTickLabelAngle()>-0.0000001)
|
||||||
|
*elongateRight=maxLabelSize.width()/2.0;
|
||||||
|
}
|
||||||
|
labheight+=maxLabelSize.height();
|
||||||
}
|
}
|
||||||
if (axisStyle.drawMode1.testFlag(JKQTPCADMAxisLabel)) {
|
if (axisStyle.drawMode1.testFlag(JKQTPCADMAxisLabel)) {
|
||||||
ptheight+=axisStyle.labelDistance;
|
ptheight+=axisStyle.labelDistance;
|
||||||
|
@ -246,7 +246,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPCoordinateAxis: public QObject {
|
|||||||
void addAxisTickLabels(const double* x, const QString* label, int items);
|
void addAxisTickLabels(const double* x, const QString* label, int items);
|
||||||
|
|
||||||
/** \brief returns the size of the left/bottom axis in pixels */
|
/** \brief returns the size of the left/bottom axis in pixels */
|
||||||
virtual QSizeF getSize1(JKQTPEnhancedPainter& painter)=0;
|
virtual QSizeF getSize1(JKQTPEnhancedPainter& painter, double* elongateMin=nullptr, double* elongateMax=nullptr)=0;
|
||||||
|
|
||||||
/** \brief returns the size of the right/top axis in pixels */
|
/** \brief returns the size of the right/top axis in pixels */
|
||||||
virtual QSizeF getSize2(JKQTPEnhancedPainter& painter)=0;
|
virtual QSizeF getSize2(JKQTPEnhancedPainter& painter)=0;
|
||||||
@ -900,7 +900,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPVerticalAxisBase: public JKQTPCoordinateAxis {
|
|||||||
JKQTPVerticalAxisBase(JKQTBasePlotter* parent);
|
JKQTPVerticalAxisBase(JKQTBasePlotter* parent);
|
||||||
|
|
||||||
/** \brief returns the size of the left axis in pixels */
|
/** \brief returns the size of the left axis in pixels */
|
||||||
virtual QSizeF getSize1(JKQTPEnhancedPainter& painter) override;
|
virtual QSizeF getSize1(JKQTPEnhancedPainter& painter, double *elongateBottom=nullptr, double* elongateTop=nullptr) override;
|
||||||
|
|
||||||
/** \brief returns the size of the right axis in pixels */
|
/** \brief returns the size of the right axis in pixels */
|
||||||
virtual QSizeF getSize2(JKQTPEnhancedPainter& painter) override;
|
virtual QSizeF getSize2(JKQTPEnhancedPainter& painter) override;
|
||||||
@ -1081,7 +1081,7 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPHorizontalAxisBase: public JKQTPCoordinateAxis
|
|||||||
JKQTPHorizontalAxisBase(JKQTBasePlotter* parent);
|
JKQTPHorizontalAxisBase(JKQTBasePlotter* parent);
|
||||||
|
|
||||||
/** \brief returns the size of the bottom axis in pixels */
|
/** \brief returns the size of the bottom axis in pixels */
|
||||||
virtual QSizeF getSize1(JKQTPEnhancedPainter& painter) override;
|
virtual QSizeF getSize1(JKQTPEnhancedPainter& painter, double* elongateLeft=nullptr, double* elongateRight=nullptr) override;
|
||||||
|
|
||||||
/** \brief returns the size of the top axis in pixels */
|
/** \brief returns the size of the top axis in pixels */
|
||||||
virtual QSizeF getSize2(JKQTPEnhancedPainter& painter) override;
|
virtual QSizeF getSize2(JKQTPEnhancedPainter& painter) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user