Commit 72fa47a1 authored by Tobias WEBER's avatar Tobias WEBER
Browse files

continued with magnetic structure factors

parent 4abc52a4
......@@ -336,6 +336,21 @@ void GlPlot_impl::SetObjectLabel(std::size_t idx, const std::string& label)
}
void GlPlot_impl::SetObjectDataString(std::size_t idx, const std::string& data)
{
if(idx >= m_objs.size()) return;
m_objs[idx].m_datastr = data;
}
const std::string& GlPlot_impl::GetObjectDataString(std::size_t idx) const
{
static const std::string empty{};
if(idx >= m_objs.size()) return empty;
return m_objs[idx].m_datastr;
}
void GlPlot_impl::SetObjectVisible(std::size_t idx, bool visible)
{
if(idx >= m_objs.size()) return;
......
......@@ -65,6 +65,7 @@ extern void set_gl_format(bool bCore=true, int iMajorVer=3, int iMinorVer=3, int
// ----------------------------------------------------------------------------
// types
using t_real_gl = GLfloat;
//using t_real_gl = GLdouble;
using t_vec3_gl = m::qvecN_adapter<int, 3, t_real_gl, QVector3D>;
using t_vec_gl = m::qvecN_adapter<int, 4, t_real_gl, QVector4D>;
using t_mat_gl = m::qmatNN_adapter<int, 4, 4, t_real_gl, QMatrix4x4>;
......@@ -108,6 +109,7 @@ struct GlPlotObj
t_vec3_gl m_labelPos = m::create<t_vec3_gl>({0., 0., 0.});
std::string m_label;
std::string m_datastr;
};
// ----------------------------------------------------------------------------
......@@ -239,7 +241,9 @@ public:
void SetObjectMatrix(std::size_t idx, const t_mat_gl& mat);
void SetObjectCol(std::size_t idx, t_real_gl r, t_real_gl g, t_real_gl b, t_real_gl a=1);
void SetObjectLabel(std::size_t idx, const std::string& label);
void SetObjectDataString(std::size_t idx, const std::string& data);
void SetObjectVisible(std::size_t idx, bool visible);
const std::string& GetObjectDataString(std::size_t idx) const;
void SetScreenDims(int w, int h);
void SetCoordMax(t_real_gl d) { m_CoordMax = d; }
......
......@@ -604,7 +604,7 @@ MagStructFactDlg::MagStructFactDlg(QWidget* pParent) : QDialog{pParent},
auto labCoordSys = new QLabel("Coordinate System:", /*m_dlgPlotSC*/ this);
auto comboCoordSys = new QComboBox(/*m_dlgPlotSC*/ this);
m_status3D = new QLabel(/*m_dlgPlotSC*/ this);
m_status3DSC = new QLabel(/*m_dlgPlotSC*/ this);
comboCoordSys->addItem("Fractional Units (rlu)");
comboCoordSys->addItem("Lab Units (A)");
......@@ -619,11 +619,11 @@ MagStructFactDlg::MagStructFactDlg(QWidget* pParent) : QDialog{pParent},
grid->addWidget(m_plotSC.get(), 0,0,1,2);
grid->addWidget(labCoordSys, 1,0,1,1);
grid->addWidget(comboCoordSys, 1,1,1,1);
grid->addWidget(m_status3D, 2,0,1,2);
grid->addWidget(m_status3DSC, 2,0,1,2);
connect(m_plotSC.get(), &GlPlot::AfterGLInitialisation, this, &MagStructFactDlg::AfterGLInitialisationSC);
//connect(m_plotSC->GetImpl(), &GlPlot_impl::PickerIntersection, this, &MagStructFactDlg::PickerIntersectionSC);
connect(m_plotSC->GetImpl(), &GlPlot_impl::PickerIntersection, this, &MagStructFactDlg::PickerIntersectionSC);
//connect(m_plotSC.get(), &GlPlot::MouseDown, this, [this](bool left, bool mid, bool right) {});
//connect(m_plotSC.get(), &GlPlot::MouseUp, this, [this](bool left, bool mid, bool right) {});
connect(comboCoordSys, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [this](int val)
......@@ -1946,10 +1946,22 @@ void MagStructFactDlg::Calc()
posGL // pre-translate
);
// labels
std::ostringstream ostrMom;
ostrMom.precision(g_prec);
ostrMom
<< "Re{M} = (" << moment[0].real() << " " << moment[1].real() << " " << moment[2].real() << "); "
<< "Im{M} = (" << moment[0].imag() << " " << moment[1].imag() << " " << moment[2].imag() << "); "
<< "r = (" << thepos[0] << " " << thepos[1] << " " << thepos[2] << ")";
m_plotSC->GetImpl()->SetObjectMatrix(objArrowRe, matArrowRe);
m_plotSC->GetImpl()->SetObjectMatrix(objArrowIm, matArrowIm);
m_plotSC->GetImpl()->SetObjectCol(objArrowRe, r, g, b, 1.);
m_plotSC->GetImpl()->SetObjectCol(objArrowIm, 1.-r, 1.-g, 1.-b, 1.);
//m_plotSC->GetImpl()->SetObjectLabel(objArrowRe, name + " (real)");
//m_plotSC->GetImpl()->SetObjectLabel(objArrowIm, name + " (imag)");
m_plotSC->GetImpl()->SetObjectDataString(objArrowRe, name + " (real); " + ostrMom.str());
m_plotSC->GetImpl()->SetObjectDataString(objArrowIm, name + " (imag); " + ostrMom.str());
m_plotSC->GetImpl()->SetObjectVisible(objArrowRe, !m::equals<t_real_gl>(normReM, 0, g_eps));
m_plotSC->GetImpl()->SetObjectVisible(objArrowIm, !m::equals<t_real_gl>(normImM, 0, g_eps));
......@@ -1992,7 +2004,7 @@ void MagStructFactDlg::Calc()
*/
void MagStructFactDlg::PickerIntersection(const t_vec3_gl* pos, std::size_t objIdx, const t_vec3_gl* posSphere)
{
if(pos)
if(pos && m_plot)
m_curPickedObj = long(objIdx);
else
m_curPickedObj = -1;
......@@ -2034,6 +2046,21 @@ void MagStructFactDlg::PickerIntersection(const t_vec3_gl* pos, std::size_t objI
}
/**
* mouse hovers over 3d object in super cell view
*/
void MagStructFactDlg::PickerIntersectionSC(const t_vec3_gl* pos, std::size_t objIdx, const t_vec3_gl* posSphere)
{
if(pos && m_plotSC)
{
const std::string& str = m_plotSC->GetImpl()->GetObjectDataString(objIdx);
m_status3DSC->setText(str.c_str());
}
else
m_status3DSC->setText("");
}
/**
* mouse button pressed
*/
......
......@@ -69,15 +69,16 @@ protected:
std::shared_ptr<GlPlot> m_plot;
std::size_t m_sphere = 0;
std::size_t m_arrow = 0;
QLabel *m_status3D = nullptr;
// super cell view
QDialog *m_dlgPlotSC = nullptr;
std::shared_ptr<GlPlot> m_plotSC;
std::size_t m_sphereSC = 0;
std::size_t m_arrowSC = 0;
QLabel *m_status3DSC = nullptr;
QLabel *m_labelGlInfos[4] = { nullptr, nullptr, nullptr, nullptr };
QLabel *m_status3D = nullptr;
QWidget *m_nucleipanel = nullptr;
QWidget *m_propvecpanel = nullptr;
......@@ -142,6 +143,7 @@ protected:
void PlotMouseDown(bool left, bool mid, bool right);
void PickerIntersection(const t_vec3_gl* pos, std::size_t objIdx, const t_vec3_gl* posSphere);
void PickerIntersectionSC(const t_vec3_gl* pos, std::size_t objIdx, const t_vec3_gl* posSphere);
void AfterGLInitialisation();
void AfterGLInitialisationSC();
......
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