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

added status messages

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