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
...
@@ -567,17 +567,22 @@ QCursor UBGraphicsTriangle::flipCursor() const
void
UBGraphicsTriangle
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
UBGraphicsTriangle
::
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
lastRect
=
rect
().
toRect
();
lastPos
=
event
->
screenPos
();
if
(
resize1Polygon
().
containsPoint
(
event
->
pos
().
toPoint
(),
Qt
::
OddEvenFill
))
if
(
resize1Polygon
().
containsPoint
(
event
->
pos
().
toPoint
(),
Qt
::
OddEvenFill
))
{
{
mResizing1
=
true
;
mResizing1
=
true
;
event
->
accept
();
event
->
accept
();
}
}
else
if
(
resize2Polygon
().
containsPoint
(
event
->
pos
().
toPoint
(),
Qt
::
OddEvenFill
))
else
if
(
resize2Polygon
().
containsPoint
(
event
->
pos
().
toPoint
(),
Qt
::
OddEvenFill
))
{
{
mResizing2
=
true
;
mResizing2
=
true
;
event
->
accept
();
event
->
accept
();
}
}
else
if
(
rotateRect
().
contains
(
event
->
pos
()))
else
if
(
rotateRect
().
contains
(
event
->
pos
()))
{
{
mRotating
=
true
;
mRotating
=
true
;
event
->
accept
();
event
->
accept
();
...
@@ -596,72 +601,69 @@ void UBGraphicsTriangle::mousePressEvent(QGraphicsSceneMouseEvent *event)
...
@@ -596,72 +601,69 @@ void UBGraphicsTriangle::mousePressEvent(QGraphicsSceneMouseEvent *event)
void
UBGraphicsTriangle
::
mouseMoveEvent
(
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
)
if
(
!
mResizing1
&&
!
mResizing2
&&
!
mRotating
)
{
{
QGraphicsItem
::
mouseMoveEvent
(
event
);
QGraphicsItem
::
mouseMoveEvent
(
event
);
}
}
else
else
{
{
//-----------------------------------------------//
if
(
mResizing1
)
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
)
if
(
mOrientation
==
TopLeft
||
mOrientation
==
BottomLeft
)
{
{
setRect
(
QRectF
(
int
deltaX
=
currPos
.
x
()
-
lastPos
.
x
();
rect
().
topLeft
(),
if
(
lastRect
.
width
()
+
deltaX
<
sMinWidth
)
QSizeF
(
rect
().
width
()
+
delta
.
x
(),
deltaX
=
sMinWidth
-
lastRect
.
width
();
rect
().
height
())),
mOrientation
);
setRect
(
QRectF
(
lastRect
.
left
(),
lastRect
.
top
(),
lastRect
.
width
()
+
deltaX
,
lastRect
.
height
()),
mOrientation
);
}
}
else
else
{
{
setRect
(
QRectF
(
int
deltaX
=
lastPos
.
x
()
-
currPos
.
x
();
rect
().
left
()
+
delta
.
x
(),
if
(
lastRect
.
width
()
+
deltaX
<
sMinWidth
)
rect
().
top
(),
deltaX
=
sMinWidth
-
lastRect
.
width
();
rect
().
width
()
-
delta
.
x
(),
rect
().
height
()),
setRect
(
QRectF
(
lastRect
.
left
()
-
deltaX
,
lastRect
.
top
(),
mOrientation
lastRect
.
width
()
+
deltaX
,
lastRect
.
height
()),
mOrientation
);
);
}
}
}
}
//-----------------------------------------------//
if
(
mResizing2
)
if
(
mResizing2
)
{
{
QPointF
delta
=
event
->
pos
()
-
event
->
lastPos
();
if
(
mOrientation
==
BottomRight
||
mOrientation
==
BottomLeft
)
if
(
mOrientation
==
BottomRight
||
mOrientation
==
BottomLeft
)
{
{
if
(
rect
().
height
()
-
delta
.
y
()
<
(
qreal
)
sMinHeight
)
int
deltaY
=
lastPos
.
y
()
-
currPos
.
y
();
delta
.
setY
((
qreal
)
sMinHeight
-
rect
().
height
());
if
(
lastRect
.
height
()
+
deltaY
<
sMinHeight
)
deltaY
=
sMinHeight
-
lastRect
.
height
();
setRect
(
QRectF
(
lastRect
.
left
(),
lastRect
.
top
()
-
deltaY
,
lastRect
.
width
(),
lastRect
.
height
()
+
deltaY
),
mOrientation
);
}
}
else
else
{
{
if
(
rect
().
height
()
+
delta
.
y
()
<
(
qreal
)
sMinHeight
)
int
deltaY
=
currPos
.
y
()
-
lastPos
.
y
();
delta
.
setY
((
qreal
)
sMinHeight
-
rect
().
height
());
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
)
if
(
mRotating
)
{
{
QLineF
currentLine
(
rotationCenter
(),
event
->
pos
());
QLineF
currentLine
(
rotationCenter
(),
event
->
pos
());
...
@@ -669,6 +671,8 @@ void UBGraphicsTriangle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
...
@@ -669,6 +671,8 @@ void UBGraphicsTriangle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
rotateAroundCenter
(
currentLine
.
angleTo
(
lastLine
));
rotateAroundCenter
(
currentLine
.
angleTo
(
lastLine
));
}
}
//-----------------------------------------------//
event
->
accept
();
event
->
accept
();
}
}
}
}
...
...
src/tools/UBGraphicsTriangle.h
View file @
de2fb68f
...
@@ -113,6 +113,8 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
...
@@ -113,6 +113,8 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
bool
mResizing1
;
bool
mResizing1
;
bool
mResizing2
;
bool
mResizing2
;
bool
mRotating
;
bool
mRotating
;
QRect
lastRect
;
QPoint
lastPos
;
QGraphicsSvgItem
*
mHFlipSvgItem
;
QGraphicsSvgItem
*
mHFlipSvgItem
;
QGraphicsSvgItem
*
mVFlipSvgItem
;
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