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
66f8d530
Commit
66f8d530
authored
Feb 20, 2013
by
Claudio Valerio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing previous bad commit
parent
84addd4d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
118 additions
and
109 deletions
+118
-109
UBSvgSubsetAdaptor.cpp
src/adaptors/UBSvgSubsetAdaptor.cpp
+118
-109
No files found.
src/adaptors/UBSvgSubsetAdaptor.cpp
View file @
66f8d530
...
...
@@ -391,8 +391,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
UBGraphicsStroke
*
annotationGroup
=
0
;
UBGraphicsStrokesGroup
*
strokesGroup
=
0
;
QMap
<
QString
,
UBGraphicsStrokesGroup
*>
strokesList
;
while
(
!
mXmlReader
.
atEnd
())
{
mXmlReader
.
readNext
();
...
...
@@ -562,8 +560,11 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
{
polygonItem
=
polygonItemFromLineSvg
(
mScene
->
isDarkBackground
()
?
Qt
::
white
:
Qt
::
black
);
}
if
(
polygonItem
)
{
mScene
->
addItem
(
polygonItem
);
polygonItem
->
setUuid
(
uuidFromSvg
);
if
(
annotationGroup
)
...
...
@@ -580,19 +581,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
polygonItem
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Graphic
));
QString
parentId
=
mXmlReader
.
attributes
().
value
(
mNamespaceUri
,
"parent"
).
toString
();
Q_ASSERT
(
!
parentId
.
isEmpty
());
UBGraphicsStrokesGroup
*
group
;
if
(
!
strokesList
.
contains
(
parentId
)){
group
=
new
UBGraphicsStrokesGroup
();
strokesList
.
insert
(
parentId
,
group
);
}
else
group
=
strokesList
.
value
(
parentId
);
polygonItem
->
show
();
group
->
addToGroup
(
polygonItem
);
}
}
else
if
(
mXmlReader
.
name
()
==
"polyline"
)
...
...
@@ -615,17 +604,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
}
polygonItem
->
setData
(
UBGraphicsItemData
::
ItemLayerType
,
QVariant
(
UBItemLayerType
::
Graphic
));
QString
parentId
=
mXmlReader
.
attributes
().
value
(
mNamespaceUri
,
"parent"
).
toString
();
Q_ASSERT
(
!
parentId
.
isEmpty
());
UBGraphicsStrokesGroup
*
group
;
if
(
!
strokesList
.
contains
(
parentId
)){
group
=
new
UBGraphicsStrokesGroup
();
strokesList
.
insert
(
parentId
,
group
);
}
else
group
=
strokesList
.
value
(
parentId
);
polygonItem
->
show
();
}
}
...
...
@@ -883,6 +861,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
UBGraphicsAppleWidgetItem
*
appleWidgetItem
=
graphicsAppleWidgetFromSvg
();
if
(
appleWidgetItem
)
{
// appleWidgetItem->setFlag(QGraphicsItem::ItemIsMovable, true);
appleWidgetItem
->
setFlag
(
QGraphicsItem
::
ItemIsSelectable
,
true
);
appleWidgetItem
->
resize
(
foreignObjectWidth
,
foreignObjectHeight
);
...
...
@@ -978,12 +957,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
}
else
if
(
mXmlReader
.
name
()
==
tGroups
)
{
//considering groups section at the end of the document
QMapIterator
<
QString
,
UBGraphicsStrokesGroup
*>
iterator
(
strokesList
);
while
(
iterator
.
hasNext
())
{
iterator
.
next
();
mScene
->
addItem
(
iterator
.
value
());
}
readGroupRoot
();
}
else
...
...
@@ -997,6 +970,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
{
if
(
strokesGroup
&&
mScene
){
mScene
->
addItem
(
strokesGroup
);
//graphicsItemFromSvg(strokesGroup);
}
if
(
annotationGroup
)
...
...
@@ -1011,8 +985,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
}
}
qDebug
()
<<
"Number of detected strokes: "
<<
strokesList
.
count
();
if
(
mXmlReader
.
hasError
())
{
qWarning
()
<<
"error parsing Sankore file "
<<
mXmlReader
.
errorString
();
...
...
@@ -1036,7 +1008,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
UBGraphicsGroupContainerItem
*
UBSvgSubsetAdaptor
::
UBSvgSubsetReader
::
readGroup
()
{
UBGraphicsGroupContainerItem
*
group
=
new
UBGraphicsGroupContainerItem
();
//
QMultiMap<QString, UBGraphicsPolygonItem *> strokesGroupsContainer;
QMultiMap
<
QString
,
UBGraphicsPolygonItem
*>
strokesGroupsContainer
;
QList
<
QGraphicsItem
*>
groupContainer
;
mXmlReader
.
readNext
();
...
...
@@ -1045,9 +1017,10 @@ UBGraphicsGroupContainerItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroup()
if
(
mXmlReader
.
isEndElement
())
{
mXmlReader
.
readNext
();
break
;
}
else
if
(
mXmlReader
.
isStartElement
())
{
if
(
mXmlReader
.
name
()
==
tGroup
)
{
}
else
if
(
mXmlReader
.
isStartElement
())
{
if
(
mXmlReader
.
name
()
==
tGroup
)
{
qDebug
()
<<
"came across the group id is"
<<
mXmlReader
.
attributes
().
value
(
aId
);
UBGraphicsGroupContainerItem
*
curGroup
=
readGroup
();
if
(
curGroup
)
...
...
@@ -1055,69 +1028,67 @@ UBGraphicsGroupContainerItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroup()
else
qDebug
()
<<
"this is an error"
;
}
else
if
(
mXmlReader
.
name
()
==
tElement
)
{
else
if
(
mXmlReader
.
name
()
==
tElement
)
{
QString
id
=
mXmlReader
.
attributes
().
value
(
aId
).
toString
();
//
QString itemId = id.right(QUuid().toString().size());
//
QString groupId = id.left(QUuid().toString().size());
QString
itemId
=
id
.
right
(
QUuid
().
toString
().
size
());
QString
groupId
=
id
.
left
(
QUuid
().
toString
().
size
());
QGraphicsItem
*
curItem
=
readElementFromGroup
();
// UBGraphicsPolygonItem *curPolygon = qgraphicsitem_cast<UBGraphicsPolygonItem *>(curItem);
//
// if (curPolygon && !groupId.isEmpty() && !itemId.isEmpty() && itemId != groupId) {
// strokesGroupsContainer.insert(groupId, curPolygon);
// }
// else {// item
UBGraphicsPolygonItem
*
curPolygon
=
qgraphicsitem_cast
<
UBGraphicsPolygonItem
*>
(
curItem
);
// Explanation: the second condition discriminate the old storage version that should
// not be interpreted anymore
if
(
curItem
&&
id
.
count
(
"{"
)
<
2
)
if
(
curPolygon
&&
!
groupId
.
isEmpty
()
&&
!
itemId
.
isEmpty
()
&&
itemId
!=
groupId
)
{
strokesGroupsContainer
.
insert
(
groupId
,
curPolygon
);
}
else
// item
{
if
(
curItem
)
groupContainer
.
append
(
curItem
);
else
qDebug
()
<<
"this is an error"
;
// }
}
else
{
}
else
{
mXmlReader
.
skipCurrentElement
();
}
}
else
{
}
else
{
mXmlReader
.
readNext
();
}
}
//
foreach (QString key, strokesGroupsContainer.keys().toSet())
//
{
//
UBGraphicsStrokesGroup* pStrokesGroup = new UBGraphicsStrokesGroup();
//
UBGraphicsStroke *currentStroke = new UBGraphicsStroke();
//
foreach(UBGraphicsPolygonItem* poly, strokesGroupsContainer.values(key))
//
{
//
if (poly)
//
{
//
mScene->removeItem(poly);
//
mScene->removeItemFromDeletion(poly);
//
poly->setStrokesGroup(pStrokesGroup);
//
poly->setStroke(currentStroke);
//
pStrokesGroup->addToGroup(poly);
//
}
//
}
//
if (currentStroke->polygons().empty())
//
delete currentStroke;
//
if (pStrokesGroup->childItems().count())
//
mScene->addItem(pStrokesGroup);
//
else
//
delete pStrokesGroup;
//
if (pStrokesGroup)
//
{
//
QGraphicsItem *strokeGroup = qgraphicsitem_cast<QGraphicsItem *>(pStrokesGroup);
//
if(strokeGroup)
//
groupContainer.append(strokeGroup);
//
else
//
qDebug() << "this is an error";
//
}
//
}
foreach
(
QString
key
,
strokesGroupsContainer
.
keys
().
toSet
())
{
UBGraphicsStrokesGroup
*
pStrokesGroup
=
new
UBGraphicsStrokesGroup
();
UBGraphicsStroke
*
currentStroke
=
new
UBGraphicsStroke
();
foreach
(
UBGraphicsPolygonItem
*
poly
,
strokesGroupsContainer
.
values
(
key
))
{
if
(
poly
)
{
mScene
->
removeItem
(
poly
);
mScene
->
removeItemFromDeletion
(
poly
);
poly
->
setStrokesGroup
(
pStrokesGroup
);
poly
->
setStroke
(
currentStroke
);
pStrokesGroup
->
addToGroup
(
poly
);
}
}
if
(
currentStroke
->
polygons
().
empty
())
delete
currentStroke
;
if
(
pStrokesGroup
->
childItems
().
count
())
mScene
->
addItem
(
pStrokesGroup
);
else
delete
pStrokesGroup
;
if
(
pStrokesGroup
)
{
QGraphicsItem
*
strokeGroup
=
qgraphicsitem_cast
<
QGraphicsItem
*>
(
pStrokesGroup
);
if
(
strokeGroup
)
groupContainer
.
append
(
strokeGroup
);
else
qDebug
()
<<
"this is an error"
;
}
}
foreach
(
QGraphicsItem
*
item
,
groupContainer
)
group
->
addToGroup
(
item
);
...
...
@@ -1141,19 +1112,16 @@ void UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroupRoot()
if
(
mXmlReader
.
isEndElement
())
{
mXmlReader
.
readNext
();
break
;
}
else
if
(
mXmlReader
.
isStartElement
())
{
}
else
if
(
mXmlReader
.
isStartElement
())
{
if
(
mXmlReader
.
name
()
==
tGroup
)
{
UBGraphicsGroupContainerItem
*
curGroup
=
readGroup
();
if
(
curGroup
)
{
mScene
->
addGroup
(
curGroup
);
}
}
else
{
}
else
{
mXmlReader
.
skipCurrentElement
();
}
}
else
{
}
else
{
mXmlReader
.
readNext
();
}
}
...
...
@@ -1166,9 +1134,8 @@ QGraphicsItem *UBSvgSubsetAdaptor::UBSvgSubsetReader::readElementFromGroup()
QString
uuid
=
id
.
right
(
QUuid
().
toString
().
size
());
result
=
mScene
->
itemForUuid
(
QUuid
(
uuid
));
Q_ASSERT
(
result
);
// if(!result)
// qDebug() << "uuid " << uuid;
if
(
!
result
)
qDebug
()
<<
"uuid "
<<
uuid
;
mXmlReader
.
skipCurrentElement
();
mXmlReader
.
readNext
();
...
...
@@ -1272,15 +1239,38 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
UBGraphicsStrokesGroup
*
strokesGroupItem
=
qgraphicsitem_cast
<
UBGraphicsStrokesGroup
*>
(
item
);
if
(
strokesGroupItem
&&
strokesGroupItem
->
isVisible
()){
QDomElement
newGroupElement
;
if
(
!
strokesGroupItem
->
parentItem
()
&&
strokesGroupItem
->
childItems
().
count
())
{
newGroupElement
=
groupDomDocument
.
createElement
(
tGroup
);
newGroupElement
.
setAttribute
(
aId
,
strokesGroupItem
->
uuid
().
toString
());
groupRoot
.
appendChild
(
newGroupElement
);
}
//disabling g section parsing as a group of elements. Use groups refs instead
// mXmlWriter.writeStartElement("g");
// mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "uuid", UBStringUtils::toCanonicalUuid(strokesGroupItem->uuid()));
// 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
);
if
(
!
newGroupElement
.
isNull
())
{
QDomElement
curPolygonElement
=
groupDomDocument
.
createElement
(
tElement
);
curPolygonElement
.
setAttribute
(
aId
,
strokesGroupItem
->
uuid
().
toString
()
+
poly
->
uuid
().
toString
());
newGroupElement
.
appendChild
(
curPolygonElement
);
}
items
.
removeOne
(
poly
);
}
}
// mXmlWriter.writeEndElement(); //g
}
// Is the item a polygon?
...
...
@@ -1564,16 +1554,14 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistGroupToDom(QGraphicsItem *gro
if
(
!
tmpUuid
.
isNull
())
{
if
(
item
->
type
()
==
UBGraphicsGroupContainerItem
::
Type
&&
item
->
childItems
().
count
())
{
persistGroupToDom
(
item
,
curParent
,
groupDomDocument
);
}
else
if
(
item
->
type
()
==
UBGraphicsStrokesGroup
::
Type
)
{
foreach
(
QGraphicsItem
*
polygonItem
,
item
->
childItems
())
{
QDomElement
curPolygonElement
=
groupDomDocument
->
createElement
(
tElement
);
curPolygonElement
.
setAttribute
(
aId
,
tmpUuid
.
toString
()
+
UBGraphicsItem
::
getOwnUuid
(
polygonItem
).
toString
());
curGroupElement
.
appendChild
(
curPolygonElement
);
}
// else if (item->type() == UBGraphicsStrokesGroup::Type) {
// foreach (QGraphicsItem *polygonItem, item->childItems()) {
// QDomElement curPolygonElement = groupDomDocument->createElement(tElement);
// curPolygonElement.setAttribute(aId, tmpUuid.toString()
// + UBGraphicsItem::getOwnUuid(polygonItem).toString());
// curGroupElement.appendChild(curPolygonElement);
// }
// }
else
{
}
else
{
QDomElement
curSubElement
=
groupDomDocument
->
createElement
(
tElement
);
curSubElement
.
setAttribute
(
aId
,
tmpUuid
);
...
...
@@ -1584,6 +1572,27 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistGroupToDom(QGraphicsItem *gro
}
}
void
UBSvgSubsetAdaptor
::
UBSvgSubsetWriter
::
persistStrokeToDom
(
QGraphicsItem
*
strokeItem
,
QDomElement
*
curParent
,
QDomDocument
*
curDomDocument
)
{
QUuid
uuid
=
UBGraphicsScene
::
getPersonalUuid
(
strokeItem
);
if
(
!
uuid
.
isNull
())
{
QDomElement
curStrokesGroupElement
=
curDomDocument
->
createElement
(
tStrokeGroup
);
curStrokesGroupElement
.
setAttribute
(
aId
,
uuid
);
curParent
->
appendChild
(
curStrokesGroupElement
);
foreach
(
QGraphicsItem
*
item
,
strokeItem
->
childItems
())
{
QUuid
tmpUuid
=
UBGraphicsScene
::
getPersonalUuid
(
item
);
if
(
!
tmpUuid
.
isNull
())
{
if
(
item
->
type
()
==
UBGraphicsPolygonItem
::
Type
&&
item
->
childItems
().
count
())
{
QDomElement
curSubElement
=
curDomDocument
->
createElement
(
tElement
);
curSubElement
.
setAttribute
(
aId
,
tmpUuid
);
curStrokesGroupElement
.
appendChild
(
curSubElement
);
}
}
}
}
}
void
UBSvgSubsetAdaptor
::
UBSvgSubsetWriter
::
polygonItemToSvgLine
(
UBGraphicsPolygonItem
*
polygonItem
,
bool
groupHoldsInfo
)
{
mXmlWriter
.
writeStartElement
(
"line"
);
...
...
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