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
5ad4375c
Commit
5ad4375c
authored
10 years ago
by
Ricardo Ferraz Leal
Browse files
Options
Downloads
Patches
Plain Diff
Re #9249 Added move and get component by name
parent
87a93c48
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
Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadHelper.h
+3
-0
3 additions, 0 deletions
...ramework/DataHandling/inc/MantidDataHandling/LoadHelper.h
Code/Mantid/Framework/DataHandling/src/LoadHelper.cpp
+35
-0
35 additions, 0 deletions
Code/Mantid/Framework/DataHandling/src/LoadHelper.cpp
with
38 additions
and
0 deletions
Code/Mantid/Framework/DataHandling/inc/MantidDataHandling/LoadHelper.h
+
3
−
0
View file @
5ad4375c
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include
"MantidKernel/System.h"
#include
"MantidKernel/System.h"
#include
"MantidNexus/NexusClasses.h"
#include
"MantidNexus/NexusClasses.h"
#include
"MantidKernel/V3D.h"
namespace
Mantid
{
namespace
Mantid
{
namespace
DataHandling
{
namespace
DataHandling
{
...
@@ -54,6 +55,8 @@ public:
...
@@ -54,6 +55,8 @@ public:
std
::
string
&
parent_class
,
std
::
string
&
parent_class
,
int
indent
);
int
indent
);
std
::
string
dateTimeInIsoFormat
(
std
::
string
);
std
::
string
dateTimeInIsoFormat
(
std
::
string
);
void
moveComponent
(
API
::
MatrixWorkspace_sptr
ws
,
const
std
::
string
&
componentName
,
const
Kernel
::
V3D
&
newPos
);
Kernel
::
V3D
getComponentPosition
(
API
::
MatrixWorkspace_sptr
ws
,
const
std
::
string
&
componentName
);
};
};
}
// namespace DataHandling
}
// namespace DataHandling
...
...
This diff is collapsed.
Click to expand it.
Code/Mantid/Framework/DataHandling/src/LoadHelper.cpp
+
35
−
0
View file @
5ad4375c
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
*WIKI*/
*WIKI*/
#include
"MantidDataHandling/LoadHelper.h"
#include
"MantidDataHandling/LoadHelper.h"
#include
"MantidGeometry/Instrument/ComponentHelper.h"
namespace
Mantid
{
namespace
Mantid
{
namespace
DataHandling
{
namespace
DataHandling
{
...
@@ -322,5 +323,39 @@ std::string LoadHelper::dateTimeInIsoFormat(std::string dateToParse) {
...
@@ -322,5 +323,39 @@ std::string LoadHelper::dateTimeInIsoFormat(std::string dateToParse) {
}
}
}
}
void
LoadHelper
::
moveComponent
(
API
::
MatrixWorkspace_sptr
ws
,
const
std
::
string
&
componentName
,
const
V3D
&
newPos
)
{
try
{
Geometry
::
Instrument_const_sptr
instrument
=
ws
->
getInstrument
();
Geometry
::
IComponent_const_sptr
component
=
instrument
->
getComponentByName
(
componentName
);
//g_log.debug() << tube->getName() << " : t = " << theta << " ==> t = " << newTheta << "\n";
Geometry
::
ParameterMap
&
pmap
=
ws
->
instrumentParameters
();
Geometry
::
ComponentHelper
::
moveComponent
(
*
component
,
pmap
,
newPos
,
Geometry
::
ComponentHelper
::
Absolute
);
}
catch
(
Mantid
::
Kernel
::
Exception
::
NotFoundError
&
)
{
throw
std
::
runtime_error
(
"Error when trying to move the "
+
componentName
+
" : NotFoundError"
);
}
catch
(
std
::
runtime_error
&
)
{
throw
std
::
runtime_error
(
"Error when trying to move the "
+
componentName
+
" : runtime_error"
);
}
}
V3D
LoadHelper
::
getComponentPosition
(
API
::
MatrixWorkspace_sptr
ws
,
const
std
::
string
&
componentName
)
{
try
{
Geometry
::
Instrument_const_sptr
instrument
=
ws
->
getInstrument
();
Geometry
::
IComponent_const_sptr
component
=
instrument
->
getComponentByName
(
componentName
);
V3D
pos
=
component
->
getPos
();
return
pos
;
}
catch
(
Mantid
::
Kernel
::
Exception
::
NotFoundError
&
)
{
throw
std
::
runtime_error
(
"Error when trying to move the "
+
componentName
+
" : NotFoundError"
);
}
}
}
// namespace DataHandling
}
// namespace DataHandling
}
// 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