Verified Commit 8447032e authored by Tobias WEBER's avatar Tobias WEBER
Browse files

added bz cut exporting

parent 9a8cffcc
......@@ -197,7 +197,8 @@ class ScatteringTriangle : public QGraphicsItem
const tl::Kd<t_real_glob>& GetKdLattice() const { return m_kdLattice; }
const tl::Brillouin3D<t_real_glob>& GetBZ3D() const { return m_bz3; }
const std::vector<ublas::vector<t_real_glob>>& GetBZ3DPlaneVerts() const { return m_vecBZ3VertsUnproj; }
const std::vector<ublas::vector<t_real_glob>>& GetBZ3DPlaneVerts(bool planeproj=0) const
{ return planeproj ? m_vecBZ3Verts : m_vecBZ3VertsUnproj; }
const std::vector<ublas::vector<t_real_glob>>& GetBZ3DSymmVerts() const { return m_vecBZ3SymmPts; }
public:
......
......@@ -452,6 +452,9 @@ TazDlg::TazDlg(QWidget* pParent, const std::string& strLogFile)
pBZ3DExport->setIcon(load_icon("res/icons/image-x-generic.svg"));
m_pMenuViewRecip->addAction(pBZ3DExport);
QAction *pBZCutExport = new QAction("Export Brillouin Zone Cut...", this);
pBZCutExport->setIcon(load_icon("res/icons/image-x-generic.svg"));
m_pMenuViewRecip->addAction(pBZCutExport);
// --------------------------------------------------------------------------------
......@@ -830,6 +833,7 @@ TazDlg::TazDlg(QWidget* pParent, const std::string& strLogFile)
QObject::connect(pRecipExport, &QAction::triggered, this, &TazDlg::ExportRecip);
QObject::connect(pBZ3DExport, &QAction::triggered, this, &TazDlg::ExportBZ3DModel);
QObject::connect(pBZCutExport, &QAction::triggered, this, &TazDlg::ExportBZCut);
QObject::connect(pProjExport, &QAction::triggered, this, &TazDlg::ExportProj);
QObject::connect(pRealExport, &QAction::triggered, this, &TazDlg::ExportReal);
QObject::connect(pTofExport, &QAction::triggered, this, &TazDlg::ExportTof);
......
......@@ -266,6 +266,7 @@ class TazDlg : public QMainWindow, Ui::TazDlg
void ExportRecip();
void ExportProj();
void ExportBZ3DModel();
void ExportBZCut();
void ExportUCModel();
void RepopulateSpaceGroups();
......
......@@ -34,6 +34,7 @@ void TazDlg::ExportReal()
pTas->SetZoom(dZoom);
}
void TazDlg::ExportTof()
{
TofLayout *pTof = m_sceneTof.GetTofLayout();
......@@ -45,6 +46,7 @@ void TazDlg::ExportTof()
pTof->SetZoom(dZoom);
}
void TazDlg::ExportRealLattice()
{
RealLattice *pLatt = m_sceneRealLattice.GetLattice();
......@@ -56,6 +58,7 @@ void TazDlg::ExportRealLattice()
pLatt->SetZoom(dZoom);
}
void TazDlg::ExportRecip()
{
ScatteringTriangle *pTri = m_sceneRecip.GetTriangle();
......@@ -67,6 +70,7 @@ void TazDlg::ExportRecip()
pTri->SetZoom(dZoom);
}
void TazDlg::ExportProj()
{
ProjLattice *pLatt = m_sceneProjRecip.GetLattice();
......@@ -78,6 +82,7 @@ void TazDlg::ExportProj()
pLatt->SetZoom(dZoom);
}
void TazDlg::ExportSceneSVG(QGraphicsScene& scene)
{
QFileDialog::Option fileopt = QFileDialog::Option(0);
......@@ -111,6 +116,62 @@ void TazDlg::ExportSceneSVG(QGraphicsScene& scene)
}
/**
* export the current cut of the brillouin zone with the scattering plane
*/
void TazDlg::ExportBZCut()
{
QFileDialog::Option fileopt = QFileDialog::Option(0);
if(!m_settings.value("main/native_dialogs", 1).toBool())
fileopt = QFileDialog::DontUseNativeDialog;
QString strDirLast = m_settings.value("main/last_dir_export", ".").toString();
QString strFile = QFileDialog::getSaveFileName(this,
"Export Data", strDirLast, "Data files (*.dat *.DAT)", nullptr, fileopt);
if(strFile == "")
return;
if(!strFile.endsWith(".dat", Qt::CaseInsensitive))
strFile += ".dat";
const ScatteringTriangle *pTri = m_sceneRecip.GetTriangle();
if(!pTri) return;
const auto& bz = pTri->GetBZ3D();
if(!bz.IsValid())
{
QMessageBox::critical(this, "Error", "3D Brillouin zone calculation is disabled or results are invalid.");
return;
}
std::ofstream ofstr(strFile.toStdString());
ofstr.precision(g_iPrec);
ofstr << "# Brillouin zone cut vertices.\n";
ofstr << "# Created with Takin " + std::string(TAKIN_VER) + ".\n";
ofstr << "\n";
const std::vector<ublas::vector<t_real>>& verts = pTri->GetBZ3DPlaneVerts();
for(ublas::vector<t_real> vert : verts)
{
if(vert.size() < 2)
{
tl::log_err("Invalid vertex in Brillouin zone cut.");
continue;
}
tl::set_eps_0(vert, g_dEps);
for(int coordidx=0; coordidx<2; ++coordidx)
ofstr << std::setw(g_iPrec*2.5) << std::left << vert[coordidx] << " ";
ofstr << "\n";
}
ofstr.flush();
std::string strDir = tl::get_dir(strFile.toStdString());
m_settings.setValue("main/last_dir_export", QString(strDir.c_str()));
}
/**
* export the 3d BZ as 3D model
*/
......@@ -129,7 +190,7 @@ void TazDlg::ExportBZ3DModel()
strFile += ".x3d";
ScatteringTriangle *pTri = m_sceneRecip.GetTriangle();
const ScatteringTriangle *pTri = m_sceneRecip.GetTriangle();
if(!pTri) return;
const auto& bz = pTri->GetBZ3D();
......@@ -208,7 +269,6 @@ void TazDlg::ExportBZ3DModel()
//--------------------------------------------------------------------------------
// 3d model exports
......
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