Commit b60b6fff authored by Ruth Mikkelson's avatar Ruth Mikkelson
Browse files

Refs #6853 Added a lot more information and fixed some errors

Run numbers, goniometer readings, hkl values were added if appropriate( only 1 run)
Also, a segmentation fault problem was fixed and failure to give the proper results
for a second PointedAt point was rectified.
parent fee4d9d7
#include "MantidAPI/AlgorithmFactory.h"
#include "MantidAPI/Column.h"
#include "MantidAPI/ColumnFactory.h"
#include "MantidGeometry/Instrument/Goniometer.h"
#include "MantidAPI/MatrixWorkspace.h"
#include <nexus/NeXusException.hpp>
#include <nexus/NeXusFile.hpp>
......@@ -16,6 +17,7 @@
#include "MantidKernel/Logger.h"
#include "MantidKernel/PhysicalConstants.h"
#include "MantidKernel/Unit.h"
#include "MantidGeometry/Crystal/OrientedLattice.h"
#include <algorithm>
#include <boost/shared_ptr.hpp>
#include <exception>
......@@ -247,58 +249,119 @@ namespace Mantid
std::pair< std::string,std::string > QMag( "|Q|", boost::lexical_cast<std::string>(QLabFrame.norm()));
Result.push_back( QMag );
std::pair< std::string,std::string > dspc( "d-spacing", boost::lexical_cast<std::string>(1.0/QLabFrame.norm()));
std::pair< std::string,std::string > dspc( "d-spacing", boost::lexical_cast<std::string>(2.0*M_PI/QLabFrame.norm()));
Result.push_back( dspc);
std::pair< std::string,std::string > Qlab("Qlab",QLabFrame.toString());
std::pair< std::string,std::string > Qlab("Qlab",boost::lexical_cast<std::string>(QLabFrame));
Result.push_back(Qlab);
try{
API::IPeak* peak = createPeak( QLabFrame);
int seqNum=-1;
bool hasOneRunNumber = true;
int runNum = -1;
double minDist= 10000000;
for( int i = 0; i < getNumberPeaks() ; i++ )
{
Peak pk = getPeak(i);
double D = QLabFrame.distance(pk.getQLabFrame() );
std::cout<<"D="<<D<<std::endl;
if( D < minDist)
{
minDist = D;
seqNum = i+1;
}
int run= pk.getRunNumber();
if( runNum <0)
runNum =run;
else if( runNum != run)
hasOneRunNumber = false;
}
if( hasOneRunNumber)
{
std::pair< std::string,std::string > runn( "RunNumber", boost::lexical_cast<std::string>(runNum));
Result.push_back(runn);
const Kernel::DblMatrix GonRconst= run().getGoniometerMatrix();
Kernel::Matrix<double> GonR(GonRconst);
Kernel::Matrix<double>ident(3,3);
ident.identityMatrix();
V3D QSamp;
if( !(GonR ==ident))
{
Kernel::Matrix<double> InvGon( GonR);
InvGon.Invert();
QSamp = InvGon *QLabFrame;
std::pair< std::string,std::string > Qsamp("QSample",boost::lexical_cast<std::string>(QSamp));
Result.push_back(Qsamp);
}else
QSamp = QLabFrame;
if( sample().hasOrientedLattice())
{
std::pair< std::string,std::string > wl( "wl", boost::lexical_cast<std::string>(peak->getWavelength()));
const Geometry::OrientedLattice & lat =(sample().getOrientedLattice());
const Kernel::Matrix<double> &UB0 = lat.getUB();
Kernel::Matrix<double> UB ( UB0);
UB.Invert();
V3D hkl = UB*QSamp/2/M_PI;
std::pair< std::string,std::string > HKL("HKL", boost::lexical_cast<std::string>(hkl));
Result.push_back( HKL );
}
//------- Now get phi, chi and omega ----------------
Geometry::Goniometer Gon( GonR);
std::vector<double>OmegaChiPhi= Gon.getEulerAngles("YZY");
Kernel::V3D PhiChiOmega( OmegaChiPhi[2],OmegaChiPhi[1],OmegaChiPhi[0]);
std::pair< std::string,std::string > GRead( "Goniometer Angles",boost::lexical_cast<std::string>(PhiChiOmega));
Result.push_back( GRead );
}
std::pair< std::string,std::string > SeqNum( "Sequence Num",boost::lexical_cast<std::string>(seqNum));
Result.push_back( SeqNum );
std::pair< std::string,std::string > wl( "Wavelength", boost::lexical_cast<std::string>(peak->getWavelength()));
Result.push_back( wl );
if( peak->findDetector())
{
V3D detPos = peak->getDetPos();
std::pair< std::string,std::string > detpos( "pos", boost::lexical_cast<std::string>(peak->getDetPos()));
std::pair< std::string,std::string > detpos( "Position(x,y,z)", boost::lexical_cast<std::string>(peak->getDetPos()));
Result.push_back( detpos );
std::pair< std::string,std::string > tof( "tof", boost::lexical_cast<std::string>(peak->getTOF()));
std::pair< std::string,std::string > tof( "TOF", boost::lexical_cast<std::string>(peak->getTOF()));
Result.push_back( tof );
std::pair< std::string,std::string > Energy( "Energy", boost::lexical_cast<std::string>(peak->getFinalEnergy()));
Result.push_back( Energy );
std::pair< std::string,std::string > row( "row", boost::lexical_cast<std::string>(peak->getRow()));
std::pair< std::string,std::string > row( "Row", boost::lexical_cast<std::string>(peak->getRow()));
Result.push_back( row );
std::pair< std::string,std::string > col( "col", boost::lexical_cast<std::string>(peak->getCol()));
std::pair< std::string,std::string > col( "Col", boost::lexical_cast<std::string>(peak->getCol()));
Result.push_back( col );
std::pair< std::string,std::string > bank( "bank",peak->getBankName() );
std::pair< std::string,std::string > bank( "Bank",peak->getBankName() );
Result.push_back( bank );
std::pair< std::string,std::string > scat( "Scattering Angle",boost::lexical_cast<std::string>(peak->getScattering() ));
Result.push_back( scat );
int seqNum=-1;
double minDist= 10000000;
for( int i = 0; i < getNumberPeaks() ; i++ )
if( detPos.distance(getPeak(i).getDetPos() )< minDist)
{
minDist = detPos.distance( getPeak( i ).getDetPos() );
seqNum = i+1;
}
std::pair< std::string,std::string > SeqNum( "Sequence Num",boost::lexical_cast<std::string>(seqNum));
Result.push_back( SeqNum );
}
......@@ -309,7 +372,6 @@ namespace Mantid
{
}
return Result;
}
//---------------------------------------------------------------------------------------------
......
......@@ -294,9 +294,9 @@ private slots:
/// Slot to enable/disable the ellipse size options controls
void setEnabledEllipseSizeOptions_slot();
/// Method to handle pointed at message from any source
/// Methods to handle pointed at message from any source
void handleQpointNotification(const Poco::AutoPtr<Mantid::API::SelectionNotificationServiceImpl::AddNotification> & message );
void handleQpointNotification1(const Poco::AutoPtr<Mantid::API::SelectionNotificationServiceImpl::AfterReplaceNotification> & message );
/// Method to get and display info about the specified Q-vector
void showInfo( Mantid::Kernel::V3D q_point );
......@@ -361,6 +361,10 @@ private:
QThreadPool *m_thread_pool; /// local thread pool with only one thread to
/// allow running precisely one operation
/// at a time in a separate thread.
Poco::NObserver<MantidEV, Mantid::API::SelectionNotificationServiceImpl::AddNotification> observer;
Poco::NObserver<MantidEV, Mantid::API::SelectionNotificationServiceImpl::AfterReplaceNotification> observer1;
};
} // namespace CustomInterfaces
......
......@@ -161,13 +161,18 @@ void RunEllipsoidIntegrate::run()
* Constructor for MantidEV. Makes the thread pool and instance of
* MantidEVWorker.
*/
MantidEV::MantidEV(QWidget *parent) : UserSubWindow(parent)
MantidEV::MantidEV(QWidget *parent) : UserSubWindow(parent),observer(*this, &MantidEV::handleQpointNotification),
observer1(*this, &MantidEV::handleQpointNotification1)
{
worker = new MantidEVWorker();
m_thread_pool = new QThreadPool( this );
m_thread_pool->setMaxThreadCount(1);
Poco::NObserver<MantidEV, SelectionNotificationServiceImpl::AddNotification> observer(*this, &MantidEV::handleQpointNotification);
SelectionNotificationService::Instance().notificationCenter.addObserver(observer);
SelectionNotificationService::Instance().notificationCenter.addObserver(observer1);
}
......@@ -178,6 +183,10 @@ MantidEV::MantidEV(QWidget *parent) : UserSubWindow(parent)
MantidEV::~MantidEV()
{
saveSettings("");
SelectionNotificationService::Instance().notificationCenter.removeObserver( observer);
SelectionNotificationService::Instance().notificationCenter.removeObserver( observer1);
delete worker;
delete m_thread_pool;
}
......@@ -968,10 +977,22 @@ void MantidEV::showInfo_slot()
}
void MantidEV::handleQpointNotification1(const Poco::AutoPtr<SelectionNotificationServiceImpl::AfterReplaceNotification> & message )
{
// std::string name = message->object_name();
// std::cout << "Name is " << name << std::endl;
// std::cout << message->object()->at(0) << std::endl;
// std::cout << message->object()->at(1) << std::endl;
// std::cout << message->object()->at(2) << std::endl;
Mantid::Kernel::V3D q_point( message->object()->at(0), message->object()->at(1), message->object()->at(2) );
showInfo( q_point );
}
void MantidEV::handleQpointNotification(const Poco::AutoPtr<SelectionNotificationServiceImpl::AddNotification> & message )
{
// std::cout << "GOT NOTIFICATION" << std::endl;
// std::string name = message->name();
// std::string name = message->object_name();
// std::cout << "Name is " << name << std::endl;
// std::cout << message->object()->at(0) << std::endl;
// std::cout << message->object()->at(1) << std::endl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment