Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
5e655e0d
Commit
5e655e0d
authored
Dec 01, 2021
by
Martyn Gigg
Committed by
Peterson, Peter
Dec 02, 2021
Browse files
Run pre-commit on all files
Fixes unformatted code after a bug in the call to precommit was fixed recently
parent
b226eb80
Changes
22
Show whitespace changes
Inline
Side-by-side
docs/source/tutorials/mantid_basic_course/connecting_data_to_instruments/01_introduction.rst
View file @
5e655e0d
docs/source/tutorials/mantid_basic_course/connecting_data_to_instruments/02_displaying_and_navigating.rst
View file @
5e655e0d
docs/source/tutorials/mantid_basic_course/connecting_data_to_instruments/03_investigating_data.rst
View file @
5e655e0d
docs/source/tutorials/mantid_basic_course/connecting_data_to_instruments/04_masking_and_grouping.rst
View file @
5e655e0d
docs/source/tutorials/mantid_basic_course/connecting_data_to_instruments/05_instrument_tree.rst
View file @
5e655e0d
docs/source/tutorials/mantid_basic_course/connecting_data_to_instruments/06_sample_logs.rst
View file @
5e655e0d
docs/source/tutorials/mantid_basic_course/connecting_data_to_instruments/08_exercises_c.rst
View file @
5e655e0d
docs/source/tutorials/mantid_basic_course/connecting_data_to_instruments/index.rst
View file @
5e655e0d
qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/BankRenderingHelpers.h
View file @
5e655e0d
...
...
@@ -20,39 +20,34 @@ namespace MantidQt {
namespace
MantidWidgets
{
namespace
BankRenderingHelpers
{
EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW
std
::
pair
<
size_t
,
size_t
>
getCorrectedTextureSize
(
const
size_t
width
,
const
size_t
height
);
EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW
std
::
pair
<
size_t
,
size_t
>
getCorrectedTextureSize
(
const
size_t
width
,
const
size_t
height
);
/** Render GridDetector Bank as 6 bitmaps for all layers or one bitmap for the
selected layer Makes OpenGL calls for drawing the bank in an OpenGL window as
textures. NB glBegin() and glEnd() are called within this function.
*/
EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW
void
renderGridBankLayer
(
const
Mantid
::
Geometry
::
ComponentInfo
&
compInfo
,
EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW
void
renderGridBankLayer
(
const
Mantid
::
Geometry
::
ComponentInfo
&
compInfo
,
size_t
index
,
size_t
layer
);
EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW
void
renderGridBankOutline
(
const
Mantid
::
Geometry
::
ComponentInfo
&
compInfo
,
EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW
void
renderGridBankOutline
(
const
Mantid
::
Geometry
::
ComponentInfo
&
compInfo
,
size_t
index
);
EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW
void
renderGridBankFull
(
const
Mantid
::
Geometry
::
ComponentInfo
&
compInfo
,
EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW
void
renderGridBankFull
(
const
Mantid
::
Geometry
::
ComponentInfo
&
compInfo
,
size_t
index
,
detail
::
GridTextureFace
gridFace
);
/** Render RectangularDetector Bank as bitmap texture
Makes OpenGL calls for drawing the bank in an OpenGL window. NB glBegin() and
glEnd() are called within this function.
*/
EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW
void
renderRectangularBank
(
const
Mantid
::
Geometry
::
ComponentInfo
&
compInfo
,
EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW
void
renderRectangularBank
(
const
Mantid
::
Geometry
::
ComponentInfo
&
compInfo
,
size_t
index
);
/** Render Structured Detector Bank as quads
Makes OpenGL calls for drawing the bank in an OpenGL window. NB glBegin() and
glEnd() are called within this function.
*/
EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW
void
renderStructuredBank
(
const
Mantid
::
Geometry
::
ComponentInfo
&
compInfo
,
EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW
void
renderStructuredBank
(
const
Mantid
::
Geometry
::
ComponentInfo
&
compInfo
,
size_t
index
,
const
std
::
vector
<
GLColor
>
&
color
);
}
// namespace BankRenderingHelpers
}
// namespace MantidWidgets
...
...
qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/BankTextureBuilder.h
View file @
5e655e0d
...
...
@@ -25,29 +25,21 @@ namespace MantidWidgets {
namespace
detail
{
class
BankTextureBuilder
{
public:
BankTextureBuilder
(
const
Mantid
::
Geometry
::
ComponentInfo
&
compInfo
,
size_t
index
);
BankTextureBuilder
(
const
Mantid
::
Geometry
::
ComponentInfo
&
compInfo
,
size_t
index
);
~
BankTextureBuilder
();
void
buildColorTextures
(
const
std
::
vector
<
GLColor
>
&
colors
,
bool
isUsingLayer
=
false
,
size_t
layer
=
0
);
void
buildPickTextures
(
const
std
::
vector
<
GLColor
>
&
colors
,
bool
isUsingLayer
=
false
,
size_t
layer
=
0
);
void
uploadTextures
(
bool
picking
,
GridTextureFace
gridFace
=
GridTextureFace
::
Front
);
void
buildColorTextures
(
const
std
::
vector
<
GLColor
>
&
colors
,
bool
isUsingLayer
=
false
,
size_t
layer
=
0
);
void
buildPickTextures
(
const
std
::
vector
<
GLColor
>
&
colors
,
bool
isUsingLayer
=
false
,
size_t
layer
=
0
);
void
uploadTextures
(
bool
picking
,
GridTextureFace
gridFace
=
GridTextureFace
::
Front
);
void
bindTextures
(
bool
picking
)
const
;
void
unbindTextures
()
const
;
private:
void
buildOpenGLTextures
(
bool
picking
,
const
std
::
vector
<
GLColor
>
&
colors
,
bool
isUsingLayer
,
size_t
layer
);
void
buildOpenGLTextures
(
bool
picking
,
const
std
::
vector
<
GLColor
>
&
colors
,
bool
isUsingLayer
,
size_t
layer
);
void
buildTubeBankTextures
(
const
std
::
vector
<
GLColor
>
&
colors
,
bool
picking
);
void
buildGridBankFull
(
const
std
::
vector
<
GLColor
>
&
colors
,
bool
picking
);
void
buildGridBankLayer
(
const
std
::
vector
<
GLColor
>
&
colors
,
bool
picking
,
size_t
layer
);
void
buildGridBankTextures
(
const
std
::
vector
<
GLColor
>
&
colors
,
bool
picking
,
bool
isUsingLayer
,
size_t
layer
);
void
buildRectangularBankTextures
(
const
std
::
vector
<
GLColor
>
&
colors
,
bool
picking
);
void
buildGridBankLayer
(
const
std
::
vector
<
GLColor
>
&
colors
,
bool
picking
,
size_t
layer
);
void
buildGridBankTextures
(
const
std
::
vector
<
GLColor
>
&
colors
,
bool
picking
,
bool
isUsingLayer
,
size_t
layer
);
void
buildRectangularBankTextures
(
const
std
::
vector
<
GLColor
>
&
colors
,
bool
picking
);
void
uploadTubeBankTextures
(
bool
picking
);
void
uploadGridBankTexture
(
bool
picking
,
GridTextureFace
gridFace
);
void
uploadRectangularBankTextures
(
bool
picking
);
...
...
qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/BaseCustomInstrumentMocks.h
View file @
5e655e0d
...
...
@@ -28,11 +28,9 @@ using Mantid::Geometry::Instrument;
using
namespace
MantidQt
;
using
namespace
MantidQt
::
MantidWidgets
;
class
MockBaseCustomInstrumentView
:
public
MantidQt
::
MantidWidgets
::
IBaseCustomInstrumentView
{
class
MockBaseCustomInstrumentView
:
public
MantidQt
::
MantidWidgets
::
IBaseCustomInstrumentView
{
public:
explicit
MockBaseCustomInstrumentView
(
const
std
::
string
&
instrument
,
QWidget
*
parent
=
nullptr
)
{
explicit
MockBaseCustomInstrumentView
(
const
std
::
string
&
instrument
,
QWidget
*
parent
=
nullptr
)
{
(
void
)
instrument
;
(
void
)
parent
;
};
...
...
@@ -45,21 +43,16 @@ public:
MOCK_METHOD1
(
setInstrumentWidget
,
void
(
InstrumentWidget
*
instrument
));
MOCK_METHOD0
(
getInstrumentView
,
MantidWidgets
::
InstrumentWidget
*
());
MOCK_METHOD2
(
setUpInstrument
,
void
(
const
std
::
string
&
fileName
,
std
::
vector
<
std
::
function
<
bool
(
std
::
map
<
std
::
string
,
bool
>
)
>>
&
instrument
));
MOCK_METHOD1
(
addObserver
,
void
(
std
::
tuple
<
std
::
string
,
Observer
*>
&
listener
));
MOCK_METHOD2
(
setUpInstrument
,
void
(
const
std
::
string
&
fileName
,
std
::
vector
<
std
::
function
<
bool
(
std
::
map
<
std
::
string
,
bool
>
)
>>
&
instrument
));
MOCK_METHOD1
(
addObserver
,
void
(
std
::
tuple
<
std
::
string
,
Observer
*>
&
listener
));
MOCK_METHOD1
(
setupInstrumentAnalysisSplitters
,
void
(
QWidget
*
analysis
));
MOCK_METHOD0
(
setupHelp
,
void
());
// override getQWidget
MOCK_METHOD0
(
getQWidget
,
QWidget
*
());
};
class
MockBaseCustomInstrumentModel
:
public
MantidQt
::
MantidWidgets
::
IBaseCustomInstrumentModel
{
class
MockBaseCustomInstrumentModel
:
public
MantidQt
::
MantidWidgets
::
IBaseCustomInstrumentModel
{
public:
explicit
MockBaseCustomInstrumentModel
(){};
~
MockBaseCustomInstrumentModel
(){};
...
...
@@ -80,15 +73,12 @@ public:
// Allows us to turn on and off mocks to functions from the presenter
// do not repeat testing
class
PartMockBaseCustomInstrumentPresenter
:
public
BaseCustomInstrumentPresenter
{
class
PartMockBaseCustomInstrumentPresenter
:
public
BaseCustomInstrumentPresenter
{
public:
explicit
PartMockBaseCustomInstrumentPresenter
(
IBaseCustomInstrumentView
*
view
,
IBaseCustomInstrumentModel
*
model
,
explicit
PartMockBaseCustomInstrumentPresenter
(
IBaseCustomInstrumentView
*
view
,
IBaseCustomInstrumentModel
*
model
,
IPlotFitAnalysisPanePresenter
*
analysis
)
:
BaseCustomInstrumentPresenter
(
view
,
model
,
analysis
),
m_initInstrument
(
0
),
m_load
(
0
),
m_layout
(
0
),
m_sideEffects
(
0
),
m_mockInitInstrument
(
false
),
m_mockLoad
(
false
),
m_mockLayout
(
false
),
:
BaseCustomInstrumentPresenter
(
view
,
model
,
analysis
),
m_initInstrument
(
0
),
m_load
(
0
),
m_layout
(
0
),
m_sideEffects
(
0
),
m_mockInitInstrument
(
false
),
m_mockLoad
(
false
),
m_mockLayout
(
false
),
m_mockSideEffects
(
false
){};
~
PartMockBaseCustomInstrumentPresenter
(){};
...
...
@@ -98,8 +88,7 @@ public:
void
setMockLayout
()
{
m_mockLayout
=
true
;
};
void
setMockSideEffects
()
{
m_mockSideEffects
=
true
;
};
// override functions so we can call mocked versions
void
initInstrument
(
std
::
pair
<
instrumentSetUp
,
instrumentObserverOptions
>
*
setUp
=
nullptr
)
override
{
void
initInstrument
(
std
::
pair
<
instrumentSetUp
,
instrumentObserverOptions
>
*
setUp
=
nullptr
)
override
{
if
(
m_mockInitInstrument
)
{
m_initInstrument
+=
1
;
}
else
{
...
...
@@ -107,8 +96,7 @@ public:
};
}
void
initLayout
(
std
::
pair
<
instrumentSetUp
,
instrumentObserverOptions
>
*
setup
=
nullptr
)
override
final
{
void
initLayout
(
std
::
pair
<
instrumentSetUp
,
instrumentObserverOptions
>
*
setup
=
nullptr
)
override
final
{
if
(
m_mockLayout
==
true
)
{
m_layout
+=
1
;
}
else
{
...
...
@@ -139,14 +127,9 @@ public:
int
getLoadSideEffectsCount
()
{
return
m_sideEffects
;
};
// allow tests to get at protected/private functions/members
void
setUpInstrumentAnalysisSplitter
()
override
{
BaseCustomInstrumentPresenter
::
setUpInstrumentAnalysisSplitter
();
};
void
loadRunNumber
()
override
{
BaseCustomInstrumentPresenter
::
loadRunNumber
();
};
std
::
pair
<
instrumentSetUp
,
instrumentObserverOptions
>
*
setupInstrument
()
override
{
void
setUpInstrumentAnalysisSplitter
()
override
{
BaseCustomInstrumentPresenter
::
setUpInstrumentAnalysisSplitter
();
};
void
loadRunNumber
()
override
{
BaseCustomInstrumentPresenter
::
loadRunNumber
();
};
std
::
pair
<
instrumentSetUp
,
instrumentObserverOptions
>
*
setupInstrument
()
override
{
return
BaseCustomInstrumentPresenter
::
setupInstrument
();
};
...
...
qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/BinDialog.h
View file @
5e655e0d
...
...
@@ -33,8 +33,7 @@ class BinDialog : public QDialog {
public:
explicit
BinDialog
(
QWidget
*
parent
=
nullptr
);
~
BinDialog
()
override
;
void
setIntegralMinMax
(
double
/*minBin*/
,
double
/*maxBin*/
,
bool
/*useEverything*/
);
void
setIntegralMinMax
(
double
/*minBin*/
,
double
/*maxBin*/
,
bool
/*useEverything*/
);
signals:
/// This signal is sent when changing the bin range selected.
/// Parameters are: min, max, and a bool set to true to mean "everything"
...
...
qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentRenderer.h
View file @
5e655e0d
...
...
@@ -39,8 +39,7 @@ public:
~
InstrumentRenderer
();
void
renderInstrument
(
const
std
::
vector
<
bool
>
&
visibleComps
,
bool
showGuides
,
bool
picking
=
false
);
void
renderInstrument
(
const
std
::
vector
<
bool
>
&
visibleComps
,
bool
showGuides
,
bool
picking
=
false
);
void
reset
();
...
...
@@ -67,8 +66,7 @@ public:
private:
void
resetColors
();
void
resetPickColors
();
void
draw
(
const
std
::
vector
<
bool
>
&
visibleComps
,
bool
showGuides
,
bool
picking
);
void
draw
(
const
std
::
vector
<
bool
>
&
visibleComps
,
bool
showGuides
,
bool
picking
);
void
drawGridBank
(
size_t
bankIndex
,
bool
picking
);
void
drawRectangularBank
(
size_t
bankIndex
,
bool
picking
);
void
drawStructuredBank
(
size_t
bankIndex
,
bool
picking
);
...
...
qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidgetRenderTab.h
View file @
5e655e0d
...
...
@@ -33,8 +33,7 @@ class BinDialog;
/**
* Implements the Render tab in InstrumentWidget.
*/
class
EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW
InstrumentWidgetRenderTab
:
public
InstrumentWidgetTab
{
class
EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW
InstrumentWidgetRenderTab
:
public
InstrumentWidgetTab
{
Q_OBJECT
public:
...
...
@@ -48,8 +47,7 @@ public:
void
setScaleType
(
ColorMap
::
ScaleType
type
);
void
setAxis
(
const
QString
&
axisName
);
bool
areAxesOn
()
const
;
void
setupColorBar
(
const
ColorMap
&
/*cmap*/
,
double
/*minValue*/
,
double
/*maxValue*/
,
double
/*minPositive*/
,
void
setupColorBar
(
const
ColorMap
&
/*cmap*/
,
double
/*minValue*/
,
double
/*maxValue*/
,
double
/*minPositive*/
,
bool
/*autoscaling*/
);
/// Load the render window tab settings from file.
virtual
void
loadFromProject
(
const
std
::
string
&
lines
)
override
;
...
...
qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidgetTab.h
View file @
5e655e0d
...
...
@@ -23,9 +23,7 @@ namespace MantidWidgets {
class
InstrumentWidget
;
class
ProjectionSurface
;
class
EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW
InstrumentWidgetTab
:
public
QFrame
,
public
InstrumentWidgetTypes
{
class
EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW
InstrumentWidgetTab
:
public
QFrame
,
public
InstrumentWidgetTypes
{
Q_OBJECT
public:
explicit
InstrumentWidgetTab
(
InstrumentWidget
*
parent
);
...
...
@@ -39,9 +37,7 @@ public:
virtual
void
loadSettings
(
const
QSettings
&
/*unused*/
)
{}
/// Add tab-specific items to the context menu
/// Return true if at least 1 item was added or false otherwise.
virtual
bool
addToDisplayContextMenu
(
QMenu
&
/*unused*/
)
const
{
return
false
;
}
virtual
bool
addToDisplayContextMenu
(
QMenu
&
/*unused*/
)
const
{
return
false
;
}
/// Get the projection surface
std
::
shared_ptr
<
ProjectionSurface
>
getSurface
()
const
;
/// Load state for the widget tab from a project file
...
...
qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/MiniPlotQwt.h
View file @
5e655e0d
...
...
@@ -30,8 +30,7 @@ public:
explicit
MiniPlotQwt
(
QWidget
*
parent
);
~
MiniPlotQwt
()
override
;
void
setXLabel
(
QString
xunit
);
void
setData
(
std
::
vector
<
double
>
x
,
std
::
vector
<
double
>
y
,
QString
xunit
,
QString
curveLabel
);
void
setData
(
std
::
vector
<
double
>
x
,
std
::
vector
<
double
>
y
,
QString
xunit
,
QString
curveLabel
);
QString
label
()
const
{
return
m_label
;
}
void
setYAxisLabelRotation
(
double
degrees
);
void
addPeakLabel
(
const
PeakMarker2D
*
/*marker*/
);
...
...
@@ -79,8 +78,7 @@ private:
class
PeakLabel
:
public
QwtPlotItem
{
public:
PeakLabel
(
const
PeakMarker2D
*
m
,
const
MiniPlotQwt
*
plot
)
:
m_marker
(
m
),
m_plot
(
plot
)
{}
PeakLabel
(
const
PeakMarker2D
*
m
,
const
MiniPlotQwt
*
plot
)
:
m_marker
(
m
),
m_plot
(
plot
)
{}
void
draw
(
QPainter
*
painter
,
const
QwtScaleMap
&
xMap
,
const
QwtScaleMap
&
yMap
,
const
QRect
&
canvasRect
)
const
override
;
...
...
qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PanelsSurface.h
View file @
5e655e0d
...
...
@@ -48,18 +48,15 @@ private:
*/
class
PanelsSurface
:
public
UnwrappedSurface
{
public:
PanelsSurface
(
const
InstrumentActor
*
rootActor
,
const
Mantid
::
Kernel
::
V3D
&
origin
,
const
Mantid
::
Kernel
::
V3D
&
axis
);
PanelsSurface
(
const
InstrumentActor
*
rootActor
,
const
Mantid
::
Kernel
::
V3D
&
origin
,
const
Mantid
::
Kernel
::
V3D
&
axis
);
~
PanelsSurface
()
override
;
void
init
()
override
;
void
project
(
const
Mantid
::
Kernel
::
V3D
&
/*pos*/
,
double
&
/*u*/
,
double
&
/*v*/
,
double
&
/*uscale*/
,
void
project
(
const
Mantid
::
Kernel
::
V3D
&
/*pos*/
,
double
&
/*u*/
,
double
&
/*v*/
,
double
&
/*uscale*/
,
double
&
/*vscale*/
)
const
override
;
protected:
boost
::
optional
<
std
::
pair
<
std
::
vector
<
size_t
>
,
Mantid
::
Kernel
::
V3D
>>
findFlatPanels
(
size_t
rootIndex
,
std
::
vector
<
bool
>
&
visited
);
boost
::
optional
<
std
::
pair
<
std
::
vector
<
size_t
>
,
Mantid
::
Kernel
::
V3D
>>
findFlatPanels
(
size_t
rootIndex
,
std
::
vector
<
bool
>
&
visited
);
void
processStructured
(
size_t
rootIndex
);
...
...
@@ -67,22 +64,18 @@ protected:
void
processGrid
(
size_t
rootIndex
);
std
::
pair
<
std
::
vector
<
size_t
>
,
Mantid
::
Kernel
::
V3D
>
processUnstructured
(
size_t
rootIndex
,
std
::
vector
<
bool
>
&
visited
);
std
::
pair
<
std
::
vector
<
size_t
>
,
Mantid
::
Kernel
::
V3D
>
processUnstructured
(
size_t
rootIndex
,
std
::
vector
<
bool
>
&
visited
);
void
rotate
(
const
UnwrappedDetector
&
udet
,
Mantid
::
Kernel
::
Quat
&
R
)
const
override
;
void
rotate
(
const
UnwrappedDetector
&
udet
,
Mantid
::
Kernel
::
Quat
&
R
)
const
override
;
// Setup the projection axes
void
setupAxes
();
// Add a flat bank
void
addFlatBankOfDetectors
(
const
Mantid
::
Kernel
::
V3D
&
normal
,
const
std
::
vector
<
size_t
>
&
detectors
);
void
addFlatBankOfDetectors
(
const
Mantid
::
Kernel
::
V3D
&
normal
,
const
std
::
vector
<
size_t
>
&
detectors
);
void
constructFromComponentInfo
();
Mantid
::
Kernel
::
Quat
calcBankRotation
(
const
Mantid
::
Kernel
::
V3D
&
detPos
,
Mantid
::
Kernel
::
V3D
normal
)
const
;
Mantid
::
Kernel
::
Quat
calcBankRotation
(
const
Mantid
::
Kernel
::
V3D
&
detPos
,
Mantid
::
Kernel
::
V3D
normal
)
const
;
// Add a detector from an assembly
void
addDetector
(
size_t
detIndex
,
const
Mantid
::
Kernel
::
V3D
&
refPos
,
int
bankIndex
,
const
Mantid
::
Kernel
::
Quat
&
rotation
);
void
addDetector
(
size_t
detIndex
,
const
Mantid
::
Kernel
::
V3D
&
refPos
,
int
bankIndex
,
const
Mantid
::
Kernel
::
Quat
&
rotation
);
// Spread the banks over the projection plane
void
spreadBanks
();
// Find index of the largest bank
...
...
qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PeakOverlay.h
View file @
5e655e0d
...
...
@@ -56,19 +56,13 @@ private:
/// Helper class for scaling peak markers to intensities.
class
AbstractIntensityScale
{
public:
explicit
AbstractIntensityScale
(
const
std
::
shared_ptr
<
Mantid
::
API
::
IPeaksWorkspace
>
&
pws
)
{
setPeaksWorkspace
(
pws
);
}
explicit
AbstractIntensityScale
(
const
std
::
shared_ptr
<
Mantid
::
API
::
IPeaksWorkspace
>
&
pws
)
{
setPeaksWorkspace
(
pws
);
}
virtual
~
AbstractIntensityScale
()
{}
void
setPeaksWorkspace
(
const
std
::
shared_ptr
<
Mantid
::
API
::
IPeaksWorkspace
>
&
pws
);
void
setPeaksWorkspace
(
const
std
::
shared_ptr
<
Mantid
::
API
::
IPeaksWorkspace
>
&
pws
);
virtual
PeakMarker2D
::
Style
getScaledMarker
(
double
intensity
,
const
PeakMarker2D
::
Style
&
baseStyle
)
const
=
0
;
virtual
PeakMarker2D
::
Style
getScaledMarker
(
double
intensity
,
const
PeakMarker2D
::
Style
&
baseStyle
)
const
=
0
;
protected:
double
m_maxIntensity
=
0.0
;
...
...
@@ -78,15 +72,12 @@ protected:
/// Default intensity scale leaves all markers unchanged.
class
DefaultIntensityScale
:
public
AbstractIntensityScale
{
public:
explicit
DefaultIntensityScale
(
const
std
::
shared_ptr
<
Mantid
::
API
::
IPeaksWorkspace
>
&
pws
)
explicit
DefaultIntensityScale
(
const
std
::
shared_ptr
<
Mantid
::
API
::
IPeaksWorkspace
>
&
pws
)
:
AbstractIntensityScale
(
pws
)
{}
protected:
/// Returns the base style unmodified.
PeakMarker2D
::
Style
getScaledMarker
(
double
intensity
,
const
PeakMarker2D
::
Style
&
baseStyle
)
const
override
{
PeakMarker2D
::
Style
getScaledMarker
(
double
intensity
,
const
PeakMarker2D
::
Style
&
baseStyle
)
const
override
{
UNUSED_ARG
(
intensity
);
return
baseStyle
;
...
...
@@ -97,14 +88,11 @@ protected:
/// strong, very strong).
class
QualitativeIntensityScale
:
public
AbstractIntensityScale
{
public:
explicit
QualitativeIntensityScale
(
const
std
::
shared_ptr
<
Mantid
::
API
::
IPeaksWorkspace
>
&
pws
)
explicit
QualitativeIntensityScale
(
const
std
::
shared_ptr
<
Mantid
::
API
::
IPeaksWorkspace
>
&
pws
)
:
AbstractIntensityScale
(
pws
)
{}
protected:
PeakMarker2D
::
Style
getScaledMarker
(
double
intensity
,
const
PeakMarker2D
::
Style
&
baseStyle
)
const
override
;
PeakMarker2D
::
Style
getScaledMarker
(
double
intensity
,
const
PeakMarker2D
::
Style
&
baseStyle
)
const
override
;
private:
// cppcheck-suppress unusedPrivateFunction
...
...
@@ -117,12 +105,10 @@ private:
/**
* Class for managing peak markers on an unwrapped instrument surface.
*/
class
PeakOverlay
:
public
Shape2DCollection
,
public
MantidQt
::
API
::
WorkspaceObserver
{
class
PeakOverlay
:
public
Shape2DCollection
,
public
MantidQt
::
API
::
WorkspaceObserver
{
Q_OBJECT
public:
PeakOverlay
(
UnwrappedSurface
*
surface
,
const
std
::
shared_ptr
<
Mantid
::
API
::
IPeaksWorkspace
>
&
pws
);
PeakOverlay
(
UnwrappedSurface
*
surface
,
const
std
::
shared_ptr
<
Mantid
::
API
::
IPeaksWorkspace
>
&
pws
);
~
PeakOverlay
()
override
{}
/// Override the drawing method
void
draw
(
QPainter
&
painter
)
const
override
;
...
...
@@ -137,9 +123,7 @@ public:
Mantid
::
Geometry
::
IPeak
&
getPeak
(
int
/*i*/
);
QList
<
PeakMarker2D
*>
getSelectedPeakMarkers
();
/// Return PeaksWorkspace associated with this overlay.
std
::
shared_ptr
<
Mantid
::
API
::
IPeaksWorkspace
>
getPeaksWorkspace
()
{
return
m_peaksWorkspace
;
}
std
::
shared_ptr
<
Mantid
::
API
::
IPeaksWorkspace
>
getPeaksWorkspace
()
{
return
m_peaksWorkspace
;
}
/// set HKL precision
void
setPrecision
(
int
prec
)
const
{
m_precision
=
prec
;
}
void
setShowRowsFlag
(
bool
yes
)
{
m_showRows
=
yes
;
}
...
...
@@ -153,19 +137,15 @@ signals:
private:
/// A WorkspaceObserver handle implemented.
void
afterReplaceHandle
(
const
std
::
string
&
wsName
,
const
Mantid
::
API
::
Workspace_sptr
&
ws
)
override
;
void
afterReplaceHandle
(
const
std
::
string
&
wsName
,
const
Mantid
::
API
::
Workspace_sptr
&
ws
)
override
;
PeakMarker2D
::
Style
getCurrentStyle
()
const
;
void
recreateMarkers
(
const
PeakMarker2D
::
Style
&
style
);
QMultiHash
<
int
,
PeakMarker2D
*>
m_det2marker
;
///< detector ID to PeakMarker2D map
QMultiHash
<
int
,
PeakMarker2D
*>
m_det2marker
;
///< detector ID to PeakMarker2D map
mutable
QList
<
PeakHKL
>
m_labels
;
std
::
shared_ptr
<
Mantid
::
API
::
IPeaksWorkspace
>
m_peaksWorkspace
;
///< peaks to be drawn ontop of the surface
UnwrappedSurface
*
m_surface
;
///< pointer to the surface this overlay is applied to
std
::
shared_ptr
<
Mantid
::
API
::
IPeaksWorkspace
>
m_peaksWorkspace
;
///< peaks to be drawn ontop of the surface
UnwrappedSurface
*
m_surface
;
///< pointer to the surface this overlay is applied to
mutable
int
m_precision
;
mutable
bool
m_showRows
;
///< flag to show peak row index
mutable
bool
m_showLabels
;
///< flag to show peak hkl labels
...
...
qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedDetector.h
View file @
5e655e0d
qt/widgets/instrumentview/src/MiniPlotQwt.cpp
View file @
5e655e0d
...
...
@@ -33,8 +33,7 @@ Mantid::Kernel::Logger g_log("MiniPlotQwt");
namespace
MantidQt
{
namespace
MantidWidgets
{
MiniPlotQwt
::
MiniPlotQwt
(
QWidget
*
parent
)
:
QwtPlot
(
parent
),
m_curve
(
nullptr
),
m_xUnits
(
""
)
{
MiniPlotQwt
::
MiniPlotQwt
(
QWidget
*
parent
)
:
QwtPlot
(
parent
),
m_curve
(
nullptr
),
m_xUnits
(
""
)
{
const
QFont
&
font
=
parent
->
font
();
setAxisFont
(
QwtPlot
::
xBottom
,
font
);
setAxisFont
(
QwtPlot
::
yLeft
,
font
);
...
...
@@ -44,16 +43,13 @@ MiniPlotQwt::MiniPlotQwt(QWidget *parent)
setAxisTitle
(
xBottom
,
dummyText
);
canvas
()
->
setCursor
(
Qt
::
ArrowCursor
);
setContextMenuPolicy
(
Qt
::
DefaultContextMenu
);
m_zoomer
=
new
QwtPlotZoomer
(
QwtPlot
::
xBottom
,
QwtPlot
::
yLeft
,
QwtPicker
::
DragSelection
|
QwtPicker
::
CornerToCorner
,
m_zoomer
=
new
QwtPlotZoomer
(
QwtPlot
::
xBottom
,
QwtPlot
::
yLeft
,
QwtPicker
::
DragSelection
|
QwtPicker
::
CornerToCorner
,
QwtPicker
::
AlwaysOff
,
canvas
());
m_zoomer
->
setRubberBandPen
(
QPen
(
Qt
::
black
));
QList
<
QColor
>
colors
;
m_colors
<<
Qt
::
red
<<
Qt
::
green
<<
Qt
::
blue
<<
Qt
::
cyan
<<
Qt
::
magenta
<<
Qt
::
yellow
<<
Qt
::
gray
;
m_colors
<<
Qt
::
darkRed
<<
Qt
::
darkGreen
<<
Qt
::
darkBlue
<<
Qt
::
darkCyan
<<
Qt
::
darkMagenta
<<
Qt
::
darkYellow
<<
Qt
::
darkGray
;
m_colors
<<
Qt
::
red
<<
Qt
::
green
<<
Qt
::
blue
<<
Qt
::
cyan
<<
Qt
::
magenta
<<
Qt
::
yellow
<<
Qt
::
gray
;
m_colors
<<
Qt
::
darkRed
<<
Qt
::
darkGreen
<<
Qt
::
darkBlue
<<
Qt
::
darkCyan
<<
Qt
::
darkMagenta
<<
Qt
::
darkYellow
<<
Qt
::
darkGray
;
m_colorIndex
=
0
;
m_x0
=
0
;
m_y0
=
0
;
...
...
@@ -96,8 +92,7 @@ void MiniPlotQwt::setXScale(double from, double to) {
if
(
nMajorTicks
>
6
)
nMajorTicks
=
6
;
// try creating a scale
const
QwtScaleDiv
div
=
axisScaleEngine
(
QwtPlot
::
xBottom
)
->
divideScale
(
from
,
to
,
nMajorTicks
,
nMajorTicks
);
const
QwtScaleDiv
div
=
axisScaleEngine
(
QwtPlot
::
xBottom
)
->
divideScale
(
from
,
to
,
nMajorTicks
,
nMajorTicks
);
// Major ticks are placed at round numbers so the first or last tick could be
// missing making
// scale look ugly. Trying to fix it if possible
...
...
@@ -135,8 +130,7 @@ void MiniPlotQwt::setXScale(double from, double to) {
if
(
fabs
(
shift
/
range
)
<
0.1
)
{
from
+=
shift
;
const
QwtScaleDiv
updatedDiv
=
axisScaleEngine
(
QwtPlot
::
xBottom
)
->
divideScale
(
from
,
to
,
nMajorTicks
,
nMajorTicks
);
axisScaleEngine
(
QwtPlot
::
xBottom
)
->
divideScale
(
from
,
to
,
nMajorTicks
,
nMajorTicks
);
setAxisScaleDiv
(
xBottom
,
updatedDiv
);
rescaled
=
true
;
}
...
...
@@ -160,8 +154,7 @@ void MiniPlotQwt::setXScale(double from, double to) {
if
(
fabs
(
shift
/
range
)
<
0.1
)
{
to
+=
shift
;
const
QwtScaleDiv
updatedDiv
=
axisScaleEngine
(
QwtPlot
::
xBottom
)
->
divideScale
(
from
,
to
,
nMajorTicks
,
nMajorTicks
);
axisScaleEngine
(
QwtPlot
::
xBottom
)
->
divideScale
(
from
,
to
,
nMajorTicks
,
nMajorTicks
);
setAxisScaleDiv
(
xBottom
,
updatedDiv
);
rescaled
=
true
;
}
...
...
@@ -222,8 +215,7 @@ void MiniPlotQwt::setYScale(double from, double to) {
* @param xUnits :: Units for the data
* @param curveLabel :: A label for hthe die
*/
void
MiniPlotQwt
::
setData
(
std
::
vector
<
double
>
x
,
std
::
vector
<
double
>
y
,
QString
xunit
,
QString
curveLabel
)
{
void
MiniPlotQwt
::
setData
(
std
::
vector
<
double
>
x
,
std
::
vector
<
double
>
y
,
QString
xunit
,
QString
curveLabel
)
{
if
(
x
.
empty
())
{
g_log
.
warning
(
"setData(): X array is empty!"
);
return
;
...
...
@@ -233,9 +225,8 @@ void MiniPlotQwt::setData(std::vector<double> x, std::vector<double> y,
return
;
}
if
(
x
.
size
()
!=
y
.
size
())
{
g_log
.
warning
(
std
::
string
(
"setData(): X/Y size mismatch! X="
+
std
::
to_string
(
x
.
size
())
+
", Y="
+
std
::
to_string
(
y
.
size
())));
g_log
.
warning
(
std
::
string
(
"setData(): X/Y size mismatch! X="
+
std
::
to_string
(
x
.
size
())
+
", Y="
+
std
::
to_string
(
y
.
size
())));
return
;
}
...
...
@@ -352,15 +343,12 @@ void MiniPlotQwt::mousePressEvent(QMouseEvent *e) {
void
MiniPlotQwt
::
mouseReleaseEvent
(
QMouseEvent
*
e
)
{
if
(
e
->
button
()
==
Qt
::
LeftButton
)
{
if
(
m_x0
==
e
->
x
()
&&
m_y0
==
e
->
y
())
{
// there were no dragging
emit
clickedAt
(
invTransform
(
xBottom
,
e
->
x
()
-
canvas
()
->
x
()),
invTransform
(
yLeft
,
e
->
y
()
-
canvas
()
->
y
()));
emit
clickedAt
(
invTransform
(
xBottom
,
e
->
x
()
-
canvas
()
->
x
()),
invTransform
(
yLeft
,
e
->
y
()
-
canvas
()
->
y
()));
}
}
}
void
MiniPlotQwt
::
setYAxisLabelRotation
(
double
degrees
)
{
axisScaleDraw
(
yLeft
)
->
setLabelRotation
(
degrees
);
}
void
MiniPlotQwt
::
setYAxisLabelRotation
(
double
degrees
)
{
axisScaleDraw
(
yLeft
)
->
setLabelRotation
(
degrees
);
}
/**
* Set the log scale on the y axis
...
...
@@ -492,8 +480,8 @@ void MiniPlotQwt::clearAll() {
/**
* Draw PeakLabel on a plot
*/
void
PeakLabel
::
draw
(
QPainter
*
painter
,
const
QwtScaleMap
&
xMap
,
const
QwtScaleMap
&
yMap
,
const
QRect
&
canvasRect
)
const
{
void
PeakLabel
::
draw
(
QPainter
*
painter
,
const
QwtScaleMap
&
xMap
,
const
QwtScaleMap
&
yMap
,
const
QRect
&
canvasRect
)
const
{
(
void
)
yMap
;
double
peakX
;
if
(
m_plot
->
getXUnits
().
isEmpty
())
...
...
@@ -506,8 +494,7 @@ void PeakLabel::draw(QPainter *painter, const QwtScaleMap &xMap,
peakX