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

finished with bz cuts

parent 290cd478
......@@ -184,7 +184,9 @@ BZDlg::BZDlg(QWidget* pParent) : QDialog{pParent},
m_bzscene = new BZCutScene(cutspanel);
m_bzview = new BZCutView(m_bzscene);
for(QDoubleSpinBox** const cut : { &m_cutX, &m_cutY, &m_cutZ, &m_cutD })
for(QDoubleSpinBox** const cut :
{ &m_cutX, &m_cutY, &m_cutZ,
&m_cutNX, &m_cutNY, &m_cutNZ, &m_cutD })
{
*cut = new QDoubleSpinBox(cutspanel);
(*cut)->setMinimum(-99);
......@@ -197,15 +199,20 @@ BZDlg::BZDlg(QWidget* pParent) : QDialog{pParent},
(&QDoubleSpinBox::valueChanged),
this, &BZDlg::CalcBZCut);
}
m_cutZ->setValue(1);
m_cutX->setValue(1);
m_cutNZ->setValue(1);
pGrid->addWidget(m_bzview, 0,0, 1,4);
pGrid->addWidget(new QLabel("Plane Normal:"), 1,0, 1,1);
pGrid->addWidget(new QLabel("In-Plane Vector:"), 1,0, 1,1);
pGrid->addWidget(m_cutX, 1,1, 1,1);
pGrid->addWidget(m_cutY, 1,2, 1,1);
pGrid->addWidget(m_cutZ, 1,3, 1,1);
pGrid->addWidget(new QLabel("Plane Offset:"), 2,0, 1,1);
pGrid->addWidget(m_cutD, 2,1, 1,1);
pGrid->addWidget(new QLabel("Plane Normal:"), 2,0, 1,1);
pGrid->addWidget(m_cutNX, 2,1, 1,1);
pGrid->addWidget(m_cutNY, 2,2, 1,1);
pGrid->addWidget(m_cutNZ, 2,3, 1,1);
pGrid->addWidget(new QLabel("Plane Offset:"), 3,0, 1,1);
pGrid->addWidget(m_cutD, 3,1, 1,1);
tabs->addTab(cutspanel, "Cut");
}
......
......@@ -97,11 +97,15 @@ protected:
QDoubleSpinBox *m_cutX = nullptr;
QDoubleSpinBox *m_cutY = nullptr;
QDoubleSpinBox *m_cutZ = nullptr;
QDoubleSpinBox *m_cutNX = nullptr;
QDoubleSpinBox *m_cutNY = nullptr;
QDoubleSpinBox *m_cutNZ = nullptr;
QDoubleSpinBox *m_cutD = nullptr;
// brillouin zone panel
QPlainTextEdit *m_bz = nullptr;
QSpinBox *m_maxBZ = nullptr;
std::vector<std::vector<t_vec>> m_bz_polys;
QMenu *m_pTabContextMenu = nullptr; // menu in case a symop is selected
QMenu *m_pTabContextMenuNoItem = nullptr; // menu if nothing is selected
......@@ -130,8 +134,8 @@ protected:
void GetSymOpsFromSG();
std::vector<t_mat> GetSymOps(bool only_centring = false) const;
void CalcB(bool bFullRecalc=true);
void CalcBZ();
void CalcB(bool full_recalc = true);
void CalcBZ(bool full_recalc = true);
void CalcBZCut();
void ClearPlot();
......
......@@ -44,7 +44,7 @@ using namespace tl2_ops;
/**
* calculate crystal B matrix
*/
void BZDlg::CalcB(bool bFullRecalc)
void BZDlg::CalcB(bool full_recalc)
{
if(m_ignoreCalc)
return;
......@@ -93,7 +93,7 @@ void BZDlg::CalcB(bool bFullRecalc)
m_plot->GetRenderer()->SetBTrafo(m_crystB, &matA);
}
if(bFullRecalc)
if(full_recalc)
CalcBZ();
}
......@@ -101,7 +101,7 @@ void BZDlg::CalcB(bool bFullRecalc)
/**
* calculate brillouin zone
*/
void BZDlg::CalcBZ()
void BZDlg::CalcBZ(bool full_recalc)
{
if(m_ignoreCalc)
return;
......@@ -151,6 +151,7 @@ void BZDlg::CalcBZ()
voronoi = tl2::remove_duplicates(voronoi, g_eps);
ClearPlot();
m_bz_polys.clear();
#ifdef DEBUG
std::ofstream ofstrSites("sites.dat");
......@@ -211,10 +212,14 @@ void BZDlg::CalcBZ()
}
}
m_bz_polys = std::move(bz_triags);
PlotAddTriangles(bz_all_triags);
// brillouin zone description
m_bz->setPlainText(ostr.str().c_str());
if(full_recalc)
CalcBZCut();
}
......@@ -223,12 +228,47 @@ void BZDlg::CalcBZ()
*/
void BZDlg::CalcBZCut()
{
t_real nx = m_cutX->value();
t_real ny = m_cutY->value();
t_real nz = m_cutZ->value();
if(m_ignoreCalc || !m_bz_polys.size())
return;
t_real x = m_cutX->value();
t_real y = m_cutY->value();
t_real z = m_cutZ->value();
t_real nx = m_cutNX->value();
t_real ny = m_cutNY->value();
t_real nz = m_cutNZ->value();
t_real d = m_cutD->value();
// get plane coordinate system
t_vec vec1 = tl2::create<t_vec>({ x, y, z });
t_vec norm = tl2::create<t_vec>({ nx, ny, nz });
norm /= tl2::norm<t_vec>(norm);
t_vec vec2 = tl2::cross<t_vec>(norm, vec1);
vec1 = tl2::cross<t_vec>(vec2, norm);
vec1 /= tl2::norm<t_vec>(vec1);
vec2 /= tl2::norm<t_vec>(vec2);
t_mat matPlane = tl2::create<t_mat, t_vec>({ vec1, vec2, norm }, true);
std::vector<std::pair<t_vec, t_vec>> lines;
for(const auto& bz_poly : m_bz_polys)
{
auto vecs = tl2::intersect_plane_poly<t_vec>(
norm, d, bz_poly, g_eps);
vecs = tl2::remove_duplicates(vecs, g_eps);
if(vecs.size() >= 2)
{
t_vec pt1 = matPlane * vecs[0];
t_vec pt2 = matPlane * vecs[1];
lines.emplace_back(std::make_pair(pt1, pt2));
}
}
m_bzscene->clear();
m_bzscene->AddCut(lines);
PlotSetPlane(norm, d);
}
......@@ -360,5 +360,5 @@ void BZDlg::AfterGLInitialisation()
m_labelGlInfos[2]->setText(QString("GL Vendor: ") + strGlVendor.c_str() + QString("."));
m_labelGlInfos[3]->setText(QString("GL Device: ") + strGlRenderer.c_str() + QString("."));
CalcBZ();
CalcB(true);
}
......@@ -31,13 +31,23 @@
// --------------------------------------------------------------------------------
BZCutScene::BZCutScene(QWidget *parent) : QGraphicsScene(parent)
{
//addLine(QLineF(0,0, 10,10));
}
BZCutScene::~BZCutScene()
{
}
void BZCutScene::AddCut(const std::vector<std::pair<t_vec, t_vec>>& lines)
{
for(const auto& line : lines)
{
addLine(QLineF(
line.first[0]*m_scale, line.first[1]*m_scale,
line.second[0]*m_scale, line.second[1]*m_scale));
}
}
// --------------------------------------------------------------------------------
......
......@@ -42,8 +42,11 @@ public:
BZCutScene(QWidget *parent = nullptr);
virtual ~BZCutScene();
void AddCut(const std::vector<std::pair<t_vec, t_vec>>& lines);
protected:
t_real m_scale = 100.;
};
......
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