|
|
|||
File indexing completed on 2026-09-16 09:19:09
0001 // Created on: 2000-05-11 0002 // Created by: Edward AGAPOV 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_ColorTool_HeaderFile 0017 #define _XCAFDoc_ColorTool_HeaderFile 0018 0019 #include <Standard.hxx> 0020 #include <Standard_Type.hxx> 0021 0022 #include <TDataStd_GenericEmpty.hxx> 0023 #include <Standard_Boolean.hxx> 0024 #include <TDF_Label.hxx> 0025 #include <NCollection_Sequence.hxx> 0026 #include <XCAFDoc_ColorType.hxx> 0027 class XCAFDoc_ShapeTool; 0028 class TDF_Label; 0029 class Standard_GUID; 0030 class Quantity_Color; 0031 class Quantity_ColorRGBA; 0032 class TopoDS_Shape; 0033 0034 //! Provides tools to store and retrieve attributes (colors) 0035 //! of TopoDS_Shape in and from TDocStd_Document 0036 //! A Document is intended to hold different 0037 //! attributes of ONE shape and it's sub-shapes 0038 //! Provide tools for management of Colors section of document. 0039 class XCAFDoc_ColorTool : public TDataStd_GenericEmpty 0040 { 0041 public: 0042 //! Returns current auto-naming mode; TRUE by default. 0043 //! If TRUE then for added colors the TDataStd_Name attribute will be automatically added. 0044 //! This setting is global. 0045 Standard_EXPORT static bool AutoNaming(); 0046 0047 //! See also AutoNaming(). 0048 Standard_EXPORT static void SetAutoNaming(bool theIsAutoNaming); 0049 0050 public: 0051 Standard_EXPORT XCAFDoc_ColorTool(); 0052 0053 //! Creates (if not exist) ColorTool. 0054 Standard_EXPORT static occ::handle<XCAFDoc_ColorTool> Set(const TDF_Label& L); 0055 0056 Standard_EXPORT static const Standard_GUID& GetID(); 0057 0058 //! returns the label under which colors are stored 0059 Standard_EXPORT TDF_Label BaseLabel() const; 0060 0061 //! Returns internal XCAFDoc_ShapeTool tool 0062 Standard_EXPORT const occ::handle<XCAFDoc_ShapeTool>& ShapeTool(); 0063 0064 //! Returns True if label belongs to a colortable and 0065 //! is a color definition 0066 Standard_EXPORT bool IsColor(const TDF_Label& lab) const; 0067 0068 //! Returns color defined by label lab 0069 //! Returns False if the label is not in colortable 0070 //! or does not define a color 0071 Standard_EXPORT static bool GetColor(const TDF_Label& lab, Quantity_Color& col); 0072 0073 //! Returns color defined by label lab 0074 //! Returns False if the label is not in colortable 0075 //! or does not define a color 0076 Standard_EXPORT static bool GetColor(const TDF_Label& lab, Quantity_ColorRGBA& col); 0077 0078 //! Finds a color definition in a colortable and returns 0079 //! its label if found 0080 //! Returns False if color is not found in colortable 0081 Standard_EXPORT bool FindColor(const Quantity_Color& col, TDF_Label& lab) const; 0082 0083 //! Finds a color definition in a colortable and returns 0084 //! its label if found 0085 //! Returns False if color is not found in colortable 0086 Standard_EXPORT bool FindColor(const Quantity_ColorRGBA& col, TDF_Label& lab) const; 0087 0088 //! Finds a color definition in a colortable and returns 0089 //! its label if found (or Null label else) 0090 Standard_EXPORT TDF_Label FindColor(const Quantity_Color& col) const; 0091 0092 //! Finds a color definition in a colortable and returns 0093 //! its label if found (or Null label else) 0094 Standard_EXPORT TDF_Label FindColor(const Quantity_ColorRGBA& col) const; 0095 0096 //! Adds a color definition to a colortable and returns 0097 //! its label (returns existing label if the same color 0098 //! is already defined) 0099 Standard_EXPORT TDF_Label AddColor(const Quantity_Color& col) const; 0100 0101 //! Adds a color definition to a colortable and returns 0102 //! its label (returns existing label if the same color 0103 //! is already defined) 0104 Standard_EXPORT TDF_Label AddColor(const Quantity_ColorRGBA& col) const; 0105 0106 //! Removes color from the colortable 0107 Standard_EXPORT void RemoveColor(const TDF_Label& lab) const; 0108 0109 //! Returns a sequence of colors currently stored 0110 //! in the colortable 0111 Standard_EXPORT void GetColors(NCollection_Sequence<TDF_Label>& Labels) const; 0112 0113 //! Sets a link with GUID defined by <type> (see 0114 //! XCAFDoc::ColorRefGUID()) from label <L> to color 0115 //! defined by <colorL>. Color of shape is defined following way 0116 //! in dependance with type of color. 0117 //! If type of color is XCAFDoc_ColorGen - then this color 0118 //! defines default color for surfaces and curves. 0119 //! If for shape color with types XCAFDoc_ColorSurf or XCAFDoc_ColorCurv is specified 0120 //! then such color overrides generic color. 0121 Standard_EXPORT void SetColor(const TDF_Label& L, 0122 const TDF_Label& colorL, 0123 const XCAFDoc_ColorType type) const; 0124 0125 //! Sets a link with GUID defined by <type> (see 0126 //! XCAFDoc::ColorRefGUID()) from label <L> to color <Color> 0127 //! in the colortable 0128 //! Adds a color as necessary 0129 Standard_EXPORT void SetColor(const TDF_Label& L, 0130 const Quantity_Color& Color, 0131 const XCAFDoc_ColorType type) const; 0132 0133 //! Sets a link with GUID defined by <type> (see 0134 //! XCAFDoc::ColorRefGUID()) from label <L> to color <Color> 0135 //! in the colortable 0136 //! Adds a color as necessary 0137 Standard_EXPORT void SetColor(const TDF_Label& L, 0138 const Quantity_ColorRGBA& Color, 0139 const XCAFDoc_ColorType type) const; 0140 0141 //! Removes a link with GUID defined by <type> (see 0142 //! XCAFDoc::ColorRefGUID()) from label <L> to color 0143 Standard_EXPORT void UnSetColor(const TDF_Label& L, const XCAFDoc_ColorType type) const; 0144 0145 //! Returns True if label <L> has a color assignment 0146 //! of the type <type> 0147 Standard_EXPORT bool IsSet(const TDF_Label& L, const XCAFDoc_ColorType type) const; 0148 0149 //! Returns label with color assigned to <L> as <type> 0150 //! Returns False if no such color is assigned 0151 Standard_EXPORT static bool GetColor(const TDF_Label& L, 0152 const XCAFDoc_ColorType type, 0153 TDF_Label& colorL); 0154 0155 //! Returns color assigned to <L> as <type> 0156 //! Returns False if no such color is assigned 0157 Standard_EXPORT static bool GetColor(const TDF_Label& L, 0158 const XCAFDoc_ColorType type, 0159 Quantity_Color& color); 0160 0161 //! Returns color assigned to <L> as <type> 0162 //! Returns False if no such color is assigned 0163 Standard_EXPORT static bool GetColor(const TDF_Label& L, 0164 const XCAFDoc_ColorType type, 0165 Quantity_ColorRGBA& color); 0166 0167 //! Sets a link with GUID defined by <type> (see 0168 //! XCAFDoc::ColorRefGUID()) from label <L> to color 0169 //! defined by <colorL> 0170 //! Returns False if cannot find a label for shape S 0171 Standard_EXPORT bool SetColor(const TopoDS_Shape& S, 0172 const TDF_Label& colorL, 0173 const XCAFDoc_ColorType type); 0174 0175 //! Sets a link with GUID defined by <type> (see 0176 //! XCAFDoc::ColorRefGUID()) from label <L> to color <Color> 0177 //! in the colortable 0178 //! Adds a color as necessary 0179 //! Returns False if cannot find a label for shape S 0180 Standard_EXPORT bool SetColor(const TopoDS_Shape& S, 0181 const Quantity_Color& Color, 0182 const XCAFDoc_ColorType type); 0183 0184 //! Sets a link with GUID defined by <type> (see 0185 //! XCAFDoc::ColorRefGUID()) from label <L> to color <Color> 0186 //! in the colortable 0187 //! Adds a color as necessary 0188 //! Returns False if cannot find a label for shape S 0189 Standard_EXPORT bool SetColor(const TopoDS_Shape& S, 0190 const Quantity_ColorRGBA& Color, 0191 const XCAFDoc_ColorType type); 0192 0193 //! Removes a link with GUID defined by <type> (see 0194 //! XCAFDoc::ColorRefGUID()) from label <L> to color 0195 //! Returns True if such link existed 0196 Standard_EXPORT bool UnSetColor(const TopoDS_Shape& S, const XCAFDoc_ColorType type); 0197 0198 //! Returns True if label <L> has a color assignment 0199 //! of the type <type> 0200 Standard_EXPORT bool IsSet(const TopoDS_Shape& S, const XCAFDoc_ColorType type); 0201 0202 //! Returns label with color assigned to <L> as <type> 0203 //! Returns False if no such color is assigned 0204 Standard_EXPORT bool GetColor(const TopoDS_Shape& S, 0205 const XCAFDoc_ColorType type, 0206 TDF_Label& colorL); 0207 0208 //! Returns color assigned to <L> as <type> 0209 //! Returns False if no such color is assigned 0210 Standard_EXPORT bool GetColor(const TopoDS_Shape& S, 0211 const XCAFDoc_ColorType type, 0212 Quantity_Color& color); 0213 0214 //! Returns color assigned to <L> as <type> 0215 //! Returns False if no such color is assigned 0216 Standard_EXPORT bool GetColor(const TopoDS_Shape& S, 0217 const XCAFDoc_ColorType type, 0218 Quantity_ColorRGBA& color); 0219 0220 //! Return TRUE if object on this label is visible, FALSE if invisible. 0221 Standard_EXPORT static bool IsVisible(const TDF_Label& L); 0222 0223 //! Set the visibility of object on label. Do nothing if there no any object. 0224 //! Set UAttribute with corresponding GUID. 0225 Standard_EXPORT void SetVisibility(const TDF_Label& shapeLabel, const bool isvisible = true); 0226 0227 //! Return TRUE if object color defined by its Layer, FALSE if not. 0228 Standard_EXPORT bool IsColorByLayer(const TDF_Label& L) const; 0229 0230 //! Set the Color defined by Layer flag on label. Do nothing if there no any object. 0231 //! Set UAttribute with corresponding GUID. 0232 Standard_EXPORT void SetColorByLayer(const TDF_Label& shapeLabel, 0233 const bool isColorByLayer = false); 0234 0235 //! Sets the color of component that styled with SHUO structure 0236 //! Returns FALSE if no sush component found 0237 //! NOTE: create SHUO structeure if it is necessary and if <isCreateSHUO> 0238 Standard_EXPORT bool SetInstanceColor(const TopoDS_Shape& theShape, 0239 const XCAFDoc_ColorType type, 0240 const Quantity_Color& color, 0241 const bool isCreateSHUO = true); 0242 0243 //! Sets the color of component that styled with SHUO structure 0244 //! Returns FALSE if no sush component found 0245 //! NOTE: create SHUO structeure if it is necessary and if <isCreateSHUO> 0246 Standard_EXPORT bool SetInstanceColor(const TopoDS_Shape& theShape, 0247 const XCAFDoc_ColorType type, 0248 const Quantity_ColorRGBA& color, 0249 const bool isCreateSHUO = true); 0250 0251 //! Gets the color of component that styled with SHUO structure 0252 //! Returns FALSE if no sush component or color type 0253 Standard_EXPORT bool GetInstanceColor(const TopoDS_Shape& theShape, 0254 const XCAFDoc_ColorType type, 0255 Quantity_Color& color); 0256 0257 //! Gets the color of component that styled with SHUO structure 0258 //! Returns FALSE if no sush component or color type 0259 Standard_EXPORT bool GetInstanceColor(const TopoDS_Shape& theShape, 0260 const XCAFDoc_ColorType type, 0261 Quantity_ColorRGBA& color); 0262 0263 //! Gets the visibility status of component that styled with SHUO structure 0264 //! Returns FALSE if no sush component 0265 Standard_EXPORT bool IsInstanceVisible(const TopoDS_Shape& theShape); 0266 0267 //! Reverses order in chains of TreeNodes (from Last to First) under 0268 //! each Color Label since we became to use function ::Prepend() 0269 //! instead of ::Append() in method SetColor() for acceleration 0270 Standard_EXPORT bool ReverseChainsOfTreeNodes(); 0271 0272 Standard_EXPORT const Standard_GUID& ID() const override; 0273 0274 //! Dumps the content of me into the stream 0275 Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const override; 0276 0277 DEFINE_DERIVED_ATTRIBUTE(XCAFDoc_ColorTool, TDataStd_GenericEmpty) 0278 0279 private: 0280 occ::handle<XCAFDoc_ShapeTool> myShapeTool; 0281 }; 0282 0283 #endif // _XCAFDoc_ColorTool_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|