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

bz: started with bz cut plot

parent 056276f6
......@@ -71,7 +71,8 @@ include_directories(
add_executable(takin_bz
bz.cpp bz_file.cpp
bz_plot.cpp bz_main.cpp
bz_ops.cpp bz.h
bz_ops.cpp bz.h globals.h
plot_cut.cpp plot_cut.h
../../tlibs2/libs/qt/gl.cpp ../../tlibs2/libs/qt/gl.h
../../tlibs2/libs/qt/glplot.cpp ../../tlibs2/libs/qt/glplot.h)
......
......@@ -32,6 +32,7 @@
#include <QtWidgets/QTabWidget>
#include <QtWidgets/QLabel>
#include <QtWidgets/QToolButton>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QFileDialog>
#include <QtWidgets/QMessageBox>
......@@ -42,7 +43,6 @@
namespace algo = boost::algorithm;
#include "../structfact/loadcif.h"
#include "tlibs2/libs/maths.h"
#include "tlibs2/libs/phys.h"
#include "tlibs2/libs/algos.h"
#include "tlibs2/libs/qt/helper.h"
......@@ -82,24 +82,23 @@ BZDlg::BZDlg(QWidget* pParent) : QDialog{pParent},
m_symops->setHorizontalHeaderItem(COL_OP, new QTableWidgetItem{"Symmetry Operation"});
m_symops->setColumnWidth(COL_OP, 500);
QToolButton *pTabBtnAdd = new QToolButton(symopspanel);
QToolButton *pTabBtnDel = new QToolButton(symopspanel);
QToolButton *pTabBtnUp = new QToolButton(symopspanel);
QToolButton *pTabBtnDown = new QToolButton(symopspanel);
QToolButton *pTabBtnSG = new QToolButton(symopspanel);
QToolButton *btnAdd = new QToolButton(symopspanel);
QToolButton *btnDel = new QToolButton(symopspanel);
QToolButton *btnUp = new QToolButton(symopspanel);
QToolButton *btnDown = new QToolButton(symopspanel);
QPushButton *btnSG = new QPushButton("Get SymOps", symopspanel);
m_symops->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Expanding});
pTabBtnAdd->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Fixed});
pTabBtnDel->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Fixed});
pTabBtnUp->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Fixed});
pTabBtnDown->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Fixed});
pTabBtnSG->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Fixed});
pTabBtnAdd->setText("Add SymOp");
pTabBtnDel->setText("Delete SymOp");
pTabBtnUp->setText("Move SymOp Up");
pTabBtnDown->setText("Move SymOp Down");
pTabBtnSG->setText("Get SymOps");
btnAdd->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Fixed});
btnDel->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Fixed});
btnUp->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Fixed});
btnDown->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Fixed});
btnSG->setSizePolicy(QSizePolicy{QSizePolicy::Expanding, QSizePolicy::Fixed});
btnAdd->setText("Add SymOp");
btnDel->setText("Delete SymOp");
btnUp->setText("Move SymOp Up");
btnDown->setText("Move SymOp Down");
m_editA = new QLineEdit("5", symopspanel);
m_editB = new QLineEdit("5", symopspanel);
......@@ -127,14 +126,14 @@ BZDlg::BZDlg(QWidget* pParent) : QDialog{pParent},
int y=0;
//pTabGrid->addWidget(m_plot.get(), y,0,1,4);
pTabGrid->addWidget(m_symops, y,0,1,4);
pTabGrid->addWidget(pTabBtnAdd, ++y,0,1,1);
pTabGrid->addWidget(pTabBtnDel, y,1,1,1);
pTabGrid->addWidget(pTabBtnUp, y,2,1,1);
pTabGrid->addWidget(pTabBtnDown, y,3,1,1);
pTabGrid->addWidget(btnAdd, ++y,0,1,1);
pTabGrid->addWidget(btnDel, y,1,1,1);
pTabGrid->addWidget(btnUp, y,2,1,1);
pTabGrid->addWidget(btnDown, y,3,1,1);
pTabGrid->addWidget(new QLabel("Space Group:"), ++y,0,1,1);
pTabGrid->addWidget(m_comboSG, y,1,1,2);
pTabGrid->addWidget(pTabBtnSG, y,3,1,1);
pTabGrid->addWidget(btnSG, y,3,1,1);
auto sep1 = new QFrame(symopspanel); sep1->setFrameStyle(QFrame::HLine);
......@@ -169,11 +168,11 @@ BZDlg::BZDlg(QWidget* pParent) : QDialog{pParent},
for(auto* edit : std::vector<QLineEdit*>{{ m_editA, m_editB, m_editC, m_editAlpha, m_editBeta, m_editGamma }})
connect(edit, &QLineEdit::textEdited, this, [this]() { this->CalcB(); });
connect(pTabBtnAdd, &QToolButton::clicked, this, [this]() { this->AddTabItem(-1); });
connect(pTabBtnDel, &QToolButton::clicked, this, [this]() { BZDlg::DelTabItem(); });
connect(pTabBtnUp, &QToolButton::clicked, this, &BZDlg::MoveTabItemUp);
connect(pTabBtnDown, &QToolButton::clicked, this, &BZDlg::MoveTabItemDown);
connect(pTabBtnSG, &QToolButton::clicked, this, &BZDlg::GetSymOpsFromSG);
connect(btnAdd, &QToolButton::clicked, this, [this]() { this->AddTabItem(-1); });
connect(btnDel, &QToolButton::clicked, this, [this]() { BZDlg::DelTabItem(); });
connect(btnUp, &QToolButton::clicked, this, &BZDlg::MoveTabItemUp);
connect(btnDown, &QToolButton::clicked, this, &BZDlg::MoveTabItemDown);
connect(btnSG, &QPushButton::clicked, this, &BZDlg::GetSymOpsFromSG);
connect(m_symops, &QTableWidget::currentCellChanged, this, &BZDlg::TableCurCellChanged);
connect(m_symops, &QTableWidget::entered, this, &BZDlg::TableCellEntered);
......@@ -184,33 +183,71 @@ BZDlg::BZDlg(QWidget* pParent) : QDialog{pParent},
}
{ // brillouin zone cuts panel
auto cutspanel = new QWidget(this);
auto pGrid = new QGridLayout(cutspanel);
pGrid->setSpacing(4);
pGrid->setContentsMargins(4,4,4,4);
m_bzscene = new BZCutScene(cutspanel);
m_bzview = new BZCutView(m_bzscene);
for(QDoubleSpinBox** const cut : { &m_cutX, &m_cutY, &m_cutZ, &m_cutD })
{
*cut = new QDoubleSpinBox(cutspanel);
(*cut)->setMinimum(-99);
(*cut)->setMaximum(99);
(*cut)->setDecimals(2);
(*cut)->setSingleStep(1);
(*cut)->setValue(0);
}
m_cutZ->setValue(1);
pGrid->addWidget(m_bzview, 0,0, 1,4);
pGrid->addWidget(new QLabel("Plane Normal:"), 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);
// signals
// TODO
tabs->addTab(cutspanel, "Cuts");
}
{ // brillouin zone panel
auto sfactpanel = new QWidget(this);
auto pGrid = new QGridLayout(sfactpanel);
auto bzpanel = new QWidget(this);
auto pGrid = new QGridLayout(bzpanel);
pGrid->setSpacing(4);
pGrid->setContentsMargins(4,4,4,4);
m_bz = new QPlainTextEdit(sfactpanel);
m_bz = new QPlainTextEdit(bzpanel);
m_bz->setReadOnly(true);
m_bz->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
m_maxBZ = new QSpinBox(sfactpanel);
m_maxBZ = new QSpinBox(bzpanel);
m_maxBZ->setMinimum(1);
m_maxBZ->setMaximum(99);
m_maxBZ->setValue(4);
QPushButton *btnShowBZ = new QPushButton("3D View...", bzpanel);
pGrid->addWidget(m_bz, 0,0, 1,4);
pGrid->addWidget(new QLabel("Max. Order:"), 1,0,1,1);
pGrid->addWidget(m_maxBZ, 1,1, 1,1);
pGrid->addWidget(btnShowBZ, 1,3, 1,1);
// signals
connect(m_maxBZ,
static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this, [this]() { this->CalcBZ(); });
connect(btnShowBZ, &QPushButton::clicked, this, &BZDlg::ShowBZPlot);
tabs->addTab(sfactpanel, "Brillouin Zone");
tabs->addTab(bzpanel, "Brillouin Zone");
}
......
......@@ -33,6 +33,7 @@
#include <QtWidgets/QPlainTextEdit>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QSpinBox>
#include <QtWidgets/QDoubleSpinBox>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QMenu>
#include <QtWidgets/QLabel>
......@@ -43,30 +44,13 @@
#include <vector>
#include <sstream>
#include <boost/math/quaternion.hpp>
namespace math = boost::math;
#include "globals.h"
#include "plot_cut.h"
#include "tlibs2/libs/qt/glplot.h"
#include "tlibs2/libs/math20.h"
#include "tlibs2/libs/qt/numerictablewidgetitem.h"
using t_real = double;
using t_vec = tl2::vec<t_real, std::vector>;
using t_mat = tl2::mat<t_real, std::vector>;
using t_quat = math::quaternion<t_real>;
using t_real_gl = tl2::t_real_gl;
using t_vec2_gl = tl2::t_vec2_gl;
using t_vec3_gl = tl2::t_vec3_gl;
using t_vec_gl = tl2::t_vec_gl;
using t_mat_gl = tl2::t_mat_gl;
constexpr t_real g_eps = 1e-6;
constexpr int g_prec = 6;
enum : int
{
COL_OP = 0,
......@@ -86,23 +70,33 @@ protected:
QSettings *m_sett = nullptr;
QMenuBar *m_menu = nullptr;
// plotter
QDialog *m_dlgPlot = nullptr;
std::shared_ptr<tl2::GlPlot> m_plot;
std::size_t m_sphere = 0;
QLabel *m_labelGlInfos[4] = { nullptr, nullptr, nullptr, nullptr };
QLabel *m_status3D = nullptr;
QTableWidget *m_symops = nullptr;
QPlainTextEdit *m_bz = nullptr;
// symops panel
QLineEdit *m_editA = nullptr;
QLineEdit *m_editB = nullptr;
QLineEdit *m_editC = nullptr;
QLineEdit *m_editAlpha = nullptr;
QLineEdit *m_editBeta = nullptr;
QLineEdit *m_editGamma = nullptr;
QTableWidget *m_symops = nullptr;
QComboBox *m_comboSG = nullptr;
// cuts panel
BZCutScene *m_bzscene = nullptr;
BZCutView *m_bzview = nullptr;
QDoubleSpinBox *m_cutX = nullptr;
QDoubleSpinBox *m_cutY = nullptr;
QDoubleSpinBox *m_cutZ = nullptr;
QDoubleSpinBox *m_cutD = nullptr;
// brillouin zone panel
QPlainTextEdit *m_bz = nullptr;
QSpinBox *m_maxBZ = nullptr;
QMenu *m_pTabContextMenu = nullptr; // menu in case a symop is selected
......
......@@ -38,7 +38,6 @@
namespace pt = boost::property_tree;
#include "../structfact/loadcif.h"
#include "tlibs2/libs/maths.h"
#include "tlibs2/libs/algos.h"
using namespace tl2_ops;
......
......@@ -34,7 +34,6 @@
#include <iostream>
#include <tuple>
#include "tlibs2/libs/maths.h"
#include "tlibs2/libs/phys.h"
#include "tlibs2/libs/algos.h"
#include "tlibs2/libs/qt/helper.h"
......
......@@ -29,7 +29,6 @@
#include "bz.h"
#include "tlibs2/libs/maths.h"
#include "tlibs2/libs/phys.h"
#include "tlibs2/libs/algos.h"
......
/**
* brillouin zone tool
* @author Tobias Weber <tweber@ill.fr>
* @date Maz-2022
* @license GPLv3, see 'LICENSE' file
*
* ----------------------------------------------------------------------------
* mag-core (part of the Takin software suite)
* Copyright (C) 2018-2022 Tobias WEBER (Institut Laue-Langevin (ILL),
* Grenoble, France).
* "misc" project
* Copyright (C) 2017-2021 Tobias WEBER (privately developed).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ----------------------------------------------------------------------------
*/
#ifndef __BZTOOL_GLOBALS_H__
#define __BZTOOL_GLOBALS_H__
#include <boost/math/quaternion.hpp>
namespace math = boost::math;
#include "tlibs2/libs/maths.h"
#include "tlibs2/libs/qt/gl.h"
using t_real = double;
using t_vec = tl2::vec<t_real, std::vector>;
using t_mat = tl2::mat<t_real, std::vector>;
using t_quat = math::quaternion<t_real>;
using t_real_gl = tl2::t_real_gl;
using t_vec2_gl = tl2::t_vec2_gl;
using t_vec3_gl = tl2::t_vec3_gl;
using t_vec_gl = tl2::t_vec_gl;
using t_mat_gl = tl2::t_mat_gl;
constexpr t_real g_eps = 1e-6;
constexpr int g_prec = 6;
#endif
/**
* brillouin zone tool
* @author Tobias Weber <tweber@ill.fr>
* @date May-2022
* @license GPLv3, see 'LICENSE' file
*
* ----------------------------------------------------------------------------
* mag-core (part of the Takin software suite)
* Copyright (C) 2018-2022 Tobias WEBER (Institut Laue-Langevin (ILL),
* Grenoble, France).
* "misc" project
* Copyright (C) 2017-2021 Tobias WEBER (privately developed).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ----------------------------------------------------------------------------
*/
#include "plot_cut.h"
// --------------------------------------------------------------------------------
BZCutScene::BZCutScene(QWidget *parent) : QGraphicsScene(parent)
{
//addLine(QLineF(0,0, 10,10));
}
BZCutScene::~BZCutScene()
{
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
BZCutView::BZCutView(BZCutScene* scene)
: QGraphicsView(scene, static_cast<QWidget*>(scene->parent()))
{
setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
setDragMode(QGraphicsView::ScrollHandDrag);
setInteractive(true);
setMouseTracking(true);
}
BZCutView::~BZCutView()
{
}
void BZCutView::wheelEvent(QWheelEvent *evt)
{
t_real sc = std::pow(2., evt->angleDelta().y()/8.*0.01);
QGraphicsView::scale(sc, sc);
}
// --------------------------------------------------------------------------------
/**
* brillouin zone tool
* @author Tobias Weber <tweber@ill.fr>
* @date May-2022
* @license GPLv3, see 'LICENSE' file
*
* ----------------------------------------------------------------------------
* mag-core (part of the Takin software suite)
* Copyright (C) 2018-2022 Tobias WEBER (Institut Laue-Langevin (ILL),
* Grenoble, France).
* "misc" project
* Copyright (C) 2017-2021 Tobias WEBER (privately developed).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ----------------------------------------------------------------------------
*/
#ifndef __BZCUT_H__
#define __BZCUT_H__
#include <QtWidgets/QGraphicsScene>
#include <QtWidgets/QGraphicsView>
#include <QtWidgets/QGraphicsItem>
#include <QtGui/QWheelEvent>
#include "globals.h"
class BZCutScene : public QGraphicsScene
{
public:
BZCutScene(QWidget *parent = nullptr);
virtual ~BZCutScene();
protected:
};
class BZCutView : public QGraphicsView
{
public:
BZCutView(BZCutScene* scene);
virtual ~BZCutView();
protected:
virtual void wheelEvent(QWheelEvent *evt) override;
};
#endif
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