Skip to content
Snippets Groups Projects
Commit 1e75114e authored by Peter Parker's avatar Peter Parker
Browse files

Merge remote-tracking branch 'origin/bugfix/9419_instrumentview_exception_on_replace'

parents a4636d88 53fdf98d
No related merge requests found
......@@ -79,9 +79,6 @@ m_failedColor(200,200,200)
// set up data ranges and colours
setUpWorkspace(sharedWorkspace, scaleMin, scaleMax);
/// Keep the pointer to the detid2index map
m_detid2index_map = sharedWorkspace->getDetectorIDToWorkspaceIndexMap();
Instrument_const_sptr instrument = getInstrument();
// If the instrument is empty, maybe only having the sample and source
......@@ -172,6 +169,9 @@ void InstrumentActor::setUpWorkspace(boost::shared_ptr<const Mantid::API::Matrix
auto wsValidator = Mantid::API::CommonBinsValidator();
m_ragged = ! wsValidator.isValid(sharedWorkspace).empty();
/// Keep the pointer to the detid2index map
m_detid2index_map = sharedWorkspace->getDetectorIDToWorkspaceIndexMap();
}
/** Used to set visibility of an actor corresponding to a particular component
......@@ -1066,8 +1066,6 @@ void InstrumentActor::setDataMinMaxRange(double vmin, double vmax)
void InstrumentActor::setDataIntegrationRange(const double& xmin,const double& xmax)
{
if (!getWorkspace()) return;
m_BinMinValue = xmin;
m_BinMaxValue = xmax;
......
......@@ -720,12 +720,20 @@ void InstrumentWindow::afterReplaceHandle(const std::string& wsName,
{
if (m_instrumentActor)
{
// try to detect if the instrument changes with the workspace
// Check if it's still the same workspace underneath (as well as having the same name)
auto matrixWS = boost::dynamic_pointer_cast<const MatrixWorkspace>( workspace );
bool sameWS = false;
try {
sameWS = ( matrixWS == m_instrumentActor->getWorkspace() );
} catch (std::runtime_error&) {
// Carry on, sameWS should stay false
}
// try to detect if the instrument changes (unlikely if the workspace hasn't, but theoretically possible)
bool resetGeometry = matrixWS->getInstrument()->getNumberDetectors() != m_instrumentActor->ndetectors();
// if instrument doesn't change keep the scaling
if ( !resetGeometry )
// if workspace and instrument don't change keep the scaling
if ( sameWS && !resetGeometry )
{
m_instrumentActor->updateColors();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment