42cf5bc1 |
1 | // Created on: 1993-10-22 |
2 | // Created by: Gilles DEBARBOUILLE |
3 | // Copyright (c) 1993-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _Units_UnitsSystem_HeaderFile |
18 | #define _Units_UnitsSystem_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
23 | #include <Units_QuantitiesSequence.hxx> |
24 | #include <TColStd_HSequenceOfInteger.hxx> |
25e59720 |
25 | #include <Standard_Transient.hxx> |
42cf5bc1 |
26 | #include <Standard_CString.hxx> |
27 | #include <Standard_Boolean.hxx> |
28 | #include <Standard_Real.hxx> |
29 | class Units_NoSuchUnit; |
30 | class Units_NoSuchType; |
31 | class TCollection_AsciiString; |
32 | |
33 | |
34 | class Units_UnitsSystem; |
25e59720 |
35 | DEFINE_STANDARD_HANDLE(Units_UnitsSystem, Standard_Transient) |
42cf5bc1 |
36 | |
37 | //! This class allows the user to define his own |
38 | //! system of units. |
25e59720 |
39 | class Units_UnitsSystem : public Standard_Transient |
42cf5bc1 |
40 | { |
41 | |
42 | public: |
43 | |
44 | |
45 | //! Returns an instance of UnitsSystem initialized to the |
46 | //! S.I. units system. |
47 | Standard_EXPORT Units_UnitsSystem(); |
48 | |
49 | //! Returns an instance of UnitsSystem initialized to the |
50 | //! S.I. units system upgraded by the base system units decription |
51 | //! file. |
52 | //! Attempts to find the four following files: |
53 | //! $CSF_`aName`Defaults/.aName |
54 | //! $CSF_`aName`SiteDefaults/.aName |
55 | //! $CSF_`aName`GroupDefaults/.aName |
56 | //! $CSF_`aName`UserDefaults/.aName |
57 | //! See : Resource_Manager for the description of this file. |
58 | Standard_EXPORT Units_UnitsSystem(const Standard_CString aName, const Standard_Boolean Verbose = Standard_False); |
59 | |
60 | //! Returns the sequence of refined quantities. |
61 | Standard_EXPORT Handle(Units_QuantitiesSequence) QuantitiesSequence() const; |
62 | |
63 | //! Returns a sequence of integer in correspondance with |
64 | //! the sequence of quantities, which indicates, for each |
65 | //! redefined quantity, the index into the sequence of |
66 | //! units, of the active unit. |
67 | Standard_EXPORT Handle(TColStd_HSequenceOfInteger) ActiveUnitsSequence() const; |
68 | |
69 | //! Specifies for <aquantity> the unit <aunit> used. |
70 | Standard_EXPORT void Specify (const Standard_CString aquantity, const Standard_CString aunit); |
71 | |
72 | //! Removes for <aquantity> the unit <aunit> used. |
73 | Standard_EXPORT void Remove (const Standard_CString aquantity, const Standard_CString aunit); |
74 | |
75 | //! Specifies for <aquantity> the unit <aunit> used. |
76 | Standard_EXPORT void Activate (const Standard_CString aquantity, const Standard_CString aunit); |
77 | |
78 | //! Activates the first unit of all defined system quantities |
79 | Standard_EXPORT void Activates(); |
80 | |
81 | //! Returns for <aquantity> the active unit. |
82 | Standard_EXPORT TCollection_AsciiString ActiveUnit (const Standard_CString aquantity) const; |
83 | |
84 | //! Converts a real value <avalue> from the unit <aunit> |
85 | //! belonging to the physical dimensions <aquantity> to |
86 | //! the corresponding unit of the user system. |
87 | Standard_EXPORT Standard_Real ConvertValueToUserSystem (const Standard_CString aquantity, const Standard_Real avalue, const Standard_CString aunit) const; |
88 | |
89 | //! Converts the real value <avalue> from the S.I. system |
90 | //! of units to the user system of units. <aquantity> is |
91 | //! the physical dimensions of the measurement. |
92 | Standard_EXPORT Standard_Real ConvertSIValueToUserSystem (const Standard_CString aquantity, const Standard_Real avalue) const; |
93 | |
94 | //! Converts the real value <avalue> from the user system |
95 | //! of units to the S.I. system of units. <aquantity> is |
96 | //! the physical dimensions of the measurement. |
97 | Standard_EXPORT Standard_Real ConvertUserSystemValueToSI (const Standard_CString aquantity, const Standard_Real avalue) const; |
98 | |
99 | Standard_EXPORT void Dump() const; |
100 | |
101 | //! Returns TRUE if no units has been defined in the system. |
102 | Standard_EXPORT Standard_Boolean IsEmpty() const; |
103 | |
104 | |
105 | |
106 | |
25e59720 |
107 | DEFINE_STANDARD_RTTIEXT(Units_UnitsSystem,Standard_Transient) |
42cf5bc1 |
108 | |
109 | protected: |
110 | |
111 | |
112 | |
113 | |
114 | private: |
115 | |
116 | |
117 | Handle(Units_QuantitiesSequence) thequantitiessequence; |
118 | Handle(TColStd_HSequenceOfInteger) theactiveunitssequence; |
119 | |
120 | |
121 | }; |
122 | |
123 | |
124 | |
125 | |
126 | |
127 | |
128 | |
129 | #endif // _Units_UnitsSystem_HeaderFile |