Skip to content

Commit

Permalink
Refs #4547. Replot graph after changing the style.
Browse files Browse the repository at this point in the history
Final tidy up of the code.
  • Loading branch information
Robert-Whitley committed Jan 27, 2012
1 parent 193ef4b commit 5bf8041
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 95 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 @@ -16911,7 +16911,7 @@ void ApplicationWindow::setPlotType(const QStringList & plotDetails)
{
if (plotDetails.size() == 0)
{
QMessageBox::information(this, "Mantid - Error", "Plot type or curve index is missing. Please contact a Mantid team member.");
QMessageBox::information(this, "Mantid - Error", "Plot type or workspace name is missing. Please contact a Mantid team member.");
}
else
{
Expand Down Expand Up @@ -16961,7 +16961,7 @@ void ApplicationWindow::setPlotType(const QStringList & plotDetails)
else
pd->setPlotType(connectType, curveNum);
}
g->activateGraph();
g->replot();
}
}
}
Expand Down
20 changes: 0 additions & 20 deletions Code/Mantid/MantidPlot/src/Mantid/PeakPickerTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,12 +555,6 @@ void PeakPickerTool::algorithmFinished(const QString& out)
new MantidMatrixCurve(m_curveDifName,out,graph(),2,false);
}

//customise the plot
QStringList plotDetails;
plotDetails.push_back(workspaceName());

m_fitPropertyBrowser->customisation(plotDetails);

graph()->replot();
}

Expand Down Expand Up @@ -882,29 +876,15 @@ void PeakPickerTool::plotGuess()
MantidQt::MantidWidgets::PropertyHandler* h = m_fitPropertyBrowser->getHandler();
plotFitFunction(h);
h->hasPlot() = true;

d_graph->replot();

QStringList plotDetails;
plotDetails.push_back(m_wsName);

m_fitPropertyBrowser->customisation(plotDetails);
}

void PeakPickerTool::plotCurrentGuess()
{
MantidQt::MantidWidgets::PropertyHandler* h = m_fitPropertyBrowser->currentHandler();
plotFitFunction(h);
h->hasPlot() = true;

d_graph->replot();

QString axisLabel = QString::fromStdString(m_ws->getAxis(1)->label(spec()));
QStringList plotDetails;
plotDetails.push_back(m_wsName);
plotDetails.push_back(axisLabel);

m_fitPropertyBrowser->customisation(plotDetails);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,10 @@ private slots:
/// Update the pair plot based on changes on the group page.
void settingsTabUpdatePlot();

/// Assigns a peak picker tool to the workspace
/// Assigns a peak picker tool to the workspace.
void assignPeakPickerTool(const QString &);

/// Change the data style and color
void changeDataPlotType(const QStringList &);

/// Group the fitted workspaces.
void groupFittedWorkspaces(QString);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ class MuonAnalysisFitDataTab : MantidQt::API::UserSubWindow
void init();

void makeRawWorkspace(const std::string & wsName);
void groupRawWorkspace(const std::vector<std::string> & inputWorkspaces, const std::string & groupName);
void groupWorkspaces(const std::vector<std::string> & inputWorkspaces, const std::string & groupName);
void groupFittedWorkspaces(QString workspaceName);

QStringList getAllPlotDetails(const QStringList & plotDetails);
QStringList getAllPlotDetails(const QString & workspace);

signals:

Expand Down
55 changes: 8 additions & 47 deletions Code/Mantid/MantidQt/CustomInterfaces/src/MuonAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@ void MuonAnalysis::initLayout()
// Detect when the tab is changed
connect(m_uiForm.tabWidget, SIGNAL(currentChanged(int)), this, SLOT(changeTab(int)));

// Detect if the graph should be customised and call the two functions that change the different curves on the graph.
connect(m_uiForm.fitBrowser, SIGNAL(customiseGraph(const QStringList &)), this, SLOT(changeDataPlotType(const QStringList &)));

// Detect when the fit has finished and group the workspaces that have been created as a result.
connect(m_uiForm.fitBrowser, SIGNAL(fittingDone(QString)), this, SLOT(groupFittedWorkspaces(QString)));

Expand Down Expand Up @@ -1512,7 +1509,7 @@ void MuonAnalysis::createPlotWS(const std::string& groupName, const std::string&
std::vector<std::string> groupWorkspaces;
groupWorkspaces.push_back(groupName);
groupWorkspaces.push_back(wsname + "_Raw");
m_fitDataTab->groupRawWorkspace(groupWorkspaces, groupName);
m_fitDataTab->groupWorkspaces(groupWorkspaces, groupName);
}
}

Expand Down Expand Up @@ -1712,22 +1709,8 @@ void MuonAnalysis::plotGroup(const std::string& plotType)
QString pyOutput = runPythonCode( pyString ).trimmed();

// Change the plot style of the graph so that it matches what is selected on
// the plot options tab. Default is set to line (0).
QStringList plotDetails;
QString plotType("");
plotType.setNum(m_uiForm.connectPlotType->currentIndex());

plotDetails.push_back(titleLabel);
plotDetails.push_back(plotType);
plotDetails.push_back("Data");
if(m_uiForm.showErrorBars->isChecked())
{
plotDetails.push_back("AllErrors");
}
else
{
plotDetails.push_back("NoErrors");
}
// the plot options tab.
QStringList plotDetails = m_fitDataTab->getAllPlotDetails(titleLabel);
changePlotType(plotDetails);

