Commit 92980904 authored by Tobias WEBER's avatar Tobias WEBER
Browse files

continued with moldyn tool

parent 44b7c110
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "moldyn.h" #include "moldyn.h"
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QFileDialog> #include <QtWidgets/QFileDialog>
#include <QtWidgets/QMessageBox> #include <QtWidgets/QMessageBox>
...@@ -34,6 +35,13 @@ MolDynDlg::MolDynDlg(QWidget* pParent) : QMainWindow{pParent}, ...@@ -34,6 +35,13 @@ MolDynDlg::MolDynDlg(QWidget* pParent) : QMainWindow{pParent},
this->setStatusBar(m_status); this->setStatusBar(m_status);
QWidget *pMainPanel = new QWidget();
auto pMainGrid = new QGridLayout(pMainPanel);
pMainGrid->setSpacing(2);
pMainGrid->setContentsMargins(4,4,4,4);
this->setCentralWidget(pMainPanel);
// menu bar // menu bar
{ {
m_menu = new QMenuBar(this); m_menu = new QMenuBar(this);
...@@ -80,7 +88,21 @@ MolDynDlg::MolDynDlg(QWidget* pParent) : QMainWindow{pParent}, ...@@ -80,7 +88,21 @@ MolDynDlg::MolDynDlg(QWidget* pParent) : QMainWindow{pParent},
connect(m_plot, &GlPlot::MouseDown, this, &MolDynDlg::PlotMouseDown); connect(m_plot, &GlPlot::MouseDown, this, &MolDynDlg::PlotMouseDown);
connect(m_plot, &GlPlot::MouseUp, this, &MolDynDlg::PlotMouseUp); connect(m_plot, &GlPlot::MouseUp, this, &MolDynDlg::PlotMouseUp);
this->setCentralWidget(m_plot); //this->setCentralWidget(m_plot);
pMainGrid->addWidget(m_plot, 0,0,1,1);
}
// controls
{
m_slider = new QSlider(Qt::Horizontal, this);
m_slider->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Minimum});
m_slider->setMinimum(0);
m_slider->setTracking(1);
connect(m_slider, &QSlider::valueChanged, this, &MolDynDlg::SliderValueChanged);
pMainGrid->addWidget(m_slider, 1,0,1,1);
} }
...@@ -136,9 +158,13 @@ void MolDynDlg::Load() ...@@ -136,9 +158,13 @@ void MolDynDlg::Load()
if(!m_mol.LoadFile(filename.toStdString(), 100)) if(!m_mol.LoadFile(filename.toStdString(), 100))
{ {
QMessageBox::critical(this, "Molecular Dynamics", "Error loading file."); QMessageBox::critical(this, "Molecular Dynamics", "Error loading file.");
return;
} }
m_slider->setMaximum(m_mol.GetFrameCount());
// atom colors
std::vector<t_vec> cols = std::vector<t_vec> cols =
{ {
m::create<t_vec>({1, 0, 0}), m::create<t_vec>({1, 0, 0}),
...@@ -149,6 +175,7 @@ void MolDynDlg::Load() ...@@ -149,6 +175,7 @@ void MolDynDlg::Load()
m::create<t_vec>({0, 0, 0}), m::create<t_vec>({0, 0, 0}),
}; };
// add atoms to 3d view
if(m_mol.GetFrameCount()) if(m_mol.GetFrameCount())
{ {
const auto& frame = m_mol.GetFrame(0); const auto& frame = m_mol.GetFrame(0);
...@@ -235,6 +262,12 @@ void MolDynDlg::PlotMouseUp(bool left, bool mid, bool right) ...@@ -235,6 +262,12 @@ void MolDynDlg::PlotMouseUp(bool left, bool mid, bool right)
void MolDynDlg::SliderValueChanged(int val)
{
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void MolDynDlg::AfterGLInitialisation() void MolDynDlg::AfterGLInitialisation()
{ {
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <QtWidgets/QMenu> #include <QtWidgets/QMenu>
#include <QtWidgets/QMenuBar> #include <QtWidgets/QMenuBar>
#include <QtWidgets/QStatusBar> #include <QtWidgets/QStatusBar>
#include <QtWidgets/QSlider>
#include <QtCore/QSettings> #include <QtCore/QSettings>
#include <vector> #include <vector>
...@@ -39,6 +40,7 @@ protected: ...@@ -39,6 +40,7 @@ protected:
QSettings *m_sett = nullptr; QSettings *m_sett = nullptr;
QMenuBar *m_menu = nullptr; QMenuBar *m_menu = nullptr;
QStatusBar *m_status = nullptr; QStatusBar *m_status = nullptr;
QSlider *m_slider = nullptr;
GlPlot *m_plot = nullptr; GlPlot *m_plot = nullptr;
std::size_t m_sphere = 0; std::size_t m_sphere = 0;
...@@ -57,6 +59,8 @@ protected: ...@@ -57,6 +59,8 @@ protected:
void PickerIntersection(const t_vec3_gl* pos, std::size_t objIdx, const t_vec3_gl* posSphere); void PickerIntersection(const t_vec3_gl* pos, std::size_t objIdx, const t_vec3_gl* posSphere);
void AfterGLInitialisation(); void AfterGLInitialisation();
void SliderValueChanged(int val);
virtual void closeEvent(QCloseEvent *evt) override; virtual void closeEvent(QCloseEvent *evt) override;
private: private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment