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
faef4407
Commit
faef4407
authored
Apr 11, 2012
by
Claudio Valerio
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:Sankore/Sankore-3.1
parents
9444787b
896383fd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
18 deletions
+55
-18
UBGraphicsDelegateFrame.cpp
src/domain/UBGraphicsDelegateFrame.cpp
+53
-17
UBGraphicsDelegateFrame.h
src/domain/UBGraphicsDelegateFrame.h
+1
-0
UBGraphicsPixmapItem.cpp
src/domain/UBGraphicsPixmapItem.cpp
+1
-1
No files found.
src/domain/UBGraphicsDelegateFrame.cpp
View file @
faef4407
...
...
@@ -192,7 +192,7 @@ void UBGraphicsDelegateFrame::initializeTransform()
mAngle
=
topLine
.
angle
();
//
the fact the the lenght
is used we loose the horizontalFlip information
//
the fact the the length
is used we loose the horizontalFlip information
// a better way to do this is using DeltaX that preserve the direction information.
mTotalScaleX
=
(
width
/
itemRect
.
width
())
*
horizontalFlip
;
mTotalScaleY
=
height
/
itemRect
.
height
()
*
verticalFlip
;
...
...
@@ -230,6 +230,22 @@ void UBGraphicsDelegateFrame::mousePressEvent(QGraphicsSceneMouseEvent *event)
event
->
accept
();
}
bool
UBGraphicsDelegateFrame
::
canResizeBottomRight
(
qreal
width
,
qreal
height
,
qreal
scaleFactor
)
{
bool
res
=
false
;
if
(
!
mMirrorX
&&
!
mMirrorX
&&
((
width
*
scaleFactor
)
>
2
*
mFrameWidth
&&
(
height
*
scaleFactor
)
>
2
*
mFrameWidth
)){
res
=
true
;
}
else
if
(
mMirrorX
&&
!
mMirrorY
&&
(
-
width
*
scaleFactor
)
>
2
*
mFrameWidth
&&
(
height
*
scaleFactor
)
>
2
*
mFrameWidth
){
res
=
true
;
}
else
if
(
!
mMirrorX
&&
mMirrorY
&&
(
width
*
scaleFactor
)
>
2
*
mFrameWidth
&&
(
-
height
*
scaleFactor
)
>
2
*
mFrameWidth
){
res
=
true
;
}
else
if
(
mMirrorX
&&
mMirrorY
&&
(
-
width
*
scaleFactor
)
>
2
*
mFrameWidth
&&
(
-
height
*
scaleFactor
)
>
2
*
mFrameWidth
){
res
=
true
;
}
return
res
;
}
void
UBGraphicsDelegateFrame
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
...
...
@@ -240,27 +256,33 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
qreal
height
=
delegated
()
->
boundingRect
().
height
()
*
mTotalScaleY
;
mTranslateX
=
moveX
;
if
(
mOperationMode
==
Scaling
)
{
// // Hide the buttons
// mDelegate->setButtonsVisible(false);
// mResizing = true;
// Perform the resize
if
(
resizingBottomRight
())
{
// -----------------------------------------------------
// ! We want to keep the aspect ratio with this resize !
// -----------------------------------------------------
qreal
scaleX
=
(
width
+
moveX
)
/
width
;
qreal
scaleY
=
(
height
+
moveY
)
/
height
;
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
;
}
qreal
scaleFactor
=
(
scaleX
+
scaleY
)
/
2
;
// Do not allow resizing of image size under frame size
if
(
scaleFactor
>
1
||
((
width
*
scaleFactor
)
>
2
*
mFrameWidth
&&
(
height
*
scaleFactor
)
>
2
*
mFrameWidth
))
if
(
canResizeBottomRight
(
width
,
height
,
scaleFactor
))
{
if
(
mRespectRatio
)
{
...
...
@@ -285,7 +307,6 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if
(
mDelegate
->
isFlippable
()
&&
qAbs
(
scaleX
)
!=
0
){
if
((
qAbs
(
width
*
scaleX
))
<
2
*
mFrameWidth
){
bool
negative
=
(
scaleX
<
0
)
?
true
:
false
;
//mMirrorX = (negative?mMirrorX:!mMirrorX);
if
(
negative
){
scaleX
=
-
2
*
mFrameWidth
/
width
;
}
else
{
...
...
@@ -363,9 +384,6 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
QSizeF
newSize
=
resizableItem
->
size
()
+
incVector
;
// if (newSize.width() < 50 /*0*/ || newSize.height() < /*0*/ 50)
// return;
resizableItem
->
resize
(
newSize
);
}
}
...
...
@@ -417,10 +435,28 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
//TODO UB 4.x: Could find a better solution ?
if
(
resizingRight
()
||
resizingBottom
()
||
resizingBottomRight
())
{
QPointF
topLeft
=
tr
.
map
(
delegated
()
->
boundingRect
().
topLeft
());
QPointF
fixedPoint
=
mInitialTransform
.
map
(
delegated
()
->
boundingRect
().
topLeft
());
QPointF
ref
;
if
(
!
mMirrorX
&&
!
mMirrorY
){
ref
=
delegated
()
->
boundingRect
().
topLeft
();
}
else
if
(
mMirrorX
&&
!
mMirrorY
){
ref
=
delegated
()
->
boundingRect
().
topRight
();
}
else
if
(
!
mMirrorX
&&
mMirrorY
){
ref
=
delegated
()
->
boundingRect
().
bottomLeft
();
}
else
if
(
mMirrorX
&&
mMirrorY
){
ref
=
delegated
()
->
boundingRect
().
bottomRight
();
}
// Map the item topleft point to the current mouse move transform
QPointF
topLeft
=
tr
.
map
(
ref
);
// Map the item topleft point to the mouse press transform
QPointF
fixedPoint
=
mInitialTransform
.
map
(
ref
);
// Update the translation coordinates
mTranslateX
+=
fixedPoint
.
x
()
-
topLeft
.
x
();
mTranslateY
+=
fixedPoint
.
y
()
-
topLeft
.
y
();
// Update the transform
tr
=
buildTransform
();
}
else
if
(
resizingTop
()
||
resizingLeft
())
...
...
src/domain/UBGraphicsDelegateFrame.h
View file @
faef4407
...
...
@@ -65,6 +65,7 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
inline
bool
resizingTop
()
const
{
return
mCurrentTool
==
ResizeTop
;
}
inline
bool
rotating
()
const
{
return
mCurrentTool
==
Rotate
;
}
inline
bool
moving
()
const
{
return
mCurrentTool
==
Move
;
}
bool
canResizeBottomRight
(
qreal
width
,
qreal
height
,
qreal
scaleFactor
);
QTransform
buildTransform
();
void
updateResizeCursors
();
...
...
src/domain/UBGraphicsPixmapItem.cpp
View file @
faef4407
...
...
@@ -32,7 +32,7 @@ UBGraphicsPixmapItem::UBGraphicsPixmapItem(QGraphicsItem* parent)
mDelegate
->
init
();
// NOTE: Do not remove this code, I'm just doing a backup of my changes! thx..
mDelegate
->
setFlippable
(
true
);
//
mDelegate->setFlippable(true);
setData
(
UBGraphicsItemData
::
ItemLayerType
,
UBItemLayerType
::
Object
);
setTransformationMode
(
Qt
::
SmoothTransformation
);
...
...
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