Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-11 09:19:44

0001 // Created on: 2000-09-26
0002 // Created by: Pavel TELKOV.
0003 // Copyright (c) 2000-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _XCAFDoc_LayerTool_HeaderFile
0017 #define _XCAFDoc_LayerTool_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 #include <Standard_Type.hxx>
0021 
0022 #include <TDataStd_GenericEmpty.hxx>
0023 #include <TDF_Label.hxx>
0024 #include <NCollection_Sequence.hxx>
0025 #include <TCollection_ExtendedString.hxx>
0026 #include <NCollection_HSequence.hxx>
0027 class XCAFDoc_ShapeTool;
0028 class TDF_Label;
0029 class Standard_GUID;
0030 class TCollection_ExtendedString;
0031 class TopoDS_Shape;
0032 
0033 //! Provides tools to store and retrieve attributes (Layers)
0034 //! of TopoDS_Shape in and from TDocStd_Document
0035 //! A Document is intended to hold different
0036 //! attributes of ONE shape and it's sub-shapes
0037 //! Provide tools for management of Layers section of document.
0038 class XCAFDoc_LayerTool : public TDataStd_GenericEmpty
0039 {
0040 
0041 public:
0042   Standard_EXPORT XCAFDoc_LayerTool();
0043 
0044   //! Creates (if not exist) LayerTool.
0045   Standard_EXPORT static occ::handle<XCAFDoc_LayerTool> Set(const TDF_Label& L);
0046 
0047   Standard_EXPORT static const Standard_GUID& GetID();
0048 
0049   //! returns the label under which Layers are stored
0050   Standard_EXPORT TDF_Label BaseLabel() const;
0051 
0052   //! Returns internal XCAFDoc_ShapeTool tool
0053   Standard_EXPORT const occ::handle<XCAFDoc_ShapeTool>& ShapeTool();
0054 
0055   //! Returns True if label belongs to a Layertable and
0056   //! is a Layer definition
0057   Standard_EXPORT bool IsLayer(const TDF_Label& lab) const;
0058 
0059   //! Returns Layer defined by label lab
0060   //! Returns False if the label is not in Layertable
0061   //! or does not define a Layer
0062   Standard_EXPORT bool GetLayer(const TDF_Label& lab, TCollection_ExtendedString& aLayer) const;
0063 
0064   //! Finds a Layer definition in a Layertable and returns
0065   //! its label if found
0066   //! Returns False if Layer is not found in Layertable
0067   Standard_EXPORT bool FindLayer(const TCollection_ExtendedString& aLayer, TDF_Label& lab) const;
0068 
0069   //! Finds a Layer definition in a Layertable by name
0070   //! Returns first founded label with the same name if <theToFindWithProperty> is false
0071   //! If <theToFindWithProperty> is true returns first label that
0072   //! contains or not contains visible attr, according to the <theToFindVisible> parameter
0073   Standard_EXPORT TDF_Label FindLayer(const TCollection_ExtendedString& aLayer,
0074                                       const bool theToFindWithProperty = false,
0075                                       const bool theToFindVisible      = true) const;
0076 
0077   //! Adds a Layer definition to a Layertable and returns
0078   //! its label (returns existing label if the same Layer
0079   //! is already defined)
0080   Standard_EXPORT TDF_Label AddLayer(const TCollection_ExtendedString& theLayer) const;
0081 
0082   //! Adds a Layer definition to a Layertable and returns its label
0083   //! Returns existing label (if it is already defined)
0084   //! of visible or invisible layer, according to <theToFindVisible> parameter
0085   Standard_EXPORT TDF_Label AddLayer(const TCollection_ExtendedString& theLayer,
0086                                      const bool                        theToFindVisible) const;
0087 
0088   //! Removes Layer from the Layertable
0089   Standard_EXPORT void RemoveLayer(const TDF_Label& lab) const;
0090 
0091   //! Returns a sequence of Layers currently stored
0092   //! in the Layertable
0093   Standard_EXPORT void GetLayerLabels(NCollection_Sequence<TDF_Label>& Labels) const;
0094 
0095   //! Sets a link from label <L> to Layer
0096   //! defined by <LayerL>
0097   //! optional parameter <shapeInOneLayer> show could shape be
0098   //! in number of layers or only in one.
0099   Standard_EXPORT void SetLayer(const TDF_Label& L,
0100                                 const TDF_Label& LayerL,
0101                                 const bool       shapeInOneLayer = false) const;
0102 
0103   //! Sets a link from label <L> to Layer <aLayer>
0104   //! in the Layertable
0105   //! Adds a Layer as necessary
0106   //! optional parameter <shapeInOneLayer> show could shape be
0107   //! in number of layers or only in one.
0108   Standard_EXPORT void SetLayer(const TDF_Label&                  L,
0109                                 const TCollection_ExtendedString& aLayer,
0110                                 const bool                        shapeInOneLayer = false) const;
0111 
0112   //! Removes a link from label <L> to all layers
0113   Standard_EXPORT void UnSetLayers(const TDF_Label& L) const;
0114 
0115   //! Remove link from label <L> and Layer <aLayer>.
0116   //! returns FALSE if no such layer.
0117   Standard_EXPORT bool UnSetOneLayer(const TDF_Label&                  L,
0118                                      const TCollection_ExtendedString& aLayer) const;
0119 
0120   //! Remove link from label <L> and Layer <aLayerL>.
0121   //! returns FALSE if <aLayerL> is not a layer label.
0122   Standard_EXPORT bool UnSetOneLayer(const TDF_Label& L, const TDF_Label& aLayerL) const;
0123 
0124   //! Returns True if label <L> has a Layer associated
0125   //! with the <aLayer>.
0126   Standard_EXPORT bool IsSet(const TDF_Label& L, const TCollection_ExtendedString& aLayer) const;
0127 
0128   //! Returns True if label <L> has a Layer associated
0129   //! with the <aLayerL> label.
0130   Standard_EXPORT bool IsSet(const TDF_Label& L, const TDF_Label& aLayerL) const;
0131 
0132   //! Return sequence of strings <aLayerS> that associated with label <L>.
0133   Standard_EXPORT bool GetLayers(
0134     const TDF_Label&                                                L,
0135     occ::handle<NCollection_HSequence<TCollection_ExtendedString>>& aLayerS);
0136 
0137   //! Return sequence of labels <aLayerSL> that associated with label <L>.
0138   Standard_EXPORT bool GetLayers(const TDF_Label& L, NCollection_Sequence<TDF_Label>& aLayerLS);
0139 
0140   //! Return sequence of strings that associated with label <L>.
0141   Standard_EXPORT occ::handle<NCollection_HSequence<TCollection_ExtendedString>> GetLayers(
0142     const TDF_Label& L);
0143 
0144   //! Return sequanese of shape labels that assigned with layers to <ShLabels>.
0145   Standard_EXPORT static void GetShapesOfLayer(const TDF_Label&                 theLayerL,
0146                                                NCollection_Sequence<TDF_Label>& theShLabels);
0147 
0148   //! Return TRUE if layer is visible, FALSE if invisible.
0149   Standard_EXPORT bool IsVisible(const TDF_Label& layerL) const;
0150 
0151   //! Set the visibility of layer. If layer is invisible when on it's layer
0152   //! will set UAttribute with corresponding GUID.
0153   Standard_EXPORT void SetVisibility(const TDF_Label& layerL, const bool isvisible = true) const;
0154 
0155   //! Sets a link from label that containing shape <Sh>
0156   //! with layer that situated at label <LayerL>.
0157   //! optional parameter <shapeInOneLayer> show could shape be
0158   //! in number of layers or only in one.
0159   //! return FALSE if no such shape <Sh> or label <LayerL>
0160   Standard_EXPORT bool SetLayer(const TopoDS_Shape& Sh,
0161                                 const TDF_Label&    LayerL,
0162                                 const bool          shapeInOneLayer = false);
0163 
0164   //! Sets a link from label that containing shape <Sh>
0165   //! with layer <aLayer>. Add <aLayer> to LayerTable if nessesery.
0166   //! optional parameter <shapeInOneLayer> show could shape be
0167   //! in number of layers or only in one.
0168   //! return FALSE if no such shape <Sh>.
0169   Standard_EXPORT bool SetLayer(const TopoDS_Shape&               Sh,
0170                                 const TCollection_ExtendedString& aLayer,
0171                                 const bool                        shapeInOneLayer = false);
0172 
0173   //! Remove link between shape <Sh> and all Layers at LayerTable.
0174   //! return FALSE if no such shape <Sh> in XCAF Document.
0175   Standard_EXPORT bool UnSetLayers(const TopoDS_Shape& Sh);
0176 
0177   //! Remove link between shape <Sh> and layer <aLayer>.
0178   //! returns FALSE if no such layer <aLayer> or shape <Sh>.
0179   Standard_EXPORT bool UnSetOneLayer(const TopoDS_Shape&               Sh,
0180                                      const TCollection_ExtendedString& aLayer);
0181 
0182   //! Remove link between shape <Sh> and layer <aLayerL>.
0183   //! returns FALSE if no such layer <aLayerL> or shape <Sh>.
0184   Standard_EXPORT bool UnSetOneLayer(const TopoDS_Shape& Sh, const TDF_Label& aLayerL);
0185 
0186   //! Returns True if shape <Sh> has a Layer associated
0187   //! with the <aLayer>.
0188   Standard_EXPORT bool IsSet(const TopoDS_Shape& Sh, const TCollection_ExtendedString& aLayer);
0189 
0190   //! Returns True if shape <Sh> has a Layer associated
0191   //! with the <aLayerL>.
0192   Standard_EXPORT bool IsSet(const TopoDS_Shape& Sh, const TDF_Label& aLayerL);
0193 
0194   //! Return sequence of strings <aLayerS> that associated with shape <Sh>.
0195   Standard_EXPORT bool GetLayers(
0196     const TopoDS_Shape&                                             Sh,
0197     occ::handle<NCollection_HSequence<TCollection_ExtendedString>>& aLayerS);
0198 
0199   //! Return sequence of labels <aLayerLS> that associated with shape <Sh>.
0200   Standard_EXPORT bool GetLayers(const TopoDS_Shape& Sh, NCollection_Sequence<TDF_Label>& aLayerLS);
0201 
0202   //! Return sequence of strings that associated with shape <Sh>.
0203   Standard_EXPORT occ::handle<NCollection_HSequence<TCollection_ExtendedString>> GetLayers(
0204     const TopoDS_Shape& Sh);
0205 
0206   Standard_EXPORT const Standard_GUID& ID() const override;
0207 
0208   //! Dumps the content of me into the stream
0209   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const override;
0210 
0211   DEFINE_DERIVED_ATTRIBUTE(XCAFDoc_LayerTool, TDataStd_GenericEmpty)
0212 
0213 private:
0214   occ::handle<XCAFDoc_ShapeTool> myShapeTool;
0215 };
0216 
0217 #endif // _XCAFDoc_LayerTool_HeaderFile