Updated geometric functions (transform, scale, rotate) for Qt5 comp.

preferencesAboutTextFull
Craig Watson 9 years ago
parent 4b15c535ec
commit a2c2c2c4e1
  1. 7
      src/domain/UBGraphicsDelegateFrame.cpp
  2. 2
      src/domain/UBGraphicsItemDelegate.cpp
  3. 2
      src/domain/UBGraphicsMediaItem.cpp
  4. 8
      src/domain/UBGraphicsScene.cpp
  5. 2
      src/domain/UBSelectionFrame.cpp
  6. 48
      src/tools/UBGraphicsProtractor.cpp

@ -832,9 +832,10 @@ void UBGraphicsDelegateFrame::positionHandles()
}
resetTransform();
translate(center.x(), center.y());
rotate(-angle);
translate(-center.x(), -center.y());
setTransform(QTransform::fromTranslate(center.x(), center.y()), true);
setTransform(QTransform().rotate(-angle), true);
setTransform(QTransform::fromTranslate(-center.x(), -center.y()), true);
//TODO: combine these transforms into one
mBottomRightResizeGripSvgItem->setParentItem(this);
mBottomResizeGripSvgItem->setParentItem(this);

@ -792,7 +792,7 @@ void UBGraphicsItemDelegate::updateButtons(bool showUpdated)
button->setParentItem(mFrame);
button->setPos(topXTitleBar + (k++ * (frameButtonHeight + 5)), topYTitleBar);
button->setTransform(tr);
button->scale(0.8,0.8);
button->setTransform(QTransform::fromScale(0.8, 0.8), true);
}
else if(button->getSection() == Qt::NoSection){
++l;

@ -318,7 +318,7 @@ void UBGraphicsMediaItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
QPointF eventPos = mapFromScene( event->scenePos());
QPointF translation = eventPos - mouseMovePos;
translate(translation.x(), translation.y());
setTransform(QTransform::fromTranslate(translation.x(), translation.y()), true);
}
mMouseMovePos = event->scenePos();

