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
dfa87203
Commit
dfa87203
authored
Sep 27, 2012
by
Ilia Ryabokon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CFF export and strokes groups
parent
57a2d141
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
105 additions
and
21 deletions
+105
-21
UBCFFAdaptor.cpp
plugins/cffadaptor/src/UBCFFAdaptor.cpp
+28
-5
UBCFFAdaptor.h
plugins/cffadaptor/src/UBCFFAdaptor.h
+1
-1
UBCFFConstants.h
plugins/cffadaptor/src/UBCFFConstants.h
+2
-1
UBSvgSubsetAdaptor.cpp
src/adaptors/UBSvgSubsetAdaptor.cpp
+64
-14
UBSvgSubsetAdaptor.h
src/adaptors/UBSvgSubsetAdaptor.h
+1
-0
UBGraphicsPolygonItem.cpp
src/domain/UBGraphicsPolygonItem.cpp
+7
-0
UBGraphicsPolygonItem.h
src/domain/UBGraphicsPolygonItem.h
+2
-0
No files found.
plugins/cffadaptor/src/UBCFFAdaptor.cpp
View file @
dfa87203
...
...
@@ -550,8 +550,8 @@ QDomElement UBCFFAdaptor::UBToCFFConverter::parsePage(const QString &pageFileNam
pageFile
.
close
();
return
QDomElement
();
}
}
else
if
(
tagname
==
tUBZGroup
)
{
group
=
parseGroupPageSection
(
nextTopElement
);
}
else
if
(
tagname
==
tUBZGroup
s
)
{
group
=
parseGroup
s
PageSection
(
nextTopElement
);
if
(
group
.
isNull
())
{
qDebug
()
<<
"Page doesn't contains any groups."
;
pageFile
.
close
();
...
...
@@ -634,6 +634,7 @@ QDomElement UBCFFAdaptor::UBToCFFConverter::parseSvgPageSection(const QDomElemen
else
if
(
tagName
==
tUBZLine
)
parseUBZLine
(
nextElement
,
svgElements
);
else
if
(
tagName
==
tUBZPolygon
)
parseUBZPolygon
(
nextElement
,
svgElements
);
else
if
(
tagName
==
tUBZPolyline
)
parseUBZPolyline
(
nextElement
,
svgElements
);
else
if
(
tagName
==
tUBZGroups
)
parseGroupsPageSection
(
nextElement
);
nextElement
=
nextElement
.
nextSiblingElement
();
}
...
...
@@ -694,12 +695,34 @@ bool UBCFFAdaptor::UBToCFFConverter::writeExtendedIwbSection()
// extended element options
// editable, background, locked are supported for now
QDomElement
UBCFFAdaptor
::
UBToCFFConverter
::
parseGroup
PageSection
(
const
QDomElement
&
elemen
t
)
QDomElement
UBCFFAdaptor
::
UBToCFFConverter
::
parseGroup
sPageSection
(
const
QDomElement
&
groupRoo
t
)
{
// First sankore side implementation needed. TODO in Sankore 1.5
Q_UNUSED
(
element
)
if
(
!
groupRoot
.
hasChildNodes
())
{
qDebug
()
<<
"Group root is empty"
;
return
QDomElement
();
}
QDomElement
groupElement
=
groupRoot
.
firstChildElement
();
while
(
!
groupElement
.
isNull
())
{
QDomElement
extendedElement
=
mDataModel
->
createElementNS
(
iwbNS
,
groupElement
.
tagName
());
QDomElement
groupChildElement
=
groupElement
.
firstChildElement
();
while
(
!
groupChildElement
.
isNull
())
{
QDomElement
extSubElement
=
mDataModel
->
createElementNS
(
iwbNS
,
groupChildElement
.
tagName
());
extSubElement
.
setAttribute
(
aRef
,
groupChildElement
.
attribute
(
aID
,
QUuid
().
toString
()));
extendedElement
.
appendChild
(
extSubElement
);
groupChildElement
=
groupChildElement
.
nextSiblingElement
();
}
mExtendedElements
.
append
(
extendedElement
);
groupElement
=
groupElement
.
nextSiblingElement
();
}
qDebug
()
<<
"parsing ubz group section"
;
return
QDomElement
()
;
return
groupRoot
;
}
QString
UBCFFAdaptor
::
UBToCFFConverter
::
getDstContentFolderName
(
const
QString
&
elementType
)
...
...
plugins/cffadaptor/src/UBCFFAdaptor.h
View file @
dfa87203
...
...
@@ -63,7 +63,7 @@ private:
QDomElement
parseSvgPageSection
(
const
QDomElement
&
element
);
void
writeQDomElementToXML
(
const
QDomNode
&
node
);
bool
writeExtendedIwbSection
();
QDomElement
parseGroup
PageSection
(
const
QDomElement
&
elemen
t
);
QDomElement
parseGroup
sPageSection
(
const
QDomElement
&
groupRoo
t
);
bool
createBackground
(
const
QDomElement
&
element
,
QMultiMap
<
int
,
QDomElement
>
&
dstSvgList
);
QString
createBackgroundImage
(
const
QDomElement
&
element
,
QSize
size
);
...
...
plugins/cffadaptor/src/UBCFFConstants.h
View file @
dfa87203
...
...
@@ -28,6 +28,7 @@ const QString tIWBPageSet = "pageset";
const
QString
tId
=
"id"
;
const
QString
tElement
=
"element"
;
const
QString
tUBZGroup
=
"group"
;
const
QString
tUBZGroups
=
"groups"
;
const
QString
tUBZG
=
"g"
;
const
QString
tUBZPolygon
=
"polygon"
;
const
QString
tUBZPolyline
=
"polyline"
;
...
...
@@ -376,4 +377,4 @@ struct UBItemLayerType
};
};
#endif // UBCFFCONSTANTS_H
\ No newline at end of file
#endif // UBCFFCONSTANTS_H
src/adaptors/UBSvgSubsetAdaptor.cpp
View file @
dfa87203
...
...
@@ -48,6 +48,7 @@
#include "frameworks/UBFileSystemUtils.h"
#include "frameworks/UBStringUtils.h"
#include "frameworks/UBFileSystemUtils.h"
#include "core/UBSettings.h"
#include "core/UBSetting.h"
...
...
@@ -79,6 +80,7 @@ const QString UBSvgSubsetAdaptor::sFormerUniboardDocumentNamespaceUri = "http://
const
QString
tElement
=
"element"
;
const
QString
tGroup
=
"group"
;
const
QString
tStrokeGroup
=
"strokeGroup"
;
const
QString
tGroups
=
"groups"
;
const
QString
aId
=
"id"
;
...
...
@@ -1152,25 +1154,42 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
QGraphicsItem
*
item
=
items
.
takeFirst
();
// Is the item a strokes group?
UBGraphicsStrokesGroup
*
strokesGroupItem
=
qgraphicsitem_cast
<
UBGraphicsStrokesGroup
*>
(
item
);
if
(
strokesGroupItem
&&
strokesGroupItem
->
isVisible
()){
mXmlWriter
.
writeStartElement
(
"g"
);
mXmlWriter
.
writeAttribute
(
UBSettings
::
uniboardDocumentNamespaceUri
,
"uuid"
,
UBStringUtils
::
toCanonicalUuid
(
strokesGroupItem
->
uuid
()));
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
);
items
.
removeOne
(
poly
);
}
}
// 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
//
mXmlWriter.writeEndElement(); //g
}
// Is the item a polygon?
...
...
@@ -1401,12 +1420,12 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
QDomElement
curElement
=
groupRoot
.
firstChildElement
();
while
(
!
curElement
.
isNull
())
{
if
(
curElement
.
hasAttribute
(
aId
))
{
mXmlWriter
.
writeStartElement
(
tGroup
);
mXmlWriter
.
writeStartElement
(
curElement
.
tagName
()
);
mXmlWriter
.
writeAttribute
(
aId
,
curElement
.
attribute
(
aId
));
QDomElement
curSubElement
=
curElement
.
firstChildElement
();
while
(
!
curSubElement
.
isNull
())
{
if
(
curSubElement
.
hasAttribute
(
aId
))
{
mXmlWriter
.
writeStartElement
(
tElement
);
mXmlWriter
.
writeStartElement
(
curSubElement
.
tagName
()
);
mXmlWriter
.
writeAttribute
(
aId
,
curSubElement
.
attribute
(
aId
));
mXmlWriter
.
writeEndElement
();
curSubElement
=
curSubElement
.
nextSiblingElement
();
...
...
@@ -1454,8 +1473,16 @@ 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
{
QDomElement
curSubElement
=
groupDomDocument
->
createElement
(
tGroup
);
QDomElement
curSubElement
=
groupDomDocument
->
createElement
(
tElement
);
curSubElement
.
setAttribute
(
aId
,
tmpUuid
);
curGroupElement
.
appendChild
(
curSubElement
);
}
...
...
@@ -1464,6 +1491,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"
);
...
...
@@ -1615,6 +1663,8 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::polygonItemToSvgPolygon(UBGraphicsPo
,
"fill-on-light-background"
,
polygonItem
->
colorOnLightBackground
().
name
());
}
mXmlWriter
.
writeAttribute
(
UBSettings
::
uniboardDocumentNamespaceUri
,
"uuid"
,
UBStringUtils
::
toCanonicalUuid
(
polygonItem
->
uuid
()));
mXmlWriter
.
writeEndElement
();
}
}
...
...
src/adaptors/UBSvgSubsetAdaptor.h
View file @
dfa87203
...
...
@@ -179,6 +179,7 @@ class UBSvgSubsetAdaptor
private
:
void
persistGroupToDom
(
QGraphicsItem
*
groupItem
,
QDomElement
*
curParent
,
QDomDocument
*
curDomDocument
);
void
persistStrokeToDom
(
QGraphicsItem
*
strokeItem
,
QDomElement
*
curParent
,
QDomDocument
*
curDomDocument
);
void
polygonItemToSvgPolygon
(
UBGraphicsPolygonItem
*
polygonItem
,
bool
groupHoldsInfo
);
void
polygonItemToSvgLine
(
UBGraphicsPolygonItem
*
polygonItem
,
bool
groupHoldsInfo
);
void
strokeToSvgPolyline
(
UBGraphicsStroke
*
stroke
,
bool
groupHoldsInfo
);
...
...
src/domain/UBGraphicsPolygonItem.cpp
View file @
dfa87203
...
...
@@ -60,6 +60,13 @@ UBGraphicsPolygonItem::UBGraphicsPolygonItem (const QLineF& pLine, qreal pWidth)
void
UBGraphicsPolygonItem
::
initialize
()
{
setData
(
UBGraphicsItemData
::
itemLayerType
,
QVariant
(
itemLayerType
::
DrawingItem
));
//Necessary to set if we want z value to be assigned correctly
setUuid
(
QUuid
::
createUuid
());
}
void
UBGraphicsPolygonItem
::
setUuid
(
const
QUuid
&
pUuid
)
{
UBItem
::
setUuid
(
pUuid
);
setData
(
UBGraphicsItemData
::
ItemUuid
,
QVariant
(
pUuid
));
//store item uuid inside the QGraphicsItem to fast operations with Items on the scene
}
void
UBGraphicsPolygonItem
::
clearStroke
()
...
...
src/domain/UBGraphicsPolygonItem.h
View file @
dfa87203
...
...
@@ -39,6 +39,8 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
void
initialize
();
void
setUuid
(
const
QUuid
&
pUuid
);
void
setStrokesGroup
(
UBGraphicsStrokesGroup
*
group
);
UBGraphicsStrokesGroup
*
strokesGroup
()
const
{
return
mpGroup
;}
void
setColor
(
const
QColor
&
color
);
...
...
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