BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
customplotutils.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // qt-mvvm: Model-view-view-model framework for large GUI applications
4 //
5 //! @file mvvm/view/mvvm/plotting/customplotutils.cpp
6 //! @brief Implements class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Gennady Pospelov et al, Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 #include <qcustomplot.h>
17 
18 void ModelView::Utils::SetLogarithmicScale(QCPColorScale* axis, bool is_log_scale)
19 {
20  if (is_log_scale && axis->dataScaleType() != QCPAxis::stLogarithmic)
21  axis->setDataScaleType(QCPAxis::stLogarithmic);
22 
23  else if (!is_log_scale && axis->dataScaleType() != QCPAxis::stLinear)
24  axis->setDataScaleType(QCPAxis::stLinear);
25 
26  SetLogarithmicScale(axis->axis(), is_log_scale);
27 }
28 
29 void ModelView::Utils::SetLogarithmicScale(QCPAxis* axis, bool is_log_scale)
30 {
31  if (is_log_scale) {
32  axis->setNumberFormat("eb");
33  axis->setNumberPrecision(0);
34  axis->setScaleType(QCPAxis::stLogarithmic);
35  QSharedPointer<QCPAxisTicker> ticker(new QCPAxisTickerLog);
36  axis->setTicker(ticker);
37  } else {
38  axis->setNumberFormat("g");
39  axis->setNumberPrecision(6);
40  axis->setScaleType(QCPAxis::stLinear);
41  QSharedPointer<QCPAxisTicker> ticker(new QCPAxisTicker);
42  axis->setTicker(ticker);
43  }
44 }
Defines class CLASS?
MVVM_VIEW_EXPORT void SetLogarithmicScale(QCPColorScale *axis, bool is_log_scale)
Switch axis to logarithmic scale mode.