diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Muon/MuonAnalysis.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Muon/MuonAnalysis.h index 57ef529085a8612717f91aed0d50e522885bba0f..c721809f1dfde591611d789b0cbf01fc37a3c1f1 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Muon/MuonAnalysis.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Muon/MuonAnalysis.h @@ -101,6 +101,7 @@ signals: private slots: /// Guess Alpha clicked void guessAlphaClicked(); + void handleGroupBox(bool enabled, bool updateWorkspaces = true); /// Checks whether two specified periods are equal and, if they are, sets /// second one to None diff --git a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Muon/MuonAnalysisFitDataPresenter.h b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Muon/MuonAnalysisFitDataPresenter.h index f2005b376b185b2045bae80d740b94a48bda0dd7..d02834a9160a8b6cb770de2b54c878489ba5fb1e 100644 --- a/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Muon/MuonAnalysisFitDataPresenter.h +++ b/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Muon/MuonAnalysisFitDataPresenter.h @@ -136,6 +136,7 @@ public slots: void openSequentialFitDialog(); /// Handles "fit raw data" selection/deselection void handleFitRawData(bool enabled, bool updateWorkspaces = true); +// void handleGroupBox(bool enabled, bool updateWorkspaces = true); /// Perform pre-fit checks void doPreFitChecks(bool sequentialFit); diff --git a/MantidQt/CustomInterfaces/src/Muon/MuonAnalysis.cpp b/MantidQt/CustomInterfaces/src/Muon/MuonAnalysis.cpp index 3e42f48323527dc916bb7bb1fa1f32306d49c3fd..5869dd7873b45e236fcb9c09e18b6f39a2e8471c 100644 --- a/MantidQt/CustomInterfaces/src/Muon/MuonAnalysis.cpp +++ b/MantidQt/CustomInterfaces/src/Muon/MuonAnalysis.cpp @@ -318,6 +318,7 @@ void MuonAnalysis::initLayout() { // Manage User Directories connect(m_uiForm.manageDirectoriesBtn, SIGNAL(clicked()), this, SLOT(openDirectoryDialog())); + // m_uiForm. } /** @@ -2112,6 +2113,9 @@ void MuonAnalysis::loadFittings() { SLOT(dataToFitChanged())); connect(m_uiForm.plotCreation, SIGNAL(currentIndexChanged(int)), this, SLOT(updateDataPresenterOverwrite(int))); + connect(m_uiForm.fitBrowser, SIGNAL(groupBoxClicked(bool)), this, + SLOT(handleGroupBox(bool))); + //add changed here? m_fitDataPresenter->setOverwrite(isOverwriteEnabled()); // Set multi fit mode on/off as appropriate const auto &multiFitState = m_optionTab->getMultiFitState(); @@ -2120,7 +2124,20 @@ void MuonAnalysis::loadFittings() { const auto &TFAsymmState = m_optionTab->getTFAsymmState(); m_fitFunctionPresenter->setTFAsymmState(TFAsymmState); } - +/** +* Handle "groups" selected/deselected +* Update stored value +* Create raw workspaces if necessary +* @param enabled :: [input] Whether option has been selected or unselected +* @param updateWorkspaces :: [input] Whether to create workspaces if they don't +* exist +*/ +void MuonAnalysis::handleGroupBox(bool enabled, + bool updateWorkspaces) { + //send the group to dataselector + m_dataSelector->setGroupsSelected(m_uiForm.fitBrowser->getChosenGroups()); + m_fitDataPresenter->handleSelectedDataChanged(true); +} /** * Allow/disallow loading. */ diff --git a/MantidQt/CustomInterfaces/src/Muon/MuonAnalysisFitDataPresenter.cpp b/MantidQt/CustomInterfaces/src/Muon/MuonAnalysisFitDataPresenter.cpp index 13f3ee185166939d094a36ea6284ebf7cd7e0486..9db7b2b46cc99340ae4cffe044a241880a0ba15e 100644 --- a/MantidQt/CustomInterfaces/src/Muon/MuonAnalysisFitDataPresenter.cpp +++ b/MantidQt/CustomInterfaces/src/Muon/MuonAnalysisFitDataPresenter.cpp @@ -144,6 +144,8 @@ void MuonAnalysisFitDataPresenter::doConnect() { SLOT(doPreFitChecks(bool))); connect(fitBrowser, SIGNAL(fitRawDataClicked(bool)), this, SLOT(handleFitRawData(bool))); +// connect(fitBrowser, SIGNAL(groupBoxClicked(bool)), this, +// SLOT(handleGroupBox(bool))); } if (const QObject *dataSelector = dynamic_cast<QObject *>(m_dataSelector)) { connect(dataSelector, SIGNAL(dataPropertiesChanged()), this, diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MuonFitDataSelector.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MuonFitDataSelector.h index 2e98d6e87e5e7c0820455c78a61c9ef79b1140c6..b76f7f36bdc176017f809b7600a4a040f8a14dd7 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MuonFitDataSelector.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MuonFitDataSelector.h @@ -66,6 +66,7 @@ public: QStringList getChosenGroups() const override; /// Set chosen group void setChosenGroup(const QString &group) override; + void setGroupsSelected(QStringList groups) { m_chosenGroups = groups; }; /// Clear list of selected groups void clearChosenGroups() const; /// Get selected periods @@ -156,6 +157,7 @@ private: /// Map of period names to checkboxes QMap<QString, QCheckBox *> m_periodBoxes; double startX; + QStringList m_chosenGroups; private slots: /// Set normal cursor and enable input void unsetBusyState(); diff --git a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MuonFitPropertyBrowser.h b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MuonFitPropertyBrowser.h index c138c28dab35b12e66b14bffd7073f2f3c3ecc03..3ab66361dc987f73f0b2964589f8810030edfcbb 100644 --- a/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MuonFitPropertyBrowser.h +++ b/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/MuonFitPropertyBrowser.h @@ -105,9 +105,10 @@ public: void TFAsymmFit(int maxIterations); void setAvailableGroups(const QStringList &groups); QStringList getChosenGroups() const; - void setChosenGroup(const QString &group); /// Clear list of selected groups void clearChosenGroups() const; + void setAllGroups(); + void setAllPairs(); public slots: /// Perform the fit algorithm @@ -128,6 +129,8 @@ signals: void userChangedDatasetIndex(int index) override; /// Emitted when "fit to raw data" is changed void fitRawDataClicked(bool enabled) override; + void groupBoxClicked(bool enabled); + /// Emitted when fit is about to be run void preFitChecksRequested(bool sequential) override; @@ -156,6 +159,8 @@ private: const int nWorkspaces) const; void clearGroupCheckboxes(); void addGroupCheckbox(const QString &name); + void genGroupWindow(); + void setGroupOptions(int current,std::string option); /// Splitter for additional widgets and splitter between this and browser QSplitter *m_widgetSplitter, *m_mainSplitter; /// Names of workspaces to fit @@ -170,7 +175,11 @@ private: /// Map of group names to checkboxes QMap<QString,QtProperty *> m_groupBoxes; QtBrowserItem *m_groupWindow; - //int m_groupWindowCount; + //QtTreePropertyBrowser *m_groupBrowser; + QtProperty *m_showGroup; + mutable QStringList m_showGroupValue; + std::vector<std::string> m_groupsList = { "fwd","bkwd","top","bottom","bwd"}; + }; std::vector<double> readNormalization(); diff --git a/MantidQt/MantidWidgets/src/MuonFitDataSelector.cpp b/MantidQt/MantidWidgets/src/MuonFitDataSelector.cpp index 19c7e39f5ab51bed9a6475c93ec2307cc115c571..c418cbc2fae34d4664c6bfa4d0b48be6efe724af 100644 --- a/MantidQt/MantidWidgets/src/MuonFitDataSelector.cpp +++ b/MantidQt/MantidWidgets/src/MuonFitDataSelector.cpp @@ -378,14 +378,19 @@ QStringList MuonFitDataSelector::getPeriodSelections() const { * @returns :: list of selected groups */ QStringList MuonFitDataSelector::getChosenGroups() const { - QStringList chosen; + /*for (auto group : m_chosenGroups) { + std::string tmp = group.toStdString(); + double a = 1.; +}*/ + return m_chosenGroups; + /*QStringList chosen; for (auto iter = m_groupBoxes.constBegin(); iter != m_groupBoxes.constEnd(); ++iter) { if (iter.value()->isChecked()) { chosen.append(iter.key()); } } - return chosen; + return chosen;*/ } /** * Clears the list of selected groups (unchecks boxes) @@ -520,9 +525,9 @@ IMuonFitDataSelector::FitType MuonFitDataSelector::getFitType() const { // will // If radio buttons disabled, it's a single fit unless multiple groups/periods // chosen if (!m_ui.rbCoAdd->isEnabled()) { - const auto groups = getChosenGroups(); + const auto groups = m_chosenGroups.size();//getChosenGroups(); const auto periods = getPeriodSelections(); - return groups.size() <= 1 && periods.size() <= 1 ? FitType::Single + return groups <= 1 && periods.size() <= 1 ? FitType::Single : FitType::Simultaneous; } else { // which button is selected @@ -651,9 +656,9 @@ void MuonFitDataSelector::setSimultaneousFitLabel(const QString &label) { * Called when groups/periods selection changes. */ void MuonFitDataSelector::checkForMultiGroupPeriodSelection() { - const auto groups = getChosenGroups(); + // const auto groups = getChosenGroups(); const auto periods = getPeriodSelections(); - m_ui.txtSimFitLabel->setEnabled(groups.size() > 1 || periods.size() > 1 || + m_ui.txtSimFitLabel->setEnabled(m_chosenGroups.size() > 1 || periods.size() > 1 || getFitType() == FitType::Simultaneous); } diff --git a/MantidQt/MantidWidgets/src/MuonFitPropertyBrowser.cpp b/MantidQt/MantidWidgets/src/MuonFitPropertyBrowser.cpp index 92ba2a49740bfc41c21c4fe527b2f6b51c52d8ed..b1bd5f2c7a291bd67e128f75e236d2e41a1e509c 100644 --- a/MantidQt/MantidWidgets/src/MuonFitPropertyBrowser.cpp +++ b/MantidQt/MantidWidgets/src/MuonFitPropertyBrowser.cpp @@ -163,11 +163,17 @@ void MuonFitPropertyBrowser::init() { m_groupsToFit = m_enumManager->addProperty("Groups/Pairs to fit"); m_groupsToFitOptions << "All groups" << "All Pairs" - << "Custom"; + << "Custom"<<"Show"; + + m_showGroupValue << "groups"; + m_showGroup = m_enumManager->addProperty("Selected Groups"); + //moo need to add periods.... m_enumManager->setEnumNames(m_groupsToFit, m_groupsToFitOptions); multiFitSettingsGroup->addSubProperty(m_groupsToFit); + multiFitSettingsGroup->addSubProperty(m_showGroup); + m_enumManager->setEnumNames(m_showGroup, m_showGroupValue); connect(m_browser, SIGNAL(currentItemChanged(QtBrowserItem *)), this, SLOT(currentItemChanged(QtBrowserItem *))); @@ -186,6 +192,8 @@ void MuonFitPropertyBrowser::init() { m_functionsGroup = m_browser->addProperty(functionsGroup); m_settingsGroup = m_browser->addProperty(settingsGroup); m_multiFitSettingsGroup = m_browser->addProperty(multiFitSettingsGroup); + m_multiFitSettingsGroup->property()->removeSubProperty(m_showGroup); + // Don't show "Function" or "Data" sections as they have separate widgets m_browser->setItemVisible(m_functionsGroup, false); m_browser->setItemVisible(m_settingsGroup, false); @@ -330,16 +338,56 @@ void MuonFitPropertyBrowser::setWorkspaceName(const QString &wsName) { void MuonFitPropertyBrowser::enumChanged(QtProperty *prop) { if (!m_changeSlotsEnabled) return; - + m_multiFitSettingsGroup->property()->removeSubProperty(m_showGroup); bool storeSettings = false; if (prop == m_groupsToFit) { int j = m_enumManager->value(m_groupsToFit); std::string option = m_groupsToFitOptions[j].toStdString(); + + + if (option == "All groups") { + setAllGroups(); + } + else if (option == "All Pairs") { + setAllPairs(); + } + else if(option == "Custom") { + genGroupWindow(); + + } + else if (option == "Show") { + m_showGroupValue.clear(); + m_showGroupValue << getChosenGroups().join(","); + m_enumManager->setEnumNames(m_showGroup, m_showGroupValue); + m_multiFitSettingsGroup->property()->addSubProperty(m_showGroup); + } + + //m_enumManager->setEnumNames(m_groupsToFit, m_groupsToFitOptions); + } else { FitPropertyBrowser::enumChanged(prop); } } + +void MuonFitPropertyBrowser::setGroupOptions(int current, std::string option) { + m_groupsToFitOptions.clear(); + if (option == "Custom") { + if (current == 2) { + m_groupsToFitOptions << "All groups" + << "All Pairs" + << "Show" << "Custom"; + } + else { + m_groupsToFitOptions << "All groups" + << "All Pairs" + << "Custom" << "Show"; + } + } + m_enumManager->setEnumNames(m_groupsToFit, m_groupsToFitOptions); + +} + /** Called when a double property changed * @param prop :: A pointer to the property */ @@ -401,9 +449,22 @@ void MuonFitPropertyBrowser::boolChanged(QtProperty *prop) { if (prop == m_rawData) { const bool val = m_boolManager->value(prop); emit fitRawDataClicked(val); - } else { - // defer to parent class - FitPropertyBrowser::boolChanged(prop); + } + else { + bool done = false; + for (auto iter = m_groupBoxes.constBegin(); iter != m_groupBoxes.constEnd(); + ++iter) { + if (iter.value() == prop) { + const bool val = m_boolManager->value(prop); + done = true; + emit groupBoxClicked(val); + } + } + + if (done == false) { + // defer to parent class + FitPropertyBrowser::boolChanged(prop); + } } } @@ -931,6 +992,7 @@ void MuonFitPropertyBrowser::setAvailableGroups(const QStringList &groups) { groupSettings->addSubProperty(m_groupBoxes.value(group)); } m_groupWindow = m_browser->addProperty(groupSettings); + //m_groupWindow2 = m_groupBrowser->addProperty(groupSettings); } /** @@ -950,20 +1012,15 @@ void MuonFitPropertyBrowser::clearGroupCheckboxes() { * @param name :: [input] Name of group to add */ void MuonFitPropertyBrowser::addGroupCheckbox(const QString &name) { - //auto checkBox = new QCheckBox(name); - - - m_groupBoxes.insert(name,m_boolManager->addProperty(name)); - - //m_groupBoxes.value(name)->setChecked(false); - //QSettings settings; - //settings.beginGroup("Mantid/test"); - - bool plotDiff = false; - m_boolManager->setValue(m_groupBoxes.value(name), plotDiff); - //m_groupWindow->addSubProperty(m_groupBoxes.value(name)); - //connect(m_groupBoxes.value(name), SIGNAL(clicked(bool)), this, - // SIGNAL(selectedGroupsChanged())); + m_groupBoxes.insert(name, m_boolManager->addProperty(name)); + int j = m_enumManager->value(m_groupsToFit); + auto option = m_groupsToFitOptions[j].toStdString(); + if (option == "All groups") { + setAllGroups(); + } + else if (option == "All Pairs") { + setAllPairs(); + } } /** * Returns a list of the selected groups (checked boxes) @@ -973,7 +1030,7 @@ QStringList MuonFitPropertyBrowser::getChosenGroups() const { QStringList chosen; for (auto iter = m_groupBoxes.constBegin(); iter != m_groupBoxes.constEnd(); ++iter) { - if (iter.value()==false) { + if (m_boolManager->value(iter.value()) ==true) { chosen.append(iter.key()); } } @@ -989,22 +1046,63 @@ void MuonFitPropertyBrowser::clearChosenGroups() const { //iter.value()->setChecked(false); } } + /** -* Set the chosen group ticked and all others off -* Used when switching from Home tab to Data Analysis tab -* @param group :: [input] Name of group to select +* Selects all groups */ -void MuonFitPropertyBrowser::setChosenGroup(const QString &group) { +void MuonFitPropertyBrowser::setAllGroups() { + + clearChosenGroups(); for (auto iter = m_groupBoxes.constBegin(); iter != m_groupBoxes.constEnd(); ++iter) { - if (iter.key() == group) { - m_boolManager->setValue(iter.value(), false); + for (auto group : m_groupsList) { + if (iter.key().toStdString() == group) { + m_boolManager->setValue(iter.value(), true); - //iter.value()->setChecked(true); + } } } } - - +/* +* sets all pairs +*/ +void MuonFitPropertyBrowser::setAllPairs() { + clearChosenGroups(); + bool isItGroup = false; + for (auto iter = m_groupBoxes.constBegin(); iter != m_groupBoxes.constEnd(); + ++iter) { + isItGroup = false; + for (auto group : m_groupsList) { + if (iter.key().toStdString() == group) { + isItGroup = true; + } + } + if (!isItGroup) { + m_boolManager->setValue(iter.value(), true); + } + } +} +/* +* Create a popup window to select a custom +* selection of groups/pairs +*/ +void MuonFitPropertyBrowser::genGroupWindow() { + QWidget *w = new QWidget; + QtGroupPropertyManager *groupManager = new QtGroupPropertyManager(w); + QVBoxLayout *layout = new QVBoxLayout(w); + QtTreePropertyBrowser *groupBrowser = new QtTreePropertyBrowser(); + QtProperty *groupSettings = groupManager->addProperty("test"); + for (auto iter = m_groupBoxes.constBegin(); iter != m_groupBoxes.constEnd(); + ++iter){ + groupSettings->addSubProperty(m_groupBoxes.value(iter.key())); + m_boolManager->setValue(iter.value(),m_boolManager->value(iter.value())); + } + QtCheckBoxFactory *checkBoxFactory = new QtCheckBoxFactory(w); + groupBrowser->setFactoryForManager(m_boolManager, checkBoxFactory); + groupBrowser->addProperty(groupSettings); + layout->addWidget(groupBrowser); + w->setLayout(layout); + w->show(); +} } // MantidQt } // API