Skip to content

Commit

Permalink
Refs #3779. Implement a plot option to bring up the parameter table.
Browse files Browse the repository at this point in the history
By right-clicking on a plot, with the peak picker tool attached, the
user should be able to select "Get Parameters" which opens up the table
of values.
  • Loading branch information
Robert-Whitley committed Dec 8, 2011
1 parent 46afa3b commit 6f4571b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Code/Mantid/MantidPlot/src/ApplicationWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7664,7 +7664,7 @@ void ApplicationWindow::selectMultiPeak(bool showFitPropertyBrowser)
if (g->validCurvesDataSize())
{
//Called when setting up usual peakPickerTool
PeakPickerTool* ppicker = new PeakPickerTool(g, mantidUI->fitFunctionBrowser(), showFitPropertyBrowser);
PeakPickerTool* ppicker = new PeakPickerTool(g, mantidUI->fitFunctionBrowser(), mantidUI, showFitPropertyBrowser);
g->setActiveTool(ppicker);
connect(plot,SIGNAL(windowStateChanged(Qt::WindowStates, Qt::WindowStates)),ppicker,SLOT(windowStateChanged(Qt::WindowStates, Qt::WindowStates)));
}
Expand Down Expand Up @@ -16498,7 +16498,7 @@ void ApplicationWindow::runConnectFitting(MantidQt::MantidWidgets::FitPropertyBr
foreach(Graph *g, layers)
{
// Go through and set up the PeakPickerTool for the new graph
PeakPickerTool* ppicker = new PeakPickerTool(g, fpb);
PeakPickerTool* ppicker = new PeakPickerTool(g, fpb, mantidUI, true);
g->setActiveTool(ppicker);
}
}
Expand Down
31 changes: 29 additions & 2 deletions Code/Mantid/MantidPlot/src/Mantid/PeakPickerTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
#include <QAction>
#include <QMenu>
#include <QInputDialog>
#include <QMessageBox>

#include <iostream>

PeakPickerTool::PeakPickerTool(Graph *graph, MantidQt::MantidWidgets::FitPropertyBrowser *fitPropertyBrowser, bool showFitPropertyBrowser) : //MantidUI *mantidUI) :
PeakPickerTool::PeakPickerTool(Graph *graph, MantidQt::MantidWidgets::FitPropertyBrowser *fitPropertyBrowser, MantidUI *mantidUI, bool showFitPropertyBrowser) :
QwtPlotPicker(graph->plotWidget()->canvas()),
PlotToolInterface(graph),
m_fitPropertyBrowser(fitPropertyBrowser),m_wsName(),m_spec(),m_init(false), //m_current(0),
m_fitPropertyBrowser(fitPropertyBrowser),
m_mantidUI(mantidUI),
m_wsName(),m_spec(),m_init(false), //m_current(0),
m_width_set(true),m_width(0),m_addingPeak(false),m_resetting(false)
{
d_graph->plotWidget()->canvas()->setCursor(Qt::pointingHandCursor);
Expand Down Expand Up @@ -734,6 +737,12 @@ void PeakPickerTool::prepareContextMenu(QMenu& menu)

menu.addSeparator();

action = new QAction("Get Parameters", this);
connect(action, SIGNAL(triggered()), this, SLOT(getParameters()));
menu.addAction(action);

menu.addSeparator();

if (m_fitPropertyBrowser->isFitEnabled())
{
action = new QAction("Fit",this);
Expand Down Expand Up @@ -1021,6 +1030,24 @@ void PeakPickerTool::resetRange()
d_graph->replot();
}


/**
* Checks whether there is a parameters file attached to the plot.
* If so, it opens up that parameters table.
*/
void PeakPickerTool::getParameters()
{
QString parameterWs = m_wsName + "_Parameters";
if (Mantid::API::AnalysisDataService::Instance().doesExist(parameterWs.toStdString() ) )
{
m_mantidUI->importWorkspace(parameterWs);
}
else
{
QMessageBox::information(m_fitPropertyBrowser, "Mantid - Warning", "No parameter file with the name \"" + parameterWs + "\" found.");
}
}

void PeakPickerTool::modifiedGraph()
{
}
Expand Down
6 changes: 5 additions & 1 deletion Code/Mantid/MantidPlot/src/Mantid/PeakPickerTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class PeakPickerTool : public QwtPlotPicker, public PlotToolInterface, public Qw
Q_OBJECT
public:
/// Constructor
PeakPickerTool(Graph *graph, MantidQt::MantidWidgets::FitPropertyBrowser *fitPropertyBrowser, bool showFitPropertyBrowser=true); //MantidUI *mantidUI);
PeakPickerTool(Graph *graph, MantidQt::MantidWidgets::FitPropertyBrowser *fitPropertyBrowser, MantidUI *mantidUI, bool showFitPropertyBrowser=true);
/// Destructor
~PeakPickerTool();
/// Runtime type identifier
Expand Down Expand Up @@ -131,6 +131,8 @@ private slots:

void resetRange();

void getParameters();

private:
void plotFitFunction(MantidQt::MantidWidgets::PropertyHandler* h);
void replot(MantidQt::MantidWidgets::PropertyHandler* h) const;
Expand Down Expand Up @@ -185,6 +187,8 @@ private slots:
/// Creates a pointer to fitPropertyBrowser
MantidQt::MantidWidgets::FitPropertyBrowser* m_fitPropertyBrowser;

MantidUI *m_mantidUI;

/// Workspace name
QString m_wsName;
/// Spectrum index
Expand Down

0 comments on commit 6f4571b

Please sign in to comment.