Commit b90326de authored by Antti Soininen's avatar Antti Soininen
Browse files

Access instrument actor always via InstrumentWidget.

This prevents segfaulting if the instrument changes which would
invalidate all pointers pointing to the actor.

Re #16957
parent 164ece1c
#ifndef INSTRUMENTTREEMODEL_H #ifndef INSTRUMENTTREEMODEL_H
#define INSTRUMENTTREEMODEL_H #define INSTRUMENTTREEMODEL_H
#include "MantidQtMantidWidgets/InstrumentView/InstrumentWidget.h"
#include <QAbstractItemModel> #include <QAbstractItemModel>
#include <QModelIndex> //#include <QModelIndex>
#include <boost/shared_ptr.hpp> //#include <boost/shared_ptr.hpp>
namespace MantidQt { namespace MantidQt {
namespace MantidWidgets { namespace MantidWidgets {
class InstrumentActor;
/** /**
* The InstrumentTreeModel is a class used by a QTreeView * The InstrumentTreeModel is a class used by a QTreeView
...@@ -23,7 +24,7 @@ class InstrumentActor; ...@@ -23,7 +24,7 @@ class InstrumentActor;
class InstrumentTreeModel : public QAbstractItemModel { class InstrumentTreeModel : public QAbstractItemModel {
Q_OBJECT Q_OBJECT
public: public:
InstrumentTreeModel(const InstrumentActor *, QObject *parent); InstrumentTreeModel(const InstrumentWidget *instrWidget, QObject *parent);
~InstrumentTreeModel() override; ~InstrumentTreeModel() override;
QVariant data(const QModelIndex &index, int role) const override; QVariant data(const QModelIndex &index, int role) const override;
...@@ -37,8 +38,8 @@ public: ...@@ -37,8 +38,8 @@ public:
int columnCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override;
private: private:
const InstrumentActor * /// instrument widget to which the model corresponds
m_instrumentActor; ///< actor of instrument to which the model corresponds const InstrumentWidget *m_instrWidget;
}; };
} // MantidWidgets } // MantidWidgets
} // MantidQt } // MantidQt
......
...@@ -24,7 +24,7 @@ class EXPORT_OPT_MANTIDQT_MANTIDWIDGETS InstrumentTreeWidget ...@@ -24,7 +24,7 @@ class EXPORT_OPT_MANTIDQT_MANTIDWIDGETS InstrumentTreeWidget
Q_OBJECT Q_OBJECT
public: public:
explicit InstrumentTreeWidget(QWidget *w); explicit InstrumentTreeWidget(QWidget *w);
void setInstrumentActor(InstrumentActor *instrActor); void setInstrumentWidget(InstrumentWidget *w);
void getSelectedBoundingBox(const QModelIndex &index, double &xmax, void getSelectedBoundingBox(const QModelIndex &index, double &xmax,
double &ymax, double &zmax, double &xmin, double &ymax, double &zmax, double &xmin,
double &ymin, double &zmin); double &ymin, double &zmin);
...@@ -39,7 +39,7 @@ signals: ...@@ -39,7 +39,7 @@ signals:
void componentSelected(const Mantid::Geometry::ComponentID); void componentSelected(const Mantid::Geometry::ComponentID);
private: private:
InstrumentActor *m_instrActor; InstrumentWidget *m_instrWidget;
InstrumentTreeModel *m_treeModel; InstrumentTreeModel *m_treeModel;
}; };
} // MantidWidgets } // MantidWidgets
......
...@@ -115,7 +115,8 @@ public: ...@@ -115,7 +115,8 @@ public:
void setScaleType(GraphOptions::ScaleType type); void setScaleType(GraphOptions::ScaleType type);
void setExponent(double nth_power); void setExponent(double nth_power);
void setViewType(const QString &type); void setViewType(const QString &type);
InstrumentActor *getInstrumentActor() const { return m_instrumentActor; } const InstrumentActor &getInstrumentActor() const { return *m_instrumentActor; }
InstrumentActor &getInstrumentActor() { return *m_instrumentActor; }
void resetInstrument(bool resetGeometry); void resetInstrument(bool resetGeometry);
void selectTab(int tab); void selectTab(int tab);
void selectTab(Tab tab) { selectTab(int(tab)); } void selectTab(Tab tab) { selectTab(int(tab)); }
...@@ -256,7 +257,7 @@ protected: ...@@ -256,7 +257,7 @@ protected:
/// InstrumentActor holds a pointer to the workspace itself. /// InstrumentActor holds a pointer to the workspace itself.
QString m_workspaceName; QString m_workspaceName;
/// Instrument actor is an interface to the instrument /// Instrument actor is an interface to the instrument
InstrumentActor *m_instrumentActor; std::unique_ptr<InstrumentActor> m_instrumentActor;
/// Option to use or not OpenGL display for "unwrapped" view, 3D is always in /// Option to use or not OpenGL display for "unwrapped" view, 3D is always in
/// OpenGL /// OpenGL
bool m_useOpenGL; bool m_useOpenGL;
......
...@@ -188,7 +188,7 @@ class ComponentInfoController : public QObject { ...@@ -188,7 +188,7 @@ class ComponentInfoController : public QObject {
public: public:
/// Constructor. /// Constructor.
ComponentInfoController(InstrumentWidgetPickTab *tab, ComponentInfoController(InstrumentWidgetPickTab *tab,
InstrumentActor *instrActor, QTextEdit *infoDisplay); const InstrumentWidget *instrWidget, QTextEdit *infoDisplay);
public slots: public slots:
void displayInfo(size_t pickID); void displayInfo(size_t pickID);
void displayComparePeaksInfo( void displayComparePeaksInfo(
...@@ -208,7 +208,7 @@ private: ...@@ -208,7 +208,7 @@ private:
QString getPeakOverlayInfo(); QString getPeakOverlayInfo();
InstrumentWidgetPickTab *m_tab; InstrumentWidgetPickTab *m_tab;
InstrumentActor *m_instrActor; const InstrumentWidget *m_instrWidget;
QTextEdit *m_selectionInfoDisplay; QTextEdit *m_selectionInfoDisplay;
bool m_freezePlot; bool m_freezePlot;
...@@ -234,7 +234,7 @@ public: ...@@ -234,7 +234,7 @@ public:
}; };
DetectorPlotController(InstrumentWidgetPickTab *tab, DetectorPlotController(InstrumentWidgetPickTab *tab,
InstrumentActor *instrActor, OneCurvePlot *plot); InstrumentWidget *instrWidget, OneCurvePlot *plot);
void setEnabled(bool on) { m_enabled = on; } void setEnabled(bool on) { m_enabled = on; }
void setPlotData(size_t pickID); void setPlotData(size_t pickID);
void setPlotData(QList<int> detIDs); void setPlotData(QList<int> detIDs);
...@@ -273,7 +273,7 @@ private: ...@@ -273,7 +273,7 @@ private:
const Mantid::Kernel::V3D &normal); const Mantid::Kernel::V3D &normal);
InstrumentWidgetPickTab *m_tab; InstrumentWidgetPickTab *m_tab;
InstrumentActor *m_instrActor; InstrumentWidget *m_instrWidget;
OneCurvePlot *m_plot; OneCurvePlot *m_plot;
PlotType m_plotType; PlotType m_plotType;
......
...@@ -19,9 +19,9 @@ namespace MantidWidgets { ...@@ -19,9 +19,9 @@ namespace MantidWidgets {
/** /**
* Constructor for tree model to display instrument tree * Constructor for tree model to display instrument tree
*/ */
InstrumentTreeModel::InstrumentTreeModel(const InstrumentActor *actor, InstrumentTreeModel::InstrumentTreeModel(const InstrumentWidget *instrWidget,
QObject *parent) QObject *parent)
: QAbstractItemModel(parent), m_instrumentActor(actor) {} : QAbstractItemModel(parent), m_instrWidget(instrWidget) {}
/** /**
* Destructor for instrument display tree * Destructor for instrument display tree
...@@ -37,7 +37,7 @@ InstrumentTreeModel::~InstrumentTreeModel() {} ...@@ -37,7 +37,7 @@ InstrumentTreeModel::~InstrumentTreeModel() {}
int InstrumentTreeModel::columnCount(const QModelIndex &parent) const { int InstrumentTreeModel::columnCount(const QModelIndex &parent) const {
try { try {
if (parent.isValid()) { if (parent.isValid()) {
auto instr = m_instrumentActor->getInstrument(); auto instr = m_instrWidget->getInstrumentActor().getInstrument();
boost::shared_ptr<const IComponent> comp = instr->getComponentByID( boost::shared_ptr<const IComponent> comp = instr->getComponentByID(
static_cast<Mantid::Geometry::ComponentID>(parent.internalPointer())); static_cast<Mantid::Geometry::ComponentID>(parent.internalPointer()));
boost::shared_ptr<const ICompAssembly> objcomp = boost::shared_ptr<const ICompAssembly> objcomp =
...@@ -62,7 +62,7 @@ QVariant InstrumentTreeModel::data(const QModelIndex &index, int role) const { ...@@ -62,7 +62,7 @@ QVariant InstrumentTreeModel::data(const QModelIndex &index, int role) const {
if (role != Qt::DisplayRole) if (role != Qt::DisplayRole)
return QVariant(); return QVariant();
auto instr = m_instrumentActor->getInstrument(); auto instr = m_instrWidget->getInstrumentActor().getInstrument();
if (!index.isValid()) // not valid has to return the root node if (!index.isValid()) // not valid has to return the root node
return QString(instr->getName().c_str()); return QString(instr->getName().c_str());
...@@ -109,7 +109,7 @@ QModelIndex InstrumentTreeModel::index(int row, int column, ...@@ -109,7 +109,7 @@ QModelIndex InstrumentTreeModel::index(int row, int column,
//"<<parent.isValid()<<'\n'; //"<<parent.isValid()<<'\n';
try { try {
boost::shared_ptr<const ICompAssembly> parentItem; boost::shared_ptr<const ICompAssembly> parentItem;
auto instr = m_instrumentActor->getInstrument(); auto instr = m_instrWidget->getInstrumentActor().getInstrument();
if (!parent.isValid()) // invalid parent, has to be the root node i.e if (!parent.isValid()) // invalid parent, has to be the root node i.e
// instrument // instrument
return createIndex(row, column, instr->getComponentID()); return createIndex(row, column, instr->getComponentID());
...@@ -152,7 +152,7 @@ QModelIndex InstrumentTreeModel::parent(const QModelIndex &index) const { ...@@ -152,7 +152,7 @@ QModelIndex InstrumentTreeModel::parent(const QModelIndex &index) const {
// for root return empty. // for root return empty.
return QModelIndex(); return QModelIndex();
auto instr = m_instrumentActor->getInstrument(); auto instr = m_instrWidget->getInstrumentActor().getInstrument();
if (instr->getComponentID() == if (instr->getComponentID() ==
static_cast<Mantid::Geometry::ComponentID>(index.internalPointer())) static_cast<Mantid::Geometry::ComponentID>(index.internalPointer()))
...@@ -193,7 +193,7 @@ int InstrumentTreeModel::rowCount(const QModelIndex &parent) const { ...@@ -193,7 +193,7 @@ int InstrumentTreeModel::rowCount(const QModelIndex &parent) const {
{ {
return 1; // boost::dynamic_pointer_cast<ICompAssembly>(m_instrument)->nelements(); return 1; // boost::dynamic_pointer_cast<ICompAssembly>(m_instrument)->nelements();
} else { } else {
auto instr = m_instrumentActor->getInstrument(); auto instr = m_instrWidget->getInstrumentActor().getInstrument();
if (instr->getComponentID() == static_cast<Mantid::Geometry::ComponentID>( if (instr->getComponentID() == static_cast<Mantid::Geometry::ComponentID>(
parent.internalPointer())) { parent.internalPointer())) {
return instr->nelements(); return instr->nelements();
......
...@@ -18,14 +18,14 @@ namespace MantidQt { ...@@ -18,14 +18,14 @@ namespace MantidQt {
namespace MantidWidgets { namespace MantidWidgets {
InstrumentTreeWidget::InstrumentTreeWidget(QWidget *w) InstrumentTreeWidget::InstrumentTreeWidget(QWidget *w)
: QTreeView(w), m_instrActor(NULL), m_treeModel(NULL) { : QTreeView(w), m_instrWidget(nullptr), m_treeModel(nullptr) {
connect(this, SIGNAL(clicked(const QModelIndex)), this, connect(this, SIGNAL(clicked(const QModelIndex)), this,
SLOT(sendComponentSelectedSignal(const QModelIndex))); SLOT(sendComponentSelectedSignal(const QModelIndex)));
} }
void InstrumentTreeWidget::setInstrumentActor(InstrumentActor *instrActor) { void InstrumentTreeWidget::setInstrumentWidget(InstrumentWidget *w) {
m_instrActor = instrActor; m_instrWidget = w;
m_treeModel = new InstrumentTreeModel(instrActor, this); m_treeModel = new InstrumentTreeModel(w, this);
setModel(m_treeModel); setModel(m_treeModel);
setSelectionMode(SingleSelection); setSelectionMode(SingleSelection);
setSelectionBehavior(SelectRows); setSelectionBehavior(SelectRows);
...@@ -36,7 +36,7 @@ void InstrumentTreeWidget::getSelectedBoundingBox(const QModelIndex &index, ...@@ -36,7 +36,7 @@ void InstrumentTreeWidget::getSelectedBoundingBox(const QModelIndex &index,
double &zmax, double &xmin, double &zmax, double &xmin,
double &ymin, double &zmin) { double &ymin, double &zmin) {
Mantid::Geometry::Instrument_const_sptr instrument = Mantid::Geometry::Instrument_const_sptr instrument =
m_instrActor->getInstrument(); m_instrWidget->getInstrumentActor().getInstrument();
// Check whether its instrument // Check whether its instrument
boost::shared_ptr<const Mantid::Geometry::IComponent> selectedComponent; boost::shared_ptr<const Mantid::Geometry::IComponent> selectedComponent;
if (instrument->getComponentID() == if (instrument->getComponentID() ==
...@@ -66,7 +66,7 @@ void InstrumentTreeWidget::getSelectedBoundingBox(const QModelIndex &index, ...@@ -66,7 +66,7 @@ void InstrumentTreeWidget::getSelectedBoundingBox(const QModelIndex &index,
// int(instrument->getSample()->getComponentID()) << '\n'; // int(instrument->getSample()->getComponentID()) << '\n';
if (tmpObj->getComponentID() == if (tmpObj->getComponentID() ==
instrument->getSample()->getComponentID()) { instrument->getSample()->getComponentID()) {
boundBox = m_instrActor->getWorkspace() boundBox = m_instrWidget->getInstrumentActor().getWorkspace()
->sample() ->sample()
.getShape() .getShape()
.getBoundingBox(); .getBoundingBox();
...@@ -123,7 +123,7 @@ void InstrumentTreeWidget::sendComponentSelectedSignal( ...@@ -123,7 +123,7 @@ void InstrumentTreeWidget::sendComponentSelectedSignal(
Mantid::Geometry::ComponentID id = Mantid::Geometry::ComponentID id =
static_cast<Mantid::Geometry::ComponentID>(index.internalPointer()); static_cast<Mantid::Geometry::ComponentID>(index.internalPointer());
auto visitor = SetVisibleComponentVisitor(id); auto visitor = SetVisibleComponentVisitor(id);
m_instrActor->accept(visitor); m_instrWidget->getInstrumentActor().accept(visitor);
emit componentSelected(id); emit componentSelected(id);
} }
......
...@@ -195,7 +195,6 @@ InstrumentWidget::InstrumentWidget(const QString &wsName, QWidget *parent, ...@@ -195,7 +195,6 @@ InstrumentWidget::InstrumentWidget(const QString &wsName, QWidget *parent,
InstrumentWidget::~InstrumentWidget() { InstrumentWidget::~InstrumentWidget() {
if (m_instrumentActor) { if (m_instrumentActor) {
saveSettings(); saveSettings();
delete m_instrumentActor;
} }
} }
...@@ -250,8 +249,8 @@ void InstrumentWidget::init(bool resetGeometry, bool autoscaling, ...@@ -250,8 +249,8 @@ void InstrumentWidget::init(bool resetGeometry, bool autoscaling,
double scaleMin, double scaleMax, double scaleMin, double scaleMax,
bool setDefaultView) { bool setDefaultView) {
// Previously in (now removed) setWorkspaceName method // Previously in (now removed) setWorkspaceName method
m_instrumentActor = m_instrumentActor.reset(
new InstrumentActor(m_workspaceName, autoscaling, scaleMin, scaleMax); new InstrumentActor(m_workspaceName, autoscaling, scaleMin, scaleMax));
m_xIntegration->setTotalRange(m_instrumentActor->minBinValue(), m_xIntegration->setTotalRange(m_instrumentActor->minBinValue(),
m_instrumentActor->maxBinValue()); m_instrumentActor->maxBinValue());
m_xIntegration->setUnits(QString::fromStdString( m_xIntegration->setUnits(QString::fromStdString(
...@@ -275,7 +274,7 @@ void InstrumentWidget::init(bool resetGeometry, bool autoscaling, ...@@ -275,7 +274,7 @@ void InstrumentWidget::init(bool resetGeometry, bool autoscaling,
} }
setupColorMap(); setupColorMap();
} else { } else {
surface->resetInstrumentActor(m_instrumentActor); surface->resetInstrumentActor(m_instrumentActor.get());
updateInfoText(); updateInfoText();
} }
} }
...@@ -285,8 +284,6 @@ void InstrumentWidget::init(bool resetGeometry, bool autoscaling, ...@@ -285,8 +284,6 @@ void InstrumentWidget::init(bool resetGeometry, bool autoscaling,
* @param resetGeometry * @param resetGeometry
*/ */
void InstrumentWidget::resetInstrument(bool resetGeometry) { void InstrumentWidget::resetInstrument(bool resetGeometry) {
delete m_instrumentActor;
m_instrumentActor = nullptr;
init(resetGeometry, true, 0.0, 0.0, false); init(resetGeometry, true, 0.0, 0.0, false);
updateInstrumentDetectors(); updateInstrumentDetectors();
} }
...@@ -415,15 +412,15 @@ void InstrumentWidget::setSurfaceType(int type) { ...@@ -415,15 +412,15 @@ void InstrumentWidget::setSurfaceType(int type) {
// create the surface // create the surface
if (surfaceType == FULL3D) { if (surfaceType == FULL3D) {
surface = surface =
new Projection3D(m_instrumentActor, getInstrumentDisplayWidth(), new Projection3D(m_instrumentActor.get(), getInstrumentDisplayWidth(),
getInstrumentDisplayHeight()); getInstrumentDisplayHeight());
} else if (surfaceType <= CYLINDRICAL_Z) { } else if (surfaceType <= CYLINDRICAL_Z) {
surface = new UnwrappedCylinder(m_instrumentActor, sample_pos, axis); surface = new UnwrappedCylinder(m_instrumentActor.get(), sample_pos, axis);
} else if (surfaceType <= SPHERICAL_Z) { } else if (surfaceType <= SPHERICAL_Z) {
surface = new UnwrappedSphere(m_instrumentActor, sample_pos, axis); surface = new UnwrappedSphere(m_instrumentActor.get(), sample_pos, axis);
} else // SIDE_BY_SIDE } else // SIDE_BY_SIDE
{ {
surface = new PanelsSurface(m_instrumentActor, sample_pos, axis); surface = new PanelsSurface(m_instrumentActor.get(), sample_pos, axis);
} }
} catch (InstrumentHasNoSampleError &) { } catch (InstrumentHasNoSampleError &) {
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
...@@ -1217,7 +1214,7 @@ QString InstrumentWidget::getSettingsGroupName() const { ...@@ -1217,7 +1214,7 @@ QString InstrumentWidget::getSettingsGroupName() const {
QString InstrumentWidget::getInstrumentSettingsGroupName() const { QString InstrumentWidget::getInstrumentSettingsGroupName() const {
return QString::fromAscii(InstrumentWidgetSettingsGroup) + "/" + return QString::fromAscii(InstrumentWidgetSettingsGroup) + "/" +
QString::fromStdString( QString::fromStdString(
getInstrumentActor()->getInstrument()->getName()); getInstrumentActor().getInstrument()->getName());
} }
bool InstrumentWidget::hasWorkspace(const std::string &wsName) const { bool InstrumentWidget::hasWorkspace(const std::string &wsName) const {
...@@ -1311,10 +1308,10 @@ void InstrumentWidget::overlayPeaksWorkspace(IPeaksWorkspace_sptr ws) { ...@@ -1311,10 +1308,10 @@ void InstrumentWidget::overlayPeaksWorkspace(IPeaksWorkspace_sptr ws) {
* @param ws :: mask workspace to overlay * @param ws :: mask workspace to overlay
*/ */
void InstrumentWidget::overlayMaskedWorkspace(IMaskWorkspace_sptr ws) { void InstrumentWidget::overlayMaskedWorkspace(IMaskWorkspace_sptr ws) {
auto actor = getInstrumentActor(); auto &actor = getInstrumentActor();
actor->setMaskMatrixWorkspace( actor.setMaskMatrixWorkspace(
boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(ws)); boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(ws));
actor->updateColors(); actor.updateColors();
updateInstrumentDetectors(); updateInstrumentDetectors();
emit maskedWorkspaceOverlayed(); emit maskedWorkspaceOverlayed();
} }
......
...@@ -632,7 +632,7 @@ void InstrumentWidgetMaskTab::doubleChanged(QtProperty *prop) { ...@@ -632,7 +632,7 @@ void InstrumentWidgetMaskTab::doubleChanged(QtProperty *prop) {
void InstrumentWidgetMaskTab::applyMask() { void InstrumentWidgetMaskTab::applyMask() {
storeMask(); storeMask();
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
m_instrWidget->getInstrumentActor()->applyMaskWorkspace(); m_instrWidget->getInstrumentActor().applyMaskWorkspace();
enableApplyButtons(); enableApplyButtons();
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
...@@ -650,7 +650,7 @@ void InstrumentWidgetMaskTab::applyMaskToView() { ...@@ -650,7 +650,7 @@ void InstrumentWidgetMaskTab::applyMaskToView() {
*/ */
void InstrumentWidgetMaskTab::clearMask() { void InstrumentWidgetMaskTab::clearMask() {
clearShapes(); clearShapes();
m_instrWidget->getInstrumentActor()->clearMasks(); m_instrWidget->getInstrumentActor().clearMasks();
m_instrWidget->updateInstrumentView(); m_instrWidget->updateInstrumentView();
enableApplyButtons(); enableApplyButtons();
} }
...@@ -666,7 +666,7 @@ Mantid::API::MatrixWorkspace_sptr ...@@ -666,7 +666,7 @@ Mantid::API::MatrixWorkspace_sptr
InstrumentWidgetMaskTab::createMaskWorkspace(bool invertMask, bool temp) const { InstrumentWidgetMaskTab::createMaskWorkspace(bool invertMask, bool temp) const {
m_instrWidget->updateInstrumentView(); // to refresh the pick image m_instrWidget->updateInstrumentView(); // to refresh the pick image
Mantid::API::MatrixWorkspace_sptr inputWS = Mantid::API::MatrixWorkspace_sptr inputWS =
m_instrWidget->getInstrumentActor()->getMaskMatrixWorkspace(); m_instrWidget->getInstrumentActor().getMaskMatrixWorkspace();
Mantid::API::MatrixWorkspace_sptr outputWS; Mantid::API::MatrixWorkspace_sptr outputWS;
const std::string outputWorkspaceName = generateMaskWorkspaceName(temp); const std::string outputWorkspaceName = generateMaskWorkspaceName(temp);
...@@ -785,7 +785,7 @@ void InstrumentWidgetMaskTab::saveExcludeGroupToFile() { ...@@ -785,7 +785,7 @@ void InstrumentWidgetMaskTab::saveExcludeGroupToFile() {
if (!fname.isEmpty()) { if (!fname.isEmpty()) {
QList<int> dets; QList<int> dets;
m_instrWidget->getSurface()->getMaskedDetectors(dets); m_instrWidget->getSurface()->getMaskedDetectors(dets);
DetXMLFile mapFile(m_instrWidget->getInstrumentActor()->getAllDetIDs(), DetXMLFile mapFile(m_instrWidget->getInstrumentActor().getAllDetIDs(),
dets, fname); dets, fname);
} }
} }
...@@ -931,11 +931,11 @@ void InstrumentWidgetMaskTab::saveMaskingToTableWorkspace(bool invertMask) { ...@@ -931,11 +931,11 @@ void InstrumentWidgetMaskTab::saveMaskingToTableWorkspace(bool invertMask) {
// Apply the view (no workspace) to a buffered mask workspace // Apply the view (no workspace) to a buffered mask workspace
Mantid::API::MatrixWorkspace_sptr inputWS = Mantid::API::MatrixWorkspace_sptr inputWS =
m_instrWidget->getInstrumentActor()->getMaskMatrixWorkspace(); m_instrWidget->getInstrumentActor().getMaskMatrixWorkspace();
// Extract from MaskWorkspace to a TableWorkspace // Extract from MaskWorkspace to a TableWorkspace
double xmin = m_instrWidget->getInstrumentActor()->minBinValue(); double xmin = m_instrWidget->getInstrumentActor().minBinValue();
double xmax = m_instrWidget->getInstrumentActor()->maxBinValue(); double xmax = m_instrWidget->getInstrumentActor().maxBinValue();
// std::cout << "[DB] Selected x-range: " << xmin << ", " << xmax << ".\n"; // std::cout << "[DB] Selected x-range: " << xmin << ", " << xmax << ".\n";
// Always use the same name // Always use the same name
...@@ -1020,13 +1020,13 @@ InstrumentWidgetMaskTab::generateMaskWorkspaceName(bool temp) const { ...@@ -1020,13 +1020,13 @@ InstrumentWidgetMaskTab::generateMaskWorkspaceName(bool temp) const {
* enables/disables the apply and clear buttons. * enables/disables the apply and clear buttons.
*/ */
void InstrumentWidgetMaskTab::enableApplyButtons() { void InstrumentWidgetMaskTab::enableApplyButtons() {
auto instrActor = m_instrWidget->getInstrumentActor(); const auto &instrActor = m_instrWidget->getInstrumentActor();
auto mode = getMode(); auto mode = getMode();
m_maskBins = !m_instrWidget->getInstrumentActor()->wholeRange(); m_maskBins = !instrActor.wholeRange();
bool hasMaskShapes = m_instrWidget->getSurface()->hasMasks(); bool hasMaskShapes = m_instrWidget->getSurface()->hasMasks();
bool hasMaskWorkspace = instrActor->hasMaskWorkspace(); bool hasMaskWorkspace = instrActor.hasMaskWorkspace();
bool hasBinMask = instrActor->hasBinMask(); bool hasBinMask = instrActor.hasBinMask();
bool hasDetectorMask = hasMaskShapes || hasMaskWorkspace; bool hasDetectorMask = hasMaskShapes || hasMaskWorkspace;
bool hasMask = hasDetectorMask || hasBinMask; bool hasMask = hasDetectorMask || hasBinMask;
...@@ -1113,7 +1113,7 @@ void InstrumentWidgetMaskTab::storeDetectorMask(bool isROI) { ...@@ -1113,7 +1113,7 @@ void InstrumentWidgetMaskTab::storeDetectorMask(bool isROI) {
// get detectors covered by the shapes // get detectors covered by the shapes
m_instrWidget->getSurface()->getMaskedDetectors(dets); m_instrWidget->getSurface()->getMaskedDetectors(dets);
if (!dets.isEmpty()) { if (!dets.isEmpty()) {
auto wsMask = m_instrWidget->getInstrumentActor()->getMaskWorkspace(); auto wsMask = m_instrWidget->getInstrumentActor().getMaskWorkspace();
// have to cast up to the MaskWorkspace to get access to clone() // have to cast up to the MaskWorkspace to get access to clone()
std::set<Mantid::detid_t> detList; std::set<Mantid::detid_t> detList;
...@@ -1122,8 +1122,8 @@ void InstrumentWidgetMaskTab::storeDetectorMask(bool isROI) { ...@@ -1122,8 +1122,8 @@ void InstrumentWidgetMaskTab::storeDetectorMask(bool isROI) {
// but not if the mask is fresh and empty // but not if the mask is fresh and empty
if (wsMask->getNumberMasked() > 0) { if (wsMask->getNumberMasked() > 0) {
wsFresh = boost::dynamic_pointer_cast<Mantid::API::IMaskWorkspace>( wsFresh = boost::dynamic_pointer_cast<Mantid::API::IMaskWorkspace>(
m_instrWidget->getInstrumentActor()->extractCurrentMask()); m_instrWidget->getInstrumentActor().extractCurrentMask());
m_instrWidget->getInstrumentActor()->invertMaskWorkspace(); m_instrWidget->getInstrumentActor().invertMaskWorkspace();
} }
} }
foreach (int id, dets) { detList.insert(id); } foreach (int id, dets) { detList.insert(id); }
...@@ -1143,14 +1143,14 @@ void InstrumentWidgetMaskTab::storeDetectorMask(bool isROI) { ...@@ -1143,14 +1143,14 @@ void InstrumentWidgetMaskTab::storeDetectorMask(bool isROI) {
} }
if (isROI) { if (isROI) {
if (wsFresh) if (wsFresh)
m_instrWidget->getInstrumentActor()->setMaskMatrixWorkspace( m_instrWidget->getInstrumentActor().setMaskMatrixWorkspace(
boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>( boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
wsFresh)); wsFresh));