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
12a6e852
Commit
12a6e852
authored
5 months ago
by
Mikhail Svechnikov
Browse files
Options
Downloads
Patches
Plain Diff
preserve central value of distribution
parent
a81e347d
No related branches found
No related tags found
1 merge request
!2750
Initialize beam with reasonable default values
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
GUI/Model/Beam/DistributionItems.h
+4
-0
4 additions, 0 deletions
GUI/Model/Beam/DistributionItems.h
GUI/View/Device/DistributionSelector.cpp
+7
-3
7 additions, 3 deletions
GUI/View/Device/DistributionSelector.cpp
GUI/View/Numeric/ComboUtil.h
+22
-10
22 additions, 10 deletions
GUI/View/Numeric/ComboUtil.h
with
33 additions
and
13 deletions
GUI/Model/Beam/DistributionItems.h
+
4
−
0
View file @
12a6e852
...
...
@@ -38,6 +38,7 @@ public:
virtual
DoubleProperty
&
center
()
=
0
;
virtual
const
DoubleProperty
&
center
()
const
=
0
;
virtual
void
setCenter
(
double
v
)
=
0
;
//! Serialization of contents.
//!
...
...
@@ -63,6 +64,7 @@ public:
DoubleProperty
&
center
()
override
{
return
mean
();
}
const
DoubleProperty
&
center
()
const
override
{
return
mean
();
}
void
setCenter
(
double
v
)
override
{
m_mean
.
setDVal
(
v
);
}
void
writeTo
(
QXmlStreamWriter
*
w
)
const
override
;
void
readFrom
(
QXmlStreamReader
*
r
)
override
;
...
...
@@ -88,6 +90,7 @@ public:
DoubleProperty
&
center
()
override
{
return
m_center
;
}
const
DoubleProperty
&
center
()
const
override
{
return
m_center
;
}
void
setCenter
(
double
v
)
override
{
m_center
.
setDVal
(
v
);
}
DoubleProperty
&
halfwidth
()
{
return
m_halfwidth
;
}
const
DoubleProperty
&
halfwidth
()
const
{
return
m_halfwidth
;
}
...
...
@@ -149,6 +152,7 @@ public:
DoubleProperty
&
center
()
override
{
return
median
();
}
const
DoubleProperty
&
center
()
const
override
{
return
median
();
}
void
setCenter
(
double
v
)
override
{
m_median
.
setDVal
(
v
);
}
DoubleProperty
&
scaleParameter
()
{
return
m_scale_parameter
;
}
const
DoubleProperty
&
scaleParameter
()
const
{
return
m_scale_parameter
;
}
...
...
This diff is collapsed.
Click to expand it.
GUI/View/Device/DistributionSelector.cpp
+
7
−
3
View file @
12a6e852
...
...
@@ -33,13 +33,17 @@ DistributionSelector::DistributionSelector(std::optional<MeanConfig> mean_config
m_form_layout
=
new
QFormLayout
(
this
);
m_form_layout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
m_distribution_combo
=
GUI
::
Util
::
createComboBoxFromPolyPtr
(
item
->
distributionSelection
(),
[
this
](
int
)
{
m_distribution_combo
=
GUI
::
Util
::
createGeneralComboBoxFromPolyPtr
(
m_item
->
distributionSelection
(),
[
this
](
int
index
)
{
double
old_center
=
m_item
->
distributionItem
()
->
center
().
dVal
();
m_item
->
distributionSelection
().
setCertainIndex
(
index
);
m_item
->
distributionItem
()
->
setCenter
(
old_center
);
createDistributionWidgets
();
emit
distributionChanged
();
},
true
);
m_distribution_combo
->
setEnabled
(
allow_distr
);
m_form_layout
->
addRow
(
"Distribution:"
,
m_distribution_combo
);
...
...
This diff is collapsed.
Click to expand it.
GUI/View/Numeric/ComboUtil.h
+
22
−
10
View file @
12a6e852
...
...
@@ -43,12 +43,9 @@ QComboBox* createComboBox(std::function<ComboProperty()> comboFunction,
//! Furthermore, the combo box can prohibit accidental changes by the mouse wheel. Otherwise it
//! would be dangerous if the combo is on a scrollable form - unintended and unnoticed changes would
//! take place when just scrolling through the form.
//!
//! Changes in the combobox will be notified to the PolyItem already. The additional (and
//! optional) slot can be used to be notified about an already executed change.
template
<
typename
B
,
typename
C
>
QComboBox
*
createComboBoxFromPolyPtr
(
PolyPtr
<
B
,
C
>&
d
,
std
::
function
<
void
(
int
)
>
slot
,
bool
inScrollArea
)
QComboBox
*
create
General
ComboBoxFromPolyPtr
(
PolyPtr
<
B
,
C
>&
d
,
std
::
function
<
void
(
int
)
>
full_
slot
,
bool
inScrollArea
)
{
auto
*
combo
=
new
QComboBox
;
combo
->
addItems
(
d
.
menuEntries
());
...
...
@@ -59,15 +56,30 @@ QComboBox* createComboBoxFromPolyPtr(PolyPtr<B, C>& d, std::function<void(int)>
if
(
inScrollArea
)
WheelEventEater
::
install
(
combo
);
QObject
::
connect
(
combo
,
&
QComboBox
::
currentIndexChanged
,
[
&
d
,
slot
](
int
index
)
{
d
.
setCertainIndex
(
index
);
if
(
slot
)
slot
(
index
);
QObject
::
connect
(
combo
,
&
QComboBox
::
currentIndexChanged
,
[
full_slot
](
int
index
)
{
if
(
full_slot
)
full_slot
(
index
);
});
return
combo
;
}
//! Create a combo box with the information found in a selection property.
//!
//! Changes in the combobox will be notified to the PolyItem already. The additional (and
//! optional) slot can be used to be notified about an already executed change.
template
<
typename
B
,
typename
C
>
QComboBox
*
createComboBoxFromPolyPtr
(
PolyPtr
<
B
,
C
>&
d
,
std
::
function
<
void
(
int
)
>
optional_slot
,
bool
inScrollArea
)
{
return
createGeneralComboBoxFromPolyPtr
(
d
,
[
&
d
,
optional_slot
](
int
index
)
{
d
.
setCertainIndex
(
index
);
if
(
optional_slot
)
optional_slot
(
index
);
},
inScrollArea
);
}
}
// namespace GUI::Util
#endif // BORNAGAIN_GUI_VIEW_NUMERIC_COMBOUTIL_H
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