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
d0550e94
Commit
d0550e94
authored
7 years ago
by
Yurov, Dmitry
Browse files
Options
Downloads
Patches
Plain Diff
Moved beam and background to the InstrumentItem
Redmine: #1936
parent
d057c018
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/coregui/Models/InstrumentItems.cpp
+51
-45
51 additions, 45 deletions
GUI/coregui/Models/InstrumentItems.cpp
GUI/coregui/Models/InstrumentItems.h
+9
-7
9 additions, 7 deletions
GUI/coregui/Models/InstrumentItems.h
with
60 additions
and
52 deletions
GUI/coregui/Models/InstrumentItems.cpp
+
51
−
45
View file @
d0550e94
...
...
@@ -31,39 +31,76 @@ const QString background_group_label = "Type";
}
const
QString
InstrumentItem
::
P_IDENTIFIER
=
"Identifier"
;
const
QString
InstrumentItem
::
P_BEAM
=
"Beam"
;
const
QString
InstrumentItem
::
P_BACKGROUND
=
"Background"
;
QStringList
InstrumentItem
::
translateList
(
const
QStringList
&
list
)
const
{
QStringList
result
;
// Add constant background directly to simulation
if
(
list
.
back
().
startsWith
(
P_BACKGROUND
)
&&
list
.
size
()
==
2
)
{
result
<<
list
[
0
]
<<
QString
::
fromStdString
(
BornAgain
::
ConstantBackgroundType
);
}
else
{
// TODO Consider usage of ModelTypeTranslator in IntrusmentItem's constructor
// after the refactoring of SessionItem::translateList
result
=
SessionItem
::
translateList
(
list
);
if
(
result
.
back
()
==
Constants
::
GISASInstrumentType
)
{
result
.
removeLast
();
result
<<
QStringLiteral
(
"Instrument"
);
}
}
return
result
;
}
BeamItem
*
InstrumentItem
::
beamItem
()
const
{
return
&
item
<
BeamItem
>
(
P_BEAM
);
}
BackgroundItem
*
InstrumentItem
::
backgroundItem
()
const
{
return
&
groupItem
<
BackgroundItem
>
(
P_BACKGROUND
);
}
GroupItem
*
InstrumentItem
::
backgroundGroup
()
{
return
&
item
<
GroupItem
>
(
P_BACKGROUND
);
}
std
::
unique_ptr
<
Instrument
>
InstrumentItem
::
createInstrument
()
const
{
std
::
unique_ptr
<
Instrument
>
result
(
new
Instrument
);
auto
beam
=
beamItem
()
->
createBeam
();
result
->
setBeam
(
*
beam
);
return
result
;
}
InstrumentItem
::
InstrumentItem
(
const
QString
&
modelType
)
:
SessionItem
(
modelType
)
{
setItemName
(
modelType
);
addProperty
(
P_IDENTIFIER
,
GUIHelpers
::
createUuid
())
->
setVisible
(
false
);
addGroupProperty
(
P_BEAM
,
Constants
::
BeamType
);
auto
item
=
addGroupProperty
(
P_BACKGROUND
,
Constants
::
BackgroundGroup
);
item
->
setDisplayName
(
background_group_label
);
item
->
setToolTip
(
"Background type"
);
}
const
QString
Instrument2DItem
::
P_BEAM
=
"Beam"
;
const
QString
Instrument2DItem
::
P_DETECTOR
=
"Detector"
;
const
QString
Instrument2DItem
::
P_BACKGROUND
=
"Background"
;
Instrument2DItem
::
Instrument2DItem
(
const
QString
&
modelType
)
:
InstrumentItem
(
modelType
)
{
addGroupProperty
(
P_BEAM
,
Constants
::
BeamType
);
addGroupProperty
(
P_DETECTOR
,
Constants
::
DetectorGroup
);
setDefaultTag
(
P_DETECTOR
);
auto
item
=
addGroupProperty
(
P_BACKGROUND
,
Constants
::
BackgroundGroup
);
item
->
setDisplayName
(
background_group_label
);
item
->
setToolTip
(
"Background type"
);
}
Instrument2DItem
::~
Instrument2DItem
()
=
default
;
BeamItem
*
Instrument2DItem
::
beamItem
()
const
{
return
&
item
<
BeamItem
>
(
P_BEAM
);
}
DetectorItem
*
Instrument2DItem
::
detectorItem
()
const
{
return
&
groupItem
<
DetectorItem
>
(
P_DETECTOR
);
...
...
@@ -74,16 +111,6 @@ GroupItem* Instrument2DItem::detectorGroup()
return
&
item
<
GroupItem
>
(
P_DETECTOR
);
}
BackgroundItem
*
Instrument2DItem
::
backgroundItem
()
const
{
return
&
groupItem
<
BackgroundItem
>
(
P_BACKGROUND
);
}
GroupItem
*
Instrument2DItem
::
backgroundGroup
()
{
return
&
item
<
GroupItem
>
(
P_BACKGROUND
);
}
void
Instrument2DItem
::
setDetectorGroup
(
const
QString
&
modelType
)
{
setGroupProperty
(
P_DETECTOR
,
modelType
);
...
...
@@ -99,30 +126,9 @@ void Instrument2DItem::importMasks(MaskContainerItem* maskContainer)
detectorItem
()
->
importMasks
(
maskContainer
);
}
QStringList
Instrument2DItem
::
translateList
(
const
QStringList
&
list
)
const
{
QStringList
result
;
// Add constant background directly to simulation
if
(
list
.
back
().
startsWith
(
P_BACKGROUND
)
&&
list
.
size
()
==
2
)
{
result
<<
list
[
0
]
<<
QString
::
fromStdString
(
BornAgain
::
ConstantBackgroundType
);
}
else
{
// TODO Consider usage of ModelTypeTranslator in IntrusmentItem's constructor
// after the refactoring of SessionItem::translateList
result
=
SessionItem
::
translateList
(
list
);
if
(
result
.
back
()
==
Constants
::
GISASInstrumentType
)
{
result
.
removeLast
();
result
<<
QStringLiteral
(
"Instrument"
);
}
}
return
result
;
}
std
::
unique_ptr
<
Instrument
>
Instrument2DItem
::
createInstrument
()
const
{
std
::
unique_ptr
<
Instrument
>
result
(
new
Instrument
);
auto
beam
=
beamItem
()
->
createBeam
();
result
->
setBeam
(
*
beam
);
auto
result
=
InstrumentItem
::
createInstrument
();
auto
detector
=
detectorItem
()
->
createDetector
();
result
->
setDetector
(
*
detector
);
...
...
This diff is collapsed.
Click to expand it.
GUI/coregui/Models/InstrumentItems.h
+
9
−
7
View file @
d0550e94
...
...
@@ -28,8 +28,17 @@ class BA_CORE_API_ InstrumentItem : public SessionItem
{
public:
static
const
QString
P_IDENTIFIER
;
static
const
QString
P_BEAM
;
static
const
QString
P_BACKGROUND
;
QStringList
translateList
(
const
QStringList
&
list
)
const
override
;
BeamItem
*
beamItem
()
const
;
BackgroundItem
*
backgroundItem
()
const
;
GroupItem
*
backgroundGroup
();
virtual
std
::
unique_ptr
<
Instrument
>
createInstrument
()
const
=
0
;
protected:
explicit
InstrumentItem
(
const
QString
&
modelType
);
};
...
...
@@ -39,15 +48,10 @@ class BA_CORE_API_ Instrument2DItem : public InstrumentItem
public:
virtual
~
Instrument2DItem
();
static
const
QString
P_BEAM
;
static
const
QString
P_DETECTOR
;
static
const
QString
P_BACKGROUND
;
BeamItem
*
beamItem
()
const
;
DetectorItem
*
detectorItem
()
const
;
GroupItem
*
detectorGroup
();
BackgroundItem
*
backgroundItem
()
const
;
GroupItem
*
backgroundGroup
();
void
setDetectorGroup
(
const
QString
&
modelType
);
...
...
@@ -55,8 +59,6 @@ public:
void
importMasks
(
MaskContainerItem
*
maskContainer
);
QStringList
translateList
(
const
QStringList
&
list
)
const
override
;
std
::
unique_ptr
<
Instrument
>
createInstrument
()
const
override
;
protected:
...
...
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