MCPcopy Index your code
hub / github.com/Audio4Linux/JDSP4Linux / setParentAnchorY

Method setParentAnchorY

3rdparty/qcustomplot/qcustomplot.cpp:12443–12499  ·  view source on GitHub ↗

! This method sets the parent anchor of the Y coordinate to \a parentAnchor. For a detailed description of what a parent anchor is, see the documentation of \ref setParentAnchor. \see setParentAnchor, setParentAnchorX */

Source from the content-addressed store, hash-verified

12441 \see setParentAnchor, setParentAnchorX
12442*/
12443bool QCPItemPosition::setParentAnchorY(QCPItemAnchor *parentAnchor, bool keepPixelPosition)
12444{
12445 // make sure self is not assigned as parent:
12446 if (parentAnchor == this)
12447 {
12448 qDebug() << Q_FUNC_INFO << "can't set self as parent anchor" << reinterpret_cast<quintptr>(parentAnchor);
12449 return false;
12450 }
12451 // make sure no recursive parent-child-relationships are created:
12452 QCPItemAnchor *currentParent = parentAnchor;
12453 while (currentParent)
12454 {
12455 if (QCPItemPosition *currentParentPos = currentParent->toQCPItemPosition())
12456 {
12457 // is a QCPItemPosition, might have further parent, so keep iterating
12458 if (currentParentPos == this)
12459 {
12460 qDebug() << Q_FUNC_INFO << "can't create recursive parent-child-relationship" << reinterpret_cast<quintptr>(parentAnchor);
12461 return false;
12462 }
12463 currentParent = currentParentPos->parentAnchorY();
12464 } else
12465 {
12466 // is a QCPItemAnchor, can't have further parent. Now make sure the parent items aren't the
12467 // same, to prevent a position being child of an anchor which itself depends on the position,
12468 // because they're both on the same item:
12469 if (currentParent->mParentItem == mParentItem)
12470 {
12471 qDebug() << Q_FUNC_INFO << "can't set parent to be an anchor which itself depends on this position" << reinterpret_cast<quintptr>(parentAnchor);
12472 return false;
12473 }
12474 break;
12475 }
12476 }
12477
12478 // if previously no parent set and PosType is still ptPlotCoords, set to ptAbsolute:
12479 if (!mParentAnchorY && mPositionTypeY == ptPlotCoords)
12480 setTypeY(ptAbsolute);
12481
12482 // save pixel position:
12483 QPointF pixelP;
12484 if (keepPixelPosition)
12485 pixelP = pixelPosition();
12486 // unregister at current parent anchor:
12487 if (mParentAnchorY)
12488 mParentAnchorY->removeChildY(this);
12489 // register at new parent anchor:
12490 if (parentAnchor)
12491 parentAnchor->addChildY(this);
12492 mParentAnchorY = parentAnchor;
12493 // restore pixel position under new parent:
12494 if (keepPixelPosition)
12495 setPixelPosition(pixelP);
12496 else
12497 setCoords(coords().x(), 0);
12498 return true;
12499}
12500

Callers 2

~QCPItemAnchorMethod · 0.80
~QCPItemPositionMethod · 0.80

Calls 3

coordsFunction · 0.85
removeChildYMethod · 0.80
addChildYMethod · 0.80

Tested by

no test coverage detected