Skip to content

Commit

Permalink
Switch over most plotting
Browse files Browse the repository at this point in the history
Need a way to specify a range
Renames plotContour to plot2D to match Python API

Refs #11446
  • Loading branch information
DanNixon committed Mar 30, 2015
1 parent a2c8865 commit da9b306
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 19 deletions.
Expand Up @@ -99,7 +99,7 @@ namespace CustomInterfaces
void plotSpectrum(const QString & workspaceName, int specIndex = 0);

/// Plot a contour plot of a given workspace
void plotContour(const QString & workspaceName);
void plot2D(const QString & workspaceName);

/// Function to set the range limits of the plot
void setPlotPropertyRange(MantidQt::MantidWidgets::RangeSelector * rs,
Expand Down
Expand Up @@ -275,7 +275,7 @@ namespace IDA
plotSpectrum(QString::fromStdString(m_pythonExportWsName));

if(plotType == "Contour" || plotType == "Both")
plotContour(QString::fromStdString(m_pythonExportWsName));
plot2D(QString::fromStdString(m_pythonExportWsName));
}


Expand Down
Expand Up @@ -163,12 +163,7 @@ namespace CustomInterfaces

// Handle spectra plotting
if(m_uiForm.ckPlot->isChecked())
{
QString pyInput = "from mantidplot import plotSpectrum, plot2D\n"
"plotSpectrum('" + m_outputWsName + "', 0)\n";

runPythonCode(pyInput);
}
plotSpectrum(m_outputWsName);
}


Expand Down
Expand Up @@ -290,8 +290,10 @@ namespace CustomInterfaces
// Plot the smoothed workspace if required
if(m_uiForm.ckSmoothResolution->isChecked() && m_uiForm.ckPlot->isChecked())
{
std::string pyInput = "from mantidplot import plotSpectrum\nplotSpectrum(['" + m_pythonExportWsName + "', '" + m_pythonExportWsName + "_pre_smooth'], 0)\n";
m_pythonRunner.runPythonCode(QString::fromStdString(pyInput));
QStringList plotWorkspaces;
plotWorkspaces << QString::fromStdString(m_pythonExportWsName)
<< QString::fromStdString(m_pythonExportWsName) + "_pre_smooth";
plotSpectrum(plotWorkspaces);
}
}

Expand Down
Expand Up @@ -472,8 +472,7 @@ namespace CustomInterfaces
QFileInfo rawFileInfo(rawFile);
std::string name = rawFileInfo.baseName().toStdString();

std::string pyInput = "from mantidplot import plotSpectrum\nplotSpectrum('" + name + "_grp', 0)\n";
m_pythonRunner.runPythonCode(QString::fromStdString(pyInput));
plotSpectrum(QString::fromStdString(name) + "_grp");
}

/**
Expand Down
Expand Up @@ -88,9 +88,7 @@ namespace MantidQt
if(error || !plot)
return;

// Plot the output workspace group
QString pyInput = "plotSpectrum('" + m_outWsName + "', 0)\n";
emit runAsPythonScript(pyInput);
plotSpectrum(m_outWsName);
}

/**
Expand Down
Expand Up @@ -164,12 +164,11 @@ namespace CustomInterfaces
QString plotType = m_uiForm.cbPlotType->currentText();

if(plotType == "Contour")
{
pyInput += "plot2D(sqw_ws)\n";
}
plot2D(sqwWsName);

else if(plotType == "Spectra")
{
//TODO
pyInput +=
"n_spec = mtd[sqw_ws].getNumberHistograms()\n"
"plotSpectrum(sqw_ws, range(0, n_spec))\n";
Expand Down
Expand Up @@ -227,7 +227,7 @@ namespace CustomInterfaces
*
* @param workspaceName Name of workspace to plot
*/
void IndirectTab::plotContour(const QString & workspaceName)
void IndirectTab::plot2D(const QString & workspaceName)
{
QString pyInput = "from mantidplot import plot2D\n";

Expand Down

0 comments on commit da9b306

Please sign in to comment.