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
ac0419e4
Commit
ac0419e4
authored
3 years ago
by
Matthias Puchner
Browse files
Options
Downloads
Patches
Plain Diff
harmonized & less generic UI for Minimizer properties widget
parent
a3f90b75
No related branches found
No related tags found
1 merge request
!475
Harmonized and less generic UI for minimizers
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/View/Fit/MinimizerSettingsWidget.cpp
+125
-15
125 additions, 15 deletions
GUI/View/Fit/MinimizerSettingsWidget.cpp
GUI/View/Fit/MinimizerSettingsWidget.h
+21
-5
21 additions, 5 deletions
GUI/View/Fit/MinimizerSettingsWidget.h
with
146 additions
and
20 deletions
GUI/View/Fit/MinimizerSettingsWidget.cpp
+
125
−
15
View file @
ac0419e4
...
...
@@ -16,27 +16,23 @@
#include
"GUI/Model/Fit/FitSuiteItem.h"
#include
"GUI/Model/Fit/MinimizerItem.h"
#include
"GUI/Model/Job/JobItem.h"
#include
"GUI/View/PropertyEditor/ComponentTreeView.h"
#include
"GUI/View/Edit/DoubleSpinBox.h"
#include
"GUI/View/Tool/LayoutUtils.h"
#include
<QComboBox>
#include
<QFormLayout>
#include
<QPushButton>
#include
<QVBoxLayout>
MinimizerSettingsWidget
::
MinimizerSettingsWidget
(
QWidget
*
parent
)
:
QWidget
(
parent
),
m_currentItem
(
nullptr
)
,
m_componentEditor
(
new
ComponentTreeView
)
:
QWidget
(
parent
),
m_currentItem
(
nullptr
)
{
setWindowTitle
(
QLatin1String
(
"Minimizer Settings"
));
setAttribute
(
Qt
::
WA_StyledBackground
,
true
);
setProperty
(
"stylable"
,
true
);
// for stylesheet addressing
auto
*
layout
=
new
QVBoxLayout
;
layout
->
setMargin
(
0
);
layout
->
setSpacing
(
0
);
layout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
layout
->
addWidget
(
m_componentEditor
);
setLayout
(
layout
);
}
QSize
MinimizerSettingsWidget
::
minimumSizeHint
()
const
{
return
QSize
(
25
,
25
);
m_mainLayout
=
new
QFormLayout
(
this
);
m_mainLayout
->
setContentsMargins
(
8
,
8
,
8
,
8
);
m_mainLayout
->
setSpacing
(
5
);
}
void
MinimizerSettingsWidget
::
setItem
(
JobItem
*
jobItem
)
...
...
@@ -48,6 +44,120 @@ void MinimizerSettingsWidget::setItem(JobItem* jobItem)
void
MinimizerSettingsWidget
::
setItem
(
MinimizerContainerItem
*
minimizerItem
)
{
ASSERT
(
minimizerItem
);
if
(
m_currentItem
)
m_currentItem
->
mapper
()
->
unsubscribe
(
this
);
GUI
::
Util
::
Layout
::
clearLayout
(
m_mainLayout
);
m_updaters
.
clear
();
m_currentItem
=
minimizerItem
;
m_componentEditor
->
setItem
(
minimizerItem
);
if
(
!
m_currentItem
)
return
;
auto
minimizerDescriptor
=
m_currentItem
->
minimizers
();
auto
*
minimizerCombo
=
new
QComboBox
(
this
);
minimizerCombo
->
addItems
(
minimizerDescriptor
.
options
);
minimizerCombo
->
setMaxCount
(
minimizerDescriptor
.
options
.
size
());
minimizerCombo
->
setToolTip
(
minimizerDescriptor
.
tooltip
);
connect
(
minimizerCombo
,
qOverload
<
int
>
(
&
QComboBox
::
currentIndexChanged
),
[
=
](
int
newIndex
)
{
minimizerDescriptor
.
setCurrentIndex
(
newIndex
);
createMimimizerEdits
();
});
m_updaters
<<
[
=
]()
{
QSignalBlocker
b
(
minimizerCombo
);
minimizerCombo
->
setCurrentIndex
(
minimizerDescriptor
.
currentIndex
());
};
m_mainLayout
->
addRow
(
"Minimizer:"
,
minimizerCombo
);
auto
*
w
=
new
QWidget
(
this
);
m_minimizerLayout
=
new
QFormLayout
(
w
);
m_minimizerLayout
->
setContentsMargins
(
10
,
8
,
0
,
8
);
m_mainLayout
->
addRow
(
""
,
w
);
m_mainLayout
->
addRow
(
"Objective metric:"
,
createComboBox
(
m_currentItem
->
objectiveMetric
()));
m_mainLayout
->
addRow
(
"Norm function:"
,
createComboBox
(
m_currentItem
->
normFunction
()));
createMimimizerEdits
();
updateUIValues
();
}
QWidget
*
MinimizerSettingsWidget
::
createComboBox
(
SelectionDescriptor
<
QString
>
d
)
{
auto
*
combo
=
new
QComboBox
(
this
);
combo
->
addItems
(
d
.
options
);
combo
->
setMaxCount
(
d
.
options
.
size
());
combo
->
setToolTip
(
d
.
tooltip
);
connect
(
combo
,
qOverload
<
int
>
(
&
QComboBox
::
currentIndexChanged
),
[
=
](
int
newIndex
)
{
d
.
setCurrentIndex
(
newIndex
);
});
m_updaters
<<
[
=
]()
{
QSignalBlocker
b
(
combo
);
combo
->
setCurrentIndex
(
d
.
currentIndex
());
};
return
combo
;
}
QWidget
*
MinimizerSettingsWidget
::
createDoubleSpinbox
(
DoubleDescriptor
d
)
{
auto
*
spinBox
=
new
DoubleSpinBox
(
this
,
d
);
spinBox
->
setToolTip
(
d
.
tooltip
);
QObject
::
connect
(
spinBox
,
&
DoubleSpinBox
::
baseValueChanged
,
[
=
](
double
newValue
)
{
d
.
set
(
newValue
);
});
m_updaters
<<
[
=
]()
{
spinBox
->
updateValue
();
};
return
spinBox
;
}
QWidget
*
MinimizerSettingsWidget
::
createSpinbox
(
UIntDescriptor
d
)
{
auto
*
spinBox
=
new
QSpinBox
(
this
);
spinBox
->
setToolTip
(
d
.
tooltip
);
spinBox
->
setMaximum
(
std
::
numeric_limits
<
int
>::
max
());
spinBox
->
setSizePolicy
(
QSizePolicy
::
Minimum
,
QSizePolicy
::
Fixed
);
if
(
d
.
limits
.
hasLowerLimit
())
spinBox
->
setMinimum
(
static_cast
<
int
>
(
d
.
limits
.
lowerLimit
()));
if
(
d
.
limits
.
hasUpperLimit
())
spinBox
->
setMaximum
(
static_cast
<
int
>
(
d
.
limits
.
upperLimit
()));
spinBox
->
setValue
(
d
.
get
());
QObject
::
connect
(
spinBox
,
QOverload
<
int
>::
of
(
&
QSpinBox
::
valueChanged
),
[
=
](
int
newValue
)
{
d
.
set
(
newValue
);
});
m_updaters
<<
[
=
]()
{
QSignalBlocker
b
(
spinBox
);
spinBox
->
setValue
(
d
.
get
());
};
return
spinBox
;
}
void
MinimizerSettingsWidget
::
createMimimizerEdits
()
{
GUI
::
Util
::
Layout
::
clearLayout
(
m_minimizerLayout
);
for
(
auto
v
:
m_currentItem
->
minimizers
().
currentItem
()
->
valueDescriptorsForUI
())
{
if
(
std
::
holds_alternative
<
DoubleDescriptor
>
(
v
))
{
auto
d
=
std
::
get
<
DoubleDescriptor
>
(
v
);
m_minimizerLayout
->
addRow
(
d
.
label
+
":"
,
createDoubleSpinbox
(
d
));
}
else
if
(
std
::
holds_alternative
<
SelectionDescriptor
<
QString
>>
(
v
))
{
auto
d
=
std
::
get
<
SelectionDescriptor
<
QString
>>
(
v
);
m_minimizerLayout
->
addRow
(
d
.
label
+
":"
,
createComboBox
(
d
));
}
else
if
(
std
::
holds_alternative
<
UIntDescriptor
>
(
v
))
{
auto
d
=
std
::
get
<
UIntDescriptor
>
(
v
);
m_minimizerLayout
->
addRow
(
d
.
label
+
":"
,
createSpinbox
(
d
));
}
}
}
void
MinimizerSettingsWidget
::
updateUIValues
()
{
for
(
auto
updater
:
m_updaters
)
updater
();
}
This diff is collapsed.
Click to expand it.
GUI/View/Fit/MinimizerSettingsWidget.h
+
21
−
5
View file @
ac0419e4
...
...
@@ -15,13 +15,20 @@
#ifndef BORNAGAIN_GUI_VIEW_FIT_MINIMIZERSETTINGSWIDGET_H
#define BORNAGAIN_GUI_VIEW_FIT_MINIMIZERSETTINGSWIDGET_H
#include
"GUI/Model/Group/SelectionDescriptor.h"
#include
<QList>
#include
<QWidget>
#include
<functional>
class
ComponentTreeView
;
class
JobItem
;
class
MinimizerContainerItem
;
class
DoubleDescriptor
;
class
UIntDescriptor
;
class
QFormLayout
;
//! The MinimizerSettingsWidget contains editor for all minnimizer settings and related fit
using
std
::
function
;
//! The MinimizerSettingsWidget contains editor for all minimizer settings and related fit
//! options. Part of FitSuiteWidget.
class
MinimizerSettingsWidget
:
public
QWidget
{
...
...
@@ -30,15 +37,24 @@ class MinimizerSettingsWidget : public QWidget {
public:
MinimizerSettingsWidget
(
QWidget
*
parent
=
nullptr
);
QSize
minimumSizeHint
()
const
override
;
public
slots
:
void
setItem
(
JobItem
*
jobItem
);
void
setItem
(
MinimizerContainerItem
*
minimizerItem
);
private:
QWidget
*
createComboBox
(
SelectionDescriptor
<
QString
>
d
);
QWidget
*
createDoubleSpinbox
(
DoubleDescriptor
d
);
QWidget
*
createSpinbox
(
UIntDescriptor
d
);
void
createMimimizerEdits
();
void
updateUIValues
();
private:
MinimizerContainerItem
*
m_currentItem
;
ComponentTreeView
*
m_componentEditor
;
QFormLayout
*
m_mainLayout
;
QFormLayout
*
m_minimizerLayout
;
QList
<
function
<
void
()
>>
m_updaters
;
};
#endif // BORNAGAIN_GUI_VIEW_FIT_MINIMIZERSETTINGSWIDGET_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