Commit c7863ed4 authored by Lamar Moore's avatar Lamar Moore
Browse files

Re #14911 Code Refactor, move InstrumentWidget to MantidWidgets namespace

parent 5bcf733d
...@@ -692,6 +692,7 @@ include_directories ( ../QtPropertyBrowser/src ) ...@@ -692,6 +692,7 @@ include_directories ( ../QtPropertyBrowser/src )
include_directories ( ../MantidQt/API/inc ) include_directories ( ../MantidQt/API/inc )
include_directories ( ../MantidQt/MantidWidgets/inc ) include_directories ( ../MantidQt/MantidWidgets/inc )
include_directories ( ../MantidQt/MantidWidgets/inc/MantidQtMantidWidgets) include_directories ( ../MantidQt/MantidWidgets/inc/MantidQtMantidWidgets)
include_directories ( ../MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView)
include_directories ( ../MantidQt/SliceViewer/inc ) include_directories ( ../MantidQt/SliceViewer/inc )
include_directories ( ../MantidQt/SpectrumViewer/inc ) include_directories ( ../MantidQt/SpectrumViewer/inc )
include_directories ( ../MantidQt/Factory/inc ) include_directories ( ../MantidQt/Factory/inc )
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
try: try:
import pymantidplot import pymantidplot
from pymantidplot import * from pymantidplot import *
except ImportError: except ImportError, Exc:
raise ImportError('Could not import mantidplot (when trying to import pymantidplot). Something is broken in this installation, please check.') raise ImportError('Could not import mantidplot (when trying to import pymantidplot). Something is broken in this installation, please check.'+str(Exc))
try: try:
# import pyplot and also bring it into the standard MantidPlot namespace # import pyplot and also bring it into the standard MantidPlot namespace
......
...@@ -17,16 +17,18 @@ import os ...@@ -17,16 +17,18 @@ import os
import time import time
import mantid.api import mantid.api
import mantidqtpython import mantidqtpython
from mantidqtpython import GraphOptions
# Import into the global namespace qti classes that: # Import into the global namespace qti classes that:
# (a) don't need a proxy & (b) can be constructed from python or (c) have enumerations within them # (a) don't need a proxy & (b) can be constructed from python or (c) have enumerations within them
from _qti import (PlotSymbol, ImageSymbol, ArrowMarker, ImageMarker, from _qti import (PlotSymbol, ImageSymbol, ArrowMarker, ImageMarker)
GraphOptions, InstrumentWidget, InstrumentWidgetRenderTab, InstrumentWidgetPickTab,
InstrumentWidgetMaskTab) print dir(mantidqtpython)
# Make the ApplicationWindow instance accessible from the mantidplot namespace # Make the ApplicationWindow instance accessible from the mantidplot namespace
from _qti import app from _qti import app
# Alias threadsafe_call so users have a more understandable name # Alias threadsafe_call so users have a more understandable name
gui_cmd = threadsafe_call gui_cmd = threadsafe_call
...@@ -677,6 +679,8 @@ def getMantidMatrix(name): ...@@ -677,6 +679,8 @@ def getMantidMatrix(name):
"""Get a handle to the named Mantid matrix""" """Get a handle to the named Mantid matrix"""
return new_proxy(proxies.MantidMatrix, _qti.app.mantidUI.getMantidMatrix, name) return new_proxy(proxies.MantidMatrix, _qti.app.mantidUI.getMantidMatrix, name)
InstrumentWidget = mantidqtpython.MantidQt.MantidWidgets.InstrumentWidget
def getInstrumentView(name, tab=InstrumentWidget.RENDER): def getInstrumentView(name, tab=InstrumentWidget.RENDER):
"""Create an instrument view window based on the given workspace. """Create an instrument view window based on the given workspace.
...@@ -866,14 +870,14 @@ for name in MantidUIImports: ...@@ -866,14 +870,14 @@ for name in MantidUIImports:
# Set some aliases for Layer enumerations so that old code will still work # Set some aliases for Layer enumerations so that old code will still work
Layer = _qti.Layer Layer = _qti.Layer
Layer.Log10 = _qti.GraphOptions.Log10 Layer.Log10 = mantidqtpython.GraphOptions.Log10
Layer.Linear = _qti.GraphOptions.Linear Layer.Linear = mantidqtpython.GraphOptions.Linear
Layer.Left = _qti.GraphOptions.Left Layer.Left = mantidqtpython.GraphOptions.Left
Layer.Right = _qti.GraphOptions.Right Layer.Right = mantidqtpython.GraphOptions.Right
Layer.Bottom = _qti.GraphOptions.Bottom Layer.Bottom = mantidqtpython.GraphOptions.Bottom
Layer.Top = _qti.GraphOptions.Top Layer.Top = mantidqtpython.GraphOptions.Top
DistrFlag = mantidqtpython.MantidQt DistrFlag = mantidqtpython.MantidQt.DistributionFlag
DistrFlag.DistrDefault = mantidqtpython.MantidQt.DistributionDefault DistrFlag.DistrDefault = mantidqtpython.MantidQt.DistributionDefault
DistrFlag.DistrTrue = mantidqtpython.MantidQt.DistributionTrue DistrFlag.DistrTrue = mantidqtpython.MantidQt.DistributionTrue
DistrFlag.DistrFalse = mantidqtpython.MantidQt.DistributionFalse DistrFlag.DistrFalse = mantidqtpython.MantidQt.DistributionFalse
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <ProjectionSurface.h> #include <ProjectionSurface.h>
using namespace Mantid::API; using namespace Mantid::API;
using namespace MantidQt::MantidWidgets;
InstrumentWindow::InstrumentWindow(const QString &wsName, const QString &label, InstrumentWindow::InstrumentWindow(const QString &wsName, const QString &label,
ApplicationWindow *parent, ApplicationWindow *parent,
......
...@@ -9,7 +9,13 @@ ...@@ -9,7 +9,13 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
class ApplicationWindow; class ApplicationWindow;
class InstrumentWidget; namespace MantidQt
{
namespace MantidWidgets
{
class InstrumentWidget;
}
}
using namespace Mantid; using namespace Mantid;
...@@ -25,7 +31,7 @@ public: ...@@ -25,7 +31,7 @@ public:
void loadFromProject(const std::string &lines, ApplicationWindow *app, void loadFromProject(const std::string &lines, ApplicationWindow *app,
const int fileVersion); const int fileVersion);
std::string saveToProject(ApplicationWindow *app); std::string saveToProject(ApplicationWindow *app);
InstrumentWidget *getInstrumentWidget() { return m_instrumentWidget; } MantidQt::MantidWidgets::InstrumentWidget *getInstrumentWidget() { return m_instrumentWidget; }
void selectTab(int tab); void selectTab(int tab);
private: private:
...@@ -41,7 +47,7 @@ private: ...@@ -41,7 +47,7 @@ private:
virtual void clearADSHandle(); virtual void clearADSHandle();
private: private:
InstrumentWidget *m_instrumentWidget; MantidQt::MantidWidgets::InstrumentWidget *m_instrumentWidget;
}; };
#endif // INSTRUMENTWINDOW_H #endif // INSTRUMENTWINDOW_H
\ No newline at end of file
...@@ -85,6 +85,7 @@ ...@@ -85,6 +85,7 @@
using namespace std; using namespace std;
using namespace Mantid::API; using namespace Mantid::API;
using namespace MantidQt::MantidWidgets;
using Mantid::Kernel::DateAndTime; using Mantid::Kernel::DateAndTime;
using MantidQt::SliceViewer::SliceViewerWindow; using MantidQt::SliceViewer::SliceViewerWindow;
...@@ -2049,7 +2050,7 @@ InstrumentWidget* MantidUI::getInstrumentView(const QString & wsName, int tab) ...@@ -2049,7 +2050,7 @@ InstrumentWidget* MantidUI::getInstrumentView(const QString & wsName, int tab)
InstrumentWindow *insWin = new InstrumentWindow( InstrumentWindow *insWin = new InstrumentWindow(
wsName, QString("Instrument"), appWindow(), windowName); wsName, QString("Instrument"), appWindow(), windowName);
insWin->getInstrumentWidget()->selectTab(tab); insWin->selectTab(tab);
appWindow()->addMdiSubWindow(insWin); appWindow()->addMdiSubWindow(insWin);
...@@ -2075,6 +2076,7 @@ MdiSubWindow *MantidUI::getInstrumentWindow(const QString & wsName, int tab) ...@@ -2075,6 +2076,7 @@ MdiSubWindow *MantidUI::getInstrumentWindow(const QString & wsName, int tab)
void MantidUI::showMantidInstrument(const QString& wsName) void MantidUI::showMantidInstrument(const QString& wsName)
{ {
InstrumentWidget *insWin = getInstrumentView(wsName); InstrumentWidget *insWin = getInstrumentView(wsName);
if (!insWin) if (!insWin)
{ {
m_lastShownInstrumentWin = NULL; m_lastShownInstrumentWin = NULL;
......
...@@ -38,7 +38,7 @@ class MantidDockWidget; ...@@ -38,7 +38,7 @@ class MantidDockWidget;
class AlgorithmDockWidget; class AlgorithmDockWidget;
class RemoteClusterDockWidget; class RemoteClusterDockWidget;
class AlgorithmMonitor; class AlgorithmMonitor;
class InstrumentWidget;
namespace MantidQt namespace MantidQt
{ {
namespace API namespace API
...@@ -48,6 +48,7 @@ namespace MantidQt ...@@ -48,6 +48,7 @@ namespace MantidQt
namespace MantidWidgets namespace MantidWidgets
{ {
class FitPropertyBrowser; class FitPropertyBrowser;
class InstrumentWidget;
} }
namespace SliceViewer namespace SliceViewer
{ {
...@@ -418,7 +419,7 @@ signals: ...@@ -418,7 +419,7 @@ signals:
void manageMantidWorkspaces(); void manageMantidWorkspaces();
//Python related functions //Python related functions
InstrumentWidget* getInstrumentView(const QString & wsName, int tab = -1); MantidQt::MantidWidgets::InstrumentWidget* getInstrumentView(const QString & wsName, int tab = -1);
MdiSubWindow *getInstrumentWindow(const QString & wsName, int tab = -1); MdiSubWindow *getInstrumentWindow(const QString & wsName, int tab = -1);
...@@ -561,7 +562,7 @@ private: ...@@ -561,7 +562,7 @@ private:
// keep track of the last shown, which will be refreshed or killed/rebuilt if showing only one inst. window // keep track of the last shown, which will be refreshed or killed/rebuilt if showing only one inst. window
// QPointer handles when events, etc. destroy these windows // QPointer handles when events, etc. destroy these windows
QPointer<InstrumentWidget> m_lastShownInstrumentWin; QPointer<MantidQt::MantidWidgets::InstrumentWidget> m_lastShownInstrumentWin;
QPointer<MantidQt::SliceViewer::SliceViewerWindow> m_lastShownSliceViewWin; QPointer<MantidQt::SliceViewer::SliceViewerWindow> m_lastShownSliceViewWin;
QPointer<MantidQt::SpectrumView::SpectrumView> m_lastShownSpectrumViewerWin; QPointer<MantidQt::SpectrumView::SpectrumView> m_lastShownSpectrumViewerWin;
QPointer<MultiLayer> m_lastShownColorFillWin; QPointer<MultiLayer> m_lastShownColorFillWin;
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#include "MantidAPI/IMDWorkspace.h" #include "MantidAPI/IMDWorkspace.h"
#include "MantidQtAPI/MantidColorMap.h" #include "MantidQtAPI/MantidColorMap.h"
#include "MantidQtAPI/WorkspaceObserver.h" #include "MantidQtAPI/WorkspaceObserver.h"
#include "MantidQtMantidWidgets/InstrumentWidget.h" #include <InstrumentWidget.h>
#include <fstream> #include <fstream>
#include <float.h> #include <float.h>
......
...@@ -683,17 +683,6 @@ private: ...@@ -683,17 +683,6 @@ private:
Grid(const Grid&); Grid(const Grid&);
}; };
namespace GraphOptions
{
%TypeHeaderCode
#include "MantidQtAPI/GraphOptions.h"
%End
enum ScaleType {Linear, Log10};
enum Axis{Left, Right, Bottom, Top};
};
namespace MantidQt namespace MantidQt
{ {
%TypeHeaderCode %TypeHeaderCode
...@@ -1375,313 +1364,6 @@ private: ...@@ -1375,313 +1364,6 @@ private:
MantidMatrix(const MantidMatrix&); MantidMatrix(const MantidMatrix&);
}; };
class InstrumentWidgetTab: QFrame
{
%TypeHeaderCode
#include "../MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentWidgetTab.h"
%End
public:
// This is a duplicate from the same enum in InstrumentWidget, just so you
// can do like InstrumentWidgetRenderTab.FULL3D
enum SurfaceType { FULL3D, CYLINDRICAL_X, CYLINDRICAL_Y, CYLINDRICAL_Z,
SPHERICAL_X, SPHERICAL_Y, SPHERICAL_Z,
RENDERMODE_SIZE };
private:
InstrumentWidgetTab(const InstrumentWidgetTab &);
};
class InstrumentWidget: MdiSubWindow
{
%TypeHeaderCode
#include "../MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentWidget.h"
%End
%Docstring
The InstrumentWidget contains functionality for exploring
a 3D model of an instrument. It is a tabbed widget offering
rendering, picking, masking and grouping functions. There is
also a tree view of the instrument hierarchy.
For further help see the functions defined on each of the following
- InstrumentWidgetRenderTab
- InstrumentWidgetPickTab
- InstrumentWidgetMaskTab
%End
public:
// Note this enum is also defined in InstrumentWidgetTab
enum SurfaceType { FULL3D, CYLINDRICAL_X, CYLINDRICAL_Y, CYLINDRICAL_Z,
SPHERICAL_X, SPHERICAL_Y, SPHERICAL_Z,
RENDERMODE_SIZE };
enum Tab { RENDER, PICK, MASK, TREE };
InstrumentWidgetTab * getTab(const QString & title) const;
%Docstring
Returns a handler to the requested tab
Args:
title The full title of a tab in the window
Returns:
a pointer to the requested tab widget
%End
InstrumentWidgetTab * getTab(const Tab tab) const;
%Docstring
Returns a handler to the requested tab
Args:
tab One of the Tab enumeration types:
InstrumentWidget.RENDER,InstrumentWidget.PICK,
InstrumentWidget.MASK,InstrumentWidget.TREE
Returns:
a pointer to the requested tab widget
%End
void setBinRange(double min_value, double max_value);
%Docstring
Updates the integration range over which the colours
are calculated
Args:
min_value The minimum value over which the data is integrated
max_value The maximum value over which the data is integrated
%End
bool overlay(const QString & wsName);
%Docstring
Overlays a workspace onto an unwrapped surface on the instrument view.
Raises a dialog box if the current surface is not unwrapped.
Args:
wsName The name of the workspace
Returns:
A boolean indicating if the overlay was successful or not
%End
// -- Deprecated in favour of specific tab functions --
// Deprecation is done in mantidplot.py module rather than using
// sip /Deprecated/annotation so that the message can be customised
void changeColormap();
void changeColormap(const QString & file);
void setColorMapMinValue(double);
void setColorMapMaxValue(double);
void setColorMapRange(double, double);
void selectComponent(const QString &);
void setScaleType(GraphOptions::ScaleType);
void setViewType(const QString &);
private:
InstrumentWidget();
InstrumentWidget(const InstrumentWidget &);
};
class InstrumentWidgetRenderTab: InstrumentWidgetTab
{
%TypeHeaderCode
#include "../MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentWidgetRenderTab.h"
%End
public:
GraphOptions::ScaleType getScaleType() const;
%Docstring
Returns the current scale type. 0=Linear, 1=Log10
%End
void setScaleType(GraphOptions::ScaleType type);
%Docstring
Set the scale type for the colour bar.
Args:
type The new type Options are: GraphOptions.Linear, GraphOptions.Log10
%End
void setAxis(const QString& axisName);
%Docstring
Set the current viewing axis by name.
Args:
axisName The name of a view in a string: X+,X-,Y+,Y-,Z+,Z-
%End
void setMinValue(double value, bool apply = true);
%Docstring
Set the minimum value for the colour scale
Args:
value The new value for the minimum
%End
void setMaxValue(double value, bool apply = true);
%Docstring
Set the maximum value for the colour scale
Args:
value The new value for the maximum
%End
void setRange(double minValue, double maxValue, bool apply = true);
%Docstring
Set the range of the colour bar
Args:
minValue The new value for the minimum
maxValue The new value for the maximum
%End
void showAxes(bool on);
%Docstring
Set the axes on/off
Args:
on True/False indicating whether the axes are visible
%End
void setColorMapAutoscaling(bool on);
%Docstring
Set whether the colour scale should auto scale when the data is updated
Args:
on True/False indicating whether auto scaling is active
%End
void displayDetectorsOnly(bool yes);
%Docstring
Set whether only detectors should be shown.
Args:
yes True/False indicating whether only detectors are shown
%End
void enableGL(bool on);
%Docstring
Toggle the use of OpenGL. This can only be used for the unwrapped views.
Args:
on True/False indicating whether OpenGL should be used.
%End
void changeColorMap(const QString & filename = "");
%Docstring
Change the color map for the given one. If blank then a dialog is raised
Args:
filename A filename giving the full path to a color map file
%End
void setSurfaceType(int type);
%Docstring
Set the surface type of the current window.
Args:
type A known suface type: FULL3D, CYLINDRICAL_X, CYLINDRICAL_Y,
CYLINDRICAL_Z,SPHERICAL_X, SPHERICAL_Y,
SPHERICAL_Z
%End
void flipUnwrappedView(bool on);
%Docstring
Set whether an unwrapped view is flipped
Args:
on True/False indicatingif to flip the view
%End
void saveImage(QString filename = "");
%Docstring
Save the current display buffer to an image file. The format is chosen by the filename extension and must
be one of .bmp,.jpeg,.jpeg,.png,.ppm,.tiff,.xbm,.xpm
Args:
filename The filename for the saved image. An empty string raises a dialog box.
%End
private:
InstrumentWidgetRenderTab();
InstrumentWidgetRenderTab(const InstrumentWidgetRenderTab &);
};
class InstrumentWidgetPickTab: InstrumentWidgetTab
{
%TypeHeaderCode
#include "../MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentWidgetPickTab.h"
%End
public:
enum ToolType {Zoom, PixelSelect, TubeSelect, PeakSelect, PeakErase};
void selectTool(const ToolType tool);
%Docstring
Select the active tool.
Args:
tool One of InstrumentWidgetPickTab.{Zoom, PixelSelect, TubeSelect, PeakSelect, PeakErase}
%End
private:
InstrumentWidgetPickTab();
InstrumentWidgetPickTab(const InstrumentWidgetPickTab &);
};
class InstrumentWidgetMaskTab: InstrumentWidgetTab
{
%TypeHeaderCode
#include "../MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentWidgetMaskTab.h"
%End
public:
enum Mode {Mask, Group};
enum Activity {Move,Select,DrawEllipse,DrawRectangle,DrawEllipticalRing,DrawRectangularRing};
void setMode(Mode mode);
%Docstring
Set the mode to either group/mask
Args:
mode One of the Mode enumerations InstrumentWidgetMaskTab.{Mask, Group}
%End
void selectTool(Activity tool);
%Docstring
Set the mode to either group/mask
Args:
tool One of the Activity enumerations InstrumentWidgetMaskTab.{Move,Select,DrawEllipse,DrawRectangle,DrawEllipticalRing,DrawRectangularRing}
%End
private:
InstrumentWidgetMaskTab();
InstrumentWidgetMaskTab(const InstrumentWidgetMaskTab &);
};
class InstrumentWidgetTreeTab: InstrumentWidgetTab
{
%TypeHeaderCode
#include "../MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentWidgetTreeTab.h"
%End
public:
void selectComponentByName(const QString& name);
%Docstring
Sets the tree tab to center the view on the named component
Args:
name The name of a component in the instrument
%End
private:
InstrumentWidgetTreeTab();
InstrumentWidgetTreeTab(const InstrumentWidgetTreeTab &);
};
class MantidUI: QObject class MantidUI: QObject
{ {
...@@ -1720,7 +1402,7 @@ public: ...@@ -1720,7 +1402,7 @@ public:
// Methods relating to creating or getting handles to GUI objects // Methods relating to creating or getting handles to GUI objects
MantidMatrix* getMantidMatrix(const QString &); MantidMatrix* getMantidMatrix(const QString &);
QString getSelectedWorkspaceName(); QString getSelectedWorkspaceName();
InstrumentWidget*