Verified Commit 7e324d3f authored by Tobias WEBER's avatar Tobias WEBER
Browse files

cleanups

parent 52106108
This diff is collapsed.
......@@ -127,7 +127,7 @@ protected:
bool DoesDirectPathCollide(const t_vec2& vert1, const t_vec2& vert2, bool deg = false) const;
// get the angular distance of a vertex to the nearest wall
t_real GetDistToNearestWall(const t_vec2& vertex, bool deg = false) const;
t_real GetDistToNearestWall(const t_vec2& vertex) const;
// find the closest point on a path segment
std::tuple<t_real, t_real, int>
......
......@@ -495,46 +495,15 @@ ConfigSpaceDlg::ConfigSpaceDlg(QWidget* parent, QSettings *sett)
// connections
// ------------------------------------------------------------------------
// mouse button down
connect(m_plot.get(), &QCustomPlot::mousePress,
[this](QMouseEvent* evt)
// mouse event handler
auto mouse_event = [this](QMouseEvent* evt, bool mouse_move)
{
if(!this->m_plot || !m_moveInstr)
if(!this->m_plot || !evt)
return;
const t_real _a4 = this->m_plot->xAxis->pixelToCoord(evt->pos().x());
const t_real _a2 = this->m_plot->yAxis->pixelToCoord(evt->pos().y());
std::optional<t_real> a1 = _a2 * t_real(0.5) / t_real(180) * tl2::pi<t_real>;
std::optional<t_real> a4 = _a4 / t_real(180) * tl2::pi<t_real>;
bool kf_fixed = true;
if(m_pathsbuilder && m_pathsbuilder->GetTasCalculator())
{
// move monochromator if kf=fixed and analyser otherwise
if(!std::get<1>(m_pathsbuilder->GetTasCalculator()->GetKfix()))
kf_fixed = false;
}
// move instrument
if(kf_fixed)
this->EmitGotoAngles(a1, std::nullopt, a4, std::nullopt);
else
this->EmitGotoAngles(std::nullopt, std::nullopt, a4, a1);
});
// mouse move
connect(m_plot.get(), &QCustomPlot::mouseMove,
[this](QMouseEvent* evt)
{
if(!this->m_plot)
return;
const int x = evt->pos().x();
const int y = evt->pos().y();
const t_real _a4 = this->m_plot->xAxis->pixelToCoord(x);
const t_real _a2 = this->m_plot->yAxis->pixelToCoord(y);
bool kf_fixed = true;
if(m_pathsbuilder && m_pathsbuilder->GetTasCalculator())
{
......@@ -555,26 +524,37 @@ ConfigSpaceDlg::ConfigSpaceDlg(QWidget* parent, QSettings *sett)
this->EmitGotoAngles(std::nullopt, std::nullopt, a4, a1);
}
// set status
std::ostringstream ostr;
ostr.precision(g_prec_gui);
if(mouse_move && m_status)
{
// set status
std::ostringstream ostr;
ostr.precision(g_prec_gui);
// show angular coordinates
ostr << "2θ_S = " << _a4 << " deg";
if(kf_fixed)
ostr << ", 2θ_M = " << _a2 << " deg.";
else
ostr << ", 2θ_A = " << _a2 << " deg.";
// show angular coordinates
ostr << "2θ_S = " << _a4 << " deg";
if(kf_fixed)
ostr << ", 2θ_M = " << _a2 << " deg.";
else
ostr << ", 2θ_A = " << _a2 << " deg.";
// show pixel coordinates
if(m_pathsbuilder)
{
t_vec2 pix = m_pathsbuilder->AngleToPixel(_a4, _a2);
ostr <<" Pixel: (" << (int)pix[0] << ", " << (int)pix[1] << ").";
// show pixel coordinates
if(m_pathsbuilder)
{
t_vec2 pix = m_pathsbuilder->AngleToPixel(_a4, _a2);
ostr <<" Pixel: (" << (int)pix[0] << ", " << (int)pix[1] << ").";
}
m_status->setText(ostr.str().c_str());
}
};
m_status->setText(ostr.str().c_str());
});
// mouse button down
connect(m_plot.get(), &QCustomPlot::mousePress,
[mouse_event](QMouseEvent* evt) { mouse_event(evt, false); });
// mouse move
connect(m_plot.get(), &QCustomPlot::mouseMove,
[mouse_event](QMouseEvent* evt) { mouse_event(evt, true); });
// path mesh options
......
......@@ -629,9 +629,17 @@ void PathsTool::GotoCoordinates(
const t_real *sensesCCW = m_tascalc.GetScatteringSenses();
t_real a2_abs = angles.monoXtalAngle * 2. * sensesCCW[0];
t_real a4_abs = angles.sampleScatteringAngle * sensesCCW[1];
t_real a6_abs = angles.anaXtalAngle * 2. * sensesCCW[2];
// is kf or ki fixed?
bool kf_fixed = true;
if(!std::get<1>(m_tascalc.GetKfix()))
kf_fixed = false;
t_real _a2_or_a6 = kf_fixed ? a2_abs : a6_abs;
pathwidget->SetTarget(
a2_abs / tl2::pi<t_real> * 180.,
_a2_or_a6 / tl2::pi<t_real> * 180.,
a4_abs / tl2::pi<t_real> * 180.);
}
......@@ -693,11 +701,11 @@ void PathsTool::GotoAngles(std::optional<t_real> a1,
kf_fixed = false;
// move either monochromator or analyser depending if kf=fixed
t_real _a2 = kf_fixed ? *a1 * 2. : *a5 * 2.;
t_real _a2_or_a6 = kf_fixed ? *a1 * 2. : *a5 * 2.;
t_real _a4 = *a4;
pathwidget->SetTarget(
_a2 / tl2::pi<t_real> * 180.,
_a2_or_a6 / tl2::pi<t_real> * 180.,
_a4 / tl2::pi<t_real> * 180.);
}
......@@ -1200,7 +1208,12 @@ PathsTool::PathsTool(QWidget* pParent) : QMainWindow{pParent}
//std::cout << "target angles: " << a2 << ", " << a4 << std::endl;
const t_real *sensesCCW = m_tascalc.GetScatteringSenses();
a2 = a2 / 180. * tl2::pi<t_real> * sensesCCW[0];
bool kf_fixed = true;
if(!std::get<1>(m_tascalc.GetKfix()))
kf_fixed = false;
t_real sense_mono_or_ana = kf_fixed ? sensesCCW[0] : sensesCCW[2];
a2 = a2 / 180. * tl2::pi<t_real> * sense_mono_or_ana;
a4 = a4 / 180. * tl2::pi<t_real> * sensesCCW[1];
m_targetMonoScatteringAngle = a2;
......@@ -2222,9 +2235,15 @@ void PathsTool::CalculatePath()
// adjust scattering senses
const t_real* sensesCCW = m_tascalc.GetScatteringSenses();
curMonoScatteringAngle *= sensesCCW[0];
bool kf_fixed = true;
if(!std::get<1>(m_tascalc.GetKfix()))
kf_fixed = false;
t_real sense_mono_or_ana = kf_fixed ? sensesCCW[0] : sensesCCW[2];
curMonoScatteringAngle *= sense_mono_or_ana;
curSampleScatteringAngle *= sensesCCW[1];
t_real targetMonoScatteringAngle = m_targetMonoScatteringAngle * sensesCCW[0];
t_real targetMonoScatteringAngle = m_targetMonoScatteringAngle * sense_mono_or_ana;
t_real targetSampleScatteringAngle = m_targetSampleScatteringAngle * sensesCCW[1];
// path options
......
......@@ -79,6 +79,7 @@ PathPropertiesWidget::PathPropertiesWidget(QWidget *parent)
SetGoButtonText(true);
m_btnGo->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
// TODO: change the label "monochromator" to "analyser" for ki=const mode
const char* labels[] = {"Monochromator:", "Sample:"};
auto *groupFinish = new QGroupBox("Target Scattering Angles", this);
......
......@@ -397,8 +397,8 @@ bool TASPropertiesWidget::Load(const boost::property_tree::ptree& prop)
// old scattering senses
bool scM = m_checkScatteringSense[0]->isChecked();
bool scS = m_checkScatteringSense[0]->isChecked();
bool scA = m_checkScatteringSense[0]->isChecked();
bool scS = m_checkScatteringSense[1]->isChecked();
bool scA = m_checkScatteringSense[2]->isChecked();
// old d spacings
t_real dM = m_spinMonoD->value();
......
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