Verified Commit c7a5b324 authored by Tobias WEBER's avatar Tobias WEBER
Browse files

bz tool: continued with gui

parent ee0f4f31
......@@ -66,12 +66,13 @@ BZDlg::BZDlg(QWidget* pParent) : QDialog{pParent},
m_symops->setSelectionBehavior(QTableWidget::SelectRows);
m_symops->setSelectionMode(QTableWidget::ContiguousSelection);
m_symops->setContextMenuPolicy(Qt::CustomContextMenu);
m_symops->verticalHeader()->setDefaultSectionSize(fontMetrics().lineSpacing() + 4);
m_symops->verticalHeader()->setDefaultSectionSize(
fontMetrics().lineSpacing()*4 + 4);
m_symops->verticalHeader()->setVisible(false);
m_symops->setAlternatingRowColors(true);
m_symops->setColumnCount(NUM_COLS);
m_symops->setHorizontalHeaderItem(COL_OP, new QTableWidgetItem{"Symmetry Operations"});
m_symops->setHorizontalHeaderItem(COL_OP,
new QTableWidgetItem{"Symmetry Operations"});
m_symops->setColumnWidth(COL_OP, 500);
QToolButton *btnAdd = new QToolButton(symopspanel);
......
......@@ -38,6 +38,10 @@
#include <boost/property_tree/xml_parser.hpp>
namespace pt = boost::property_tree;
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/replace.hpp>
namespace algo = boost::algorithm;
#include "../structfact/loadcif.h"
#include "tlibs2/libs/algos.h"
......@@ -248,9 +252,11 @@ void BZDlg::Save()
// symop list
for(int row=0; row<m_symops->rowCount(); ++row)
{
pt::ptree itemNode;
itemNode.put<std::string>("op", m_symops->item(row, COL_OP)->text().toStdString());
std::string opstr = m_symops->item(row, COL_OP)->text().toStdString();
algo::replace_all(opstr, "\n", " ");
pt::ptree itemNode;
itemNode.put<std::string>("op", opstr);
node.add_child("bz.symops.symop", itemNode);
}
......
......@@ -55,10 +55,14 @@ std::string BZDlg::OpToStr(const t_mat& op)
{
t_real elem = op(row, col);
tl2::set_eps_0(elem);
ostr << elem << " ";
ostr << elem;
if(col != op.size2()-1)
ostr << " ";
}
ostr << " ";
if(row != op.size1()-1)
ostr << "\n";
}
return ostr.str();
......@@ -174,7 +178,8 @@ void BZDlg::MoveTabItemUp()
for(int row=0; row<m_symops->rowCount(); ++row)
{
if(auto *item = m_symops->item(row, 0);
item && std::find(selected.begin(), selected.end(), row+1) != selected.end())
item && std::find(selected.begin(), selected.end(), row+1)
!= selected.end())
{
for(int col=0; col<m_symops->columnCount(); ++col)
m_symops->item(row, col)->setSelected(true);
......@@ -209,7 +214,8 @@ void BZDlg::MoveTabItemDown()
for(int row=0; row<m_symops->rowCount(); ++row)
{
if(auto *item = m_symops->item(row, 0);
item && std::find(selected.begin(), selected.end(), row-1) != selected.end())
item && std::find(selected.begin(), selected.end(), row-1)
!= selected.end())
{
for(int col=0; col<m_symops->columnCount(); ++col)
m_symops->item(row, col)->setSelected(true);
......
......@@ -50,7 +50,7 @@ void BZDlg::ShowBZPlot()
m_plot->GetRenderer()->SetLight(0, tl2::create<t_vec3_gl>({ 5, 5, 5 }));
m_plot->GetRenderer()->SetLight(1, tl2::create<t_vec3_gl>({ -5, -5, -5 }));
m_plot->GetRenderer()->SetCoordMax(1.);
m_plot->GetRenderer()->GetCamera().SetDist(1.5);
m_plot->GetRenderer()->GetCamera().SetDist(2.);
m_plot->GetRenderer()->GetCamera().UpdateTransformation();
//auto labCoordSys = new QLabel("Coordinate System:", this);
......@@ -65,7 +65,10 @@ void BZDlg::ShowBZPlot()
m_plot_labels->setChecked(true);
m_plot_plane->setChecked(true);
// status bar
m_status3D = new QLabel(this);
m_status3D->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
m_status3D->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred);
m_plot->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Expanding});
//labCoordSys->setSizePolicy(QSizePolicy{QSizePolicy::Fixed, QSizePolicy::Fixed});
......@@ -291,9 +294,22 @@ void BZDlg::PickerIntersection(
m_curPickedObj = -1;
if(m_curPickedObj > 0)
if(m_curPickedObj > 0 && pos)
{
// TODO
std::ostringstream ostr;
ostr.precision(g_prec_gui);
t_vec QinvA = tl2::convert<t_vec>(*pos);
t_mat Binv = m_crystA / (t_real(2)*tl2::pi<t_real>);
t_vec Qrlu = Binv * QinvA;
tl2::set_eps_0<t_vec>(QinvA, t_real_gl(g_eps));
tl2::set_eps_0<t_vec>(Qrlu, t_real_gl(g_eps));
ostr << "Q = (" << QinvA[0] << ", " << QinvA[1] << ", " << QinvA[2] << ") Å⁻¹";
ostr << " = (" << Qrlu[0] << ", " << Qrlu[1] << ", " << Qrlu[2] << ") rlu.";
Set3DStatusMsg(ostr.str());
}
else
{
......
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