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
5083b9a8
Commit
5083b9a8
authored
3 years ago
by
Matthias Puchner
Browse files
Options
Downloads
Patches
Plain Diff
split computation method setting in two methods; use string constants
parent
85adde49
No related branches found
No related tags found
1 merge request
!217
Refactor SimulationOptionsItem for strong typed methods
Pipeline
#41779
passed
3 years ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
GUI/Models/SimulationOptionsItem.cpp
+32
-31
32 additions, 31 deletions
GUI/Models/SimulationOptionsItem.cpp
GUI/Models/SimulationOptionsItem.h
+2
-1
2 additions, 1 deletion
GUI/Models/SimulationOptionsItem.h
Tests/UnitTests/GUI/TestMapperCases.cpp
+1
-1
1 addition, 1 deletion
Tests/UnitTests/GUI/TestMapperCases.cpp
with
35 additions
and
33 deletions
GUI/Models/SimulationOptionsItem.cpp
+
32
−
31
View file @
5083b9a8
...
...
@@ -36,6 +36,14 @@ const QString tooltip_ambientmaterial =
const
QString
tooltip_specularpeak
=
"Defines if the specular peak should be included in the simulation result"
;
const
QString
Immediately
=
"Immediately"
;
const
QString
InBackground
=
"In background"
;
const
QString
Analytical
=
"Analytical"
;
const
QString
MonteCarlo
=
"Monte-Carlo Integration"
;
const
QString
AmbientLayerMaterial
=
"Ambient Layer Material"
;
const
QString
AverageLayerMaterial
=
"Average Layer Material"
;
const
QString
Yes
=
"Yes"
;
const
QString
No
=
"No"
;
}
// namespace
const
QString
SimulationOptionsItem
::
P_RUN_POLICY
=
"Run Policy"
;
...
...
@@ -61,21 +69,18 @@ SimulationOptionsItem::SimulationOptionsItem() : SessionItem(M_TYPE)
addProperty
(
P_NTHREADS
,
nthreads
.
variant
())
->
setToolTip
(
tooltip_nthreads
);
ComboProperty
computationMethod
;
computationMethod
<<
"Analytical"
<<
"Monte-Carlo Integration"
;
computationMethod
<<
Analytical
<<
MonteCarlo
;
addProperty
(
P_COMPUTATION_METHOD
,
computationMethod
.
variant
())
->
setToolTip
(
tooltip_computation
);
addProperty
(
P_MC_POINTS
,
100
)
->
setEnabled
(
false
);
ComboProperty
averageLayerMaterials
;
averageLayerMaterials
<<
"Ambient Layer Material"
<<
"Average Layer Material"
;
averageLayerMaterials
<<
AmbientLayerMaterial
<<
AverageLayerMaterial
;
addProperty
(
P_FRESNEL_MATERIAL_METHOD
,
averageLayerMaterials
.
variant
())
->
setToolTip
(
tooltip_ambientmaterial
);
ComboProperty
includeSpecularPeak
;
includeSpecularPeak
<<
"No"
<<
"Yes"
;
includeSpecularPeak
<<
No
<<
Yes
;
addProperty
(
P_INCLUDE_SPECULAR_PEAK
,
includeSpecularPeak
.
variant
())
->
setToolTip
(
tooltip_specularpeak
);
...
...
@@ -83,17 +88,14 @@ SimulationOptionsItem::SimulationOptionsItem() : SessionItem(M_TYPE)
if
(
name
==
P_COMPUTATION_METHOD
&&
isTag
(
P_MC_POINTS
))
{
ComboProperty
combo
=
getItemValue
(
P_COMPUTATION_METHOD
).
value
<
ComboProperty
>
();
if
(
combo
.
getValue
()
==
"
Analytical
"
)
{
if
(
combo
.
getValue
()
==
Analytical
)
getItem
(
P_MC_POINTS
)
->
setEnabled
(
false
);
}
else
{
else
getItem
(
P_MC_POINTS
)
->
setEnabled
(
true
);
}
}
else
if
(
name
==
P_NTHREADS
)
{
}
else
if
(
name
==
P_NTHREADS
)
updateComboItem
(
P_NTHREADS
,
getCPUUsageOptions
());
}
else
if
(
name
==
P_RUN_POLICY
)
{
else
if
(
name
==
P_RUN_POLICY
)
updateComboItem
(
P_RUN_POLICY
,
getRunPolicyNames
());
}
});
}
...
...
@@ -117,17 +119,17 @@ void SimulationOptionsItem::setNumberOfThreads(int number)
bool
SimulationOptionsItem
::
runImmediately
()
const
{
return
runPolicy
()
==
"
Immediately
"
;
return
runPolicy
()
==
Immediately
;
}
bool
SimulationOptionsItem
::
runInBackground
()
const
{
return
run
Policy
()
==
"In background"
;
return
!
run
Immediately
()
;
}
void
SimulationOptionsItem
::
setRunImmediately
(
bool
runImmediately
)
{
setRunPolicy
(
runImmediately
?
"
Immediately
"
:
"
In
b
ackground
"
);
setRunPolicy
(
runImmediately
?
Immediately
:
In
B
ackground
);
}
void
SimulationOptionsItem
::
setRunPolicy
(
const
QString
&
policy
)
...
...
@@ -137,19 +139,20 @@ void SimulationOptionsItem::setRunPolicy(const QString& policy)
setItemValue
(
P_RUN_POLICY
,
combo
.
variant
());
}
void
SimulationOptionsItem
::
setMonteCarloIntegration
(
bool
useMonteCarlo
,
int
numberOfPoints
)
void
SimulationOptionsItem
::
set
Use
MonteCarloIntegration
(
int
numberOfPoints
)
{
if
(
useMonteCarlo
)
{
setComputationMethod
(
"Monte-Carlo Integration"
);
setNumberOfMonteCarloPoints
(
numberOfPoints
);
}
else
{
setComputationMethod
(
"Analytical"
);
}
setComputationMethod
(
MonteCarlo
);
setNumberOfMonteCarloPoints
(
numberOfPoints
);
}
void
SimulationOptionsItem
::
setUseAnalytical
()
{
setComputationMethod
(
Analytical
);
}
bool
SimulationOptionsItem
::
useMonteCarloIntegration
()
const
{
return
getComputationMethod
()
.
startsWith
(
"Mon"
)
;
return
getComputationMethod
()
==
MonteCarlo
;
}
void
SimulationOptionsItem
::
setComputationMethod
(
const
QString
&
name
)
...
...
@@ -177,13 +180,12 @@ void SimulationOptionsItem::setNumberOfMonteCarloPoints(int npoints)
void
SimulationOptionsItem
::
setUseAverageMaterials
(
bool
useAverageMaterials
)
{
setFresnelMaterialMethod
(
useAverageMaterials
?
"Average Layer Material"
:
"Ambient Layer Material"
);
setFresnelMaterialMethod
(
useAverageMaterials
?
AverageLayerMaterial
:
AmbientLayerMaterial
);
}
bool
SimulationOptionsItem
::
useAverageMaterials
()
const
{
return
getFresnelMaterialMethod
()
.
startsWith
(
"Aver"
)
;
return
getFresnelMaterialMethod
()
==
AverageLayerMaterial
;
}
void
SimulationOptionsItem
::
setFresnelMaterialMethod
(
const
QString
&
name
)
...
...
@@ -202,14 +204,14 @@ QString SimulationOptionsItem::getFresnelMaterialMethod() const
void
SimulationOptionsItem
::
setIncludeSpecularPeak
(
bool
includeSpecularPeak
)
{
ComboProperty
combo
=
getItemValue
(
P_INCLUDE_SPECULAR_PEAK
).
value
<
ComboProperty
>
();
combo
.
setValue
(
includeSpecularPeak
?
"
Yes
"
:
"
No
"
);
combo
.
setValue
(
includeSpecularPeak
?
Yes
:
No
);
setItemValue
(
P_INCLUDE_SPECULAR_PEAK
,
combo
.
variant
());
}
bool
SimulationOptionsItem
::
includeSpecularPeak
()
const
{
ComboProperty
combo
=
getItemValue
(
P_INCLUDE_SPECULAR_PEAK
).
value
<
ComboProperty
>
();
return
combo
.
getValue
()
==
"
Yes
"
;
return
combo
.
getValue
()
==
Yes
;
}
SessionItem
*
SimulationOptionsItem
::
monteCarloPointsItem
()
const
...
...
@@ -247,8 +249,7 @@ QStringList SimulationOptionsItem::getCPUUsageOptions()
QStringList
SimulationOptionsItem
::
getRunPolicyNames
()
{
QStringList
result
;
result
<<
"Immediately"
<<
"In background"
;
result
<<
Immediately
<<
InBackground
;
return
result
;
}
...
...
This diff is collapsed.
Click to expand it.
GUI/Models/SimulationOptionsItem.h
+
2
−
1
View file @
5083b9a8
...
...
@@ -43,7 +43,8 @@ public:
bool
runImmediately
()
const
;
bool
runInBackground
()
const
;
void
setMonteCarloIntegration
(
bool
useMonteCarlo
,
int
numberOfPoints
=
50
);
void
setUseMonteCarloIntegration
(
int
numberOfPoints
);
void
setUseAnalytical
();
bool
useMonteCarloIntegration
()
const
;
void
setNumberOfMonteCarloPoints
(
int
npoints
);
...
...
This diff is collapsed.
Click to expand it.
Tests/UnitTests/GUI/TestMapperCases.cpp
+
1
−
1
View file @
5083b9a8
...
...
@@ -38,6 +38,6 @@ TEST_F(TestMapperCases, test_SimulationOptionsComputationToggle)
EXPECT_EQ
(
item
->
useMonteCarloIntegration
(),
false
);
EXPECT_FALSE
(
item
->
monteCarloPointsItem
()
->
isEnabled
());
item
->
setMonteCarloIntegration
(
true
);
item
->
set
Use
MonteCarloIntegration
(
100
);
EXPECT_TRUE
(
item
->
monteCarloPointsItem
()
->
isEnabled
());
}
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