Skip to content
Snippets Groups Projects
moldyn.h 2.04 KiB
Newer Older
  • Learn to ignore specific revisions
  • Tobias WEBER's avatar
    Tobias WEBER committed
     * atom dynamics
    
     * @author Tobias Weber <tweber@ill.fr>
     * @date Dec-2019
     * @license GPLv3, see 'LICENSE' file
     */
    
    
    Tobias WEBER's avatar
    Tobias WEBER committed
    #ifndef __MOLDYN_GUI_H__
    #define __MOLDYN_GUI_H__
    
    Tobias WEBER's avatar
    Tobias WEBER committed
    #include <QtWidgets/QMainWindow>
    
    Tobias WEBER's avatar
    Tobias WEBER committed
    #include <QtWidgets/QMenu>
    
    Tobias WEBER's avatar
    Tobias WEBER committed
    #include <QtWidgets/QMenuBar>
    #include <QtWidgets/QStatusBar>
    
    #include <QtWidgets/QSlider>
    
    #include <QtWidgets/QDoubleSpinBox>
    
    Tobias WEBER's avatar
    Tobias WEBER committed
    #include <QtCore/QSettings>
    
    
    #include <vector>
    
    
    Tobias WEBER's avatar
    Tobias WEBER committed
    #include "libs/_cxx20/glplot.h"
    #include "libs/_cxx20/math_algos.h"
    
    Tobias WEBER's avatar
    Tobias WEBER committed
    #include "moldyn-loader.h"
    
    
    Tobias WEBER's avatar
    Tobias WEBER committed
    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
    class MolDynDlg : public QMainWindow
    
    Tobias WEBER's avatar
    Tobias WEBER committed
    public:
    	MolDynDlg(QWidget* pParent = nullptr);
    	~MolDynDlg() = default;
    
    Tobias WEBER's avatar
    Tobias WEBER committed
    protected:
    
    	std::size_t Add3DItem(const t_vec& vec, const t_vec& col, t_real scale, const std::string& label);
    
    	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
    	void SetStatusMsg(const std::string& msg);
    
    Tobias WEBER's avatar
    Tobias WEBER committed
    	void New();
    	void Load();
    
    Tobias WEBER's avatar
    Tobias WEBER committed
    	void SaveAs();
    
    Tobias WEBER's avatar
    Tobias WEBER committed
    	void PlotMouseDown(bool left, bool mid, bool right);
    	void PlotMouseUp(bool left, bool mid, bool right);
    
    Tobias WEBER's avatar
    Tobias WEBER committed
    	void PlotMouseClick(bool left, bool mid, bool right);
    
    Tobias WEBER's avatar
    Tobias WEBER committed
    	void PickerIntersection(const t_vec3_gl* pos, std::size_t objIdx, const t_vec3_gl* posSphere);
    	void AfterGLInitialisation();
    
    	void SliderValueChanged(int val);
    
    
    Tobias WEBER's avatar
    Tobias WEBER committed
    	void DeleteAtomUnderCursor();
    	void DeleteAllAtomsOfSameType();
    	void KeepAtomsOfSameType();
    
    
    Tobias WEBER's avatar
    Tobias WEBER committed
    	virtual void closeEvent(QCloseEvent *evt) override;
    
    	virtual void keyPressEvent(QKeyEvent *evt) override;
    
    
    protected:
    	MolDyn<t_real, t_vec> m_mol;
    
    	t_mat m_crystA = m::unit<t_mat>(3);
    	t_mat m_crystB = m::unit<t_mat>(3);
    
    
    	QSettings *m_sett = nullptr;
    	QMenuBar *m_menu = nullptr;
    	QStatusBar *m_status = nullptr;
    	QSlider *m_slider = nullptr;
    
    	QDoubleSpinBox *m_spinScale = nullptr;
    
    Tobias WEBER's avatar
    Tobias WEBER committed
    	QMenu *m_atomContextMenu = nullptr;
    
    
    	GlPlot *m_plot = nullptr;
    	std::size_t m_sphere = 0;
    	std::vector<std::size_t> m_sphereHandles;
    
    
    
    Tobias WEBER's avatar
    Tobias WEBER committed
    private:
    	long m_curPickedObj = -1;
    	bool m_ignoreChanges = 1;