Commit 34f56f26 authored by Tobias WEBER's avatar Tobias WEBER
Browse files

added status messages

parent d67d45f7
...@@ -38,11 +38,12 @@ class MolFrame ...@@ -38,11 +38,12 @@ class MolFrame
{ m_config.push_back(config); } { m_config.push_back(config); }
std::size_t GetNumAtoms() const std::size_t GetNumAtomTypes() const
{ return m_config.size(); } { return m_config.size(); }
const std::vector<t_vec>& GetCoords(std::size_t atomidx) const
{ return m_config[atomidx]; } const std::vector<t_vec>& GetCoords(std::size_t idxType) const
{ return m_config[idxType]; }
/** /**
...@@ -122,14 +123,24 @@ class MolDyn ...@@ -122,14 +123,24 @@ class MolDyn
{ return m_frames[frame]; } { return m_frames[frame]; }
std::size_t GetAtomCount() const std::size_t GetNumAtomTypes() const
{ return m_vecAtoms.size(); } { return m_vecAtoms.size(); }
const std::string& GetAtomName(std::size_t idx) const std::size_t GetNumAtomsTotal() const
{ return m_vecAtoms[idx]; } {
std::size_t num = 0;
for(std::size_t numpertype : m_vecAtomNums)
num += numpertype;
return num;
}
const std::string& GetAtomName(std::size_t idxType) const
{ return m_vecAtoms[idxType]; }
unsigned int GetAtomNum(std::size_t idx) const unsigned int GetAtomNum(std::size_t idxType) const
{ return m_vecAtomNums[idx]; } { return m_vecAtomNums[idxType]; }
void AddAtomType(const std::string& name, unsigned int number) void AddAtomType(const std::string& name, unsigned int number)
...@@ -415,7 +426,7 @@ class MolDyn ...@@ -415,7 +426,7 @@ class MolDyn
const MolFrame<t_real, t_vec>& config = m_frames[frame]; const MolFrame<t_real, t_vec>& config = m_frames[frame];
// iterate atom types // iterate atom types
for(std::size_t atomidx=0; atomidx<config.GetNumAtoms(); ++atomidx) for(std::size_t atomidx=0; atomidx<config.GetNumAtomTypes(); ++atomidx)
{ {
const auto& coords = config.GetCoords(atomidx); const auto& coords = config.GetCoords(atomidx);
// iterate coordinates // iterate coordinates
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
#include <QtWidgets/QGridLayout> #include <QtWidgets/QGridLayout>
#include <QtWidgets/QFileDialog> #include <QtWidgets/QFileDialog>
#include <QtWidgets/QLabel>
#include <QtWidgets/QSpinBox> #include <QtWidgets/QSpinBox>
#include <QtWidgets/QComboBox> #include <QtWidgets/QComboBox>
#include <QtWidgets/QMessageBox> #include <QtWidgets/QMessageBox>
...@@ -90,6 +89,8 @@ MolDynDlg::MolDynDlg(QWidget* pParent) : QMainWindow{pParent}, ...@@ -90,6 +89,8 @@ MolDynDlg::MolDynDlg(QWidget* pParent) : QMainWindow{pParent},
this->setObjectName("moldyn"); this->setObjectName("moldyn");
m_status = new QStatusBar(this); m_status = new QStatusBar(this);
m_statusAtoms = new QLabel(m_status);
m_status->addPermanentWidget(m_statusAtoms);
this->setStatusBar(m_status); this->setStatusBar(m_status);
...@@ -706,9 +707,9 @@ void MolDynDlg::Load() ...@@ -706,9 +707,9 @@ void MolDynDlg::Load()
if(m_mol.GetFrameCount()) if(m_mol.GetFrameCount())
{ {
const auto& frame = m_mol.GetFrame(0); const auto& frame = m_mol.GetFrame(0);
m_sphereHandles.reserve(frame.GetNumAtoms()); m_sphereHandles.reserve(frame.GetNumAtomTypes());
for(std::size_t atomidx=0; atomidx<frame.GetNumAtoms(); ++atomidx) for(std::size_t atomidx=0; atomidx<frame.GetNumAtomTypes(); ++atomidx)
{ {
const auto& coords = frame.GetCoords(atomidx); const auto& coords = frame.GetCoords(atomidx);
for(const t_vec& vec : coords) for(const t_vec& vec : coords)
...@@ -725,6 +726,8 @@ void MolDynDlg::Load() ...@@ -725,6 +726,8 @@ void MolDynDlg::Load()
QMessageBox::critical(this, PROG_NAME, ex.what()); QMessageBox::critical(this, PROG_NAME, ex.what());
} }
UpdateAtomsStatusMsg();
m_plot->update(); m_plot->update();
} }
...@@ -803,12 +806,22 @@ void MolDynDlg::PickerIntersection(const t_vec3_gl* pos, std::size_t objIdx, con ...@@ -803,12 +806,22 @@ void MolDynDlg::PickerIntersection(const t_vec3_gl* pos, std::size_t objIdx, con
void MolDynDlg::SetStatusMsg(const std::string& msg) void MolDynDlg::SetStatusMsg(const std::string& msg)
{ {
if(!m_status) return; if(!m_status) return;
m_status->showMessage(msg.c_str()); m_status->showMessage(msg.c_str());
} }
void MolDynDlg::UpdateAtomsStatusMsg()
{
if(!m_statusAtoms) return;
std::string numAtoms = std::to_string(m_mol.GetNumAtomsTotal()) + " atoms in "
+ std::to_string(m_mol.GetFrameCount()) + " frames.";
m_statusAtoms->setText(numAtoms.c_str());
}
/** /**
* mouse button pressed * mouse button pressed
*/ */
...@@ -897,7 +910,7 @@ void MolDynDlg::SliderValueChanged(int val) ...@@ -897,7 +910,7 @@ void MolDynDlg::SliderValueChanged(int val)
t_real atomscale = m_spinScale->value(); t_real atomscale = m_spinScale->value();
std::size_t counter = 0; std::size_t counter = 0;
for(std::size_t atomidx=0; atomidx<frame.GetNumAtoms(); ++atomidx) for(std::size_t atomidx=0; atomidx<frame.GetNumAtomTypes(); ++atomidx)
{ {
const auto& coords = frame.GetCoords(atomidx); const auto& coords = frame.GetCoords(atomidx);
for(const t_vec& vec : coords) for(const t_vec& vec : coords)
...@@ -932,7 +945,7 @@ MolDynDlg::GetAtomIndexFromHandle(std::size_t handle) const ...@@ -932,7 +945,7 @@ MolDynDlg::GetAtomIndexFromHandle(std::size_t handle) const
std::size_t atomCountsSoFar = 0; std::size_t atomCountsSoFar = 0;
std::size_t atomTypeIdx = 0; std::size_t atomTypeIdx = 0;
for(atomTypeIdx=0; atomTypeIdx<m_mol.GetAtomCount(); ++atomTypeIdx) for(atomTypeIdx=0; atomTypeIdx<m_mol.GetNumAtomTypes(); ++atomTypeIdx)
{ {
std::size_t numAtoms = m_mol.GetAtomNum(atomTypeIdx); std::size_t numAtoms = m_mol.GetAtomNum(atomTypeIdx);
if(atomCountsSoFar + numAtoms > sphereIdx) if(atomCountsSoFar + numAtoms > sphereIdx)
...@@ -1000,6 +1013,7 @@ void MolDynDlg::DeleteAtomUnderCursor() ...@@ -1000,6 +1013,7 @@ void MolDynDlg::DeleteAtomUnderCursor()
m_mol.RemoveAtom(atomTypeIdx, atomSubTypeIdx); m_mol.RemoveAtom(atomTypeIdx, atomSubTypeIdx);
SetStatusMsg("1 atom removed."); SetStatusMsg("1 atom removed.");
UpdateAtomsStatusMsg();
m_plot->update(); m_plot->update();
} }
...@@ -1018,7 +1032,7 @@ void MolDynDlg::DeleteAllAtomsOfSameType() ...@@ -1018,7 +1032,7 @@ void MolDynDlg::DeleteAllAtomsOfSameType()
std::size_t startIdx = 0; std::size_t startIdx = 0;
std::size_t totalRemoved = 0; std::size_t totalRemoved = 0;
for(std::size_t atomIdx=0; atomIdx<m_mol.GetAtomCount();) for(std::size_t atomIdx=0; atomIdx<m_mol.GetNumAtomTypes();)
{ {
std::size_t numAtoms = m_mol.GetAtomNum(atomIdx); std::size_t numAtoms = m_mol.GetAtomNum(atomIdx);
...@@ -1042,6 +1056,7 @@ void MolDynDlg::DeleteAllAtomsOfSameType() ...@@ -1042,6 +1056,7 @@ void MolDynDlg::DeleteAllAtomsOfSameType()
} }
SetStatusMsg(std::to_string(totalRemoved) + " atoms removed."); SetStatusMsg(std::to_string(totalRemoved) + " atoms removed.");
UpdateAtomsStatusMsg();
m_plot->update(); m_plot->update();
} }
...@@ -1060,7 +1075,7 @@ void MolDynDlg::KeepAtomsOfSameType() ...@@ -1060,7 +1075,7 @@ void MolDynDlg::KeepAtomsOfSameType()
std::size_t startIdx = 0; std::size_t startIdx = 0;
std::size_t totalRemoved = 0; std::size_t totalRemoved = 0;
for(std::size_t atomIdx=0; atomIdx<m_mol.GetAtomCount();) for(std::size_t atomIdx=0; atomIdx<m_mol.GetNumAtomTypes();)
{ {
std::size_t numAtoms = m_mol.GetAtomNum(atomIdx); std::size_t numAtoms = m_mol.GetAtomNum(atomIdx);
...@@ -1084,6 +1099,7 @@ void MolDynDlg::KeepAtomsOfSameType() ...@@ -1084,6 +1099,7 @@ void MolDynDlg::KeepAtomsOfSameType()
} }
SetStatusMsg(std::to_string(totalRemoved) + " atoms removed."); SetStatusMsg(std::to_string(totalRemoved) + " atoms removed.");
UpdateAtomsStatusMsg();
m_plot->update(); m_plot->update();
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <QtWidgets/QMenuBar> #include <QtWidgets/QMenuBar>
#include <QtWidgets/QStatusBar> #include <QtWidgets/QStatusBar>
#include <QtWidgets/QSlider> #include <QtWidgets/QSlider>
#include <QtWidgets/QLabel>
#include <QtWidgets/QDoubleSpinBox> #include <QtWidgets/QDoubleSpinBox>
#include <QtCore/QSettings> #include <QtCore/QSettings>
...@@ -41,6 +42,7 @@ protected: ...@@ -41,6 +42,7 @@ protected:
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); 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);
void SetStatusMsg(const std::string& msg); void SetStatusMsg(const std::string& msg);
void UpdateAtomsStatusMsg();
void New(); void New();
void Load(); void Load();
...@@ -80,6 +82,7 @@ protected: ...@@ -80,6 +82,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;
QLabel *m_statusAtoms = nullptr;
QSlider *m_slider = nullptr; QSlider *m_slider = nullptr;
QDoubleSpinBox *m_spinScale = nullptr; QDoubleSpinBox *m_spinScale = nullptr;
QMenu *m_atomContextMenu = nullptr; QMenu *m_atomContextMenu = nullptr;
......
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