Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
e0c2fdc3
Commit
e0c2fdc3
authored
Sep 07, 2012
by
Aleksei Kanash
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed some cases for resizing items.
parent
c556535e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
67 deletions
+79
-67
UBGraphicsDelegateFrame.cpp
src/domain/UBGraphicsDelegateFrame.cpp
+77
-66
UBGraphicsItemDelegate.cpp
src/domain/UBGraphicsItemDelegate.cpp
+2
-1
No files found.
src/domain/UBGraphicsDelegateFrame.cpp
View file @
e0c2fdc3
...
...
@@ -291,13 +291,18 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if
(
None
==
mCurrentTool
)
return
;
QLineF
move
(
mStartingPoint
,
event
->
scenePos
());
QLineF
move
;
if
(
rotating
()
||
moving
()
||
mOperationMode
==
Scaling
)
move
=
QLineF
(
mStartingPoint
,
event
->
scenePos
());
else
move
=
QLineF
(
event
->
lastScenePos
(),
event
->
scenePos
());
qreal
moveX
=
move
.
length
()
*
cos
((
move
.
angle
()
-
mAngle
)
*
PI
/
180
);
qreal
moveY
=
-
move
.
length
()
*
sin
((
move
.
angle
()
-
mAngle
)
*
PI
/
180
);
qreal
width
=
delegated
()
->
boundingRect
().
width
()
*
mTotalScaleX
;
qreal
height
=
delegated
()
->
boundingRect
().
height
()
*
mTotalScaleY
;
if
(
mOperationMode
==
Scaling
)
if
(
!
rotating
()
)
{
mTranslateX
=
moveX
;
// Perform the resize
...
...
@@ -398,43 +403,6 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}
}
}
else
if
(
mOperationMode
==
Resizing
||
mOperationMode
==
ResizingHorizontally
)
{
mTranslateX
=
moveX
;
UBResizableGraphicsItem
*
resizableItem
=
dynamic_cast
<
UBResizableGraphicsItem
*>
(
delegated
());
if
(
resizableItem
)
{
QLineF
mousePosDelta
(
delegated
()
->
mapFromScene
(
event
->
lastScenePos
())
,
delegated
()
->
mapFromScene
(
event
->
scenePos
()));
QSizeF
incVector
(
0
,
0
);
if
(
resizingBottomRight
())
{
incVector
=
QSizeF
(
mousePosDelta
.
dx
(),
mousePosDelta
.
dy
());
}
else
if
(
resizingRight
())
{
incVector
=
QSizeF
(
mousePosDelta
.
dx
(),
0
);
}
else
if
(
resizingBottom
())
{
incVector
=
QSizeF
(
0
,
mousePosDelta
.
dy
());
}
else
if
(
resizingLeft
())
{
incVector
=
QSizeF
(
-
mousePosDelta
.
dx
(),
0
);
}
else
if
(
resizingTop
())
{
incVector
=
QSizeF
(
0
,
-
mousePosDelta
.
dy
());
}
QSizeF
newSize
=
resizableItem
->
size
()
+
incVector
;
resizableItem
->
resize
(
newSize
);
}
}
if
(
rotating
())
{
...
...
@@ -483,49 +451,92 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
// we just detects coordinates of corner before and after scaling and then moves object at diff between them.
if
(
resizingBottomRight
()
&&
mMirrorX
)
{
mTranslateX
+=
mInitialTransform
.
map
(
delegated
()
->
boundingRect
().
bottomRight
()).
x
()
-
tr
.
map
(
delegated
()
->
boundingRect
().
bottomRight
()).
x
();
else
mTranslateX
+=
mInitialTransform
.
map
(
delegated
()
->
boundingRect
().
topLeft
()).
x
()
-
tr
.
map
(
delegated
()
->
boundingRect
().
topLeft
()).
x
();
if
(
resizingBottomRight
()
&&
mMirrorY
)
mTranslateY
+=
mInitialTransform
.
map
(
delegated
()
->
boundingRect
().
bottomRight
()).
y
()
-
tr
.
map
(
delegated
()
->
boundingRect
().
bottomRight
()).
y
();
}
else
{
mTranslateX
+=
mInitialTransform
.
map
(
delegated
()
->
boundingRect
().
topLeft
()).
x
()
-
tr
.
map
(
delegated
()
->
boundingRect
().
topLeft
()).
x
();
mTranslateY
+=
mInitialTransform
.
map
(
delegated
()
->
boundingRect
().
topLeft
()).
y
()
-
tr
.
map
(
delegated
()
->
boundingRect
().
topLeft
()).
y
();
// Update the transform
tr
=
buildTransform
();
}
else
if
(
resizingTop
()
||
resizingLeft
())
{
if
(
mOperationMode
==
Scaling
)
}
else
if
(
mOperationMode
==
Scaling
&&
(
resizingTop
()
||
resizingLeft
()))
{
QPointF
bottomRight
=
tr
.
map
(
delegated
()
->
boundingRect
().
bottomRight
());
QPointF
fixedPoint
=
mInitialTransform
.
map
(
delegated
()
->
boundingRect
().
bottomRight
());
mTranslateX
+=
fixedPoint
.
x
()
-
bottomRight
.
x
();
mTranslateY
+=
fixedPoint
.
y
()
-
bottomRight
.
y
();
}
else
if
(
mOperationMode
==
Scaling
||
moving
()
||
rotating
())
{
tr
=
buildTransform
();
delegated
()
->
setTransform
(
tr
);
}
else
if
(
mOperationMode
==
Resizing
)
{
QSizeF
originalSize
=
delegated
()
->
boundingRect
().
size
();
// QSizeF originalSize = delegated()->sceneBoundingRect().size(); //
mScaleX
=
1
;
mScaleY
=
1
;
tr
=
buildTransform
().
translate
(
moveX
,
moveY
);
if
(
resizingRight
()
||
resizingBottom
()
||
resizingBottomRight
()
||
resizingTop
()
||
resizingLeft
())
{
QLineF
vector
;
if
(
resizingLeft
())
qreal
dPosX
;
qreal
dPosY
;
if
(
resizingTop
()
||
resizingLeft
())
{
QPointF
topRight1
=
mInitialTransform
.
map
(
QPointF
(
delegated
()
->
boundingRect
().
width
()
-
moveX
,
0
));
QPointF
topRight2
=
mInitialTransform
.
map
(
QPointF
(
delegated
()
->
boundingRect
().
width
(),
0
));
vector
.
setPoints
(
topRight1
,
topRight2
);
dPosX
=
mMirrorX
?
moveX
:
-
moveX
;
dPosY
=
mMirrorY
?
moveY
:
-
moveY
;
}
else
if
(
resizingBottomRight
())
{
dPosX
=
moveX
;
dPosY
=
moveY
;
}
else
{
QPointF
bottomLeft1
=
mInitialTransform
.
map
(
QPointF
(
0
,
delegated
()
->
boundingRect
().
height
()
-
moveY
));
QPointF
bottomLeft2
=
mInitialTransform
.
map
(
QPointF
(
0
,
delegated
()
->
boundingRect
().
height
()));
vector
.
setPoints
(
bottomLeft1
,
bottomLeft2
);
dPosX
=
mMirrorX
?
-
moveX
:
moveX
;
dPosY
=
mMirrorY
?
-
moveY
:
moveY
;
}
QPointF
oldPos
;
if
(
mMirrorX
)
oldPos
=
delegated
()
->
sceneBoundingRect
().
topLeft
();
else
oldPos
=
delegated
()
->
sceneBoundingRect
().
bottomRight
();
delegated
()
->
setTransform
(
tr
);
UBResizableGraphicsItem
*
resizableItem
=
dynamic_cast
<
UBResizableGraphicsItem
*>
(
delegated
());
if
(
resizableItem
)
{
resizableItem
->
resize
(
originalSize
.
width
()
+
dPosX
,
originalSize
.
height
()
+
dPosY
);
if
(
resizingTop
()
||
resizingLeft
()
||
(
mMirrorX
&&
resizingBottomRight
()))
{
QPointF
newPos
;
if
(
mMirrorX
)
newPos
=
delegated
()
->
sceneBoundingRect
().
topLeft
();
else
newPos
=
delegated
()
->
sceneBoundingRect
().
bottomRight
();
delegated
()
->
setPos
(
delegated
()
->
pos
()
-
newPos
+
oldPos
);
}
}
mTranslateX
=
vector
.
dx
();
mTranslateY
=
vector
.
dy
();
}
tr
=
buildTransform
();
}
delegated
()
->
setTransform
(
tr
);
event
->
accept
();
}
...
...
src/domain/UBGraphicsItemDelegate.cpp
View file @
e0c2fdc3
...
...
@@ -166,6 +166,7 @@ void UBGraphicsItemDelegate::init()
UBGraphicsItemDelegate
::~
UBGraphicsItemDelegate
()
{
if
(
UBApplication
::
boardController
)
disconnect
(
UBApplication
::
boardController
,
SIGNAL
(
zoomChanged
(
qreal
)),
this
,
SLOT
(
onZoomChanged
()));
// do not release mMimeData.
// the mMimeData is owned by QDrag since the setMimeData call as specified in the documentation
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment