MCPcopy Create free account
hub / github.com/OpenBoard-org/OpenBoard / positionHandles

Method positionHandles

src/domain/UBGraphicsDelegateFrame.cpp:884–1031  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

882
883
884void UBGraphicsDelegateFrame::positionHandles()
885{
886 QRectF itemRect = delegated()->boundingRect();
887
888 if (mDelegate->getToolBarItem() && mDelegate->getToolBarItem()->isVisibleOnBoard()
889 && mDelegate->getToolBarItem()->isShifting())
890 {
891 QPointF graphicsItemPosition = itemRect.topLeft();
892 itemRect.setTopLeft(graphicsItemPosition-QPointF(0,mDelegate->getToolBarItem()->boundingRect().height()* mDelegate->antiScaleRatio()));
893 }
894
895 QTransform itemTransform = delegated()->sceneTransform();
896 QPointF topLeft = itemTransform.map(itemRect.topLeft());
897 QPointF topRight = itemTransform.map(itemRect.topRight());
898 QPointF bottomLeft = itemTransform.map(itemRect.bottomLeft());
899 QPointF bottomRight = itemTransform.map(itemRect.bottomRight());
900 QPointF center = itemTransform.map(itemRect.center());
901 int rotateHeight = QLineF(topLeft, bottomLeft).length();
902
903 // Handle the mirroring
904 if(topLeft.x() > topRight.x()){
905 QPointF topTmp = topRight;
906 QPointF bottomTmp = bottomRight;
907 topRight = topLeft;
908 topLeft = topTmp;
909 bottomRight = bottomLeft;
910 bottomLeft = bottomTmp;
911 }
912
913 if(bottomLeft.y() > topLeft.y()){
914 QPointF leftTmp = bottomLeft;
915 QPointF rightTmp = bottomRight;
916 bottomLeft = topLeft;
917 topLeft = leftTmp;
918 bottomRight = topRight;
919 topRight = rightTmp;
920 }
921
922 QLineF topLine(topLeft, topRight);
923 qreal angle = topLine.angle();
924 qreal width = topLine.length();
925
926 QLineF leftLine(topLeft, bottomLeft);
927 qreal height = leftLine.length();
928
929 int h = rotating()?rotateHeight:height;
930
931 if (mVisible)
932 {
933 setRect(center.x() - mFrameWidth - width / 2, center.y() - mFrameWidth - mTitleBarHeight - h / 2, width + 2 * mFrameWidth, h + (2 * mFrameWidth) + mTitleBarHeight);
934 }
935 else
936 {
937 setRect(center.x() - width / 2, center.y() - h / 2, width, h);
938 }
939
940 resetTransform();
941 setTransform(QTransform::fromTranslate(center.x(), center.y()), true);

Callers

nothing calls this directly

Calls 15

getToolBarItemMethod · 0.80
isVisibleOnBoardMethod · 0.80
isShiftingMethod · 0.80
antiScaleRatioMethod · 0.80
testUBFlagsMethod · 0.80
QTransformClass · 0.50
boundingRectMethod · 0.45
heightMethod · 0.45
lengthMethod · 0.45
angleMethod · 0.45
dataMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected