Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
ed47bb2f
Commit
ed47bb2f
authored
Aug 29, 2016
by
Jan Burle
Browse files
fetched upstream
parent
b88cdccb
Changes
992
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
ed47bb2f
...
...
@@ -13,6 +13,8 @@ set ( SYSTEM_PACKAGE_TARGET "")
# Add the path to our custom 'find' modules
set
(
CMAKE_MODULE_PATH
"
${
CMAKE_SOURCE_DIR
}
/buildconfig/CMake"
)
set
(
ENABLE_MANTIDPLOT ON CACHE BOOL
"Switch for compiling the gui components"
)
SET
(
CPACK_INSTALL_CMAKE_PROJECTS
"
${
CMAKE_BINARY_DIR
}
"
"Mantid"
"ALL"
"/"
)
...
...
@@ -52,7 +54,9 @@ include ( CommonSetup )
###########################################################################
# Check for Qt (DarwinSetup below needs a variable from this)
###########################################################################
find_package
(
Qt4 COMPONENTS QtCore QtGui QtOpenGL QtXml QtSvg REQUIRED
)
if
(
ENABLE_MANTIDPLOT
)
find_package
(
Qt4 COMPONENTS QtCore QtGui QtOpenGL QtXml QtSvg REQUIRED
)
endif
()
###########################################################################
# Find OpenGL
...
...
@@ -66,7 +70,9 @@ endif ()
###########################################################################
# Set ParaView information since later items depend on it
###########################################################################
include
(
ParaViewSetup
)
if
(
ENABLE_MANTIDPLOT
)
include
(
ParaViewSetup
)
endif
()
# We probably don't want this to run on every build.
option
(
COVERALLS
"Generate coveralls data"
OFF
)
...
...
@@ -79,18 +85,22 @@ endif()
###########################################################################
# Find qwt. Needs to be version 5
###########################################################################
find_package
(
Qwt REQUIRED
)
if
(
QWT_VERSION VERSION_LESS 5.0 OR QWT_VERSION VERSION_EQUAL 6.0 OR
QWT_VERSION VERSION_GREATER 6.0
)
message
(
FATAL_ERROR
"Qwt version 5 is required, found:
${
QWT_VERSION
}
"
)
if
(
ENABLE_MANTIDPLOT
)
find_package
(
Qwt REQUIRED
)
if
(
QWT_VERSION VERSION_LESS 5.0 OR QWT_VERSION VERSION_EQUAL 6.0 OR
QWT_VERSION VERSION_GREATER 6.0
)
message
(
FATAL_ERROR
"Qwt version 5 is required, found:
${
QWT_VERSION
}
"
)
endif
()
endif
()
###########################################################################
# Find PyQt & sip
###########################################################################
find_package
(
PyQt4 REQUIRED
)
find_package
(
SIP REQUIRED
)
separate_arguments
(
PYQT4_SIP_FLAGS
)
if
(
ENABLE_MANTIDPLOT
)
find_package
(
PyQt4 REQUIRED
)
find_package
(
SIP REQUIRED
)
separate_arguments
(
PYQT4_SIP_FLAGS
)
endif
()
###########################################################################
# gsl is currently needed by Geometry, Algorithms, Curvefitting, & MantidPlot
...
...
@@ -100,7 +110,9 @@ find_package ( GSL REQUIRED )
###########################################################################
# Add QtPropertyBrowser to build
###########################################################################
add_subdirectory
(
QtPropertyBrowser
)
if
(
ENABLE_MANTIDPLOT
)
add_subdirectory
(
QtPropertyBrowser
)
endif
(
ENABLE_MANTIDPLOT
)
###########################################################################
# Now add in all the components
...
...
@@ -118,7 +130,7 @@ set ( CXXTEST_ADD_PERFORMANCE OFF CACHE BOOL "Switch to add Performance tests to
# VATES flag. Requires ParaView
set
(
MAKE_VATES OFF CACHE BOOL
"Switch for compiling the Vates project"
)
if
(
MAKE_VATES
)
if
(
ENABLE_MANTIDPLOT AND
MAKE_VATES
)
find_package
(
ParaView
)
if
(
ParaView_FOUND
)
add_definitions
(
-DMAKE_VATES
)
...
...
@@ -134,20 +146,22 @@ include_directories ( Framework/API/inc )
set
(
CORE_MANTIDLIBS Kernel HistogramData Geometry API
)
# Add a target for all GUI tests
add_custom_target
(
GUITests
)
add_dependencies
(
GUITests MantidWidgetsTest
)
add_dependencies
(
check GUITests
)
# Collect all tests together
add_custom_target
(
AllTests
)
add_dependencies
(
AllTests FrameworkTests GUITests
)
if
(
ENABLE_MANTIDPLOT
)
# Add a target for all GUI tests
add_custom_target
(
GUITests
)
add_dependencies
(
GUITests MantidWidgetsTest
)
add_dependencies
(
check GUITests
)
# Collect all tests together
add_custom_target
(
AllTests
)
add_dependencies
(
AllTests FrameworkTests GUITests
)
endif
()
if
(
UNIX
)
#Experimental feature. Unix only at this point.
set
(
UNITY_BUILD OFF CACHE BOOL
"Switch for utilising unity builds. Faster builds for selected components."
)
endif
(
UNIX
)
if
(
MAKE_VATES
)
if
(
ENABLE_MANTIDPLOT AND
MAKE_VATES
)
add_subdirectory
(
Vates
)
if
(
NOT APPLE
)
LIST
(
APPEND CPACK_INSTALL_CMAKE_PROJECTS
...
...
@@ -164,18 +178,23 @@ if ( MAKE_VATES )
)
endif
()
endif
(
MAKE_VATES
)
endif
(
ENABLE_MANTIDPLOT AND
MAKE_VATES
)
if
(
MSVC
)
add_definitions
(
-DQWT_DLL
)
endif
()
add_subdirectory
(
MantidQt
)
add_subdirectory
(
MantidPlot
)
if
(
ENABLE_MANTIDPLOT
)
add_subdirectory
(
MantidQt
)
add_subdirectory
(
MantidPlot
)
endif
()
add_subdirectory
(
scripts
)
add_subdirectory
(
docs
)
if
(
ENABLE_MANTIDPLOT
)
add_subdirectory
(
docs
)
endif
()
# System test data target
add_subdirectory
(
Testing/SystemTests/scripts
)
...
...
@@ -205,7 +224,7 @@ endif ()
install
(
DIRECTORY installers/colormaps/ DESTINATION
${
INBUNDLE
}
colormaps
)
# Install the files (.desktop and icon) to create a menu item, but only if installing to /opt/Mantid
if
(
${
CMAKE_SYSTEM_NAME
}
STREQUAL
"Linux"
AND CMAKE_INSTALL_PREFIX STREQUAL
"/opt/Mantid"
)
if
(
ENABLE_MANTIDPLOT AND
${
CMAKE_SYSTEM_NAME
}
STREQUAL
"Linux"
AND CMAKE_INSTALL_PREFIX STREQUAL
"/opt/Mantid"
)
install
(
FILES
${
CMAKE_CURRENT_SOURCE_DIR
}
/installers/LinuxInstaller/mantidplot.desktop
DESTINATION /usr/share/applications
)
install
(
FILES
${
CMAKE_CURRENT_SOURCE_DIR
}
/images/MantidPlot_Icon_32offset.png
...
...
@@ -217,6 +236,13 @@ endif()
# for an explanation
add_subdirectory
(
Framework/PostInstall
)
# Conda
set
(
ENABLE_CONDA CACHE BOOL
"Switch to enable conda package generation"
)
if
(
ENABLE_CONDA
)
include
(
conda
)
endif
(
ENABLE_CONDA
)
###########################################################################
# CPack settings
###########################################################################
...
...
@@ -237,7 +263,7 @@ if ( ENABLE_CPACK )
message
(
STATUS
" CPACK_PACKAGE_FILE_NAME =
${
CPACK_PACKAGE_FILE_NAME
}
"
)
# rhel requirements
set
(
CPACK_RPM_PACKAGE_REQUIRES
"qt4 >= 4.2,nexus >= 4.3.1,nexus-python >= 4.3.1,gsl,glibc,qwtplot3d-qt4,muParser,numpy,h5py >= 2.3.1,PyCifRW >= 4.2.1"
)
set
(
CPACK_RPM_PACKAGE_REQUIRES
"qt4 >= 4.2,nexus >= 4.3.1,nexus-python >= 4.3.1,gsl,glibc,qwtplot3d-qt4,muParser,numpy,h5py >= 2.3.1,PyCifRW >= 4.2.1
,tbb
"
)
# OCE
set
(
CPACK_RPM_PACKAGE_REQUIRES
"
${
CPACK_RPM_PACKAGE_REQUIRES
}
,OCE-draw,OCE-foundation,OCE-modeling,OCE-ocaf,OCE-visualization"
)
set
(
CPACK_RPM_PACKAGE_REQUIRES
"
${
CPACK_RPM_PACKAGE_REQUIRES
}
,poco-crypto,poco-data,poco-mysql,poco-sqlite,poco-odbc,poco-util,poco-xml,poco-zip,poco-net,poco-netssl,poco-foundation,PyQt4,sip"
)
...
...
@@ -290,6 +316,7 @@ if ( ENABLE_CPACK )
"ipython-notebook,"
"python-matplotlib,"
"python-scipy,"
"libtbb2,"
"libpocofoundation11,libpocoutil11,libpoconet11,libpoconetssl11,libpococrypto11,libpocoxml11,"
"python-pycifrw (>= 4.2.1)"
)
set
(
PERFTOOLS_DEB_PACKAGE
"libgoogle-perftools4 (>= 1.7)"
)
...
...
Framework/API/inc/MantidAPI/Column.h
View file @
ed47bb2f
...
...
@@ -157,13 +157,16 @@ public:
/**
* Fills a std vector with values from the column if the types are compatible.
* @param
vec :: The vector to
f
i
ll
i
n.
* @param
maxSize :: Set size to less than the
f
u
ll
colum
n.
*/
template
<
class
T
>
void
numeric_fill
(
std
::
vector
<
T
>
&
vec
)
const
{
vec
.
resize
(
size
());
template
<
class
T
=
double
>
std
::
vector
<
T
>
numeric_fill
(
size_t
maxSize
=
std
::
numeric_limits
<
size_t
>::
max
())
const
{
std
::
vector
<
T
>
vec
(
std
::
min
(
size
(),
maxSize
));
for
(
size_t
i
=
0
;
i
<
vec
.
size
();
++
i
)
{
vec
[
i
]
=
static_cast
<
T
>
(
toDouble
(
i
));
}
return
vec
;
}
protected:
...
...
Framework/API/inc/MantidAPI/IMDWorkspace.h
View file @
ed47bb2f
...
...
@@ -163,6 +163,9 @@ public:
// Preferred normalization to use for displaying histo workspaces
virtual
MDNormalization
displayNormalizationHisto
()
const
;
// Check if this class is an instance of MDHistoWorkspace
virtual
bool
isMDHistoWorkspace
()
const
{
return
false
;
}
protected:
/// Protected copy constructor. May be used by childs for cloning.
IMDWorkspace
(
const
IMDWorkspace
&
)
=
default
;
...
...
Framework/API/inc/MantidAPI/IPeaksWorkspace.h
View file @
ed47bb2f
...
...
@@ -110,7 +110,7 @@ public:
* @return a pointer to a new Peak object.
*/
virtual
Mantid
::
Geometry
::
IPeak
*
createPeak
(
Mantid
::
Kernel
::
V3D
QLabFrame
,
createPeak
(
const
Mantid
::
Kernel
::
V3D
&
QLabFrame
,
boost
::
optional
<
double
>
detectorDistance
)
const
=
0
;
/**
...
...
@@ -119,7 +119,7 @@ public:
* @return a pointer to a new Peak object.
*/
virtual
Mantid
::
Geometry
::
IPeak
*
createPeakHKL
(
Mantid
::
Kernel
::
V3D
HKL
)
const
=
0
;
createPeakHKL
(
const
Mantid
::
Kernel
::
V3D
&
HKL
)
const
=
0
;
//---------------------------------------------------------------------------------------------
/** Determine if the workspace has been integrated using a peaks integration
...
...
@@ -154,8 +154,9 @@ public:
getSpecialCoordinateSystem
()
const
=
0
;
virtual
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
peakInfo
(
Kernel
::
V3D
QFrame
,
bool
labCoords
)
const
=
0
;
virtual
int
peakInfoNumber
(
Kernel
::
V3D
qLabFrame
,
bool
labCoords
)
const
=
0
;
peakInfo
(
const
Kernel
::
V3D
&
QFrame
,
bool
labCoords
)
const
=
0
;
virtual
int
peakInfoNumber
(
const
Kernel
::
V3D
&
qLabFrame
,
bool
labCoords
)
const
=
0
;
std
::
string
convention
;
...
...
Framework/API/inc/MantidAPI/ISpectrum.h
View file @
ed47bb2f
...
...
@@ -47,7 +47,7 @@ namespace API {
*/
class
DLLExport
ISpectrum
{
public:
ISpectrum
();
ISpectrum
()
=
default
;
ISpectrum
(
const
specnum_t
specNo
);
virtual
~
ISpectrum
()
=
default
;
...
...
@@ -105,10 +105,25 @@ public:
HistogramData
::
Histogram
histogram
(
std
::
forward
<
T
>
(
data
)...);
// Check for the special case EventList, it only accepts histograms without
// Y and E data.
checkHistogram
(
histogram
);
check
AndSanitize
Histogram
(
histogram
);
mutableHistogramRef
()
=
std
::
move
(
histogram
);
}
HistogramData
::
Histogram
::
YMode
yMode
()
const
{
return
histogramRef
().
yMode
();
}
void
setYMode
(
HistogramData
::
Histogram
::
YMode
ymode
)
{
mutableHistogramRef
().
setYMode
(
ymode
);
}
void
convertToCounts
()
{
checkIsYAndEWritable
();
mutableHistogramRef
().
convertToCounts
();
}
void
convertToFrequencies
()
{
checkIsYAndEWritable
();
mutableHistogramRef
().
convertToFrequencies
();
}
HistogramData
::
BinEdges
binEdges
()
const
{
return
histogramRef
().
binEdges
();
}
HistogramData
::
BinEdgeStandardDeviations
binEdgeStandardDeviations
()
const
{
return
histogramRef
().
binEdgeStandardDeviations
();
...
...
@@ -236,7 +251,7 @@ public:
}
protected:
virtual
void
checkHistogram
(
const
HistogramData
::
Histogram
&
)
const
{}
virtual
void
check
AndSanitize
Histogram
(
HistogramData
::
Histogram
&
)
{}
virtual
void
checkWorksWithPoints
()
const
{}
virtual
void
checkIsYAndEWritable
()
const
{}
...
...
@@ -247,15 +262,15 @@ protected:
ISpectrum
&
operator
=
(
const
ISpectrum
&
)
=
default
;
ISpectrum
&
operator
=
(
ISpectrum
&&
)
=
default
;
private:
virtual
const
HistogramData
::
Histogram
&
histogramRef
()
const
=
0
;
virtual
HistogramData
::
Histogram
&
mutableHistogramRef
()
=
0
;
/// The spectrum number of this spectrum
specnum_t
m_specNo
;
specnum_t
m_specNo
{
0
}
;
/// Set of the detector IDs associated with this spectrum
std
::
set
<
detid_t
>
detectorIDs
;
private:
virtual
const
HistogramData
::
Histogram
&
histogramRef
()
const
=
0
;
virtual
HistogramData
::
Histogram
&
mutableHistogramRef
()
=
0
;
};
}
// namespace API
...
...
Framework/API/inc/MantidAPI/MatrixWorkspace.h
View file @
ed47bb2f
...
...
@@ -187,6 +187,12 @@ public:
void
setHistogram
(
const
size_t
index
,
T
&&
...
data
)
&
{
getSpectrum
(
index
).
setHistogram
(
std
::
forward
<
T
>
(
data
)...);
}
void
convertToCounts
(
const
size_t
index
)
{
getSpectrum
(
index
).
convertToCounts
();
}
void
convertToFrequencies
(
const
size_t
index
)
{
getSpectrum
(
index
).
convertToFrequencies
();
}
HistogramData
::
BinEdges
binEdges
(
const
size_t
index
)
const
{
return
getSpectrum
(
index
).
binEdges
();
}
...
...
@@ -451,7 +457,7 @@ public:
void
setYUnitLabel
(
const
std
::
string
&
newLabel
);
/// Are the Y-values dimensioned?
const
bool
&
isDistribution
()
const
;
bool
isDistribution
()
const
;
void
setDistribution
(
bool
newValue
);
/// Mask a given workspace index, setting the data and error values to zero
...
...
@@ -599,8 +605,6 @@ private:
std
::
string
m_YUnit
;
/// A text label for use when plotting spectra
std
::
string
m_YUnitLabel
;
/// Flag indicating whether the Y-values are dimensioned. False by default
bool
m_isDistribution
;
/// Flag indicating whether the m_isCommonBinsFlag has been set. False by
/// default
...
...
Framework/API/inc/MantidAPI/MultipleFileProperty.h
View file @
ed47bb2f
...
...
@@ -145,11 +145,6 @@ public:
using
Kernel
::
PropertyWithValue
<
std
::
vector
<
std
::
vector
<
std
::
string
>>>::
operator
=
;
/// Return a "flattened" vector with the contents of the given vector of
/// vectors.
static
std
::
vector
<
std
::
string
>
flattenFileNames
(
const
std
::
vector
<
std
::
vector
<
std
::
string
>>
&
fileNames
);
private:
std
::
string
setValueAsSingleFile
(
const
std
::
string
&
propValue
);
std
::
string
setValueAsMultipleFiles
(
const
std
::
string
&
propValue
);
...
...
Framework/API/inc/MantidAPI/Sample.h
View file @
ed47bb2f
...
...
@@ -76,7 +76,7 @@ public:
/** @name Material properties.*/
//@{
/// Return the material (convenience method)
const
Kernel
::
Material
&
getMaterial
()
const
;
const
Kernel
::
Material
getMaterial
()
const
;
//@}
/** @name Access the environment information */
...
...
Framework/API/inc/MantidAPI/WorkspaceProperty.h
View file @
ed47bb2f
...
...
@@ -322,25 +322,24 @@ public:
if
(
this
->
direction
()
==
Kernel
::
Direction
::
Input
||
this
->
direction
()
==
Kernel
::
Direction
::
InOut
)
{
// If an input workspace, get the list of workspaces currently in the ADS
auto
vals
=
AnalysisDataService
::
Instance
().
getObjectNames
();
auto
vals
=
AnalysisDataService
::
Instance
().
getObjectNames
(
Mantid
::
Kernel
::
DataServiceSort
::
Sorted
);
if
(
isOptional
())
// Insert an empty option
{
vals
.
insert
(
""
);
vals
.
push_back
(
""
);
}
// Copy-construct a temporary workspace property to test the validity of
// each workspace
WorkspaceProperty
<
TYPE
>
tester
(
*
this
);
for
(
auto
it
=
vals
.
begin
();
it
!=
vals
.
end
();)
{
// Remove any workspace that's not valid for this algorithm
if
(
!
tester
.
setValue
(
*
it
).
empty
())
{
vals
.
erase
(
it
++
);
// Post-fix so that it erase the previous when returned
}
else
++
it
;
}
auto
values
=
std
::
vector
<
std
::
string
>
(
vals
.
begin
(),
vals
.
end
());
std
::
sort
(
values
.
begin
(),
values
.
end
());
return
values
;
// Remove any workspace that's not valid for this algorithm
auto
eraseIter
=
remove_if
(
vals
.
begin
(),
vals
.
end
(),
[
&
tester
](
const
std
::
string
&
wsName
)
{
return
!
tester
.
setValue
(
wsName
).
empty
();
});
// Erase everything past returned iterator afterwards for readability
vals
.
erase
(
eraseIter
,
vals
.
end
());
return
vals
;
}
else
{
// For output workspaces, just return an empty set
return
std
::
vector
<
std
::
string
>
();
...
...
Framework/API/src/ADSValidator.cpp
View file @
ed47bb2f
...
...
@@ -62,14 +62,13 @@ ADSValidator::checkValidity(const std::vector<std::string> &value) const {
*/
std
::
vector
<
std
::
string
>
ADSValidator
::
allowedValues
()
const
{
// Get the list of workspaces currently in the ADS
auto
vals
=
AnalysisDataService
::
Instance
().
getObjectNames
();
auto
vals
=
AnalysisDataService
::
Instance
().
getObjectNames
(
Mantid
::
Kernel
::
DataServiceSort
::
Sorted
);
if
(
isOptional
())
// Insert an empty option
{
vals
.
insert
(
""
);
vals
.
push_back
(
""
);
}
auto
values
=
std
::
vector
<
std
::
string
>
(
vals
.
begin
(),
vals
.
end
());
std
::
sort
(
values
.
begin
(),
values
.
end
());
return
values
;
return
vals
;
}
}
// namespace API
...
...
Framework/API/src/AlgorithmManager.cpp
View file @
ed47bb2f
...
...
@@ -116,11 +116,17 @@ IAlgorithm_sptr AlgorithmManagerImpl::create(const std::string &algName,
}
/**
* Clears all managed algorithm objects.
* Clears all managed algorithm objects
that are not currently running
.
*/
void
AlgorithmManagerImpl
::
clear
()
{
std
::
lock_guard
<
std
::
mutex
>
_lock
(
this
->
m_managedMutex
);
m_managed_algs
.
clear
();
for
(
auto
itAlg
=
m_managed_algs
.
begin
();
itAlg
!=
m_managed_algs
.
end
();)
{
if
(
!
(
*
itAlg
)
->
isRunning
())
{
itAlg
=
m_managed_algs
.
erase
(
itAlg
);
}
else
{
++
itAlg
;
}
}
}
std
::
size_t
AlgorithmManagerImpl
::
size
()
const
{
return
m_managed_algs
.
size
();
}
...
...
Framework/API/src/FileFinder.cpp
View file @
ed47bb2f
...
...
@@ -125,6 +125,7 @@ std::string FileFinderImpl::getFullPath(const std::string &filename,
const
std
::
vector
<
std
::
string
>
&
searchPaths
=
Kernel
::
ConfigService
::
Instance
().
getDataSearchDirs
();
for
(
const
auto
&
searchPath
:
searchPaths
)
{
g_log
.
debug
()
<<
"Searching for "
<<
fName
<<
" in "
<<
searchPath
<<
"
\n
"
;
// On windows globbing is note working properly with network drives
// for example a network drive containing a $
// For this reason, and since windows is case insensitive anyway
...
...
@@ -491,7 +492,9 @@ FileFinderImpl::findRun(const std::string &hintstr,
filename
=
hint
.
substr
(
0
,
hint
.
rfind
(
extension
));
if
(
hintPath
.
depth
()
==
0
)
{
try
{
filename
=
makeFileName
(
filename
,
instrument
);
if
(
!
facility
.
noFilePrefix
())
{
filename
=
makeFileName
(
filename
,
instrument
);
}
}
catch
(
std
::
invalid_argument
&
)
{
if
(
filename
.
length
()
>=
hint
.
length
())
{
g_log
.
information
()
<<
"Could not form filename from standard rules '"
...
...
@@ -683,6 +686,7 @@ FileFinderImpl::getArchivePath(const std::vector<IArchiveSearch_sptr> &archs,
std
::
string
path
;
for
(
const
auto
&
arch
:
archs
)
{
try
{
g_log
.
debug
()
<<
"Getting archive path for requested files
\n
"
;
path
=
arch
->
getArchivePath
(
filenames
,
exts
);
if
(
!
path
.
empty
())
{
return
path
;
...
...
Framework/API/src/FunctionFactory.cpp
View file @
ed47bb2f
...
...
@@ -216,7 +216,14 @@ CompositeFunction_sptr FunctionFactoryImpl::createComposite(
cfun
->
addFunction
(
fun
);
size_t
i
=
cfun
->
nFunctions
()
-
1
;
for
(
auto
&
pAttribute
:
pAttributes
)
{
cfun
->
setLocalAttributeValue
(
i
,
pAttribute
.
first
,
pAttribute
.
second
);
// Apply parent attributes of the child function to this function. If this
// function doesn't have those attributes, they get passed up the chain to
// this function's parent.
if
(
cfun
->
hasLocalAttribute
(
pAttribute
.
first
))
{
cfun
->
setLocalAttributeValue
(
i
,
pAttribute
.
first
,
pAttribute
.
second
);
}
else
{
parentAttributes
[
pAttribute
.
first
]
=
pAttribute
.
second
;
}
}
}
...
...
Framework/API/src/ISpectrum.cpp
View file @
ed47bb2f
...
...
@@ -5,18 +5,11 @@
namespace
Mantid
{
namespace
API
{
//----------------------------------------------------------------------------------------------
/** Constructor
*/
ISpectrum
::
ISpectrum
()
:
m_specNo
(
0
),
detectorIDs
()
{}
/** Constructor with spectrum number
* @param specNo :: spectrum # of the spectrum
*/
ISpectrum
::
ISpectrum
(
const
specnum_t
specNo
)
:
m_specNo
(
specNo
),
detectorIDs
()
{}
ISpectrum
::
ISpectrum
(
const
specnum_t
specNo
)
:
m_specNo
(
specNo
)
{}
//----------------------------------------------------------------------------------------------
/** Copy spectrum number and detector IDs, but not X vector, from another
*ISpectrum
*
...
...
@@ -43,8 +36,6 @@ const MantidVec &ISpectrum::readY() const { return this->dataY(); }
/// Deprecated, use e() instead. Returns the y error data const
const
MantidVec
&
ISpectrum
::
readE
()
const
{
return
this
->
dataE
();
}
// =============================================================================================
// --------------------------------------------------------------------------
/** Add a detector ID to the set of detector IDs
*
* @param detID :: detector ID to insert in set.
...
...
@@ -58,8 +49,6 @@ void ISpectrum::addDetectorID(const detid_t detID) {
* @param detIDs :: set of detector IDs to insert in set.
*/
void
ISpectrum
::
addDetectorIDs
(
const
std
::
set
<
detid_t
>
&
detIDs
)
{
if
(
detIDs
.
empty
())
return
;
this
->
detectorIDs
.
insert
(
detIDs
.
begin
(),
detIDs
.
end
());
}
...
...
@@ -68,12 +57,9 @@ void ISpectrum::addDetectorIDs(const std::set<detid_t> &detIDs) {
* @param detIDs :: vector of detector IDs to insert in set.
*/
void
ISpectrum
::
addDetectorIDs
(
const
std
::
vector
<
detid_t
>
&
detIDs
)
{
if
(
detIDs
.
empty
())
return
;
this
->
detectorIDs
.
insert
(
detIDs
.
begin
(),
detIDs
.
end
());
}
// --------------------------------------------------------------------------
/** Clear the list of detector IDs, then add one.
*
* @param detID :: detector ID to insert in set.
...
...
@@ -96,37 +82,28 @@ void ISpectrum::setDetectorIDs(const std::set<detid_t> &detIDs) {
* @param detIDs The new list of detector ID numbers
*/
void
ISpectrum
::
setDetectorIDs
(
std
::
set
<
detid_t
>
&&
detIDs
)
{
#if !(defined(__INTEL_COMPILER))
detectorIDs
=
std
::
move
(
detIDs
);
#else
detectorIDs
=
detIDs
;
// No moving on the Mac :(
#endif
}
// --------------------------------------------------------------------------
/** Return true if the given detector ID is in the list for this ISpectrum */
bool
ISpectrum
::
hasDetectorID
(
const
detid_t
detID
)
const
{
return
(
detectorIDs
.
find
(
detID
)
!=
detectorIDs
.
end
());
}
// --------------------------------------------------------------------------
/** Get a const reference to the detector IDs set.
*/
const
std
::
set
<
detid_t
>
&
ISpectrum
::
getDetectorIDs
()
const
{
return
this
->
detectorIDs
;
}
// --------------------------------------------------------------------------
/** Clear the detector IDs set.
*/
void
ISpectrum
::
clearDetectorIDs
()
{
this
->
detectorIDs
.
clear
();
}
// --------------------------------------------------------------------------
/** Get a mutable reference to the detector IDs set.
*/
std
::
set
<
detid_t
>
&
ISpectrum
::
getDetectorIDs
()
{
return
this
->
detectorIDs
;
}
// ---------------------------------------------------------
/// @return the spectrum number of this spectrum
specnum_t
ISpectrum
::
getSpectrumNo
()
const
{
return
m_specNo
;
}
...
...
@@ -134,7 +111,6 @@ specnum_t ISpectrum::getSpectrumNo() const { return m_specNo; }
* @param num :: the spectrum number of this spectrum */
void
ISpectrum
::
setSpectrumNo
(
specnum_t
num
)
{
m_specNo
=
num
;
}
//---------------------------------------------------------
/**
* Gets the value of the use flag.
* @returns true if DX has been set, else false
...
...
Framework/API/src/LogManager.cpp
View file @
ed47bb2f
...
...
@@ -20,6 +20,84 @@ using namespace Kernel;
namespace
{
/// static logger
Logger
g_log
(
"LogManager"
);
/// Templated method to convert property to double
template
<
typename
T
>
bool
convertSingleValue
(
const
Property
*
property
,
double
&
value
)
{
if
(
auto
log
=
dynamic_cast
<
const
PropertyWithValue
<
T
>
*>
(
property
))
{
value
=
static_cast
<
double
>
(
*
log
);
return
true
;
}
else
{
return
false
;
}
}
/// Converts numeric property to double
bool
convertSingleValue
(
const
Property
*
property
,
double
&
value
)
{
// The first one to succeed short-circuits and the value is returned.
// If all fail, returns false.
return
convertSingleValue
<
double
>
(
property
,
value
)
||
convertSingleValue
<
int32_t
>
(
property
,
value
)
||
convertSingleValue
<
int64_t
>
(
property
,
value
)
||
convertSingleValue
<
float
>
(
property
,
value
)
||
convertSingleValue
<
uint32_t
>
(
property
,
value
)
||
convertSingleValue
<
uint64_t
>
(
property
,
value
);
}
/// Templated method to convert time series property to single double
template
<
typename
T
>
bool
convertTimeSeriesToDouble
(
const
Property
*
property
,
double
&
value
,
const
Math
::
StatisticType
&
function
)
{
if
(
const
auto
*
log
=
dynamic_cast
<
const
TimeSeriesProperty
<
T
>
*>
(
property
))
{
switch
(
function
)
{
case
Math
::
TimeAveragedMean
:
value
=
static_cast
<
double
>
(
log
->
timeAverageValue
());
break
;
case
Math
::
FirstValue
:
value
=
static_cast
<
double
>
(
log
->
firstValue
());
break
;
case
Math
::
LastValue
:
value
=
static_cast
<
double
>
(
log
->
lastValue
());
break
;