Skip to content

Commit

Permalink
Added new widget and connected it to Fury interface.
Browse files Browse the repository at this point in the history
Refs #7681
  • Loading branch information
Samuel Jackson committed Aug 9, 2013
1 parent 2bb0664 commit 45546ec
Show file tree
Hide file tree
Showing 9 changed files with 526 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace IDA

private slots:
void resType(const QString& type);
void plotInput();
void plotInput(const QString& wsname);
void minChanged(double val);
void maxChanged(double val);
void updateRS(QtProperty* prop, double val);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,6 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="fury_pbPlotInput">
<property name="text">
<string>Plot Input</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
Expand Down Expand Up @@ -363,76 +356,22 @@
<item row="0" column="1">
<layout class="QHBoxLayout" name="fury_layout_input">
<item>
<widget class="QComboBox" name="fury_cbInputType">
<item>
<property name="text">
<string>File</string>
</property>
</item>
<item>
<property name="text">
<string>Workspace</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QStackedWidget" name="fury_swInput">
<property name="currentIndex">
<number>0</number>
<widget class="MantidQt::MantidWidgets::DataSelector" name="fury_dsInput">
<property name="loadLabelText" stdset="0">
<string>Plot Input</string>
</property>
<property name="workspaceSuffixes" stdset="0">
<stringlist>
<string>_red</string>
<string>_sqw</string>
</stringlist>
</property>
<property name="fileBrowserSuffixes" stdset="0">
<stringlist>
<string>_red.nxs</string>
<string>_sqw.nxs</string>
</stringlist>
</property>
<widget class="QWidget" name="fury_page_inputFile">
<layout class="QVBoxLayout" name="fury_page_inputFile_layout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="MantidQt::MantidWidgets::MWRunFiles" name="fury_iconFile">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>41</verstretch>
</sizepolicy>
</property>
<property name="findRunFiles" stdset="0">
<bool>false</bool>
</property>
<property name="label" stdset="0">
<string>Sample: </string>
</property>
<property name="multipleFiles" stdset="0">
<bool>true</bool>
</property>
<property name="fileExtensions">
<stringlist>
<string>_red.nxs</string>
<string>_sqw.nxs</string>
</stringlist>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="fury_page_inputWorkspace">
<layout class="QHBoxLayout" name="fury_layout_page_inputWorkspace">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="MantidQt::MantidWidgets::WorkspaceSelector" name="fury_wsSample">
<property name="WorkspaceTypes">
<stringlist/>
</property>
<property name="Suffix" stdset="0">
<stringlist>
<string>_res</string>
<string>_sqw</string>
</stringlist>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
Expand Down Expand Up @@ -2450,6 +2389,11 @@
<extends>QComboBox</extends>
<header>MantidQtMantidWidgets/WorkspaceSelector.h</header>
</customwidget>
<customwidget>
<class>MantidQt::MantidWidgets::DataSelector</class>
<extends>QWidget</extends>
<header>MantidQtMantidWidgets/DataSelector.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tabWidget</tabstop>
Expand All @@ -2461,9 +2405,7 @@
<tabstop>msd_ckVerbose</tabstop>
<tabstop>msd_ckPlot</tabstop>
<tabstop>msd_ckSave</tabstop>
<tabstop>fury_pbPlotInput</tabstop>
<tabstop>fury_cbResType</tabstop>
<tabstop>fury_cbInputType</tabstop>
<tabstop>fury_ckVerbose</tabstop>
<tabstop>fury_ckPlot</tabstop>
<tabstop>fury_ckSave</tabstop>
Expand Down
66 changes: 8 additions & 58 deletions Code/Mantid/MantidQt/CustomInterfaces/src/Fury.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,13 @@ namespace IDA
connect(m_furRange, SIGNAL(maxValueChanged(double)), this, SLOT(maxChanged(double)));
connect(m_furDblMng, SIGNAL(valueChanged(QtProperty*, double)), this, SLOT(updateRS(QtProperty*, double)));

connect(uiForm().fury_cbInputType, SIGNAL(currentIndexChanged(int)), uiForm().fury_swInput, SLOT(setCurrentIndex(int)));
connect(uiForm().fury_cbResType, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(resType(const QString&)));
connect(uiForm().fury_pbPlotInput, SIGNAL(clicked()), this, SLOT(plotInput()));
connect(uiForm().fury_dsInput, SIGNAL(dataReady(const QString&)), this, SLOT(plotInput(const QString&)));
}

