FIXed drawing of secondary axes (distances betweeen axes were wrong, in part doubled and inside-ticks for secondary axes were not taken into account ... also fixed several minor bugs around this)
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 138 KiB After Width: | Height: | Size: 139 KiB |
Before Width: | Height: | Size: 136 KiB After Width: | Height: | Size: 137 KiB |
Before Width: | Height: | Size: 149 KiB After Width: | Height: | Size: 150 KiB |
Before Width: | Height: | Size: 140 KiB After Width: | Height: | Size: 141 KiB |
Before Width: | Height: | Size: 142 KiB After Width: | Height: | Size: 144 KiB |
Before Width: | Height: | Size: 138 KiB After Width: | Height: | Size: 138 KiB |
Before Width: | Height: | Size: 105 KiB After Width: | Height: | Size: 104 KiB |
Before Width: | Height: | Size: 158 KiB After Width: | Height: | Size: 158 KiB |
Before Width: | Height: | Size: 137 KiB After Width: | Height: | Size: 137 KiB |
Before Width: | Height: | Size: 140 KiB After Width: | Height: | Size: 140 KiB |
Before Width: | Height: | Size: 144 KiB After Width: | Height: | Size: 144 KiB |
@ -18,6 +18,7 @@ In the code we take these step to set up a plot with two secondary axes and thre
|
||||
size_t columnY1=ds->addColumnCalculatedFromColumn(columnX, [](double x) { return x; }, "y1");
|
||||
size_t columnY2=ds->addColumnCalculatedFromColumn(columnX, [](double x) { return cos(x); }, "y2");
|
||||
size_t columnY3=ds->addColumnCalculatedFromColumn(columnX, [](double x) { return x*x; }, "y3");
|
||||
size_t columnY4=ds->addColumnCalculatedFromColumn(columnX, [](double x) { return sqrt(x); }, "y3");
|
||||
```
|
||||
|
||||
3. create a second y-axis and set its formating options, so it only draws an axis on the right
|
||||
@ -31,7 +32,7 @@ In the code we take these step to set up a plot with two secondary axes and thre
|
||||
plot.getYAxis(yAxisRef2)->setShowZeroAxis(false);
|
||||
```
|
||||
|
||||
... and ctreate third y-axis
|
||||
... and create third y-axis
|
||||
|
||||
```.cpp
|
||||
auto yAxisRef3=plot.getPlotter()->addSecondaryYAxis(new JKQTPVerticalAxis(plot.getPlotter(), JKQTPPrimaryAxis));
|
||||
@ -42,6 +43,17 @@ In the code we take these step to set up a plot with two secondary axes and thre
|
||||
plot.getYAxis(yAxisRef3)->setShowZeroAxis(false);
|
||||
```
|
||||
|
||||
... and a fourth y-axis (on the primary side)
|
||||
|
||||
```.cpp
|
||||
auto yAxisRef4=plot.getPlotter()->addSecondaryYAxis(new JKQTPVerticalAxis(plot.getPlotter(), JKQTPPrimaryAxis));
|
||||
plot.getYAxis(yAxisRef4)->setDrawGrid(false);
|
||||
plot.getYAxis(yAxisRef4)->setDrawMode1(JKQTPCADMcomplete);
|
||||
plot.getYAxis(yAxisRef4)->setDrawMode2(JKQTPCADMnone);
|
||||
plot.getYAxis(yAxisRef4)->setDrawMode0(JKQTPCADMnone);
|
||||
plot.getYAxis(yAxisRef4)->setShowZeroAxis(false);
|
||||
```
|
||||
|
||||
... reformat the major y-axis, so it does not draw on the right and thus the secondary axis yAxisRef2 replaces it there. If this step is omitted, the secondary axes stack on the right of the primary.
|
||||
|
||||
```.cpp
|
||||
@ -98,15 +110,27 @@ set axis label
|
||||
plot.getYAxis(yAxisRef3)->setColor(graph3->getLineColor());
|
||||
plot.getYAxis(yAxisRef3)->setAxisLabel("graph3");
|
||||
graph3->setYAxis(yAxisRef3);
|
||||
```
|
||||
|
||||
3.5 the fourth graph uses the default (primary) x-axis, but the secondary axis yAxisRef4 as y-axis
|
||||
|
||||
```.cpp
|
||||
JKQTPXYLineGraph* graph4=new JKQTPXYLineGraph(&plot);
|
||||
graph4->setKeyColumn(columnX);
|
||||
graph4->setValueColumn(columnY4);
|
||||
plot.addGraph(graph3);
|
||||
plot.getYAxis(yAxisRef4)->setColor(graph4->getLineColor());
|
||||
plot.getYAxis(yAxisRef4)->setAxisLabel("graph4");
|
||||
graph4->setYAxis(yAxisRef4);
|
||||
```
|
||||
|
||||
4. autoscale the plot so the graph is contained. This auto-scales all axes using the graphs (and their data) as assigned to the axes, i.e.:
|
||||
- all 3 graphs for x-axis,
|
||||
- graph1 for primary y-axis,
|
||||
- graph2 for secondary axis yAxisRef2
|
||||
- graph3 for secondary axis yAxisRef3
|
||||
- all 3 graphs for x-axis,
|
||||
- graph1 for primary y-axis,
|
||||
- graph2 for secondary axis yAxisRef2
|
||||
- graph3 for secondary axis yAxisRef3
|
||||
- graph4 for secondary axis yAxisRef4
|
||||
.
|
||||
|
||||
```.cpp
|
||||
plot.zoomToFit();
|
||||
|
@ -22,6 +22,7 @@ void exampleSecondYAxis(JKQTPlotter& plot, const QString& title)
|
||||
size_t columnY1=ds->addColumnCalculatedFromColumn(columnX, [](double x) { return x; }, "y1");
|
||||
size_t columnY2=ds->addColumnCalculatedFromColumn(columnX, [](double x) { return cos(x); }, "y2");
|
||||
size_t columnY3=ds->addColumnCalculatedFromColumn(columnX, [](double x) { return x*x; }, "y3");
|
||||
size_t columnY4=ds->addColumnCalculatedFromColumn(columnX, [](double x) { return sqrt(x); }, "y3");
|
||||
|
||||
// 3. create a second y-axis and set its formating options, so it only draws an axis on the right
|
||||
auto yAxisRef2=plot.getPlotter()->addSecondaryYAxis(new JKQTPVerticalAxis(plot.getPlotter(), JKQTPPrimaryAxis));
|
||||
@ -30,13 +31,20 @@ void exampleSecondYAxis(JKQTPlotter& plot, const QString& title)
|
||||
plot.getYAxis(yAxisRef2)->setDrawMode2(JKQTPCADMcomplete);
|
||||
plot.getYAxis(yAxisRef2)->setDrawMode0(JKQTPCADMnone);
|
||||
plot.getYAxis(yAxisRef2)->setShowZeroAxis(false);
|
||||
// ... and ctreate third y-axis
|
||||
// ... and create third y-axis
|
||||
auto yAxisRef3=plot.getPlotter()->addSecondaryYAxis(new JKQTPVerticalAxis(plot.getPlotter(), JKQTPPrimaryAxis));
|
||||
plot.getYAxis(yAxisRef3)->setDrawGrid(false);
|
||||
plot.getYAxis(yAxisRef3)->setDrawMode1(JKQTPCADMnone);
|
||||
plot.getYAxis(yAxisRef3)->setDrawMode2(JKQTPCADMcomplete);
|
||||
plot.getYAxis(yAxisRef3)->setDrawMode0(JKQTPCADMnone);
|
||||
plot.getYAxis(yAxisRef3)->setShowZeroAxis(false);
|
||||
// ... and create fourth y-axis
|
||||
auto yAxisRef4=plot.getPlotter()->addSecondaryYAxis(new JKQTPVerticalAxis(plot.getPlotter(), JKQTPPrimaryAxis));
|
||||
plot.getYAxis(yAxisRef4)->setDrawGrid(false);
|
||||
plot.getYAxis(yAxisRef4)->setDrawMode1(JKQTPCADMcomplete);
|
||||
plot.getYAxis(yAxisRef4)->setDrawMode2(JKQTPCADMnone);
|
||||
plot.getYAxis(yAxisRef4)->setDrawMode0(JKQTPCADMnone);
|
||||
plot.getYAxis(yAxisRef4)->setShowZeroAxis(false);
|
||||
// ... reformat the major y-axis, so it does not draw on the right and thus the secondary axis yAxisRef2 replaces it there
|
||||
// if this step is omitted, the secondary axes stack on the right of the primary.
|
||||
plot.getYAxis()->setDrawMode2(JKQTPCADMnone);
|
||||
@ -72,6 +80,15 @@ void exampleSecondYAxis(JKQTPlotter& plot, const QString& title)
|
||||
plot.getYAxis(yAxisRef3)->setAxisLabel("graph3");
|
||||
graph3->setYAxis(yAxisRef3);
|
||||
|
||||
// 3.4 the fourth graph uses the default (primary) x-axis, but the ternary axis yAxisRef4 as y-axis
|
||||
JKQTPXYLineGraph* graph4=new JKQTPXYLineGraph(&plot);
|
||||
graph4->setKeyColumn(columnX);
|
||||
graph4->setValueColumn(columnY4);
|
||||
plot.addGraph(graph3);
|
||||
plot.getYAxis(yAxisRef4)->setColor(graph4->getLineColor());
|
||||
plot.getYAxis(yAxisRef4)->setAxisLabel("graph4");
|
||||
graph4->setYAxis(yAxisRef4);
|
||||
|
||||
|
||||
// 4. autoscale the plot so the graph is contained
|
||||
// This auto-scales all axes using the graphs (and their data) as assigned to the axes!
|
||||
@ -99,6 +116,7 @@ void exampleSecondXAxis(JKQTPlotter& plot, const QString& title)
|
||||
size_t columnX1=ds->addColumnCalculatedFromColumn(columnY, [](double x) { return x; }, "x1");
|
||||
size_t columnX2=ds->addColumnCalculatedFromColumn(columnY, [](double x) { return cos(x); }, "x2");
|
||||
size_t columnX3=ds->addColumnCalculatedFromColumn(columnY, [](double x) { return x*x; }, "x3");
|
||||
size_t columnX4=ds->addColumnCalculatedFromColumn(columnY, [](double x) { return sqrt(x); }, "x4");
|
||||
|
||||
JKQTPXYLineGraph* graph1=new JKQTPXYLineGraph(&plot);
|
||||
graph1->setXColumn(columnX1);
|
||||
@ -112,6 +130,10 @@ void exampleSecondXAxis(JKQTPlotter& plot, const QString& title)
|
||||
graph3->setXColumn(columnX3);
|
||||
graph3->setYColumn(columnY);
|
||||
plot.addGraph(graph3);
|
||||
JKQTPXYLineGraph* graph4=new JKQTPXYLineGraph(&plot);
|
||||
graph4->setXColumn(columnX4);
|
||||
graph4->setYColumn(columnY);
|
||||
plot.addGraph(graph4);
|
||||
|
||||
plot.getXAxis()->setDrawMode2(JKQTPCADMLineTicksTickLabels);
|
||||
plot.getXAxis()->setColor(graph1->getLineColor());
|
||||
@ -137,6 +159,16 @@ void exampleSecondXAxis(JKQTPlotter& plot, const QString& title)
|
||||
plot.getXAxis(xAxisRef3)->setAxisLabel("graph3");
|
||||
graph3->setXAxis(xAxisRef3);
|
||||
|
||||
auto xAxisRef4=plot.getPlotter()->addSecondaryXAxis(new JKQTPHorizontalAxis(plot.getPlotter(), JKQTPPrimaryAxis));
|
||||
plot.getXAxis(xAxisRef4)->setDrawGrid(false);
|
||||
plot.getXAxis(xAxisRef4)->setDrawMode1(JKQTPCADMcomplete);
|
||||
plot.getXAxis(xAxisRef4)->setDrawMode2(JKQTPCADMnone);
|
||||
plot.getXAxis(xAxisRef4)->setDrawMode0(JKQTPCADMnone);
|
||||
plot.getXAxis(xAxisRef4)->setShowZeroAxis(false);
|
||||
plot.getXAxis(xAxisRef4)->setColor(graph4->getLineColor());
|
||||
plot.getXAxis(xAxisRef4)->setAxisLabel("graph4");
|
||||
graph4->setXAxis(xAxisRef4);
|
||||
|
||||
plot.zoomToFit();
|
||||
|
||||
plot.setWindowTitle(title);
|
||||
@ -152,8 +184,10 @@ int main(int argc, char* argv[])
|
||||
|
||||
|
||||
JKQTPlotter plotsecondY;
|
||||
//plotsecondY.getPlotter()->enableDebugShowRegionBoxes(true);
|
||||
exampleSecondYAxis(plotsecondY, "1: Second Y-Axis");
|
||||
JKQTPlotter plotsecondX;
|
||||
//plotsecondX.getPlotter()->enableDebugShowRegionBoxes(true);
|
||||
exampleSecondXAxis(plotsecondX, "2: Second X-Axis");
|
||||
|
||||
return app.exec();
|
||||
|
@ -919,12 +919,16 @@ void JKQTBasePlotter::calcPlotScaling(JKQTPEnhancedPainter& painter){
|
||||
|
||||
// read size required by secondary axes
|
||||
for (const auto& ax: qAsConst(secondaryYAxis)) {
|
||||
internalPlotMargins[PlotMarginUse::muAxesOutside].left+=ax->getSize1(painter).requiredSize+plotterStyle.secondaryAxisSeparation;
|
||||
internalPlotMargins[PlotMarginUse::muAxesOutside].right+=ax->getSize2(painter).requiredSize+plotterStyle.secondaryAxisSeparation;
|
||||
const auto s1=ax->getSize1(painter);
|
||||
const auto s2=ax->getSize2(painter);
|
||||
internalPlotMargins[PlotMarginUse::muAxesOutside].left+=s1.requiredSize+((fabs(s1.requiredSize)>0.1)?pt2px(painter, plotterStyle.secondaryAxisSeparation):0.0);
|
||||
internalPlotMargins[PlotMarginUse::muAxesOutside].right+=s2.requiredSize+((fabs(s2.requiredSize)>0.1)?pt2px(painter, plotterStyle.secondaryAxisSeparation):0.0);
|
||||
}
|
||||
for (const auto& ax: qAsConst(secondaryXAxis)) {
|
||||
internalPlotMargins[PlotMarginUse::muAxesOutside].bottom+=ax->getSize1(painter).requiredSize+plotterStyle.secondaryAxisSeparation;
|
||||
internalPlotMargins[PlotMarginUse::muAxesOutside].top+=ax->getSize2(painter).requiredSize+plotterStyle.secondaryAxisSeparation;
|
||||
const auto s1=ax->getSize1(painter);
|
||||
const auto s2=ax->getSize2(painter);
|
||||
internalPlotMargins[PlotMarginUse::muAxesOutside].bottom+=s1.requiredSize+((fabs(s1.requiredSize)>0.1)?pt2px(painter, plotterStyle.secondaryAxisSeparation):0.0);
|
||||
internalPlotMargins[PlotMarginUse::muAxesOutside].top+=s2.requiredSize+((fabs(s2.requiredSize)>0.1)?pt2px(painter, plotterStyle.secondaryAxisSeparation):0.0);
|
||||
}
|
||||
|
||||
if (internalPlotMargins.calcRight()<elongateRight) internalPlotMargins[PlotMarginUse::muAxesOutsideExtend].right=elongateRight-internalPlotMargins.calcRight();
|
||||
@ -1079,16 +1083,18 @@ void JKQTBasePlotter::drawSystemXAxis(JKQTPEnhancedPainter& painter) {
|
||||
|
||||
if (secondaryXAxis.size()>0) {
|
||||
double ibMove1=xAxis->getSize1(painter).requiredSize;
|
||||
if (ibMove1>0) ibMove1+=plotterStyle.secondaryAxisSeparation;
|
||||
//if (ibMove1>0) ibMove1+=pt2px(painter, plotterStyle.secondaryAxisSeparation);
|
||||
double ibMove2=xAxis->getSize2(painter).requiredSize;
|
||||
if (ibMove2>0) ibMove1+=plotterStyle.secondaryAxisSeparation;
|
||||
//if (ibMove2>0) ibMove2+=pt2px(painter, plotterStyle.secondaryAxisSeparation);
|
||||
|
||||
for (auto& ax: secondaryXAxis) {
|
||||
ax->drawAxes(painter, ibMove1, ibMove2);
|
||||
const double add1=ax->getSize1(painter).requiredSize;
|
||||
const double add2=ax->getSize2(painter).requiredSize;
|
||||
if (add1>0) ibMove1+=add1+plotterStyle.secondaryAxisSeparation;
|
||||
if (add2>0) ibMove2+=add2+plotterStyle.secondaryAxisSeparation;
|
||||
if (add1>0) ibMove1+=pt2px(painter, plotterStyle.secondaryAxisSeparation);
|
||||
if (add2>0) ibMove2+=pt2px(painter, plotterStyle.secondaryAxisSeparation);
|
||||
ax->drawAxes(painter, ibMove1, ibMove2);
|
||||
ibMove1+=add1;
|
||||
ibMove2+=add2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1103,16 +1109,18 @@ void JKQTBasePlotter::drawSystemYAxis(JKQTPEnhancedPainter& painter) {
|
||||
|
||||
if (secondaryYAxis.size()>0) {
|
||||
double ibMove1=yAxis->getSize1(painter).requiredSize;
|
||||
if (ibMove1>0) ibMove1+=plotterStyle.secondaryAxisSeparation;
|
||||
//if (ibMove1>0) ibMove1+=pt2px(painter, plotterStyle.secondaryAxisSeparation);
|
||||
double ibMove2=yAxis->getSize2(painter).requiredSize;
|
||||
if (ibMove2>0) ibMove1+=plotterStyle.secondaryAxisSeparation;
|
||||
//if (ibMove2>0) ibMove2+=pt2px(painter, plotterStyle.secondaryAxisSeparation);
|
||||
|
||||
for (auto& ax: secondaryYAxis) {
|
||||
ax->drawAxes(painter, ibMove1, ibMove2);
|
||||
const double add1=ax->getSize1(painter).requiredSize;
|
||||
const double add2=ax->getSize2(painter).requiredSize;
|
||||
if (add1>0) ibMove1+=add1+plotterStyle.secondaryAxisSeparation;
|
||||
if (add2>0) ibMove2+=add2+plotterStyle.secondaryAxisSeparation;
|
||||
if (add1>0) ibMove1+=pt2px(painter, plotterStyle.secondaryAxisSeparation);
|
||||
if (add2>0) ibMove2+=pt2px(painter, plotterStyle.secondaryAxisSeparation);
|
||||
ax->drawAxes(painter, ibMove1, ibMove2);
|
||||
ibMove1+=add1;
|
||||
ibMove2+=add2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3064,11 +3072,20 @@ QMap<JKQTPCoordinateAxisRef, JKQTPVerticalAxisBase *> JKQTBasePlotter::getYAxes(
|
||||
|
||||
QList<JKQTPCoordinateAxis *> JKQTBasePlotter::getAxes(bool includePrimaries)
|
||||
{
|
||||
QList<JKQTPCoordinateAxis *> res;
|
||||
if (includePrimaries) res<<xAxis<<yAxis;
|
||||
for (auto& ax: secondaryXAxis) res<<ax;
|
||||
for (auto& ax: secondaryYAxis) res<<ax;
|
||||
return res;
|
||||
QList<JKQTPCoordinateAxis *> res;
|
||||
if (includePrimaries) res<<xAxis<<yAxis;
|
||||
for (auto& ax: secondaryXAxis) res<<ax;
|
||||
for (auto& ax: secondaryYAxis) res<<ax;
|
||||
return res;
|
||||
}
|
||||
|
||||
QList<const JKQTPCoordinateAxis *> JKQTBasePlotter::getAxes(bool includePrimaries) const
|
||||
{
|
||||
QList<const JKQTPCoordinateAxis *> res;
|
||||
if (includePrimaries) res<<xAxis<<yAxis;
|
||||
for (auto& ax: secondaryXAxis) res<<ax;
|
||||
for (auto& ax: secondaryYAxis) res<<ax;
|
||||
return res;
|
||||
}
|
||||
|
||||
JKQTPCoordinateAxisRef JKQTBasePlotter::addSecondaryXAxis(JKQTPHorizontalAxisBase *axis)
|
||||
|
@ -1201,6 +1201,8 @@ class JKQTPLOTTER_LIB_EXPORT JKQTBasePlotter: public QObject {
|
||||
QMap<JKQTPCoordinateAxisRef, JKQTPVerticalAxisBase*> getYAxes(bool includePrimary=true);
|
||||
/** \brief returns all available x- or y-axes */
|
||||
QList<JKQTPCoordinateAxis*> getAxes(bool includePrimaries=true);
|
||||
/** \brief returns all available x- or y-axes */
|
||||
QList<const JKQTPCoordinateAxis*> getAxes(bool includePrimaries=true) const;
|
||||
|
||||
/** \brief adds a secondary x-axis
|
||||
*
|
||||
|
@ -1285,6 +1285,17 @@ double JKQTPCoordinateAxis::getZeroAxisPos(bool *drawZeroAxis) {
|
||||
return zeroaxispos;
|
||||
}
|
||||
|
||||
bool JKQTPCoordinateAxis::isSecondaryAxis() const
|
||||
{
|
||||
if (parent) {
|
||||
const auto axlist=parent->getAxes(false);
|
||||
for (const auto ax: axlist){
|
||||
if (ax==this) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1355,12 +1366,13 @@ JKQTPCoordinateAxis::Axis0ElementsSizeDescription JKQTPVerticalAxisBase::getSize
|
||||
|
||||
|
||||
JKQTPCoordinateAxis::AxisElementsSizeDescription JKQTPVerticalAxisBase::getSize1(JKQTPEnhancedPainter& painter) {
|
||||
const double insidefactor=(isSecondaryAxis()) ? 1.0 : 0.0;
|
||||
AxisElementsSizeDescription res;
|
||||
if (axisStyle.drawMode1!=JKQTPCADMnone) {
|
||||
double ptwidth=axisStyle.axisLineOffset;
|
||||
const double arrowSize=((axisStyle.drawMode1&(JKQTPCADMMinArrow|JKQTPCADMMinFilledArrow|JKQTPCADMMaxArrow|JKQTPCADMMaxFilledArrow))!=int(0))?(axisStyle.getArrowSize(painter, parent)/2.0):0.0;
|
||||
double labwidth=0;
|
||||
if (axisStyle.drawMode1.testFlag(JKQTPCADMTicks)) ptwidth+=axisStyle.tickOutsideLength;
|
||||
if (axisStyle.drawMode1.testFlag(JKQTPCADMTicks)) ptwidth+=qMax(axisStyle.tickOutsideLength,axisStyle.minorTickOutsideLength)+insidefactor*qMax(axisStyle.minorTickInsideLength,axisStyle.tickInsideLength);
|
||||
if (axisStyle.drawMode1.testFlag(JKQTPCADMTickLabels)) {
|
||||
ptwidth+=axisStyle.tickLabelDistance;
|
||||
// find out the maximum width over all visible plot labels
|
||||
@ -1378,11 +1390,11 @@ JKQTPCoordinateAxis::AxisElementsSizeDescription JKQTPVerticalAxisBase::getSize1
|
||||
if (axisStyle.drawMode1.testFlag(JKQTPCADMAxisLabel)) {
|
||||
const auto labSize=parent->getTextSizeDetail(getParent()->getCurrentPlotterStyle().defaultFontName, axisStyle.labelFontSize*parent->getFontSizeMultiplier(), axisLabel, painter);
|
||||
if (axisStyle.labelPosition==JKQTPLabelMinBesides) {
|
||||
labwidth=qMax(labwidth, labSize.width/2.0+2);
|
||||
res.elongateMin=qMax(res.elongateMin, parent->pt2px(painter, axisStyle.labelDistance)*1.5+labSize.overallHeight);
|
||||
labwidth=qMax(labwidth, labSize.getDescent());
|
||||
res.elongateMin=qMax(res.elongateMin, parent->pt2px(painter, axisStyle.labelDistance)*1.5+labSize.width);
|
||||
} else if (axisStyle.labelPosition==JKQTPLabelMaxBesides) {
|
||||
labwidth=qMax(labwidth, labSize.width/2.0+2);
|
||||
res.elongateMax=qMax(res.elongateMax, parent->pt2px(painter, axisStyle.labelDistance)*1.5+labSize.overallHeight);
|
||||
labwidth=qMax(labwidth, labSize.getDescent());
|
||||
res.elongateMax=qMax(res.elongateMax, parent->pt2px(painter, axisStyle.labelDistance)*1.5+labSize.width);
|
||||
} else {
|
||||
ptwidth+=axisStyle.labelDistance;
|
||||
// find out size of axis label
|
||||
@ -1404,12 +1416,13 @@ QSizeF JKQTPVerticalAxisBase::getQSize1(JKQTPEnhancedPainter &painter)
|
||||
}
|
||||
|
||||
JKQTPCoordinateAxis::AxisElementsSizeDescription JKQTPVerticalAxisBase::getSize2(JKQTPEnhancedPainter& painter) {
|
||||
const double insidefactor=(isSecondaryAxis()) ? 1.0 : 0.0;
|
||||
AxisElementsSizeDescription res;
|
||||
if (axisStyle.drawMode2!=JKQTPCADMnone) {
|
||||
double ptwidth=axisStyle.axisLineOffset;
|
||||
const double arrowSize=((axisStyle.drawMode2&(JKQTPCADMMinArrow|JKQTPCADMMinFilledArrow|JKQTPCADMMaxArrow|JKQTPCADMMaxFilledArrow))!=int(0))?(axisStyle.getArrowSize(painter, parent)/2.0):0.0;
|
||||
double labwidth=0;
|
||||
if (axisStyle.drawMode2.testFlag(JKQTPCADMTicks)) ptwidth+=axisStyle.tickOutsideLength;
|
||||
if (axisStyle.drawMode2.testFlag(JKQTPCADMTicks)) ptwidth+=qMax(axisStyle.tickOutsideLength,axisStyle.minorTickOutsideLength)+insidefactor*qMax(axisStyle.minorTickInsideLength,axisStyle.tickInsideLength);
|
||||
if (axisStyle.drawMode2.testFlag(JKQTPCADMTickLabels)) {
|
||||
ptwidth+=axisStyle.tickLabelDistance;
|
||||
// find out the maximum width over all visible plot labels
|
||||
@ -1427,11 +1440,11 @@ JKQTPCoordinateAxis::AxisElementsSizeDescription JKQTPVerticalAxisBase::getSize2
|
||||
if (axisStyle.drawMode2.testFlag(JKQTPCADMAxisLabel)) {
|
||||
const auto labSize=parent->getTextSizeDetail(getParent()->getCurrentPlotterStyle().defaultFontName, axisStyle.labelFontSize*parent->getFontSizeMultiplier(), axisLabel, painter);
|
||||
if (axisStyle.labelPosition==JKQTPLabelMinBesides) {
|
||||
labwidth=qMax(labwidth, labSize.width/2.0+2);
|
||||
res.elongateMin=qMax(res.elongateMin, parent->pt2px(painter, axisStyle.labelDistance)*1.5+labSize.overallHeight);
|
||||
labwidth=qMax(labwidth, labSize.getAscent());
|
||||
res.elongateMin=qMax(res.elongateMin, parent->pt2px(painter, axisStyle.labelDistance)*1.5+labSize.width);
|
||||
} else if (axisStyle.labelPosition==JKQTPLabelMaxBesides) {
|
||||
labwidth=qMax(labwidth, labSize.width/2.0+2);
|
||||
res.elongateMax=qMax(res.elongateMax, parent->pt2px(painter, axisStyle.labelDistance)*1.5+labSize.overallHeight);
|
||||
labwidth=qMax(labwidth, labSize.getAscent());
|
||||
res.elongateMax=qMax(res.elongateMax, parent->pt2px(painter, axisStyle.labelDistance)*1.5+labSize.width);
|
||||
} else {
|
||||
ptwidth+=axisStyle.labelDistance;
|
||||
// find out size of axis label
|
||||
@ -1685,7 +1698,7 @@ void JKQTPVerticalAxisBase::drawAxisLabel2(JKQTPEnhancedPainter &painter, double
|
||||
|
||||
|
||||
QRectF rect(0,0, getParentPlotWidth(), labSize.overallHeight);
|
||||
QPointF pos0(right+labelOffset+rect.height(), bottom);
|
||||
QPointF pos0(right+labelOffset, bottom);
|
||||
Qt::Alignment align=Qt::AlignBottom|Qt::AlignHCenter;
|
||||
double rot=-90;
|
||||
if (axisStyle.labelPosition==JKQTPLabelMaxBesides) {
|
||||
@ -1728,6 +1741,11 @@ void JKQTPVerticalAxisBase::drawAxes(JKQTPEnhancedPainter& painter, int move1, i
|
||||
#ifdef JKQTBP_AUTOTIMER
|
||||
JKQTPAutoOutputTimer jkaat(QString("JKQTPEnhancedPainter[%1]::drawAxes()").arg(objectName()));
|
||||
#endif
|
||||
const bool isSecondAxis=isSecondaryAxis();
|
||||
// correct move1,move2 for the length of inside ticks for secondary axes
|
||||
double moveForTicks1=0, moveForTicks2=0;
|
||||
if (isSecondAxis && axisStyle.drawMode1.testFlag(JKQTPCADMTicks)) moveForTicks1=qMax(axisStyle.minorTickInsideLength,axisStyle.tickInsideLength);
|
||||
if (isSecondAxis && axisStyle.drawMode2.testFlag(JKQTPCADMTicks)) moveForTicks2=qMax(axisStyle.minorTickInsideLength,axisStyle.tickInsideLength);
|
||||
|
||||
// make shure all parameters are calculated correctly
|
||||
calcPlotScaling();
|
||||
@ -1748,8 +1766,8 @@ void JKQTPVerticalAxisBase::drawAxes(JKQTPEnhancedPainter& painter, int move1, i
|
||||
right=getParentOtheraxisOffset()+getParentOtheraxisWidth();//;
|
||||
}
|
||||
// move axes outside plot rectangle, if required
|
||||
left-=parent->pt2px(painter, axisStyle.axisLineOffset)+move1;
|
||||
right+=parent->pt2px(painter, axisStyle.axisLineOffset)+move2;
|
||||
left-=parent->pt2px(painter, axisStyle.axisLineOffset)+move1+moveForTicks1;
|
||||
right+=parent->pt2px(painter, axisStyle.axisLineOffset)+move2+moveForTicks2;
|
||||
|
||||
|
||||
double ticklabelOffset1PT=axisStyle.tickLabelDistance; // offset of tick labels from axis 1
|
||||
@ -1985,14 +2003,15 @@ void JKQTPVerticalAxisBase::drawAxes(JKQTPEnhancedPainter& painter, int move1, i
|
||||
if (getParent()->getCurrentPlotterStyle().debugShowRegionBoxes) {
|
||||
painter.save(); auto __finalpaintif=JKQTPFinally([&painter]() {painter.restore();});
|
||||
QPen p("cyan");
|
||||
if (isSecondAxis) p=QPen("darkcyan");
|
||||
p.setWidthF(getParent()->getCurrentPlotterStyle().debugRegionLineWidth);
|
||||
QColor col=p.color(); col.setAlphaF(0.8f); p.setColor(col);
|
||||
QColor col=p.color(); col.setAlphaF(0.6f); p.setColor(col);
|
||||
painter.setPen(p);
|
||||
painter.setBrush(QBrush(QColor(Qt::transparent)));
|
||||
const QSizeF s1(getSize1(painter).requiredSize, getParentPlotWidth());
|
||||
const QSizeF s2(getSize2(painter).requiredSize, getParentPlotWidth());
|
||||
painter.drawRect(QRectF(QPointF(left-s1.width(), top), s1));
|
||||
painter.drawRect(QRectF(QPointF(right, top), s2));
|
||||
painter.drawRect(QRectF(QPointF(left+moveForTicks1-s1.width(), top), s1));
|
||||
painter.drawRect(QRectF(QPointF(right-moveForTicks2, top), s2));
|
||||
|
||||
}
|
||||
|
||||
@ -2193,12 +2212,13 @@ JKQTPCoordinateAxis::Axis0ElementsSizeDescription JKQTPHorizontalAxisBase::getSi
|
||||
}
|
||||
|
||||
JKQTPCoordinateAxis::AxisElementsSizeDescription JKQTPHorizontalAxisBase::getSize1(JKQTPEnhancedPainter& painter) {
|
||||
const double insidefactor=(isSecondaryAxis()) ? 1.0 : 0.0;
|
||||
AxisElementsSizeDescription res;
|
||||
if (axisStyle.drawMode1!=JKQTPCADMnone) {
|
||||
double ptheight=axisStyle.axisLineOffset;
|
||||
const double arrowSize=((axisStyle.drawMode1&(JKQTPCADMMinArrow|JKQTPCADMMinFilledArrow|JKQTPCADMMaxArrow|JKQTPCADMMaxFilledArrow))!=int(0))?(axisStyle.getArrowSize(painter, parent)/2.0):0.0;
|
||||
double labheight=0;
|
||||
if (axisStyle.drawMode1.testFlag(JKQTPCADMTicks)) ptheight+=axisStyle.tickOutsideLength;
|
||||
if (axisStyle.drawMode1.testFlag(JKQTPCADMTicks)) ptheight+=qMax(axisStyle.tickOutsideLength,axisStyle.minorTickOutsideLength)+insidefactor*qMax(axisStyle.minorTickInsideLength,axisStyle.tickInsideLength);
|
||||
if (axisStyle.drawMode1.testFlag(JKQTPCADMTickLabels)) {
|
||||
ptheight+=axisStyle.tickLabelDistance;
|
||||
// find out the maximum width over all visible plot labels
|
||||
@ -2242,12 +2262,13 @@ QSizeF JKQTPHorizontalAxisBase::getQSize1(JKQTPEnhancedPainter &painter)
|
||||
}
|
||||
|
||||
JKQTPCoordinateAxis::AxisElementsSizeDescription JKQTPHorizontalAxisBase::getSize2(JKQTPEnhancedPainter& painter) {
|
||||
const double insidefactor=(isSecondaryAxis()) ? 1.0 : 0.0;
|
||||
AxisElementsSizeDescription res;
|
||||
if (axisStyle.drawMode2!=JKQTPCADMnone) {
|
||||
double ptheight=axisStyle.axisLineOffset;
|
||||
const double arrowSize=((axisStyle.drawMode2&(JKQTPCADMMinArrow|JKQTPCADMMinFilledArrow|JKQTPCADMMaxArrow|JKQTPCADMMaxFilledArrow))!=int(0))?(axisStyle.getArrowSize(painter, parent)/2.0):0.0;
|
||||
double labheight=0;
|
||||
if (axisStyle.drawMode2.testFlag(JKQTPCADMTicks)) ptheight+=axisStyle.tickOutsideLength;
|
||||
if (axisStyle.drawMode2.testFlag(JKQTPCADMTicks)) ptheight+=qMax(axisStyle.tickOutsideLength,axisStyle.minorTickOutsideLength)+insidefactor*qMax(axisStyle.minorTickInsideLength,axisStyle.tickInsideLength);
|
||||
if (axisStyle.drawMode2.testFlag(JKQTPCADMTickLabels)) {
|
||||
ptheight+=axisStyle.tickLabelDistance;
|
||||
// find out the maximum width over all visible plot labels
|
||||
@ -2265,10 +2286,10 @@ JKQTPCoordinateAxis::AxisElementsSizeDescription JKQTPHorizontalAxisBase::getSiz
|
||||
if (axisStyle.drawMode2.testFlag(JKQTPCADMAxisLabel)) {
|
||||
const auto labSize=parent->getTextSizeDetail(getParent()->getCurrentPlotterStyle().defaultFontName, axisStyle.labelFontSize*parent->getFontSizeMultiplier(), axisLabel, painter);
|
||||
if (axisStyle.labelPosition==JKQTPLabelMinBesides) {
|
||||
labheight=qMax(labheight, labSize.getDescent());
|
||||
labheight=qMax(labheight, labSize.getAscent());
|
||||
res.elongateMin=qMax(res.elongateMin, parent->pt2px(painter, axisStyle.labelDistance)*1.5+labSize.width);
|
||||
} else if (axisStyle.labelPosition==JKQTPLabelMaxBesides) {
|
||||
labheight=qMax(labheight, labSize.getDescent());
|
||||
labheight=qMax(labheight, labSize.getAscent());
|
||||
res.elongateMax=qMax(res.elongateMax, parent->pt2px(painter, axisStyle.labelDistance)*1.5+labSize.width);
|
||||
} else {
|
||||
ptheight+=axisStyle.labelDistance;
|
||||
@ -2276,11 +2297,6 @@ JKQTPCoordinateAxis::AxisElementsSizeDescription JKQTPHorizontalAxisBase::getSiz
|
||||
labheight+=labSize.overallHeight;
|
||||
}
|
||||
}
|
||||
if (axisStyle.drawMode2.testFlag(JKQTPCADMAxisLabel)) {
|
||||
ptheight+=axisStyle.labelDistance;
|
||||
// find out size of axis label
|
||||
labheight+=parent->getTextSizeSize(getParent()->getCurrentPlotterStyle().defaultFontName, axisStyle.labelFontSize*parent->getFontSizeMultiplier(), axisLabel, painter).height();
|
||||
}
|
||||
res.requiredSize=qMax(arrowSize,parent->pt2px(painter, ptheight)+labheight);
|
||||
}
|
||||
|
||||
@ -2529,6 +2545,13 @@ void JKQTPHorizontalAxisBase::drawAxes(JKQTPEnhancedPainter& painter, int move1,
|
||||
JKQTPAutoOutputTimer jkaat(QString("JKQTPHorizontalAxis[%1]::drawAxes()").arg(objectName()));
|
||||
#endif
|
||||
|
||||
const bool isSecondAxis=isSecondaryAxis();
|
||||
// correct move1,move2 for the length of inside ticks for secondary axes
|
||||
double moveForTicks1=0, moveForTicks2=0;
|
||||
if (isSecondAxis && axisStyle.drawMode1.testFlag(JKQTPCADMTicks)) moveForTicks1=qMax(axisStyle.minorTickInsideLength,axisStyle.tickInsideLength);
|
||||
if (isSecondAxis && axisStyle.drawMode2.testFlag(JKQTPCADMTicks)) moveForTicks2=qMax(axisStyle.minorTickInsideLength,axisStyle.tickInsideLength);
|
||||
|
||||
|
||||
// make shure all parameters are calculated correctly
|
||||
calcPlotScaling();
|
||||
|
||||
@ -2548,8 +2571,8 @@ void JKQTPHorizontalAxisBase::drawAxes(JKQTPEnhancedPainter& painter, int move1,
|
||||
bottom=getParentOtheraxisOffset()+getParentOtheraxisWidth();//;
|
||||
}
|
||||
// move axes outside plot rectangle, if required
|
||||
top-=parent->pt2px(painter, axisStyle.axisLineOffset)+move2;
|
||||
bottom+=parent->pt2px(painter, axisStyle.axisLineOffset)+move1;
|
||||
top-=parent->pt2px(painter, axisStyle.axisLineOffset)+move2+moveForTicks2;
|
||||
bottom+=parent->pt2px(painter, axisStyle.axisLineOffset)+move1+moveForTicks1;
|
||||
|
||||
double ticklabelOffset1PT=axisStyle.tickLabelDistance; // offset of tick labels from axis 1
|
||||
double minorticklabelOffset1PT=axisStyle.tickLabelDistance; // offset ofminor tick labels from axis 1
|
||||
@ -2777,14 +2800,15 @@ void JKQTPHorizontalAxisBase::drawAxes(JKQTPEnhancedPainter& painter, int move1,
|
||||
if (getParent()->getCurrentPlotterStyle().debugShowRegionBoxes) {
|
||||
painter.save(); auto __finalpaintif=JKQTPFinally([&painter]() {painter.restore();});
|
||||
QPen p("cyan");
|
||||
QColor col=p.color(); col.setAlphaF(0.8f); p.setColor(col);
|
||||
if (isSecondAxis) p=QPen("darkcyan");
|
||||
QColor col=p.color(); col.setAlphaF(0.6f); p.setColor(col);
|
||||
p.setWidthF(getParent()->getCurrentPlotterStyle().debugRegionLineWidth);
|
||||
painter.setPen(p);
|
||||
painter.setBrush(QBrush(QColor(Qt::transparent)));
|
||||
const QSizeF s1(getParentPlotWidth(), getSize1(painter).requiredSize);
|
||||
const QSizeF s2(getParentPlotWidth(), getSize2(painter).requiredSize);
|
||||
painter.drawRect(QRectF(QPointF(left, bottom), s1));
|
||||
painter.drawRect(QRectF(QPointF(left, top-s2.height()), s2));
|
||||
painter.drawRect(QRectF(QPointF(left, bottom-moveForTicks1), s1));
|
||||
painter.drawRect(QRectF(QPointF(left, top+moveForTicks2-s2.height()), s2));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -907,6 +907,9 @@ class JKQTPLOTTER_LIB_EXPORT JKQTPCoordinateAxis: public QObject {
|
||||
/** \brief calculate the position of the zero-axis (and whether to draw it or not) */
|
||||
double getZeroAxisPos(bool* drawZeroAxis=nullptr);
|
||||
|
||||
/** \brief figures out (possibly by probing the parent JKQTBasePloter), whether this axis is a secondary axis */
|
||||
virtual bool isSecondaryAxis() const;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 15 KiB |