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
68db0058
Commit
68db0058
authored
May 08, 2013
by
Claudio Valerio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed issue with bad transfrom matrix
parent
59725062
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
47 deletions
+45
-47
UBSvgSubsetAdaptor.cpp
src/adaptors/UBSvgSubsetAdaptor.cpp
+45
-47
No files found.
src/adaptors/UBSvgSubsetAdaptor.cpp
View file @
68db0058
...
@@ -97,12 +97,12 @@ QMap<QString,IDataStorage*> UBSvgSubsetAdaptor::additionalElementToStore;
...
@@ -97,12 +97,12 @@ QMap<QString,IDataStorage*> UBSvgSubsetAdaptor::additionalElementToStore;
QString
UBSvgSubsetAdaptor
::
toSvgTransform
(
const
QMatrix
&
matrix
)
QString
UBSvgSubsetAdaptor
::
toSvgTransform
(
const
QMatrix
&
matrix
)
{
{
return
QString
(
"matrix(%1, %2, %3, %4, %5, %6)"
)
return
QString
(
"matrix(%1, %2, %3, %4, %5, %6)"
)
.
arg
(
matrix
.
m11
(),
0
,
'g'
)
.
arg
(
matrix
.
m11
(),
0
,
'g'
)
.
arg
(
matrix
.
m12
(),
0
,
'g'
)
.
arg
(
matrix
.
m12
(),
0
,
'g'
)
.
arg
(
matrix
.
m21
(),
0
,
'g'
)
.
arg
(
matrix
.
m21
(),
0
,
'g'
)
.
arg
(
matrix
.
m22
(),
0
,
'g'
)
.
arg
(
matrix
.
m22
(),
0
,
'g'
)
.
arg
(
matrix
.
dx
(),
0
,
'g'
)
.
arg
(
matrix
.
dx
(),
0
,
'g'
)
.
arg
(
matrix
.
dy
(),
0
,
'g'
);
.
arg
(
matrix
.
dy
(),
0
,
'g'
);
}
}
...
@@ -117,12 +117,12 @@ QMatrix UBSvgSubsetAdaptor::fromSvgTransform(const QString& transform)
...
@@ -117,12 +117,12 @@ QMatrix UBSvgSubsetAdaptor::fromSvgTransform(const QString& transform)
if
(
sl
.
size
()
>=
6
)
if
(
sl
.
size
()
>=
6
)
{
{
matrix
.
setMatrix
(
matrix
.
setMatrix
(
sl
.
at
(
0
).
toFloat
(),
sl
.
at
(
0
).
toFloat
(),
sl
.
at
(
1
).
toFloat
(),
sl
.
at
(
1
).
toFloat
(),
sl
.
at
(
2
).
toFloat
(),
sl
.
at
(
2
).
toFloat
(),
sl
.
at
(
3
).
toFloat
(),
sl
.
at
(
3
).
toFloat
(),
sl
.
at
(
4
).
toFloat
(),
sl
.
at
(
4
).
toFloat
(),
sl
.
at
(
5
).
toFloat
());
sl
.
at
(
5
).
toFloat
());
}
}
return
matrix
;
return
matrix
;
...
@@ -340,7 +340,7 @@ QString UBSvgSubsetAdaptor::readTeacherGuideNode(int sceneIndex)
...
@@ -340,7 +340,7 @@ QString UBSvgSubsetAdaptor::readTeacherGuideNode(int sceneIndex)
mXmlReader
.
readNext
();
mXmlReader
.
readNext
();
if
(
mXmlReader
.
isStartElement
())
if
(
mXmlReader
.
isStartElement
())
{
{
if
(
mXmlReader
.
name
()
==
"teacherBar"
||
mXmlReader
.
name
()
==
"teacherGuide"
){
if
(
mXmlReader
.
name
()
==
"teacherBar"
||
mXmlReader
.
name
()
==
"teacherGuide"
){
result
.
clear
();
result
.
clear
();
result
+=
"<teacherGuide version=
\"
"
+
mXmlReader
.
attributes
().
value
(
"version"
).
toString
()
+
"
\"
>"
;
result
+=
"<teacherGuide version=
\"
"
+
mXmlReader
.
attributes
().
value
(
"version"
).
toString
()
+
"
\"
>"
;
result
+=
"
\n
"
;
result
+=
"
\n
"
;
...
@@ -372,10 +372,10 @@ QString UBSvgSubsetAdaptor::readTeacherGuideNode(int sceneIndex)
...
@@ -372,10 +372,10 @@ QString UBSvgSubsetAdaptor::readTeacherGuideNode(int sceneIndex)
UBSvgSubsetAdaptor
::
UBSvgSubsetReader
::
UBSvgSubsetReader
(
UBDocumentProxy
*
pProxy
,
const
QByteArray
&
pXmlData
)
UBSvgSubsetAdaptor
::
UBSvgSubsetReader
::
UBSvgSubsetReader
(
UBDocumentProxy
*
pProxy
,
const
QByteArray
&
pXmlData
)
:
mXmlReader
(
pXmlData
)
:
mXmlReader
(
pXmlData
)
,
mProxy
(
pProxy
)
,
mProxy
(
pProxy
)
,
mDocumentPath
(
pProxy
->
persistencePath
())
,
mDocumentPath
(
pProxy
->
persistencePath
())
,
mGroupHasInfo
(
false
)
,
mGroupHasInfo
(
false
)
{
{
// NOOP
// NOOP
}
}
...
@@ -588,7 +588,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
...
@@ -588,7 +588,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
else
if
(
mXmlReader
.
name
()
==
"polyline"
)
else
if
(
mXmlReader
.
name
()
==
"polyline"
)
{
{
QList
<
UBGraphicsPolygonItem
*>
polygonItems
QList
<
UBGraphicsPolygonItem
*>
polygonItems
=
polygonItemsFromPolylineSvg
(
mScene
->
isDarkBackground
()
?
Qt
::
white
:
Qt
::
black
);
=
polygonItemsFromPolylineSvg
(
mScene
->
isDarkBackground
()
?
Qt
::
white
:
Qt
::
black
);
QString
parentId
=
QUuid
::
createUuid
().
toString
();
QString
parentId
=
QUuid
::
createUuid
().
toString
();
...
@@ -1111,9 +1111,9 @@ void UBSvgSubsetAdaptor::persistScene(UBDocumentProxy* proxy, UBGraphicsScene* p
...
@@ -1111,9 +1111,9 @@ void UBSvgSubsetAdaptor::persistScene(UBDocumentProxy* proxy, UBGraphicsScene* p
UBSvgSubsetAdaptor
::
UBSvgSubsetWriter
::
UBSvgSubsetWriter
(
UBDocumentProxy
*
proxy
,
UBGraphicsScene
*
pScene
,
const
int
pageIndex
)
UBSvgSubsetAdaptor
::
UBSvgSubsetWriter
::
UBSvgSubsetWriter
(
UBDocumentProxy
*
proxy
,
UBGraphicsScene
*
pScene
,
const
int
pageIndex
)
:
mScene
(
pScene
)
:
mScene
(
pScene
)
,
mDocumentPath
(
proxy
->
persistencePath
())
,
mDocumentPath
(
proxy
->
persistencePath
())
,
mPageIndex
(
pageIndex
)
,
mPageIndex
(
pageIndex
)
{
{
// NOOP
// NOOP
...
@@ -1216,23 +1216,23 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
...
@@ -1216,23 +1216,23 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
foreach
(
QGraphicsItem
*
item
,
strokesGroupItem
->
childItems
())
{
foreach
(
QGraphicsItem
*
item
,
strokesGroupItem
->
childItems
())
{
UBGraphicsPolygonItem
*
poly
=
qgraphicsitem_cast
<
UBGraphicsPolygonItem
*>
(
item
);
UBGraphicsPolygonItem
*
poly
=
qgraphicsitem_cast
<
UBGraphicsPolygonItem
*>
(
item
);
if
(
!
poly
)
{
if
(
!
poly
)
continue
;
continue
;
}
else
if
(
!
resultPoly
)
{
if
(
!
resultPoly
)
{
resultPoly
=
poly
;
resultPoly
=
poly
;
continue
;
continue
;
}
}
QPolygonF
newPolygon
=
poly
->
sceneTransform
().
map
(
poly
->
polygon
());
QPainterPath
strokePainterPath
;
QPolygonF
unitedPolygon
=
resultPoly
->
polygon
().
united
(
poly
->
polygon
());
strokePainterPath
.
addPolygon
(
resultPoly
->
sceneTransform
().
map
(
resultPoly
->
polygon
()));
resultPoly
->
setPolygon
(
unitedPolygon
);
QPolygonF
oldPolygons
=
strokePainterPath
.
simplified
().
toFillPolygon
(
resultPoly
->
sceneTransform
().
inverted
());
newPolygon
=
oldPolygons
.
united
(
newPolygon
);
resultPoly
->
setPolygon
(
newPolygon
);
//
items
.
removeOne
(
poly
);
items
.
removeOne
(
poly
);
}
}
if
(
resultPoly
)
{
if
(
resultPoly
)
{
//Claudio: the painter path simplification remove all the polygons overlap
QPainterPath
painterPath
;
painterPath
.
addPolygon
(
resultPoly
->
polygon
());
painterPath
=
painterPath
.
simplified
();
resultPoly
->
setPolygon
(
painterPath
.
toFillPolygon
());
polygonItemToSvgPolygon
(
resultPoly
,
true
);
polygonItemToSvgPolygon
(
resultPoly
,
true
);
items
.
removeOne
(
resultPoly
);
items
.
removeOne
(
resultPoly
);
}
}
...
@@ -1242,9 +1242,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
...
@@ -1242,9 +1242,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
UBGraphicsPolygonItem
*
polygonItem
=
qgraphicsitem_cast
<
UBGraphicsPolygonItem
*>
(
item
);
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
))
{
{
mXmlWriter
.
writeEndElement
();
//g
mXmlWriter
.
writeEndElement
();
//g
...
@@ -1703,7 +1701,7 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromPol
...
@@ -1703,7 +1701,7 @@ UBGraphicsPolygonItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItemFromPol
if
(
!
svgPoints
.
isNull
())
if
(
!
svgPoints
.
isNull
())
{
{
QStringList
ts
=
svgPoints
.
toString
().
split
(
QLatin1Char
(
' '
),
QStringList
ts
=
svgPoints
.
toString
().
split
(
QLatin1Char
(
' '
),
QString
::
SkipEmptyParts
);
QString
::
SkipEmptyParts
);
foreach
(
const
QString
sPoint
,
ts
)
foreach
(
const
QString
sPoint
,
ts
)
{
{
...
@@ -1998,7 +1996,7 @@ QList<UBGraphicsPolygonItem*> UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItem
...
@@ -1998,7 +1996,7 @@ QList<UBGraphicsPolygonItem*> UBSvgSubsetAdaptor::UBSvgSubsetReader::polygonItem
if
(
!
svgPoints
.
isNull
())
if
(
!
svgPoints
.
isNull
())
{
{
QStringList
ts
=
svgPoints
.
toString
().
split
(
QLatin1Char
(
' '
),
QStringList
ts
=
svgPoints
.
toString
().
split
(
QLatin1Char
(
' '
),
QString
::
SkipEmptyParts
);
QString
::
SkipEmptyParts
);
QList
<
QPointF
>
points
;
QList
<
QPointF
>
points
;
...
@@ -2370,9 +2368,9 @@ void UBSvgSubsetAdaptor::UBSvgSubsetReader::graphicsItemFromSvg(QGraphicsItem* g
...
@@ -2370,9 +2368,9 @@ void UBSvgSubsetAdaptor::UBSvgSubsetReader::graphicsItemFromSvg(QGraphicsItem* g
{
{
if
(
!
svgX
.
isNull
()
&&
!
svgY
.
isNull
())
if
(
!
svgX
.
isNull
()
&&
!
svgY
.
isNull
())
{
{
#ifdef Q_WS_WIN
#ifdef Q_WS_WIN
gItem
->
setPos
(
svgX
.
toString
().
toFloat
(),
svgY
.
toString
().
toFloat
());
gItem
->
setPos
(
svgX
.
toString
().
toFloat
(),
svgY
.
toString
().
toFloat
());
#endif
#endif
}
}
}
}
...
@@ -2749,7 +2747,7 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
...
@@ -2749,7 +2747,7 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
color
.
setNamedColor
(
ubFillOnLightBackground
.
toString
());
color
.
setNamedColor
(
ubFillOnLightBackground
.
toString
());
if
(
!
color
.
isValid
())
if
(
!
color
.
isValid
())
color
=
Qt
::
black
;
color
=
Qt
::
black
;
textItem
->
setColorOnLightBackground
(
color
);
textItem
->
setColorOnLightBackground
(
color
);
}
}
QString
text
;
QString
text
;
...
@@ -2779,7 +2777,7 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
...
@@ -2779,7 +2777,7 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
return
textItem
;
return
textItem
;
}
}
//tracking for backward capability with older versions
//tracking for backward capability with older versions
}
else
if
(
mXmlReader
.
name
()
==
"font"
)
{
}
else
if
(
mXmlReader
.
name
()
==
"font"
)
{
QFont
font
=
textItem
->
font
();
QFont
font
=
textItem
->
font
();
...
@@ -2794,18 +2792,18 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
...
@@ -2794,18 +2792,18 @@ UBGraphicsTextItem* UBSvgSubsetAdaptor::UBSvgSubsetReader::textItemFromSvg()
styleToken
=
styleToken
.
trimmed
();
styleToken
=
styleToken
.
trimmed
();
if
(
styleToken
.
startsWith
(
sFontSizePrefix
)
&&
styleToken
.
endsWith
(
sPixelUnit
))
{
if
(
styleToken
.
startsWith
(
sFontSizePrefix
)
&&
styleToken
.
endsWith
(
sPixelUnit
))
{
int
fontSize
=
styleToken
.
mid
(
int
fontSize
=
styleToken
.
mid
(
sFontSizePrefix
.
length
(),
sFontSizePrefix
.
length
(),
styleToken
.
length
()
-
sFontSizePrefix
.
length
()
-
sPixelUnit
.
length
()).
toInt
();
styleToken
.
length
()
-
sFontSizePrefix
.
length
()
-
sPixelUnit
.
length
()).
toInt
();
font
.
setPixelSize
(
fontSize
);
font
.
setPixelSize
(
fontSize
);
}
else
if
(
styleToken
.
startsWith
(
sFontWeightPrefix
))
{
}
else
if
(
styleToken
.
startsWith
(
sFontWeightPrefix
))
{
QString
fontWeight
=
styleToken
.
mid
(
QString
fontWeight
=
styleToken
.
mid
(
sFontWeightPrefix
.
length
(),
sFontWeightPrefix
.
length
(),
styleToken
.
length
()
-
sFontWeightPrefix
.
length
());
styleToken
.
length
()
-
sFontWeightPrefix
.
length
());
font
.
setBold
(
fontWeight
.
contains
(
"bold"
));
font
.
setBold
(
fontWeight
.
contains
(
"bold"
));
}
else
if
(
styleToken
.
startsWith
(
sFontStylePrefix
))
{
}
else
if
(
styleToken
.
startsWith
(
sFontStylePrefix
))
{
QString
fontStyle
=
styleToken
.
mid
(
QString
fontStyle
=
styleToken
.
mid
(
sFontStylePrefix
.
length
(),
sFontStylePrefix
.
length
(),
styleToken
.
length
()
-
sFontStylePrefix
.
length
());
styleToken
.
length
()
-
sFontStylePrefix
.
length
());
font
.
setItalic
(
fontStyle
.
contains
(
"italic"
));
font
.
setItalic
(
fontStyle
.
contains
(
"italic"
));
}
}
}
}
...
@@ -3159,7 +3157,7 @@ UBGraphicsTriangle* UBSvgSubsetAdaptor::UBSvgSubsetReader::triangleFromSvg()
...
@@ -3159,7 +3157,7 @@ UBGraphicsTriangle* UBSvgSubsetAdaptor::UBSvgSubsetReader::triangleFromSvg()
UBGraphicsTriangle
::
UBGraphicsTriangleOrientation
orientation
=
UBGraphicsTriangle
::
orientationFromStr
(
orientationStringRef
);
UBGraphicsTriangle
::
UBGraphicsTriangleOrientation
orientation
=
UBGraphicsTriangle
::
orientationFromStr
(
orientationStringRef
);
triangle
->
setOrientation
(
orientation
);
triangle
->
setOrientation
(
orientation
);
if
(
!
svgX
.
isNull
()
&&
!
svgY
.
isNull
()
&&
!
svgWidth
.
isNull
()
&&
!
svgHeight
.
isNull
())
if
(
!
svgX
.
isNull
()
&&
!
svgY
.
isNull
()
&&
!
svgWidth
.
isNull
()
&&
!
svgHeight
.
isNull
())
{
{
triangle
->
setRect
(
svgX
.
toString
().
toFloat
(),
svgY
.
toString
().
toFloat
(),
svgWidth
.
toString
().
toFloat
(),
svgHeight
.
toString
().
toFloat
(),
orientation
);
triangle
->
setRect
(
svgX
.
toString
().
toFloat
(),
svgY
.
toString
().
toFloat
(),
svgWidth
.
toString
().
toFloat
(),
svgHeight
.
toString
().
toFloat
(),
orientation
);
}
}
...
...
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