Skip to content

Commit

Permalink
Refs #5085: Martyn's fixes for concurrent python fixed these calls
Browse files Browse the repository at this point in the history
from python to launch an algorithm asynchronously. The problem was that a non-gui thread was launching an observer method in a GUI thread. Something martyn changed fixed this (apparently :) )
  • Loading branch information
Janik Zikovsky committed Apr 13, 2012
1 parent 6940769 commit 164d568
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 20 deletions.
3 changes: 1 addition & 2 deletions Code/Mantid/MantidPlot/mantidplotpy/proxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,7 @@ class SliceViewerProxy(QtProxyObject):
"""Proxy for a C++ SliceViewer widget.
"""
# These are the exposed python method names
#slicer_methods = ["setWorkspace", "getWorkspaceName", "showControls", "openFromXML", "getImage", "saveImage", "copyImageToClipboard", "setFastRender", "getFastRender", "toggleLineMode", "setXYDim", "setXYDim", "getDimX", "getDimY", "setSlicePoint", "setSlicePoint", "getSlicePoint", "getSlicePoint", "setXYLimits", "getXLimits", "getYLimits", "zoomBy", "setXYCenter", "resetZoom", "loadColorMap", "setColorScale", "setColorScaleMin", "setColorScaleMax", "setColorScaleLog", "getColorScaleMin", "getColorScaleMax", "getColorScaleLog", "setColorScaleAutoFull", "setColorScaleAutoSlice", "setColorMapBackground", "setTransparentZeros", "setNormalization", "getNormalization", "setRebinThickness", "setRebinNumBins", "setRebinMode", "refreshRebin"]
slicer_methods = ["setWorkspace", "getWorkspaceName", "showControls", "openFromXML", "getImage", "saveImage", "copyImageToClipboard", "setFastRender", "getFastRender", "toggleLineMode", "setXYDim", "setXYDim", "getDimX", "getDimY", "setSlicePoint", "setSlicePoint", "getSlicePoint", "getSlicePoint", "setXYLimits", "getXLimits", "getYLimits", "zoomBy", "setXYCenter", "resetZoom", "loadColorMap", "setColorScale", "setColorScaleMin", "setColorScaleMax", "setColorScaleLog", "getColorScaleMin", "getColorScaleMax", "getColorScaleLog", "setColorScaleAutoFull", "setColorScaleAutoSlice", "setColorMapBackground", "setTransparentZeros", "setNormalization", "getNormalization"]
slicer_methods = ["setWorkspace", "getWorkspaceName", "showControls", "openFromXML", "getImage", "saveImage", "copyImageToClipboard", "setFastRender", "getFastRender", "toggleLineMode", "setXYDim", "setXYDim", "getDimX", "getDimY", "setSlicePoint", "setSlicePoint", "getSlicePoint", "getSlicePoint", "setXYLimits", "getXLimits", "getYLimits", "zoomBy", "setXYCenter", "resetZoom", "loadColorMap", "setColorScale", "setColorScaleMin", "setColorScaleMax", "setColorScaleLog", "getColorScaleMin", "getColorScaleMax", "getColorScaleLog", "setColorScaleAutoFull", "setColorScaleAutoSlice", "setColorMapBackground", "setTransparentZeros", "setNormalization", "getNormalization", "setRebinThickness", "setRebinNumBins", "setRebinMode", "refreshRebin"]

def __init__(self, toproxy):
QtProxyObject.__init__(self, toproxy)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,15 +369,17 @@ def test_fixedBinWidth(self):
#==========================================================================
#======================= Dynamic Rebinning ================================
#==========================================================================
# FIXME: Figure out why this fails
def xtest_DynamicRebinning(self):
def test_DynamicRebinning(self):
sv = self.sv
sv.setRebinThickness(2, 1.0)
sv.setRebinNumBins(50, 200)
sv.refreshRebin()
sv.setRebinMode(True, True)
time.sleep(1)
self.assertTrue(mtd.workspaceExists('uniform_binned'), 'Dynamically rebinned workspace was created.')
self.assertTrue(mtd.workspaceExists('uniform_rebinned'), 'Dynamically rebinned workspace was created.')
ws = mtd['uniform_rebinned']
self.assertEqual(ws.getNumDims(), 3)
self.assertEqual(ws.getNPoints(), 50*200*1)



