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
3d3a040b
Commit
3d3a040b
authored
Sep 20, 2012
by
Aleksei Kanash
Browse files
Options
Browse Files
Download
Plain Diff
Merge fix for resizing of items from aleksei_kanash_dev.
parents
ab25ec27
be07b400
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
160 additions
and
144 deletions
+160
-144
UBBoardView.cpp
src/board/UBBoardView.cpp
+0
-3
UBGraphicsDelegateFrame.cpp
src/domain/UBGraphicsDelegateFrame.cpp
+157
-140
UBGraphicsDelegateFrame.h
src/domain/UBGraphicsDelegateFrame.h
+3
-1
No files found.
src/board/UBBoardView.cpp
View file @
3d3a040b
...
...
@@ -749,9 +749,6 @@ void UBBoardView::handleItemMousePress(QMouseEvent *event)
void
UBBoardView
::
handleItemMouseMove
(
QMouseEvent
*
event
)
{
if
(
!
movingItem
)
return
;
// determine item to move (maybee we need to move group of item or his parent.
movingItem
=
determineItemToMove
(
movingItem
);
...
...
src/domain/UBGraphicsDelegateFrame.cpp
View file @
3d3a040b
...
...
@@ -224,12 +224,14 @@ void UBGraphicsDelegateFrame::mousePressEvent(QGraphicsSceneMouseEvent *event)
mAngleOffset
=
0
;
mInitialTransform
=
buildTransform
();
mOriginalSize
=
delegated
()
->
boundingRect
().
size
();
mCurrentTool
=
toolFromPos
(
event
->
pos
());
setCursorFromAngle
(
QString
::
number
((
int
)
mAngle
%
360
));
event
->
accept
();
prepareFramesToMove
(
getLinkedFrames
());
if
(
moving
())
prepareFramesToMove
(
getLinkedFrames
());
}
...
...
@@ -358,20 +360,25 @@ QSizeF UBGraphicsDelegateFrame::getResizeVector(qreal moveX, qreal moveY)
return
QSizeF
(
dPosX
,
dPosY
);
}
void
UBGraphicsDelegateFrame
::
resizeDelegate
(
qreal
moveX
,
qreal
moveY
)
QSizeF
UBGraphicsDelegateFrame
::
resizeDelegate
(
qreal
moveX
,
qreal
moveY
)
{
QPointF
fixedPoint
=
getFixedPointFromPos
();
QSizeF
incVector
;
mFixedPoint
=
getFixedPointFromPos
();
UBResizableGraphicsItem
*
resizableItem
=
dynamic_cast
<
UBResizableGraphicsItem
*>
(
delegated
());
if
(
resizableItem
)
{
QSizeF
originalSize
=
delegated
()
->
boundingRect
().
size
();
resizableItem
->
resize
(
originalSize
+
getResizeVector
(
moveX
,
moveY
)
);
incVector
=
getResizeVector
(
moveX
,
moveY
);
resizableItem
->
resize
(
mOriginalSize
+
incVector
);
if
(
resizingTop
()
||
resizingLeft
()
||
((
mMirrorX
||
mMirrorY
)
&&
resizingBottomRight
()))
{
delegated
()
->
setPos
(
delegated
()
->
pos
()
-
getFixedPointFromPos
()
+
fixedPoint
);
QPointF
pos1
=
getFixedPointFromPos
();
delegated
()
->
setPos
(
delegated
()
->
pos
()
-
pos1
+
mFixedPoint
);
}
}
return
incVector
;
}
void
UBGraphicsDelegateFrame
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
...
...
@@ -379,113 +386,111 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if
(
None
==
mCurrentTool
)
return
;
QLineF
move
;
if
(
rotating
()
||
moving
()
||
mOperationMode
==
Scaling
)
move
=
QLineF
(
mStartingPoint
,
event
->
scenePos
());
else
move
=
QLineF
(
event
->
lastScenePos
(),
event
->
scenePos
());
QLineF
move
=
QLineF
(
mStartingPoint
,
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
(
!
rotating
())
{
mTranslateX
=
moveX
;
// Perform the resize
if
(
resizingBottomRight
())
if
(
mOperationMode
==
Scaling
)
{
if
(
!
rotating
())
{
// -----------------------------------------------------
// ! We want to keep the aspect ratio with this resize !
// -----------------------------------------------------
qreal
scaleX
;
qreal
scaleY
;
if
(
!
mMirrorX
){
scaleX
=
(
width
+
moveX
)
/
width
;
}
else
{
scaleX
=
(
width
-
moveX
)
/
width
;
}
if
(
!
mMirrorY
){
scaleY
=
(
height
+
moveY
)
/
height
;
}
else
{
scaleY
=
(
height
-
moveY
)
/
height
;
}
mTranslateX
=
moveX
;
// Perform the resize
if
(
resizingBottomRight
())
{
// -----------------------------------------------------
// ! We want to keep the aspect ratio with this resize !
// -----------------------------------------------------
qreal
scaleX
;
qreal
scaleY
;
qreal
scaleFactor
=
(
scaleX
+
scaleY
)
/
2
;
if
(
!
mMirrorX
){
scaleX
=
(
width
+
moveX
)
/
width
;
}
else
{
scaleX
=
(
width
-
moveX
)
/
width
;
}
// Do not allow resizing of image size under frame size
if
(
canResizeBottomRight
(
width
,
height
,
scaleFactor
))
{
if
(
mRespectRatio
)
{
mScaleX
=
scaleFactor
;
mScaleY
=
scaleFactor
;
if
(
!
mMirrorY
){
scaleY
=
(
height
+
moveY
)
/
height
;
}
else
{
scaleY
=
(
height
-
moveY
)
/
height
;
}
else
qreal
scaleFactor
=
(
scaleX
+
scaleY
)
/
2
;
// Do not allow resizing of image size under frame size
if
(
canResizeBottomRight
(
width
,
height
,
scaleFactor
))
{
mScaleX
=
scaleX
;
mScaleY
=
scaleY
;
}
}
}
else
if
(
resizingLeft
()
||
resizingRight
())
{
if
(
width
!=
0
){
qreal
scaleX
=
0.0
;
if
(
resizingLeft
()){
scaleX
=
(
width
-
moveX
)
/
width
;
}
else
if
(
resizingRight
()){
scaleX
=
(
width
+
moveX
)
/
width
;
}
if
(
mDelegate
->
isFlippable
()
&&
qAbs
(
scaleX
)
!=
0
){
if
((
qAbs
(
width
*
scaleX
))
<
2
*
mFrameWidth
){
bool
negative
=
(
scaleX
<
0
)
?
true
:
false
;
if
(
negative
){
if
(
mMirrorX
)
scaleX
=
2
*
mFrameWidth
/
width
;
else
scaleX
=
-
2
*
mFrameWidth
/
width
;
}
else
{
scaleX
=
-
1
;
}
if
(
mRespectRatio
)
{
mScaleX
=
scaleFactor
;
mScaleY
=
scaleFactor
;
}
mScaleX
=
scaleX
;
}
else
if
(
scaleX
>
1
||
(
width
*
scaleX
)
>
2
*
mFrameWidth
){
mScaleX
=
scaleX
;
if
(
resizingLeft
()){
mTranslateX
=
moveX
;
else
{
mScaleX
=
scaleX
;
mScaleY
=
scaleY
;
}
}
}
}
else
if
(
resizingTop
()
||
resizingBottom
()){
if
(
height
!=
0
){
qreal
scaleY
=
0.0
;
if
(
resizingTop
()){
scaleY
=
(
height
-
moveY
)
/
height
;
}
else
if
(
resizingBottom
()){
scaleY
=
(
height
+
moveY
)
/
height
;
}
if
(
mDelegate
->
isFlippable
()
&&
qAbs
(
scaleY
)
!=
0
){
if
((
qAbs
(
height
*
scaleY
))
<
2
*
mFrameWidth
){
bool
negative
=
(
scaleY
<
0
)
?
true
:
false
;
if
(
negative
){
if
(
mMirrorY
)
scaleY
=
2
*
mFrameWidth
/
width
;
else
scaleY
=
-
2
*
mFrameWidth
/
width
;
}
else
{
scaleY
=
-
1
;
}
else
if
(
resizingLeft
()
||
resizingRight
())
{
if
(
width
!=
0
){
qreal
scaleX
=
0.0
;
if
(
resizingLeft
()){
scaleX
=
(
width
-
moveX
)
/
width
;
}
else
if
(
resizingRight
()){
scaleX
=
(
width
+
moveX
)
/
width
;
}
if
(
mDelegate
->
isFlippable
()
&&
qAbs
(
scaleX
)
!=
0
){
if
((
qAbs
(
width
*
scaleX
))
<
2
*
mFrameWidth
){
bool
negative
=
(
scaleX
<
0
)
?
true
:
false
;
if
(
negative
){
if
(
mMirrorX
)
scaleX
=
2
*
mFrameWidth
/
width
;
else
scaleX
=
-
2
*
mFrameWidth
/
width
;
}
else
{
scaleX
=
-
1
;
}
}
mScaleX
=
scaleX
;
}
else
if
(
scaleX
>
1
||
(
width
*
scaleX
)
>
2
*
mFrameWidth
){
mScaleX
=
scaleX
;
if
(
resizingLeft
()){
mTranslateX
=
moveX
;
}
}
mScaleY
=
scaleY
;
}
else
if
(
scaleY
>
1
||
(
height
*
scaleY
)
>
2
*
mFrameWidth
)
{
mScaleY
=
scaleY
;
}
}
else
if
(
resizingTop
()
||
resizingBottom
()){
if
(
height
!=
0
)
{
qreal
scaleY
=
0.0
;
if
(
resizingTop
()){
mTranslateY
=
moveY
;
scaleY
=
(
height
-
moveY
)
/
height
;
}
else
if
(
resizingBottom
()){
scaleY
=
(
height
+
moveY
)
/
height
;
}
if
(
mDelegate
->
isFlippable
()
&&
qAbs
(
scaleY
)
!=
0
){
if
((
qAbs
(
height
*
scaleY
))
<
2
*
mFrameWidth
){
bool
negative
=
(
scaleY
<
0
)
?
true
:
false
;
if
(
negative
){
if
(
mMirrorY
)
scaleY
=
2
*
mFrameWidth
/
width
;
else
scaleY
=
-
2
*
mFrameWidth
/
width
;
}
else
{
scaleY
=
-
1
;
}
}
mScaleY
=
scaleY
;
}
else
if
(
scaleY
>
1
||
(
height
*
scaleY
)
>
2
*
mFrameWidth
)
{
mScaleY
=
scaleY
;
if
(
resizingTop
()){
mTranslateY
=
moveY
;
}
}
}
}
...
...
@@ -531,64 +536,75 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
moveLinkedItems
(
move
);
}
QTransform
tr
=
buildTransform
();
if
(
resizingRight
()
||
resizingBottom
()
||
resizingBottomRight
())
if
(
mOperationMode
==
Scaling
||
moving
()
||
rotating
())
{
Q
PointF
ref
;
Q
Transform
tr
=
buildTransform
()
;
// we just detects coordinates of corner before and after scaling and then moves object at diff between them.
if
(
resizingBottomRight
()
&&
mMirrorX
)
if
(
resizingRight
()
||
resizingBottom
()
||
resizingBottomRight
())
{
mTranslateX
+=
mInitialTransform
.
map
(
delegated
()
->
boundingRect
().
bottomRight
()).
x
()
-
tr
.
map
(
delegated
()
->
boundingRect
().
bottomRight
()).
x
();
mTranslateY
+=
mInitialTransform
.
map
(
delegated
()
->
boundingRect
().
bottomRight
()).
y
()
-
tr
.
map
(
delegated
()
->
boundingRect
().
bottomRight
()).
y
();
QPointF
ref
;
// 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
();
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
();
}
}
else
else
if
(
resizingTop
()
||
resizingLeft
())
{
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
();
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
(
moving
()
||
rotating
())
delegated
()
->
setTransform
(
tr
);
}
else
if
(
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
// resizing/resizing horizontally
{
if
(
mOperationMode
==
Scaling
||
moving
()
||
rotating
())
{
tr
=
buildTransform
();
delegated
()
->
setTransform
(
tr
);
}
else
if
(
mOperationMode
==
Resizing
)
{
if
(
!
moving
()
&&
!
rotating
())
if
(
resizingBottomRight
())
{
if
(
resizingBottomRight
())
{
if
(
mMirrorX
&&
mMirrorY
)
mCurrentTool
=
ResizeTop
;
else
mCurrentTool
=
ResizeBottom
;
static
QSizeF
incV
=
QSizeF
();
static
QSizeF
incH
=
QSizeF
();
resizeDelegate
(
moveX
,
moveY
);
if
(
mMirrorX
&&
mMirrorY
)
mCurrentTool
=
ResizeTop
;
else
mCurrentTool
=
ResizeBottom
;
if
(
mMirrorX
&&
mMirrorY
)
mCurrentTool
=
ResizeLeft
;
else
mCurrentTool
=
ResizeRight
;
mOriginalSize
-=
incH
;
resizeDelegate
(
moveX
,
moveY
);
mCurrentTool
=
ResizeBottomRight
;
}
incV
=
resizeDelegate
(
moveX
,
moveY
);
mOriginalSize
+=
incV
;
if
(
mMirrorX
&&
mMirrorY
)
mCurrentTool
=
ResizeLeft
;
else
resizeDelegate
(
moveX
,
moveY
);
mCurrentTool
=
ResizeRight
;
move
=
QLineF
(
event
->
lastScenePos
(),
event
->
scenePos
());
moveX
=
move
.
length
()
*
cos
((
move
.
angle
()
-
mAngle
)
*
PI
/
180
);
moveY
=
-
move
.
length
()
*
sin
((
move
.
angle
()
-
mAngle
)
*
PI
/
180
);
mFixedPoint
=
getFixedPointFromPos
();
incH
=
resizeDelegate
(
moveX
,
moveY
);
mOriginalSize
-=
incV
;
mOriginalSize
+=
incH
;
mCurrentTool
=
ResizeBottomRight
;
}
else
resizeDelegate
(
moveX
,
moveY
);
}
event
->
accept
();
}
...
...
@@ -689,6 +705,7 @@ void UBGraphicsDelegateFrame::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
event
->
accept
();
mCurrentTool
=
None
;
QGraphicsRectItem
::
mouseReleaseEvent
(
event
);
// Show the buttons
...
...
src/domain/UBGraphicsDelegateFrame.h
View file @
3d3a040b
...
...
@@ -39,7 +39,7 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
virtual
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
QPointF
getFixedPointFromPos
();
QSizeF
getResizeVector
(
qreal
moveX
,
qreal
moveY
);
void
resizeDelegate
(
qreal
moveX
,
qreal
moveY
);
QSizeF
resizeDelegate
(
qreal
moveX
,
qreal
moveY
);
virtual
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
virtual
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
...
...
@@ -105,6 +105,8 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
QPointF
mStartingPoint
;
QTransform
mInitialTransform
;
QSizeF
mOriginalSize
;
QPointF
mFixedPoint
;
QGraphicsSvgItem
*
mBottomRightResizeGripSvgItem
;
QGraphicsSvgItem
*
mBottomResizeGripSvgItem
;
...
...
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