1 // Created on: 1994-06-01
2 // Created by: Christian CAILLET
3 // Copyright (c) 1994-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 _IGESSelect_FloatFormat_HeaderFile
18 #define _IGESSelect_FloatFormat_HeaderFile
19 
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22 
23 #include <Standard_Boolean.hxx>
24 #include <TCollection_AsciiString.hxx>
25 #include <Standard_Real.hxx>
26 #include <IGESSelect_FileModifier.hxx>
27 #include <Standard_Integer.hxx>
28 #include <Standard_CString.hxx>
29 class IFSelect_ContextWrite;
30 class IGESData_IGESWriter;
31 
32 
33 class IGESSelect_FloatFormat;
34 DEFINE_STANDARD_HANDLE(IGESSelect_FloatFormat, IGESSelect_FileModifier)
35 
36 //! This class gives control out format for floatting values :
37 //! ZeroSuppress or no, Main Format, Format in Range (for values
38 //! around 1.), as IGESWriter allows to manage it.
39 //! Formats are given under C-printf form
40 class IGESSelect_FloatFormat : public IGESSelect_FileModifier
41 {
42 
43 public:
44 
45 
46   //! Creates a new FloatFormat, with standard options :
47   //! ZeroSuppress, Main Format = %E,
48   //! Format between 0.001 and 1000. = %f
49   Standard_EXPORT IGESSelect_FloatFormat();
50 
51   //! Sets FloatFormat to default value (see Create) but if <digits>
52   //! is given positive, it commands Formats (main and range) to
53   //! ensure <digits> significant digits to be displayed
54   Standard_EXPORT void SetDefault (const Standard_Integer digits = 0);
55 
56   //! Sets ZeroSuppress mode to a new value
57   Standard_EXPORT void SetZeroSuppress (const Standard_Boolean mode);
58 
59   //! Sets Main Format to a new value
60   //! Remark : SetFormat, SetZeroSuppress and SetFormatForRange are
61   //! independent
62   Standard_EXPORT void SetFormat (const Standard_CString format = "%E");
63 
64   //! Sets Format for Range to a new value with its range of
65   //! application.
66   //! To cancel it, give format as "" (empty string)
67   //! Remark that if the condition (0. < Rmin < Rmax)  is not
68   //! verified, this secondary format will be ignored.
69   //! Moreover, this secondary format is intended to be used in a
70   //! range around 1.
71   Standard_EXPORT void SetFormatForRange (const Standard_CString format = "%f", const Standard_Real Rmin = 0.1, const Standard_Real Rmax = 1000.0);
72 
73   //! Returns all recorded parameters :
74   //! zerosup  : ZeroSuppress status
75   //! mainform : Main Format (which applies out of the range, or
76   //! for every real if no range is set)
77   //! hasrange : True if a FormatInRange is set, False else
78   //! (following parameters do not apply if it is False)
79   //! forminrange : Secondary Format (it applies inside the range)
80   //! rangemin, rangemax : the range in which the secondary format
81   //! applies
82   Standard_EXPORT void Format (Standard_Boolean& zerosup, TCollection_AsciiString& mainform, Standard_Boolean& hasrange, TCollection_AsciiString& forminrange, Standard_Real& rangemin, Standard_Real& rangemax) const;
83 
84   //! Sets the Floatting Formats of IGESWriter to the recorded
85   //! parameters
86   Standard_EXPORT void Perform (IFSelect_ContextWrite& ctx, IGESData_IGESWriter& writer) const Standard_OVERRIDE;
87 
88   //! Returns specific Label : for instance,
89   //! "Float Format [ZeroSuppress] %E [, in range R1-R2 %f]"
90   Standard_EXPORT TCollection_AsciiString Label() const Standard_OVERRIDE;
91 
92 
93 
94 
95   DEFINE_STANDARD_RTTIEXT(IGESSelect_FloatFormat,IGESSelect_FileModifier)
96 
97 protected:
98 
99 
100 
101 
102 private:
103 
104 
105   Standard_Boolean thezerosup;
106   TCollection_AsciiString themainform;
107   TCollection_AsciiString theformrange;
108   Standard_Real therangemin;
109   Standard_Real therangemax;
110 
111 
112 };
113 
114 
115 
116 
117 
118 
119 
120 #endif // _IGESSelect_FloatFormat_HeaderFile
121