Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "MantidQtMantidWidgets/MWSpectrogram.h"
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidKernel/System.h"
#include "MantidKernel/ReadLock.h"
namespace MantidQt
{
namespace MantidWidgets
{
//----------------------------------------------------------------------------------------------
/** Constructor
*/
MWSpectrogram::MWSpectrogram(QWidget * parent)
: QwtPlot(parent)
{
}
//----------------------------------------------------------------------------------------------
/** Constructor
*/
MWSpectrogram::MWSpectrogram(const QwtText &title, QWidget * parent)
: QwtPlot(title, parent)
{
}
//----------------------------------------------------------------------------------------------
/** Destructor
*/
MWSpectrogram::~MWSpectrogram()
{
}
//----------------------------------------------------------------------------------------------
/** Set the workspace that we read-lock when drawing.
*
* @param ws :: shared ptr to workspace
*/
void MWSpectrogram::setWorkspace(Mantid::API::MatrixWorkspace_sptr ws)
{
m_ws = ws;
}
//----------------------------------------------------------------------------------------------
/** Overridden drawCanvas() that protects the
* workspace from being overwritten while being drawn
*
* @param painter :: QPainter
*/
void MWSpectrogram::drawCanvas(QPainter * painter)
{
// Do nothing if the workspace is not valid.
if (!m_ws) return;
// Get the scoped read lock.
Mantid::Kernel::ReadLock lock(*m_ws);
// Draw using the usual procedure.
QwtPlot::drawCanvas(painter);
// lock is released when it goes out of scope.
}
} // namespace MantidQt
} // namespace MantidWidgets