Skip to content

Commit

Permalink
Refs #4407: fix error viewing 4D workspaces and a slicer...
Browse files Browse the repository at this point in the history
that did not show up right
  • Loading branch information
Janik Zikovsky committed Jan 6, 2012
1 parent 2096624 commit f6485c5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
14 changes: 13 additions & 1 deletion Code/Mantid/MantidPlot/test/MantidPlotSliceViewerTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
import time

CreateMDWorkspace(Dimensions='3',Extents='0,10,0,10,0,10',Names='x,y,z',Units='m,m,m',SplitInto='5',MaxRecursionDepth='20',OutputWorkspace='mdw')
CreateMDWorkspace(Dimensions='3',Extents='0,10,0,10,0,10',Names='x,y,z',Units='m,m,m',SplitInto='5',MaxRecursionDepth='20',OutputWorkspace='empty')
FakeMDEventData("mdw", UniformParams="1e5")
FakeMDEventData("mdw", PeakParams="1e4, 2,4,6, 1.5")
BinMD("mdw", "uniform", 1, "x,0,10,30", "y,0,10,30", "z,0,10,30", IterateEvents="1", Parallel="0")
CreateMDWorkspace(Dimensions='3',Extents='0,10,0,10,0,10',Names='x,y,z',Units='m,m,m',SplitInto='5',MaxRecursionDepth='20',OutputWorkspace='empty')
CreateMDWorkspace(Dimensions='4',Extents='0,10,0,10,0,10,0,10',Names='x,y,z,e',Units='m,m,m,meV',SplitInto='5',MaxRecursionDepth='20',OutputWorkspace='md4')


class MantidPlotSliceViewerTest(unittest.TestCase):
Expand Down Expand Up @@ -64,6 +65,17 @@ def test_methods_pass_through(self):
self.assertEqual(svw.getDimX(), 2)
self.assertEqual(svw.getDimY(), 0)

def test_plot4D_workspace(self):
svw = plotSlice('md4')
svw.setSlicePoint(2, 2.5)
svw.setSlicePoint(3, 7.5)
self.assertAlmostEqual(svw.getSlicePoint(2), 2.5, 3)
self.assertAlmostEqual(svw.getSlicePoint(3), 7.5, 3)
screenshot(svw, "SliceViewer_4D", "SliceViewer open to a 4D workspace; z=2.5, e=7.5.")
svw.setXYDim("z", "e")
self.assertEqual(svw.getDimX(), 2)
self.assertEqual(svw.getDimY(), 3)

def test_plotSlice_arguments(self):
""" Pass arguments to plotSlice """
svw = plotSlice('uniform', label='test_label', xydim=[1,2],
Expand Down
4 changes: 4 additions & 0 deletions Code/Mantid/MantidQt/SliceViewer/src/DimensionSliceWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,12 @@ void DimensionSliceWidget::setShownDim(int dim)
{
m_insideSetShownDim = true;
m_shownDim = dim;
ui.btnX->blockSignals(true);
ui.btnY->blockSignals(true);
ui.btnX->setChecked( m_shownDim == 0 );
ui.btnY->setChecked( m_shownDim == 1 );
ui.btnX->blockSignals(false);
ui.btnY->blockSignals(false);
bool slicing = m_shownDim == -1;
ui.horizontalSlider->setVisible( slicing );
ui.doubleSpinBox->setVisible( slicing );
Expand Down
10 changes: 7 additions & 3 deletions Code/Mantid/MantidQt/SliceViewer/src/SliceViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ SliceViewer::SliceViewer(QWidget *parent)
/// Destructor
SliceViewer::~SliceViewer()
{
// std::cout << "SliceViewer " << this << " deleted" << std::endl;
delete m_data;
saveSettings();
// Don't delete Qt objects, I think these are auto-deleted
Expand Down Expand Up @@ -349,7 +348,7 @@ void SliceViewer::updateDimensionSliceWidgets()
{
for (size_t d=m_dimWidgets.size(); d<m_ws->getNumDims(); d++)
{
DimensionSliceWidget * widget = new DimensionSliceWidget(this /*TODO set to this */);
DimensionSliceWidget * widget = new DimensionSliceWidget(this);

ui.verticalLayoutControls->insertWidget(int(d), widget);

Expand All @@ -376,6 +375,8 @@ void SliceViewer::updateDimensionSliceWidgets()
for (size_t d=0; d<m_dimensions.size(); d++)
{
DimensionSliceWidget * widget = m_dimWidgets[d];
widget->blockSignals(true);

widget->setDimension( int(d), m_dimensions[d] );
// Default slicing layout
if (d == m_dimX)
Expand All @@ -391,6 +392,8 @@ void SliceViewer::updateDimensionSliceWidgets()
if (w > maxLabelWidth) maxLabelWidth = w;
w = widget->ui.lblUnits->sizeHint().width();
if (w > maxUnitsWidth) maxUnitsWidth = w;

widget->blockSignals(false);
}

// Make the labels all the same width
Expand All @@ -411,6 +414,8 @@ void SliceViewer::updateDimensionSliceWidgets()
void SliceViewer::setWorkspace(Mantid::API::IMDWorkspace_sptr ws)
{
m_ws = ws;
m_data->setWorkspace(ws);

// Emit the signal that we changed the workspace
emit workspaceChanged();

Expand Down Expand Up @@ -438,7 +443,6 @@ void SliceViewer::setWorkspace(Mantid::API::IMDWorkspace_sptr ws)
// Build up the widgets
this->updateDimensionSliceWidgets();

m_data->setWorkspace(ws);
// Find the full range. And use it
findRangeFull();
m_colorBar->setViewRange(m_colorRangeFull);
Expand Down

0 comments on commit f6485c5

Please sign in to comment.