Skip to content

Commit

Permalink
Refs #8534. Better error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
arturbekasov committed Dec 4, 2013
1 parent 05c7d3b commit 117a034
Showing 1 changed file with 34 additions and 27 deletions.
61 changes: 34 additions & 27 deletions Code/Mantid/MantidQt/CustomInterfaces/src/MuonAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,42 +350,49 @@ void MuonAnalysis::plotItem(ItemType itemType, int tableRow, PlotType plotType)

AnalysisDataServiceImpl& ads = AnalysisDataService::Instance();

// Name of the group currently used to store plot workspaces. Depends on loaded data.
const std::string groupName = getGroupName().toStdString();
try
{
// Name of the group currently used to store plot workspaces. Depends on loaded data.
const std::string groupName = getGroupName().toStdString();

// Create workspace and a raw (unbinned) version of it
MatrixWorkspace_sptr ws = createAnalysisWorkspace(itemType, tableRow, plotType);
MatrixWorkspace_sptr wsRaw = createAnalysisWorkspace(itemType, tableRow, plotType, true);
// Create workspace and a raw (unbinned) version of it
MatrixWorkspace_sptr ws = createAnalysisWorkspace(itemType, tableRow, plotType);
MatrixWorkspace_sptr wsRaw = createAnalysisWorkspace(itemType, tableRow, plotType, true);

// Find names for new workspaces
const std::string wsName = getNewAnalysisWSName(groupName, itemType, tableRow, plotType);
const std::string wsRawName = wsName + "; Raw";
// Find names for new workspaces
const std::string wsName = getNewAnalysisWSName(groupName, itemType, tableRow, plotType);
const std::string wsRawName = wsName + "; Raw";

// Make sure they end up in the ADS
ads.addOrReplace(wsName, ws);
ads.addOrReplace(wsRawName, wsRaw);
// Make sure they end up in the ADS
ads.addOrReplace(wsName, ws);
ads.addOrReplace(wsRawName, wsRaw);

// Make sure they are in the right group
if ( ! ads.retrieveWS<WorkspaceGroup>(groupName)->contains(wsName) )
{
ads.addToGroup(groupName, wsName);
ads.addToGroup(groupName, wsRawName);
}
// Make sure they are in the right group
if ( ! ads.retrieveWS<WorkspaceGroup>(groupName)->contains(wsName) )
{
ads.addToGroup(groupName, wsName);
ads.addToGroup(groupName, wsRawName);
}

QString wsNameQ = QString::fromStdString(wsName);
QString wsNameQ = QString::fromStdString(wsName);

// Hide all the previous plot windows, if requested by user
if (m_uiForm.hideGraphs->isChecked())
hideAllPlotWindows();
// Hide all the previous plot windows, if requested by user
if (m_uiForm.hideGraphs->isChecked())
hideAllPlotWindows();

// Plot the workspace
plotSpectrum( wsNameQ, 0, (plotType == Logorithm) );
// Plot the workspace
plotSpectrum( wsNameQ, 0, (plotType == Logorithm) );

// Change the plot style of the graph so that it matches what is selected on
// the plot options tab.
setPlotStyle( wsNameQ, getPlotStyleParams(wsNameQ, 0) );
// Change the plot style of the graph so that it matches what is selected on
// the plot options tab.
setPlotStyle( wsNameQ, getPlotStyleParams(wsNameQ, 0) );

setCurrentDataName( wsNameQ );
setCurrentDataName( wsNameQ );
}
catch(std::exception& e)
{
QMessageBox::critical( this, "MuonAnalysis - Error", "Unable to plot the item. Check log for details." );
}

m_updating = false;
}
Expand Down

0 comments on commit 117a034

Please sign in to comment.