plot.h 1.18 KB
Newer Older
Tobias WEBER's avatar
Tobias WEBER committed
1
2
3
4
5
6
7
8
9
10
/**
 * plotter
 * @author Tobias Weber <tweber@ill.fr>
 * @date 15-Jun-2018
 * @license see 'LICENSE' file
 */

#ifndef __PLOT_H__
#define __PLOT_H__

11
#include <QtCore/QSettings>
Tobias WEBER's avatar
Tobias WEBER committed
12
#include <QtWidgets/QWidget>
13
14
#include <QtWidgets/QMenu>

Tobias WEBER's avatar
Tobias WEBER committed
15
16
17
18
19
#include "qcp/qcustomplot.h"

#include "data.h"


20

Tobias WEBER's avatar
Tobias WEBER committed
21
22
23
class Plotter : public QWidget
{
private:
24
25
	QSettings *m_pSettings = nullptr;

Tobias WEBER's avatar
Tobias WEBER committed
26
	QCustomPlot *m_pPlotter = new QCustomPlot(this);
27
28
29
30
	QMenu *m_pPlotContextMenu = new QMenu(m_pPlotter);

	// current dataset
	const Dataset* m_pdataset = nullptr;
Tobias WEBER's avatar
Tobias WEBER committed
31
32

public:
33
	Plotter(QWidget *parent, QSettings* = nullptr);
Tobias WEBER's avatar
Tobias WEBER committed
34
35
36
37
38
39
	virtual ~Plotter();

	QCustomPlot* GetPlotter() { return m_pPlotter; }
	const QCustomPlot* GetPlotter() const { return m_pPlotter; }

	void Plot(const Dataset &dataset);
Tobias WEBER's avatar
Tobias WEBER committed
40
	void Clear();
41
42
43
44
45

	void ShowPlotContextMenu(const QPoint& pt);

	void SavePDF();
	void SaveGpl();
Tobias WEBER's avatar
Tobias WEBER committed
46
47
48
};


Tobias WEBER's avatar
Tobias WEBER committed
49
50
51
52
53
54
55
56
57
58

/**
 * the dock which contains the plotter
 */
class PlotterDock : public QDockWidget
{
private:
	std::unique_ptr<Plotter> m_pPlot;

public:
59
	PlotterDock(QWidget* pParent = nullptr, QSettings* = nullptr);
Tobias WEBER's avatar
Tobias WEBER committed
60
61
62
63
64
65
	virtual ~PlotterDock();

	const Plotter* GetWidget() const { return m_pPlot.get(); }
	Plotter* GetWidget() { return m_pPlot.get(); }
};

66

Tobias WEBER's avatar
Tobias WEBER committed
67
#endif