1 #include <StepSelect_FloatFormat.ixx>
2 #include <Interface_FloatWriter.hxx>
7 StepSelect_FloatFormat::StepSelect_FloatFormat ()
8 : thezerosup (Standard_True) , themainform ("%E") ,
9 theformrange ("%f") , therangemin (0.1) , therangemax (1000.)
12 void StepSelect_FloatFormat::SetDefault (const Standard_Integer digits)
17 themainform.AssignCat ("%E");
18 theformrange.AssignCat ("%f");
21 char pourcent = '%'; char point = '.';
22 sprintf(format, "%c%d%c%dE",pourcent,digits+2,point,digits);
23 themainform.AssignCat (format);
24 sprintf(format, "%c%d%c%df",pourcent,digits+2,point,digits);
25 theformrange.AssignCat (format);
27 therangemin = 0.1; therangemax = 1000.;
28 thezerosup = Standard_True;
31 void StepSelect_FloatFormat::SetZeroSuppress (const Standard_Boolean mode)
32 { thezerosup = mode; }
34 void StepSelect_FloatFormat::SetFormat (const Standard_CString format)
35 { themainform.Clear(); themainform.AssignCat(format); }
38 void StepSelect_FloatFormat::SetFormatForRange
39 (const Standard_CString form, const Standard_Real R1, const Standard_Real R2)
41 theformrange.Clear(); theformrange.AssignCat(form);
42 therangemin = R1; therangemax = R2;
45 void StepSelect_FloatFormat::Format
46 (Standard_Boolean& zerosup, TCollection_AsciiString& mainform,
47 Standard_Boolean& hasrange, TCollection_AsciiString& formrange,
48 Standard_Real& rangemin, Standard_Real& rangemax) const
51 mainform = themainform;
52 hasrange = (theformrange.Length() > 0);
53 formrange = theformrange;
54 rangemin = therangemin;
55 rangemax = therangemax;
59 void StepSelect_FloatFormat::Perform
60 (IFSelect_ContextWrite& ctx,
61 StepData_StepWriter& writer) const
63 writer.FloatWriter().SetFormat (themainform.ToCString());
64 writer.FloatWriter().SetZeroSuppress (thezerosup);
65 if (theformrange.Length() > 0) writer.FloatWriter().SetFormatForRange
66 (theformrange.ToCString(), therangemin, therangemax);
69 TCollection_AsciiString StepSelect_FloatFormat::Label () const
71 TCollection_AsciiString lab("Float Format ");
72 if (thezerosup) lab.AssignCat(" ZeroSuppress");
73 lab.AssignCat (themainform);
74 if (theformrange.Length() > 0) {
76 sprintf(mess,", in range %f %f %s",
77 therangemin,therangemax,theformrange.ToCString());