Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
d424ef7a
Commit
d424ef7a
authored
2 years ago
by
Mikhail Svechnikov
Browse files
Options
Downloads
Patches
Plain Diff
PointwiseItem: upd r/w
parent
ff8c5e92
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1197
GUI: serialization refactoring part 5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/Model/Device/PointwiseAxisItem.cpp
+35
-30
35 additions, 30 deletions
GUI/Model/Device/PointwiseAxisItem.cpp
GUI/Model/Device/PointwiseAxisItem.h
+2
-2
2 additions, 2 deletions
GUI/Model/Device/PointwiseAxisItem.h
with
37 additions
and
32 deletions
GUI/Model/Device/PointwiseAxisItem.cpp
+
35
−
30
View file @
d424ef7a
...
@@ -22,20 +22,13 @@
...
@@ -22,20 +22,13 @@
#include
"GUI/Support/XML/UtilXML.h"
#include
"GUI/Support/XML/UtilXML.h"
namespace
{
namespace
{
namespace
Tag
{
namespace
Tag
{
const
QString
NativeUnits
(
"NativeUnits"
);
const
QString
NativeUnits
(
"NativeUnits"
);
const
QString
BinaryData
(
"BinaryData"
);
const
QString
BinaryData
(
"BinaryData"
);
const
QString
BaseData
(
"BaseData"
);
}
// namespace Tag
}
// namespace Tag
namespace
Attrib
{
const
QString
value
(
"value"
);
}
}
// namespace
}
// namespace
PointwiseAxisItem
::
PointwiseAxisItem
(
QObject
*
parent
)
PointwiseAxisItem
::
PointwiseAxisItem
(
QObject
*
parent
)
...
@@ -106,44 +99,56 @@ void PointwiseAxisItem::deserializeBinaryData(const QByteArray& data)
...
@@ -106,44 +99,56 @@ void PointwiseAxisItem::deserializeBinaryData(const QByteArray& data)
m_axis
=
std
::
unique_ptr
<
IAxis
>
(
d
->
axis
(
0
).
clone
());
m_axis
=
std
::
unique_ptr
<
IAxis
>
(
d
->
axis
(
0
).
clone
());
}
}
void
PointwiseAxisItem
::
writeTo
(
QXmlStreamWriter
*
w
riter
)
const
void
PointwiseAxisItem
::
writeTo
(
QXmlStreamWriter
*
w
)
const
{
{
BasicAxisItem
::
writeTo
(
writer
);
XML
::
writeAttribute
(
w
,
XML
::
Attrib
::
version
,
uint
(
1
));
// parameters from base class
w
->
writeStartElement
(
Tag
::
BaseData
);
BasicAxisItem
::
writeTo
(
w
);
w
->
writeEndElement
();
// axis binary data
// axis binary data
QByteArray
a
=
serializeBinaryData
();
QByteArray
a
=
serializeBinaryData
();
if
(
!
a
.
isEmpty
())
{
if
(
!
a
.
isEmpty
())
{
w
riter
->
writeStartElement
(
Tag
::
BinaryData
);
w
->
writeStartElement
(
Tag
::
BinaryData
);
w
riter
->
writeCharacters
(
a
.
toBase64
());
w
->
writeCharacters
(
a
.
toBase64
());
w
riter
->
writeEndElement
();
w
->
writeEndElement
();
}
}
// native units
// native units
w
riter
->
writeStartElement
(
Tag
::
NativeUnits
);
w
->
writeStartElement
(
Tag
::
NativeUnits
);
XML
::
writeAttribute
(
w
riter
,
Attrib
::
value
,
m_nativeAxisUnits
);
XML
::
writeAttribute
(
w
,
XML
::
Attrib
::
value
,
m_nativeAxisUnits
);
w
riter
->
writeEndElement
();
w
->
writeEndElement
();
}
}
void
PointwiseAxisItem
::
readFrom
(
QXmlStreamReader
*
reade
r
)
void
PointwiseAxisItem
::
readFrom
(
QXmlStreamReader
*
r
)
{
{
while
(
reader
->
readNextStartElement
())
{
const
uint
version
=
XML
::
readUIntAttribute
(
r
,
XML
::
Attrib
::
version
);
Q_UNUSED
(
version
)
while
(
r
->
readNextStartElement
())
{
QString
tag
=
r
->
name
().
toString
();
// axis binary data
// parameters from base class
if
(
reader
->
name
()
==
Tag
::
BinaryData
)
{
if
(
tag
==
Tag
::
BaseData
)
{
QString
valueAsBase64
=
reader
->
readElementText
(
QXmlStreamReader
::
SkipChildElements
);
BasicAxisItem
::
readFrom
(
r
);
XML
::
gotoEndElementOfTag
(
r
,
tag
);
// axis binary data
}
else
if
(
tag
==
Tag
::
BinaryData
)
{
QString
valueAsBase64
=
r
->
readElementText
(
QXmlStreamReader
::
SkipChildElements
);
const
auto
data
=
QByteArray
::
fromBase64
(
valueAsBase64
.
toLatin1
());
const
auto
data
=
QByteArray
::
fromBase64
(
valueAsBase64
.
toLatin1
());
deserializeBinaryData
(
data
);
deserializeBinaryData
(
data
);
XML
::
gotoEndElementOfTag
(
r
eader
,
T
ag
::
BinaryData
);
XML
::
gotoEndElementOfTag
(
r
,
t
ag
);
// native units
// native units
}
else
if
(
reader
->
name
()
==
Tag
::
NativeUnits
)
{
}
else
if
(
tag
==
Tag
::
NativeUnits
)
{
XML
::
readAttribute
(
reader
,
Attrib
::
value
,
&
m_nativeAxisUnits
);
XML
::
readAttribute
(
r
,
XML
::
Attrib
::
value
,
&
m_nativeAxisUnits
);
XML
::
gotoEndElementOfTag
(
reader
,
Tag
::
NativeUnits
);
XML
::
gotoEndElementOfTag
(
r
,
tag
);
// members from base class
}
else
}
else
{
r
->
skipCurrentElement
();
BasicAxisItem
::
readBasicTags
(
reader
);
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
GUI/Model/Device/PointwiseAxisItem.h
+
2
−
2
View file @
d424ef7a
...
@@ -42,8 +42,8 @@ public:
...
@@ -42,8 +42,8 @@ public:
QByteArray
serializeBinaryData
()
const
;
QByteArray
serializeBinaryData
()
const
;
void
deserializeBinaryData
(
const
QByteArray
&
data
);
void
deserializeBinaryData
(
const
QByteArray
&
data
);
void
writeTo
(
QXmlStreamWriter
*
w
riter
)
const
override
;
void
writeTo
(
QXmlStreamWriter
*
w
)
const
override
;
void
readFrom
(
QXmlStreamReader
*
reade
r
)
override
;
void
readFrom
(
QXmlStreamReader
*
r
)
override
;
private:
private:
bool
checkValidity
()
const
;
bool
checkValidity
()
const
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment