BornAgain
1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
Unit.h
Go to the documentation of this file.
1
// ************************************************************************************************
2
//
3
// BornAgain: simulate and fit reflection and scattering
4
//
5
//! @file GUI/Support/Type/Unit.h
6
//! @brief Defines class Unit
7
//!
8
//! @homepage http://www.bornagainproject.org
9
//! @license GNU General Public License v3 or higher (see COPYING)
10
//! @copyright Forschungszentrum Jülich GmbH 2021
11
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12
//
13
// ************************************************************************************************
14
15
#ifndef BORNAGAIN_GUI_SUPPORT_TYPE_UNIT_H
16
#define BORNAGAIN_GUI_SUPPORT_TYPE_UNIT_H
17
18
class
QString;
19
20
//! Defines units, mainly to be able to convert between units.
21
//!
22
//! E.g. internal unit is nanometer, displayed unit is angstrom.
23
//! Units which do not support conversion do not have to be
24
//! part of the enum, since the relevant code parts support defining a
25
//! unit via enum or via string
26
enum class
Unit
{
27
unitless
,
28
nanometer
,
29
nanometer2
,
30
nanometerMinus2
,
31
angstrom
,
32
angstrom2
,
33
angstromMinus2
,
34
degree
,
35
radiant
,
36
other
//!< The unit has no enum value defined in here (e.g. when defined as an explicit string)
37
};
38
39
//! Convert the given value d from unit "from" to unit "to"
40
//! Throws an exception if no conversion possible.
41
double
convert
(
double
d,
Unit
from,
Unit
to);
42
43
//! Returns the string for the given unit
44
QString
unitAsString
(
const
Unit
& unit);
45
46
#endif
// BORNAGAIN_GUI_SUPPORT_TYPE_UNIT_H
unitAsString
QString unitAsString(const Unit &unit)
Returns the string for the given unit.
Definition:
Unit.cpp:58
Unit
Unit
Defines units, mainly to be able to convert between units.
Definition:
Unit.h:26
Unit::nanometerMinus2
@ nanometerMinus2
Unit::angstrom
@ angstrom
Unit::other
@ other
The unit has no enum value defined in here (e.g. when defined as an explicit string)
Unit::nanometer2
@ nanometer2
Unit::angstrom2
@ angstrom2
Unit::radiant
@ radiant
Unit::angstromMinus2
@ angstromMinus2
Unit::unitless
@ unitless
Unit::nanometer
@ nanometer
Unit::degree
@ degree
convert
double convert(double d, Unit from, Unit to)
Convert the given value d from unit "from" to unit "to" Throws an exception if no conversion possible...
Definition:
Unit.cpp:20
GUI
Support
Type
Unit.h
Generated by
1.9.1