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
de2fb68f
Commit
de2fb68f
authored
Aug 12, 2011
by
Anatoly Mihalchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Triangle resizing bug fix
parent
bba6631b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
355 additions
and
349 deletions
+355
-349
UBGraphicsTriangle.cpp
src/tools/UBGraphicsTriangle.cpp
+291
-287
UBGraphicsTriangle.h
src/tools/UBGraphicsTriangle.h
+64
-62
No files found.
src/tools/UBGraphicsTriangle.cpp
View file @
de2fb68f
...
...
@@ -567,17 +567,22 @@ QCursor UBGraphicsTriangle::flipCursor() const
void
UBGraphicsTriangle
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
lastRect
=
rect
().
toRect
();
lastPos
=
event
->
screenPos
();
if
(
resize1Polygon
().
containsPoint
(
event
->
pos
().
toPoint
(),
Qt
::
OddEvenFill
))
{
mResizing1
=
true
;
event
->
accept
();
}
else
if
(
resize2Polygon
().
containsPoint
(
event
->
pos
().
toPoint
(),
Qt
::
OddEvenFill
))
else
if
(
resize2Polygon
().
containsPoint
(
event
->
pos
().
toPoint
(),
Qt
::
OddEvenFill
))
{
mResizing2
=
true
;
event
->
accept
();
}
else
if
(
rotateRect
().
contains
(
event
->
pos
()))
else
if
(
rotateRect
().
contains
(
event
->
pos
()))
{
mRotating
=
true
;
event
->
accept
();
...
...
@@ -596,72 +601,69 @@ void UBGraphicsTriangle::mousePressEvent(QGraphicsSceneMouseEvent *event)
void
UBGraphicsTriangle
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
QPoint
currPos
=
event
->
screenPos
();
// qDebug() << QString(" X: %1 ").arg(currPos.x());
// qDebug() << QString(" Y: %1 ").arg(currPos.y());
if
(
!
mResizing1
&&
!
mResizing2
&&
!
mRotating
)
{
QGraphicsItem
::
mouseMoveEvent
(
event
);
}
else
{
//-----------------------------------------------//
if
(
mResizing1
)
{
QPointF
delta
=
event
->
pos
()
-
event
->
lastPos
();
if
(
mOrientation
==
TopLeft
||
mOrientation
==
BottomLeft
)
{
if
(
rect
().
width
()
+
delta
.
x
()
<
(
qreal
)
sMinWidth
)
delta
.
setX
((
qreal
)
sMinWidth
-
rect
().
width
());
}
else
{
if
(
rect
().
width
()
-
delta
.
x
()
<
(
qreal
)
sMinWidth
)
delta
.
setX
((
qreal
)
sMinWidth
-
rect
().
width
());
}
if
(
mOrientation
==
TopLeft
||
mOrientation
==
BottomLeft
)
{
setRect
(
QRectF
(
rect
().
topLeft
(),
QSizeF
(
rect
().
width
()
+
delta
.
x
(),
rect
().
height
())),
mOrientation
);
int
deltaX
=
currPos
.
x
()
-
lastPos
.
x
();
if
(
lastRect
.
width
()
+
deltaX
<
sMinWidth
)
deltaX
=
sMinWidth
-
lastRect
.
width
();
setRect
(
QRectF
(
lastRect
.
left
(),
lastRect
.
top
(),
lastRect
.
width
()
+
deltaX
,
lastRect
.
height
()),
mOrientation
);
}
else
{
setRect
(
QRectF
(
rect
().
left
()
+
delta
.
x
(),
rect
().
top
(),
rect
().
width
()
-
delta
.
x
(),
rect
().
height
()),
mOrientation
);
int
deltaX
=
lastPos
.
x
()
-
currPos
.
x
();
if
(
lastRect
.
width
()
+
deltaX
<
sMinWidth
)
deltaX
=
sMinWidth
-
lastRect
.
width
();
setRect
(
QRectF
(
lastRect
.
left
()
-
deltaX
,
lastRect
.
top
(),
lastRect
.
width
()
+
deltaX
,
lastRect
.
height
()),
mOrientation
);
}
}
//-----------------------------------------------//
if
(
mResizing2
)
{
QPointF
delta
=
event
->
pos
()
-
event
->
lastPos
();
if
(
mOrientation
==
BottomRight
||
mOrientation
==
BottomLeft
)
{
if
(
rect
().
height
()
-
delta
.
y
()
<
(
qreal
)
sMinHeight
)
delta
.
setY
((
qreal
)
sMinHeight
-
rect
().
height
());
int
deltaY
=
lastPos
.
y
()
-
currPos
.
y
();
if
(
lastRect
.
height
()
+
deltaY
<
sMinHeight
)
deltaY
=
sMinHeight
-
lastRect
.
height
();
setRect
(
QRectF
(
lastRect
.
left
(),
lastRect
.
top
()
-
deltaY
,
lastRect
.
width
(),
lastRect
.
height
()
+
deltaY
),
mOrientation
);
}
else
{
if
(
rect
().
height
()
+
delta
.
y
()
<
(
qreal
)
sMinHeight
)
delta
.
setY
((
qreal
)
sMinHeight
-
rect
().
height
());
int
deltaY
=
currPos
.
y
()
-
lastPos
.
y
();
if
(
lastRect
.
height
()
+
deltaY
<
sMinHeight
)
deltaY
=
sMinHeight
-
lastRect
.
height
();
setRect
(
QRectF
(
lastRect
.
left
(),
lastRect
.
top
(),
lastRect
.
width
(),
lastRect
.
height
()
+
deltaY
),
mOrientation
);
}
if
(
mOrientation
==
BottomRight
||
mOrientation
==
BottomLeft
)
setRect
(
QRectF
(
rect
().
left
(),
rect
().
top
()
+
delta
.
y
(),
rect
().
width
(),
rect
().
height
()
-
delta
.
y
()),
mOrientation
);
else
setRect
(
QRectF
(
rect
().
left
(),
rect
().
top
(),
rect
().
width
(),
rect
().
height
()
+
delta
.
y
()),
mOrientation
);
}
//-----------------------------------------------//
if
(
mRotating
)
{
QLineF
currentLine
(
rotationCenter
(),
event
->
pos
());
...
...
@@ -669,6 +671,8 @@ void UBGraphicsTriangle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
rotateAroundCenter
(
currentLine
.
angleTo
(
lastLine
));
}
//-----------------------------------------------//
event
->
accept
();
}
}
...
...
src/tools/UBGraphicsTriangle.h
View file @
de2fb68f
...
...
@@ -113,6 +113,8 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
bool
mResizing1
;
bool
mResizing2
;
bool
mRotating
;
QRect
lastRect
;
QPoint
lastPos
;
QGraphicsSvgItem
*
mHFlipSvgItem
;
QGraphicsSvgItem
*
mVFlipSvgItem
;
...
...
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