Skip to content

Commit

Permalink
Fixed quant widget display issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Glowacki committed Sep 27, 2023
1 parent 67f466a commit f18789d
Showing 1 changed file with 44 additions and 29 deletions.
73 changes: 44 additions & 29 deletions src/mvc/QuantificationWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void QuantificationWidget::_createLayout()

_axisY = new QValueAxis();
_axisY->setTitleText("Energy Calibration");
_axisY->setLabelFormat("%i");
//_axisY->setLabelFormat("%i");
//_axisY->setTickCount(series->count());

_calib_curve_series_k = new QLineSeries();
Expand All @@ -70,22 +70,15 @@ void QuantificationWidget::_createLayout()

if (_display_log10)
{
// ymax = _axisYLog10->max();
// ymin = _axisYLog10->min();
_currentYAxis = _axisYLog10;
}
else
{
// ymax = _axisY->max();
// ymin = _axisY->min();
_currentYAxis = _axisY;
}

_chart->addAxis(_currentYAxis, Qt::AlignLeft);
//_chart->addAxis(_axisY, Qt::AlignLeft);
//_chart->addAxis(_axisYLog10, Qt::AlignLeft);


_chart->addSeries(_calib_curve_series_k);
_calib_curve_series_k->attachAxis(_axisX);
_calib_curve_series_k->attachAxis(_currentYAxis);
Expand Down Expand Up @@ -175,38 +168,47 @@ void QuantificationWidget::update(const QString& val)
if (_calib_curve->calib_curve.count(data_struct::Element_Symbols[i + 1]) > 0)
{
kval = _calib_curve->calib_curve.at(data_struct::Element_Symbols[i + 1]);
if (false == std::isfinite(kval) || kval <= 0.0)
if (_display_log10)
{
kval = 1.0e-1;
if (false == std::isfinite(kval) || kval <= 0.0)
{
kval = 1.0e-1;
}
}
//max_val = std::max(max_val, kval);
//min_val = std::min(min_val, kval);
max_val = std::max(max_val, kval);
min_val = std::min(min_val, kval);
}
_calib_curve_series_k->append(i, kval);
_calib_curve_series_k->append(i + 1, kval);

if (_calib_curve->calib_curve.count(data_struct::Element_Symbols[i + 1] + "_L") > 0)
{
lval = _calib_curve->calib_curve.at(data_struct::Element_Symbols[i + 1] + "_L");
if (false == std::isfinite(lval) || lval <= 0.0)
if (_display_log10)
{
lval = 1.0e-1;
if (false == std::isfinite(lval) || lval <= 0.0)
{
lval = 1.0e-1;
}
}
//max_val = std::max(max_val, lval);
//min_val = std::min(min_val, lval);
max_val = std::max(max_val, lval);
min_val = std::min(min_val, lval);
}
_calib_curve_series_l->append(i, lval);
_calib_curve_series_l->append(i + 1, lval);

if (_calib_curve->calib_curve.count(data_struct::Element_Symbols[i + 1] + "_M") > 0)
{
mval = _calib_curve->calib_curve.at(data_struct::Element_Symbols[i + 1] + "_M");
if (false == std::isfinite(mval) || mval <= 0.0)
if (_display_log10)
{
mval = 1.0e-1;
if (false == std::isfinite(mval) || mval <= 0.0)
{
mval = 1.0e-1;
}
}
//max_val = std::max(max_val, mval);
//min_val = std::min(min_val, mval);
max_val = std::max(max_val, mval);
min_val = std::min(min_val, mval);
}
_calib_curve_series_m->append(i, mval);
_calib_curve_series_m->append(i + 1, mval);
Expand All @@ -224,13 +226,23 @@ void QuantificationWidget::update(const QString& val)
_calib_curve_series_m->attachAxis(_axisX);
_calib_curve_series_m->attachAxis(_currentYAxis);

//double ymax = _axisY->max();
//double ymin = _axisY->min();
//_axisY->setRange(0.0, max_val);
//_axisYLog10->setRange(min_val, max_val);
// _axisYLog10->setRange(1.0e-2, max_val);
/*
double ymax;
double ymin;
if (_display_log10)
{
ymax = _axisYLog10->max();
ymin = _axisYLog10->min();
}
else
{
ymax = _axisY->max();
ymin = _axisY->min();
}
*/
double diff = (max_val - min_val) / 10.0;
_currentYAxis->setRange(min_val, max_val+ diff);
_axisX->setRange(10, 80);
//_calib_curve_series->attachAxis(_currentYAxis);
}
else
{
Expand All @@ -240,9 +252,9 @@ void QuantificationWidget::update(const QString& val)

foreach(QScatterSeries * sitr, _scatter_list)
{
_chart->removeSeries(sitr);
sitr->detachAxis(_axisX);
sitr->detachAxis(_currentYAxis);
_chart->removeSeries(sitr);
delete sitr;
}
_scatter_list.clear();
Expand All @@ -257,9 +269,12 @@ void QuantificationWidget::update(const QString& val)
{
double val = itr.second->e_cal_ratio;
//val = log10(val);
if (false == std::isfinite(val) || val <= 0.0)
if (_display_log10)
{
val = 0.1;
if (false == std::isfinite(val) || val <= 0.0)
{
val = 0.1;
}
}
scatter_series->append((itr.second->Z-0.5), val);
max_z = std::max(itr.second->Z, max_z);
Expand Down

0 comments on commit f18789d

Please sign in to comment.