Skip to content
Snippets Groups Projects
Commit b7e8d503 authored by Mikhail Svechnikov's avatar Mikhail Svechnikov Committed by Wuttke, Joachim
Browse files

specular case

parent f0c9495e
No related branches found
No related tags found
No related merge requests found
...@@ -124,6 +124,6 @@ void AmplitudeAxisItem::setLogRangeOrders(double v) ...@@ -124,6 +124,6 @@ void AmplitudeAxisItem::setLogRangeOrders(double v)
void AmplitudeAxisItem::adjustLogRangeOrders() void AmplitudeAxisItem::adjustLogRangeOrders()
{ {
if (min() > 0) if (min() > 0 && max() > 0)
m_logRangeOrders = std::log10(max() / min()); m_logRangeOrders = std::log10(max() / min());
} }
...@@ -291,12 +291,16 @@ QPair<double, double> SpecularDataItem::dataRange() const ...@@ -291,12 +291,16 @@ QPair<double, double> SpecularDataItem::dataRange() const
const auto vec = data->flatVector(); const auto vec = data->flatVector();
double min(*std::min_element(vec.cbegin(), vec.cend())); double min(*std::min_element(vec.cbegin(), vec.cend()));
min = std::numeric_limits<double>::epsilon() < min ? min : default_min;
double max(*std::max_element(vec.cbegin(), vec.cend())); double max(*std::max_element(vec.cbegin(), vec.cend()));
max *= 1.1;
min /= 2.0; double logRange = pow(10, yAxisItem()->logRangeOrders());
min = std::numeric_limits<double>::epsilon() < min ? min : default_min; if (isLog())
max *= 2.0; min = std::max(min, max / logRange);
max = max > min ? max : default_max; else
min /= 2.0;
return QPair<double, double>(min, max); return QPair<double, double>(min, max);
} }
......
...@@ -90,12 +90,26 @@ void SpecularDataPropertyWidget::createPanelElements() ...@@ -90,12 +90,26 @@ void SpecularDataPropertyWidget::createPanelElements()
yFormLayout->setContentsMargins(0, 0, 0, 0); yFormLayout->setContentsMargins(0, 0, 0, 0);
yFormLayout->setSpacing(5); yFormLayout->setSpacing(5);
auto* logRangeSpinbox = GUI::Util::createDoubleSpinbox(
[this] { return currentSpecularDataItem()->yAxisItem()->logRangeOrders(); },
[this](double newValue) {
for (auto item : mainSpecularDataItems()) {
item->yAxisItem()->setLogRangeOrders(newValue);
updateUIValues();
}
gProjectDocument.value()->setModified();
},
&m_updaters, "Dynamic range to display values", RealLimits::positive());
yFormLayout->addRow("Min:", yFormLayout->addRow("Min:",
GUI::Util::createDoubleSpinbox( GUI::Util::createDoubleSpinbox(
[this] { return currentSpecularDataItem()->yAxisItem()->min(); }, [this] { return currentSpecularDataItem()->yAxisItem()->min(); },
[this](double newValue) { [this](double newValue) {
for (auto item : mainSpecularDataItems()) for (auto item : mainSpecularDataItems()) {
item->yAxisItem()->setMin(newValue); item->yAxisItem()->setMin(newValue);
item->yAxisItem()->adjustLogRangeOrders();
updateUIValues();
}
gProjectDocument.value()->setModified(); gProjectDocument.value()->setModified();
}, },
&m_updaters)); &m_updaters));
...@@ -104,21 +118,27 @@ void SpecularDataPropertyWidget::createPanelElements() ...@@ -104,21 +118,27 @@ void SpecularDataPropertyWidget::createPanelElements()
GUI::Util::createDoubleSpinbox( GUI::Util::createDoubleSpinbox(
[this] { return currentSpecularDataItem()->yAxisItem()->max(); }, [this] { return currentSpecularDataItem()->yAxisItem()->max(); },
[this](double newValue) { [this](double newValue) {
for (auto item : mainSpecularDataItems()) for (auto item : mainSpecularDataItems()) {
item->yAxisItem()->setMax(newValue); item->yAxisItem()->setMax(newValue);
item->yAxisItem()->adjustLogRangeOrders();
updateUIValues();
}
gProjectDocument.value()->setModified(); gProjectDocument.value()->setModified();
}, },
&m_updaters)); &m_updaters));
yFormLayout->addRow(GUI::Util::createCheckBox( yFormLayout->addRow(GUI::Util::createCheckBox(
"log10", [this] { return currentSpecularDataItem()->yAxisItem()->isLogScale(); }, "log10", [this] { return currentSpecularDataItem()->yAxisItem()->isLogScale(); },
[this](bool b) { [this, logRangeSpinbox](bool b) {
logRangeSpinbox->setEnabled(b);
for (auto item : allSpecularDataItems()) for (auto item : allSpecularDataItems())
item->yAxisItem()->setLogScale(b); item->yAxisItem()->setLogScale(b);
gProjectDocument.value()->setModified(); gProjectDocument.value()->setModified();
}, },
&m_updaters)); &m_updaters));
yFormLayout->addRow("Log range:", logRangeSpinbox);
m_mainLayout->addRow(yGroup); m_mainLayout->addRow(yGroup);
updateUIValues(); updateUIValues();
......
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