|
|
@ -40,8 +40,8 @@ UBGraphicsAristo::UBGraphicsAristo() |
|
|
|
, mResizing(false) |
|
|
|
, mResizing(false) |
|
|
|
, mRotating(false) |
|
|
|
, mRotating(false) |
|
|
|
, mOrientation(Undefined) |
|
|
|
, mOrientation(Undefined) |
|
|
|
, mAngle(0) |
|
|
|
, mRotatedAngle(0) |
|
|
|
, mCurrentAngle(0) |
|
|
|
, mMarkerAngle(0) |
|
|
|
, mStartAngle(0) |
|
|
|
, mStartAngle(0) |
|
|
|
, mSpan(180) |
|
|
|
, mSpan(180) |
|
|
|
, mHFlipSvgItem(0) |
|
|
|
, mHFlipSvgItem(0) |
|
|
@ -190,8 +190,11 @@ void UBGraphicsAristo::copyItemParameters(UBItem *copy) const |
|
|
|
{
|
|
|
|
{
|
|
|
|
/* TODO: copy all members */ |
|
|
|
/* TODO: copy all members */ |
|
|
|
cp->setPos(this->pos()); |
|
|
|
cp->setPos(this->pos()); |
|
|
|
cp->setPath(this->path()); |
|
|
|
|
|
|
|
cp->setTransform(this->transform()); |
|
|
|
cp->setTransform(this->transform()); |
|
|
|
|
|
|
|
cp->setBoundingRect(boundingRect()); |
|
|
|
|
|
|
|
cp->setOrientation(mOrientation); |
|
|
|
|
|
|
|
cp->mRotatedAngle = mRotatedAngle; |
|
|
|
|
|
|
|
cp->mMarkerAngle = mMarkerAngle; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -401,23 +404,23 @@ void UBGraphicsAristo::paintMarker(QPainter *painter) |
|
|
|
/* adjusting marker button */ |
|
|
|
/* adjusting marker button */ |
|
|
|
mMarkerSvgItem->resetTransform(); |
|
|
|
mMarkerSvgItem->resetTransform(); |
|
|
|
mMarkerSvgItem->translate(-markerButtonRect().left(), -markerButtonRect().top()); |
|
|
|
mMarkerSvgItem->translate(-markerButtonRect().left(), -markerButtonRect().top()); |
|
|
|
mMarkerSvgItem->rotate(mCurrentAngle); |
|
|
|
mMarkerSvgItem->rotate(mMarkerAngle); |
|
|
|
mMarkerSvgItem->translate(markerButtonRect().left(), markerButtonRect().top()); |
|
|
|
mMarkerSvgItem->translate(markerButtonRect().left(), markerButtonRect().top()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qreal co = cos((mCurrentAngle) * PI/180); |
|
|
|
qreal co = cos((mMarkerAngle) * PI/180); |
|
|
|
qreal si = sin((mCurrentAngle) * PI/180); |
|
|
|
qreal si = sin((mMarkerAngle) * PI/180); |
|
|
|
|
|
|
|
|
|
|
|
/* Setting point composing the line (from point C) which intersects the line we want to draw. */ |
|
|
|
/* Setting point composing the line (from point C) which intersects the line we want to draw. */ |
|
|
|
QPointF referencePoint; |
|
|
|
QPointF referencePoint; |
|
|
|
if (mOrientation == Bottom) { |
|
|
|
if (mOrientation == Bottom) { |
|
|
|
if ((int)mCurrentAngle % 360 < 90) |
|
|
|
if ((int)mMarkerAngle % 360 < 90) |
|
|
|
referencePoint = B; |
|
|
|
referencePoint = B; |
|
|
|
else |
|
|
|
else |
|
|
|
referencePoint = A; |
|
|
|
referencePoint = A; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (mOrientation == Top) { |
|
|
|
else if (mOrientation == Top) { |
|
|
|
if ((int)mCurrentAngle % 360 < 270 && (int)mCurrentAngle % 360 > 0) |
|
|
|
if ((int)mMarkerAngle % 360 < 270 && (int)mMarkerAngle % 360 > 0) |
|
|
|
referencePoint = A; |
|
|
|
referencePoint = A; |
|
|
|
else |
|
|
|
else |
|
|
|
referencePoint = B; |
|
|
|
referencePoint = B; |
|
|
@ -430,7 +433,7 @@ void UBGraphicsAristo::paintMarker(QPainter *painter) |
|
|
|
painter->drawLine(QLineF(intersectionPoint, rotationCenter())); |
|
|
|
painter->drawLine(QLineF(intersectionPoint, rotationCenter())); |
|
|
|
|
|
|
|
|
|
|
|
/* drawing angle value */ |
|
|
|
/* drawing angle value */ |
|
|
|
qreal rightAngle = mOrientation == Bottom ? mCurrentAngle : 360 - mCurrentAngle; |
|
|
|
qreal rightAngle = mOrientation == Bottom ? mMarkerAngle : 360 - mMarkerAngle; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString angleText = QString("%1°").arg(rightAngle, 0, 'f', 1); |
|
|
|
QString angleText = QString("%1°").arg(rightAngle, 0, 'f', 1); |
|
|
@ -450,18 +453,18 @@ void UBGraphicsAristo::paintMarker(QPainter *painter) |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsAristo::rotateAroundCenter(qreal angle) |
|
|
|
void UBGraphicsAristo::rotateAroundCenter(qreal angle) |
|
|
|
{ |
|
|
|
{ |
|
|
|
qreal oldAngle = mAngle; |
|
|
|
qreal oldAngle = mRotatedAngle; |
|
|
|
mAngle = angle; |
|
|
|
mRotatedAngle = angle; |
|
|
|
QTransform transform; |
|
|
|
QTransform transform; |
|
|
|
rotateAroundCenter(transform, rotationCenter()); |
|
|
|
rotateAroundCenter(transform, rotationCenter()); |
|
|
|
setTransform(transform, true); |
|
|
|
setTransform(transform, true); |
|
|
|
mAngle = oldAngle + angle; // We have to store absolute value for FLIP case
|
|
|
|
mRotatedAngle = oldAngle + angle; // We have to store absolute value for FLIP case
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsAristo::rotateAroundCenter(QTransform& transform, QPointF center) |
|
|
|
void UBGraphicsAristo::rotateAroundCenter(QTransform& transform, QPointF center) |
|
|
|
{ |
|
|
|
{ |
|
|
|
transform.translate(center.x(), center.y()); |
|
|
|
transform.translate(center.x(), center.y()); |
|
|
|
transform.rotate(mAngle); |
|
|
|
transform.rotate(mRotatedAngle); |
|
|
|
transform.translate(- center.x(), - center.y()); |
|
|
|
transform.translate(- center.x(), - center.y()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -582,20 +585,20 @@ void UBGraphicsAristo::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
else if(mMarking) { |
|
|
|
else if(mMarking) { |
|
|
|
qreal angle = currentLine.angleTo(lastLine); |
|
|
|
qreal angle = currentLine.angleTo(lastLine); |
|
|
|
|
|
|
|
|
|
|
|
mCurrentAngle += angle; |
|
|
|
mMarkerAngle += angle; |
|
|
|
mCurrentAngle -= (int)(mCurrentAngle/360)*360; |
|
|
|
mMarkerAngle -= (int)(mMarkerAngle/360)*360; |
|
|
|
|
|
|
|
|
|
|
|
if (mOrientation == Bottom) { |
|
|
|
if (mOrientation == Bottom) { |
|
|
|
if (mCurrentAngle >= 270) |
|
|
|
if (mMarkerAngle >= 270) |
|
|
|
mCurrentAngle = 0; |
|
|
|
mMarkerAngle = 0; |
|
|
|
else if (mCurrentAngle > 180) |
|
|
|
else if (mMarkerAngle > 180) |
|
|
|
mCurrentAngle = 180; |
|
|
|
mMarkerAngle = 180; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (mOrientation == Top) { |
|
|
|
else if (mOrientation == Top) { |
|
|
|
if (mCurrentAngle < 90) |
|
|
|
if (mMarkerAngle < 90) |
|
|
|
mCurrentAngle = 360; |
|
|
|
mMarkerAngle = 360; |
|
|
|
else if (mCurrentAngle < 180) |
|
|
|
else if (mMarkerAngle < 180) |
|
|
|
mCurrentAngle = 180; |
|
|
|
mMarkerAngle = 180; |
|
|
|
} |
|
|
|
} |
|
|
|
update(); |
|
|
|
update(); |
|
|
|
} |
|
|
|
} |
|
|
@ -622,7 +625,7 @@ void UBGraphicsAristo::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
break; |
|
|
|
break; |
|
|
|
case HorizontalFlip: |
|
|
|
case HorizontalFlip: |
|
|
|
/* substracting difference to zero [2pi] twice, to obtain the desired angle */ |
|
|
|
/* substracting difference to zero [2pi] twice, to obtain the desired angle */ |
|
|
|
mCurrentAngle -= 2 * (mCurrentAngle - (int)(mCurrentAngle/360)*360) - 360; |
|
|
|
mMarkerAngle -= 2 * (mMarkerAngle - (int)(mMarkerAngle/360)*360) - 360; |
|
|
|
/* setting new orientation */ |
|
|
|
/* setting new orientation */ |
|
|
|
switch(mOrientation) { |
|
|
|
switch(mOrientation) { |
|
|
|
case Bottom: |
|
|
|
case Bottom: |
|
|
@ -749,7 +752,7 @@ UBGraphicsAristo::Tool UBGraphicsAristo::toolFromPos(QPointF pos) |
|
|
|
{ |
|
|
|
{ |
|
|
|
pos = pos - rotationCenter(); |
|
|
|
pos = pos - rotationCenter(); |
|
|
|
|
|
|
|
|
|
|
|
qreal rotationAngle = mOrientation == Bottom ? - mCurrentAngle : Top ? 360 * (int)(mCurrentAngle / 360 + 1) - mCurrentAngle : 0; |
|
|
|
qreal rotationAngle = mOrientation == Bottom ? - mMarkerAngle : Top ? 360 * (int)(mMarkerAngle / 360 + 1) - mMarkerAngle : 0; |
|
|
|
|
|
|
|
|
|
|
|
QTransform t; |
|
|
|
QTransform t; |
|
|
|
t.rotate(rotationAngle); |
|
|
|
t.rotate(rotationAngle); |
|
|
|