void Fury::run()
{
QString filenames;
switch ( uiForm().fury_cbInputType->currentIndex() )
{
case 0:
filenames = uiForm().fury_iconFile->getFilenames().join("', r'");
break;
case 1:
filenames = uiForm().fury_wsSample->currentText();
break;
}
QString filenames = uiForm().fury_dsInput->getCurrentDataName();

QString pyInput =
"from IndirectDataAnalysis import fury\n"
Expand Down Expand Up @@ -101,16 +91,6 @@ namespace IDA
{
UserInputValidator uiv;

switch ( uiForm().fury_cbInputType->currentIndex() )
{
case 0:
uiv.checkMWRunFilesIsValid("Reduction", uiForm().fury_iconFile); break;
case 1:
uiv.checkWorkspaceSelectorIsNotEmpty("Reduction", uiForm().fury_wsSample); break;
}

uiv.checkMWRunFilesIsValid("Resolution", uiForm().fury_resFile);

double eLow = m_furDblMng->value(m_furProp["ELow"]);
double eWidth = m_furDblMng->value(m_furProp["EWidth"]);
double eHigh = m_furDblMng->value(m_furProp["EHigh"]);
Expand All @@ -122,7 +102,6 @@ namespace IDA

void Fury::loadSettings(const QSettings & settings)
{
uiForm().fury_iconFile->readSettings(settings.group());
uiForm().fury_resFile->readSettings(settings.group());
}

Expand All @@ -142,49 +121,20 @@ namespace IDA
uiForm().fury_resFile->setFileExtensions(exts);
}

void Fury::plotInput()
void Fury::plotInput(const QString& wsname)
{
using Mantid::API::MatrixWorkspace;
using Mantid::API::MatrixWorkspace_const_sptr;

MatrixWorkspace_const_sptr workspace;
if ( uiForm().fury_cbInputType->currentIndex() == 0 )
try
{
if ( uiForm().fury_iconFile->isValid() )
{
QString filename = uiForm().fury_iconFile->getFirstFilename();
QFileInfo fi(filename);
QString wsname = fi.baseName();
workspace = runLoadNexus(filename, wsname);
if(!workspace)
{
showInformationBox(QString("Unable to load file: ") + filename);
return;
}
}
else
{
showInformationBox("Selected input files are invalid.");
return;
}
workspace = Mantid::API::AnalysisDataService::Instance().retrieveWS<const MatrixWorkspace>(wsname.toStdString());
}
else if ( uiForm().fury_cbInputType->currentIndex() == 1 )
catch(Mantid::Kernel::Exception::NotFoundError&)
{
QString wsname = uiForm().fury_wsSample->currentText();
if(wsname.isEmpty())
{
showInformationBox("No workspace selected.");
return;
}
try
{
workspace = Mantid::API::AnalysisDataService::Instance().retrieveWS<const MatrixWorkspace>(wsname.toStdString());
}
catch(Mantid::Kernel::Exception::NotFoundError&)
{
showInformationBox(QString("Unable to retrieve workspace: " + wsname));
return;
}
showInformationBox(QString("Unable to retrieve workspace: " + wsname));
return;
}

m_furCurve = plotMiniplot(m_furPlot, m_furCurve, workspace, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QtDesigner>
#include <QtPlugin>
#include "MantidQtMantidWidgets/AlgorithmSelectorWidget.h"
#include "MantidQtMantidWidgets/DataSelector.h"
#include "MantidQtDesignerPlugins/DesignerPlugin.h"
#include "MantidQtMantidWidgets/ScriptEditor.h"
#include "MantidQtMantidWidgets/MWRunFiles.h"
Expand Down Expand Up @@ -143,4 +144,8 @@ DECLARE_WIDGET_PLUGIN(MessageDisplayPlugin,
MantidQt::MantidWidgets::MessageDisplay,
"Display messages with various priorities, optionally connecting to the logging framework");

DECLARE_WIDGET_PLUGIN(DataSelectorPlugin,
MantidQt::MantidWidgets::DataSelector,
"Choose a file path or workspace to work with");

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ PluginCollectionInterface::PluginCollectionInterface(QObject *parent) : QObject(
m_widgets.append(new SafeQwtPlotPlugin(this));
m_widgets.append(new AlgorithmPropertiesWidgetPlugin(this));
m_widgets.append(new ProcessingAlgoWidgetPlugin(this));

m_widgets.append(new DataSelectorPlugin(this));
m_widgets.append(new FitBrowserPlugin(this));
m_widgets.append(new MuonFitBrowserPlugin(this));
m_widgets.append(new MessageDisplayPlugin(this));
Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/MantidQt/MantidWidgets/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set ( SRC_FILES
src/AlgorithmSelectorWidget.cpp
src/DataSelector.cpp
src/DiagResults.cpp
src/FindReplaceDialog.cpp
src/FindDialog.cpp
Expand Down Expand Up @@ -39,6 +40,7 @@ set ( SRC_UNITY_IGNORE_FILES
# Header files with Q_OBJECT that qmake will "moc"
set ( MOC_FILES
inc/MantidQtMantidWidgets/AlgorithmSelectorWidget.h
inc/MantidQtMantidWidgets/DataSelector.h
inc/MantidQtMantidWidgets/DiagResults.h
inc/MantidQtMantidWidgets/FindReplaceDialog.h
inc/MantidQtMantidWidgets/FindDialog.h
Expand Down Expand Up @@ -78,6 +80,7 @@ set ( INC_FILES

# QtDesigner UI files to process
set ( UI_FILES
inc/MantidQtMantidWidgets/DataSelector.ui
inc/MantidQtMantidWidgets/ICatAdvancedSearch.ui
inc/MantidQtMantidWidgets/ICatInvestigation.ui
inc/MantidQtMantidWidgets/ICatMyDataSearch.ui
Expand Down

0 comments on commit 45546ec

Please sign in to comment.