BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
CoordName.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Util/CoordName.cpp
6 //! @brief Implements namespace GUI::Util::CoordName
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #include "GUI/Util/CoordName.h"
16 #include <map>
17 
18 namespace {
19 
20 const std::map<QString, Coords> units_from_names{{"nbins", Coords::NBINS},
21  {"Radians", Coords::RADIANS},
22  {"Degrees", Coords::DEGREES},
23  {"mm", Coords::MM},
24  {"q-space", Coords::QSPACE}};
25 
26 const std::map<Coords, QString> names_from_coords{{Coords::NBINS, "nbins"},
27  {Coords::RADIANS, "Radians"},
28  {Coords::MM, "mm"},
29  {Coords::QSPACE, "q-space"},
30  {Coords::DEGREES, "Degrees"}};
31 
32 } // namespace
33 
34 //! Correspondence of domain detector axes types to their GUI counterpart.
35 
37 {
38  const auto it = names_from_coords.find(units);
39  if (it == names_from_coords.end())
40  return "";
41  return it->second;
42 }
43 
44 //! Correspondence of GUI axes units names to their domain counterpart.
45 
47 {
48  return units_from_names.at(name);
49 }
Defines namespace GUI::Util::CoordName.
QString const & name(EShape k)
Definition: particles.cpp:20
Coords coordFromName(const QString &name)
Returns domain axes units type from their GUI name.
Definition: CoordName.cpp:46
QString nameFromCoord(Coords units)
Returns axes units names from their domain counterpart.
Definition: CoordName.cpp:36