Expand Down
10 changes: 5 additions & 5 deletions Code/Mantid/MantidQt/mantidqt.in.sip
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,11 @@ public:
void setNormalization(Mantid::API::MDNormalization norm);
Mantid::API::MDNormalization getNormalization() const;

// //*WIKI* ==== Dynamic Rebinning ====
// void setRebinThickness(int dim, double thickness) throw (std::runtime_error);
// void setRebinNumBins(int xBins, int yBins) throw (std::runtime_error);
// void setRebinMode(bool mode, bool locked) throw (std::runtime_error);
// void refreshRebin() throw (std::runtime_error);
//*WIKI* ==== Dynamic Rebinning ====
void setRebinThickness(int dim, double thickness) throw (std::runtime_error);
void setRebinNumBins(int xBins, int yBins) throw (std::runtime_error);
void setRebinMode(bool mode, bool locked) throw (std::runtime_error);
void refreshRebin() throw (std::runtime_error);
};


Expand Down
14 changes: 9 additions & 5 deletions Code/Mantid/MantidQt/mantidqt.rhel5.sip
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,15 @@ public:
Mantid::API::MDNormalization getNormalization() const;


// //*WIKI* ==== Dynamic Rebinning ====
// void setRebinThickness(int dim, double thickness) throw (std::runtime_error);
// void setRebinNumBins(int xBins, int yBins) throw (std::runtime_error);
// void setRebinMode(bool mode, bool locked) throw (std::runtime_error);
// void refreshRebin() throw (std::runtime_error);
//*WIKI* ==== Dynamic Rebinning ====
void setRebinThickness(int dim, double thickness) throw (std::runtime_error);

void setRebinNumBins(int xBins, int yBins) throw (std::runtime_error);

void setRebinMode(bool mode, bool locked) throw (std::runtime_error);

void refreshRebin() throw (std::runtime_error);

};


Expand Down
62 changes: 57 additions & 5 deletions Code/Mantid/MantidQt/mantidqt.sip
Original file line number Diff line number Diff line change
Expand Up @@ -961,11 +961,63 @@ Mantid::API::MDNormalization SliceViewer::getNormalization()
%End


// //*WIKI* ==== Dynamic Rebinning ====
// void setRebinThickness(int dim, double thickness) throw (std::runtime_error);
// void setRebinNumBins(int xBins, int yBins) throw (std::runtime_error);
// void setRebinMode(bool mode, bool locked) throw (std::runtime_error);
// void refreshRebin() throw (std::runtime_error);
//*WIKI* ==== Dynamic Rebinning ====
void setRebinThickness(int dim, double thickness) throw (std::runtime_error);
%Docstring
void SliceViewer::setRebinThickness(int dim, double thickness)
--------------------------------------------------------------
Set the thickness (above and below the plane) for dynamic rebinning.

Args:
dim :: index of the dimension to adjust
thickness :: thickness to set, in units of the dimension.

Raises:
runtime_error if the dimension index is invalid or the thickness is <= 0.0.

%End

void setRebinNumBins(int xBins, int yBins) throw (std::runtime_error);
%Docstring
void SliceViewer::setRebinNumBins(int xBins, int yBins)
-------------------------------------------------------
Set the number of bins for dynamic rebinning.

Args:
xBins :: number of bins in the viewed X direction
yBins :: number of bins in the viewed Y direction

Raises:
runtime_error if the number of bins is < 1

%End

void setRebinMode(bool mode, bool locked) throw (std::runtime_error);
%Docstring
void SliceViewer::setRebinMode(bool mode, bool locked)
------------------------------------------------------
Sets the SliceViewer in dynamic rebin mode.
In this mode, the current view area (see setXYLimits()) is used as the
limits to rebin.
See setRebinNumBins() to adjust the number of bins in the X/Y dimensions.
See setRebinThickness() to adjust the thickness in other dimensions.

Args:
mode :: true for rebinning mode
locked :: if true, then the rebinned area is only refreshed manually
or when changing rebinning parameters.

%End

void refreshRebin() throw (std::runtime_error);
%Docstring
void SliceViewer::refreshRebin()
--------------------------------
When in dynamic rebinning mode, this refreshes the rebinned area to be the
currently viewed area. See setXYLimits(), setRebinNumBins(), setRebinThickness()

%End

};


Expand Down

0 comments on commit 164d568

Please sign in to comment.