Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
390052c2
Commit
390052c2
authored
6 years ago
by
Brandon Hewer
Browse files
Options
Downloads
Patches
Plain Diff
Ensure the grouping string is constructed correctly
Refs #22988
parent
36a60ddf
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
qt/scientific_interfaces/Indirect/ISISEnergyTransfer.cpp
+49
-20
49 additions, 20 deletions
qt/scientific_interfaces/Indirect/ISISEnergyTransfer.cpp
qt/scientific_interfaces/Indirect/ISISEnergyTransfer.h
+1
-1
1 addition, 1 deletion
qt/scientific_interfaces/Indirect/ISISEnergyTransfer.h
with
50 additions
and
21 deletions
qt/scientific_interfaces/Indirect/ISISEnergyTransfer.cpp
+
49
−
20
View file @
390052c2
#include
"ISISEnergyTransfer.h"
#include
"ISISEnergyTransfer.h"
#include
"../General/UserInputValidator.h"
#include
"MantidAPI/MatrixWorkspace.h"
#include
"MantidAPI/MatrixWorkspace.h"
#include
"MantidAPI/WorkspaceGroup.h"
#include
"MantidAPI/WorkspaceGroup.h"
#include
"../General/UserInputValidator.h"
#include
<QFileInfo>
#include
<QFileInfo>
using
namespace
Mantid
::
API
;
using
namespace
Mantid
::
API
;
using
MantidQt
::
API
::
BatchAlgorithmRunner
;
using
MantidQt
::
API
::
BatchAlgorithmRunner
;
namespace
{
std
::
string
createRangeString
(
std
::
size_t
from
,
std
::
size_t
to
)
{
return
std
::
to_string
(
from
)
+
"-"
+
std
::
to_string
(
to
);
}
std
::
string
createGroupString
(
std
::
size_t
start
,
std
::
size_t
size
)
{
return
createRangeString
(
start
,
start
+
size
-
1
);
}
std
::
string
createGroupingString
(
std
::
size_t
groupSize
,
std
::
size_t
numberOfGroups
)
{
auto
groupingString
=
createRangeString
(
0
,
groupSize
-
1
);
for
(
auto
i
=
groupSize
;
i
<
groupSize
*
numberOfGroups
;
i
+=
groupSize
)
groupingString
+=
","
+
createGroupString
(
i
,
groupSize
);
return
groupingString
;
}
std
::
string
createDetectorGroupingString
(
std
::
size_t
groupSize
,
std
::
size_t
numberOfGroups
,
std
::
size_t
numberOfDetectors
)
{
const
auto
groupingString
=
createGroupingString
(
groupSize
,
numberOfGroups
);
const
auto
remainder
=
numberOfDetectors
%
numberOfGroups
;
if
(
remainder
==
0
)
return
groupingString
;
return
groupingString
+
","
+
createRangeString
(
numberOfDetectors
-
remainder
,
numberOfDetectors
-
1
);
}
std
::
string
createDetectorGroupingString
(
std
::
size_t
numberOfDetectors
,
std
::
size_t
numberOfGroups
)
{
const
auto
groupSize
=
numberOfDetectors
/
numberOfGroups
;
if
(
groupSize
==
0
)
return
createRangeString
(
0
,
numberOfDetectors
);
return
createDetectorGroupingString
(
groupSize
,
numberOfGroups
,
numberOfDetectors
);
}
}
// namespace
namespace
MantidQt
{
namespace
MantidQt
{
namespace
CustomInterfaces
{
namespace
CustomInterfaces
{
//----------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------
...
@@ -457,7 +498,7 @@ ISISEnergyTransfer::createMapFile(const std::string &groupType) {
...
@@ -457,7 +498,7 @@ ISISEnergyTransfer::createMapFile(const std::string &groupType) {
return
std
::
make_pair
(
"File"
,
groupFile
.
toStdString
());
return
std
::
make_pair
(
"File"
,
groupFile
.
toStdString
());
}
else
if
(
groupType
==
"Groups"
)
}
else
if
(
groupType
==
"Groups"
)
return
std
::
make_pair
(
"Custom"
,
create
DetectorGroupingString
());
return
std
::
make_pair
(
"Custom"
,
get
DetectorGroupingString
());
else
if
(
groupType
==
"Default"
)
else
if
(
groupType
==
"Default"
)
return
std
::
make_pair
(
"IPF"
,
""
);
return
std
::
make_pair
(
"IPF"
,
""
);
else
if
(
groupType
==
"Custom"
)
else
if
(
groupType
==
"Custom"
)
...
@@ -469,25 +510,12 @@ ISISEnergyTransfer::createMapFile(const std::string &groupType) {
...
@@ -469,25 +510,12 @@ ISISEnergyTransfer::createMapFile(const std::string &groupType) {
}
}
}
}
const
std
::
string
ISISEnergyTransfer
::
createDetectorGroupingString
()
{
std
::
string
ISISEnergyTransfer
::
getDetectorGroupingString
()
const
{
const
unsigned
int
nGroups
=
m_uiForm
.
spNumberGroups
->
value
();
const
unsigned
int
nGroups
=
m_uiForm
.
spNumberGroups
->
value
();
const
unsigned
int
nSpectra
=
const
unsigned
int
nSpectra
=
m_uiForm
.
spSpectraMax
->
value
()
-
m_uiForm
.
spSpectraMin
->
value
();
1
+
m_uiForm
.
spSpectraMax
->
value
()
-
m_uiForm
.
spSpectraMin
->
value
();
const
unsigned
int
groupSize
=
nSpectra
/
nGroups
;
return
createDetectorGroupingString
(
static_cast
<
std
::
size_t
>
(
nSpectra
),
auto
n
=
groupSize
;
static_cast
<
std
::
size_t
>
(
nGroups
));
std
::
stringstream
groupingString
;
groupingString
<<
"0-"
<<
std
::
to_string
(
n
);
for
(
auto
i
=
1u
;
i
<
nGroups
;
++
i
)
{
groupingString
<<
", "
<<
std
::
to_string
(
n
+
1
)
<<
"-"
;
n
+=
groupSize
;
groupingString
<<
std
::
to_string
(
n
);
}
if
(
n
!=
nSpectra
)
// add remainder as extra group
groupingString
<<
", "
<<
std
::
to_string
(
n
+
1
)
<<
"-"
<<
std
::
to_string
(
nSpectra
);
return
groupingString
.
str
();
}
}
/**
/**
...
@@ -575,6 +603,7 @@ void ISISEnergyTransfer::plotRaw() {
...
@@ -575,6 +603,7 @@ void ISISEnergyTransfer::plotRaw() {
if
(
m_uiForm
.
ckBackgroundRemoval
->
isChecked
())
{
if
(
m_uiForm
.
ckBackgroundRemoval
->
isChecked
())
{
MatrixWorkspace_sptr
tempWs
=
MatrixWorkspace_sptr
tempWs
=
AnalysisDataService
::
Instance
().
retrieveWS
<
MatrixWorkspace
>
(
name
);
AnalysisDataService
::
Instance
().
retrieveWS
<
MatrixWorkspace
>
(
name
);
const
double
minBack
=
tempWs
->
x
(
0
)[
0
];
const
double
minBack
=
tempWs
->
x
(
0
)[
0
];
const
double
maxBack
=
tempWs
->
x
(
0
)[
tempWs
->
blocksize
()];
const
double
maxBack
=
tempWs
->
x
(
0
)[
tempWs
->
blocksize
()];
...
@@ -744,4 +773,4 @@ void ISISEnergyTransfer::saveClicked() {
...
@@ -744,4 +773,4 @@ void ISISEnergyTransfer::saveClicked() {
}
}
}
// namespace CustomInterfaces
}
// namespace CustomInterfaces
}
// namespace Mantid
}
// namespace Mantid
Qt
This diff is collapsed.
Click to expand it.
qt/scientific_interfaces/Indirect/ISISEnergyTransfer.h
+
1
−
1
View file @
390052c2
...
@@ -76,7 +76,7 @@ private:
...
@@ -76,7 +76,7 @@ private:
std
::
vector
<
std
::
string
>
std
::
vector
<
std
::
string
>
m_outputWorkspaces
;
///< get a vector of workspaces to plot
m_outputWorkspaces
;
///< get a vector of workspaces to plot
QString
validateDetectorGrouping
();
QString
validateDetectorGrouping
();
const
std
::
string
create
DetectorGroupingString
();
std
::
string
get
DetectorGroupingString
()
const
;
};
};
}
// namespace CustomInterfaces
}
// namespace CustomInterfaces
}
// namespace Mantid
}
// namespace Mantid
...
...
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