Skip to content

Commit

Permalink
Refs #8534. MuonAnalysis: plotSelectedItem() using new functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
arturbekasov committed Dec 3, 2013
1 parent 98e544d commit 4201c81
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ private slots:
MatrixWorkspace_sptr createAnalysisWorkspace(ItemType itemType, int tableRow, PlotType type,
bool isRaw = false);

/// Returns PlotType as chosen using given selector
PlotType parsePlotType(QComboBox* selector);

/// Finds a name for new analysis workspace
std::string getNewAnalysisWSName(const std::string& runLabel, ItemType itemType, int tableRow,
PlotType plotType);
Expand Down
51 changes: 40 additions & 11 deletions Code/Mantid/MantidQt/CustomInterfaces/src/MuonAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,30 @@ void MuonAnalysis::runFrontPlotButton()
*/
void MuonAnalysis::plotSelectedItem()
{
// Get current index
ItemType itemType;
int tableRow;

int index = m_uiForm.frontGroupGroupPairComboBox->currentIndex();

if (index < 0)
throw std::runtime_error("Item not selected");

if (index >= numGroups())
{
itemType = Pair;
tableRow = m_pairToRow[index-numGroups()];
}
else
{
itemType = Group;
tableRow = m_groupToRow[index];
}

PlotType plotType = parsePlotType(m_uiForm.frontPlotFuncs);

plotItem(itemType, tableRow, plotType);
}

/**
* Creates workspace for specified group/pair and plots it;
* @param itemType :: Whether it's a group or pair
Expand Down Expand Up @@ -425,22 +445,31 @@ std::string MuonAnalysis::getNewAnalysisWSName(const std::string& runLabel, Item

return newName;
}

/**
* Returns PlotType as chosen using given selector.
* @param selector :: Widget to use for parsing
* @return PlotType as selected using the widget
*/
MuonAnalysis::PlotType MuonAnalysis::parsePlotType(QComboBox* selector)
{
std::string plotTypeName = selector->currentText().toStdString();

if ( plotTypeName == "Asymmetry" )
{
return Asymmetry;
}
else if ( plotTypeName == "Counts" )
{
index = 0;
m_uiForm.frontGroupGroupPairComboBox->setCurrentIndex(index);
return Counts;
}
else if (index >= numGroups())
else if ( plotTypeName == "Logorithm" )
{
// i.e. index points to a pair
m_pairTableRowInFocus = m_pairToRow[index-numGroups()]; // this can be improved
std::string str = m_uiForm.frontPlotFuncs->currentText().toStdString();
plotPair(str);
return Logorithm;
}
else
{
m_groupTableRowInFocus = m_groupToRow[index];
std::string str = m_uiForm.frontPlotFuncs->currentText().toStdString();
plotGroup(str);
throw std::runtime_error("Unknown plot type name: " + plotTypeName);
}
}

Expand Down

0 comments on commit 4201c81

Please sign in to comment.