QCAD Application Framework
CAD Application Development and Automation.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RUnit.h
Go to the documentation of this file.
1 #ifndef RUNIT_H
2 #define RUNIT_H
3 
4 #include "RS.h"
5 #include "RVector.h"
6 
7 class RDocument;
8 
14 class RUnit {
15 public:
16  //static RS::Unit stringToUnit(const QString& u);
17 
18  static QString formatLinear(double length, RS::Unit unit,
19  RS::LinearFormat format,
20  int prec, bool showUnit=false,
21  bool showLeadingZeroes=true,
22  bool showTrailingZeroes=false);
23  static QString formatScientific(double length, RS::Unit unit,
24  int prec, bool showUnit=false,
25  bool showLeadingZeroes=true,
26  bool showTrailingZeroes=false);
27  static QString formatDecimal(double length, RS::Unit unit,
28  int prec, bool showUnit=false,
29  bool showLeadingZeroes=true,
30  bool showTrailingZeroes=false);
31  static QString formatEngineering(double length, RS::Unit unit,
32  int prec, bool showUnit=false,
33  bool showLeadingZeroes=true,
34  bool showTrailingZeroes=false);
35  static QString formatArchitectural(double length, RS::Unit unit,
36  int prec, bool showUnit=false,
37  bool showLeadingZeroes=true,
38  bool showTrailingZeroes=false);
39  static QString formatFractional(double length, RS::Unit unit,
40  int prec, bool showUnit=false,
41  bool showLeadingZeroes=true,
42  bool showTrailingZeroes=false);
43  static QString trimTrailingZeroes(const QString& s);
44 
45  static QString formatAngle(double angle, RS::AngleFormat format,
46  int prec,
47  bool showLeadingZeroes=true,
48  bool showTrailingZeroes=false);
49 
50  /*
51  static RVector paperFormatToSize(RS::PaperFormat p);
52  static RS::PaperFormat paperSizeToFormat(const RVector s);
53 
54  static QString paperFormatToString(RS::PaperFormat p);
55  static RS::PaperFormat stringToPaperFormat(const QString& p);
56  */
57 
58  static bool isMetric(RS::Unit unit);
59  static double convert(double value, RS::Unit source, RS::Unit dest);
60  static RVector convert(const RVector& value, RS::Unit source, RS::Unit dest);
61  static double getFactorToM(RS::Unit unit);
62  static QString unitToSymbol(RS::Unit unit);
63  static QString unitToName(RS::Unit unit, bool tr=true);
64  static QString getLabel(double v, RDocument& document,
65  bool maxPrecision=false,
66  bool forceSuppressTrailingZeroes=false);
67 
68  static QString doubleToString(double value, double prec,
69  bool showLeadingZeroes=true, bool showTrailingZeroes=false);
70  static QString doubleToString(double value, int prec,
71  bool showLeadingZeroes=true, bool showTrailingZeroes=false);
72 };
73 
75 
76 #endif