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
940704fa
Commit
940704fa
authored
Aug 25, 2011
by
Anatoly Mihalchenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SANKORE-220: Internal application: Triangle is lost after import from UBZ
parent
d146e791
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
10 deletions
+56
-10
UBSvgSubsetAdaptor.cpp
src/adaptors/UBSvgSubsetAdaptor.cpp
+43
-10
UBSvgSubsetAdaptor.h
src/adaptors/UBSvgSubsetAdaptor.h
+1
-0
UBGraphicsTriangle.h
src/tools/UBGraphicsTriangle.h
+12
-0
No files found.
src/adaptors/UBSvgSubsetAdaptor.cpp
View file @
940704fa
...
@@ -654,7 +654,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
...
@@ -654,7 +654,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene
->
registerTool
(
protractor
);
scene
->
registerTool
(
protractor
);
}
}
}
}
else
if
(
mXmlReader
.
name
()
==
"protractor
"
)
else
if
(
mXmlReader
.
name
()
==
"triangle
"
)
{
{
UBGraphicsTriangle
*
triangle
=
triangleFromSvg
();
UBGraphicsTriangle
*
triangle
=
triangleFromSvg
();
...
@@ -1060,6 +1060,14 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene()
...
@@ -1060,6 +1060,14 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene()
protractorToSvg
(
protractor
);
protractorToSvg
(
protractor
);
continue
;
continue
;
}
}
UBGraphicsTriangle
*
triangle
=
qgraphicsitem_cast
<
UBGraphicsTriangle
*>
(
item
);
if
(
triangle
&&
triangle
->
isVisible
())
{
triangleToSvg
(
triangle
);
continue
;
}
}
}
if
(
openStroke
)
if
(
openStroke
)
...
@@ -2589,6 +2597,39 @@ UBGraphicsProtractor* UBSvgSubsetAdaptor::UBSvgSubsetReader::protractorFromSvg()
...
@@ -2589,6 +2597,39 @@ UBGraphicsProtractor* UBSvgSubsetAdaptor::UBSvgSubsetReader::protractorFromSvg()
return
protractor
;
return
protractor
;
}
}
void
UBSvgSubsetAdaptor
::
UBSvgSubsetWriter
::
triangleToSvg
(
UBGraphicsTriangle
*
item
)
{
/**
*
* sample
*
<ub:triangle x="250" y="150" width="122" height="67"...>
</ub:triangle>
*/
mXmlWriter
.
writeStartElement
(
UBSettings
::
uniboardDocumentNamespaceUri
,
"triangle"
);
mXmlWriter
.
writeAttribute
(
"x"
,
QString
(
"%1"
).
arg
(
item
->
boundingRect
().
x
()));
mXmlWriter
.
writeAttribute
(
"y"
,
QString
(
"%1"
).
arg
(
item
->
boundingRect
().
y
()));
mXmlWriter
.
writeAttribute
(
"width"
,
QString
(
"%1"
).
arg
(
item
->
boundingRect
().
width
()));
mXmlWriter
.
writeAttribute
(
"height"
,
QString
(
"%1"
).
arg
(
item
->
boundingRect
().
height
()));
mXmlWriter
.
writeAttribute
(
"transform"
,
toSvgTransform
(
item
->
sceneMatrix
()));
mXmlWriter
.
writeAttribute
(
"orientation"
,
UBGraphicsTriangle
::
orientationToStr
(
item
->
getOrientation
()));
QString
zs
;
zs
.
setNum
(
item
->
zValue
(),
'f'
);
// 'f' keeps precision
mXmlWriter
.
writeAttribute
(
UBSettings
::
uniboardDocumentNamespaceUri
,
"z-value"
,
zs
);
UBItem
*
ubItem
=
dynamic_cast
<
UBItem
*>
(
item
);
if
(
ubItem
)
{
mXmlWriter
.
writeAttribute
(
UBSettings
::
uniboardDocumentNamespaceUri
,
"uuid"
,
UBStringUtils
::
toCanonicalUuid
(
ubItem
->
uuid
()));
}
mXmlWriter
.
writeEndElement
();
}
UBGraphicsTriangle
*
UBSvgSubsetAdaptor
::
UBSvgSubsetReader
::
triangleFromSvg
()
UBGraphicsTriangle
*
UBSvgSubsetAdaptor
::
UBSvgSubsetReader
::
triangleFromSvg
()
{
{
UBGraphicsTriangle
*
triangle
=
new
UBGraphicsTriangle
();
UBGraphicsTriangle
*
triangle
=
new
UBGraphicsTriangle
();
...
@@ -2598,20 +2639,12 @@ UBGraphicsTriangle* UBSvgSubsetAdaptor::UBSvgSubsetReader::triangleFromSvg()
...
@@ -2598,20 +2639,12 @@ UBGraphicsTriangle* UBSvgSubsetAdaptor::UBSvgSubsetReader::triangleFromSvg()
graphicsItemFromSvg
(
triangle
);
graphicsItemFromSvg
(
triangle
);
QStringRef
svgX
=
mXmlReader
.
attributes
().
value
(
"x"
);
QStringRef
svgY
=
mXmlReader
.
attributes
().
value
(
"y"
);
QStringRef
svgWidth
=
mXmlReader
.
attributes
().
value
(
"width"
);
QStringRef
svgHeight
=
mXmlReader
.
attributes
().
value
(
"height"
);
QStringRef
orientationStringRef
=
mXmlReader
.
attributes
().
value
(
"orientation"
);
QStringRef
orientationStringRef
=
mXmlReader
.
attributes
().
value
(
"orientation"
);
UBGraphicsTriangle
::
UBGraphicsTriangleOrientation
orientation
=
UBGraphicsTriangle
::
orientationFromStr
(
orientationStringRef
);
UBGraphicsTriangle
::
UBGraphicsTriangleOrientation
orientation
=
UBGraphicsTriangle
::
orientationFromStr
(
orientationStringRef
);
triangle
->
setOrientation
(
orientation
);
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
->
setVisible
(
true
);
triangle
->
setVisible
(
true
);
return
triangle
;
return
triangle
;
}
}
...
...
src/adaptors/UBSvgSubsetAdaptor.h
View file @
940704fa
...
@@ -210,6 +210,7 @@ class UBSvgSubsetAdaptor
...
@@ -210,6 +210,7 @@ class UBSvgSubsetAdaptor
void
rulerToSvg
(
UBGraphicsRuler
*
item
);
void
rulerToSvg
(
UBGraphicsRuler
*
item
);
void
compassToSvg
(
UBGraphicsCompass
*
item
);
void
compassToSvg
(
UBGraphicsCompass
*
item
);
void
protractorToSvg
(
UBGraphicsProtractor
*
item
);
void
protractorToSvg
(
UBGraphicsProtractor
*
item
);
void
triangleToSvg
(
UBGraphicsTriangle
*
item
);
void
writeSvgElement
();
void
writeSvgElement
();
private
:
private
:
...
...
src/tools/UBGraphicsTriangle.h
View file @
940704fa
...
@@ -66,12 +66,24 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
...
@@ -66,12 +66,24 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
if
(
str
==
"TopRight"
)
return
TopRight
;
if
(
str
==
"TopRight"
)
return
TopRight
;
return
sDefaultOrientation
;
return
sDefaultOrientation
;
}
}
static
QString
orientationToStr
(
UBGraphicsTriangleOrientation
orientation
)
{
QString
result
;
if
(
orientation
==
0
)
result
=
"BottomLeft"
;
else
if
(
orientation
==
1
)
result
=
"BottomRight"
;
else
if
(
orientation
==
2
)
result
=
"TopLeft"
;
else
if
(
orientation
==
3
)
result
=
"TopRight"
;
return
result
;
}
void
setRect
(
const
QRectF
&
rect
,
UBGraphicsTriangleOrientation
orientation
)
void
setRect
(
const
QRectF
&
rect
,
UBGraphicsTriangleOrientation
orientation
)
{
{
setRect
(
rect
.
x
(),
rect
.
y
(),
rect
.
width
(),
rect
.
height
(),
orientation
);
setRect
(
rect
.
x
(),
rect
.
y
(),
rect
.
width
(),
rect
.
height
(),
orientation
);
}
}
void
setRect
(
qreal
x
,
qreal
y
,
qreal
w
,
qreal
h
,
UBGraphicsTriangleOrientation
orientation
);
void
setRect
(
qreal
x
,
qreal
y
,
qreal
w
,
qreal
h
,
UBGraphicsTriangleOrientation
orientation
);
void
setOrientation
(
UBGraphicsTriangleOrientation
orientation
);
void
setOrientation
(
UBGraphicsTriangleOrientation
orientation
);
UBGraphicsTriangleOrientation
getOrientation
()
const
{
return
mOrientation
;}
QRectF
rect
()
const
{
return
boundingRect
();}
QRectF
rect
()
const
{
return
boundingRect
();}
UBGraphicsScene
*
scene
()
const
;
UBGraphicsScene
*
scene
()
const
;
...
...
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