plot.h 2.09 KB
Newer Older
Tobias WEBER's avatar
Tobias WEBER committed
1
2
3
4
5
/**
 * plotter
 * @author Tobias Weber <tweber@ill.fr>
 * @date 15-Jun-2018
 * @license see 'LICENSE' file
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 *
 * ----------------------------------------------------------------------------
 * mag-core (part of the Takin software suite)
 * Copyright (C) 2018-2021  Tobias WEBER (Institut Laue-Langevin (ILL),
 *                          Grenoble, France).
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * ----------------------------------------------------------------------------
Tobias WEBER's avatar
Tobias WEBER committed
24
25
26
27
28
 */

#ifndef __PLOT_H__
#define __PLOT_H__

29
#include <QtCore/QSettings>
Tobias WEBER's avatar
Tobias WEBER committed
30
#include <QtWidgets/QWidget>
31
#include <QtWidgets/QMenu>
32
#include <memory>
33

34
#include "qcustomplot.h"
Tobias WEBER's avatar
Tobias WEBER committed
35
36
37
38

#include "data.h"


39

Tobias WEBER's avatar
Tobias WEBER committed
40
41
42
class Plotter : public QWidget
{
private:
43
44
	QSettings *m_pSettings = nullptr;

Tobias WEBER's avatar
Tobias WEBER committed
45
46
	std::shared_ptr<QCustomPlot> m_pPlotter;
	QMenu *m_pPlotContextMenu = nullptr;
47

Tobias WEBER's avatar
Tobias WEBER committed
48
49
	// copy of current dataset
	Dataset m_dataset;
Tobias WEBER's avatar
Tobias WEBER committed
50
51

public:
52
	Plotter(QWidget *parent, QSettings* = nullptr);
Tobias WEBER's avatar
Tobias WEBER committed
53
54
	virtual ~Plotter();

Tobias WEBER's avatar
Tobias WEBER committed
55
56
	std::shared_ptr<QCustomPlot> GetPlotter() { return m_pPlotter; }
	std::shared_ptr<QCustomPlot> GetPlotter() const { return m_pPlotter; }
Tobias WEBER's avatar
Tobias WEBER committed
57
58

	void Plot(const Dataset &dataset);
Tobias WEBER's avatar
Tobias WEBER committed
59
	void Clear();
60
61
62
63
64

	void ShowPlotContextMenu(const QPoint& pt);

	void SavePDF();
	void SaveGpl();
Tobias WEBER's avatar
Tobias WEBER committed
65
66
67
};


Tobias WEBER's avatar
Tobias WEBER committed
68
69
70
71
72
73
74
75
76
77

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

public:
78
	PlotterDock(QWidget* pParent = nullptr, QSettings* = nullptr);
Tobias WEBER's avatar
Tobias WEBER committed
79
80
81
82
83
84
	virtual ~PlotterDock();

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

85

Tobias WEBER's avatar
Tobias WEBER committed
86
#endif