]> Shamusworld >> Repos - architektonas/blob - src/base/units.h
Initial removal of unnecessary rs_ prefixes from files.
[architektonas] / src / base / units.h
1 #ifndef __UNITS_H__
2 #define __UNITS_H__
3
4 #include <QtCore>
5 #include "rs.h"
6 #include "vector.h"
7
8 /**
9  * Conversion methods for units
10  *
11  * @author Andrew Mustun
12  */
13 class RS_Units
14 {
15         public:
16                 //static char* unit2sign(RS2::Unit unit);
17
18                 //static RS2::Unit string2unit(const char* str, bool* ok=0);
19                 //static char* unit2string(RS2::Unit unit);
20
21                 static RS2::Unit dxfint2unit(int dxfint);
22
23                 static QString unitToString(RS2::Unit u, bool t = true);
24                 static RS2::Unit stringToUnit(const QString & u);
25
26                 static bool isMetric(RS2::Unit u);
27                 static double getFactorToMM(RS2::Unit u);
28                 static double convert(double val, RS2::Unit src, RS2::Unit dest);
29                 static Vector convert(const Vector val, RS2::Unit src, RS2::Unit dest);
30
31                 static QString unitToSign(RS2::Unit u);
32
33                 static QString formatLinear(double length, RS2::Unit unit,
34                         RS2::LinearFormat format, int prec, bool showUnit = false);
35                 static QString formatScientific(double length, RS2::Unit unit, int prec, bool showUnit = false);
36                 static QString formatDecimal(double length, RS2::Unit unit, int prec, bool showUnit = false);
37                 static QString formatEngineering(double length, RS2::Unit unit, int prec, bool showUnit = false);
38                 static QString formatArchitectural(double length, RS2::Unit unit, int prec, bool showUnit = false);
39                 static QString formatFractional(double length, RS2::Unit unit, int prec, bool showUnit = false);
40
41                 static QString formatAngle(double angle, RS2::AngleFormat format, int prec);
42
43                 static Vector paperFormatToSize(RS2::PaperFormat p);
44                 static RS2::PaperFormat paperSizeToFormat(const Vector s);
45
46                 static QString paperFormatToString(RS2::PaperFormat p);
47                 static RS2::PaperFormat stringToPaperFormat(const QString & p);
48
49                 static void test();
50 };
51
52 #endif