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
b8541f1c
Commit
b8541f1c
authored
Oct 08, 2019
by
Anthony Lim
Browse files
refs #26544 added instrument view to new version of ALFView
parent
3fbc02c6
Changes
11
Hide whitespace changes
Inline
Side-by-side
qt/scientific_interfaces/Direct/ALFView.cpp
View file @
b8541f1c
...
...
@@ -18,7 +18,7 @@
namespace
MantidQt
{
namespace
CustomInterfaces
{
//
DECLARE_SUBWINDOW(ALFView)
DECLARE_SUBWINDOW
(
ALFView
)
/// static logger
Mantid
::
Kernel
::
Logger
g_log
(
"ALFView"
);
...
...
qt/scientific_interfaces/Direct/ALFView_model.cpp
View file @
b8541f1c
...
...
@@ -23,6 +23,8 @@ const std::string TMPNAME = "ALF_tmp";
const
std
::
string
INSTRUMENTNAME
=
"ALF"
;
const
std
::
string
WSNAME
=
"ALFData"
;
const
int
ERRORCODE
=
-
999
;
const
std
::
string
EXTRACTEDWS
=
"extractedTubes_"
;
const
std
::
string
CURVES
=
"Curves"
;
}
// namespace
using
namespace
Mantid
::
API
;
...
...
@@ -115,6 +117,8 @@ void ALFView_model::remove() {
AnalysisDataService
::
Instance
().
remove
(
TMPNAME
);
}
std
::
string
ALFView_model
::
dataFileName
()
{
return
WSNAME
;
}
int
ALFView_model
::
currentRun
()
{
try
{
...
...
@@ -130,5 +134,57 @@ bool ALFView_model::isErrorCode(const int run) { return (run == ERRORCODE); }
std
::
string
ALFView_model
::
getInstrument
()
{
return
INSTRUMENTNAME
;
}
void
ALFView_model
::
storeSingleTube
(
const
std
::
string
&
name
)
{
auto
alg
=
AlgorithmManager
::
Instance
().
create
(
"ScaleX"
);
alg
->
initialize
();
alg
->
setProperty
(
"InputWorkspace"
,
CURVES
);
alg
->
setProperty
(
"OutputWorkspace"
,
EXTRACTEDWS
+
name
);
alg
->
setProperty
(
"Factor"
,
180.
/
M_PI
);
// convert to degrees
alg
->
execute
();
auto
histogramAlg
=
AlgorithmManager
::
Instance
().
create
(
"ConvertToHistogram"
);
histogramAlg
->
initialize
();
histogramAlg
->
setProperty
(
"InputWorkspace"
,
EXTRACTEDWS
+
name
);
histogramAlg
->
setProperty
(
"OutputWorkspace"
,
EXTRACTEDWS
+
name
);
histogramAlg
->
execute
();
AnalysisDataService
::
Instance
().
remove
(
CURVES
);
}
void
ALFView_model
::
averageTube
(
const
int
&
oldTotalNumber
,
const
std
::
string
&
name
)
{
// multiply up current average
auto
ws
=
AnalysisDataService
::
Instance
().
retrieveWS
<
MatrixWorkspace
>
(
EXTRACTEDWS
+
name
);
ws
->
mutableY
(
0
)
*
double
(
oldTotalNumber
);
// get the data to add
storeSingleTube
(
name
);
// rebin to match
auto
rebin
=
AlgorithmManager
::
Instance
().
create
(
"RebinToWorkspace"
);
rebin
->
initialize
();
rebin
->
setProperty
(
"WorkspaceToRebin"
,
EXTRACTEDWS
+
name
);
rebin
->
setProperty
(
"WorkspaceToMatch"
,
ws
);
rebin
->
setProperty
(
"OutputWorkspace"
,
EXTRACTEDWS
+
name
);
rebin
->
execute
();
// add together
auto
alg
=
AlgorithmManager
::
Instance
().
create
(
"Plus"
);
alg
->
initialize
();
alg
->
setProperty
(
"LHSWorkspace"
,
EXTRACTEDWS
+
name
);
alg
->
setProperty
(
"RHSWorkspace"
,
ws
);
alg
->
setProperty
(
"OutputWorkspace"
,
EXTRACTEDWS
+
name
);
alg
->
execute
();
// do division
ws
=
AnalysisDataService
::
Instance
().
retrieveWS
<
MatrixWorkspace
>
(
EXTRACTEDWS
+
name
);
ws
->
mutableY
(
0
)
/=
(
double
(
oldTotalNumber
)
+
1.0
);
AnalysisDataService
::
Instance
().
addOrReplace
(
EXTRACTEDWS
+
name
,
ws
);
}
bool
ALFView_model
::
hasTubeBeenExtracted
(
const
std
::
string
&
name
)
{
return
AnalysisDataService
::
Instance
().
doesExist
(
EXTRACTEDWS
+
name
);
}
}
// namespace CustomInterfaces
}
// namespace MantidQt
qt/scientific_interfaces/Direct/ALFView_model.h
View file @
b8541f1c
...
...
@@ -20,9 +20,13 @@ public:
void
transformData
();
void
rename
();
void
remove
();
std
::
string
dataFileName
();
int
currentRun
();
bool
isErrorCode
(
const
int
run
);
std
::
string
getInstrument
();
void
storeSingleTube
(
const
std
::
string
&
name
);
void
averageTube
(
const
int
&
oldTotalNumber
,
const
std
::
string
&
name
);
bool
hasTubeBeenExtracted
(
const
std
::
string
&
name
);
};
}
// namespace CustomInterfaces
...
...
qt/scientific_interfaces/Direct/ALFView_presenter.cpp
View file @
b8541f1c
...
...
@@ -17,8 +17,11 @@ namespace CustomInterfaces {
ALFView_presenter
::
ALFView_presenter
(
ALFView_view
*
view
,
ALFView_model
*
model
)
:
m_view
(
view
),
m_model
(
model
),
m_currentRun
(
0
),
m_currentFile
(
""
),
m_loadRunObserver
(
nullptr
)
{
m_loadRunObserver
(
nullptr
),
m_numberOfTubesInAverage
(
0
),
m_extractSingleTubeObserver
(
nullptr
),
m_averageTubeObserver
(
nullptr
)
{
m_loadRunObserver
=
new
VoidObserver
();
m_extractSingleTubeObserver
=
new
VoidObserver
();
m_averageTubeObserver
=
new
VoidObserver
();
m_model
->
loadEmptyInstrument
();
}
...
...
@@ -28,6 +31,7 @@ void ALFView_presenter::initLayout() {
std
::
function
<
void
()
>
loadBinder
=
std
::
bind
(
&
ALFView_presenter
::
loadRunNumber
,
this
);
m_loadRunObserver
->
setSlot
(
loadBinder
);
initInstrument
();
}
void
ALFView_presenter
::
loadAndAnalysis
(
const
std
::
string
&
pathToRun
)
{
...
...
@@ -56,5 +60,68 @@ void ALFView_presenter::loadRunNumber() {
loadAndAnalysis
(
pathToRun
);
}
void
ALFView_presenter
::
initInstrument
()
{
// set up instrument
std
::
function
<
bool
(
std
::
map
<
std
::
string
,
bool
>
)
>
extractConditionBinder
=
std
::
bind
(
&
ALFView_presenter
::
extractTubeConditon
,
this
,
std
::
placeholders
::
_1
);
std
::
function
<
bool
(
std
::
map
<
std
::
string
,
bool
>
)
>
averageTubeConditonBinder
=
std
::
bind
(
&
ALFView_presenter
::
averageTubeConditon
,
this
,
std
::
placeholders
::
_1
);
m_view
->
setUpInstrument
(
m_model
->
dataFileName
(),
extractConditionBinder
,
averageTubeConditonBinder
);
// set up single tube extract
m_view
->
observeExtractSingleTube
(
m_extractSingleTubeObserver
);
std
::
function
<
void
()
>
extractSingleTubeBinder
=
std
::
bind
(
&
ALFView_presenter
::
extractSingleTube
,
this
);
m_extractSingleTubeObserver
->
setSlot
(
extractSingleTubeBinder
);
// set up average tube
m_view
->
observeAverageTube
(
m_averageTubeObserver
);
std
::
function
<
void
()
>
averageTubeBinder
=
std
::
bind
(
&
ALFView_presenter
::
averageTube
,
this
);
m_averageTubeObserver
->
setSlot
(
averageTubeBinder
);
}
bool
ALFView_presenter
::
extractTubeConditon
(
std
::
map
<
std
::
string
,
bool
>
tabBools
)
{
try
{
bool
ifCurve
=
(
tabBools
.
find
(
"plotStroed"
)
->
second
||
tabBools
.
find
(
"hasCurve"
)
->
second
);
return
(
tabBools
.
find
(
"isTube"
)
->
second
&&
ifCurve
);
}
catch
(...)
{
return
false
;
}
}
bool
ALFView_presenter
::
averageTubeConditon
(
std
::
map
<
std
::
string
,
bool
>
tabBools
)
{
try
{
bool
ifCurve
=
(
tabBools
.
find
(
"plotStroed"
)
->
second
||
tabBools
.
find
(
"hasCurve"
)
->
second
);
return
(
m_numberOfTubesInAverage
>
0
&&
tabBools
.
find
(
"isTube"
)
->
second
&&
ifCurve
&&
m_model
->
hasTubeBeenExtracted
(
m_model
->
getInstrument
()
+
std
::
to_string
(
m_currentRun
)));
}
catch
(...)
{
return
false
;
}
}
void
ALFView_presenter
::
extractSingleTube
()
{
m_model
->
storeSingleTube
(
m_model
->
getInstrument
()
+
std
::
to_string
(
m_currentRun
));
m_numberOfTubesInAverage
=
1
;
}
void
ALFView_presenter
::
averageTube
()
{
m_model
->
averageTube
(
m_numberOfTubesInAverage
,
m_model
->
getInstrument
()
+
std
::
to_string
(
m_currentRun
));
m_numberOfTubesInAverage
++
;
}
}
// namespace CustomInterfaces
}
// namespace MantidQt
\ No newline at end of file
qt/scientific_interfaces/Direct/ALFView_presenter.h
View file @
b8541f1c
...
...
@@ -31,12 +31,19 @@ private slots:
private:
void
loadAndAnalysis
(
const
std
::
string
&
run
);
void
initInstrument
();
bool
extractTubeConditon
(
std
::
map
<
std
::
string
,
bool
>
tabBools
);
bool
averageTubeConditon
(
std
::
map
<
std
::
string
,
bool
>
tabBools
);
void
extractSingleTube
();
void
averageTube
();
ALFView_view
*
m_view
;
ALFView_model
*
m_model
;
int
m_currentRun
;
std
::
string
m_currentFile
;
VoidObserver
*
m_loadRunObserver
;
int
m_numberOfTubesInAverage
;
VoidObserver
*
m_extractSingleTubeObserver
;
VoidObserver
*
m_averageTubeObserver
;
};
}
// namespace CustomInterfaces
}
// namespace MantidQt
...
...
qt/scientific_interfaces/Direct/ALFView_view.cpp
View file @
b8541f1c
...
...
@@ -5,6 +5,7 @@
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#include
"ALFView_view.h"
#include
"MantidQtWidgets/InstrumentView/InstrumentWidgetPickTab.h"
#include
<QMessageBox>
#include
<QSizePolicy>
...
...
@@ -16,12 +17,40 @@ namespace CustomInterfaces {
ALFView_view
::
ALFView_view
(
const
std
::
string
&
instrument
,
QWidget
*
parent
)
:
QSplitter
(
Qt
::
Vertical
,
parent
),
m_loadRunObservable
(
nullptr
),
m_files
(
nullptr
),
m_instrument
(
QString
::
fromStdString
(
instrument
))
{
m_files
(
nullptr
),
m_instrument
(
QString
::
fromStdString
(
instrument
)),
m_extractSingleTubeObservable
(
nullptr
),
m_averageTubeObservable
(
nullptr
),
m_instrumentWidget
(
nullptr
),
m_extractAction
(
nullptr
),
m_averageAction
(
nullptr
){
auto
loadWidget
=
generateLoadWidget
();
this
->
addWidget
(
loadWidget
);
}
void
ALFView_view
::
setUpInstrument
(
std
::
string
fileName
,
std
::
function
<
bool
(
std
::
map
<
std
::
string
,
bool
>
)
>
&
extractBinder
,
std
::
function
<
bool
(
std
::
map
<
std
::
string
,
bool
>
)
>
&
averageBinder
)
{
m_extractSingleTubeObservable
=
new
Observable
();
m_averageTubeObservable
=
new
Observable
();
m_instrumentWidget
=
new
MantidWidgets
::
InstrumentWidget
(
"ALFData"
);
m_instrumentWidget
->
removeTab
(
"Instrument"
);
m_instrumentWidget
->
removeTab
(
"Draw"
);
this
->
addWidget
(
m_instrumentWidget
);
// set up extract single tube
m_extractAction
=
new
QAction
(
"Extract Single Tube"
,
this
);
connect
(
m_extractAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
extractSingleTube
())),
m_instrumentWidget
->
getPickTab
()
->
addToContextMenu
(
m_extractAction
,
extractBinder
);
// set up add to average
m_averageAction
=
new
QAction
(
"Add Tube To Average"
,
this
);
connect
(
m_averageAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
averageTube
())),
m_instrumentWidget
->
getPickTab
()
->
addToContextMenu
(
m_averageAction
,
averageBinder
);
}
QWidget
*
ALFView_view
::
generateLoadWidget
()
{
m_loadRunObservable
=
new
Observable
();
...
...
@@ -69,9 +98,20 @@ void ALFView_view::fileLoaded() {
void
ALFView_view
::
warningBox
(
const
std
::
string
&
message
)
{
warningBox
(
QString
::
fromStdString
(
message
));
}
void
ALFView_view
::
warningBox
(
const
QString
&
message
)
{
QMessageBox
::
warning
(
this
,
m_instrument
+
" view"
,
message
);
}
void
ALFView_view
::
extractSingleTube
()
{
m_instrumentWidget
->
getPickTab
()
->
savePlotToWorkspace
();
m_extractSingleTubeObservable
->
notify
();
}
void
ALFView_view
::
averageTube
()
{
m_instrumentWidget
->
getPickTab
()
->
savePlotToWorkspace
();
m_averageTubeObservable
->
notify
();
}
}
// namespace CustomInterfaces
}
// namespace MantidQt
\ No newline at end of file
qt/scientific_interfaces/Direct/ALFView_view.h
View file @
b8541f1c
...
...
@@ -32,9 +32,20 @@ public:
m_loadRunObservable
->
attach
(
listener
);
};
void
warningBox
(
const
std
::
string
&
message
);
void
observeExtractSingleTube
(
Observer
*
listner
)
{
m_extractSingleTubeObservable
->
attach
(
listner
);
}
void
observeAverageTube
(
Observer
*
listner
)
{
m_averageTubeObservable
->
attach
(
listner
);
}
void
setUpInstrument
(
const
std
::
string
fileName
,
std
::
function
<
bool
(
std
::
map
<
std
::
string
,
bool
>
)
>
&
extractBinder
,
std
::
function
<
bool
(
std
::
map
<
std
::
string
,
bool
>
)
>
&
averageBinder
);
public
slots
:
void
fileLoaded
();
void
extractSingleTube
();
void
averageTube
();
private:
QWidget
*
generateLoadWidget
();
...
...
@@ -43,6 +54,12 @@ private:
Observable
*
m_loadRunObservable
;
API
::
MWRunFiles
*
m_files
;
QString
m_instrument
;
Observable
*
m_extractSingleTubeObservable
;
Observable
*
m_averageTubeObservable
;
MantidWidgets
::
InstrumentWidget
*
m_instrumentWidget
;
QAction
*
m_extractAction
;
QAction
*
m_averageAction
;
};
}
// namespace CustomInterfaces
}
// namespace MantidQt
...
...
qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidget.h
View file @
b8541f1c
...
...
@@ -155,6 +155,9 @@ public:
void
loadFromProject
(
const
std
::
string
&
lines
);
/// Save the widget to a Mantid projecy file.
std
::
string
saveToProject
()
const
;
void
removeTab
(
const
std
::
string
&
tabName
);
void
addTab
(
const
std
::
string
&
tabName
);
InstrumentWidgetPickTab
*
getPickTab
()
{
return
m_pickTab
;
};
signals:
void
enableLighting
(
bool
/*_t1*/
);
...
...
@@ -254,7 +257,8 @@ protected:
void
setSurfaceType
(
const
QString
&
typeStr
);
/// Return a filename to save a grouping to
QString
getSaveGroupingFilename
();
/// add the selected tabs
void
addSelectedTabs
();
// GUI elements
QLabel
*
mInteractionInfo
;
QTabWidget
*
mControlsTab
;
...
...
@@ -304,6 +308,8 @@ protected:
bool
m_blocked
;
QList
<
int
>
m_selectedDetectors
;
bool
m_instrumentDisplayContextMenuOn
;
/// dict of selected tabs
std
::
vector
<
std
::
pair
<
std
::
string
,
bool
>>
m_stateOfTabs
;
private:
/// ADS notification handlers
...
...
qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidgetPickTab.h
View file @
b8541f1c
...
...
@@ -95,10 +95,14 @@ public:
virtual
void
loadFromProject
(
const
std
::
string
&
lines
)
override
;
/// Save settings for the pick tab to a project file
virtual
std
::
string
saveToProject
()
const
override
;
void
addToContextMenu
(
QAction
*
action
,
std
::
function
<
bool
(
std
::
map
<
std
::
string
,
bool
>
)
>
&
actionCondition
);
public
slots
:
void
setTubeXUnits
(
int
units
);
void
changedIntegrationRange
(
double
/*unused*/
,
double
/*unused*/
);
void
savePlotToWorkspace
();
private
slots
:
void
plotContextMenu
();
void
sumDetectors
();
...
...
@@ -117,7 +121,6 @@ private slots:
void
updateSelectionInfoDisplay
();
void
shapeCreated
();
void
updatePlotMultipleDetectors
();
void
savePlotToWorkspace
();
private:
void
showEvent
(
QShowEvent
*
/*unused*/
)
override
;
...
...
@@ -179,7 +182,10 @@ private:
// Temporary caches for values from settings
int
m_tubeXUnitsCache
;
int
m_plotTypeCache
;
// store added actions and conditions
std
::
vector
<
std
::
pair
<
QAction
*
,
std
::
function
<
bool
(
std
::
map
<
std
::
string
,
bool
>
)
>>>
m_addedActions
;
friend
class
InstrumentWidgetEncoder
;
friend
class
InstrumentWidgetDecoder
;
};
...
...
qt/widgets/instrumentview/src/InstrumentWidget.cpp
View file @
b8541f1c
...
...
@@ -100,7 +100,7 @@ InstrumentWidget::InstrumentWidget(const QString &wsName, QWidget *parent,
Mantid
::
Kernel
::
ConfigService
::
Instance
().
getString
(
"defaultsave.directory"
))),
mViewChanged
(
false
),
m_blocked
(
false
),
m_instrumentDisplayContextMenuOn
(
false
)
{
m_instrumentDisplayContextMenuOn
(
false
)
,
m_stateOfTabs
(
std
::
vector
<
std
::
pair
<
std
::
string
,
bool
>>
{})
{
setFocusPolicy
(
Qt
::
StrongFocus
);
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
(
this
);
QSplitter
*
controlPanelLayout
=
new
QSplitter
(
Qt
::
Horizontal
);
...
...
@@ -1202,17 +1202,14 @@ void InstrumentWidget::createTabs(QSettings &settings) {
connect
(
m_renderTab
,
SIGNAL
(
setAutoscaling
(
bool
)),
this
,
SLOT
(
setColorMapAutoscaling
(
bool
)));
connect
(
m_renderTab
,
SIGNAL
(
rescaleColorMap
()),
this
,
SLOT
(
setupColorMap
()));
mControlsTab
->
addTab
(
m_renderTab
,
QString
(
"Render"
));
m_renderTab
->
loadSettings
(
settings
);
// Pick controls
m_pickTab
=
new
InstrumentWidgetPickTab
(
this
);
mControlsTab
->
addTab
(
m_pickTab
,
QString
(
"Pick"
));
m_pickTab
->
loadSettings
(
settings
);
// Mask controls
m_maskTab
=
new
InstrumentWidgetMaskTab
(
this
);
mControlsTab
->
addTab
(
m_maskTab
,
QString
(
"Draw"
));
connect
(
m_maskTab
,
SIGNAL
(
executeAlgorithm
(
const
QString
&
,
const
QString
&
)),
this
,
SLOT
(
executeAlgorithm
(
const
QString
&
,
const
QString
&
)));
connect
(
m_xIntegration
,
SIGNAL
(
changed
(
double
,
double
)),
m_maskTab
,
...
...
@@ -1221,15 +1218,75 @@ void InstrumentWidget::createTabs(QSettings &settings) {
// Instrument tree controls
m_treeTab
=
new
InstrumentWidgetTreeTab
(
this
);
mControlsTab
->
addTab
(
m_treeTab
,
QString
(
"Instrument"
));
m_treeTab
->
loadSettings
(
settings
);
connect
(
mControlsTab
,
SIGNAL
(
currentChanged
(
int
)),
this
,
SLOT
(
tabChanged
(
int
)));
m_stateOfTabs
.
push_back
(
std
::
make_pair
(
std
::
string
(
"Render"
),
true
));
m_stateOfTabs
.
push_back
(
std
::
make_pair
(
std
::
string
(
"Pick"
),
true
));
m_stateOfTabs
.
push_back
(
std
::
make_pair
(
std
::
string
(
"Draw"
),
true
));
m_stateOfTabs
.
push_back
(
std
::
make_pair
(
std
::
string
(
"Instrument"
),
true
));
addSelectedTabs
();
m_tabs
<<
m_renderTab
<<
m_pickTab
<<
m_maskTab
<<
m_treeTab
;
}
/**
* Adds the tabs that are currently selected to the GUI
*/
void
InstrumentWidget
::
addSelectedTabs
()
{
for
(
std
::
pair
<
std
::
string
,
bool
>
tab
:
m_stateOfTabs
)
{
if
(
tab
.
first
==
"Render"
&&
tab
.
second
)
{
mControlsTab
->
addTab
(
m_renderTab
,
QString
(
"Render"
));
}
if
(
tab
.
first
==
"Pick"
&&
tab
.
second
)
{
mControlsTab
->
addTab
(
m_pickTab
,
QString
(
"Pick"
));
}
if
(
tab
.
first
==
"Draw"
&&
tab
.
second
)
{
mControlsTab
->
addTab
(
m_maskTab
,
QString
(
"Draw"
));
}
if
(
tab
.
first
==
"Instrument"
&&
tab
.
second
)
{
mControlsTab
->
addTab
(
m_treeTab
,
QString
(
"Instrument"
));
}
}
}
/**
* Removes tab from the GUI
* param tabName: name of the tab to remove
*/
void
InstrumentWidget
::
removeTab
(
const
std
::
string
&
tabName
)
{
int
index
=
0
;
for
(
auto
name
=
m_stateOfTabs
.
begin
();
name
!=
m_stateOfTabs
.
end
();
name
++
)
{
if
(
name
->
first
==
tabName
&&
name
->
second
)
{
mControlsTab
->
removeTab
(
index
);
name
->
second
=
false
;
return
;
}
else
{
if
(
name
->
second
)
{
index
++
;
}
}
}
}
/**
* Adds tab back into the GUI
* param tabName: name of the tab to remove
*/
void
InstrumentWidget
::
addTab
(
const
std
::
string
&
tabName
)
{
for
(
auto
name
=
m_stateOfTabs
.
begin
();
name
!=
m_stateOfTabs
.
end
();
name
++
)
{
if
(
name
->
first
==
tabName
)
{
name
->
second
=
true
;
}
// remove everything
if
(
name
->
second
)
{
mControlsTab
->
removeTab
(
0
);
}
}
// add the selected tabs back into the GUI
addSelectedTabs
();
}
/**
* Return a name for a group in QSettings to store InstrumentWidget
* configuration.
...
...
qt/widgets/instrumentview/src/InstrumentWidgetPickTab.cpp
View file @
b8541f1c
...
...
@@ -77,7 +77,10 @@ double getPhiOffset(const Mantid::Kernel::V3D &pos, const double offset) {
*/
InstrumentWidgetPickTab
::
InstrumentWidgetPickTab
(
InstrumentWidget
*
instrWidget
)
:
InstrumentWidgetTab
(
instrWidget
),
m_freezePlot
(
false
),
m_tubeXUnitsCache
(
0
),
m_plotTypeCache
(
0
)
{
m_tubeXUnitsCache
(
0
),
m_plotTypeCache
(
0
),
m_addedActions
(
std
::
vector
<
std
::
pair
<
QAction
*
,
std
::
function
<
bool
(
std
::
map
<
std
::
string
,
bool
>
)
>>>
{})
{
// connect to InstrumentWindow signals
connect
(
m_instrWidget
,
SIGNAL
(
integrationRangeChanged
(
double
,
double
)),
this
,
...
...
@@ -636,7 +639,12 @@ void InstrumentWidgetPickTab::loadSettings(const QSettings &settings) {
m_plotTypeCache
=
settings
.
value
(
"PlotType"
,
DetectorPlotController
::
Single
).
toInt
();
}
void
InstrumentWidgetPickTab
::
addToContextMenu
(
QAction
*
action
,
std
::
function
<
bool
(
std
::
map
<
std
::
string
,
bool
>
)
>
&
actionCondition
)
{
auto
pair
=
std
::
make_pair
(
action
,
actionCondition
);
m_addedActions
.
push_back
(
pair
);
}
/**
* Fill in the context menu.
* @param context :: A menu to fill.
...
...
@@ -652,6 +660,15 @@ bool InstrumentWidgetPickTab::addToDisplayContextMenu(QMenu &context) const {
context
.
addAction
(
m_savePlotToWorkspace
);
res
=
true
;
}
std
::
map
<
std
::
string
,
bool
>
tabBools
=
{};
tabBools
.
insert
(
std
::
make_pair
(
"plotStroed"
,
m_plot
->
hasStored
()));
tabBools
.
insert
(
std
::
make_pair
(
"hasCurve"
,
m_plot
->
hasCurve
()));
tabBools
.
insert
(
std
::
make_pair
(
"isTube"
,
m_tube
->
isChecked
()));
for
(
auto
actionPair
:
m_addedActions
)
{
if
(
actionPair
.
second
&&
actionPair
.
second
(
tabBools
))
{
context
.
addAction
(
actionPair
.
first
);
}
}
return
res
;
}
...
...
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