0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[occt.git] / src / Units / Units_Measurement.hxx
CommitLineData
42cf5bc1 1// Created on: 1992-06-22
2// Created by: Gilles DEBARBOUILLE
3// Copyright (c) 1992-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_Measurement_HeaderFile
18#define _Units_Measurement_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
24#include <Standard_Real.hxx>
25#include <Standard_Boolean.hxx>
26#include <Standard_CString.hxx>
27class Units_Token;
28
29
30//! This class defines a measurement which is the
31//! association of a real value and a unit.
32class Units_Measurement
33{
34public:
35
36 DEFINE_STANDARD_ALLOC
37
38
39 //! It is the empty constructor of the class.
40 Standard_EXPORT Units_Measurement();
41
42 //! Returns an instance of this class. <avalue> defines
43 //! the measurement, and <atoken> the token which defines
44 //! the unit used.
45 Standard_EXPORT Units_Measurement(const Standard_Real avalue, const Handle(Units_Token)& atoken);
46
47 //! Returns an instance of this class. <avalue> defines
48 //! the measurement, and <aunit> the unit used,
49 //! described in natural language.
50 Standard_EXPORT Units_Measurement(const Standard_Real avalue, const Standard_CString aunit);
51
52 //! Converts (if possible) the measurement object into
53 //! another unit. <aunit> must have the same
54 //! dimensionality as the unit contained in the token
55 //! <thetoken>.
56 Standard_EXPORT void Convert (const Standard_CString aunit);
57
58 //! Returns a Measurement object with the integer value of
59 //! the measurement contained in <me>.
60 Standard_EXPORT Units_Measurement Integer() const;
61
62 //! Returns a Measurement object with the fractional value
63 //! of the measurement contained in <me>.
64 Standard_EXPORT Units_Measurement Fractional() const;
65
66 //! Returns the value of the measurement.
67 Standard_EXPORT Standard_Real Measurement() const;
68
69 //! Returns the token contained in <me>.
70 Standard_EXPORT Handle(Units_Token) Token() const;
71
72 //! Returns (if it is possible) a measurement which is the
73 //! addition of <me> and <ameasurement>. The chosen
74 //! returned unit is the unit of <me>.
75 Standard_EXPORT Units_Measurement Add (const Units_Measurement& ameasurement) const;
76Units_Measurement operator + (const Units_Measurement& ameasurement) const
77{
78 return Add(ameasurement);
79}
80
81 //! Returns (if it is possible) a measurement which is the
82 //! subtraction of <me> and <ameasurement>. The chosen
83 //! returned unit is the unit of <me>.
84 Standard_EXPORT Units_Measurement Subtract (const Units_Measurement& ameasurement) const;
85Units_Measurement operator - (const Units_Measurement& ameasurement) const
86{
87 return Subtract(ameasurement);
88}
89
90 //! Returns a measurement which is the multiplication of
91 //! <me> and <ameasurement>.
92 Standard_EXPORT Units_Measurement Multiply (const Units_Measurement& ameasurement) const;
93Units_Measurement operator * (const Units_Measurement& ameasurement) const
94{
95 return Multiply(ameasurement);
96}
97
98 //! Returns a measurement which is the multiplication of
99 //! <me> with the value <avalue>.
100 Standard_EXPORT Units_Measurement Multiply (const Standard_Real avalue) const;
101Units_Measurement operator * (const Standard_Real avalue) const
102{
103 return Multiply(avalue);
104}
105
106 //! Returns a measurement which is the division of <me> by
107 //! <ameasurement>.
108 Standard_EXPORT Units_Measurement Divide (const Units_Measurement& ameasurement) const;
109Units_Measurement operator / (const Units_Measurement& ameasurement) const
110{
111 return Divide(ameasurement);
112}
113
114 //! Returns a measurement which is the division of <me> by
115 //! the constant <avalue>.
116 Standard_EXPORT Units_Measurement Divide (const Standard_Real avalue) const;
117Units_Measurement operator / (const Standard_Real avalue) const
118{
119 return Divide(avalue);
120}
121
122 //! Returns a measurement which is <me> powered
123 //! <anexponent>.
124 Standard_EXPORT Units_Measurement Power (const Standard_Real anexponent) const;
125
126 Standard_EXPORT Standard_Boolean HasToken() const;
127
128 //! Useful for debugging.
129 Standard_EXPORT void Dump() const;
130
131
132
133
134protected:
135
136
137
138
139
140private:
141
142
143
144 Standard_Real themeasurement;
145 Handle(Units_Token) thetoken;
146 Standard_Boolean myHasToken;
147
148
149};
150
151
152
153
154
155
156
157#endif // _Units_Measurement_HeaderFile