m_currentDataName = titleLabel;
Expand Down Expand Up @@ -1878,21 +1861,7 @@ void MuonAnalysis::plotPair(const std::string& plotType)

// Change the plot style of the graph so that it matches what is selected on
// the plot options tab. Default is set to line (0).
QStringList plotDetails;
QString plotType("");
plotType.setNum(m_uiForm.connectPlotType->currentIndex());

plotDetails.push_back(titleLabel);
plotDetails.push_back(plotType);
plotDetails.push_back("Data");
if(m_uiForm.showErrorBars->isChecked())
{
plotDetails.push_back("AllErrors");
}
else
{
plotDetails.push_back("NoErrors");
}
QStringList plotDetails = m_fitDataTab->getAllPlotDetails(titleLabel);
changePlotType(plotDetails);

m_currentDataName = titleLabel;
Expand Down Expand Up @@ -2985,18 +2954,6 @@ void MuonAnalysis::assignPeakPickerTool(const QString & workspaceName)
}


/**
* Set up the string that will contain all the data needed for changing the data.
* [wsName, connectType, plotType, Errors, Color]
*
* @param plotDetails :: The workspace name of the plot to be created.
*/
void MuonAnalysis::changeDataPlotType(const QStringList & plotDetails)
{
QStringList allPlotDetails(m_fitDataTab->getAllPlotDetails(plotDetails));
changePlotType(allPlotDetails);
}

/**
* Group the fitted workspaces that are created from the 'fit' algorithm
*
Expand All @@ -3005,6 +2962,10 @@ void MuonAnalysis::changeDataPlotType(const QStringList & plotDetails)
void MuonAnalysis::groupFittedWorkspaces(QString workspaceName)
{
m_fitDataTab->groupFittedWorkspaces(workspaceName);

//QStringList plotDetails;
//plotDetails.push_back(workspaceName);
//changeDataPlotType(plotDetails);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void MuonAnalysisFitDataTab::makeRawWorkspace(const std::string& wsName)
* @param inputWorkspaces :: The name of the workspace the raw file is associated to.
* @param groupName :: The name of the workspaceGroup to join with and what to call the output.
*/
void MuonAnalysisFitDataTab::groupRawWorkspace(const std::vector<std::string> & inputWorkspaces, const std::string & groupName)
void MuonAnalysisFitDataTab::groupWorkspaces(const std::vector<std::string> & inputWorkspaces, const std::string & groupName)
{
Mantid::API::IAlgorithm_sptr groupingAlg = Mantid::API::AlgorithmManager::Instance().create("GroupWorkspaces");
groupingAlg->setProperty("InputWorkspaces", inputWorkspaces);
Expand Down Expand Up @@ -100,7 +100,7 @@ void MuonAnalysisFitDataTab::groupFittedWorkspaces(QString workspaceName)

if (inputWorkspaces.size() > 1)
{
groupRawWorkspace(inputWorkspaces, groupName);
groupWorkspaces(inputWorkspaces, groupName);
}
}

Expand All @@ -111,9 +111,10 @@ void MuonAnalysisFitDataTab::groupFittedWorkspaces(QString workspaceName)
*
* @param plotDetails :: The workspace name of the plot to be created.
*/
QStringList MuonAnalysisFitDataTab::getAllPlotDetails(const QStringList & plotDetails)
QStringList MuonAnalysisFitDataTab::getAllPlotDetails(const QString & workspace)
{
QStringList allPlotDetails(plotDetails);
QStringList allPlotDetails;
allPlotDetails.push_back(workspace);

QString fitType("");
fitType.setNum(m_uiForm.connectPlotType->currentIndex());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,6 @@ class EXPORT_OPT_MANTIDQT_MANTIDWIDGETS FitPropertyBrowser: public QDockWidget,
/// Update the PeakPickerTool with the current workspace to be displayed and which to associate itself with
void updatePPTool(const QString& name);

/// Emits a signal to customise the plot it is associated with
void customisation(const QStringList& plotDetails);

/// Returns the list of workspaces that are currently been worked on by the fit property browser.
QStringList getWorkspaceNames();

Expand Down Expand Up @@ -242,8 +239,6 @@ public slots:
void removePlotSignal(MantidQt::MantidWidgets::PropertyHandler*);
void removeFitCurves();

void customiseGraph(const QStringList&);

void executeFit(QString,QMap<QString,QString>,Mantid::API::AlgorithmObserver*);
void multifitFinished();

Expand Down
11 changes: 0 additions & 11 deletions Code/Mantid/MantidQt/MantidWidgets/src/FitPropertyBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2110,17 +2110,6 @@ void FitPropertyBrowser::clearAllPlots()
emit removeFitCurves();
}

/**
* Customise the plot if it is a custom fitting. (i.e part of muon analysis)
*
* @param plotDetails :: The name of the workspace plot to be customised seperated by a '.'
*/
void FitPropertyBrowser::customisation(const QStringList& plotDetails)
{
if (m_customFittings)
emit customiseGraph(plotDetails);
}

/** Create a double property and set some settings
* @param name :: The name of the new property
* @return Pointer to the created property
Expand Down

0 comments on commit 5bf8041

Please sign in to comment.