diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Muon/MuonAnalysis.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Muon/MuonAnalysis.h index cd1a37e8bebf3ce4b291169a6c5cb8c480421c70..7b6236d0c19a9d3c942b1d68e0408586cda856fa 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Muon/MuonAnalysis.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Muon/MuonAnalysis.h @@ -103,8 +103,6 @@ private slots: void guessAlphaClicked(); void handleGroupBox(); void handlePeriodBox(); - void setChosenGroupSlot(QString &group); - void setChosenPeriodSlot(QString &period); /// Checks whether two specified periods are equal and, if they are, sets /// second one to None void checkForEqualPeriods(); @@ -569,6 +567,8 @@ private: /// Set the Grouping and Data Analysis tabs enabled/disabled void setAnalysisTabsEnabled(const bool enabled); + + void setChosenGroupAndPeriods(const QString &wsName); }; } } diff --git a/MantidQt/CustomInterfaces/src/Muon/MuonAnalysis.cpp b/MantidQt/CustomInterfaces/src/Muon/MuonAnalysis.cpp index a3a8758ae40a38e78356e45513e40d79ccf597e8..feda9230ee547530230a613ff567b799f7d7a2c9 100644 --- a/MantidQt/CustomInterfaces/src/Muon/MuonAnalysis.cpp +++ b/MantidQt/CustomInterfaces/src/Muon/MuonAnalysis.cpp @@ -318,19 +318,25 @@ void MuonAnalysis::initLayout() { // Manage User Directories connect(m_uiForm.manageDirectoriesBtn, SIGNAL(clicked()), this, SLOT(openDirectoryDialog())); - connect(this, SIGNAL(setChosenGroupSignal(QString &)), this, - SLOT(setChosenGroupSlot(QString &))); - connect(this, SIGNAL(setChosenPeriodSignal(QString &)), this, - SLOT(setChosenPeriodSlot(QString &))); } -void MuonAnalysis::setChosenGroupSlot(QString &group) { - m_uiForm.fitBrowser->setChosenGroup(group); -} -void MuonAnalysis::setChosenPeriodSlot(QString &period) { - m_uiForm.fitBrowser->setChosenPeriods(period); +void MuonAnalysis::setChosenGroupAndPeriods(const QString &wsName) { + const auto wsParams = + MuonAnalysisHelper::parseWorkspaceName(wsName.toStdString()); + + const QString &groupToSet = QString::fromStdString(wsParams.itemName); + const QString &periodToSet = QString::fromStdString(wsParams.periods); + const auto &groups = m_dataSelector->getChosenGroups(); + const auto &periods = m_dataSelector->getPeriodSelections(); + if (!groups.contains(groupToSet)) { + m_uiForm.fitBrowser->setChosenGroup(groupToSet); + } + if (!periodToSet.isEmpty() && !periods.contains(periodToSet)) { + m_uiForm.fitBrowser->setChosenPeriods(periodToSet); + } } + /** * Muon Analysis help (slot) */ @@ -1480,6 +1486,7 @@ void MuonAnalysis::updateFront() { /** * Update front including first re-populate pair list combo box + * Also update multiple fitting */ void MuonAnalysis::updateFrontAndCombo() { // for now brute force clearing and adding new context @@ -1493,13 +1500,19 @@ void MuonAnalysis::updateFrontAndCombo() { int numG = numGroups(); int numP = numPairs(); - for (int i = 0; i < numG; i++) - m_uiForm.frontGroupGroupPairComboBox->addItem( - m_uiForm.groupTable->item(m_groupToRow[i], 0)->text()); - for (int i = 0; i < numP; i++) - m_uiForm.frontGroupGroupPairComboBox->addItem( - m_uiForm.pairTable->item(m_pairToRow[i], 0)->text()); + QStringList groupsAndPairs; + for (int i = 0; i < numG; i++) { + m_uiForm.frontGroupGroupPairComboBox->addItem( + m_uiForm.groupTable->item(m_groupToRow[i], 0)->text()); + groupsAndPairs << m_uiForm.groupTable->item(m_groupToRow[i], 0)->text(); + } + for (int i = 0; i < numP; i++) { + m_uiForm.frontGroupGroupPairComboBox->addItem( + m_uiForm.pairTable->item(m_pairToRow[i], 0)->text()); + groupsAndPairs << m_uiForm.groupTable->item(m_pairToRow[i], 0)->text(); + } + m_uiForm.fitBrowser->setAvailableGroups(groupsAndPairs); // If it doesn't match then reset if (currentI >= m_uiForm.frontGroupGroupPairComboBox->count()) { currentI = 0; @@ -1862,6 +1875,7 @@ void MuonAnalysis::selectMultiPeak(const QString &wsName, // Set the selected run, group/pair and period m_fitDataPresenter->setAssignedFirstRun(wsName, filePath); + setChosenGroupAndPeriods(wsName); } QString code; @@ -2131,10 +2145,6 @@ void MuonAnalysis::loadFittings() { Mantid::Kernel::make_unique<MuonAnalysisFitFunctionPresenter>( nullptr, m_uiForm.fitBrowser, m_functionBrowser); // Connect signals - connect(m_dataSelector, SIGNAL(selectedGroupsChanged()), this, - SLOT(dataToFitChanged())); - connect(m_dataSelector, SIGNAL(selectedPeriodsChanged()), this, - SLOT(dataToFitChanged())); connect(m_dataSelector, SIGNAL(workspaceChanged()), this, SLOT(dataToFitChanged())); connect(m_uiForm.plotCreation, SIGNAL(currentIndexChanged(int)), this, @@ -2502,6 +2512,7 @@ void MuonAnalysis::changeTab(int newTabIndex) { const boost::optional<QString> filePath = m_uiForm.mwRunFiles->getUserInput().toString(); m_fitDataPresenter->setSelectedWorkspace(m_currentDataName, filePath); + setChosenGroupAndPeriods(m_currentDataName); selectMultiPeak(m_currentDataName, filePath); } diff --git a/MantidQt/CustomInterfaces/src/Muon/MuonAnalysisFitDataPresenter.cpp b/MantidQt/CustomInterfaces/src/Muon/MuonAnalysisFitDataPresenter.cpp index 69f5de4123504dcdc93b449cde2106f5b2649d14..b35a7338e7892cbb476d74a3ecd3ab13b901c99b 100644 --- a/MantidQt/CustomInterfaces/src/Muon/MuonAnalysisFitDataPresenter.cpp +++ b/MantidQt/CustomInterfaces/src/Muon/MuonAnalysisFitDataPresenter.cpp @@ -787,20 +787,6 @@ void MuonAnalysisFitDataPresenter::setUpDataSelector( m_dataSelector->setWorkspaceDetails( numberString, QString::fromStdString(wsParams.instrument), filePath); - // Set selected groups/pairs and periods here too - // (unless extra groups/periods are already selected, in which case don't - // unselect them) - const QString &groupToSet = QString::fromStdString(wsParams.itemName); - const QString &periodToSet = QString::fromStdString(wsParams.periods); - const auto &groups = m_dataSelector->getChosenGroups(); - const auto &periods = m_dataSelector->getPeriodSelections(); - if (!groups.contains(groupToSet)) { - emit setChosenGroupSignal(groupToSet); - } - if (!periodToSet.isEmpty() && !periods.contains(periodToSet)) { - emit setChosenPeriodSignal(periodToSet); - } - // If given an optional file path to "current run", cache it for later use if (filePath && !wsParams.runs.empty()) { m_currentRun = Muon::CurrentRun(wsParams.runs.front(), filePath.get()); diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MuonFitPropertyBrowser.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MuonFitPropertyBrowser.h index 341e858c6e877d5b7b87791a1c95e7b5ab5fe0a5..a90c0c2562c42f424a8aa2065c101893fe43e242 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MuonFitPropertyBrowser.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MuonFitPropertyBrowser.h @@ -112,7 +112,7 @@ public: void setAllGroups(); void setAllPairs(); void clearChosenPeriods() const; - void setChosenGroup(QString &group); + void setChosenGroup(const QString &group); void setChosenPeriods(const QString &period); void setSingleFitLabel(std::string name); public slots: diff --git a/MantidQt/MantidWidgets/src/MuonFitPropertyBrowser.cpp b/MantidQt/MantidWidgets/src/MuonFitPropertyBrowser.cpp index 4df544d78653e9a87de29f35170f365760fdfc83..42a50f651486214542bc45921b0b9473e3f86bdd 100644 --- a/MantidQt/MantidWidgets/src/MuonFitPropertyBrowser.cpp +++ b/MantidQt/MantidWidgets/src/MuonFitPropertyBrowser.cpp @@ -178,9 +178,6 @@ void MuonFitPropertyBrowser::init() { multiFitSettingsGroup->addSubProperty(m_showPeriods); m_enumManager->setEnumNames(m_showPeriods, m_showPeriodValue); - connect(m_browser, SIGNAL(currentItemChanged(QtBrowserItem *)), this, - SLOT(currentItemChanged(QtBrowserItem *))); - /* Create editors and assign them to the managers */ createEditors(w); @@ -189,6 +186,8 @@ void MuonFitPropertyBrowser::init() { m_functionsGroup = m_browser->addProperty(functionsGroup); m_settingsGroup = m_browser->addProperty(settingsGroup); m_multiFitSettingsGroup = m_browser->addProperty(multiFitSettingsGroup); + connect(m_browser, SIGNAL(currentItemChanged(QtBrowserItem *)), this, + SLOT(currentItemChanged(QtBrowserItem *))); m_btnGroup = new QGroupBox(tr("Reselect Data")); QHBoxLayout *btnLayout = new QHBoxLayout; @@ -1012,7 +1011,7 @@ void MuonFitPropertyBrowser::setAvailableGroups(const QStringList &groups) { * Selects a single group/pair * @param group :: [input] Group/pair to select */ -void MuonFitPropertyBrowser::setChosenGroup(QString &group) { +void MuonFitPropertyBrowser::setChosenGroup(const QString &group) { clearChosenGroups(); for (auto iter = m_groupBoxes.constBegin(); iter != m_groupBoxes.constEnd(); ++iter) { @@ -1109,7 +1108,8 @@ void MuonFitPropertyBrowser::setAllPairs() { * selection of groups/pairs */ void MuonFitPropertyBrowser::genGroupWindow() { - + //reset group window + m_groupWindow = new QDialog; QtGroupPropertyManager *groupManager = new QtGroupPropertyManager(m_groupWindow); QVBoxLayout *layout = new QVBoxLayout(m_groupWindow); @@ -1276,6 +1276,8 @@ void MuonFitPropertyBrowser::setChosenPeriods(const QString &period) { * selection of periods */ void MuonFitPropertyBrowser::genPeriodWindow() { + //reset period window + m_periodWindow = new QDialog; QtGroupPropertyManager *groupManager = new QtGroupPropertyManager(m_periodWindow); QVBoxLayout *layout = new QVBoxLayout(m_periodWindow); @@ -1298,6 +1300,8 @@ void MuonFitPropertyBrowser::genPeriodWindow() { * a combination of periods */ void MuonFitPropertyBrowser::genCombinePeriodWindow() { + //reset combine window + m_comboWindow = new QDialog; QVBoxLayout *layout = new QVBoxLayout(m_comboWindow); QFormLayout *formLayout = new QFormLayout; m_positiveCombo = new QLineEdit();