Skip to content
Snippets Groups Projects
Commit 8de49404 authored by Janik Zikovsky's avatar Janik Zikovsky
Browse files

Refs #4316 fixed issue with setShownDim

And added a test that runs within MantidPlot
parent d355ab55
No related merge requests found
......@@ -70,6 +70,7 @@ void DimensionSliceWidget::btnXYChanged()
{
if (m_insideSetShownDim)
return;
int oldDim = m_shownDim;
if (ui.btnX->isChecked() && ui.btnY->isChecked() )
{
// Toggle when both are checked
......@@ -84,6 +85,9 @@ void DimensionSliceWidget::btnXYChanged()
this->setShownDim(1);
else
this->setShownDim(-1);
// Emit that the user changed the shown dimension
emit changedShownDim(m_dimIndex, m_shownDim, oldDim);
}
......@@ -96,7 +100,6 @@ void DimensionSliceWidget::btnXYChanged()
void DimensionSliceWidget::setShownDim(int dim)
{
m_insideSetShownDim = true;
int oldDim = m_shownDim;
m_shownDim = dim;
ui.btnX->setChecked( m_shownDim == 0 );
ui.btnY->setChecked( m_shownDim == 1 );
......@@ -130,9 +133,6 @@ void DimensionSliceWidget::setShownDim(int dim)
this->update();
m_insideSetShownDim = false;
// Emit that the user changed the shown dimension
emit changedShownDim(m_dimIndex, m_shownDim, oldDim);
}
//-------------------------------------------------------------------------------------------------
......
......@@ -21,6 +21,9 @@ QwtRasterDataMD::QwtRasterDataMD()
m_minVal = DBL_MAX;
m_maxVal = -DBL_MAX;
m_range = QwtDoubleInterval(0.0, 1.0);
m_nd = 0;
m_dimX = 0;
m_dimY = 0;
nan = std::numeric_limits<double>::quiet_NaN();
}
......@@ -127,6 +130,8 @@ QSize QwtRasterDataMD::rasterHint(const QwtDoubleRect &area) const
*/
void QwtRasterDataMD::setWorkspace(Mantid::API::IMDWorkspace_sptr ws)
{
if (!ws)
throw std::runtime_error("QwtRasterDataMD::setWorkspace(): NULL workspace passed.");
m_ws = ws;
m_nd = m_ws->getNumDims();
m_dimX = 0;
......@@ -144,10 +149,12 @@ void QwtRasterDataMD::setWorkspace(Mantid::API::IMDWorkspace_sptr ws)
*/
void QwtRasterDataMD::setSliceParams(size_t dimX, size_t dimY, std::vector<Mantid::coord_t> & slicePoint)
{
if (slicePoint.size() != m_nd)
throw std::runtime_error("QwtRasterDataMD::setSliceParams(): inconsistent vector/number of dimensions size.");
m_dimX = dimX;
m_dimY = dimY;
delete [] m_slicePoint;
m_slicePoint = new coord_t[m_nd];
m_slicePoint = new coord_t[slicePoint.size()];
for (size_t d=0; d<m_nd; d++)
m_slicePoint[d] = slicePoint[d];
}
......
......@@ -3,59 +3,54 @@ import sys
import os
import unittest
import time
# Import the Mantid framework
sys.path.append( os.getcwd() )
import MantidFramework
from MantidFramework import mtd
from mantidsimple import *
from PyQt4 import Qt
from PyQt4 import QtTest
from PyQt4.QtTest import QTest
import libmantidqtpython
# Create a test data set
CreateMDWorkspace(Dimensions='3',Extents='0,10,0,10,0,10',Names='x,y,z',
Units='m,m,m',SplitInto='5',MaxRecursionDepth='20',OutputWorkspace='mdw')
FakeMDEventData("mdw", UniformParams="1e6")
Units='m,m,m',SplitInto='5',SplitThreshold=100, MaxRecursionDepth='20',OutputWorkspace='mdw')
FakeMDEventData("mdw", UniformParams="1e4")
FakeMDEventData("mdw", PeakParams="1e3, 1, 2, 3, 1.0")
BinMD("mdw", "uniform", AxisAligned=1, AlignedDimX="x,0,10,30", AlignedDimY="y,0,10,30", AlignedDimZ="z,0,10,30", IterateEvents="1", Parallel="0")
w = mtd['uniform']
print "CREATED!", w
from PyQt4 import Qt
import libmantidqtpython
class SliceViewerPythonInterfaceTest(unittest.TestCase):
"""Test for accessing SliceViewer widgets from MantidPlot
python interpreter"""
def setUp(self):
self.app = Qt.QApplication(sys.argv)
""" Set up and create a SliceViewer widget """
global libmantidqtpython
self.sv = libmantidqtpython.MantidQt.SliceViewer.SliceViewer()
pass
def tearDown(self):
""" Close the created widget """
self.sv.close()
def test_creating(self):
print "test_creating"
import time
def test_setWorkspace(self):
print "test_setWorkspace"
sv = self.sv
#sv.setWorkspace('mdw')
sv.setWorkspace('uniform')
sv.show()
print sv
#sv.close()
global QTest
#QTest.mouseClick(sv)
def test_creating2(self):
print "test_creating2"
def test_other(self):
print "test_other"
sv = self.sv
sv.setWorkspace('mdw')
sv.show()
if __name__=="__main__":
unittest.main()
## ----- Create and run the unit test ----------------------
#sys.path.append("/home/8oz/Code/Mantid/Code/Mantid/TestingTools/unittest-xml-reporting/src")
#import xmlrunner
#suite = unittest.makeSuite(SliceViewerPythonInterfaceTest)
#runner = xmlrunner.XMLTestRunner(output='Testing')
#runner.run(suite)
#print "Done!"
# ----- Create and run the unit test ----------------------
sys.path.append("/home/8oz/Code/Mantid/Code/Mantid/TestingTools/unittest-xml-reporting/src")
import xmlrunner
suite = unittest.makeSuite(SliceViewerPythonInterfaceTest)
runner = xmlrunner.XMLTestRunner(output='Testing')
runner.run(suite)
print "Done!"
#
## Run the app.
#a.exec_()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment