1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 #include <StepSelect_FloatFormat.ixx>
19 #include <Interface_FloatWriter.hxx>
24 StepSelect_FloatFormat::StepSelect_FloatFormat ()
25 : thezerosup (Standard_True) , themainform ("%E") ,
26 theformrange ("%f") , therangemin (0.1) , therangemax (1000.)
29 void StepSelect_FloatFormat::SetDefault (const Standard_Integer digits)
34 themainform.AssignCat ("%E");
35 theformrange.AssignCat ("%f");
38 char pourcent = '%'; char point = '.';
39 Sprintf(format, "%c%d%c%dE",pourcent,digits+2,point,digits);
40 themainform.AssignCat (format);
41 Sprintf(format, "%c%d%c%df",pourcent,digits+2,point,digits);
42 theformrange.AssignCat (format);
44 therangemin = 0.1; therangemax = 1000.;
45 thezerosup = Standard_True;
48 void StepSelect_FloatFormat::SetZeroSuppress (const Standard_Boolean mode)
49 { thezerosup = mode; }
51 void StepSelect_FloatFormat::SetFormat (const Standard_CString format)
52 { themainform.Clear(); themainform.AssignCat(format); }
55 void StepSelect_FloatFormat::SetFormatForRange
56 (const Standard_CString form, const Standard_Real R1, const Standard_Real R2)
58 theformrange.Clear(); theformrange.AssignCat(form);
59 therangemin = R1; therangemax = R2;
62 void StepSelect_FloatFormat::Format
63 (Standard_Boolean& zerosup, TCollection_AsciiString& mainform,
64 Standard_Boolean& hasrange, TCollection_AsciiString& formrange,
65 Standard_Real& rangemin, Standard_Real& rangemax) const
68 mainform = themainform;
69 hasrange = (theformrange.Length() > 0);
70 formrange = theformrange;
71 rangemin = therangemin;
72 rangemax = therangemax;
76 void StepSelect_FloatFormat::Perform
77 (IFSelect_ContextWrite& /*ctx*/,
78 StepData_StepWriter& writer) const
80 writer.FloatWriter().SetFormat (themainform.ToCString());
81 writer.FloatWriter().SetZeroSuppress (thezerosup);
82 if (theformrange.Length() > 0) writer.FloatWriter().SetFormatForRange
83 (theformrange.ToCString(), therangemin, therangemax);
86 TCollection_AsciiString StepSelect_FloatFormat::Label () const
88 TCollection_AsciiString lab("Float Format ");
89 if (thezerosup) lab.AssignCat(" ZeroSuppress");
90 lab.AssignCat (themainform);
91 if (theformrange.Length() > 0) {
93 Sprintf(mess,", in range %f %f %s",
94 therangemin,therangemax,theformrange.ToCString());