QCAD
Open Source 2D CAD
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RUnit.h
Go to the documentation of this file.
1 
20 #ifndef RUNIT_H
21 #define RUNIT_H
22 
23 #include "core_global.h"
24 
25 #include "RS.h"
26 #include "RVector.h"
27 
28 class RDocument;
29 
36 public:
37  //static RS::Unit stringToUnit(const QString& u);
38 
39  static QString formatLinear(double length, RS::Unit unit,
40  RS::LinearFormat format,
41  int prec, bool showUnit=false,
42  bool showLeadingZeroes=true,
43  bool showTrailingZeroes=false,
44  bool onlyPreciseResult=false);
45  static QString formatScientific(double length, RS::Unit unit,
46  int prec, bool showUnit=false,
47  bool showLeadingZeroes=true,
48  bool showTrailingZeroes=false,
49  bool onlyPreciseResult=false);
50  static QString formatDecimal(double length, RS::Unit unit,
51  int prec, bool showUnit=false,
52  bool showLeadingZeroes=true,
53  bool showTrailingZeroes=false,
54  bool onlyPreciseResult=false);
55  static QString formatEngineering(double length, RS::Unit unit,
56  int prec, bool showUnit=false,
57  bool showLeadingZeroes=true,
58  bool showTrailingZeroes=false,
59  bool onlyPreciseResult=false);
60  static QString formatArchitectural(double length, RS::Unit unit,
61  int prec, bool showUnit=false,
62  bool showLeadingZeroes=true,
63  bool showTrailingZeroes=false,
64  bool onlyPreciseResult=false);
65  static QString formatFractional(double length, RS::Unit unit,
66  int prec, bool showUnit=false,
67  bool showLeadingZeroes=true,
68  bool showTrailingZeroes=false,
69  bool onlyPreciseResult=false);
70  static QString trimTrailingZeroes(const QString& s);
71 
72  static QString formatAngle(double angle, RS::AngleFormat format,
73  int prec,
74  bool showLeadingZeroes=true,
75  bool showTrailingZeroes=false);
76 
77  /*
78  static RVector paperFormatToSize(RS::PaperFormat p);
79  static RS::PaperFormat paperSizeToFormat(const RVector s);
80 
81  static QString paperFormatToString(RS::PaperFormat p);
82  static RS::PaperFormat stringToPaperFormat(const QString& p);
83  */
84 
85  static bool isMetric(RS::Unit unit);
86  static double convert(double value, RS::Unit source, RS::Unit dest);
87  static RVector convert(const RVector& value, RS::Unit source, RS::Unit dest);
88  static double getFactorToM(RS::Unit unit);
89  static QString unitToSymbol(RS::Unit unit);
90  static QString unitToName(RS::Unit unit, bool tr=true);
91  static QString getLabel(double v, RDocument& document,
92  bool maxPrecision=false,
93  bool forceSuppressTrailingZeroes=false,
94  bool onlyPreciseResult=false);
95 
96  static QString doubleToString(double value, double prec,
97  bool showLeadingZeroes=true, bool showTrailingZeroes=false);
98  static QString doubleToString(double value, int prec,
99  bool showLeadingZeroes=true, bool showTrailingZeroes=false);
100 };
101 
103 
104 #endif