Skip to content

Commit

Permalink
Replaced use of old widgets in diffraction
Browse files Browse the repository at this point in the history
Refs #10863
  • Loading branch information
DanNixon committed Jan 8, 2015
1 parent 18a04d6 commit b3ebfc9
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 54 deletions.
Expand Up @@ -29,9 +29,9 @@ class IndirectDiffractionReduction : public MantidQt::API::UserSubWindow
~IndirectDiffractionReduction();

public slots:
void instrumentSelected(const QString & instrumentName, const QString & analyserName,
const QString & reflectionName);
void demonRun();
void instrumentSelected(int);
void reflectionSelected(int);
void openDirectoryDialog();
void help();
void plotResults(bool error);
Expand Down
Expand Up @@ -58,13 +58,51 @@ IndirectDiffractionReduction::~IndirectDiffractionReduction()
saveSettings();
}

/**
* Sets up UI components and Qt signal/slot connections.
*/
void IndirectDiffractionReduction::initLayout()
{
m_uiForm.setupUi(this);

connect(m_uiForm.pbHelp, SIGNAL(clicked()), this, SLOT(help()));
connect(m_uiForm.pbManageDirs, SIGNAL(clicked()), this, SLOT(openDirectoryDialog()));
connect(m_uiForm.pbRun, SIGNAL(clicked()), this, SLOT(demonRun()));

connect(m_uiForm.iicInstrumentConfiguration, SIGNAL(instrumentConfigurationUpdated(const QString &, const QString &, const QSting &)),
this, SLOT(instrumentSelected(const QString &, const QString &, const QString &)));

// Update run button based on state of raw files field
connect(m_uiForm.dem_rawFiles, SIGNAL(fileTextChanged(const QString &)), this, SLOT(runFilesChanged()));
connect(m_uiForm.dem_rawFiles, SIGNAL(findingFiles()), this, SLOT(runFilesFinding()));
connect(m_uiForm.dem_rawFiles, SIGNAL(fileFindingFinished()), this, SLOT(runFilesFound()));

m_valInt = new QIntValidator(this);
m_valDbl = new QDoubleValidator(this);

m_uiForm.set_leSpecMin->setValidator(m_valInt);
m_uiForm.set_leSpecMax->setValidator(m_valInt);

m_uiForm.leRebinStart->setValidator(m_valDbl);
m_uiForm.leRebinWidth->setValidator(m_valDbl);
m_uiForm.leRebinEnd->setValidator(m_valDbl);

// Update the list of plot options when individual grouping is toggled
connect(m_uiForm.ckIndividualGrouping, SIGNAL(stateChanged(int)), this, SLOT(individualGroupingToggled(int)));

loadSettings();

// Update invalid rebinning markers
validateRebin();
}

