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
c42b7e2f
Commit
c42b7e2f
authored
2 years ago
by
Mikhail Svechnikov
Committed by
Mikhail Svechnikov
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
RoughnessItems: add writeTo & readFrom
parent
c903e0e9
No related branches found
No related tags found
1 merge request
!1191
GUI: serialization refactoring part 3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/Model/Sample/RoughnessItems.cpp
+56
-3
56 additions, 3 deletions
GUI/Model/Sample/RoughnessItems.cpp
GUI/Model/Sample/RoughnessItems.h
+5
-2
5 additions, 2 deletions
GUI/Model/Sample/RoughnessItems.h
with
61 additions
and
5 deletions
GUI/Model/Sample/RoughnessItems.cpp
+
56
−
3
View file @
c42b7e2f
...
...
@@ -14,6 +14,7 @@
#include
"GUI/Model/Sample/RoughnessItems.h"
#include
"GUI/Support/XML/Serialize.h"
#include
"GUI/Support/XML/UtilXML.h"
namespace
{
namespace
Tag
{
...
...
@@ -40,7 +41,59 @@ BasicRoughnessItem::BasicRoughnessItem()
void
BasicRoughnessItem
::
serialize
(
Streamer
&
s
)
{
s
.
assertVersion
(
0
);
Serialize
::
rwProperty
(
s
,
Tag
::
Sigma
,
m_sigma
);
Serialize
::
rwProperty
(
s
,
Tag
::
Hurst
,
m_hurst
);
Serialize
::
rwProperty
(
s
,
Tag
::
LateralCorrelationLength
,
m_lateralCorrelationLength
);
// Serialize::rwProperty(s, Tag::Sigma, m_sigma);
// Serialize::rwProperty(s, Tag::Hurst, m_hurst);
// Serialize::rwProperty(s, Tag::LateralCorrelationLength, m_lateralCorrelationLength);
if
(
s
.
xmlReader
())
readFrom
(
s
.
xmlReader
());
else
if
(
s
.
xmlWriter
())
writeTo
(
s
.
xmlWriter
());
}
void
BasicRoughnessItem
::
writeTo
(
QXmlStreamWriter
*
w
)
const
{
XML
::
writeAttribute
(
w
,
XML
::
Attrib
::
version
,
uint
(
1
));
// sigma
w
->
writeStartElement
(
Tag
::
Sigma
);
m_sigma
.
writeTo
(
w
);
w
->
writeEndElement
();
// hurst
w
->
writeStartElement
(
Tag
::
Hurst
);
m_hurst
.
writeTo
(
w
);
w
->
writeEndElement
();
// lateral correlation length
w
->
writeStartElement
(
Tag
::
LateralCorrelationLength
);
m_lateralCorrelationLength
.
writeTo
(
w
);
w
->
writeEndElement
();
}
void
BasicRoughnessItem
::
readFrom
(
QXmlStreamReader
*
r
)
{
const
uint
version
=
XML
::
readUIntAttribute
(
r
,
XML
::
Attrib
::
version
);
Q_UNUSED
(
version
)
while
(
r
->
readNextStartElement
())
{
QString
tag
=
r
->
name
().
toString
();
// sigma
if
(
tag
==
Tag
::
Sigma
)
{
m_sigma
.
readFrom
(
r
);
XML
::
gotoEndElementOfTag
(
r
,
tag
);
// hurst
}
else
if
(
tag
==
Tag
::
Hurst
)
{
m_hurst
.
readFrom
(
r
);
XML
::
gotoEndElementOfTag
(
r
,
tag
);
// lateral correlation length
}
else
if
(
tag
==
Tag
::
LateralCorrelationLength
)
{
m_lateralCorrelationLength
.
readFrom
(
r
);
XML
::
gotoEndElementOfTag
(
r
,
tag
);
}
else
r
->
skipCurrentElement
();
}
}
This diff is collapsed.
Click to expand it.
GUI/Model/Sample/RoughnessItems.h
+
5
−
2
View file @
c42b7e2f
...
...
@@ -16,15 +16,16 @@
#define BORNAGAIN_GUI_MODEL_SAMPLE_ROUGHNESSITEMS_H
#include
"GUI/Model/Descriptor/DoubleProperty.h"
#include
<QXmlStreamReader>
class
QXmlStreamReader
;
class
QXmlStreamWriter
;
class
Streamer
;
class
RoughnessItem
{
public:
virtual
~
RoughnessItem
()
=
default
;
virtual
void
serialize
(
Streamer
&
s
)
=
0
;
virtual
void
writeTo
(
QXmlStreamWriter
*
w
)
const
=
0
;
virtual
void
readFrom
(
QXmlStreamReader
*
r
)
=
0
;
virtual
DoubleProperties
roughnessProperties
()
=
0
;
protected:
...
...
@@ -48,6 +49,8 @@ public:
void
setLateralCorrelationLength
(
double
v
)
{
m_lateralCorrelationLength
.
setValue
(
v
);
}
void
serialize
(
Streamer
&
s
)
override
;
void
writeTo
(
QXmlStreamWriter
*
w
)
const
;
void
readFrom
(
QXmlStreamReader
*
r
);
DoubleProperties
roughnessProperties
()
override
{
...
...
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