Verified Commit 3d02d4c5 authored by Tobias WEBER's avatar Tobias WEBER
Browse files

bz tool: gui cleanup

parent 8a5d4111
...@@ -109,11 +109,11 @@ BZDlg::BZDlg(QWidget* pParent) : QDialog{pParent}, ...@@ -109,11 +109,11 @@ BZDlg::BZDlg(QWidget* pParent) : QDialog{pParent},
// get space groups and symops // get space groups and symops
auto spacegroups = get_sgs<t_mat>(); auto spacegroups = get_sgs<t_mat>();
m_SGops.reserve(spacegroups.size()); m_sg_ops.reserve(spacegroups.size());
for(auto [sgnum, descr, ops] : spacegroups) for(auto [sgnum, descr, ops] : spacegroups)
{ {
m_comboSG->addItem(descr.c_str(), m_comboSG->count()); m_comboSG->addItem(descr.c_str(), m_comboSG->count());
m_SGops.emplace_back(std::move(ops)); m_sg_ops.emplace_back(std::move(ops));
} }
...@@ -295,12 +295,9 @@ BZDlg::BZDlg(QWidget* pParent) : QDialog{pParent}, ...@@ -295,12 +295,9 @@ BZDlg::BZDlg(QWidget* pParent) : QDialog{pParent},
grid->setSpacing(4); grid->setSpacing(4);
grid->setContentsMargins(6, 6, 6, 6); grid->setContentsMargins(6, 6, 6, 6);
auto sep1 = new QFrame(infopanel); auto sep1 = new QFrame(infopanel); sep1->setFrameStyle(QFrame::HLine);
sep1->setFrameStyle(QFrame::HLine); auto sep2 = new QFrame(infopanel); sep2->setFrameStyle(QFrame::HLine);
auto sep2 = new QFrame(infopanel); auto sep3 = new QFrame(infopanel); sep3->setFrameStyle(QFrame::HLine);
sep2->setFrameStyle(QFrame::HLine);
auto sep3 = new QFrame(infopanel);
sep3->setFrameStyle(QFrame::HLine);
std::string strBoost = BOOST_LIB_VERSION; std::string strBoost = BOOST_LIB_VERSION;
algo::replace_all(strBoost, "_", "."); algo::replace_all(strBoost, "_", ".");
...@@ -352,14 +349,26 @@ BZDlg::BZDlg(QWidget* pParent) : QDialog{pParent}, ...@@ -352,14 +349,26 @@ BZDlg::BZDlg(QWidget* pParent) : QDialog{pParent},
grid->addWidget(sep2, y++,0, 1,1); grid->addWidget(sep2, y++,0, 1,1);
grid->addWidget(new QLabel( auto labelQt = new QLabel(QString(
QString("Qt Version: ") + "<a href=\"http://code.qt.io/cgit/\">Qt</a>"
QString(QT_VERSION_STR) + ".", " Version: %1.").arg(QT_VERSION_STR),
infopanel), y++,0, 1,1); infopanel);
grid->addWidget(new QLabel( labelQt->setOpenExternalLinks(true);
QString("Boost Version: ") + grid->addWidget(labelQt, y++,0, 1,1);
strBoost.c_str() + ".",
infopanel), y++,0, 1,1); auto labelBoost = new QLabel(QString(
"<a href=\"http://www.boost.org\">Boost</a>"
" Version: %1.").arg(strBoost.c_str()),
infopanel);
labelBoost->setOpenExternalLinks(true);
grid->addWidget(labelBoost, y++,0, 1,1);
auto labelGemmi = new QLabel(QString(
"<a href=\"https://github.com/project-gemmi/gemmi\">Gemmi</a>"
" Version: %1.").arg(get_gemmi_version<QString>()),
infopanel);
labelGemmi->setOpenExternalLinks(true);
grid->addWidget(labelGemmi, y++,0, 1,1);
grid->addWidget(sep3, y++,0, 1,1); grid->addWidget(sep3, y++,0, 1,1);
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include "tlibs2/libs/qt/numerictablewidgetitem.h" #include "tlibs2/libs/qt/numerictablewidgetitem.h"
// sg table column indices
enum : int enum : int
{ {
COL_OP = 0, COL_OP = 0,
...@@ -72,11 +73,10 @@ protected: ...@@ -72,11 +73,10 @@ protected:
QMenuBar *m_menu = nullptr; QMenuBar *m_menu = nullptr;
QLabel *m_status = nullptr; QLabel *m_status = nullptr;
// plotter // 3d plotter
QDialog *m_dlgPlot = nullptr; QDialog *m_dlgPlot = nullptr;
std::shared_ptr<tl2::GlPlot> m_plot; std::shared_ptr<tl2::GlPlot> m_plot;
std::size_t m_sphere = 0; std::size_t m_sphere = 0, m_plane = 0;
std::size_t m_plane = 0;
QLabel *m_labelGlInfos[4] = { nullptr, nullptr, nullptr, nullptr }; QLabel *m_labelGlInfos[4] = { nullptr, nullptr, nullptr, nullptr };
QLabel *m_status3D = nullptr; QLabel *m_status3D = nullptr;
QCheckBox *m_plot_coordcross = nullptr; QCheckBox *m_plot_coordcross = nullptr;
...@@ -104,24 +104,24 @@ protected: ...@@ -104,24 +104,24 @@ protected:
QDoubleSpinBox *m_cutNZ = nullptr; QDoubleSpinBox *m_cutNZ = nullptr;
QDoubleSpinBox *m_cutD = nullptr; QDoubleSpinBox *m_cutD = nullptr;
QSpinBox *m_BZDrawOrder = nullptr; QSpinBox *m_BZDrawOrder = nullptr;
QAction *m_acCutHull = nullptr;
QSpinBox *m_BZCalcOrder = nullptr; QSpinBox *m_BZCalcOrder = nullptr;
std::vector<std::vector<t_vec>> m_bz_polys; QAction *m_acCutHull = nullptr;
// results panel // results panel
QPlainTextEdit *m_bzresults = nullptr; QPlainTextEdit *m_bzresults = nullptr;
std::string m_descrBZ, m_descrBZCut; std::string m_descrBZ, m_descrBZCut; // text description of the results
QMenu *m_tabContextMenu = nullptr; // menu in case a symop is selected QMenu *m_tabContextMenu = nullptr; // menu in case a symop is selected
QMenu *m_tabContextMenuNoItem = nullptr; // menu if nothing is selected QMenu *m_tabContextMenuNoItem = nullptr; // menu if nothing is selected
t_mat m_crystA = tl2::unit<t_mat>(3); t_mat m_crystA = tl2::unit<t_mat>(3); // crystal A matrix
t_mat m_crystB = tl2::unit<t_mat>(3); t_mat m_crystB = tl2::unit<t_mat>(3); // crystal B matrix
t_mat m_cut_plane = tl2::unit<t_mat>(3); t_mat m_cut_plane = tl2::unit<t_mat>(3); // cutting plane
t_mat m_cut_plane_inv = tl2::unit<t_mat>(3); t_mat m_cut_plane_inv = tl2::unit<t_mat>(3); // and its inverse
t_real m_cut_norm_scale = 1.; // convert 1/A to rlu lengths along the normal t_real m_cut_norm_scale = 1.; // convert 1/A to rlu lengths along the normal
std::vector<std::vector<t_mat>> m_SGops; std::vector<std::vector<t_mat>> m_sg_ops; // symops per space group
std::vector<std::vector<t_vec>> m_bz_polys; // polygons of the 3d bz
protected: protected:
...@@ -130,12 +130,12 @@ protected: ...@@ -130,12 +130,12 @@ protected:
void DelTabItem(int begin=-2, int end=-2); void DelTabItem(int begin=-2, int end=-2);
void MoveTabItemUp(); void MoveTabItemUp();
void MoveTabItemDown(); void MoveTabItemDown();
void TableCurCellChanged(int rowNew, int colNew, int rowOld, int colOld); void TableCurCellChanged(int rowNew, int colNew, int rowOld, int colOld);
void TableCellEntered(const QModelIndex& idx); void TableCellEntered(const QModelIndex& idx);
void TableItemChanged(QTableWidgetItem *item); void TableItemChanged(QTableWidgetItem *item);
void ShowTableContextMenu(const QPoint& pt); void ShowTableContextMenu(const QPoint& pt);
// menu functions
void NewFile(); void NewFile();
void Load(); void Load();
void Save(); void Save();
...@@ -143,6 +143,7 @@ protected: ...@@ -143,6 +143,7 @@ protected:
void GetSymOpsFromSG(); void GetSymOpsFromSG();
void SaveCutSVG(); void SaveCutSVG();
// calculation functions
std::vector<t_mat> GetSymOps(bool only_centring = false) const; std::vector<t_mat> GetSymOps(bool only_centring = false) const;
void CalcB(bool full_recalc = true); void CalcB(bool full_recalc = true);
void CalcBZ(bool full_recalc = true); void CalcBZ(bool full_recalc = true);
...@@ -180,12 +181,12 @@ protected: ...@@ -180,12 +181,12 @@ protected:
private: private:
int m_iCursorRow = -1; int m_cursorRow = -1; // current sg row
bool m_ignoreChanges = 1; bool m_ignoreChanges = 1; // ignore sg changes
bool m_ignoreCalc = 0; bool m_ignoreCalc = 0; // ignore bz calculation
long m_curPickedObj = -1; long m_curPickedObj = -1; // current 3d bz object
std::vector<std::size_t> m_plotObjs; std::vector<std::size_t> m_plotObjs; // 3d bz plot objects
private: private:
......
...@@ -114,13 +114,13 @@ void BZDlg::AddTabItem(int row, const t_mat& op) ...@@ -114,13 +114,13 @@ void BZDlg::AddTabItem(int row, const t_mat& op)
if(row == -1) // append to end of table if(row == -1) // append to end of table
row = m_symops->rowCount(); row = m_symops->rowCount();
else if(row == -2 && m_iCursorRow >= 0) // use row from member variable else if(row == -2 && m_cursorRow >= 0) // use row from member variable
row = m_iCursorRow; row = m_cursorRow;
else if(row == -3 && m_iCursorRow >= 0) // use row from member variable +1 else if(row == -3 && m_cursorRow >= 0) // use row from member variable +1
row = m_iCursorRow + 1; row = m_cursorRow + 1;
else if(row == -4 && m_iCursorRow >= 0) // use row from member variable +1 else if(row == -4 && m_cursorRow >= 0) // use row from member variable +1
{ {
row = m_iCursorRow + 1; row = m_cursorRow + 1;
bclone = 1; bclone = 1;
} }
...@@ -132,7 +132,7 @@ void BZDlg::AddTabItem(int row, const t_mat& op) ...@@ -132,7 +132,7 @@ void BZDlg::AddTabItem(int row, const t_mat& op)
{ {
for(int thecol=0; thecol<NUM_COLS; ++thecol) for(int thecol=0; thecol<NUM_COLS; ++thecol)
m_symops->setItem(row, thecol, m_symops->setItem(row, thecol,
m_symops->item(m_iCursorRow, thecol)->clone()); m_symops->item(m_cursorRow, thecol)->clone());
} }
else else
{ {
...@@ -317,7 +317,7 @@ void BZDlg::ShowTableContextMenu(const QPoint& pt) ...@@ -317,7 +317,7 @@ void BZDlg::ShowTableContextMenu(const QPoint& pt)
if(const auto* item = m_symops->itemAt(pt); item) if(const auto* item = m_symops->itemAt(pt); item)
{ {
m_iCursorRow = item->row(); m_cursorRow = item->row();
ptGlob.setY(ptGlob.y() + m_tabContextMenu->sizeHint().height()/2); ptGlob.setY(ptGlob.y() + m_tabContextMenu->sizeHint().height()/2);
m_tabContextMenu->popup(ptGlob); m_tabContextMenu->popup(ptGlob);
} }
...@@ -340,7 +340,7 @@ void BZDlg::GetSymOpsFromSG() ...@@ -340,7 +340,7 @@ void BZDlg::GetSymOpsFromSG()
{ {
// symops of current space group // symops of current space group
auto sgidx = m_comboSG->itemData(m_comboSG->currentIndex()).toInt(); auto sgidx = m_comboSG->itemData(m_comboSG->currentIndex()).toInt();
if(sgidx < 0 || std::size_t(sgidx) >= m_SGops.size()) if(sgidx < 0 || std::size_t(sgidx) >= m_sg_ops.size())
{ {
QMessageBox::critical(this, "Space Group Conversion", QMessageBox::critical(this, "Space Group Conversion",
"Invalid space group selected."); "Invalid space group selected.");
...@@ -353,7 +353,7 @@ void BZDlg::GetSymOpsFromSG() ...@@ -353,7 +353,7 @@ void BZDlg::GetSymOpsFromSG()
DelTabItem(-1); DelTabItem(-1);
// add symops // add symops
for(const auto& op : m_SGops[sgidx]) for(const auto& op : m_sg_ops[sgidx])
{ {
AddTabItem(-1, op); AddTabItem(-1, op);
} }
......
...@@ -728,11 +728,13 @@ MagDynDlg::MagDynDlg(QWidget* pParent) : QDialog{pParent}, ...@@ -728,11 +728,13 @@ MagDynDlg::MagDynDlg(QWidget* pParent) : QDialog{pParent},
grid->addWidget(m_field_dir[2], y++,3,1,1); grid->addWidget(m_field_dir[2], y++,3,1,1);
grid->addWidget(m_align_spins, y++,0,1,2); grid->addWidget(m_align_spins, y++,0,1,2);
auto sep1 = new QFrame(m_samplepanel); sep1->setFrameStyle(QFrame::HLine);
auto sep2 = new QFrame(m_samplepanel); sep2->setFrameStyle(QFrame::HLine);
auto sep3 = new QFrame(m_samplepanel); sep3->setFrameStyle(QFrame::HLine);
grid->addItem(new QSpacerItem(8, 8, grid->addItem(new QSpacerItem(8, 8,
QSizePolicy::Minimum, QSizePolicy::Fixed), QSizePolicy::Minimum, QSizePolicy::Fixed),
y++,0, 1,1); y++,0, 1,1);
auto sep1 = new QFrame(m_samplepanel);
sep1->setFrameStyle(QFrame::HLine);
grid->addWidget(sep1, y++,0, 1,4); grid->addWidget(sep1, y++,0, 1,4);
grid->addItem(new QSpacerItem(8, 8, grid->addItem(new QSpacerItem(8, 8,
QSizePolicy::Minimum, QSizePolicy::Fixed), QSizePolicy::Minimum, QSizePolicy::Fixed),
...@@ -752,8 +754,6 @@ MagDynDlg::MagDynDlg(QWidget* pParent) : QDialog{pParent}, ...@@ -752,8 +754,6 @@ MagDynDlg::MagDynDlg(QWidget* pParent) : QDialog{pParent},
grid->addItem(new QSpacerItem(16, 16, grid->addItem(new QSpacerItem(16, 16,
QSizePolicy::Minimum, QSizePolicy::Fixed), QSizePolicy::Minimum, QSizePolicy::Fixed),
y++,0, 1,1); y++,0, 1,1);
auto sep2 = new QFrame(m_samplepanel);
sep2->setFrameStyle(QFrame::HLine);
grid->addWidget(sep2, y++,0, 1,4); grid->addWidget(sep2, y++,0, 1,4);
grid->addItem(new QSpacerItem(16, 16, grid->addItem(new QSpacerItem(16, 16,
QSizePolicy::Minimum, QSizePolicy::Fixed), QSizePolicy::Minimum, QSizePolicy::Fixed),
...@@ -768,8 +768,6 @@ MagDynDlg::MagDynDlg(QWidget* pParent) : QDialog{pParent}, ...@@ -768,8 +768,6 @@ MagDynDlg::MagDynDlg(QWidget* pParent) : QDialog{pParent},
grid->addItem(new QSpacerItem(16, 16, grid->addItem(new QSpacerItem(16, 16,
QSizePolicy::Minimum, QSizePolicy::Fixed), QSizePolicy::Minimum, QSizePolicy::Fixed),
y++,0, 1,1); y++,0, 1,1);
auto sep3 = new QFrame(m_samplepanel);
sep3->setFrameStyle(QFrame::HLine);
grid->addWidget(sep3, y++,0, 1,4); grid->addWidget(sep3, y++,0, 1,4);
grid->addItem(new QSpacerItem(16, 16, grid->addItem(new QSpacerItem(16, 16,
QSizePolicy::Minimum, QSizePolicy::Fixed), QSizePolicy::Minimum, QSizePolicy::Fixed),
...@@ -1063,14 +1061,10 @@ MagDynDlg::MagDynDlg(QWidget* pParent) : QDialog{pParent}, ...@@ -1063,14 +1061,10 @@ MagDynDlg::MagDynDlg(QWidget* pParent) : QDialog{pParent},
grid->setSpacing(4); grid->setSpacing(4);
grid->setContentsMargins(6, 6, 6, 6); grid->setContentsMargins(6, 6, 6, 6);
auto sep1 = new QFrame(infopanel); auto sep1 = new QFrame(infopanel); sep1->setFrameStyle(QFrame::HLine);
sep1->setFrameStyle(QFrame::HLine); auto sep2 = new QFrame(infopanel); sep2->setFrameStyle(QFrame::HLine);
auto sep2 = new QFrame(infopanel); auto sep3 = new QFrame(infopanel); sep3->setFrameStyle(QFrame::HLine);
sep2->setFrameStyle(QFrame::HLine); auto sep4 = new QFrame(infopanel); sep4->setFrameStyle(QFrame::HLine);
auto sep3 = new QFrame(infopanel);
sep3->setFrameStyle(QFrame::HLine);
auto sep4 = new QFrame(infopanel);
sep4->setFrameStyle(QFrame::HLine);
std::string strBoost = BOOST_LIB_VERSION; std::string strBoost = BOOST_LIB_VERSION;
algo::replace_all(strBoost, "_", "."); algo::replace_all(strBoost, "_", ".");
...@@ -1138,9 +1132,7 @@ MagDynDlg::MagDynDlg(QWidget* pParent) : QDialog{pParent}, ...@@ -1138,9 +1132,7 @@ MagDynDlg::MagDynDlg(QWidget* pParent) : QDialog{pParent},
infopanel), y++,0, 1,1); infopanel), y++,0, 1,1);
grid->addWidget(sep3, y++,0, 1,1); grid->addWidget(sep3, y++,0, 1,1);
grid->addWidget(labelPaper, y++,0, 1,1); grid->addWidget(labelPaper, y++,0, 1,1);
grid->addWidget(sep4, y++,0, 1,1); grid->addWidget(sep4, y++,0, 1,1);
for(int i=0; i<4; ++i) for(int i=0; i<4; ++i)
......
...@@ -36,12 +36,20 @@ ...@@ -36,12 +36,20 @@
#include <gemmi/cif.hpp> #include <gemmi/cif.hpp>
#include <gemmi/symmetry.hpp> #include <gemmi/symmetry.hpp>
#include <gemmi/version.hpp>
#include "tlibs2/libs/maths.h" #include "tlibs2/libs/maths.h"
using namespace tl2_ops; using namespace tl2_ops;
template<class t_real=double> template<class t_str = std::string>
t_str get_gemmi_version()
{
return GEMMI_VERSION;
}
template<class t_real = double>
struct Lattice struct Lattice
{ {
t_real a, b, c; t_real a, b, c;
......
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