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
#define INSTRUMENTTREEMODEL_H
#include "MantidQtMantidWidgets/InstrumentView/InstrumentWidget.h"
#include <QAbstractItemModel>
#include <QModelIndex>
//#include <QModelIndex>
#include <boost/shared_ptr.hpp>
//#include <boost/shared_ptr.hpp>
namespace MantidQt {
namespace MantidWidgets {
class InstrumentActor;
/**
* The InstrumentTreeModel is a class used by a QTreeView
......@@ -23,7 +24,7 @@ class InstrumentActor;
class InstrumentTreeModel : public QAbstractItemModel {
Q_OBJECT
public:
InstrumentTreeModel(const InstrumentActor *, QObject *parent);
InstrumentTreeModel(const InstrumentWidget *instrWidget, QObject *parent);
~InstrumentTreeModel() override;
QVariant data(const QModelIndex &index, int role) const override;
......@@ -37,8 +38,8 @@ public:
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
private:
const InstrumentActor *
m_instrumentActor; ///< actor of instrument to which the model corresponds
/// instrument widget to which the model corresponds
const InstrumentWidget *m_instrWidget;
};
} // MantidWidgets
} // MantidQt
......
......@@ -24,7 +24,7 @@ class EXPORT_OPT_MANTIDQT_MANTIDWIDGETS InstrumentTreeWidget
Q_OBJECT
public:
explicit InstrumentTreeWidget(QWidget *w);
void setInstrumentActor(InstrumentActor *instrActor);
void setInstrumentWidget(InstrumentWidget *w);
void getSelectedBoundingBox(const QModelIndex &index, double &xmax,
double &ymax, double &zmax, double &xmin,
double &ymin, double &zmin);
......@@ -39,7 +39,7 @@ signals:
void componentSelected(const Mantid::Geometry::ComponentID);
private:
InstrumentActor *m_instrActor;
InstrumentWidget *m_instrWidget;
InstrumentTreeModel *m_treeModel;
};
} // MantidWidgets
......
......@@ -115,7 +115,8 @@ public:
void setScaleType(GraphOptions::ScaleType type);
void setExponent(double nth_power);
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 selectTab(int tab);
void selectTab(Tab tab) { selectTab(int(tab)); }
......@@ -256,7 +257,7 @@ protected:
/// InstrumentActor holds a pointer to the workspace itself.
QString m_workspaceName;
/// 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
/// OpenGL
bool m_useOpenGL;
......
......@@ -188,7 +188,7 @@ class ComponentInfoController : public QObject {
public:
/// Constructor.
ComponentInfoController(InstrumentWidgetPickTab *tab,
InstrumentActor *instrActor, QTextEdit *infoDisplay);
const InstrumentWidget *instrWidget, QTextEdit *infoDisplay);
public slots:
void displayInfo(size_t pickID);
void displayComparePeaksInfo(
......@@ -208,7 +208,7 @@ private:
QString getPeakOverlayInfo();
InstrumentWidgetPickTab *m_tab;
InstrumentActor *m_instrActor;
const InstrumentWidget *m_instrWidget;
QTextEdit *m_selectionInfoDisplay;
bool m_freezePlot;
......@@ -234,7 +234,7 @@ public:
};
DetectorPlotController(InstrumentWidgetPickTab *tab,
InstrumentActor *instrActor, OneCurvePlot *plot);
InstrumentWidget *instrWidget, OneCurvePlot *plot);
void setEnabled(bool on) { m_enabled = on; }
void setPlotData(size_t pickID);
void setPlotData(QList<int> detIDs);
......@@ -273,7 +273,7 @@ private:
const Mantid::Kernel::V3D &normal);
InstrumentWidgetPickTab *m_tab;
InstrumentActor *m_instrActor;
InstrumentWidget *m_instrWidget;
OneCurvePlot *m_plot;
PlotType m_plotType;
......
......@@ -19,9 +19,9 @@ namespace MantidWidgets {
/**
* Constructor for tree model to display instrument tree
*/
InstrumentTreeModel::InstrumentTreeModel(const InstrumentActor *actor,
InstrumentTreeModel::InstrumentTreeModel(const InstrumentWidget *instrWidget,
QObject *parent)
: QAbstractItemModel(parent), m_instrumentActor(actor) {}
: QAbstractItemModel(parent), m_instrWidget(instrWidget) {}
/**
* Destructor for instrument display tree
......@@ -37,7 +37,7 @@ InstrumentTreeModel::~InstrumentTreeModel() {}
int InstrumentTreeModel::columnCount(const QModelIndex &parent) const {
try {
if (parent.isValid()) {
auto instr = m_instrumentActor->getInstrument();
auto instr = m_instrWidget->getInstrumentActor().getInstrument();
boost::shared_ptr<const IComponent> comp = instr->getComponentByID(
static_cast<Mantid::Geometry::ComponentID>(parent.internalPointer()));
boost::shared_ptr<const ICompAssembly> objcomp =
......@@ -62,7 +62,7 @@ QVariant InstrumentTreeModel::data(const QModelIndex &index, int role) const {
if (role != Qt::DisplayRole)
return QVariant();
auto instr = m_instrumentActor->getInstrument();
auto instr = m_instrWidget->getInstrumentActor().getInstrument();
if (!index.isValid()) // not valid has to return the root node
return QString(instr->getName().c_str());
......@@ -109,7 +109,7 @@ QModelIndex InstrumentTreeModel::index(int row, int column,
//"<<parent.isValid()<<'\n';
try {
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
// instrument
return createIndex(row, column, instr->getComponentID());
......@@ -152,7 +152,7 @@ QModelIndex InstrumentTreeModel::parent(const QModelIndex &index) const {
// for root return empty.
return QModelIndex();
auto instr = m_instrumentActor->getInstrument();
auto instr = m_instrWidget->getInstrumentActor().getInstrument();
if (instr->getComponentID() ==
static_cast<Mantid::Geometry::ComponentID>(index.internalPointer()))
......@@ -193,7 +193,7 @@ int InstrumentTreeModel::rowCount(const QModelIndex &parent) const {
{
return 1; // boost::dynamic_pointer_cast<ICompAssembly>(m_instrument)->nelements();
} else {
auto instr = m_instrumentActor->getInstrument();
auto instr = m_instrWidget->getInstrumentActor().getInstrument();
if (instr->getComponentID() == static_cast<Mantid::Geometry::ComponentID>(
parent.internalPointer())) {
return instr->nelements();
......
......@@ -18,14 +18,14 @@ namespace MantidQt {
namespace MantidWidgets {
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,
SLOT(sendComponentSelectedSignal(const QModelIndex)));
}
void InstrumentTreeWidget::setInstrumentActor(InstrumentActor *instrActor) {
m_instrActor = instrActor;
m_treeModel = new InstrumentTreeModel(instrActor, this);
void InstrumentTreeWidget::setInstrumentWidget(InstrumentWidget *w) {
m_instrWidget = w;
m_treeModel = new InstrumentTreeModel(w, this);
setModel(m_treeModel);
setSelectionMode(SingleSelection);
setSelectionBehavior(SelectRows);
......@@ -36,7 +36,7 @@ void InstrumentTreeWidget::getSelectedBoundingBox(const QModelIndex &index,
double &zmax, double &xmin,
double &ymin, double &zmin) {
Mantid::Geometry::Instrument_const_sptr instrument =
m_instrActor->getInstrument();
m_instrWidget->getInstrumentActor().getInstrument();
// Check whether its instrument
boost::shared_ptr<const Mantid::Geometry::IComponent> selectedComponent;
if (instrument->getComponentID() ==
......@@ -66,7 +66,7 @@ void InstrumentTreeWidget::getSelectedBoundingBox(const QModelIndex &index,
// int(instrument->getSample()->getComponentID()) << '\n';
if (tmpObj->getComponentID() ==
instrument->getSample()->getComponentID()) {
boundBox = m_instrActor->getWorkspace()
boundBox = m_instrWidget->getInstrumentActor().getWorkspace()
->sample()
.getShape()
.getBoundingBox();
......@@ -123,7 +123,7 @@ void InstrumentTreeWidget::sendComponentSelectedSignal(
Mantid::Geometry::ComponentID id =
static_cast<Mantid::Geometry::ComponentID>(index.internalPointer());
auto visitor = SetVisibleComponentVisitor(id);
m_instrActor->accept(visitor);
m_instrWidget->getInstrumentActor().accept(visitor);
emit componentSelected(id);
}
......
......@@ -195,7 +195,6 @@ InstrumentWidget::InstrumentWidget(const QString &wsName, QWidget *parent,
InstrumentWidget::~InstrumentWidget() {
if (m_instrumentActor) {
saveSettings();
delete m_instrumentActor;
}
}
......@@ -250,8 +249,8 @@ void InstrumentWidget::init(bool resetGeometry, bool autoscaling,
double scaleMin, double scaleMax,
bool setDefaultView) {
// Previously in (now removed) setWorkspaceName method
m_instrumentActor =
new InstrumentActor(m_workspaceName, autoscaling, scaleMin, scaleMax);
m_instrumentActor.reset(
new InstrumentActor(m_workspaceName, autoscaling, scaleMin, scaleMax));
m_xIntegration->setTotalRange(m_instrumentActor->minBinValue(),
m_instrumentActor->maxBinValue());
m_xIntegration->setUnits(QString::fromStdString(
......@@ -275,7 +274,7 @@ void InstrumentWidget::init(bool resetGeometry, bool autoscaling,
}
setupColorMap();
} else {
surface->resetInstrumentActor(m_instrumentActor);
surface->resetInstrumentActor(m_instrumentActor.get());
updateInfoText();
}
}
......@@ -285,8 +284,6 @@ void InstrumentWidget::init(bool resetGeometry, bool autoscaling,
* @param resetGeometry
*/
void InstrumentWidget::resetInstrument(bool resetGeometry) {
delete m_instrumentActor;
m_instrumentActor = nullptr;
init(resetGeometry, true, 0.0, 0.0, false);
updateInstrumentDetectors();
}
......@@ -415,15 +412,15 @@ void InstrumentWidget::setSurfaceType(int type) {
// create the surface
if (surfaceType == FULL3D) {
surface =
new Projection3D(m_instrumentActor, getInstrumentDisplayWidth(),
new Projection3D(m_instrumentActor.get(), getInstrumentDisplayWidth(),
getInstrumentDisplayHeight());
} 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) {
surface = new UnwrappedSphere(m_instrumentActor, sample_pos, axis);
surface = new UnwrappedSphere(m_instrumentActor.get(), sample_pos, axis);
} else // SIDE_BY_SIDE
{
surface = new PanelsSurface(m_instrumentActor, sample_pos, axis);
surface = new PanelsSurface(m_instrumentActor.get(), sample_pos, axis);
}
} catch (InstrumentHasNoSampleError &) {
QApplication::restoreOverrideCursor();
......@@ -1217,7 +1214,7 @@ QString InstrumentWidget::getSettingsGroupName() const {
QString InstrumentWidget::getInstrumentSettingsGroupName() const {
return QString::fromAscii(InstrumentWidgetSettingsGroup) + "/" +
QString::fromStdString(
getInstrumentActor()->getInstrument()->getName());
getInstrumentActor().getInstrument()->getName());
}
bool InstrumentWidget::hasWorkspace(const std::string &wsName) const {
......@@ -1311,10 +1308,10 @@ void InstrumentWidget::overlayPeaksWorkspace(IPeaksWorkspace_sptr ws) {
* @param ws :: mask workspace to overlay
*/
void InstrumentWidget::overlayMaskedWorkspace(IMaskWorkspace_sptr ws) {
auto actor = getInstrumentActor();
actor->setMaskMatrixWorkspace(
auto &actor = getInstrumentActor();
actor.setMaskMatrixWorkspace(
boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(ws));
actor->updateColors();
actor.updateColors();
updateInstrumentDetectors();
emit maskedWorkspaceOverlayed();
}
......
......@@ -632,7 +632,7 @@ void InstrumentWidgetMaskTab::doubleChanged(QtProperty *prop) {
void InstrumentWidgetMaskTab::applyMask() {
storeMask();
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
m_instrWidget->getInstrumentActor()->applyMaskWorkspace();
m_instrWidget->getInstrumentActor().applyMaskWorkspace();
enableApplyButtons();
QApplication::restoreOverrideCursor();
}
......@@ -650,7 +650,7 @@ void InstrumentWidgetMaskTab::applyMaskToView() {
*/
void InstrumentWidgetMaskTab::clearMask() {
clearShapes();
m_instrWidget->getInstrumentActor()->clearMasks();
m_instrWidget->getInstrumentActor().clearMasks();
m_instrWidget->updateInstrumentView();
enableApplyButtons();
}
......@@ -666,7 +666,7 @@ Mantid::API::MatrixWorkspace_sptr
InstrumentWidgetMaskTab::createMaskWorkspace(bool invertMask, bool temp) const {
m_instrWidget->updateInstrumentView(); // to refresh the pick image
Mantid::API::MatrixWorkspace_sptr inputWS =
m_instrWidget->getInstrumentActor()->getMaskMatrixWorkspace();
m_instrWidget->getInstrumentActor().getMaskMatrixWorkspace();
Mantid::API::MatrixWorkspace_sptr outputWS;
const std::string outputWorkspaceName = generateMaskWorkspaceName(temp);
......@@ -785,7 +785,7 @@ void InstrumentWidgetMaskTab::saveExcludeGroupToFile() {
if (!fname.isEmpty()) {
QList<int> dets;
m_instrWidget->getSurface()->getMaskedDetectors(dets);
DetXMLFile mapFile(m_instrWidget->getInstrumentActor()->getAllDetIDs(),
DetXMLFile mapFile(m_instrWidget->getInstrumentActor().getAllDetIDs(),
dets, fname);
}
}
......@@ -931,11 +931,11 @@ void InstrumentWidgetMaskTab::saveMaskingToTableWorkspace(bool invertMask) {
// Apply the view (no workspace) to a buffered mask workspace
Mantid::API::MatrixWorkspace_sptr inputWS =
m_instrWidget->getInstrumentActor()->getMaskMatrixWorkspace();
m_instrWidget->getInstrumentActor().getMaskMatrixWorkspace();
// Extract from MaskWorkspace to a TableWorkspace
double xmin = m_instrWidget->getInstrumentActor()->minBinValue();
double xmax = m_instrWidget->getInstrumentActor()->maxBinValue();
double xmin = m_instrWidget->getInstrumentActor().minBinValue();
double xmax = m_instrWidget->getInstrumentActor().maxBinValue();
// std::cout << "[DB] Selected x-range: " << xmin << ", " << xmax << ".\n";
// Always use the same name
......@@ -1020,13 +1020,13 @@ InstrumentWidgetMaskTab::generateMaskWorkspaceName(bool temp) const {
* enables/disables the apply and clear buttons.
*/
void InstrumentWidgetMaskTab::enableApplyButtons() {
auto instrActor = m_instrWidget->getInstrumentActor();
const auto &instrActor = m_instrWidget->getInstrumentActor();
auto mode = getMode();
m_maskBins = !m_instrWidget->getInstrumentActor()->wholeRange();
m_maskBins = !instrActor.wholeRange();
bool hasMaskShapes = m_instrWidget->getSurface()->hasMasks();
bool hasMaskWorkspace = instrActor->hasMaskWorkspace();
bool hasBinMask = instrActor->hasBinMask();
bool hasMaskWorkspace = instrActor.hasMaskWorkspace();
bool hasBinMask = instrActor.hasBinMask();
bool hasDetectorMask = hasMaskShapes || hasMaskWorkspace;
bool hasMask = hasDetectorMask || hasBinMask;
......@@ -1113,7 +1113,7 @@ void InstrumentWidgetMaskTab::storeDetectorMask(bool isROI) {
// get detectors covered by the shapes
m_instrWidget->getSurface()->getMaskedDetectors(dets);
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()
std::set<Mantid::detid_t> detList;
......@@ -1122,8 +1122,8 @@ void InstrumentWidgetMaskTab::storeDetectorMask(bool isROI) {
// but not if the mask is fresh and empty
if (wsMask->getNumberMasked() > 0) {
wsFresh = boost::dynamic_pointer_cast<Mantid::API::IMaskWorkspace>(
m_instrWidget->getInstrumentActor()->extractCurrentMask());
m_instrWidget->getInstrumentActor()->invertMaskWorkspace();
m_instrWidget->getInstrumentActor().extractCurrentMask());
m_instrWidget->getInstrumentActor().invertMaskWorkspace();
}
}
foreach (int id, dets) { detList.insert(id); }
......@@ -1143,14 +1143,14 @@ void InstrumentWidgetMaskTab::storeDetectorMask(bool isROI) {
}
if (isROI) {
if (wsFresh)
m_instrWidget->getInstrumentActor()->setMaskMatrixWorkspace(
m_instrWidget->getInstrumentActor().setMaskMatrixWorkspace(
boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>(
wsFresh));
// need to invert the mask before displaying
m_instrWidget->getInstrumentActor()->invertMaskWorkspace();
m_instrWidget->getInstrumentActor().invertMaskWorkspace();
}
// update detector colours
m_instrWidget->getInstrumentActor()->updateColors();
m_instrWidget->getInstrumentActor().updateColors();
m_instrWidget->updateInstrumentDetectors();
}
}
......@@ -1164,7 +1164,7 @@ void InstrumentWidgetMaskTab::storeBinMask() {
// get detectors covered by the shapes
m_instrWidget->getSurface()->getMaskedDetectors(dets);
// mask some bins
m_instrWidget->getInstrumentActor()->addMaskBinsData(dets);
m_instrWidget->getInstrumentActor().addMaskBinsData(dets);
// remove masking shapes
clearShapes();
enableApplyButtons();
......@@ -1245,9 +1245,9 @@ void InstrumentWidgetMaskTab::loadMaskViewFromProject(const std::string &name) {
if (!maskWS)
return; // if we couldn't load it then just fail silently
auto actor = m_instrWidget->getInstrumentActor();
actor->setMaskMatrixWorkspace(maskWS);
actor->updateColors();
auto &actor = m_instrWidget->getInstrumentActor();
actor.setMaskMatrixWorkspace(maskWS);
actor.updateColors();
m_instrWidget->updateInstrumentDetectors();
m_instrWidget->updateInstrumentView();
}
......@@ -1266,8 +1266,8 @@ InstrumentWidgetMaskTab::loadMask(const std::string &fileName) {
using namespace Mantid::API;
// build path and input properties etc.
auto actor = m_instrWidget->getInstrumentActor();
auto workspace = actor->getWorkspace();
const auto &actor = m_instrWidget->getInstrumentActor();
auto workspace = actor.getWorkspace();
auto instrument = workspace->getInstrument();
auto instrumentName = instrument->getName();
auto tempName = "__" + workspace->getName() + "MaskView";
......@@ -1349,8 +1349,8 @@ bool InstrumentWidgetMaskTab::saveMaskViewToProject(
try {
// get masked detector workspace from actor
auto actor = m_instrWidget->getInstrumentActor();
auto outputWS = actor->getMaskMatrixWorkspace();
const auto &actor = m_instrWidget->getInstrumentActor();
auto outputWS = actor.getMaskMatrixWorkspace();
if (!outputWS)
return false; // no mask workspace was found
......
......@@ -576,9 +576,9 @@ void InstrumentWidgetPickTab::initSurface() {
SLOT(updatePlotMultipleDetectors()));
}
m_infoController = new ComponentInfoController(
this, m_instrWidget->getInstrumentActor(), m_selectionInfoDisplay);
this, m_instrWidget, m_selectionInfoDisplay);
m_plotController = new DetectorPlotController(
this, m_instrWidget->getInstrumentActor(), m_plot);
this, m_instrWidget, m_plot);
m_plotController->setTubeXUnits(
static_cast<DetectorPlotController::TubeXUnits>(m_tubeXUnitsCache));
m_plotController->setPlotType(
......@@ -801,9 +801,9 @@ std::string InstrumentWidgetPickTab::saveToProject() const {
* @param infoDisplay :: Widget on which to display the information.
*/
ComponentInfoController::ComponentInfoController(InstrumentWidgetPickTab *tab,
InstrumentActor *instrActor,
const InstrumentWidget *instrWidget,
QTextEdit *infoDisplay)
: QObject(tab), m_tab(tab), m_instrActor(instrActor),
: QObject(tab), m_tab(tab), m_instrWidget(instrWidget),
m_selectionInfoDisplay(infoDisplay), m_freezePlot(false),
m_instrWidgetBlocked(false), m_currentPickID(-1) {}
......@@ -817,11 +817,12 @@ void ComponentInfoController::displayInfo(size_t pickID) {
pickID = m_currentPickID;
}
const auto &actor = m_instrWidget->getInstrumentActor();
QString text = "";
int detid = m_instrActor->getDetID(pickID);
int detid = actor.getDetID(pickID);
if (detid >= 0) {
text += displayDetectorInfo(detid);
} else if (auto componentID = m_instrActor->getComponentID(pickID)) {
} else if (auto componentID = actor.getComponentID(pickID)) {
text += displayNonDetectorInfo(componentID);
} else {
clear();
......@@ -849,13 +850,14 @@ QString ComponentInfoController::displayDetectorInfo(Mantid::detid_t detid) {
QString text;
if (detid >= 0) {
// collect info about selected detector and add it to text
auto &det = m_instrActor->getDetectorByDetID(detid);
const auto &actor = m_instrWidget->getInstrumentActor();
auto &det = actor.getDetectorByDetID(detid);
text = "Selected detector: " + QString::fromStdString(det.getName()) + "\n";
text += "Detector ID: " + QString::number(detid) + '\n';
QString wsIndex;
try {
wsIndex = QString::number(m_instrActor->getWorkspaceIndex(detid));
wsIndex = QString::number(actor.getWorkspaceIndex(detid));
} catch (Mantid::Kernel::Exception::NotFoundError &) {
// Detector doesn't have a workspace index relating to it
wsIndex = "None";
......@@ -882,7 +884,7 @@ QString ComponentInfoController::displayDetectorInfo(Mantid::detid_t detid) {
text += "Component path:" + textpath + "/" +
QString::fromStdString(det.getName()) + '\n';
}
const double integrated = m_instrActor->getIntegratedCounts(detid);
const double integrated = actor.getIntegratedCounts(detid);
const QString counts =
integrated == -1.0 ? "N/A" : QString::number(integrated);
text += "Counts: " + counts + '\n';
......@@ -899,7 +901,7 @@ QString ComponentInfoController::displayDetectorInfo(Mantid::detid_t detid) {
*/
QString ComponentInfoController::displayNonDetectorInfo(
Mantid::Geometry::ComponentID compID) {
auto component = m_instrActor->getInstrument()->getComponentByID(compID);
auto component = m_instrWidget->getInstrumentActor().getInstrument()->getComponentByID(compID);
QString text = "Selected component: ";
text += QString::fromStdString(component->getName()) + '\n';
Mantid::Kernel::V3D pos = component->getPos();
......@@ -1116,9 +1118,9 @@ void ComponentInfoController::clear() { m_selectionInfoDisplay->clear(); }
* @param plot :: The plot widget.
*/
DetectorPlotController::DetectorPlotController(InstrumentWidgetPickTab *tab,
InstrumentActor *instrActor,
InstrumentWidget *instrWidget,
OneCurvePlot *plot)
: QObject(tab), m_tab(tab), m_instrActor(instrActor), m_plot(plot),
: QObject(tab), m_tab(tab), m_instrWidget(instrWidget), m_plot(plot),
m_plotType(Single), m_enabled(true), m_tubeXUnits(DETECTOR_ID),
m_currentDetID(-1) {
connect(m_plot, SIGNAL(clickedAt(double, double)), this,
......@@ -1137,7 +1139,7 @@ void DetectorPlotController::setPlotData(size_t pickID) {
m_plotType = Single;
}
int detid = m_instrActor->getDetID(pickID);
const int detid = m_instrWidget->getInstrumentActor().getDetID(pickID);
if (!m_enabled) {
m_plot->clearCurve();
......@@ -1167,12 +1169,13 @@ void DetectorPlotController::setPlotData(QList<int> detIDs) {
clear();
std::vector<double> x, y;
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
m_instrActor->sumDetectors(detIDs, x, y,
const auto &actor = m_instrWidget->getInstrumentActor();
actor.sumDetectors(detIDs, x, y,
static_cast<size_t>(m_plot->width()));
QApplication::restoreOverrideCursor();
if (!x.empty()) {
m_plot->setData(&x[0], &y[0], static_cast<int>(y.size()),
m_instrActor->getWorkspace()->getAxis(0)->unit()->unitID());
actor.getWorkspace()->getAxis(0)->unit()->unitID());
}
m_plot->setLabel("multiple");
}
......@@ -1207,7 +1210,7 @@ void DetectorPlotController::plotSingle(int detid) {
// set the data
m_plot->setData(&x[0], &y[0], static_cast<int>(y.size()),
m_instrActor->getWorkspace()->getAxis(0)->unit()->unitID());
m_instrWidget->getInstrumentActor().getWorkspace()->getAxis(0)->unit()->unitID());
m_plot->setLabel("Detector " + QString::number(detid));
// find any markers
......@@ -1235,8 +1238,8 @@ void DetectorPlotController::plotSingle(int detid) {
* with this id.
*/
void DetectorPlotController::plotTube(int detid) {
auto ws = m_instrActor->getWorkspace();
auto &det = m_instrActor->getDetectorByDetID(detid);
const auto &actor = m_instrWidget->getInstrumentActor();
auto &det = actor.getDetectorByDetID(detid);
boost::shared_ptr<const Mantid::Geometry::IComponent> parent =
det.getParent();
Mantid::Geometry::ICompAssembly_const_sptr ass =
......@@ -1270,12 +1273,13 @@ void DetectorPlotController::plotTubeSums(int detid) {
clear();
return;
}
auto &det = m_instrActor->getDetectorByDetID(detid);
const auto &actor = m_instrWidget->getInstrumentActor();
auto &det = actor.getDetectorByDetID(detid);
auto parent = det.getParent();
QString label = QString::fromStdString(parent->getName()) + " (" +
QString::number(detid) + ") Sum";
m_plot->setData(&x[0], &y[0], static_cast<int>(y.size()),
m_instrActor->getWorkspace()->getAxis(0)->unit()->unitID());
actor.getWorkspace()->getAxis(0)->unit()->unitID());
m_plot->setLabel(label);