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 )
include_directories ( ../MantidQt/API/inc )
include_directories ( ../MantidQt/MantidWidgets/inc )
include_directories ( ../MantidQt/MantidWidgets/inc/MantidQtMantidWidgets)
include_directories ( ../MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/InstrumentView)
include_directories ( ../MantidQt/SliceViewer/inc )
include_directories ( ../MantidQt/SpectrumViewer/inc )
include_directories ( ../MantidQt/Factory/inc )
......
......@@ -8,8 +8,8 @@
try:
import pymantidplot
from pymantidplot import *
except ImportError:
raise ImportError('Could not import mantidplot (when trying to import pymantidplot). Something is broken in this installation, please check.')
except ImportError, Exc:
raise ImportError('Could not import mantidplot (when trying to import pymantidplot). Something is broken in this installation, please check.'+str(Exc))
try:
# import pyplot and also bring it into the standard MantidPlot namespace
......
......@@ -17,16 +17,18 @@ import os
import time
import mantid.api
import mantidqtpython
from mantidqtpython import GraphOptions
# 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
from _qti import (PlotSymbol, ImageSymbol, ArrowMarker, ImageMarker,
GraphOptions, InstrumentWidget, InstrumentWidgetRenderTab, InstrumentWidgetPickTab,
InstrumentWidgetMaskTab)
from _qti import (PlotSymbol, ImageSymbol, ArrowMarker, ImageMarker)
print dir(mantidqtpython)
# Make the ApplicationWindow instance accessible from the mantidplot namespace
from _qti import app
# Alias threadsafe_call so users have a more understandable name
gui_cmd = threadsafe_call
......@@ -677,6 +679,8 @@ def getMantidMatrix(name):
"""Get a handle to the named Mantid matrix"""
return new_proxy(proxies.MantidMatrix, _qti.app.mantidUI.getMantidMatrix, name)
InstrumentWidget = mantidqtpython.MantidQt.MantidWidgets.InstrumentWidget
def getInstrumentView(name, tab=InstrumentWidget.RENDER):
"""Create an instrument view window based on the given workspace.
......@@ -866,14 +870,14 @@ for name in MantidUIImports:
# Set some aliases for Layer enumerations so that old code will still work
Layer = _qti.Layer
Layer.Log10 = _qti.GraphOptions.Log10
Layer.Linear = _qti.GraphOptions.Linear
Layer.Left = _qti.GraphOptions.Left
Layer.Right = _qti.GraphOptions.Right
Layer.Bottom = _qti.GraphOptions.Bottom
Layer.Top = _qti.GraphOptions.Top
DistrFlag = mantidqtpython.MantidQt
Layer.Log10 = mantidqtpython.GraphOptions.Log10
Layer.Linear = mantidqtpython.GraphOptions.Linear
Layer.Left = mantidqtpython.GraphOptions.Left
Layer.Right = mantidqtpython.GraphOptions.Right
Layer.Bottom = mantidqtpython.GraphOptions.Bottom
Layer.Top = mantidqtpython.GraphOptions.Top
DistrFlag = mantidqtpython.MantidQt.DistributionFlag
DistrFlag.DistrDefault = mantidqtpython.MantidQt.DistributionDefault
DistrFlag.DistrTrue = mantidqtpython.MantidQt.DistributionTrue
DistrFlag.DistrFalse = mantidqtpython.MantidQt.DistributionFalse
......
......@@ -8,6 +8,7 @@
#include <ProjectionSurface.h>
using namespace Mantid::API;
using namespace MantidQt::MantidWidgets;
InstrumentWindow::InstrumentWindow(const QString &wsName, const QString &label,
ApplicationWindow *parent,
......
......@@ -9,7 +9,13 @@
#include <boost/shared_ptr.hpp>
class ApplicationWindow;
class InstrumentWidget;
namespace MantidQt
{
namespace MantidWidgets
{
class InstrumentWidget;
}
}
using namespace Mantid;
......@@ -25,7 +31,7 @@ public:
void loadFromProject(const std::string &lines, ApplicationWindow *app,
const int fileVersion);
std::string saveToProject(ApplicationWindow *app);
InstrumentWidget *getInstrumentWidget() { return m_instrumentWidget; }
MantidQt::MantidWidgets::InstrumentWidget *getInstrumentWidget() { return m_instrumentWidget; }
void selectTab(int tab);
private:
......@@ -41,7 +47,7 @@ private:
virtual void clearADSHandle();
private:
InstrumentWidget *m_instrumentWidget;
MantidQt::MantidWidgets::InstrumentWidget *m_instrumentWidget;
};
#endif // INSTRUMENTWINDOW_H
\ No newline at end of file
......@@ -85,6 +85,7 @@
using namespace std;
using namespace Mantid::API;
using namespace MantidQt::MantidWidgets;
using Mantid::Kernel::DateAndTime;
using MantidQt::SliceViewer::SliceViewerWindow;
......@@ -2049,7 +2050,7 @@ InstrumentWidget* MantidUI::getInstrumentView(const QString & wsName, int tab)
InstrumentWindow *insWin = new InstrumentWindow(
wsName, QString("Instrument"), appWindow(), windowName);
insWin->getInstrumentWidget()->selectTab(tab);
insWin->selectTab(tab);
appWindow()->addMdiSubWindow(insWin);
......@@ -2075,6 +2076,7 @@ MdiSubWindow *MantidUI::getInstrumentWindow(const QString & wsName, int tab)
void MantidUI::showMantidInstrument(const QString& wsName)
{
InstrumentWidget *insWin = getInstrumentView(wsName);
if (!insWin)
{
m_lastShownInstrumentWin = NULL;
......
......@@ -38,7 +38,7 @@ class MantidDockWidget;
class AlgorithmDockWidget;
class RemoteClusterDockWidget;
class AlgorithmMonitor;
class InstrumentWidget;
namespace MantidQt
{
namespace API
......@@ -48,6 +48,7 @@ namespace MantidQt
namespace MantidWidgets
{
class FitPropertyBrowser;
class InstrumentWidget;
}
namespace SliceViewer
{
......@@ -418,7 +419,7 @@ signals:
void manageMantidWorkspaces();
//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);
......@@ -561,7 +562,7 @@ private:
// 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<InstrumentWidget> m_lastShownInstrumentWin;
QPointer<MantidQt::MantidWidgets::InstrumentWidget> m_lastShownInstrumentWin;
QPointer<MantidQt::SliceViewer::SliceViewerWindow> m_lastShownSliceViewWin;
QPointer<MantidQt::SpectrumView::SpectrumView> m_lastShownSpectrumViewerWin;
QPointer<MultiLayer> m_lastShownColorFillWin;
......
......@@ -42,7 +42,7 @@
#include "MantidAPI/IMDWorkspace.h"
#include "MantidQtAPI/MantidColorMap.h"
#include "MantidQtAPI/WorkspaceObserver.h"
#include "MantidQtMantidWidgets/InstrumentWidget.h"
#include <InstrumentWidget.h>
#include <fstream>
#include <float.h>
......
......@@ -683,17 +683,6 @@ private:
Grid(const Grid&);
};
namespace GraphOptions
{
%TypeHeaderCode
#include "MantidQtAPI/GraphOptions.h"
%End
enum ScaleType {Linear, Log10};
enum Axis{Left, Right, Bottom, Top};
};
namespace MantidQt
{
%TypeHeaderCode
......@@ -1375,313 +1364,6 @@ private:
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
{
......@@ -1720,7 +1402,7 @@ public:
// Methods relating to creating or getting handles to GUI objects
MantidMatrix* getMantidMatrix(const QString &);
QString getSelectedWorkspaceName();
InstrumentWidget* getInstrumentView(const QString &, int tab = -1);
MantidQt::MantidWidgets::InstrumentWidget* getInstrumentView(const QString &, int tab = -1);
%MethodCode
sipRes = sipCpp->getInstrumentView(*a0,a1);
if(sipRes) sipRes->hide();
......
......@@ -50,51 +50,51 @@ set ( SRC_FILES
src/pqHelpWindow.cxx
src/pythonCalc.cpp
src/LineEditWithClear.cpp
src/BinDialog.cpp
src/CollapsiblePanel.cpp
src/ColorMapWidget.cpp
src/CompAssemblyActor.cpp
src/ComponentActor.cpp
src/DetXMLFile.cpp
src/GLActor.cpp
src/GLActorCollection.cpp
src/GLActorVisitor.cpp
src/GLColor.cpp
src/GLObject.cpp
src/ICompAssemblyActor.cpp
src/InstrumentActor.cpp
src/InstrumentTreeModel.cpp
src/InstrumentTreeWidget.cpp
src/InstrumentWidget.cpp
src/InstrumentWidgetMaskTab.cpp
src/InstrumentWidgetPickTab.cpp
src/InstrumentWidgetRenderTab.cpp
src/InstrumentWidgetTab.cpp
src/InstrumentWidgetTreeTab.cpp
src/MantidGLWidget.cpp
src/MaskBinsData.cpp
src/ObjCompAssemblyActor.cpp
src/ObjComponentActor.cpp
src/OneCurvePlot.cpp
src/OpenGLError.cpp
src/PanelsSurface.cpp
src/PeakMarker2D.cpp
src/PeakOverlay.cpp
src/Projection3D.cpp
src/ProjectionSurface.cpp
src/RectangularDetectorActor.cpp
src/RectF.cpp
src/RotationSurface.cpp
src/SampleActor.cpp
src/Shape2D.cpp
src/Shape2DCollection.cpp
src/SimpleWidget.cpp
src/UCorrectionDialog.cpp
src/UnwrappedCylinder.cpp
src/UnwrappedSphere.cpp
src/UnwrappedSurface.cpp
src/Viewport.cpp
src/XIntegrationControl.cpp
src/InstrumentView/BinDialog.cpp
src/InstrumentView/CollapsiblePanel.cpp
src/InstrumentView/ColorMapWidget.cpp
src/InstrumentView/CompAssemblyActor.cpp
src/InstrumentView/ComponentActor.cpp
src/InstrumentView/DetXMLFile.cpp
src/InstrumentView/GLActor.cpp
src/InstrumentView/GLActorCollection.cpp
src/InstrumentView/GLActorVisitor.cpp
src/InstrumentView/GLColor.cpp
src/InstrumentView/GLObject.cpp
src/InstrumentView/ICompAssemblyActor.cpp
src/InstrumentView/InstrumentActor.cpp
src/InstrumentView/InstrumentTreeModel.cpp
src/InstrumentView/InstrumentTreeWidget.cpp
src/InstrumentView/InstrumentWidget.cpp
src/InstrumentView/InstrumentWidgetMaskTab.cpp
src/InstrumentView/InstrumentWidgetPickTab.cpp
src/InstrumentView/InstrumentWidgetRenderTab.cpp
src/InstrumentView/InstrumentWidgetTab.cpp
src/InstrumentView/InstrumentWidgetTreeTab.cpp
src/InstrumentView/MantidGLWidget.cpp
src/InstrumentView/MaskBinsData.cpp
src/InstrumentView/ObjCompAssemblyActor.cpp
src/InstrumentView/ObjComponentActor.cpp
src/InstrumentView/OneCurvePlot.cpp
src/InstrumentView/OpenGLError.cpp
src/InstrumentView/PanelsSurface.cpp
src/InstrumentView/PeakMarker2D.cpp
src/InstrumentView/PeakOverlay.cpp
src/InstrumentView/Projection3D.cpp
src/InstrumentView/ProjectionSurface.cpp
src/InstrumentView/RectangularDetectorActor.cpp
src/InstrumentView/RectF.cpp
src/InstrumentView/RotationSurface.cpp
src/InstrumentView/SampleActor.cpp
src/InstrumentView/Shape2D.cpp
src/InstrumentView/Shape2DCollection.cpp
src/InstrumentView/SimpleWidget.cpp
src/InstrumentView/UCorrectionDialog.cpp
src/InstrumentView/UnwrappedCylinder.cpp