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
eaf1d653
Commit
eaf1d653
authored
Mar 22, 2016
by
Michael Hart
Browse files
Re #15712 Constructors to apply ParameterMap are now protected
parent
7e0fa0f9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Framework/Geometry/inc/MantidGeometry/Instrument/Detector.h
View file @
eaf1d653
...
...
@@ -48,8 +48,6 @@ public:
/// A string representation of the component type
std
::
string
type
()
const
override
{
return
"DetectorComponent"
;
}
/// Constructor for parametrized version
Detector
(
const
Detector
*
base
,
const
ParameterMap
*
map
);
Detector
(
const
std
::
string
&
name
,
int
id
,
IComponent
*
parent
);
Detector
(
const
std
::
string
&
name
,
int
id
,
boost
::
shared_ptr
<
Object
>
shape
,
IComponent
*
parent
);
...
...
@@ -91,6 +89,10 @@ private:
const
detid_t
m_id
;
/// Flags if this is a monitor
bool
m_isMonitor
;
protected:
/// Constructor for parametrized version
Detector
(
const
Detector
*
base
,
const
ParameterMap
*
map
);
};
}
// namespace Geometry
...
...
Framework/Geometry/inc/MantidGeometry/Instrument/RectangularDetectorPixel.h
View file @
eaf1d653
...
...
@@ -49,9 +49,6 @@ public:
/// A string representation of the component type
std
::
string
type
()
const
override
{
return
"RectangularDetectorPixel"
;
}
/// Constructor for parametrized version
RectangularDetectorPixel
(
const
RectangularDetectorPixel
*
base
,
const
ParameterMap
*
map
);
RectangularDetectorPixel
(
const
std
::
string
&
name
,
int
id
,
boost
::
shared_ptr
<
Object
>
shape
,
IComponent
*
parent
,
RectangularDetector
*
panel
,
size_t
row
,
size_t
col
);
...
...
@@ -66,13 +63,18 @@ public:
const
Kernel
::
V3D
getRelativePos
()
const
override
;
pr
otec
te
d
:
pr
iva
te:
/// RectangularDetector that is the parent of this pixel.
RectangularDetector
*
m_panel
;
/// Row of the pixel in the panel (y index)
size_t
m_row
;
/// Column of the pixel in the panel (x index)
size_t
m_col
;
protected:
/// Constructor for parametrized version
RectangularDetectorPixel
(
const
RectangularDetectorPixel
*
base
,
const
ParameterMap
*
map
);
};
}
// namespace Geometry
...
...
Framework/Geometry/src/Instrument/ParComponentFactory.cpp
View file @
eaf1d653
...
...
@@ -53,14 +53,6 @@ ParComponentFactory::createInstrument(boost::shared_ptr<const Instrument> base,
IComponent_sptr
ParComponentFactory
::
create
(
boost
::
shared_ptr
<
const
IComponent
>
base
,
const
ParameterMap
*
map
)
{
// RectangularDetectorPixel subclasses Detector so it has to be checked
// before.
const
RectangularDetectorPixel
*
rdp
=
dynamic_cast
<
const
RectangularDetectorPixel
*>
(
base
.
get
());
if
(
rdp
)
return
boost
::
shared_ptr
<
IComponent
>
(
new
RectangularDetectorPixel
(
rdp
,
map
));
boost
::
shared_ptr
<
const
IDetector
>
det_sptr
=
boost
::
dynamic_pointer_cast
<
const
IDetector
>
(
base
);
if
(
det_sptr
)
{
...
...
Framework/Geometry/test/ParDetectorTest.h
View file @
eaf1d653
...
...
@@ -14,13 +14,13 @@ public:
Detector
det
(
"det1"
,
0
,
0
);
ParameterMap_sptr
pmap
(
new
ParameterMap
());
Detector
pdet
(
&
det
,
pmap
.
get
());
boost
::
shared_ptr
<
Detector
>
pdet
(
det
.
cloneParameterized
(
pmap
.
get
())
)
;
TS_ASSERT_EQUALS
(
pdet
.
getName
(),
"det1"
);
TS_ASSERT
(
!
pdet
.
getParent
());
TS_ASSERT_EQUALS
(
pdet
.
getID
(),
0
);
TS_ASSERT
(
!
pdet
.
isMasked
());
TS_ASSERT
(
!
pdet
.
isMonitor
());
TS_ASSERT_EQUALS
(
pdet
->
getName
(),
"det1"
);
TS_ASSERT
(
!
pdet
->
getParent
());
TS_ASSERT_EQUALS
(
pdet
->
getID
(),
0
);
TS_ASSERT
(
!
pdet
->
isMasked
());
TS_ASSERT
(
!
pdet
->
isMonitor
());
}
void
testNameParentConstructor
()
{
...
...
@@ -28,13 +28,13 @@ public:
Detector
det
(
"det1"
,
0
,
&
parent
);
ParameterMap_sptr
pmap
(
new
ParameterMap
());
Detector
pdet
(
&
det
,
pmap
.
get
());
boost
::
shared_ptr
<
Detector
>
pdet
(
det
.
cloneParameterized
(
pmap
.
get
())
)
;
TS_ASSERT_EQUALS
(
pdet
.
getName
(),
"det1"
);
TS_ASSERT
(
pdet
.
getParent
());
TS_ASSERT_EQUALS
(
pdet
.
getID
(),
0
);
TS_ASSERT
(
!
pdet
.
isMasked
());
TS_ASSERT
(
!
pdet
.
isMonitor
());
TS_ASSERT_EQUALS
(
pdet
->
getName
(),
"det1"
);
TS_ASSERT
(
pdet
->
getParent
());
TS_ASSERT_EQUALS
(
pdet
->
getID
(),
0
);
TS_ASSERT
(
!
pdet
->
isMasked
());
TS_ASSERT
(
!
pdet
->
isMonitor
());
}
void
testId
()
{
...
...
@@ -42,42 +42,42 @@ public:
Detector
det
(
"det1"
,
id1
,
0
);
ParameterMap_sptr
pmap
(
new
ParameterMap
());
Detector
pdet
(
&
det
,
pmap
.
get
());
boost
::
shared_ptr
<
Detector
>
pdet
(
det
.
cloneParameterized
(
pmap
.
get
())
)
;
TS_ASSERT_EQUALS
(
pdet
.
getID
(),
id1
);
TS_ASSERT_EQUALS
(
pdet
->
getID
(),
id1
);
}
void
testType
()
{
Detector
det
(
"det"
,
0
,
0
);
ParameterMap_sptr
pmap
(
new
ParameterMap
());
Detector
pdet
(
&
det
,
pmap
.
get
());
boost
::
shared_ptr
<
Detector
>
pdet
(
det
.
cloneParameterized
(
pmap
.
get
())
)
;
TS_ASSERT_EQUALS
(
pdet
.
type
(),
"DetectorComponent"
);
TS_ASSERT_EQUALS
(
pdet
->
type
(),
"DetectorComponent"
);
}
void
testMasked
()
{
Detector
det
(
"det"
,
0
,
0
);
ParameterMap_sptr
pmap
(
new
ParameterMap
());
Detector
pdet
(
&
det
,
pmap
.
get
());
boost
::
shared_ptr
<
Detector
>
pdet
(
det
.
cloneParameterized
(
pmap
.
get
())
)
;
TS_ASSERT
(
!
pdet
.
isMasked
());
TS_ASSERT
(
!
pdet
->
isMasked
());
pmap
->
addBool
(
&
det
,
"masked"
,
true
);
TS_ASSERT
(
pdet
.
isMasked
());
TS_ASSERT
(
pdet
->
isMasked
());
}
void
testMonitor
()
{
Detector
det
(
"det"
,
0
,
0
);
ParameterMap_sptr
pmap
(
new
ParameterMap
());
Detector
pdet
(
&
det
,
pmap
.
get
());
boost
::
shared_ptr
<
Detector
>
pdet
(
det
.
cloneParameterized
(
pmap
.
get
())
)
;
TS_ASSERT
(
!
pdet
.
isMonitor
());
TS_ASSERT
(
!
pdet
->
isMonitor
());
TS_ASSERT_THROWS_NOTHING
(
det
.
markAsMonitor
());
TS_ASSERT
(
pdet
.
isMonitor
());
TS_ASSERT
(
pdet
->
isMonitor
());
TS_ASSERT_THROWS_NOTHING
(
det
.
markAsMonitor
(
false
));
TS_ASSERT
(
!
pdet
.
isMonitor
());
TS_ASSERT
(
!
pdet
->
isMonitor
());
}
void
testGetNumberParameter
()
{
...
...
@@ -85,8 +85,8 @@ public:
ParameterMap_sptr
pmap
(
new
ParameterMap
());
pmap
->
add
(
"double"
,
&
det
,
"testparam"
,
5.0
);
Detector
pdet
(
&
det
,
pmap
.
get
());
IDetector
*
idet
=
static_cast
<
IDetector
*>
(
&
pdet
);
boost
::
shared_ptr
<
Detector
>
pdet
(
det
.
cloneParameterized
(
pmap
.
get
())
)
;
IDetector
*
idet
=
static_cast
<
IDetector
*>
(
pdet
.
get
()
);
TS_ASSERT_EQUALS
(
idet
->
getNumberParameter
(
"testparam"
).
size
(),
1
);
TS_ASSERT_DELTA
(
idet
->
getNumberParameter
(
"testparam"
)[
0
],
5.0
,
1e-08
);
...
...
@@ -97,8 +97,8 @@ public:
ParameterMap_sptr
pmap
(
new
ParameterMap
());
pmap
->
add
(
"V3D"
,
&
det
,
"testparam"
,
Mantid
::
Kernel
::
V3D
(
0.5
,
1.0
,
1.5
));
Detector
pdet
(
&
det
,
pmap
.
get
());
IDetector
*
idet
=
static_cast
<
IDetector
*>
(
&
pdet
);
boost
::
shared_ptr
<
Detector
>
pdet
(
det
.
cloneParameterized
(
pmap
.
get
())
)
;
IDetector
*
idet
=
static_cast
<
IDetector
*>
(
pdet
.
get
()
);
std
::
vector
<
Mantid
::
Kernel
::
V3D
>
pos
=
idet
->
getPositionParameter
(
"testparam"
);
...
...
@@ -115,8 +115,8 @@ public:
ParameterMap_sptr
pmap
(
new
ParameterMap
());
pmap
->
add
(
"Quat"
,
&
det
,
"testparam"
,
Mantid
::
Kernel
::
Quat
(
1.0
,
0.25
,
0.5
,
0.75
));
Detector
pdet
(
&
det
,
pmap
.
get
());
IDetector
*
idet
=
static_cast
<
IDetector
*>
(
&
pdet
);
boost
::
shared_ptr
<
Detector
>
pdet
(
det
.
cloneParameterized
(
pmap
.
get
())
)
;
IDetector
*
idet
=
static_cast
<
IDetector
*>
(
pdet
.
get
()
);
std
::
vector
<
Mantid
::
Kernel
::
Quat
>
rot
=
idet
->
getRotationParameter
(
"testparam"
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment