Skip to content

Commit

Permalink
move pyplot out of future. and the old plot into qtiplot.py, re #11542
Browse files Browse the repository at this point in the history
  • Loading branch information
FedeMPouzols committed Apr 15, 2015
1 parent 5217533 commit be2ae72
Show file tree
Hide file tree
Showing 6 changed files with 1,806 additions and 31 deletions.
18 changes: 4 additions & 14 deletions Code/Mantid/MantidPlot/CMakeLists.txt
Expand Up @@ -855,20 +855,13 @@ copy_files_to_dir ( "${PY_FILES}"
set( MTDPLOTPY_FILES
__init__.py
proxies.py
pyplot.py
qtiplot.py
)
copy_files_to_dir ( "${MTDPLOTPY_FILES}"
${CMAKE_CURRENT_SOURCE_DIR}/pymantidplot
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/pymantidplot
MTDPLOT_INSTALL_FILES )

set( FUTURE_FILES
__init__.py
pyplot.py
)
copy_files_to_dir ( "${FUTURE_FILES}"
${CMAKE_CURRENT_SOURCE_DIR}/pymantidplot/future
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/pymantidplot/future
MTDPLOT_FUTURE_INSTALL_FILES )

# IPython scripts
set( IPY_FILES
Expand All @@ -887,7 +880,7 @@ copy_files_to_dir ( "${IPY_FILES}"
add_executable ( MantidPlot ${WIN_CONSOLE} MACOSX_BUNDLE ${ALL_SRC} src/main.cpp
${INC_FILES} ${QTIPLOT_C_SRC} ${UI_HDRS}
${RES_FILES} ${MANTID_RC_FILE}
${PYTHON_INSTALL_FILES} ${MTDPLOT_INSTALL_FILES} ${CONFIG_RESET_SCRIPT_FILE} ${MTDPLOT_FUTURE_INSTALL_FILES} ${IPYTHON_INSTALL_FILES}
${PYTHON_INSTALL_FILES} ${MTDPLOT_INSTALL_FILES} ${CONFIG_RESET_SCRIPT_FILE} ${IPYTHON_INSTALL_FILES}
)

# Library dependencies
Expand Down Expand Up @@ -963,7 +956,7 @@ set ( MANTIDPLOT_TEST_PY_FILES
MantidPlotMdiSubWindowTest.py
MantidPlotTiledWindowTest.py
MantidPlotInputArgsCheck.py
MantidPlotFuturePyplotGeneralTest.py
MantidPlotPyplotGeneralTest.py
)

if ( 0 )
Expand Down Expand Up @@ -1029,9 +1022,6 @@ install ( FILES ${PY_FILES} DESTINATION ${BIN_DIR} )
foreach(PY_FILE ${MTDPLOTPY_FILES} )
install ( FILES pymantidplot/${PY_FILE} DESTINATION ${BIN_DIR}/pymantidplot )
endforeach()
foreach(FUT_PY_FILE ${FUTURE_FILES} )
install ( FILES pymantidplot/future/${FUT_PY_FILE} DESTINATION ${BIN_DIR}/pymantidplot/future )
endforeach()
foreach(PY_FILE ${IPY_FILES} )
install ( FILES ipython_widget/${PY_FILE} DESTINATION ${BIN_DIR}/ipython_widget )
endforeach()
Expand Down
12 changes: 12 additions & 0 deletions Code/Mantid/MantidPlot/mantidplot.py
Expand Up @@ -10,3 +10,15 @@
from pymantidplot import *
except ImportError:
raise ImportError('Could not import mantidplot (when trying to import pymantidplot). Something is broken in this installation, please check.')

try:
# import pyplot and also bring it into the standard MantidPlot namespace
import pymantidplot.pyplot
from pymantidplot.pyplot import *
except ImportError:
raise ImportError('Could not import pymantidplot.pyplot. Something is broken in this installation, please check.')

try:
import pymantidplot.qtiplot
except ImportError:
raise ImportError('Could not import pymantidplot.qtiplot. Something is broken in this installation, please check.')
17 changes: 0 additions & 17 deletions Code/Mantid/MantidPlot/pymantidplot/__init__.py
Expand Up @@ -183,23 +183,6 @@ def newTiledWindow(name=None):
else:
return new_proxy(proxies.TiledWindowProxy, _qti.app.newTiledWindow, name)

#-----------------------------------------------------------------------------
# Intercept qtiplot "plot" command and forward to plotSpectrum for a workspace
def plot(source, *args, **kwargs):
"""Create a new plot given a workspace, table or matrix.
Args:
source: what to plot; if it is a Workspace, will
call plotSpectrum()
Returns:
A handle to the created Graph widget.
"""
if hasattr(source, '_getHeldObject') and isinstance(source._getHeldObject(), QtCore.QObject):
return new_proxy(proxies.Graph,_qti.app.plot, source._getHeldObject(), *args, **kwargs)
else:
return plotSpectrum(source, *args, **kwargs)

#----------------------------------------------------------------------------------------------------
def plotSpectrum(source, indices, error_bars = False, type = -1, window = None, clearWindow = False):
"""Open a 1D Plot of a spectrum in a workspace.
Expand Down

0 comments on commit be2ae72

Please sign in to comment.