Skip to content
Snippets Groups Projects
Commit fcd4d5e9 authored by Mikhail Svechnikov's avatar Mikhail Svechnikov
Browse files

cleanup AxesPanels

parent de5a8e4c
No related branches found
No related tags found
1 merge request!2864Update mask DoubleProperties to set MaskPanel spinboxes properly (#1093)
Pipeline #187465 passed
......@@ -165,34 +165,28 @@ void AxesPanel::updatePanel()
void AxesPanel::updateAxesProperties()
{
double step_factor = 0.005;
ASSERT(d2Item());
const double step_factor = 0.005;
const int start_decimals = 4;
// x axis
const double x_range =
std::abs(d2Item()->axItemX()->max().dVal() - d2Item()->axItemX()->min().dVal());
auto* aX = d2Item()->axItemX();
const double x_range = std::abs(aX->max().dVal() - aX->min().dVal());
const int x_decimals = start_decimals - Numeric::orderOfMagnitude(x_range);
const double x_step = x_range * step_factor;
d2Item()->axItemX()->min().setUseFixedStep(true);
d2Item()->axItemX()->min().setStep(x_range * step_factor);
d2Item()->axItemX()->min().setDecimals(x_decimals);
d2Item()->axItemX()->max().setUseFixedStep(true);
d2Item()->axItemX()->max().setStep(x_range * step_factor);
d2Item()->axItemX()->max().setDecimals(x_decimals);
aX->min().setStepAndDecimals(true, x_step, x_decimals);
aX->max().setStepAndDecimals(true, x_step, x_decimals);
// y axis
const double y_range =
std::abs(d2Item()->axItemY()->max().dVal() - d2Item()->axItemY()->min().dVal());
auto* aY = d2Item()->axItemY();
const double y_range = std::abs(aY->max().dVal() - aY->min().dVal());
const int y_decimals = start_decimals - Numeric::orderOfMagnitude(y_range);
const double y_step = y_range * step_factor;
d2Item()->axItemY()->min().setUseFixedStep(true);
d2Item()->axItemY()->min().setStep(y_range * step_factor);
d2Item()->axItemY()->min().setDecimals(y_decimals);
d2Item()->axItemY()->max().setUseFixedStep(true);
d2Item()->axItemY()->max().setStep(y_range * step_factor);
d2Item()->axItemY()->max().setDecimals(y_decimals);
aY->min().setStepAndDecimals(true, y_step, y_decimals);
aY->max().setStepAndDecimals(true, y_step, y_decimals);
}
// ************************************************************************************************
......
......@@ -129,21 +129,19 @@ void AxisPanel::updatePanel()
void AxisPanel::updateAxesProperties()
{
double step_factor = 0.005;
ASSERT(d1Item());
const double step_factor = 0.005;
const int start_decimals = 4;
// x axis
const double x_range =
std::abs(d1Item()->axItemX()->max().dVal() - d1Item()->axItemX()->min().dVal());
auto* aX = d1Item()->axItemX();
const double x_range = std::abs(aX->max().dVal() - aX->min().dVal());
const int x_decimals = start_decimals - Numeric::orderOfMagnitude(x_range);
const double x_step = x_range * step_factor;
d1Item()->axItemX()->min().setUseFixedStep(true);
d1Item()->axItemX()->min().setStep(x_range * step_factor);
d1Item()->axItemX()->min().setDecimals(x_decimals);
d1Item()->axItemX()->max().setUseFixedStep(true);
d1Item()->axItemX()->max().setStep(x_range * step_factor);
d1Item()->axItemX()->max().setDecimals(x_decimals);
aX->min().setStepAndDecimals(true, x_step, x_decimals);
aX->max().setStepAndDecimals(true, x_step, x_decimals);
}
// ************************************************************************************************
......
......@@ -179,13 +179,13 @@ void MasksPanel::updateMaskPresentationProperties(MaskItem* t)
const int start_decimals = 4;
// x axis
auto* aX = data2D->axItemX();
const auto* aX = data2D->axItemX();
const double x_range = std::abs(aX->max().dVal() - aX->min().dVal());
const int x_decimals = start_decimals - Numeric::orderOfMagnitude(x_range);
const double x_step = x_range * step_factor;
// y axis
auto* aY = data2D->axItemY();
const auto* aY = data2D->axItemY();
const double y_range = std::abs(aY->max().dVal() - aY->min().dVal());
const int y_decimals = start_decimals - Numeric::orderOfMagnitude(y_range);
const double y_step = y_range * step_factor;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment