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
545e19fa
Commit
545e19fa
authored
Nov 28, 2011
by
shibakaneki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated the painting algorithm for the cache
parent
f7a2d469
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
4 deletions
+35
-4
UBGraphicsCache.cpp
src/tools/UBGraphicsCache.cpp
+32
-4
UBGraphicsCache.h
src/tools/UBGraphicsCache.h
+3
-0
No files found.
src/tools/UBGraphicsCache.cpp
View file @
545e19fa
...
...
@@ -87,7 +87,7 @@ void UBGraphicsCache::init()
void
UBGraphicsCache
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
{
Q_UNUSED
(
option
);
//
Q_UNUSED(option);
Q_UNUSED
(
widget
);
setZValue
(
CACHE_ZVALUE
);
...
...
@@ -95,6 +95,7 @@ void UBGraphicsCache::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
painter
->
setBrush
(
mMaskColor
);
painter
->
setPen
(
mMaskColor
);
// Draw the hole
QPainterPath
path
;
path
.
addRect
(
rect
());
...
...
@@ -119,20 +120,32 @@ void UBGraphicsCache::mousePressEvent(QGraphicsSceneMouseEvent *event)
Q_UNUSED
(
event
);
mShapePos
=
event
->
pos
();
mDrawMask
=
true
;
update
();
// Note: if refresh issues occure, replace the following 3 lines by: update();
update
(
updateRect
(
event
->
pos
()));
mOldShapeWidth
=
mShapeWidth
;
mOldShapePos
=
event
->
pos
();
}
void
UBGraphicsCache
::
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
mShapePos
=
event
->
pos
();
update
();
// Note: if refresh issues occure, replace the following 3 lines by: update();
update
(
updateRect
(
event
->
pos
()));
mOldShapeWidth
=
mShapeWidth
;
mOldShapePos
=
event
->
pos
();
}
void
UBGraphicsCache
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
Q_UNUSED
(
event
);
mDrawMask
=
false
;
update
();
// Note: if refresh issues occure, replace the following 3 lines by: update();
update
(
updateRect
(
event
->
pos
()));
mOldShapeWidth
=
mShapeWidth
;
mOldShapePos
=
event
->
pos
();
}
int
UBGraphicsCache
::
shapeWidth
()
...
...
@@ -145,3 +158,18 @@ void UBGraphicsCache::setShapeWidth(int width)
mShapeWidth
=
width
;
update
();
}
QRectF
UBGraphicsCache
::
updateRect
(
QPointF
currentPoint
)
{
QRectF
r
;
int
x
;
int
y
;
x
=
qMin
(
currentPoint
.
x
()
-
mShapeWidth
,
mOldShapePos
.
x
()
-
mOldShapeWidth
);
y
=
qMin
(
currentPoint
.
y
()
-
mShapeWidth
,
mOldShapePos
.
y
()
-
mOldShapeWidth
);
r
=
QRect
(
x
,
y
,
qAbs
(
currentPoint
.
x
()
-
mOldShapePos
.
x
())
+
2
*
mShapeWidth
,
qAbs
(
currentPoint
.
y
()
-
mOldShapePos
.
y
())
+
2
*
mShapeWidth
);
return
r
;
}
src/tools/UBGraphicsCache.h
View file @
545e19fa
...
...
@@ -56,12 +56,15 @@ protected:
private
:
void
init
();
QRectF
updateRect
(
QPointF
currentPoint
);
QColor
mMaskColor
;
eMaskShape
mMaskShape
;
int
mShapeWidth
;
bool
mDrawMask
;
QPointF
mShapePos
;
int
mOldShapeWidth
;
QPointF
mOldShapePos
;
};
#endif // UBGRAPHICSCACHE_H
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