moldyn.h 2.04 KB
Newer Older
Tobias WEBER's avatar
Tobias WEBER committed
1
/**
Tobias WEBER's avatar
Tobias WEBER committed
2
 * atom dynamics
Tobias WEBER's avatar
Tobias WEBER committed
3 4 5 6 7
 * @author Tobias Weber <tweber@ill.fr>
 * @date Dec-2019
 * @license GPLv3, see 'LICENSE' file
 */

Tobias WEBER's avatar
Tobias WEBER committed
8 9
#ifndef __MOLDYN_GUI_H__
#define __MOLDYN_GUI_H__
Tobias WEBER's avatar
Tobias WEBER committed
10

Tobias WEBER's avatar
Tobias WEBER committed
11
#include <QtWidgets/QMainWindow>
Tobias WEBER's avatar
Tobias WEBER committed
12
#include <QtWidgets/QMenu>
Tobias WEBER's avatar
Tobias WEBER committed
13 14
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QStatusBar>
Tobias WEBER's avatar
Tobias WEBER committed
15
#include <QtWidgets/QSlider>
Tobias WEBER's avatar
Tobias WEBER committed
16
#include <QtWidgets/QDoubleSpinBox>
Tobias WEBER's avatar
Tobias WEBER committed
17
#include <QtCore/QSettings>
Tobias WEBER's avatar
Tobias WEBER committed
18 19 20

#include <vector>

Tobias WEBER's avatar
Tobias WEBER committed
21 22
#include "libs/_cxx20/glplot.h"
#include "libs/_cxx20/math_algos.h"
Tobias WEBER's avatar
Tobias WEBER committed
23

Tobias WEBER's avatar
Tobias WEBER committed
24 25
#include "moldyn-loader.h"

Tobias WEBER's avatar
Tobias WEBER committed
26

Tobias WEBER's avatar
Tobias WEBER committed
27 28 29
using t_real = double;
using t_vec = std::vector<t_real>;
using t_mat = m::mat<t_real, std::vector>;
Tobias WEBER's avatar
Tobias WEBER committed
30 31


Tobias WEBER's avatar
Tobias WEBER committed
32
class MolDynDlg : public QMainWindow
Tobias WEBER's avatar
Tobias WEBER committed
33
{
Tobias WEBER's avatar
Tobias WEBER committed
34 35 36
public:
	MolDynDlg(QWidget* pParent = nullptr);
	~MolDynDlg() = default;
Tobias WEBER's avatar
Tobias WEBER committed
37

Tobias WEBER's avatar
Tobias WEBER committed
38
protected:
39
	std::size_t Add3DItem(const t_vec& vec, const t_vec& col, t_real scale, const std::string& label);
Tobias WEBER's avatar
Tobias WEBER committed
40 41
	void Change3DItem(std::size_t obj, const t_vec* vec, const t_vec* col=nullptr, const t_real *scale=nullptr, const std::string *label=nullptr);

Tobias WEBER's avatar
Tobias WEBER committed
42
	void SetStatusMsg(const std::string& msg);
Tobias WEBER's avatar
Tobias WEBER committed
43

Tobias WEBER's avatar
Tobias WEBER committed
44 45
	void New();
	void Load();
Tobias WEBER's avatar
Tobias WEBER committed
46
	void SaveAs();
Tobias WEBER's avatar
Tobias WEBER committed
47

Tobias WEBER's avatar
Tobias WEBER committed
48 49
	void PlotMouseDown(bool left, bool mid, bool right);
	void PlotMouseUp(bool left, bool mid, bool right);
Tobias WEBER's avatar
Tobias WEBER committed
50
	void PlotMouseClick(bool left, bool mid, bool right);
Tobias WEBER's avatar
Tobias WEBER committed
51 52
	void PickerIntersection(const t_vec3_gl* pos, std::size_t objIdx, const t_vec3_gl* posSphere);
	void AfterGLInitialisation();
Tobias WEBER's avatar
Tobias WEBER committed
53

Tobias WEBER's avatar
Tobias WEBER committed
54 55
	void SliderValueChanged(int val);

Tobias WEBER's avatar
Tobias WEBER committed
56 57 58 59
	void DeleteAtomUnderCursor();
	void DeleteAllAtomsOfSameType();
	void KeepAtomsOfSameType();

Tobias WEBER's avatar
Tobias WEBER committed
60
	virtual void closeEvent(QCloseEvent *evt) override;
Tobias WEBER's avatar
Tobias WEBER committed
61
	virtual void keyPressEvent(QKeyEvent *evt) override;
Tobias WEBER's avatar
Tobias WEBER committed
62

63 64 65

protected:
	MolDyn<t_real, t_vec> m_mol;
Tobias WEBER's avatar
Tobias WEBER committed
66 67
	t_mat m_crystA = m::unit<t_mat>(3);
	t_mat m_crystB = m::unit<t_mat>(3);
68 69 70 71 72

	QSettings *m_sett = nullptr;
	QMenuBar *m_menu = nullptr;
	QStatusBar *m_status = nullptr;
	QSlider *m_slider = nullptr;
Tobias WEBER's avatar
Tobias WEBER committed
73
	QDoubleSpinBox *m_spinScale = nullptr;
Tobias WEBER's avatar
Tobias WEBER committed
74
	QMenu *m_atomContextMenu = nullptr;
75 76 77 78 79 80

	GlPlot *m_plot = nullptr;
	std::size_t m_sphere = 0;
	std::vector<std::size_t> m_sphereHandles;


Tobias WEBER's avatar
Tobias WEBER committed
81 82 83
private:
	long m_curPickedObj = -1;
	bool m_ignoreChanges = 1;
Tobias WEBER's avatar
Tobias WEBER committed
84 85 86 87
};


#endif