Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef MANTID_SLICEVIEWER_FIRSTEXPERIMENTINFOQUERY_H_
#define MANTID_SLICEVIEWER_FIRSTEXPERIMENTINFOQUERY_H_
#include "MantidKernel/System.h"
#include "MantidAPI/IMDWorkspace.h"
#include "MantidAPI/MultipleExperimentInfos.h"
namespace MantidQt
{
namespace SliceViewer
{
/*---------------------------------------------------------
FirstExperimentInfoQuery
Represents a query against the first experiment info of a workspace.
----------------------------------------------------------*/
class DLLExport FirstExperimentInfoQuery
{
public:
virtual bool hasOrientedLattice() const = 0;
virtual bool hasRotatedGoniometer() const = 0;
};
/*---------------------------------------------------------
FirstExperimentInfoQueryAdapter
Templated adapter over the FirstExperimentInfoQuery interface.
----------------------------------------------------------*/
template <typename T>
class DLLExport FirstExperimentInfoQueryAdapter : public FirstExperimentInfoQuery
{
public:
typedef boost::shared_ptr<const T> Adaptee_sptr;
private:
Adaptee_sptr m_ws;
public:
FirstExperimentInfoQueryAdapter(Mantid::API::IMDWorkspace_sptr ws)
{
m_ws = boost::dynamic_pointer_cast<const T>(ws);
if(!m_ws)
{
throw std::invalid_argument("Workspace object is of the wrong type for this adapter.");
}
}
bool hasOrientedLattice() const
{
Mantid::API::MultipleExperimentInfos_const_sptr expInfos = boost::dynamic_pointer_cast<const Mantid::API::MultipleExperimentInfos>(m_ws);
bool hasLattice = false;
if( expInfos != NULL && expInfos->getNumExperimentInfo() > 0)
{
Mantid::API::ExperimentInfo_const_sptr expInfo = expInfos->getExperimentInfo(0);
hasLattice = expInfo->sample().hasOrientedLattice();
}
return hasLattice;
}
bool hasRotatedGoniometer() const
{
Mantid::API::MultipleExperimentInfos_const_sptr expInfos = boost::dynamic_pointer_cast<const Mantid::API::MultipleExperimentInfos>(m_ws);
bool hasRotatedGoniometer = false;
if( expInfos != NULL && expInfos->getNumExperimentInfo() > 0)
{
Mantid::API::ExperimentInfo_const_sptr expInfo = expInfos->getExperimentInfo(0);
hasRotatedGoniometer = expInfo->run().getGoniometerMatrix().isRotation();
}
return hasRotatedGoniometer;
}
};
}
}
#endif /* MANTID_SLICEVIEWER_FIRSTEXPERIMENTINFOQUERY_H_ */