CFx SDK Documentation  2022 SP0
FxUnitsFormatter.h
Go to the documentation of this file.
1 //
2 // (C) Copyright 2005-2021 by Graebert GmbH.
3 //
4 // Permission to use, copy, modify, and distribute this software in
5 // object code form for any purpose and without fee is hereby granted,
6 // provided that the above copyright notice appears in all copies and
7 // that both that copyright notice and the limited warranty and
8 // restricted rights notice below appear in all supporting
9 // documentation.
10 //
11 // GRAEBERT PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
12 // GRAEBERT SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
13 // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. GRAEBERT GMBH
14 // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
15 // UNINTERRUPTED OR ERROR FREE.
16 
17 #pragma once
18 
19 #include "FxPragmaPush.h"
20 
21 #include "DDKERNEL.h"
22 #include "FxFdtType.h"
23 
24 #include <CmColor.h>
25 #include <DbUnitsFormatter.h>
26 #include <ResBuf.h>
27 #include <StaticRxObject.h>
28 
29 class CFxBaseDatabase;
30 class CFxDatabase;
31 class CFxString;
32 
39  public OdDbUnitsFormatter
40 {
41 public:
42  typedef enum _Flags
43  {
44  eNone = 0,
45  eRelativeUnit = 0x0001 //@-character in input
46  } Flags;
47 
49  ~CFxUnitsFormatter(void) override;
50 
51  void SetFxDatabase( const CFxDatabase* );
52  Flags GetFlags() const;
53 
54  const CFxDatabase* GetFxDatabase() const;
55  // (itoa)
56  virtual int IntToString( CFxString& strResult, int iValue ) const;
57 
58  // (atoi)
59  virtual int StringToInt( int* iResult, const CFxString& strValue ) const;
60 
61  // RToS
62  virtual int RealToString( CFxString& strResult, double dValue, int iUnit = -1, int iPrecision = -1, int dimzin = -1 ) const;
63 
64  // DisToF
65  virtual int StringToReal( double* pResult, const CFxString& strValue, bool bNoDistance = false, bool bAllowArchitectural = true ) const;
66 
67  virtual int PointToString( CFxString& strResult, const OdGePoint3d& ptValue, bool toPolar = false, int iUnit = kDecimal, int iPrecision = -1, OdChar seperator = ',' ) const;
68 
69  virtual int PointToString( CFxString& strResult, const OdGePoint2d& ptValue, bool toPolar = false, int iUnit = kDecimal, int iPrecision = -1, OdChar seperator = ',' ) const;
70 
71  // Converts string with point in UCS to 'OdGePoint3d' point in WCS
72  virtual int StringToPoint( OdGePoint3d& geResultWCS, const CFxString& strValueUCS, Flags* pUnitFlags = 0, const OdGePoint3d* pLastPointWCS = 0 ) const;
73 
74  virtual int AngleToString( CFxString& strResult, double dValue, int iUnit = -1, int iPrecision = -1, int dimzin = -1, bool ignoreANGBASE = false ) const;
75  virtual int AngleToString( CFxString& strResult, double dValue, int iUNITMODE, int iAUPREC, int iDIMZIN, int iAUNITS, int iANGDIR, double dANGBASE ) const;
76 
77  // AngToF
78  virtual int StringToAngle( double* pResult, const CFxString& strValue, int iUnit = -1, bool* isNegative = 0, bool ignoreANGBASE = false ) const;
79  virtual int StringToAngle( double* pResult, const CFxString& strValue, int iAUNITS, bool* isNegative, int iANGDIR, double dANGBASE) const;
80 
81  virtual int PointToUCS( OdGePoint3d& ptResultUCS, const OdGePoint3d& ptValueWCS ) const;
82 
83  virtual int PointFromUCS( OdGePoint3d& ptResultWCS, const OdGePoint3d& ptValueUCS ) const;
84 
85  virtual int OrientToString( CFxString& strResult, double dValue, int iUnit = -1, int iPrecision = -1, int dimzin = -1 ) const;
86  virtual int OrientToString( CFxString& strResult, double dValue, int iUNITMODE, int iAUPREC, int iDIMZIN, int iAUNITS, int iANGDIR, double dANGBASE ) const;
87 
88  virtual int StringToOrient( double* pResult, const CFxString& strValue, int iUnit = -1 ) const;
89  virtual int StringToOrient(double* pResult, const CFxString& strValue, int iAUNITS, int iANGDIR, double dANGBASE) const;
90  virtual int StringToColor( OdCmColor* iResult, const CFxString& strValue ) const;
91 
92  virtual int ResBufToString( CFxString& strResult, const OdResBuf* pRb) const;
93 
94  // Reads double from string till first non-digit symbol
95  // pass remainingString to get back non-digit part
96  virtual int ReadDouble( double* pResult, const CFxString& value, CFxString* remainingString = 0 ) const;
97 
98  static int NameToString( CFxString& strResult, const fdt_name pRb);
99 
100  static int StringToName( fdt_name* pResult, const CFxString& strValue );
101 
102 protected:
110  OdString formatLinear( double value ) const override;
111 
119  double unformatLinear( const OdString& string ) const override;
120 
130  OdString formatAngle( double value ) const override;
131 
141  double unformatAngle( const OdString& string ) const override;
142 
145  double toUserAngle( double value ) const override;
146 
149  double fromUserAngle( double value ) const override;
150 
153  virtual CFxString additionalRealFormatting( const CFxString& strValue ) const;
154 
162  OdString formatPoint( const OdGePoint3d& value ) const override;
163 
169  OdGePoint3d unformatPoint( const OdString& string ) const override;
170 
173  OdGePoint3d toUCS( const OdGePoint3d& wcsPt ) const override;
174 
177  OdGePoint3d fromUCS( const OdGePoint3d& ucsPt ) const override;
178 
179 
182  static int unformatL(const CFxString& string, double & resVal, bool bAllowArchitectural);
183 
193  static int unformatScale(const CFxString& string, double & resVal);
194 
205  static int unformatA(const CFxString& string, double & resVal, bool* isNegative = 0);
206 
221  static OdString formatL(double v, LUnits units, int precision, int dimzin, int mode, OdChar decsep = 0, OdChar thsep = 0);
222 
223  OdString formatCmColor(const OdCmColorBase& value) const override;
224  OdSharedPtr<OdCmColorBase> unformatCmColor(const OdString& string) const override;
225 
226 protected:
228 };
229 
230 #include "FxPragmaPop.h"
#define DDKERNEL_API
Definition: DDKERNEL.h:32
uintptr_t fdt_name[2]
Definition: FxFdtType.h:57
wchar_t OdChar
static int unformatL(const CFxString &string, double &resVal, bool bAllowArchitectural)
virtual int OrientToString(CFxString &strResult, double dValue, int iUnit=-1, int iPrecision=-1, int dimzin=-1) const
~CFxUnitsFormatter(void) override
virtual int StringToOrient(double *pResult, const CFxString &strValue, int iUnit=-1) const
virtual int RealToString(CFxString &strResult, double dValue, int iUnit=-1, int iPrecision=-1, int dimzin=-1) const
OdString formatPoint(const OdGePoint3d &value) const override
OdGePoint3d unformatPoint(const OdString &string) const override
OdString formatCmColor(const OdCmColorBase &value) const override
virtual int OrientToString(CFxString &strResult, double dValue, int iUNITMODE, int iAUPREC, int iDIMZIN, int iAUNITS, int iANGDIR, double dANGBASE) const
virtual int AngleToString(CFxString &strResult, double dValue, int iUNITMODE, int iAUPREC, int iDIMZIN, int iAUNITS, int iANGDIR, double dANGBASE) const
void SetFxDatabase(const CFxDatabase *)
double unformatAngle(const OdString &string) const override
static OdString formatL(double v, LUnits units, int precision, int dimzin, int mode, OdChar decsep=0, OdChar thsep=0)
static int unformatScale(const CFxString &string, double &resVal)
OdString formatLinear(double value) const override
virtual int StringToReal(double *pResult, const CFxString &strValue, bool bNoDistance=false, bool bAllowArchitectural=true) const
OdGePoint3d fromUCS(const OdGePoint3d &ucsPt) const override
OdSharedPtr< OdCmColorBase > unformatCmColor(const OdString &string) const override
double unformatLinear(const OdString &string) const override
virtual CFxString additionalRealFormatting(const CFxString &strValue) const
static int NameToString(CFxString &strResult, const fdt_name pRb)
virtual int StringToPoint(OdGePoint3d &geResultWCS, const CFxString &strValueUCS, Flags *pUnitFlags=0, const OdGePoint3d *pLastPointWCS=0) const
OdString formatAngle(double value) const override
Flags GetFlags() const
double fromUserAngle(double value) const override
virtual int StringToOrient(double *pResult, const CFxString &strValue, int iAUNITS, int iANGDIR, double dANGBASE) const
virtual int StringToColor(OdCmColor *iResult, const CFxString &strValue) const
OdGePoint3d toUCS(const OdGePoint3d &wcsPt) const override
virtual int PointToString(CFxString &strResult, const OdGePoint3d &ptValue, bool toPolar=false, int iUnit=kDecimal, int iPrecision=-1, OdChar seperator=',') const
virtual int PointToUCS(OdGePoint3d &ptResultUCS, const OdGePoint3d &ptValueWCS) const
static int StringToName(fdt_name *pResult, const CFxString &strValue)
virtual int StringToAngle(double *pResult, const CFxString &strValue, int iUnit=-1, bool *isNegative=0, bool ignoreANGBASE=false) const
virtual int StringToAngle(double *pResult, const CFxString &strValue, int iAUNITS, bool *isNegative, int iANGDIR, double dANGBASE) const
virtual int AngleToString(CFxString &strResult, double dValue, int iUnit=-1, int iPrecision=-1, int dimzin=-1, bool ignoreANGBASE=false) const
virtual int ReadDouble(double *pResult, const CFxString &value, CFxString *remainingString=0) const
virtual int IntToString(CFxString &strResult, int iValue) const
enum CFxUnitsFormatter::_Flags Flags
virtual int PointToString(CFxString &strResult, const OdGePoint2d &ptValue, bool toPolar=false, int iUnit=kDecimal, int iPrecision=-1, OdChar seperator=',') const
static int unformatA(const CFxString &string, double &resVal, bool *isNegative=0)
virtual int StringToInt(int *iResult, const CFxString &strValue) const
virtual int PointFromUCS(OdGePoint3d &ptResultWCS, const OdGePoint3d &ptValueUCS) const
double toUserAngle(double value) const override
const CFxDatabase * m_pDatabase
const CFxDatabase * GetFxDatabase() const
virtual int ResBufToString(CFxString &strResult, const OdResBuf *pRb) const
const GLfloat * v
Definition: gles2_ext.h:315
GLenum GLint GLint * precision
Definition: gles2_ext.h:563
GLsizei const GLfloat * value
Definition: gles2_ext.h:302