diff --git a/docs/source/release/v3.14.0/indirect_inelastic.rst b/docs/source/release/v3.14.0/indirect_inelastic.rst index f5e378a9d9316fea484d45b018ebcd7238ad0ae8..df1cd2d56ce6bb9a19f7367781c6f01e3cc8534a 100644 --- a/docs/source/release/v3.14.0/indirect_inelastic.rst +++ b/docs/source/release/v3.14.0/indirect_inelastic.rst @@ -119,6 +119,16 @@ Bugfixes - An unwanted 'Fit' plot is no longer plotted in ResNorm when you click `Plot` in the output options. +Simulations Interface +--------------------- + +Improvements +############ + +- The Run button is now above the output options. +- The Run, Plot and Save buttons are now disabled while running and plotting is taking place. + + Diffraction Interface --------------------- diff --git a/qt/scientific_interfaces/Indirect/DensityOfStates.cpp b/qt/scientific_interfaces/Indirect/DensityOfStates.cpp index 7fd5aac8a620afb305591a3608983fa4e3b15604..8f1dd0131015a0b4411747a8dbeab4bb3eb2c386 100644 --- a/qt/scientific_interfaces/Indirect/DensityOfStates.cpp +++ b/qt/scientific_interfaces/Indirect/DensityOfStates.cpp @@ -28,9 +28,10 @@ DensityOfStates::DensityOfStates(QWidget *parent) connect(m_uiForm.mwInputFile, SIGNAL(filesFound()), this, SLOT(handleFileChange())); - // Handle plot and save - connect(m_uiForm.pbSave, SIGNAL(clicked()), this, SLOT(saveClicked())); + + connect(m_uiForm.pbRun, SIGNAL(clicked()), this, SLOT(runClicked())); connect(m_uiForm.pbPlot, SIGNAL(clicked()), this, SLOT(plotClicked())); + connect(m_uiForm.pbSave, SIGNAL(clicked()), this, SLOT(saveClicked())); m_uiForm.lwIons->setSelectionMode(QAbstractItemView::MultiSelection); } @@ -68,8 +69,10 @@ bool DensityOfStates::validate() { * Configures and executes the DensityOfStates algorithm. */ void DensityOfStates::run() { + setRunIsRunning(true); + // Get the SimulatedDensityOfStates algorithm - IAlgorithm_sptr dosAlgo = + auto dosAlgo = AlgorithmManager::Instance().create("SimulatedDensityOfStates"); const auto filename = m_uiForm.mwInputFile->getFirstFilename(); @@ -153,8 +156,11 @@ void DensityOfStates::dosAlgoComplete(bool error) { disconnect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(dosAlgoComplete(bool))); - if (error) - return; + setRunIsRunning(false); + if (error) { + setPlotEnabled(false); + setSaveEnabled(false); + } } /** @@ -212,7 +218,7 @@ void DensityOfStates::ionLoadComplete(bool error) { g_log.error("Could not get a list of ions from .phonon file"); // Get the list of ions from algorithm - ITableWorkspace_sptr ionTable = + auto ionTable = AnalysisDataService::Instance().retrieveWS<ITableWorkspace>("__dos_ions"); Column_sptr ionColumn = ionTable->getColumn("Species"); size_t numIons = ionColumn->size(); @@ -232,9 +238,6 @@ void DensityOfStates::ionLoadComplete(bool error) { // Select all ions by default m_uiForm.lwIons->selectAll(); - // Enable plot and save - m_uiForm.pbPlot->setEnabled(true); - m_uiForm.pbSave->setEnabled(true); } /** @@ -247,12 +250,16 @@ void DensityOfStates::loadSettings(const QSettings &settings) { m_uiForm.mwInputFile->readSettings(settings.group()); } +void DensityOfStates::runClicked() { runTab(); } + /** * Handle mantid plotting of workspace */ void DensityOfStates::plotClicked() { + setPlotIsPlotting(true); if (checkADSForPlotSaveWorkspace(m_outputWsName.toStdString(), true)) plotSpectrum(m_outputWsName); + setPlotIsPlotting(false); } /** @@ -264,5 +271,33 @@ void DensityOfStates::saveClicked() { m_batchAlgoRunner->executeBatchAsync(); } +void DensityOfStates::setRunIsRunning(bool running) { + m_uiForm.pbRun->setText(running ? "Running..." : "Run"); + setButtonsEnabled(!running); +} + +void DensityOfStates::setPlotIsPlotting(bool running) { + m_uiForm.pbPlot->setText(running ? "Plotting..." : "Plot Result"); + setButtonsEnabled(!running); +} + +void DensityOfStates::setButtonsEnabled(bool enabled) { + setRunEnabled(enabled); + setPlotEnabled(enabled); + setSaveEnabled(enabled); +} + +void DensityOfStates::setRunEnabled(bool enabled) { + m_uiForm.pbRun->setEnabled(enabled); +} + +void DensityOfStates::setPlotEnabled(bool enabled) { + m_uiForm.pbPlot->setEnabled(enabled); +} + +void DensityOfStates::setSaveEnabled(bool enabled) { + m_uiForm.pbSave->setEnabled(enabled); +} + } // namespace CustomInterfaces } // namespace MantidQt diff --git a/qt/scientific_interfaces/Indirect/DensityOfStates.h b/qt/scientific_interfaces/Indirect/DensityOfStates.h index 15e12577cf3a3d1e1e3385a1721d8db1044c747a..58da9a0baf9e2cd74d926afdb2a7861790ce0650 100644 --- a/qt/scientific_interfaces/Indirect/DensityOfStates.h +++ b/qt/scientific_interfaces/Indirect/DensityOfStates.h @@ -31,11 +31,18 @@ private slots: void dosAlgoComplete(bool error); void handleFileChange(); void ionLoadComplete(bool error); - /// Handle plotting and saving + void runClicked(); void plotClicked(); void saveClicked(); private: + void setRunIsRunning(bool running); + void setPlotIsPlotting(bool plotting); + void setButtonsEnabled(bool enabled); + void setRunEnabled(bool enabled); + void setPlotEnabled(bool enabled); + void setSaveEnabled(bool enabled); + /// The ui form Ui::DensityOfStates m_uiForm; /// Name of output workspace diff --git a/qt/scientific_interfaces/Indirect/DensityOfStates.ui b/qt/scientific_interfaces/Indirect/DensityOfStates.ui index 7aa9543c7b0084a2f7c44f39a4150295c0daee4a..fd23990a3976ae3e7a25d4e3ff8cbc469094e408 100644 --- a/qt/scientific_interfaces/Indirect/DensityOfStates.ui +++ b/qt/scientific_interfaces/Indirect/DensityOfStates.ui @@ -56,7 +56,7 @@ <x>0</x> <y>0</y> <width>480</width> - <height>379</height> + <height>328</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_3"> @@ -242,7 +242,16 @@ </property> <widget class="QWidget" name="pgDOS"> <layout class="QGridLayout" name="gridLayout_2"> - <property name="margin"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> <number>0</number> </property> <item row="0" column="0"> @@ -413,14 +422,32 @@ </sizepolicy> </property> <layout class="QGridLayout" name="gridLayout_3"> - <property name="margin"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> <number>0</number> </property> </layout> </widget> <widget class="QWidget" name="pgRaman"> <layout class="QGridLayout" name="gridLayout_4"> - <property name="margin"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> <number>0</number> </property> <item row="0" column="0"> @@ -485,6 +512,60 @@ </widget> </widget> </item> + <item> + <widget class="QGroupBox" name="gbRun"> + <property name="title"> + <string>Run</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>7</number> + </property> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>194</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="pbRun"> + <property name="text"> + <string>Run</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>193</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> <item> <widget class="QGroupBox" name="gbOutput"> <property name="sizePolicy"> diff --git a/qt/scientific_interfaces/Indirect/IndirectLoadILL.cpp b/qt/scientific_interfaces/Indirect/IndirectLoadILL.cpp index b8421038ecf942d4253ea210d9822f5d263a7544..3d6cc1fba4fdfa1120d0f1f4154390bcc11d69d4 100644 --- a/qt/scientific_interfaces/Indirect/IndirectLoadILL.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectLoadILL.cpp @@ -24,6 +24,13 @@ IndirectLoadILL::IndirectLoadILL(QWidget *parent) : IndirectToolsTab(parent) { connect(m_uiForm.mwRun, SIGNAL(filesFound()), this, SLOT(handleFilesFound())); connect(m_uiForm.chkUseMap, SIGNAL(toggled(bool)), m_uiForm.mwMapFile, SLOT(setEnabled(bool))); + + connect(this, + SIGNAL(updateRunButton(bool, std::string const &, QString const &, + QString const &)), + this, + SLOT(updateRunButton(bool, std::string const &, QString const &, + QString const &))); } /** @@ -56,24 +63,29 @@ bool IndirectLoadILL::validate() { * script that runs IndirectLoadILL */ void IndirectLoadILL::run() { + setRunIsRunning(true); + QString plot("False"); QString save("None"); QString useMap("False"); QString rejectZero("False"); - QString filename = m_uiForm.mwRun->getFirstFilename(); - QFileInfo finfo(filename); + QString const filename = m_uiForm.mwRun->getFirstFilename(); + QFileInfo const finfo(filename); QString ext = finfo.suffix().toLower(); - QString instrument = m_uiForm.iicInstrumentConfiguration->getInstrumentName(); - QString analyser = m_uiForm.iicInstrumentConfiguration->getAnalyserName(); - QString reflection = m_uiForm.iicInstrumentConfiguration->getReflectionName(); + QString const instrument = + m_uiForm.iicInstrumentConfiguration->getInstrumentName(); + QString const analyser = + m_uiForm.iicInstrumentConfiguration->getAnalyserName(); + QString const reflection = + m_uiForm.iicInstrumentConfiguration->getReflectionName(); if (m_uiForm.chkUseMap->isChecked()) { useMap = "True"; } - QString mapPath = m_uiForm.mwMapFile->getFirstFilename(); + QString const mapPath = m_uiForm.mwMapFile->getFirstFilename(); if (m_uiForm.chkRejectZero->isChecked()) { rejectZero = "True"; @@ -107,6 +119,7 @@ void IndirectLoadILL::run() { { pyFunc += "InxStart"; } else { + setRunIsRunning(false); emit showMessageBox("Could not find appropriate loading routine for " + filename); return; @@ -121,6 +134,8 @@ void IndirectLoadILL::run() { plot + "'," + save + ")"; } runPythonScript(pyInput); + + setRunIsRunning(false); } /** @@ -153,5 +168,19 @@ void IndirectLoadILL::handleFilesFound() { void IndirectLoadILL::runClicked() { runTab(); } +void IndirectLoadILL::setRunIsRunning(bool running) { + m_uiForm.pbRun->setText(running ? "Running..." : "Run"); + setRunEnabled(!running); + setPlotOptionsEnabled(!running); +} + +void IndirectLoadILL::setRunEnabled(bool enabled) { + m_uiForm.pbRun->setEnabled(enabled); +} + +void IndirectLoadILL::setPlotOptionsEnabled(bool enabled) { + m_uiForm.cbPlot->setEnabled(enabled); +} + } // namespace CustomInterfaces } // namespace MantidQt diff --git a/qt/scientific_interfaces/Indirect/IndirectLoadILL.h b/qt/scientific_interfaces/Indirect/IndirectLoadILL.h index 5a5568041ff0d02d35cafef938012acc5893fb30..1c461917df5caa07a7820f8d69b40818c0e6d28a 100644 --- a/qt/scientific_interfaces/Indirect/IndirectLoadILL.h +++ b/qt/scientific_interfaces/Indirect/IndirectLoadILL.h @@ -37,6 +37,10 @@ private slots: void runClicked(); private: + void setRunIsRunning(bool running); + void setRunEnabled(bool enabled); + void setPlotOptionsEnabled(bool enabled); + /// Map to store instrument analysers and reflections for this instrument QMap<QString, QStringList> m_paramMap; /// The ui form diff --git a/qt/scientific_interfaces/Indirect/IndirectMolDyn.cpp b/qt/scientific_interfaces/Indirect/IndirectMolDyn.cpp index 7a8a78e5f5ca3b4ddee115abafb2f0e13f5ce83d..3d7bfa55c183b67b892c745f8f3fda267a7cf013 100644 --- a/qt/scientific_interfaces/Indirect/IndirectMolDyn.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectMolDyn.cpp @@ -14,6 +14,15 @@ using namespace Mantid::API; +namespace { + +WorkspaceGroup_sptr getADSWorkspaceGroup(std::string const &workspaceName) { + return AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>( + workspaceName); +} + +} // namespace + namespace MantidQt { namespace CustomInterfaces { IndirectMolDyn::IndirectMolDyn(QWidget *parent) @@ -26,9 +35,13 @@ IndirectMolDyn::IndirectMolDyn(QWidget *parent) SLOT(setEnabled(bool))); connect(m_uiForm.cbVersion, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(versionSelected(const QString &))); - // Handle plotting and saving + + connect(m_uiForm.pbRun, SIGNAL(clicked()), this, SLOT(runClicked())); connect(m_uiForm.pbPlot, SIGNAL(clicked()), this, SLOT(plotClicked())); connect(m_uiForm.pbSave, SIGNAL(clicked()), this, SLOT(saveClicked())); + + connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, + SLOT(algorithmComplete(bool))); } void IndirectMolDyn::setup() {} @@ -71,38 +84,44 @@ bool IndirectMolDyn::validate() { * Collect the settings on the GUI and run the MolDyn algorithm. */ void IndirectMolDyn::run() { + setRunIsRunning(true); + // Get filename and base filename (for naming output workspace group) - QString filename = m_uiForm.mwRun->getFirstFilename(); - QFileInfo fi(filename); - QString baseName = fi.baseName(); + auto const filename = m_uiForm.mwRun->getFirstFilename(); + auto const baseName = QFileInfo(filename).baseName(); + auto const functionNames = m_uiForm.leFunctionNames->text().toStdString(); + bool const symmetrise = m_uiForm.ckSymmetrise->isChecked(); + bool const cropEnergy = m_uiForm.ckCropEnergy->isChecked(); + bool const resolution = m_uiForm.ckResolution->isChecked(); // Setup algorithm - IAlgorithm_sptr molDynAlg = AlgorithmManager::Instance().create("MolDyn"); + auto molDynAlg = AlgorithmManager::Instance().create("MolDyn"); molDynAlg->setProperty("Data", filename.toStdString()); - molDynAlg->setProperty("Functions", - m_uiForm.leFunctionNames->text().toStdString()); - molDynAlg->setProperty("SymmetriseEnergy", - m_uiForm.ckSymmetrise->isChecked()); + molDynAlg->setProperty("Functions", functionNames); + molDynAlg->setProperty("SymmetriseEnergy", symmetrise); molDynAlg->setProperty("OutputWorkspace", baseName.toStdString()); // Set energy crop option - if (m_uiForm.ckCropEnergy->isChecked()) - molDynAlg->setProperty( - "MaxEnergy", - QString::number(m_uiForm.dspMaxEnergy->value()).toStdString()); + if (cropEnergy) { + auto const maxEnergy = QString::number(m_uiForm.dspMaxEnergy->value()); + molDynAlg->setProperty("MaxEnergy", maxEnergy.toStdString()); + } // Set instrument resolution option - if (m_uiForm.ckResolution->isChecked()) - molDynAlg->setProperty( - "Resolution", - m_uiForm.dsResolution->getCurrentDataName().toStdString()); + if (resolution) { + auto const resolutionName = m_uiForm.dsResolution->getCurrentDataName(); + molDynAlg->setProperty("Resolution", resolutionName.toStdString()); + } runAlgorithm(molDynAlg); +} - // Enable plot and save - m_uiForm.pbPlot->setEnabled(true); - m_uiForm.pbSave->setEnabled(true); - m_uiForm.cbPlot->setEnabled(true); +void IndirectMolDyn::algorithmComplete(bool error) { + setRunIsRunning(false); + if (error) { + setPlotEnabled(false); + setSaveEnabled(false); + } } /** @@ -124,32 +143,34 @@ void IndirectMolDyn::versionSelected(const QString &version) { bool version4(version == "4"); m_uiForm.mwRun->isForDirectory(version4); } + +void IndirectMolDyn::runClicked() { runTab(); } + /** * Handle plotting of mantid workspace */ void IndirectMolDyn::plotClicked() { + setPlotIsPlotting(true); - QString filename = m_uiForm.mwRun->getFirstFilename(); - QFileInfo fi(filename); - QString baseName = fi.baseName(); + QString const filename = m_uiForm.mwRun->getFirstFilename(); + QString const baseName = QFileInfo(filename).baseName(); if (checkADSForPlotSaveWorkspace(baseName.toStdString(), true)) { - WorkspaceGroup_sptr diffResultsGroup = - AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>( - baseName.toStdString()); + auto const diffResultsGroup = getADSWorkspaceGroup(baseName.toStdString()); + auto const names = diffResultsGroup->getNames(); + auto const plotType = m_uiForm.cbPlot->currentText(); - auto names = diffResultsGroup->getNames(); - auto plotType = m_uiForm.cbPlot->currentText(); - - for (const auto &wsName : names) { + for (auto const &name : names) { if (plotType == "Spectra" || plotType == "Both") - plotSpectrum(QString::fromStdString(wsName)); + plotSpectrum(QString::fromStdString(name)); if (plotType == "Contour" || plotType == "Both") - plot2D(QString::fromStdString(wsName)); + plot2D(QString::fromStdString(name)); } } + + setPlotIsPlotting(false); } /** @@ -166,5 +187,34 @@ void IndirectMolDyn::saveClicked() { m_batchAlgoRunner->executeBatchAsync(); } +void IndirectMolDyn::setRunIsRunning(bool running) { + m_uiForm.pbRun->setText(running ? "Running..." : "Run"); + setButtonsEnabled(!running); +} + +void IndirectMolDyn::setPlotIsPlotting(bool running) { + m_uiForm.pbPlot->setText(running ? "Plotting..." : "Plot"); + setButtonsEnabled(!running); +} + +void IndirectMolDyn::setButtonsEnabled(bool enabled) { + setRunEnabled(enabled); + setPlotEnabled(enabled); + setSaveEnabled(enabled); +} + +void IndirectMolDyn::setRunEnabled(bool enabled) { + m_uiForm.pbRun->setEnabled(enabled); +} + +void IndirectMolDyn::setPlotEnabled(bool enabled) { + m_uiForm.pbPlot->setEnabled(enabled); + m_uiForm.cbPlot->setEnabled(enabled); +} + +void IndirectMolDyn::setSaveEnabled(bool enabled) { + m_uiForm.pbSave->setEnabled(enabled); +} + } // namespace CustomInterfaces } // namespace MantidQt diff --git a/qt/scientific_interfaces/Indirect/IndirectMolDyn.h b/qt/scientific_interfaces/Indirect/IndirectMolDyn.h index f9ac180f076bc92af7a3930805f55e2926f817a8..0c9489726d59278cb1f50af6faa4b2c2030fc9b8 100644 --- a/qt/scientific_interfaces/Indirect/IndirectMolDyn.h +++ b/qt/scientific_interfaces/Indirect/IndirectMolDyn.h @@ -28,11 +28,19 @@ public: private slots: void versionSelected(const QString &); - // Handle plotting and saving + void runClicked(); void plotClicked(); void saveClicked(); + void algorithmComplete(bool error); private: + void setRunIsRunning(bool running); + void setPlotIsPlotting(bool plotting); + void setButtonsEnabled(bool enabled); + void setRunEnabled(bool enabled); + void setPlotEnabled(bool enabled); + void setSaveEnabled(bool enabled); + // The ui form Ui::IndirectMolDyn m_uiForm; }; diff --git a/qt/scientific_interfaces/Indirect/IndirectMolDyn.ui b/qt/scientific_interfaces/Indirect/IndirectMolDyn.ui index c31855ea59d13da39060efcfce9ddc0d4a3e7780..36aeda0fb4c2e512cd927bd27053af59b230a711 100644 --- a/qt/scientific_interfaces/Indirect/IndirectMolDyn.ui +++ b/qt/scientific_interfaces/Indirect/IndirectMolDyn.ui @@ -269,6 +269,60 @@ </property> </spacer> </item> + <item> + <widget class="QGroupBox" name="gbRun"> + <property name="title"> + <string>Run</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>7</number> + </property> + <item> + <spacer name="horizontalSpacer_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>194</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="pbRun"> + <property name="text"> + <string>Run</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>193</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> <item> <widget class="QGroupBox" name="gbOutput"> <property name="sizePolicy"> diff --git a/qt/scientific_interfaces/Indirect/IndirectSassena.cpp b/qt/scientific_interfaces/Indirect/IndirectSassena.cpp index 92536c9c71c20235aa5dfaa6d9297dd26aa51136..0f645c472e9f86de99f314be5238421a78c1a217 100644 --- a/qt/scientific_interfaces/Indirect/IndirectSassena.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectSassena.cpp @@ -6,6 +6,8 @@ // SPDX - License - Identifier: GPL - 3.0 + #include "IndirectSassena.h" +#include "../General/UserInputValidator.h" + #include <QFileInfo> #include <QString> @@ -16,9 +18,10 @@ IndirectSassena::IndirectSassena(QWidget *parent) m_uiForm.setupUi(parent); connect(m_batchAlgoRunner, SIGNAL(batchComplete(bool)), this, SLOT(handleAlgorithmFinish(bool))); - // Handle plotting and saving - connect(m_uiForm.pbSave, SIGNAL(clicked()), this, SLOT(saveClicked())); + + connect(m_uiForm.pbRun, SIGNAL(clicked()), this, SLOT(runClicked())); connect(m_uiForm.pbPlot, SIGNAL(clicked()), this, SLOT(plotClicked())); + connect(m_uiForm.pbSave, SIGNAL(clicked()), this, SLOT(saveClicked())); } void IndirectSassena::setup() {} @@ -29,9 +32,14 @@ void IndirectSassena::setup() {} * @return Whether the form was valid */ bool IndirectSassena::validate() { - // There is very little to actually be invalid here - // that was not already done via restrictions on input - return true; + UserInputValidator uiv; + + auto const inputFileName = m_uiForm.mwInputFile->getFirstFilename(); + if (inputFileName.isEmpty()) + uiv.addErrorMessage("Incorrect input file provided."); + + emit showMessageBox(uiv.generateErrorMessage()); + return uiv.isAllInputValid(); } /** @@ -41,18 +49,17 @@ void IndirectSassena::run() { using namespace Mantid::API; using MantidQt::API::BatchAlgorithmRunner; - QString inputFileName = m_uiForm.mwInputFile->getFirstFilename(); - QFileInfo inputFileInfo(inputFileName); - m_outWsName = inputFileInfo.baseName(); + setRunIsRunning(true); + + QString const inputFileName = m_uiForm.mwInputFile->getFirstFilename(); + m_outWsName = QFileInfo(inputFileName).baseName(); // If the workspace group already exists then remove it if (AnalysisDataService::Instance().doesExist(m_outWsName.toStdString())) AnalysisDataService::Instance().deepRemoveGroup(m_outWsName.toStdString()); - IAlgorithm_sptr sassenaAlg = - AlgorithmManager::Instance().create("LoadSassena"); + auto sassenaAlg = AlgorithmManager::Instance().create("LoadSassena"); sassenaAlg->initialize(); - sassenaAlg->setProperty("Filename", inputFileName.toStdString()); sassenaAlg->setProperty("SortByQVectors", m_uiForm.cbSortQ->isChecked()); sassenaAlg->setProperty("TimeUnit", m_uiForm.sbTimeUnit->value()); @@ -72,14 +79,11 @@ void IndirectSassena::run() { * @param error If the batch was stopped due to error */ void IndirectSassena::handleAlgorithmFinish(bool error) { - - // Nothing to do if the algorithm failed - if (error) - return; - - // Enable plot and save - m_uiForm.pbPlot->setEnabled(true); - m_uiForm.pbSave->setEnabled(true); + setRunIsRunning(false); + if (error) { + setPlotEnabled(false); + setSaveEnabled(false); + } } /** @@ -92,12 +96,16 @@ void IndirectSassena::loadSettings(const QSettings &settings) { m_uiForm.mwInputFile->readSettings(settings.group()); } +void IndirectSassena::runClicked() { runTab(); } + /** * Handle mantid plotting of workspace */ void IndirectSassena::plotClicked() { + setPlotIsPlotting(true); if (checkADSForPlotSaveWorkspace(m_outWsName.toStdString(), true)) plotSpectrum(m_outWsName); + setPlotIsPlotting(false); } /** @@ -109,5 +117,33 @@ void IndirectSassena::saveClicked() { m_batchAlgoRunner->executeBatchAsync(); } +void IndirectSassena::setRunIsRunning(bool running) { + m_uiForm.pbRun->setText(running ? "Running..." : "Run"); + setButtonsEnabled(!running); +} + +void IndirectSassena::setPlotIsPlotting(bool running) { + m_uiForm.pbPlot->setText(running ? "Plotting..." : "Plot Result"); + setButtonsEnabled(!running); +} + +void IndirectSassena::setButtonsEnabled(bool enabled) { + setRunEnabled(enabled); + setPlotEnabled(enabled); + setSaveEnabled(enabled); +} + +void IndirectSassena::setRunEnabled(bool enabled) { + m_uiForm.pbRun->setEnabled(enabled); +} + +void IndirectSassena::setPlotEnabled(bool enabled) { + m_uiForm.pbPlot->setEnabled(enabled); +} + +void IndirectSassena::setSaveEnabled(bool enabled) { + m_uiForm.pbSave->setEnabled(enabled); +} + } // namespace CustomInterfaces } // namespace MantidQt diff --git a/qt/scientific_interfaces/Indirect/IndirectSassena.h b/qt/scientific_interfaces/Indirect/IndirectSassena.h index 0da1000a421683f4efa38f3372a6c6632d6269e2..9249c1a342b3026a8f1e1ec5ca720bec799da6d2 100644 --- a/qt/scientific_interfaces/Indirect/IndirectSassena.h +++ b/qt/scientific_interfaces/Indirect/IndirectSassena.h @@ -28,11 +28,18 @@ public: private slots: /// Handle completion of the algorithm batch void handleAlgorithmFinish(bool error); - /// Handle plotting and saving + void runClicked(); void plotClicked(); void saveClicked(); private: + void setRunIsRunning(bool running); + void setPlotIsPlotting(bool plotting); + void setButtonsEnabled(bool enabled); + void setRunEnabled(bool enabled); + void setPlotEnabled(bool enabled); + void setSaveEnabled(bool enabled); + /// The ui form Ui::IndirectSassena m_uiForm; /// Name of the output workspace group diff --git a/qt/scientific_interfaces/Indirect/IndirectSassena.ui b/qt/scientific_interfaces/Indirect/IndirectSassena.ui index 366f646444971972aef57b54fcf3e0428fa7d49f..15c39e4abe2c0feb69ac0510955a79a2b721bfeb 100644 --- a/qt/scientific_interfaces/Indirect/IndirectSassena.ui +++ b/qt/scientific_interfaces/Indirect/IndirectSassena.ui @@ -20,7 +20,16 @@ <string>Input File</string> </property> <layout class="QGridLayout" name="gridLayout"> - <property name="margin"> + <property name="leftMargin"> + <number>6</number> + </property> + <property name="topMargin"> + <number>6</number> + </property> + <property name="rightMargin"> + <number>6</number> + </property> + <property name="bottomMargin"> <number>6</number> </property> <item row="0" column="1"> @@ -104,6 +113,60 @@ </property> </spacer> </item> + <item> + <widget class="QGroupBox" name="gbRun"> + <property name="title"> + <string>Run</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>7</number> + </property> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>194</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="pbRun"> + <property name="text"> + <string>Run</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>193</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> <item> <widget class="QGroupBox" name="gbOutput"> <property name="sizePolicy"> diff --git a/qt/scientific_interfaces/Indirect/IndirectSimulation.cpp b/qt/scientific_interfaces/Indirect/IndirectSimulation.cpp index 64619526c93b24480b8f6154afe1a4a6fd128fe7..2e9dd963631ee613f57101e650c712c972893435 100644 --- a/qt/scientific_interfaces/Indirect/IndirectSimulation.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectSimulation.cpp @@ -57,7 +57,6 @@ void IndirectSimulation::initLayout() { // Connect statements for the buttons shared between all tabs on the Indirect // Bayes interface - connect(m_uiForm.pbRun, SIGNAL(clicked()), this, SLOT(runClicked())); connect(m_uiForm.pbHelp, SIGNAL(clicked()), this, SLOT(helpClicked())); connect(m_uiForm.pbManageDirs, SIGNAL(clicked()), this, SLOT(manageUserDirectories())); @@ -110,18 +109,6 @@ void IndirectSimulation::loadSettings() { settings.endGroup(); } -/** - * Slot to run the underlying algorithm code based on the currently selected - * tab. - * - * This method checks the tabs validate method is passing before calling - * the run method. - */ -void IndirectSimulation::runClicked() { - int tabIndex = m_uiForm.IndirectSimulationTabs->currentIndex(); - m_simulationTabs[tabIndex]->runTab(); -} - /** * Slot to open a new browser window and navigate to the help page * on the wiki for the currently selected tab. diff --git a/qt/scientific_interfaces/Indirect/IndirectSimulation.h b/qt/scientific_interfaces/Indirect/IndirectSimulation.h index 37c1b73d0a197e91e21ff3314c4b6bbeb7c504b1..68a5dbeb735e169d16514dfc7dafa6be2b7858dd 100644 --- a/qt/scientific_interfaces/Indirect/IndirectSimulation.h +++ b/qt/scientific_interfaces/Indirect/IndirectSimulation.h @@ -47,8 +47,6 @@ public: // public constructor, destructor and functions void initLayout() override; private slots: - /// Slot for clicking on the run button - void runClicked(); /// Slot for clicking on the help button void helpClicked(); /// Slot for clicking on the manage directories button diff --git a/qt/scientific_interfaces/Indirect/IndirectSimulation.ui b/qt/scientific_interfaces/Indirect/IndirectSimulation.ui index 1add339d839ac98dd93b13129206078a016145a9..fb0505ec23027ef9a77ac6471704bb81ac97f549 100644 --- a/qt/scientific_interfaces/Indirect/IndirectSimulation.ui +++ b/qt/scientific_interfaces/Indirect/IndirectSimulation.ui @@ -14,102 +14,82 @@ <string>Indirect Simulation</string> </property> <widget class="QWidget" name="centralwidget"> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QTabWidget" name="IndirectSimulationTabs"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="molDyn"> - <attribute name="title"> - <string>MolDyn</string> - </attribute> - </widget> - <widget class="QWidget" name="sassena"> - <attribute name="title"> - <string>Sassena</string> - </attribute> - </widget> - <widget class="QWidget" name="dos"> - <attribute name="title"> - <string>DensityOfStates</string> - </attribute> - </widget> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="layout_bottom"> - <item> - <widget class="QPushButton" name="pbHelp"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maximumSize"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - <property name="text"> - <string>?</string> - </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QTabWidget" name="IndirectSimulationTabs"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="molDyn"> + <attribute name="title"> + <string>MolDyn</string> + </attribute> </widget> - </item> - <item> - <spacer name="horizontalSpacer_14"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="pbRun"> - <property name="text"> - <string>Run</string> - </property> + <widget class="QWidget" name="sassena"> + <attribute name="title"> + <string>Sassena</string> + </attribute> </widget> - </item> - <item> - <spacer name="horizontalSpacer_11"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="pbManageDirs"> - <property name="text"> - <string>Manage Directories</string> - </property> + <widget class="QWidget" name="dos"> + <attribute name="title"> + <string>DensityOfStates</string> + </attribute> </widget> - </item> - </layout> - </item> - </layout> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="layout_bottom"> + <item> + <widget class="QPushButton" name="pbHelp"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string>?</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_14"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="pbManageDirs"> + <property name="text"> + <string>Manage Directories</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> </widget> </widget> <resources/>