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
0fc1a4df
Commit
0fc1a4df
authored
Aug 24, 2012
by
Anatoly Mihalchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eraser: functionality improvement
parent
5c368021
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
28 deletions
+69
-28
UBGraphicsPolygonItem.cpp
src/domain/UBGraphicsPolygonItem.cpp
+4
-18
UBGraphicsPolygonItem.h
src/domain/UBGraphicsPolygonItem.h
+0
-2
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+65
-8
No files found.
src/domain/UBGraphicsPolygonItem.cpp
View file @
0fc1a4df
...
@@ -143,7 +143,10 @@ QColor UBGraphicsPolygonItem::color() const
...
@@ -143,7 +143,10 @@ QColor UBGraphicsPolygonItem::color() const
UBItem
*
UBGraphicsPolygonItem
::
deepCopy
()
const
UBItem
*
UBGraphicsPolygonItem
::
deepCopy
()
const
{
{
UBGraphicsPolygonItem
*
copy
=
deepCopy
(
this
->
polygon
());
UBGraphicsPolygonItem
*
copy
=
new
UBGraphicsPolygonItem
(
polygon
(),
parentItem
());
copyItemParameters
(
copy
);
copy
->
mOriginalLine
=
this
->
mOriginalLine
;
copy
->
mOriginalLine
=
this
->
mOriginalLine
;
copy
->
mOriginalWidth
=
this
->
mOriginalWidth
;
copy
->
mOriginalWidth
=
this
->
mOriginalWidth
;
copy
->
mIsNominalLine
=
this
->
mIsNominalLine
;
copy
->
mIsNominalLine
=
this
->
mIsNominalLine
;
...
@@ -152,23 +155,6 @@ UBItem* UBGraphicsPolygonItem::deepCopy() const
...
@@ -152,23 +155,6 @@ UBItem* UBGraphicsPolygonItem::deepCopy() const
}
}
UBGraphicsPolygonItem
*
UBGraphicsPolygonItem
::
deepCopy
(
const
QPolygonF
&
pol
)
const
{
QPolygonF
p
(
pol
);
if
(
parentItem
()
!=
NULL
)
{
p
=
mapToItem
(
parentItem
(),
p
);
}
UBGraphicsPolygonItem
*
copy
=
new
UBGraphicsPolygonItem
(
p
,
parentItem
());
copyItemParameters
(
copy
);
// TODO UB 4.7 ... complete all members ?
return
copy
;
}
void
UBGraphicsPolygonItem
::
copyItemParameters
(
UBItem
*
copy
)
const
void
UBGraphicsPolygonItem
::
copyItemParameters
(
UBItem
*
copy
)
const
{
{
UBGraphicsPolygonItem
*
cp
=
dynamic_cast
<
UBGraphicsPolygonItem
*>
(
copy
);
UBGraphicsPolygonItem
*
cp
=
dynamic_cast
<
UBGraphicsPolygonItem
*>
(
copy
);
...
...
src/domain/UBGraphicsPolygonItem.h
View file @
0fc1a4df
...
@@ -87,8 +87,6 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
...
@@ -87,8 +87,6 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
virtual
UBItem
*
deepCopy
()
const
;
virtual
UBItem
*
deepCopy
()
const
;
// optimisation (eraser)
UBGraphicsPolygonItem
*
deepCopy
(
const
QPolygonF
&
pol
)
const
;
virtual
void
copyItemParameters
(
UBItem
*
copy
)
const
;
virtual
void
copyItemParameters
(
UBItem
*
copy
)
const
;
QLineF
originalLine
()
{
return
mOriginalLine
;}
QLineF
originalLine
()
{
return
mOriginalLine
;}
...
...
src/domain/UBGraphicsScene.cpp
View file @
0fc1a4df
...
@@ -740,6 +740,63 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth,
...
@@ -740,6 +740,63 @@ void UBGraphicsScene::drawLineTo(const QPointF &pEndPoint, const qreal &pWidth,
}
}
}
}
void
UBGraphicsScene
::
eraseLineTo
(
const
QPointF
&
pEndPoint
,
const
qreal
&
pWidth
)
{
const
QLineF
line
(
mPreviousPoint
,
pEndPoint
);
mPreviousPoint
=
pEndPoint
;
const
QPolygonF
eraserPolygon
=
UBGeometryUtils
::
lineToPolygon
(
line
,
pWidth
);
const
QRectF
eraserBoundingRect
=
eraserPolygon
.
boundingRect
();
QPainterPath
eraserPath
;
eraserPath
.
addPolygon
(
eraserPolygon
);
// Get all the items that are intersecting with the eraser path
QList
<
QGraphicsItem
*>
collidItems
=
items
(
eraserBoundingRect
,
Qt
::
IntersectsItemBoundingRect
);
QList
<
UBGraphicsPolygonItem
*>
intersectedItems
;
QList
<
QPolygonF
>
intersectedPolygons
;
#pragma omp parallel for
for
(
int
i
=
0
;
i
<
collidItems
.
size
();
i
++
)
{
UBGraphicsPolygonItem
*
pi
=
qgraphicsitem_cast
<
UBGraphicsPolygonItem
*>
(
collidItems
[
i
]);
if
(
pi
==
NULL
)
continue
;
QPainterPath
itemPainterPath
;
itemPainterPath
.
addPolygon
(
pi
->
sceneTransform
().
map
(
pi
->
polygon
()));
if
(
eraserPath
.
contains
(
itemPainterPath
))
{
// Compele remove item
intersectedItems
<<
pi
;
intersectedPolygons
<<
QPolygonF
();
}
else
if
(
eraserPath
.
intersects
(
itemPainterPath
))
{
QPainterPath
newPath
=
itemPainterPath
.
subtracted
(
eraserPath
);
intersectedItems
<<
pi
;
intersectedPolygons
<<
newPath
.
simplified
().
toFillPolygon
(
pi
->
sceneTransform
().
inverted
());
}
}
for
(
int
i
=
0
;
i
<
intersectedItems
.
size
();
i
++
)
{
if
(
intersectedPolygons
[
i
].
empty
())
{
removeItem
(
intersectedItems
[
i
]);
}
else
{
intersectedItems
[
i
]
->
setPolygon
(
intersectedPolygons
[
i
]);
}
}
if
(
!
intersectedItems
.
empty
())
setModified
(
true
);
}
/*
void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
{
{
const QLineF line(mPreviousPoint, pEndPoint);
const QLineF line(mPreviousPoint, pEndPoint);
...
@@ -810,7 +867,6 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
...
@@ -810,7 +867,6 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
collidingPath.addPolygon(collidingPolygon);
collidingPath.addPolygon(collidingPolygon);
// Then we substract the eraser path to the polygon and we simplify it
// Then we substract the eraser path to the polygon and we simplify it
/**/
QTransform polyTransform = collidingPolygonItem->sceneTransform().inverted();
QTransform polyTransform = collidingPolygonItem->sceneTransform().inverted();
QPointF mTrPrevPoint = polyTransform.map(mPreviousPoint);
QPointF mTrPrevPoint = polyTransform.map(mPreviousPoint);
QPointF mTrEndPoint = polyTransform.map(pEndPoint);
QPointF mTrEndPoint = polyTransform.map(pEndPoint);
...
@@ -821,18 +877,18 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
...
@@ -821,18 +877,18 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
QPainterPath trEraser;
QPainterPath trEraser;
trEraser.addPolygon(trEraserPolygon);
trEraser.addPolygon(trEraserPolygon);
QPainterPath croppedPath = collidingPath.subtracted(trEraser);
QPainterPath croppedPath = collidingPath.subtracted(trEraser);
/**/
// Original
// Original
//QPainterPath croppedPath = collidingPath.subtracted(eraserPath);
//QPainterPath croppedPath = collidingPath.subtracted(eraserPath);
QPainterPath croppedPathSimplified = croppedPath.simplified();
QPainterPath croppedPathSimplified = croppedPath.simplified();
/*if (croppedPath == collidingPath)
//if (croppedPath == collidingPath)
{
//{
// NOOP
// // NOOP
toBeRemovedItems << collidingPolygonItem;
// toBeRemovedItems << collidingPolygonItem;
}
//}
else */
if
(
croppedPathSimplified
.
isEmpty
())
//else
if (croppedPathSimplified.isEmpty())
{
{
#pragma omp critical
#pragma omp critical
// Put the entire polygon into the remove list if the eraser removes all its visible content
// Put the entire polygon into the remove list if the eraser removes all its visible content
...
@@ -948,6 +1004,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
...
@@ -948,6 +1004,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
mPreviousPoint = pEndPoint;
mPreviousPoint = pEndPoint;
}
}
*/
void
UBGraphicsScene
::
drawArcTo
(
const
QPointF
&
pCenterPoint
,
qreal
pSpanAngle
)
void
UBGraphicsScene
::
drawArcTo
(
const
QPointF
&
pCenterPoint
,
qreal
pSpanAngle
)
{
{
...
...
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