Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:34

0001 // Copyright (c) 2021 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _XCAFDoc_LengthUnit_HeaderFile
0015 #define _XCAFDoc_LengthUnit_HeaderFile
0016 
0017 #include <Standard.hxx>
0018 #include <Standard_Type.hxx>
0019 #include <TDF_DerivedAttribute.hxx>
0020 
0021 #include <TCollection_AsciiString.hxx>
0022 #include <TDF_Attribute.hxx>
0023 #include <Standard_OStream.hxx>
0024 #include <Standard_GUID.hxx>
0025 
0026 class TDF_Label;
0027 class TDF_RelocationTable;
0028 
0029 
0030 class XCAFDoc_LengthUnit;
0031 DEFINE_STANDARD_HANDLE(XCAFDoc_LengthUnit, TDF_Attribute)
0032 
0033 //! Used to define a Length Unit attribute containing a length unit info
0034 class XCAFDoc_LengthUnit : public TDF_Attribute
0035 {
0036 
0037 public:
0038 
0039   //! Returns the GUID of the attribute.
0040   Standard_EXPORT static const Standard_GUID& GetID();
0041 
0042   //! Finds or creates a LengthUnit attribute
0043   //! @param theUnitName - name of the unit: mm, m, cm, km, micron, in, min, nin, ft, stat.mile
0044   //! @param theUnitValue - length scale factor to meter
0045   //! The LengthUnit attribute is returned.
0046   Standard_EXPORT static Handle(XCAFDoc_LengthUnit) Set(const TDF_Label& theLabel,
0047                                                          const TCollection_AsciiString& theUnitName,
0048                                                          const Standard_Real theUnitValue);
0049 
0050   //! Finds or creates a LengthUnit attribute
0051   //! @param theUnitValue - length scale factor to meter
0052   //! The LengthUnit attribute is returned.
0053   Standard_EXPORT static Handle(XCAFDoc_LengthUnit) Set(const TDF_Label& theLabel,
0054                                                          const Standard_Real theUnitValue);
0055 
0056   //! Finds, or creates, a LengthUnit attribute with explicit user defined GUID
0057   //! @param theUnitName - name of the unit: mm, m, cm, km, micron, in, min, nin, ft, stat.mile
0058   //! @param theUnitValue - length scale factor to meter
0059   //! The LengthUnit attribute is returned
0060   Standard_EXPORT static Handle(XCAFDoc_LengthUnit) Set(const TDF_Label& theLabel,
0061                                                          const Standard_GUID& theGUID,
0062                                                          const TCollection_AsciiString& theUnitName,
0063                                                          const Standard_Real theUnitValue);
0064 
0065   //! Creates a LengthUnit attribute
0066   //! @param theUnitName - name of the unit: mm, m, cm, km, micron, in, min, nin, ft, stat.mile
0067   //! @param theUnitValue - length scale factor to meter
0068   Standard_EXPORT void Set(const TCollection_AsciiString& theUnitName,
0069                            const Standard_Real theUnitValue);
0070   
0071   //! Length unit description (could be arbitrary text)
0072   const TCollection_AsciiString& GetUnitName() const { return myUnitName; }
0073 
0074   //! Returns length unit scale factor to meter
0075   Standard_Real GetUnitValue() const { return myUnitScaleValue; }
0076 
0077   Standard_EXPORT Standard_Boolean IsEmpty() const { return myUnitName.IsEmpty(); }
0078 
0079   Standard_EXPORT XCAFDoc_LengthUnit();
0080 
0081   Standard_EXPORT virtual const Standard_GUID& ID() const Standard_OVERRIDE;
0082 
0083   Standard_EXPORT virtual void Restore(const Handle(TDF_Attribute)& theWith) Standard_OVERRIDE;
0084 
0085   Standard_EXPORT virtual void Paste(const Handle(TDF_Attribute)& theInto, const Handle(TDF_RelocationTable)& theRT) const Standard_OVERRIDE;
0086 
0087   Standard_EXPORT virtual Standard_OStream& Dump(Standard_OStream& anOS) const Standard_OVERRIDE;
0088 
0089   //! Dumps the content of me into the stream
0090   Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0091 
0092 
0093   DEFINE_DERIVED_ATTRIBUTE(XCAFDoc_LengthUnit, TDF_Attribute)
0094 
0095 private:
0096 
0097   Standard_Real myUnitScaleValue;
0098   TCollection_AsciiString myUnitName;
0099 };
0100 
0101 #endif // _XCAFDoc_LengthUnit_HeaderFile