MCPcopy Create free account
hub / github.com/CieNTi/serial_port_plotter / updateAxesOffset

Method updateAxesOffset

qcustomplot/qcustomplot.cpp:17737–17755  ·  view source on GitHub ↗

! \internal This function makes sure multiple axes on the side specified with \a type don't collide, but are distributed according to their respective space requirement (QCPAxis::calculateMargin). It does this by setting an appropriate offset (\ref QCPAxis::setOffset) on all axes except the one with index zero. This function is called by \ref calculateAutoMargin. */

Source from the content-addressed store, hash-verified

17735 This function is called by \ref calculateAutoMargin.
17736*/
17737void QCPAxisRect::updateAxesOffset(QCPAxis::AxisType type)
17738{
17739 const QList<QCPAxis*> axesList = mAxes.value(type);
17740 if (axesList.isEmpty())
17741 return;
17742
17743 bool isFirstVisible = !axesList.first()->visible(); // if the first axis is visible, the second axis (which is where the loop starts) isn't the first visible axis, so initialize with false
17744 for (int i=1; i<axesList.size(); ++i)
17745 {
17746 int offset = axesList.at(i-1)->offset() + axesList.at(i-1)->calculateMargin();
17747 if (axesList.at(i)->visible()) // only add inner tick length to offset if this axis is visible and it's not the first visible one (might happen if true first axis is invisible)
17748 {
17749 if (!isFirstVisible)
17750 offset += axesList.at(i)->tickLengthIn();
17751 isFirstVisible = false;
17752 }
17753 axesList.at(i)->setOffset(offset);
17754 }
17755}
17756
17757/* inherits documentation from base class */
17758int QCPAxisRect::calculateAutoMargin(QCP::MarginSide side)

Callers

nothing calls this directly

Calls 7

offsetMethod · 0.80
atMethod · 0.80
calculateMarginMethod · 0.80
tickLengthInMethod · 0.80
setOffsetMethod · 0.80
isEmptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected