Skip to content

Commit

Permalink
Merge branch 'master' into feature/10372_prompt_before_discard_table
Browse files Browse the repository at this point in the history
Refs #10372

Conflicts:
	Code/Mantid/MantidQt/CustomInterfaces/src/ReflMainViewPresenter.cpp
  • Loading branch information
Harry Jeffery committed Oct 21, 2014
2 parents 935e8b5 + 5917d70 commit 414bfa9
Show file tree
Hide file tree
Showing 11 changed files with 384 additions and 179 deletions.
8 changes: 5 additions & 3 deletions Code/Mantid/Framework/API/src/MatrixWorkspace.cpp
Expand Up @@ -1516,13 +1516,15 @@ namespace Mantid
double yBinSize(1.0); // only applies for volume normalization & numeric axis
if (normalization == VolumeNormalization && ax1->isNumeric())
{
if (wi + 1 == nhist && nhist > 1)
size_t uVI; // unused vertical index.
double currentVertical = ax1->operator ()(wi, uVI);
if (wi + 1 == nhist && nhist > 1) // On the boundary, look back to get diff
{
yBinSize = yVals[wi] - yVals[wi-1];
yBinSize = currentVertical - ax1->operator ()(wi - 1, uVI);
}
else
{
yBinSize = yVals[wi+1] - yVals[wi];
yBinSize = ax1->operator ()(wi + 1, uVI) - currentVertical;
}
}

Expand Down
41 changes: 41 additions & 0 deletions Code/Mantid/Framework/API/test/MatrixWorkspaceTest.h
Expand Up @@ -700,6 +700,47 @@ class MatrixWorkspaceTest : public CxxTest::TestSuite
TS_ASSERT_DELTA(ws.getSignalAtCoord(coords, Mantid::API::NoNormalization), 1.0, 1e-5);
}

void test_getCoordAtSignal_regression()
{
/*
Having more spectrum numbers (acutally vertical axis increments) than x bins in VolumeNormalisation mode
should not cause any issues.
*/
WorkspaceTester ws;
const int nVertical = 4;

const int nBins = 2;
const int nYValues = 1;
ws.initialize(nVertical, nBins, nYValues);
NumericAxis* verticalAxis = new NumericAxis(nVertical);
for(int i = 0; i < nVertical; ++i)
{
for(int j = 0; j < nBins; ++j)
{
if( j < nYValues )
{
ws.dataY(i)[j] = 1.0; // All y values are 1.
ws.dataE(i)[j] = j;
}
ws.dataX(i)[j] = j; // x increments by 1
}
verticalAxis->setValue(i, double(i)); // Vertical axis increments by 1.
}
ws.replaceAxis(1, verticalAxis);
// Signal is always 1 and volume of each box is 1. Therefore normalized signal values by volume should always be 1.

// Test at the top right.
coord_t coord_top_right[2] = {static_cast<float>(ws.readX(0).back()), float(0)};
signal_t value = 0;
TS_ASSERT_THROWS_NOTHING(value = ws.getSignalAtCoord(coord_top_right, VolumeNormalization));
TS_ASSERT_EQUALS(1.0, value);

// Test at another location just to be sure.
coord_t coord_bottom_left[2] = {static_cast<float>(ws.readX(nVertical-1)[1]), float(nVertical-1) };
TS_ASSERT_THROWS_NOTHING(value = ws.getSignalAtCoord(coord_bottom_left, VolumeNormalization));
TS_ASSERT_EQUALS(1.0, value);
}