/**
* Runs a diffraction reduction when the user clieks Run.
*/
void IndirectDiffractionReduction::demonRun()
{
QString instName = "IRIS";
QString mode = "diffspec";
QString instName = m_uiForm.iicInstrumentConfiguration->getInstrumentName();
QString mode = m_uiForm.iicInstrumentConfiguration->getReflectionName();

if(instName == "OSIRIS" && mode == "diffonly")
{
Expand Down Expand Up @@ -114,8 +152,8 @@ void IndirectDiffractionReduction::plotResults(bool error)
AnalysisDataService::Instance().remove("IndirectDiffraction_Workspaces");
}

QString instName = "IRIS";
QString mode = "diffspec";
QString instName = m_uiForm.iicInstrumentConfiguration->getInstrumentName();
QString mode = m_uiForm.iicInstrumentConfiguration->getReflectionName();

QString plotType = m_uiForm.cbPlotType->currentText();

Expand Down Expand Up @@ -306,20 +344,18 @@ MatrixWorkspace_sptr IndirectDiffractionReduction::loadInstrument(std::string in
}

/**
* Handles loading an instrument and reflections when an instruiment is selected form the drop down.
* Handles setting default spectra range when an instrument configuration is selected.
*
* @param instrumentName Name of selected instrument
* @param analyserName Name of selected analyser (should always be "diffraction")
* @param reflectionName Name of diffraction mode selected
*/
void IndirectDiffractionReduction::instrumentSelected(int)
void IndirectDiffractionReduction::instrumentSelected(const QString & instrumentName, const QString & analyserName,
const QString & reflectionName)
{
}
UNUSED_ARG(analyserName);

/**
* Handles setting default spectra range when a reflection is slected from the drop down.
*/
void IndirectDiffractionReduction::reflectionSelected(int)
{
std::string instrumentName = "IRIS";
std::string reflection = "diffspec";
MatrixWorkspace_sptr instWorkspace = loadInstrument(instrumentName, reflection);
MatrixWorkspace_sptr instWorkspace = loadInstrument(instrumentName.toStdString(), reflectionName.toStdString());
Instrument_const_sptr instrument = instWorkspace->getInstrument();

// Get default spectra range
Expand All @@ -341,7 +377,7 @@ void IndirectDiffractionReduction::reflectionSelected(int)
m_uiForm.swVanadium->setCurrentIndex(1);

// Hide options that the current instrument config cannot process
if(instrumentName == "OSIRIS" && reflection == "diffonly")
if(instrumentName == "OSIRIS" && reflectionName == "diffonly")
{
// Disable individual grouping
m_uiForm.ckIndividualGrouping->setToolTip("OSIRIS cannot group detectors individually in diffonly mode");
Expand Down Expand Up @@ -385,44 +421,8 @@ void IndirectDiffractionReduction::help()
QDesktopServices::openUrl(QUrl(url));
}

/**
* Sets up UI components and Qt signal/slot connections.
*/
void IndirectDiffractionReduction::initLayout()
{
m_uiForm.setupUi(this);

connect(m_uiForm.pbHelp, SIGNAL(clicked()), this, SLOT(help()));
connect(m_uiForm.pbManageDirs, SIGNAL(clicked()), this, SLOT(openDirectoryDialog()));
connect(m_uiForm.pbRun, SIGNAL(clicked()), this, SLOT(demonRun()));

// Update run button based on state of raw files field
connect(m_uiForm.dem_rawFiles, SIGNAL(fileTextChanged(const QString &)), this, SLOT(runFilesChanged()));
connect(m_uiForm.dem_rawFiles, SIGNAL(findingFiles()), this, SLOT(runFilesFinding()));
connect(m_uiForm.dem_rawFiles, SIGNAL(fileFindingFinished()), this, SLOT(runFilesFound()));

m_valInt = new QIntValidator(this);
m_valDbl = new QDoubleValidator(this);

m_uiForm.set_leSpecMin->setValidator(m_valInt);
m_uiForm.set_leSpecMax->setValidator(m_valInt);

m_uiForm.leRebinStart->setValidator(m_valDbl);
m_uiForm.leRebinWidth->setValidator(m_valDbl);
m_uiForm.leRebinEnd->setValidator(m_valDbl);

// Update the list of plot options when individual grouping is toggled
connect(m_uiForm.ckIndividualGrouping, SIGNAL(stateChanged(int)), this, SLOT(individualGroupingToggled(int)));

loadSettings();

// Update invalid rebinning markers
validateRebin();
}

void IndirectDiffractionReduction::initLocalPython()
{
instrumentSelected(0);
}

void IndirectDiffractionReduction::loadSettings()
Expand Down
Expand Up @@ -85,11 +85,18 @@ namespace MantidQt
/// Gets the name of the selected reflection
QString getReflectionName();

signals:
/// Emmitted when the instrument configuration is changed
void instrumentConfigurationUpdated(const QString & instrumentName,
const QString & analyserName, const QString & reflectionName);

private slots:
/// Updates the list of analysers and reflections based on the selected instrument
void updateInstrumentConfigurations(const QString & instrumentName);
/// Updates the list of reflections when an analyser is selected
void updateReflectionsList(int index);
/// Called when an instrument configuration is selected
void newInstrumentConfiguration();

private:
/// Member containing the widgets child widgets.
Expand Down
Expand Up @@ -34,6 +34,8 @@ namespace MantidQt
this, SLOT(updateInstrumentConfigurations(const QString)));
connect(m_uiForm.cbAnalyser, SIGNAL(currentIndexChanged(int)),
this, SLOT(updateReflectionsList(int)));
connect(m_uiForm.cbReflection, SIGNAL(currentIndexChanged(int)),
this, SLOT(newInstrumentConfiguration()));
}

IndirectInstrumentConfig::~IndirectInstrumentConfig()
Expand Down Expand Up @@ -225,5 +227,17 @@ namespace MantidQt
m_uiForm.cbReflection->blockSignals(reflectionPreviousBlocking);
}


void IndirectInstrumentConfig::newInstrumentConfiguration()
{
g_log.information() << "Instrument configuration: "
<< "Instrument=" << getInstrumentName().toStdString()
<< ", Analyser=" << getAnalyserName().toStdString()
<< ", Reflection=" << getReflectionName().toStdString()
<< std::endl;

emit instrumentConfigurationUpdated(getInstrumentName(), getAnalyserName(), getReflectionName());
}

} /* namespace MantidWidgets */
} /* namespace MantidQt */

0 comments on commit b3ebfc9

Please sign in to comment.