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
8f4d375d
Commit
8f4d375d
authored
3 years ago
by
Matthias Puchner
Browse files
Options
Downloads
Patches
Plain Diff
free BackgroundItems from SessionItem
parent
53ed3a6a
No related branches found
No related tags found
1 merge request
!624
Remove SessionItem from Instrument items
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/Model/Item/BackgroundItems.cpp
+11
-45
11 additions, 45 deletions
GUI/Model/Item/BackgroundItems.cpp
GUI/Model/Item/BackgroundItems.h
+8
-17
8 additions, 17 deletions
GUI/Model/Item/BackgroundItems.h
with
19 additions
and
62 deletions
GUI/Model/Item/BackgroundItems.cpp
+
11
−
45
View file @
8f4d375d
...
...
@@ -16,65 +16,31 @@
#include
"Core/Background/ConstantBackground.h"
#include
"Core/Background/PoissonNoiseBackground.h"
#include
"GUI/Model/Types/DoubleDescriptor.h"
BackgroundItem
::
BackgroundItem
(
const
QString
&
model_type
)
:
SessionItem
(
model_type
)
{
}
// Background none
/* ------------------------------------------------ */
NoBackgroundItem
::
NoBackgroundItem
()
:
BackgroundItem
(
M_TYPE
)
{
}
std
::
unique_ptr
<
IBackground
>
NoBackgroundItem
::
createBackground
()
const
{
return
{};
}
// Constant background
/* ------------------------------------------------ */
namespace
{
const
QString
constant_background_value_tooltip
=
"Constant background value [counts/pixel]"
;
}
#include
"GUI/Model/XML/Serializer.h"
ConstantBackgroundItem
::
ConstantBackgroundItem
()
:
BackgroundItem
(
M_TYPE
)
{
addProperty
(
P_VALUE
,
0.0
)
->
setLimits
(
RealLimits
::
nonnegative
())
.
setToolTip
(
constant_background_value_tooltip
);
m_backgroundValue
.
init
(
"Background value"
,
"Constant background value"
,
0.0
,
"counts/pixel"
,
3
,
RealLimits
::
nonnegative
(),
"value"
);
}
std
::
unique_ptr
<
IBackground
>
ConstantBackgroundItem
::
createBackground
()
const
{
return
std
::
make_unique
<
ConstantBackground
>
(
getItemValue
(
P_VALUE
).
toDouble
()
);
return
std
::
make_unique
<
ConstantBackground
>
(
m_backgroundValue
);
}
DoubleDescriptor
ConstantBackgroundItem
::
backgroundValue
()
const
void
ConstantBackgroundItem
::
serialize
(
Serializer
&
s
)
{
return
DoubleDescriptor
(
getItem
(
P_VALUE
),
"counts/pixel"
);
s
.
assertVersion
(
0
);
s
.
rw
(
m_backgroundValue
);
}
void
ConstantBackgroundItem
::
setBackgroundValue
(
double
value
)
{
setItemValue
(
P_VALUE
,
value
);
}
// Background consisting of Poisson noise
/* ------------------------------------------------ */
PoissonNoiseBackgroundItem
::
PoissonNoiseBackgroundItem
()
:
BackgroundItem
(
M_TYPE
)
std
::
unique_ptr
<
IBackground
>
PoissonNoiseBackgroundItem
::
createBackground
()
const
{
return
std
::
make_unique
<
PoissonNoiseBackground
>
();
}
std
::
unique_ptr
<
IBackground
>
PoissonNoise
BackgroundItem
::
createBackground
()
const
std
::
unique_ptr
<
IBackground
>
No
BackgroundItem
::
createBackground
()
const
{
return
std
::
make_unique
<
PoissonNoiseBackground
>
()
;
return
{}
;
}
This diff is collapsed.
Click to expand it.
GUI/Model/Item/BackgroundItems.h
+
8
−
17
View file @
8f4d375d
...
...
@@ -15,45 +15,36 @@
#ifndef BORNAGAIN_GUI_MODEL_ITEM_BACKGROUNDITEMS_H
#define BORNAGAIN_GUI_MODEL_ITEM_BACKGROUNDITEMS_H
#include
"GUI/Model/BaseItem/SessionItem.h"
#include
"GUI/Model/Types/DoubleProperty.h"
#include
<memory>
class
IBackground
;
class
DoubleDescripto
r
;
class
Serialize
r
;
class
B
A_CORE_API_
BackgroundItem
:
public
Session
Item
{
class
B
ackground
Item
{
public:
explicit
BackgroundItem
(
const
QString
&
model_type
)
;
virtual
~
BackgroundItem
(
)
=
default
;
virtual
std
::
unique_ptr
<
IBackground
>
createBackground
()
const
=
0
;
virtual
void
serialize
(
Serializer
&
s
)
{}
};
class
NoBackgroundItem
:
public
BackgroundItem
{
public:
static
constexpr
auto
M_TYPE
{
"NoBackground"
};
NoBackgroundItem
();
std
::
unique_ptr
<
IBackground
>
createBackground
()
const
override
;
};
class
ConstantBackgroundItem
:
public
BackgroundItem
{
private:
static
constexpr
auto
P_VALUE
{
"BackgroundValue"
};
public:
static
constexpr
auto
M_TYPE
{
"ConstantBackground"
};
ConstantBackgroundItem
();
std
::
unique_ptr
<
IBackground
>
createBackground
()
const
override
;
void
serialize
(
Serializer
&
s
)
override
;
DoubleDescriptor
backgroundValue
()
const
;
void
setBackgroundValue
(
double
value
);
DOUBLE_PROPERTY
(
backgroundValue
,
BackgroundValue
);
};
class
PoissonNoiseBackgroundItem
:
public
BackgroundItem
{
public:
static
constexpr
auto
M_TYPE
{
"PoissonNoiseBackground"
};
PoissonNoiseBackgroundItem
();
std
::
unique_ptr
<
IBackground
>
createBackground
()
const
override
;
};
...
...
This diff is collapsed.
Click to expand it.
m.puchner
@m.puchner
mentioned in issue
#89 (closed)
·
3 years ago
mentioned in issue
#89 (closed)
mentioned in issue #89
Toggle commit list
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