void test_setMDMasking()
{
WorkspaceTester ws;
Expand Down
Expand Up @@ -6,6 +6,7 @@
#include "MantidQtCustomInterfaces/ReflMainView.h"
#include "MantidQtCustomInterfaces/IReflPresenter.h"
#include <boost/scoped_ptr.hpp>
#include <QSignalMapper>
#include "ui_ReflMainWidget.h"

namespace MantidQt
Expand Down Expand Up @@ -50,6 +51,9 @@ namespace MantidQt
//Connect the model
virtual void showTable(Mantid::API::ITableWorkspace_sptr model);

//Set the list of available tables to open
virtual void setTableList(const std::set<std::string>& tables);

//Dialog/Prompt methods
virtual std::string askUserString(const std::string& prompt, const std::string& title, const std::string& defaultValue);
virtual bool askUserYesNo(std::string prompt, std::string title);
Expand Down Expand Up @@ -79,6 +83,7 @@ namespace MantidQt
Ui::reflMainWidget ui;
//the workspace the user selected to open
std::string m_toOpen;
QSignalMapper* m_openMap;

private slots:
void setModel(QString name);
Expand Down
Expand Up @@ -42,6 +42,9 @@ namespace MantidQt
//Connect the model
virtual void showTable(Mantid::API::ITableWorkspace_sptr model) = 0;

//Set the list of available tables to open
virtual void setTableList(const std::set<std::string>& tables) = 0;

//Dialog/Prompt methods
virtual std::string askUserString(const std::string& prompt, const std::string& title, const std::string& defaultValue) = 0;
virtual bool askUserYesNo(std::string prompt, std::string title) = 0;
Expand Down
@@ -1,11 +1,16 @@
#ifndef MANTID_CUSTOMINTERFACES_REFLMAINVIEWPRESENTER_H
#define MANTID_CUSTOMINTERFACES_REFLMAINVIEWPRESENTER_H

#include "MantidKernel/System.h"
#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/ITableWorkspace.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidKernel/System.h"
#include "MantidQtCustomInterfaces/ReflMainView.h"
#include "MantidQtCustomInterfaces/IReflPresenter.h"

#include <Poco/AutoPtr.h>
#include <Poco/NObserver.h>

namespace MantidQt
{
namespace CustomInterfaces
Expand Down Expand Up @@ -40,6 +45,9 @@ namespace MantidQt
ReflMainViewPresenter(ReflMainView* view);
virtual ~ReflMainViewPresenter();
virtual void notify(int flag);

//Public for the purposes of unit testing
static std::map<std::string,std::string> parseKeyValueString(const std::string& str);
protected:
//the model the table is currently representing
Mantid::API::ITableWorkspace_sptr m_model;
Expand Down Expand Up @@ -84,6 +92,22 @@ namespace MantidQt
virtual void saveTable();
virtual void saveTableAs();

//List of workspaces the user can open
std::set<std::string> m_workspaceList;

//To maintain a list of workspaces the user may open, we observe the ADS
Poco::NObserver<ReflMainViewPresenter, Mantid::API::WorkspaceAddNotification> m_addObserver;
Poco::NObserver<ReflMainViewPresenter, Mantid::API::WorkspacePostDeleteNotification> m_remObserver;
Poco::NObserver<ReflMainViewPresenter, Mantid::API::ClearADSNotification> m_clearObserver;
Poco::NObserver<ReflMainViewPresenter, Mantid::API::WorkspaceRenameNotification> m_renameObserver;
Poco::NObserver<ReflMainViewPresenter, Mantid::API::WorkspaceAfterReplaceNotification> m_replaceObserver;

void handleAddEvent(Mantid::API::WorkspaceAddNotification_ptr pNf);
void handleRemEvent(Mantid::API::WorkspacePostDeleteNotification_ptr pNf);
void handleClearEvent(Mantid::API::ClearADSNotification_ptr pNf);
void handleRenameEvent(Mantid::API::WorkspaceRenameNotification_ptr pNf);
void handleReplaceEvent(Mantid::API::WorkspaceAfterReplaceNotification_ptr pNf);

public:
static const int COL_RUNS = 0;
static const int COL_ANGLE = 1;
Expand Down

0 comments on commit 414bfa9

Please sign in to comment.