diff --git a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp index 74c9c6041786273ade1fc42ae6b9e3cd0ff6e911..565bf7039ecda304a521bee8cd80dd6f3a214811 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp @@ -1071,8 +1071,25 @@ void InstrumentWindow::setColorMapAutoscaling(bool on) bool InstrumentWindow::overlay(const QString & wsName) { using namespace Mantid::API; - auto pws = boost::dynamic_pointer_cast<IPeaksWorkspace>(AnalysisDataService::Instance().retrieve(wsName.toStdString())); + Workspace_sptr workspace; + try { + workspace = AnalysisDataService::Instance().retrieve(wsName.toStdString()); + } catch(std::runtime_error &re) { + QMessageBox::warning(this, "MantidPlot - Warning", "No workspace called '" + wsName + "' found. "); + return workspace; + } + auto pws = boost::dynamic_pointer_cast<IPeaksWorkspace>(workspace); + if (!pws) { + QMessageBox::warning(this, "MantidPlot - Warning", "Work space called '" +wsName+ "' is not suitable." + " Please select another workspace. "); + return pws; + } auto surface = boost::dynamic_pointer_cast<UnwrappedSurface>( getSurface() ); + if (!surface) { + QMessageBox::warning(this, "MantidPlot - Warning","Please change to an unwrapped view to see peak labels."); + return surface; + } + bool success(false); if (pws && surface) { @@ -1080,10 +1097,7 @@ bool InstrumentWindow::overlay(const QString & wsName) updateInstrumentView(); success = true; } - else if (pws && !surface) - { - QMessageBox::warning(this,"MantidPlot - Warning","Please change to an unwrapped view to see peak labels."); - } + return success; } diff --git a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowTreeTab.cpp b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowTreeTab.cpp index ca109e0c6be829ec6007764a84d96b1ef39022f1..c3d6f015d50ca435df7a003059d2fa79b6ff9023 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowTreeTab.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindowTreeTab.cpp @@ -36,11 +36,11 @@ void InstrumentWindowTreeTab::selectComponentByName(const QString &name) QModelIndex component = m_instrumentTree->findComponentByName(name); if( !component.isValid() ) { - QMessageBox::critical(this,"Instrument Window - Tree Tab - Error", - "No component named '" + name + "' was found in the instrument. " - "Please use the name of a component from the instrument tree."); + QMessageBox::warning(this,"Instrument Window - Tree Tab - Error", + "No component named '" + name + "' was found. " + "Please use a valid component name "); return; - } + } m_instrumentTree->clearSelection(); m_instrumentTree->scrollTo(component, QAbstractItemView::EnsureVisible );