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
8dafb4d9
Commit
8dafb4d9
authored
May 23, 2012
by
shibakaneki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolved an issue with the eraser o the strokes as object story
parent
6ec28ed7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
26 deletions
+50
-26
UBSvgSubsetAdaptor.cpp
src/adaptors/UBSvgSubsetAdaptor.cpp
+40
-16
UBPersistenceManager.cpp
src/core/UBPersistenceManager.cpp
+0
-1
UBGraphicsScene.cpp
src/domain/UBGraphicsScene.cpp
+10
-9
No files found.
src/adaptors/UBSvgSubsetAdaptor.cpp
View file @
8dafb4d9
...
@@ -544,6 +544,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
...
@@ -544,6 +544,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
if
(
strokesGroup
){
if
(
strokesGroup
){
polygonItem
->
setTransform
(
strokesGroup
->
transform
());
polygonItem
->
setTransform
(
strokesGroup
->
transform
());
strokesGroup
->
addToGroup
(
polygonItem
);
strokesGroup
->
addToGroup
(
polygonItem
);
polygonItem
->
setStrokesGroup
(
strokesGroup
);
}
}
}
else
{
}
else
{
scene
->
addItem
(
polygonItem
);
scene
->
addItem
(
polygonItem
);
...
@@ -1005,8 +1006,6 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::writeSvgElement()
...
@@ -1005,8 +1006,6 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::writeSvgElement()
bool
UBSvgSubsetAdaptor
::
UBSvgSubsetWriter
::
persistScene
(
int
pageIndex
)
bool
UBSvgSubsetAdaptor
::
UBSvgSubsetWriter
::
persistScene
(
int
pageIndex
)
{
{
if
(
mScene
->
isModified
())
if
(
mScene
->
isModified
())
{
{
static
int
i
=
0
;
static
int
i
=
0
;
...
@@ -1029,6 +1028,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
...
@@ -1029,6 +1028,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
writeSvgElement
();
writeSvgElement
();
// Get the items from the scene
QList
<
QGraphicsItem
*>
items
=
mScene
->
items
();
QList
<
QGraphicsItem
*>
items
=
mScene
->
items
();
qSort
(
items
.
begin
(),
items
.
end
(),
itemZIndexComp
);
qSort
(
items
.
begin
(),
items
.
end
(),
itemZIndexComp
);
...
@@ -1041,10 +1041,32 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
...
@@ -1041,10 +1041,32 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
{
{
QGraphicsItem
*
item
=
items
.
takeFirst
();
QGraphicsItem
*
item
=
items
.
takeFirst
();
UBGraphicsPolygonItem
*
polygonItem
=
qgraphicsitem_cast
<
UBGraphicsPolygonItem
*>
(
item
);
// Is the item a strokes group?
UBGraphicsStrokesGroup
*
strokesGroupItem
=
qgraphicsitem_cast
<
UBGraphicsStrokesGroup
*>
(
item
);
if
(
strokesGroupItem
&&
strokesGroupItem
->
isVisible
()){
mXmlWriter
.
writeStartElement
(
"g"
);
QMatrix
matrix
=
item
->
sceneMatrix
();
if
(
!
matrix
.
isIdentity
()){
mXmlWriter
.
writeAttribute
(
"transform"
,
toSvgTransform
(
matrix
));
}
// Add the polygons
foreach
(
QGraphicsItem
*
item
,
strokesGroupItem
->
childItems
()){
UBGraphicsPolygonItem
*
poly
=
qgraphicsitem_cast
<
UBGraphicsPolygonItem
*>
(
item
);
if
(
NULL
!=
poly
){
polygonItemToSvgPolygon
(
poly
,
true
);
items
.
removeOne
(
poly
);
}
}
mXmlWriter
.
writeEndElement
();
//g
}
// Is the item a polygon?
UBGraphicsPolygonItem
*
polygonItem
=
qgraphicsitem_cast
<
UBGraphicsPolygonItem
*>
(
item
);
if
(
polygonItem
&&
polygonItem
->
isVisible
())
if
(
polygonItem
&&
polygonItem
->
isVisible
())
{
{
UBGraphicsStroke
*
currentStroke
=
polygonItem
->
stroke
();
UBGraphicsStroke
*
currentStroke
=
polygonItem
->
stroke
();
if
(
openStroke
&&
(
currentStroke
!=
openStroke
))
if
(
openStroke
&&
(
currentStroke
!=
openStroke
))
...
@@ -1116,84 +1138,86 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
...
@@ -1116,84 +1138,86 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
openStroke
=
0
;
openStroke
=
0
;
}
}
// Is the item a picture?
UBGraphicsPixmapItem
*
pixmapItem
=
qgraphicsitem_cast
<
UBGraphicsPixmapItem
*>
(
item
);
UBGraphicsPixmapItem
*
pixmapItem
=
qgraphicsitem_cast
<
UBGraphicsPixmapItem
*>
(
item
);
if
(
pixmapItem
&&
pixmapItem
->
isVisible
())
if
(
pixmapItem
&&
pixmapItem
->
isVisible
())
{
{
pixmapItemToLinkedImage
(
pixmapItem
);
pixmapItemToLinkedImage
(
pixmapItem
);
continue
;
continue
;
}
}
// Is the item a shape?
UBGraphicsSvgItem
*
svgItem
=
qgraphicsitem_cast
<
UBGraphicsSvgItem
*>
(
item
);
UBGraphicsSvgItem
*
svgItem
=
qgraphicsitem_cast
<
UBGraphicsSvgItem
*>
(
item
);
if
(
svgItem
&&
svgItem
->
isVisible
())
if
(
svgItem
&&
svgItem
->
isVisible
())
{
{
svgItemToLinkedSvg
(
svgItem
);
svgItemToLinkedSvg
(
svgItem
);
continue
;
continue
;
}
}
// Is the Item a video?
UBGraphicsVideoItem
*
videoItem
=
qgraphicsitem_cast
<
UBGraphicsVideoItem
*>
(
item
);
UBGraphicsVideoItem
*
videoItem
=
qgraphicsitem_cast
<
UBGraphicsVideoItem
*>
(
item
);
if
(
videoItem
&&
videoItem
->
isVisible
())
if
(
videoItem
&&
videoItem
->
isVisible
())
{
{
videoItemToLinkedVideo
(
videoItem
);
videoItemToLinkedVideo
(
videoItem
);
continue
;
continue
;
}
}
// Is the item an audio?
UBGraphicsAudioItem
*
audioItem
=
qgraphicsitem_cast
<
UBGraphicsAudioItem
*>
(
item
);
UBGraphicsAudioItem
*
audioItem
=
qgraphicsitem_cast
<
UBGraphicsAudioItem
*>
(
item
);
if
(
audioItem
&&
audioItem
->
isVisible
())
{
if
(
audioItem
&&
audioItem
->
isVisible
())
{
audioItemToLinkedAudio
(
audioItem
);
audioItemToLinkedAudio
(
audioItem
);
continue
;
continue
;
}
}
// Is the item an app?
UBGraphicsAppleWidgetItem
*
appleWidgetItem
=
qgraphicsitem_cast
<
UBGraphicsAppleWidgetItem
*>
(
item
);
UBGraphicsAppleWidgetItem
*
appleWidgetItem
=
qgraphicsitem_cast
<
UBGraphicsAppleWidgetItem
*>
(
item
);
if
(
appleWidgetItem
&&
appleWidgetItem
->
isVisible
())
if
(
appleWidgetItem
&&
appleWidgetItem
->
isVisible
())
{
{
graphicsAppleWidgetToSvg
(
appleWidgetItem
);
graphicsAppleWidgetToSvg
(
appleWidgetItem
);
continue
;
continue
;
}
}
// Is the item a W3C?
UBGraphicsW3CWidgetItem
*
w3cWidgetItem
=
qgraphicsitem_cast
<
UBGraphicsW3CWidgetItem
*>
(
item
);
UBGraphicsW3CWidgetItem
*
w3cWidgetItem
=
qgraphicsitem_cast
<
UBGraphicsW3CWidgetItem
*>
(
item
);
if
(
w3cWidgetItem
&&
w3cWidgetItem
->
isVisible
())
if
(
w3cWidgetItem
&&
w3cWidgetItem
->
isVisible
())
{
{
graphicsW3CWidgetToSvg
(
w3cWidgetItem
);
graphicsW3CWidgetToSvg
(
w3cWidgetItem
);
continue
;
continue
;
}
}
// Is the item a PDF?
UBGraphicsPDFItem
*
pdfItem
=
qgraphicsitem_cast
<
UBGraphicsPDFItem
*>
(
item
);
UBGraphicsPDFItem
*
pdfItem
=
qgraphicsitem_cast
<
UBGraphicsPDFItem
*>
(
item
);
if
(
pdfItem
&&
pdfItem
->
isVisible
())
if
(
pdfItem
&&
pdfItem
->
isVisible
())
{
{
pdfItemToLinkedPDF
(
pdfItem
);
pdfItemToLinkedPDF
(
pdfItem
);
continue
;
continue
;
}
}
// Is the item a text?
UBGraphicsTextItem
*
textItem
=
qgraphicsitem_cast
<
UBGraphicsTextItem
*>
(
item
);
UBGraphicsTextItem
*
textItem
=
qgraphicsitem_cast
<
UBGraphicsTextItem
*>
(
item
);
if
(
textItem
&&
textItem
->
isVisible
())
if
(
textItem
&&
textItem
->
isVisible
())
{
{
textItemToSvg
(
textItem
);
textItemToSvg
(
textItem
);
continue
;
continue
;
}
}
// Is the item a curtain?
UBGraphicsCurtainItem
*
curtainItem
=
qgraphicsitem_cast
<
UBGraphicsCurtainItem
*>
(
item
);
UBGraphicsCurtainItem
*
curtainItem
=
qgraphicsitem_cast
<
UBGraphicsCurtainItem
*>
(
item
);
if
(
curtainItem
&&
curtainItem
->
isVisible
())
if
(
curtainItem
&&
curtainItem
->
isVisible
())
{
{
curtainItemToSvg
(
curtainItem
);
curtainItemToSvg
(
curtainItem
);
continue
;
continue
;
}
}
// Is the item a ruler?
UBGraphicsRuler
*
ruler
=
qgraphicsitem_cast
<
UBGraphicsRuler
*>
(
item
);
UBGraphicsRuler
*
ruler
=
qgraphicsitem_cast
<
UBGraphicsRuler
*>
(
item
);
if
(
ruler
&&
ruler
->
isVisible
())
if
(
ruler
&&
ruler
->
isVisible
())
{
{
rulerToSvg
(
ruler
);
rulerToSvg
(
ruler
);
continue
;
continue
;
}
}
// Is the item a cache?
UBGraphicsCache
*
cache
=
qgraphicsitem_cast
<
UBGraphicsCache
*>
(
item
);
UBGraphicsCache
*
cache
=
qgraphicsitem_cast
<
UBGraphicsCache
*>
(
item
);
if
(
cache
&&
cache
->
isVisible
())
if
(
cache
&&
cache
->
isVisible
())
{
{
...
@@ -1201,32 +1225,32 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
...
@@ -1201,32 +1225,32 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
continue
;
continue
;
}
}
// Is the item a compass
UBGraphicsCompass
*
compass
=
qgraphicsitem_cast
<
UBGraphicsCompass
*>
(
item
);
UBGraphicsCompass
*
compass
=
qgraphicsitem_cast
<
UBGraphicsCompass
*>
(
item
);
if
(
compass
&&
compass
->
isVisible
())
if
(
compass
&&
compass
->
isVisible
())
{
{
compassToSvg
(
compass
);
compassToSvg
(
compass
);
continue
;
continue
;
}
}
// Is the item a protractor?
UBGraphicsProtractor
*
protractor
=
qgraphicsitem_cast
<
UBGraphicsProtractor
*>
(
item
);
UBGraphicsProtractor
*
protractor
=
qgraphicsitem_cast
<
UBGraphicsProtractor
*>
(
item
);
if
(
protractor
&&
protractor
->
isVisible
())
if
(
protractor
&&
protractor
->
isVisible
())
{
{
protractorToSvg
(
protractor
);
protractorToSvg
(
protractor
);
continue
;
continue
;
}
}
// Is the item a triangle?
UBGraphicsTriangle
*
triangle
=
qgraphicsitem_cast
<
UBGraphicsTriangle
*>
(
item
);
UBGraphicsTriangle
*
triangle
=
qgraphicsitem_cast
<
UBGraphicsTriangle
*>
(
item
);
if
(
triangle
&&
triangle
->
isVisible
())
if
(
triangle
&&
triangle
->
isVisible
())
{
{
triangleToSvg
(
triangle
);
triangleToSvg
(
triangle
);
continue
;
continue
;
}
}
// Is the item a group?
UBGraphicsGroupContainerItem
*
groupItem
=
qgraphicsitem_cast
<
UBGraphicsGroupContainerItem
*>
(
item
);
UBGraphicsGroupContainerItem
*
groupItem
=
qgraphicsitem_cast
<
UBGraphicsGroupContainerItem
*>
(
item
);
if
(
groupItem
&&
groupItem
->
isVisible
())
if
(
groupItem
&&
groupItem
->
isVisible
())
{
{
qDebug
()
<<
"came across the group during the parsing"
;
qDebug
()
<<
"came across the group during the parsing"
;
...
...
src/core/UBPersistenceManager.cpp
View file @
8dafb4d9
...
@@ -582,7 +582,6 @@ UBGraphicsScene* UBPersistenceManager::loadDocumentScene(UBDocumentProxy* proxy,
...
@@ -582,7 +582,6 @@ UBGraphicsScene* UBPersistenceManager::loadDocumentScene(UBDocumentProxy* proxy,
if
(
mSceneCache
.
contains
(
proxy
,
sceneIndex
))
if
(
mSceneCache
.
contains
(
proxy
,
sceneIndex
))
return
mSceneCache
.
value
(
proxy
,
sceneIndex
);
return
mSceneCache
.
value
(
proxy
,
sceneIndex
);
else
{
else
{
qDebug
()
<<
"scene"
<<
sceneIndex
<<
"retrieved from file ..."
;
UBGraphicsScene
*
scene
=
UBSvgSubsetAdaptor
::
loadScene
(
proxy
,
sceneIndex
);
UBGraphicsScene
*
scene
=
UBSvgSubsetAdaptor
::
loadScene
(
proxy
,
sceneIndex
);
if
(
scene
)
if
(
scene
)
...
...
src/domain/UBGraphicsScene.cpp
View file @
8dafb4d9
...
@@ -834,18 +834,17 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
...
@@ -834,18 +834,17 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
if
(
mShouldUseOMP
)
if
(
mShouldUseOMP
)
{
{
#pragma omp parallel for
//
#pragma omp parallel for
for
(
int
i
=
0
;
i
<
collidItemsSize
;
i
++
)
for
(
int
i
=
0
;
i
<
collidItemsSize
;
i
++
)
{
{
UBGraphicsPolygonItem
*
collidingPolygonItem
=
qgraphicsitem_cast
<
UBGraphicsPolygonItem
*>
(
collidItems
.
at
(
i
));
UBGraphicsPolygonItem
*
collidingPolygonItem
=
qgraphicsitem_cast
<
UBGraphicsPolygonItem
*>
(
collidItems
.
at
(
i
));
if
(
NULL
!=
collidingPolygonItem
)
if
(
NULL
!=
collidingPolygonItem
)
{
{
UBGraphicsStrokesGroup
*
pGroup
=
collidingPolygonItem
->
strokesGroup
();
UBGraphicsStrokesGroup
*
pGroup
=
collidingPolygonItem
->
strokesGroup
();
if
(
eraserInnerRect
.
contains
(
collidingPolygonItem
->
boundingRect
()))
if
(
eraserInnerRect
.
contains
(
collidingPolygonItem
->
boundingRect
()))
{
{
#pragma omp critical
//
#pragma omp critical
// Put the entire polygon into the remove list
// Put the entire polygon into the remove list
toBeRemovedItems
<<
collidingPolygonItem
;
toBeRemovedItems
<<
collidingPolygonItem
;
}
}
...
@@ -882,7 +881,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
...
@@ -882,7 +881,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
}
}
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
toBeRemovedItems
<<
collidingPolygonItem
;
toBeRemovedItems
<<
collidingPolygonItem
;
}
}
...
@@ -893,14 +892,15 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
...
@@ -893,14 +892,15 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
foreach
(
const
QPolygonF
&
pol
,
croppedPathSimplified
.
toFillPolygons
())
foreach
(
const
QPolygonF
&
pol
,
croppedPathSimplified
.
toFillPolygons
())
{
{
UBGraphicsPolygonItem
*
croppedPolygonItem
=
collidingPolygonItem
->
deepCopy
(
pol
);
UBGraphicsPolygonItem
*
croppedPolygonItem
=
collidingPolygonItem
->
deepCopy
(
pol
);
#pragma omp critical
//
#pragma omp critical
if
(
NULL
!=
pGroup
){
if
(
NULL
!=
pGroup
){
croppedPolygonItem
->
setStrokesGroup
(
pGroup
);
croppedPolygonItem
->
setStrokesGroup
(
pGroup
);
//pGroup->addToGroup(croppedPolygonItem);
}
}
// Add this new polygon to the 'added' list
// Add this new polygon to the 'added' list
toBeAddedItems
<<
croppedPolygonItem
;
toBeAddedItems
<<
croppedPolygonItem
;
}
}
#pragma omp critical
//
#pragma omp critical
// Remove the original polygonitem because it has been replaced by many smaller polygons
// Remove the original polygonitem because it has been replaced by many smaller polygons
toBeRemovedItems
<<
collidingPolygonItem
;
toBeRemovedItems
<<
collidingPolygonItem
;
}
}
...
@@ -961,8 +961,9 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
...
@@ -961,8 +961,9 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
foreach
(
QGraphicsItem
*
item
,
toBeRemovedItems
){
foreach
(
QGraphicsItem
*
item
,
toBeRemovedItems
){
UBGraphicsPolygonItem
*
poly
=
dynamic_cast
<
UBGraphicsPolygonItem
*>
(
item
);
UBGraphicsPolygonItem
*
poly
=
dynamic_cast
<
UBGraphicsPolygonItem
*>
(
item
);
if
(
NULL
!=
poly
){
if
(
NULL
!=
poly
){
if
(
NULL
!=
poly
->
strokesGroup
()){
UBGraphicsStrokesGroup
*
group
=
poly
->
strokesGroup
();
poly
->
strokesGroup
()
->
removeFromGroup
(
poly
);
if
(
NULL
!=
group
){
group
->
removeFromGroup
(
poly
);
removeItem
(
poly
);
removeItem
(
poly
);
}
else
{
}
else
{
qDebug
()
<<
"No group present"
;
qDebug
()
<<
"No group present"
;
...
...
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