Skip to content
Snippets Groups Projects
Commit 65cb5693 authored by Anthony Lim's avatar Anthony Lim
Browse files

refs #19835 displays norm in GUI

parent e30ccdd4
No related branches found
No related tags found
No related merge requests found
...@@ -257,6 +257,8 @@ private slots: ...@@ -257,6 +257,8 @@ private slots:
void setTFAsymm(Muon::TFAsymmState); void setTFAsymm(Muon::TFAsymmState);
/// Called when "overwrite" is changed /// Called when "overwrite" is changed
void updateDataPresenterOverwrite(int state); void updateDataPresenterOverwrite(int state);
//update norm
void updateNorm(QString name);
private: private:
/// Initialize local Python environment /// Initialize local Python environment
......
...@@ -183,7 +183,6 @@ void MuonAnalysis::initLayout() { ...@@ -183,7 +183,6 @@ void MuonAnalysis::initLayout() {
m_fitDataTab = new MuonAnalysisFitDataTab(m_uiForm); m_fitDataTab = new MuonAnalysisFitDataTab(m_uiForm);
m_fitDataTab->init(); m_fitDataTab->init();
m_resultTableTab = new MuonAnalysisResultTableTab(m_uiForm); m_resultTableTab = new MuonAnalysisResultTableTab(m_uiForm);
connect(m_resultTableTab, SIGNAL(runPythonCode(const QString &, bool)), this, connect(m_resultTableTab, SIGNAL(runPythonCode(const QString &, bool)), this,
SIGNAL(runAsPythonScript(const QString &, bool))); SIGNAL(runAsPythonScript(const QString &, bool)));
...@@ -2169,6 +2168,7 @@ void MuonAnalysis::loadFittings() { ...@@ -2169,6 +2168,7 @@ void MuonAnalysis::loadFittings() {
SLOT(handleGroupBox())); SLOT(handleGroupBox()));
connect(m_uiForm.fitBrowser, SIGNAL(periodBoxClicked()), this, connect(m_uiForm.fitBrowser, SIGNAL(periodBoxClicked()), this,
SLOT(handlePeriodBox())); SLOT(handlePeriodBox()));
connect(m_dataSelector, SIGNAL(nameChanged(QString)), this, SLOT(updateNorm(QString)));
m_fitDataPresenter->setOverwrite(isOverwriteEnabled()); m_fitDataPresenter->setOverwrite(isOverwriteEnabled());
// Set multi fit mode on/off as appropriate // Set multi fit mode on/off as appropriate
...@@ -2557,6 +2557,10 @@ void MuonAnalysis::changeTab(int newTabIndex) { ...@@ -2557,6 +2557,10 @@ void MuonAnalysis::changeTab(int newTabIndex) {
m_currentTab = newTab; m_currentTab = newTab;
} }
void MuonAnalysis::updateNorm(QString name) {
m_uiForm.fitBrowser->setNormalization(name.toStdString());
}
/** /**
* Set up the signals and slots for auto updating the plots * Set up the signals and slots for auto updating the plots
......
...@@ -154,6 +154,7 @@ void MuonAnalysisFitDataPresenter::doConnect() { ...@@ -154,6 +154,7 @@ void MuonAnalysisFitDataPresenter::doConnect() {
SLOT(handleSimultaneousFitLabelChanged())); SLOT(handleSimultaneousFitLabelChanged()));
connect(dataSelector, SIGNAL(datasetIndexChanged(int)), this, connect(dataSelector, SIGNAL(datasetIndexChanged(int)), this,
SLOT(handleDatasetIndexChanged(int))); SLOT(handleDatasetIndexChanged(int)));
} }
} }
...@@ -378,6 +379,18 @@ void MuonAnalysisFitDataPresenter::storeNorm(std::string name) const { ...@@ -378,6 +379,18 @@ void MuonAnalysisFitDataPresenter::storeNorm(std::string name) const {
Mantid::API::ITableWorkspace_sptr table = Mantid::API::ITableWorkspace_sptr table =
boost::dynamic_pointer_cast<Mantid::API::ITableWorkspace>( boost::dynamic_pointer_cast<Mantid::API::ITableWorkspace>(
Mantid::API::AnalysisDataService::Instance().retrieve("multiNorm")); Mantid::API::AnalysisDataService::Instance().retrieve("multiNorm"));
auto colName = table->getColumn("name");
if(table->rowCount()>1){
std::string tmp =name;
// stored with ; instead of spaces
std::replace(tmp.begin(), tmp.end(), ' ', ';');
for (size_t j = 0; j < table->rowCount(); j++) {
if (colName->cell<std::string>(j) == tmp) {//already exists
return;
}
}
}
Mantid::API::TableRow row = table->appendRow(); Mantid::API::TableRow row = table->appendRow();
std::string tmp = name; std::string tmp = name;
// spaces stop the string being written // spaces stop the string being written
......
...@@ -105,7 +105,7 @@ public slots: ...@@ -105,7 +105,7 @@ public slots:
void fitTypeChanged(bool state); void fitTypeChanged(bool state);
/// Called when group/period box selection changes /// Called when group/period box selection changes
void checkForMultiGroupPeriodSelection(); void checkForMultiGroupPeriodSelection();
void updateNormFromDropDown(int);
signals: signals:
/// Edited the start or end fields /// Edited the start or end fields
void dataPropertiesChanged(); void dataPropertiesChanged();
...@@ -115,7 +115,7 @@ signals: ...@@ -115,7 +115,7 @@ signals:
void simulLabelChanged(); void simulLabelChanged();
/// Dataset index changed /// Dataset index changed
void datasetIndexChanged(int index); void datasetIndexChanged(int index);
void nameChanged(QString name);
private: private:
/// Set default values in some input controls /// Set default values in some input controls
void setDefaultValues(); void setDefaultValues();
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>923</width> <width>923</width>
<height>269</height> <height>414</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
......
...@@ -117,7 +117,7 @@ public: ...@@ -117,7 +117,7 @@ public:
void setAllPeriods(); void setAllPeriods();
void setChosenPeriods(const QString &period); void setChosenPeriods(const QString &period);
void setSingleFitLabel(std::string name); void setSingleFitLabel(std::string name);
void setNormalization(const std::string name);
public slots: public slots:
/// Perform the fit algorithm /// Perform the fit algorithm
void fit() override; void fit() override;
...@@ -154,6 +154,8 @@ protected: ...@@ -154,6 +154,8 @@ protected:
void showEvent(QShowEvent *e) override; void showEvent(QShowEvent *e) override;
double normalization() const; double normalization() const;
void setNormalization(); void setNormalization();
private slots: private slots:
void doubleChanged(QtProperty *prop) override; void doubleChanged(QtProperty *prop) override;
void boolChanged(QtProperty *prop) override; void boolChanged(QtProperty *prop) override;
...@@ -225,6 +227,7 @@ private: ...@@ -225,6 +227,7 @@ private:
std::vector<std::string> m_groupsList; std::vector<std::string> m_groupsList;
}; };
std::map<std::string, double> readMultipleNormalization(); std::map<std::string, double> readMultipleNormalization();
std::vector<double> readNormalization(); std::vector<double> readNormalization();
} // MantidQt } // MantidQt
......
...@@ -63,6 +63,8 @@ void MuonFitDataSelector::setUpConnections() { ...@@ -63,6 +63,8 @@ void MuonFitDataSelector::setUpConnections() {
SLOT(checkForMultiGroupPeriodSelection())); SLOT(checkForMultiGroupPeriodSelection()));
connect(m_ui.cbDataset, SIGNAL(currentIndexChanged(int)), this, connect(m_ui.cbDataset, SIGNAL(currentIndexChanged(int)), this,
SIGNAL(datasetIndexChanged(int))); SIGNAL(datasetIndexChanged(int)));
connect(m_ui.cbDataset, SIGNAL(currentIndexChanged(int)), this,
SLOT(updateNormFromDropDown(int)));
connect(m_ui.btnNextDataset, SIGNAL(clicked()), this, SLOT(setNextDataset())); connect(m_ui.btnNextDataset, SIGNAL(clicked()), this, SLOT(setNextDataset()));
connect(m_ui.btnPrevDataset, SIGNAL(clicked()), this, connect(m_ui.btnPrevDataset, SIGNAL(clicked()), this,
SLOT(setPreviousDataset())); SLOT(setPreviousDataset()));
...@@ -406,9 +408,17 @@ void MuonFitDataSelector::setDatasetNames(const QStringList &datasetNames) { ...@@ -406,9 +408,17 @@ void MuonFitDataSelector::setDatasetNames(const QStringList &datasetNames) {
// Otherwise select the first in the list. // Otherwise select the first in the list.
if (i == m_ui.cbDataset->count()) { if (i == m_ui.cbDataset->count()) {
m_ui.cbDataset->setCurrentIndex(0); m_ui.cbDataset->setCurrentIndex(0);
} }
}
void MuonFitDataSelector::updateNormFromDropDown(int j) {
for(int i=0;i<m_ui.cbDataset->count();i++){
if (i==j){
auto name = m_ui.cbDataset->itemText(i);
emit nameChanged(name);
return;
}
}
} }
/** /**
* Called when "previous dataset" is clicked. * Called when "previous dataset" is clicked.
* Changes combobox to previous dataset, which will raise an event. * Changes combobox to previous dataset, which will raise an event.
...@@ -431,7 +441,7 @@ void MuonFitDataSelector::setNextDataset() { ...@@ -431,7 +441,7 @@ void MuonFitDataSelector::setNextDataset() {
const int maxIndex = m_ui.cbDataset->count() - 1; const int maxIndex = m_ui.cbDataset->count() - 1;
if (index < maxIndex) { if (index < maxIndex) {
m_ui.cbDataset->setCurrentIndex(index + 1); m_ui.cbDataset->setCurrentIndex(index + 1);
} }
} }
/** /**
......
...@@ -185,6 +185,9 @@ void MuonFitPropertyBrowser::init() { ...@@ -185,6 +185,9 @@ void MuonFitPropertyBrowser::init() {
multiFitSettingsGroup->addSubProperty(m_showPeriods); multiFitSettingsGroup->addSubProperty(m_showPeriods);
m_enumManager->setEnumNames(m_showPeriods, m_showPeriodValue); m_enumManager->setEnumNames(m_showPeriods, m_showPeriodValue);
multiFitSettingsGroup->addSubProperty(m_normalization);
/* Create editors and assign them to the managers */ /* Create editors and assign them to the managers */
createEditors(w); createEditors(w);
...@@ -461,9 +464,28 @@ double MuonFitPropertyBrowser::normalization() const { ...@@ -461,9 +464,28 @@ double MuonFitPropertyBrowser::normalization() const {
return readNormalization()[0]; return readNormalization()[0];
} }
void MuonFitPropertyBrowser::setNormalization() { void MuonFitPropertyBrowser::setNormalization() {
m_normalizationValue.clear(); setNormalization(workspaceName());
m_normalizationValue.append(QString::number(normalization())); }
m_enumManager->setEnumNames(m_normalization, m_normalizationValue); /**
* @param name :: the ws name to get normalization for
* @returns the normalization
*/
void MuonFitPropertyBrowser::setNormalization(const std::string name) {
m_normalizationValue.clear();
QString label;
auto norms = readMultipleNormalization();
std::string tmp =name;
// stored with ; instead of spaces
std::replace(tmp.begin(), tmp.end(), ' ', ';');
auto it = norms.find(tmp);
if (it == norms.end()) {
label = QString::fromStdString("N/A");
}
else {
label = QString::number(it->second);
}
m_normalizationValue.append(label);
m_enumManager->setEnumNames(m_normalization, m_normalizationValue);
} }
/** Called when a bool property changed /** Called when a bool property changed
...@@ -657,9 +679,6 @@ void MuonFitPropertyBrowser::doTFAsymmFit() { ...@@ -657,9 +679,6 @@ void MuonFitPropertyBrowser::doTFAsymmFit() {
//rescale WS: //rescale WS:
rescaleWS(norms, tmpWSNameNoRaw, -1.0); rescaleWS(norms, tmpWSNameNoRaw, -1.0);
} }
//*********************************************************************************
//replace with update
//*********************************************************************************
updateMultipleNormalization(norms); updateMultipleNormalization(norms);
} }
catch (const std::exception &e) { catch (const std::exception &e) {
...@@ -682,7 +701,7 @@ void MuonFitPropertyBrowser::updateMultipleNormalization(std::map<std::string, d ...@@ -682,7 +701,7 @@ void MuonFitPropertyBrowser::updateMultipleNormalization(std::map<std::string, d
auto it = norms.find(std::get<0>(norm)); auto it = norms.find(std::get<0>(norm));
if (it != norms.end() && it->second != std::get<1>(norm)) { if (it != norms.end() && it->second != std::get<1>(norm)) {
//write new norm //write new norm
row << it->second << std::get<0>(norm) << "Calculated"; row << it->second << std::get<0>(norm) << "Calculated";//pass calc or est
} }
else { else {
//write old norm //write old norm
...@@ -754,9 +773,6 @@ std::map<std::string, double> readMultipleNormalization() { ...@@ -754,9 +773,6 @@ std::map<std::string, double> readMultipleNormalization() {
} }
} }
else {
g_log.error("No normalizations found to read");
}
return norm; return norm;
} }
/** The transformation between normalized counts and asymmetry /** The transformation between normalized counts and asymmetry
...@@ -1133,10 +1149,12 @@ void MuonFitPropertyBrowser::setTFAsymmMode(bool enabled) { ...@@ -1133,10 +1149,12 @@ void MuonFitPropertyBrowser::setTFAsymmMode(bool enabled) {
// Show or hide the TFAsymmetry fit // Show or hide the TFAsymmetry fit
if (enabled) { if (enabled) {
m_settingsGroup->property()->addSubProperty(m_normalization); m_settingsGroup->property()->addSubProperty(m_normalization);
m_multiFitSettingsGroup->property()->addSubProperty(m_normalization);
m_settingsGroup->property()->addSubProperty(m_keepNorm); m_settingsGroup->property()->addSubProperty(m_keepNorm);
setNormalization(); setNormalization();
} else { } else {
m_settingsGroup->property()->removeSubProperty(m_normalization); m_settingsGroup->property()->removeSubProperty(m_normalization);
m_multiFitSettingsGroup->property()->removeSubProperty(m_normalization);
m_settingsGroup->property()->removeSubProperty(m_keepNorm); m_settingsGroup->property()->removeSubProperty(m_keepNorm);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment