Back to home page

EIC code displayed by LXR

 
 

    


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

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_LabelSequence.hxx>
0024 #include <TColStd_HSequenceOfExtendedString.hxx>
0025 class XCAFDoc_ShapeTool;
0026 class TDF_Label;
0027 class Standard_GUID;
0028 class TCollection_ExtendedString;
0029 class TopoDS_Shape;
0030 
0031 
0032 class XCAFDoc_LayerTool;
0033 DEFINE_STANDARD_HANDLE(XCAFDoc_LayerTool, TDataStd_GenericEmpty)
0034 
0035 //! Provides tools to store and retrieve attributes (Layers)
0036 //! of TopoDS_Shape in and from TDocStd_Document
0037 //! A Document is intended to hold different
0038 //! attributes of ONE shape and it's sub-shapes
0039 //! Provide tools for management of Layers section of document.
0040 class XCAFDoc_LayerTool : public TDataStd_GenericEmpty
0041 {
0042 
0043 public:
0044 
0045   
0046   Standard_EXPORT XCAFDoc_LayerTool();
0047   
0048   //! Creates (if not exist) LayerTool.
0049   Standard_EXPORT static Handle(XCAFDoc_LayerTool) Set (const TDF_Label& L);
0050   
0051   Standard_EXPORT static const Standard_GUID& GetID();
0052   
0053   //! returns the label under which Layers are stored
0054   Standard_EXPORT TDF_Label BaseLabel() const;
0055   
0056   //! Returns internal XCAFDoc_ShapeTool tool
0057   Standard_EXPORT const Handle(XCAFDoc_ShapeTool)& ShapeTool();
0058   
0059   //! Returns True if label belongs to a Layertable and
0060   //! is a Layer definition
0061   Standard_EXPORT Standard_Boolean IsLayer (const TDF_Label& lab) const;
0062   
0063   //! Returns Layer defined by label lab
0064   //! Returns False if the label is not in Layertable
0065   //! or does not define a Layer
0066   Standard_EXPORT Standard_Boolean GetLayer (const TDF_Label& lab, TCollection_ExtendedString& aLayer) const;
0067   
0068   //! Finds a Layer definition in a Layertable and returns
0069   //! its label if found
0070   //! Returns False if Layer is not found in Layertable
0071   Standard_EXPORT Standard_Boolean FindLayer (const TCollection_ExtendedString& aLayer, TDF_Label& lab) const;
0072   
0073   //! Finds a Layer definition in a Layertable by name
0074   //! Returns first founded label with the same name if <theToFindWithProperty> is false
0075   //! If <theToFindWithProperty> is true returns first label that
0076   //! contains or not contains visible attr, according to the <theToFindVisible> parameter
0077   Standard_EXPORT TDF_Label FindLayer (const TCollection_ExtendedString& aLayer, const Standard_Boolean theToFindWithProperty = Standard_False, const Standard_Boolean theToFindVisible = Standard_True) const;
0078   
0079   //! Adds a Layer definition to a Layertable and returns
0080   //! its label (returns existing label if the same Layer
0081   //! is already defined)
0082   Standard_EXPORT TDF_Label AddLayer (const TCollection_ExtendedString& theLayer) const;
0083 
0084   //! Adds a Layer definition to a Layertable and returns its label
0085   //! Returns existing label (if it is already defined)
0086   //! of visible or invisible layer, according to <theToFindVisible> parameter
0087   Standard_EXPORT TDF_Label AddLayer(const TCollection_ExtendedString& theLayer, const Standard_Boolean theToFindVisible) const;
0088   
0089   //! Removes Layer from the Layertable
0090   Standard_EXPORT void RemoveLayer (const TDF_Label& lab) const;
0091   
0092   //! Returns a sequence of Layers currently stored
0093   //! in the Layertable
0094   Standard_EXPORT void GetLayerLabels (TDF_LabelSequence& Labels) const;
0095   
0096   //! Sets a link from label <L> to Layer
0097   //! defined by <LayerL>
0098   //! optional parameter <shapeInOneLayer> show could shape be
0099   //! in number of layers or only in one.
0100   Standard_EXPORT void SetLayer (const TDF_Label& L, const TDF_Label& LayerL, const Standard_Boolean shapeInOneLayer = Standard_False) const;
0101   
0102   //! Sets a link from label <L> to Layer <aLayer>
0103   //! in the Layertable
0104   //! Adds a Layer as necessary
0105   //! optional parameter <shapeInOneLayer> show could shape be
0106   //! in number of layers or only in one.
0107   Standard_EXPORT void SetLayer (const TDF_Label& L, const TCollection_ExtendedString& aLayer, const Standard_Boolean shapeInOneLayer = Standard_False) const;
0108   
0109   //! Removes a link from label <L> to all layers
0110   Standard_EXPORT void UnSetLayers (const TDF_Label& L) const;
0111   
0112   //! Remove link from label <L> and Layer <aLayer>.
0113   //! returns FALSE if no such layer.
0114   Standard_EXPORT Standard_Boolean UnSetOneLayer (const TDF_Label& L, const TCollection_ExtendedString& aLayer) const;
0115   
0116   //! Remove link from label <L> and Layer <aLayerL>.
0117   //! returns FALSE if <aLayerL> is not a layer label.
0118   Standard_EXPORT Standard_Boolean UnSetOneLayer (const TDF_Label& L, const TDF_Label& aLayerL) const;
0119   
0120   //! Returns True if label <L> has a Layer associated
0121   //! with the <aLayer>.
0122   Standard_EXPORT Standard_Boolean IsSet (const TDF_Label& L, const TCollection_ExtendedString& aLayer) const;
0123   
0124   //! Returns True if label <L> has a Layer associated
0125   //! with the <aLayerL> label.
0126   Standard_EXPORT Standard_Boolean IsSet (const TDF_Label& L, const TDF_Label& aLayerL) const;
0127   
0128   //! Return sequence of strings <aLayerS> that associated with label <L>.
0129   Standard_EXPORT Standard_Boolean GetLayers (const TDF_Label& L, Handle(TColStd_HSequenceOfExtendedString)& aLayerS);
0130   
0131   //! Return sequence of labels <aLayerSL> that associated with label <L>.
0132   Standard_EXPORT Standard_Boolean GetLayers (const TDF_Label& L, TDF_LabelSequence& aLayerLS);
0133   
0134   //! Return sequence of strings that associated with label <L>.
0135   Standard_EXPORT Handle(TColStd_HSequenceOfExtendedString) GetLayers (const TDF_Label& L);
0136   
0137   //! Return sequanese of shape labels that assigned with layers to <ShLabels>.
0138   Standard_EXPORT static void GetShapesOfLayer (const TDF_Label& theLayerL, TDF_LabelSequence& theShLabels);
0139   
0140   //! Return TRUE if layer is visible, FALSE if invisible.
0141   Standard_EXPORT Standard_Boolean IsVisible (const TDF_Label& layerL) const;
0142   
0143   //! Set the visibility of layer. If layer is invisible when on it's layer
0144   //! will set UAttribute with corresponding GUID.
0145   Standard_EXPORT void SetVisibility (const TDF_Label& layerL, const Standard_Boolean isvisible = Standard_True) const;
0146   
0147   //! Sets a link from label that containing shape <Sh>
0148   //! with layer that situated at label <LayerL>.
0149   //! optional parameter <shapeInOneLayer> show could shape be
0150   //! in number of layers or only in one.
0151   //! return FALSE if no such shape <Sh> or label <LayerL>
0152   Standard_EXPORT Standard_Boolean SetLayer (const TopoDS_Shape& Sh, const TDF_Label& LayerL, const Standard_Boolean shapeInOneLayer = Standard_False);
0153   
0154   //! Sets a link from label that containing shape <Sh>
0155   //! with layer <aLayer>. Add <aLayer> to LayerTable if nessesery.
0156   //! optional parameter <shapeInOneLayer> show could shape be
0157   //! in number of layers or only in one.
0158   //! return FALSE if no such shape <Sh>.
0159   Standard_EXPORT Standard_Boolean SetLayer (const TopoDS_Shape& Sh, const TCollection_ExtendedString& aLayer, const Standard_Boolean shapeInOneLayer = Standard_False);
0160   
0161   //! Remove link between shape <Sh> and all Layers at LayerTable.
0162   //! return FALSE if no such shape <Sh> in XCAF Document.
0163   Standard_EXPORT Standard_Boolean UnSetLayers (const TopoDS_Shape& Sh);
0164   
0165   //! Remove link between shape <Sh> and layer <aLayer>.
0166   //! returns FALSE if no such layer <aLayer> or shape <Sh>.
0167   Standard_EXPORT Standard_Boolean UnSetOneLayer (const TopoDS_Shape& Sh, const TCollection_ExtendedString& aLayer);
0168   
0169   //! Remove link between shape <Sh> and layer <aLayerL>.
0170   //! returns FALSE if no such layer <aLayerL> or shape <Sh>.
0171   Standard_EXPORT Standard_Boolean UnSetOneLayer (const TopoDS_Shape& Sh, const TDF_Label& aLayerL);
0172   
0173   //! Returns True if shape <Sh> has a Layer associated
0174   //! with the <aLayer>.
0175   Standard_EXPORT Standard_Boolean IsSet (const TopoDS_Shape& Sh, const TCollection_ExtendedString& aLayer);
0176   
0177   //! Returns True if shape <Sh> has a Layer associated
0178   //! with the <aLayerL>.
0179   Standard_EXPORT Standard_Boolean IsSet (const TopoDS_Shape& Sh, const TDF_Label& aLayerL);
0180   
0181   //! Return sequence of strings <aLayerS> that associated with shape <Sh>.
0182   Standard_EXPORT Standard_Boolean GetLayers (const TopoDS_Shape& Sh, Handle(TColStd_HSequenceOfExtendedString)& aLayerS);
0183   
0184   //! Return sequence of labels <aLayerLS> that associated with shape <Sh>.
0185   Standard_EXPORT Standard_Boolean GetLayers (const TopoDS_Shape& Sh, TDF_LabelSequence& aLayerLS);
0186   
0187   //! Return sequence of strings that associated with shape <Sh>.
0188   Standard_EXPORT Handle(TColStd_HSequenceOfExtendedString) GetLayers (const TopoDS_Shape& Sh);
0189   
0190   Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
0191 
0192   //! Dumps the content of me into the stream
0193   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0194 
0195 
0196   DEFINE_DERIVED_ATTRIBUTE(XCAFDoc_LayerTool,TDataStd_GenericEmpty)
0197 
0198 
0199 private:
0200 
0201 
0202   Handle(XCAFDoc_ShapeTool) myShapeTool;
0203 
0204 
0205 };
0206 
0207 
0208 
0209 
0210 
0211 
0212 
0213 #endif // _XCAFDoc_LayerTool_HeaderFile