Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
fb852eda
Commit
fb852eda
authored
Sep 16, 2019
by
Anthony Lim
Browse files
refs #26726 Added Direct's ALFView GUI with basic data loading
parent
44f49cbe
Changes
9
Hide whitespace changes
Inline
Side-by-side
qt/scientific_interfaces/CMakeLists.txt
View file @
fb852eda
...
...
@@ -9,6 +9,7 @@ endif(${Boost_VERSION} GREATER 104799 AND ${qt_version} VERSION_GREATER 4.7.3)
# Now add the packages one-by-one, building up the dependencies as we go
add_subdirectory
(
General
)
add_subdirectory
(
Direct
)
add_subdirectory
(
MultiDatasetFit
)
add_subdirectory
(
Muon
)
add_subdirectory
(
ISISSANS
)
...
...
@@ -100,6 +101,7 @@ mtd_add_qt_tests(TARGET_NAME MantidQtScientificInterfacesTest
Qwt5
MTD_QT_LINK_LIBS
MantidScientificInterfacesGeneral
MantidScientificInterfacesDirect
MantidScientificInterfacesMuon
MantidScientificInterfacesISISReflectometry
MantidScientificInterfacesEnggDiffraction
...
...
qt/scientific_interfaces/Direct/ALFView_model.cpp
0 → 100644
View file @
fb852eda
#include
"ALFView_model.h"
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#include
"MantidAPI/Algorithm.h"
#include
"MantidAPI/AlgorithmManager.h"
#include
"MantidAPI/MatrixWorkspace.h"
#include
"MantidAPI/AnalysisDataService.h"
namespace
MantidQt
{
namespace
CustomInterfaces
{
namespace
Direct
{
/*
*Loads data for use in ALFView
* Loads data, normalise to current and then converts to d spacing
* @param name:: string name for ALF data
*/
void
loadData
(
const
std
::
string
&
name
)
{
Mantid
::
API
::
IAlgorithm_sptr
alg
=
Mantid
::
API
::
AlgorithmManager
::
Instance
().
create
(
"Load"
);
alg
->
initialize
();
alg
->
setProperty
(
"Filename"
,
name
);
alg
->
setProperty
(
"OutputWorkspace"
,
"ALF"
);
alg
->
execute
();
// check it is a valid ALF run number
Mantid
::
API
::
MatrixWorkspace_const_sptr
ws
=
Mantid
::
API
::
AnalysisDataService
::
Instance
().
retrieveWS
<
Mantid
::
API
::
MatrixWorkspace
>
(
"ALF"
);
auto
da
=
ws
->
getNEvents
();
auto
sadfas
=
ws
->
size
();
auto
gfgds
=
ws
->
readX
(
0
);
if
(
ws
->
getNEvents
()
!=
0
){
return
;
}
Mantid
::
API
::
IAlgorithm_sptr
normAlg
=
Mantid
::
API
::
AlgorithmManager
::
Instance
().
create
(
"NormaliseByCurrent"
);
normAlg
->
initialize
();
normAlg
->
setProperty
(
"InputWorkspace"
,
"ALF"
);
normAlg
->
setProperty
(
"OutputWorkspace"
,
"ALF"
);
normAlg
->
execute
();
Mantid
::
API
::
IAlgorithm_sptr
dSpacingAlg
=
Mantid
::
API
::
AlgorithmManager
::
Instance
().
create
(
"ConvertUnits"
);
dSpacingAlg
->
initialize
();
dSpacingAlg
->
setProperty
(
"InputWorkspace"
,
"ALF"
);
dSpacingAlg
->
setProperty
(
"Target"
,
"dSpacing"
);
dSpacingAlg
->
setProperty
(
"OutputWorkspace"
,
"ALF"
);
dSpacingAlg
->
execute
();
}
}
// namespace Direct
}
// namespace CustomInterfaces
}
// namespace MantidQt
\ No newline at end of file
qt/scientific_interfaces/Direct/ALFView_model.h
0 → 100644
View file @
fb852eda
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2014 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#ifndef MANTIDQT_CUSTOMINTERFACES_ALFVIEWMODEL_H_
#define MANTIDQT_CUSTOMINTERFACES_ALFVIEWMODEL_H_
#include
<string>
namespace
MantidQt
{
namespace
CustomInterfaces
{
namespace
Direct
{
void
loadData
(
const
std
::
string
&
name
);
}
// namespace Direct
}
// namespace CustomInterfaces
}
// namespace MantidQt
#endif
/* MANTIDQT_CUSTOMINTERFACES_ALFVIEWMODEL_H_ */
qt/scientific_interfaces/Direct/ALFView_presenter.cpp
0 → 100644
View file @
fb852eda
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#include
"ALFView_presenter.h"
#include
"ALFView_view.h"
#include
"ALFView_model.h"
#include
"MantidQtWidgets/Common/FunctionBrowser.h"
#include
"MantidQtWidgets/InstrumentView/InstrumentWidget.h"
#include
"MantidQtWidgets/InstrumentView/InstrumentWidgetPickTab.h"
#include
"MantidQtWidgets/Plotting/PreviewPlot.h"
#include
"MantidAPI/FileFinder.h"
#include
<QGridLayout>
#include
<QHBoxLayout>
#include
<QLineEdit>
#include
<QPushButton>
#include
<QSpinBox>
#include
<QSplitter>
#include
<QVBoxLayout>
#include
<QWidget>
#include
<math.h>
#include
<string>
namespace
MantidQt
{
namespace
CustomInterfaces
{
using
namespace
Mantid
::
Kernel
;
using
namespace
Mantid
::
API
;
DECLARE_SUBWINDOW
(
ALFView
)
using
namespace
Mantid
;
using
namespace
Mantid
::
API
;
using
namespace
Mantid
::
Kernel
;
using
namespace
MantidQt
::
MantidWidgets
;
using
namespace
MantidQt
::
CustomInterfaces
;
using
Mantid
::
API
::
Workspace_sptr
;
/// static logger
Mantid
::
Kernel
::
Logger
g_log
(
"ALFTest"
);
ALFView
::
ALFView
(
QWidget
*
parent
)
:
UserSubWindow
(
parent
),
m_view
(
nullptr
)
{
// set up an empty ALF workspace
IAlgorithm_sptr
alg
=
AlgorithmManager
::
Instance
().
create
(
"LoadEmptyInstrument"
);
alg
->
initialize
();
alg
->
setProperty
(
"OutputWorkspace"
,
"ALF"
);
alg
->
setProperty
(
"InstrumentName"
,
"ALF"
);
alg
->
execute
();
}
void
ALFView
::
initLayout
()
{
m_view
=
new
ALFView_view
(
this
);
this
->
setCentralWidget
(
m_view
);
connect
(
m_view
,
SIGNAL
(
newRun
()),
this
,
SLOT
(
loadRunNumber
()));
connect
(
m_view
,
SIGNAL
(
browsedToRun
(
const
::
std
::
string
&
)),
this
,
SLOT
(
loadBrowsedFile
(
const
std
::
string
&
)));
}
void
ALFView
::
loadRunNumber
()
{
const
std
::
string
runNumber
=
"ALF"
+
std
::
to_string
(
m_view
->
getRunNumber
());
std
::
string
filePath
;
// add memory of last good run and check alf instrument
try
{
filePath
=
Mantid
::
API
::
FileFinder
::
Instance
().
findRuns
(
runNumber
)[
0
];
}
catch
(...)
{
return
;
}
Direct
::
loadData
(
runNumber
);
}
void
ALFView
::
loadBrowsedFile
(
const
std
::
string
&
fileName
)
{
Direct
::
loadData
(
fileName
);
}
}
// namespace CustomInterfaces
}
// namespace MantidQt
\ No newline at end of file
qt/scientific_interfaces/Direct/ALFView_presenter.h
0 → 100644
View file @
fb852eda
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2014 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#ifndef MANTIDQT_CUSTOMINTERFACES_ALFVIEWPRESENTER_H_
#define MANTIDQT_CUSTOMINTERFACES_ALFVIEWPRESENTER_H_
#include
"DllConfig.h"
#include
"MantidQtWidgets/Common/UserSubWindow.h"
#include
"ALFView_view.h"
namespace
MantidQt
{
namespace
CustomInterfaces
{
/** ALCInterface : Custom interface for Avoided Level Crossing analysis
*/
class
MANTIDQT_DIRECT_DLL
ALFView
:
public
API
::
UserSubWindow
{
Q_OBJECT
public:
ALFView
(
QWidget
*
parent
=
nullptr
);
~
ALFView
(){};
static
std
::
string
name
()
{
return
"ALF View"
;
}
static
QString
categoryInfo
()
{
return
"Direct"
;
}
protected:
void
initLayout
()
override
;
private
slots
:
void
loadRunNumber
();
void
loadBrowsedFile
(
const
std
::
string
&
fileName
);
private:
ALFView_view
*
m_view
;
};
}
// customInterfaces
}
// MantidQt
#endif
/* MANTIDQT_CUSTOMINTERFACES_ALFVIEWPRESENTER_H_ */
qt/scientific_interfaces/Direct/ALFView_view.cpp
0 → 100644
View file @
fb852eda
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#include
"ALFView_view.h"
#include
<QGridLayout>
#include
<QLineEdit>
#include
<QSplitter>
#include
<QVBoxLayout>
#include
<QRegExpValidator>
#include
<QFileDialog>
namespace
MantidQt
{
namespace
CustomInterfaces
{
ALFView_view
::
ALFView_view
(
QWidget
*
parent
)
:
QWidget
(
parent
),
m_run
(
nullptr
)
{
QSplitter
*
MainLayout
=
new
QSplitter
(
Qt
::
Vertical
,
this
);
QWidget
*
loadBar
=
new
QWidget
();
generateLoadWidget
(
loadBar
);
MainLayout
->
addWidget
(
loadBar
);
// MainLayout->addWidget(widgetSplitter);
// this->addWidget(MainLayout);
}
void
ALFView_view
::
generateLoadWidget
(
QWidget
*
loadBar
)
{
m_run
=
new
QLineEdit
();
m_run
->
setValidator
(
new
QRegExpValidator
(
QRegExp
(
"[0-9]*"
),
m_run
));
connect
(
m_run
,
SIGNAL
(
editingFinished
()),
this
,
SLOT
(
runChanged
()));
m_browse
=
new
QPushButton
(
"Browse"
);
connect
(
m_browse
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
browse
()));
QHBoxLayout
*
loadLayout
=
new
QHBoxLayout
(
loadBar
);
loadLayout
->
addWidget
(
m_run
);
loadLayout
->
addWidget
(
m_browse
);
}
int
ALFView_view
::
getRunNumber
()
{
return
m_run
->
text
().
toInt
();
}
void
ALFView_view
::
runChanged
()
{
auto
fsafd
=
1
;
emit
newRun
();
}
void
ALFView_view
::
browse
()
{
auto
file
=
QFileDialog
::
getOpenFileName
(
this
,
"Open a file"
,
"directoryToOpen"
,
"File (*.nxs)"
);
auto
dad
=
file
.
toStdString
();
emit
browsedToRun
(
file
.
toStdString
());
}
}
// namespace CustomInterfaces
}
// namespace MantidQt
\ No newline at end of file
qt/scientific_interfaces/Direct/ALFView_view.h
0 → 100644
View file @
fb852eda
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2014 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#ifndef MANTIDQT_CUSTOMINTERFACES_ALFVIEW_VIEW_H_
#define MANTIDQT_CUSTOMINTERFACES_ALFVIEW_VIEW_H_
#include
"DllConfig.h"
#include
<QLineEdit>
#include
<QObject>
#include
<QPushButton>
#include
<string>
namespace
MantidQt
{
namespace
CustomInterfaces
{
class
ALFView_view
:
public
QWidget
{
Q_OBJECT
public:
ALFView_view
(
QWidget
*
parent
=
nullptr
);
int
getRunNumber
();
public
slots
:
void
runChanged
();
void
browse
();
signals:
void
newRun
();
void
browsedToRun
(
const
std
::
string
&
fileName
);
private:
void
generateLoadWidget
(
QWidget
*
loadBar
);
QLineEdit
*
m_run
;
QPushButton
*
m_browse
;
};
}
// namespace CustomInterfaces
}
// namespace MantidQt
#endif
/* MANTIDQT_CUSTOMINTERFACES_ALFVIEW_VIEW_H_ */
qt/scientific_interfaces/Direct/CMakeLists.txt
0 → 100644
View file @
fb852eda
set
(
SRC_FILES
ALFView_view.cpp
ALFView_presenter.cpp
ALFView_model.cpp
)
set
(
MOC_FILES
ALFView_view.h
ALFView_presenter.h
ALFView_model.h
)
set
(
INC_FILES
DllConfig.h
)
# Target
mtd_add_qt_library
(
TARGET_NAME MantidScientificInterfacesDirect
QT_VERSION 4
SRC
${
SRC_FILES
}
MOC
${
MOC_FILES
}
NOMOC
${
INC_FILES
}
DEFS
IN_MANTIDQT_DIRECT
SYSTEM_INCLUDE_DIRS
${
Boost_INCLUDE_DIRS
}
LINK_LIBS
${
TCMALLOC_LIBRARIES_LINKTIME
}
${
CORE_MANTIDLIBS
}
${
POCO_LIBRARIES
}
${
Boost_LIBRARIES
}
${
PYTHON_LIBRARIES
}
${
OPENGL_gl_LIBRARY
}
${
OPENGL_glu_LIBRARY
}
QT4_LINK_LIBS
Qt4::QtOpenGL
Qwt5
MTD_QT_LINK_LIBS
MantidQtWidgetsCommon
MantidQtWidgetsPlotting
MantidQtWidgetsInstrumentView
INSTALL_DIR_BASE
${
PLUGINS_DIR
}
OSX_INSTALL_RPATH
@loader_path/../../Contents/MacOS
@loader_path/../../plugins/qt4
LINUX_INSTALL_RPATH
"
\$
ORIGIN/../../
${
LIB_DIR
}
;
\$
ORIGIN/../../plugins/qt4/"
)
find_package
(
BoostPython REQUIRED
)
mtd_add_qt_library
(
TARGET_NAME MantidScientificInterfacesDirect
QT_VERSION 5
SRC
${
SRC_FILES
}
MOC
${
MOC_FILES
}
NOMOC
${
INC_FILES
}
DEFS
IN_MANTIDQT_DIRECT
LINK_LIBS
${
TCMALLOC_LIBRARIES_LINKTIME
}
${
CORE_MANTIDLIBS
}
PythonInterfaceCore
${
POCO_LIBRARIES
}
${
Boost_LIBRARIES
}
${
PYTHON_LIBRARIES
}
${
OPENGL_gl_LIBRARY
}
${
OPENGL_glu_LIBRARY
}
QT5_LINK_LIBS
Qt5::OpenGL
MTD_QT_LINK_LIBS
MantidQtWidgetsCommon
MantidQtWidgetsInstrumentView
MantidQtWidgetsPlotting
MantidQtWidgetsMplCpp
INSTALL_DIR_BASE
${
WORKBENCH_PLUGINS_DIR
}
OSX_INSTALL_RPATH
@loader_path/../../Contents/MacOS
@loader_path/../../plugins/qt5
LINUX_INSTALL_RPATH
"
\$
ORIGIN/../../
${
LIB_DIR
}
;
\$
ORIGIN/../../plugins/qt5/"
)
\ No newline at end of file
qt/scientific_interfaces/Direct/DllConfig.h
0 → 100644
View file @
fb852eda
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2014 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#ifndef MANTIDQT_DIRECT_DLLCONFIG_H_
#define MANTIDQT_DIRECT_DLLCONFIG_H_
#include
"MantidKernel/System.h"
/*
This file contains the DLLExport/DLLImport linkage configuration for the
MantidQt CustomInterfaces library
*/
#ifdef IN_MANTIDQT_DIRECT
#define MANTIDQT_DIRECT_DLL DLLExport
#define EXTERN_MANTIDQT_DIRECT
#else
#define MANTIDQT_DIRECT_DLL DLLImport
#define EXTERN_MANTIDQT_DIRECT EXTERN_IMPORT
#endif
#endif // MANTIDQT_DIRECT_DLLCONFIG_H_
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment