fixed issue on mirroring

preferencesAboutTextFull
Claudio Valerio 13 years ago
parent 544568bc2b
commit 4f8648e8b6
  1. 12
      src/domain/UBGraphicsDelegateFrame.cpp

@ -71,9 +71,11 @@ UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelega
mBottomResizeGrip = new QGraphicsRectItem(this); mBottomResizeGrip = new QGraphicsRectItem(this);
mBottomResizeGrip->setPen(Qt::NoPen); mBottomResizeGrip->setPen(Qt::NoPen);
mLeftResizeGrip = new QGraphicsRectItem(this); mLeftResizeGrip = new QGraphicsRectItem(this);
mLeftResizeGrip->setToolTip("left");
mLeftResizeGrip->setPen(Qt::NoPen); mLeftResizeGrip->setPen(Qt::NoPen);
mRightResizeGrip = new QGraphicsRectItem(this); mRightResizeGrip = new QGraphicsRectItem(this);
mRightResizeGrip->setPen(Qt::NoPen); mRightResizeGrip->setPen(Qt::NoPen);
mRightResizeGrip->setToolTip("Right");
mTopResizeGrip = new QGraphicsRectItem(this); mTopResizeGrip = new QGraphicsRectItem(this);
mTopResizeGrip->setPen(Qt::NoPen); mTopResizeGrip->setPen(Qt::NoPen);
@ -159,6 +161,7 @@ void UBGraphicsDelegateFrame::initializeTransform()
QPointF bottomLeft = itemTransform.map(itemRect.bottomLeft()); QPointF bottomLeft = itemTransform.map(itemRect.bottomLeft());
qreal horizontalFlip = (topLeft.x() > topRight.x()) ? -1 : 1; qreal horizontalFlip = (topLeft.x() > topRight.x()) ? -1 : 1;
mMirrorX = horizontalFlip < 0 ;
if(horizontalFlip < 0){ if(horizontalFlip < 0){
// why this is because of the way of calculating the translations that checks which side is the most is the // why this is because of the way of calculating the translations that checks which side is the most is the
// nearest instead of checking which one is the left side. // nearest instead of checking which one is the left side.
@ -172,12 +175,15 @@ void UBGraphicsDelegateFrame::initializeTransform()
qreal verticalFlip = (bottomLeft.y() < topLeft.y()) ? -1 : 1; qreal verticalFlip = (bottomLeft.y() < topLeft.y()) ? -1 : 1;
// not sure that is usefull // not sure that is usefull
if(verticalFlip < 0){ mMirrorY = verticalFlip < 0;
if(verticalFlip < 0 && !mMirrorX){
topLeft = itemTransform.map(itemRect.bottomLeft()); topLeft = itemTransform.map(itemRect.bottomLeft());
topRight = itemTransform.map(itemRect.bottomRight()); topRight = itemTransform.map(itemRect.bottomRight());
bottomLeft = itemTransform.map(itemRect.topLeft()); bottomLeft = itemTransform.map(itemRect.topLeft());
} }
qDebug() << "mMirrorX " << mMirrorX << " ,mMirrorY " << mMirrorY;
QLineF topLine(topLeft, topRight); QLineF topLine(topLeft, topRight);
QLineF leftLine(topLeft, bottomLeft); QLineF leftLine(topLeft, bottomLeft);
qreal width = topLine.length(); qreal width = topLine.length();
@ -278,7 +284,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if(mDelegate->isFlippable() && qAbs(scaleX) != 0){ if(mDelegate->isFlippable() && qAbs(scaleX) != 0){
if((qAbs(width * scaleX)) < 2*mFrameWidth){ if((qAbs(width * scaleX)) < 2*mFrameWidth){
bool negative = (scaleX < 0)?true:false; bool negative = (scaleX < 0)?true:false;
mMirrorX = (negative?mMirrorX:!mMirrorX); //mMirrorX = (negative?mMirrorX:!mMirrorX);
if(negative){ if(negative){
scaleX = -2*mFrameWidth/width; scaleX = -2*mFrameWidth/width;
}else{ }else{
@ -305,7 +311,7 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if(mDelegate->isFlippable() && qAbs(scaleY) != 0){ if(mDelegate->isFlippable() && qAbs(scaleY) != 0){
if((qAbs(height * scaleY)) < 2*mFrameWidth){ if((qAbs(height * scaleY)) < 2*mFrameWidth){
bool negative = (scaleY < 0)?true:false; bool negative = (scaleY < 0)?true:false;
mMirrorY = (negative?mMirrorY:!mMirrorY); //mMirrorY = (negative?mMirrorY:!mMirrorY);
if(negative){ if(negative){
scaleY = -2*mFrameWidth/width; scaleY = -2*mFrameWidth/width;
}else{ }else{

Loading…
Cancel
Save