@ -1264,7 +1264,7 @@ UBGraphicsPixmapItem* UBGraphicsScene::addPixmap(const QPixmap& pPixmap, QGraphi
UBApplication::undoStack->push(uc);
}
pixmapItem->scale(pScaleFactor, pScaleFactor);
pixmapItem->setTransform(QTransform::fromScale(pScaleFactor, pScaleFactor), true);
if (pUseAnimation)
{
@ -1403,7 +1403,7 @@ void UBGraphicsScene::addGraphicsWidget(UBGraphicsWidgetItem* graphicsWidget, co
qreal ssf = 1 / UBApplication::boardController->systemScaleFactor();
graphicsWidget->scale(ssf, ssf);
graphicsWidget->setTransform(QTransform::fromScale(ssf, ssf), true);
graphicsWidget->setPos(QPointF(pPos.x() - graphicsWidget->boundingRect().width() / 2,
pPos.y() - graphicsWidget->boundingRect().height() / 2));
@ -1530,7 +1530,7 @@ UBGraphicsSvgItem* UBGraphicsScene::addSvg(const QUrl& pSvgFileUrl, const QPoint
svgItem->setFlag(QGraphicsItem::ItemIsSelectable, true);
qreal sscale = 1 / UBApplication::boardController->systemScaleFactor();
svgItem->scale(sscale, sscale);
svgItem->setTransform(QTransform::fromScale(sscale, sscale), true);
QPointF half(svgItem->boundingRect().width() / 2, svgItem->boundingRect().height() / 2);
svgItem->setPos(pPos - half);
@ -1860,7 +1860,7 @@ QGraphicsItem* UBGraphicsScene::scaleToFitDocumentSize(QGraphicsItem* item, bool
{
qreal ratio = qMin(maxWidth / size.width(), maxHeight / size.height());
item->scale(ratio, ratio);
item->setTransform(QTransform::fromScale(ratio, ratio), true);
if(center)
{

@ -157,7 +157,7 @@ void UBSelectionFrame::mousePressEvent(QGraphicsSceneMouseEvent *event)
mLastTranslateOffset = QPointF();
mRotationAngle = 0;
if (scene()->itemAt(event->scenePos()) == mRotateButton) {
if (scene()->itemAt(event->scenePos(), transform()) == mRotateButton) {
mOperationMode = om_rotating;
} else {
mOperationMode = om_moving;

@ -78,7 +78,7 @@ UBGraphicsProtractor::UBGraphicsProtractor()
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly
setFlag(QGraphicsItem::ItemIsSelectable, false);
scale(1.5, 1.5);
setTransform(QTransform::fromScale(1.5, 1.5), true);
}
@ -201,9 +201,9 @@ void UBGraphicsProtractor::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
case Resize :
prepareGeometryChange();
translate(rect().center().x(), rect().center().y());
scale(scaleFactor, scaleFactor);
translate(-rect().center().x(), -rect().center().y());
setTransform(QTransform::fromTranslate(rect().center().x(), rect().center().y()), true);
setTransform(QTransform::fromScale(scaleFactor, scaleFactor), true);
setTransform(QTransform::fromTranslate(-rect().center().x(), -rect().center().y()), true);
mScaleFactor *= scaleFactor;
break;
@ -445,40 +445,40 @@ void UBGraphicsProtractor::paintButtons(QPainter *painter)
qreal scale = buttonSizeReference().width() / mCloseSvgItem->boundingRect().width();
mCloseSvgItem->setPos(closeButtonRect().topLeft() + rect().center());
mCloseSvgItem->resetTransform();
mCloseSvgItem->translate(-closeButtonRect().left(),-closeButtonRect().top());
mCloseSvgItem->rotate(-mStartAngle);
mCloseSvgItem->translate(closeButtonRect().left(), closeButtonRect().top());
mCloseSvgItem->scale(scale * antiSc, scale * antiSc);//this do not impact the bounding box of thr svg item...
mCloseSvgItem->setTransform(QTransform::fromTranslate(-closeButtonRect().left(),-closeButtonRect().top()), true);
mCloseSvgItem->setRotation(rotation() -mStartAngle);
mCloseSvgItem->setTransform(QTransform::fromTranslate(closeButtonRect().left(), closeButtonRect().top()), true);
mCloseSvgItem->setTransform(QTransform::fromScale(scale * antiSc, scale * antiSc), true);//this do not impact the bounding box of thr svg item...
mResetSvgItem->setPos(resetButtonRect().topLeft() + rect().center());
mResetSvgItem->resetTransform();
mResetSvgItem->translate(-resetButtonRect().left(), -resetButtonRect().top());
mResetSvgItem->rotate(-mStartAngle);
mResetSvgItem->translate(resetButtonRect().left(), resetButtonRect().top());
mResetSvgItem->scale(scale * antiSc, scale * antiSc);//this do not impact the bounding box of thr svg item...
mResetSvgItem->setTransform(QTransform::fromTranslate(-resetButtonRect().left(), -resetButtonRect().top()), true);
mResetSvgItem->setRotation(rotation() -mStartAngle);
mResetSvgItem->setTransform(QTransform::fromTranslate(resetButtonRect().left(), resetButtonRect().top()), true);
mResetSvgItem->setTransform(QTransform::fromScale(scale * antiSc, scale * antiSc), true);//this do not impact the bounding box of thr svg item...
mResizeSvgItem->setPos(resizeButtonRect().topLeft() + rect().center());
mResizeSvgItem->resetTransform();
mResizeSvgItem->translate(-resizeButtonRect().left(), -resizeButtonRect().top());
mResizeSvgItem->rotate(-mStartAngle);
mResizeSvgItem->translate(resizeButtonRect().left(), resizeButtonRect().top());
mResizeSvgItem->scale(scale * antiSc, scale * antiSc);//this do not impact the bounding box of thr svg item...
mResizeSvgItem->setTransform(QTransform::fromTranslate(-resizeButtonRect().left(), -resizeButtonRect().top()), true);
mResizeSvgItem->setRotation(rotation() -mStartAngle);
mResizeSvgItem->setTransform(QTransform::fromTranslate(resizeButtonRect().left(), resizeButtonRect().top()), true);
mResizeSvgItem->setTransform(QTransform::fromScale(scale * antiSc, scale * antiSc), true);//this do not impact the bounding box of thr svg item...
mRotateSvgItem->setPos(rotateButtonRect().topLeft() + rect().center());
mRotateSvgItem->resetTransform();
mRotateSvgItem->translate(-rotateButtonRect().left(), -rotateButtonRect().top());
mRotateSvgItem->rotate(-mStartAngle);
mRotateSvgItem->translate(rotateButtonRect().left(), rotateButtonRect().top());
mRotateSvgItem->scale(scale, scale);//this do not impact the bounding box of thr svg item...
mRotateSvgItem->setTransform(QTransform::fromTranslate(-rotateButtonRect().left(), -rotateButtonRect().top()), true);
mRotateSvgItem->setRotation(rotation() -mStartAngle);
mRotateSvgItem->setTransform(QTransform::fromTranslate(rotateButtonRect().left(), rotateButtonRect().top()), true);
mRotateSvgItem->setTransform(QTransform::fromScale(scale, scale), true);//this do not impact the bounding box of thr svg item...
}
qreal scale = markerSizeReference().width()/mMarkerSvgItem->boundingRect().width();
mMarkerSvgItem->setPos(markerButtonRect().topLeft() + rect().center());
mMarkerSvgItem->resetTransform();
mMarkerSvgItem->translate(-markerButtonRect().left(), -markerButtonRect().top());
mMarkerSvgItem->rotate(- mStartAngle - mCurrentAngle);
mMarkerSvgItem->translate(markerButtonRect().left(), markerButtonRect().top());
mMarkerSvgItem->scale(scale, scale);//this do not impact the bounding box of thr svg item...
mMarkerSvgItem->setTransform(QTransform::fromTranslate(-markerButtonRect().left(), -markerButtonRect().top()), true);
mMarkerSvgItem->setRotation(rotation() - mStartAngle - mCurrentAngle);
mMarkerSvgItem->setTransform(QTransform::fromTranslate(markerButtonRect().left(), markerButtonRect().top()), true);
mMarkerSvgItem->setTransform(QTransform::fromScale(scale, scale), true);//this do not impact the bounding box of thr svg item...
mCloseSvgItem->setVisible(mShowButtons);
mResetSvgItem->setVisible(mShowButtons);

Loading…
Cancel
Save