0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / TDF / TDF_IDFilter.hxx
1 // Created by: DAUTRY Philippe
2 // Copyright (c) 1997-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _TDF_IDFilter_HeaderFile
17 #define _TDF_IDFilter_HeaderFile
18
19 #include <Standard.hxx>
20 #include <Standard_DefineAlloc.hxx>
21 #include <Standard_Handle.hxx>
22
23 #include <Standard_Boolean.hxx>
24 #include <TDF_IDMap.hxx>
25 #include <TDF_IDList.hxx>
26 #include <Standard_OStream.hxx>
27 class Standard_GUID;
28 class TDF_Attribute;
29
30
31 //! This class offers filtering services around an ID list.
32 class TDF_IDFilter 
33 {
34 public:
35
36   DEFINE_STANDARD_ALLOC
37
38   
39   //! Creates an ID/attribute filter based on an ID
40   //! list. The default mode is "ignore all but...".
41   //!
42   //! This filter has 2 working mode: keep and ignore.
43   //!
44   //! Ignore/Exclusive mode: all IDs are ignored except
45   //! these set to be kept, using Keep(). Of course, it
46   //! is possible set an kept ID to be ignored using
47   //! Ignore().
48   //!
49   //! Keep/Inclusive mode: all IDs are kept except these
50   //! set to be ignored, using Ignore(). Of course, it
51   //! is possible set an ignored ID to be kept using
52   //! Keep().
53   Standard_EXPORT TDF_IDFilter(const Standard_Boolean ignoreMode = Standard_True);
54   
55   //! The list of ID is cleared and the filter mode is
56   //! set to ignore mode if <keep> is true; false
57   //! otherwise.
58   Standard_EXPORT void IgnoreAll (const Standard_Boolean ignore);
59   
60   //! Returns true is the mode is set to "ignore all
61   //! but...".
62     Standard_Boolean IgnoreAll() const;
63   
64   //! An attribute with <anID> as ID is to be kept and
65   //! the filter will answer true to the question
66   //! IsKept(<anID>).
67   Standard_EXPORT void Keep (const Standard_GUID& anID);
68   
69   //! Attributes with ID owned by <anIDList> are to be kept and
70   //! the filter will answer true to the question
71   //! IsKept(<anID>) with ID from <anIDList>.
72   Standard_EXPORT void Keep (const TDF_IDList& anIDList);
73   
74   //! An attribute with <anID> as ID is to be ignored and
75   //! the filter will answer false to the question
76   //! IsKept(<anID>).
77   Standard_EXPORT void Ignore (const Standard_GUID& anID);
78   
79   //! Attributes with ID owned by <anIDList> are to be
80   //! ignored and the filter will answer false to the
81   //! question IsKept(<anID>) with ID from <anIDList>.
82   Standard_EXPORT void Ignore (const TDF_IDList& anIDList);
83   
84   //! Returns true if the ID is to be kept.
85     Standard_Boolean IsKept (const Standard_GUID& anID) const;
86   
87   //! Returns true if the attribute is to be kept.
88     Standard_Boolean IsKept (const Handle(TDF_Attribute)& anAtt) const;
89   
90   //! Returns true if the ID is to be ignored.
91     Standard_Boolean IsIgnored (const Standard_GUID& anID) const;
92   
93   //! Returns true if the attribute is to be ignored.
94     Standard_Boolean IsIgnored (const Handle(TDF_Attribute)& anAtt) const;
95   
96   //! Copies the list of ID to be kept or ignored in
97   //! <anIDList>. <anIDList> is cleared before use.
98   Standard_EXPORT void IDList (TDF_IDList& anIDList) const;
99   
100   //! Copies into <me> the contents of
101   //! <fromFilter>. <me> is cleared before copy.
102   Standard_EXPORT void Copy (const TDF_IDFilter& fromFilter);
103   
104   //! Writes the contents of <me> to <OS>.
105   Standard_EXPORT void Dump (Standard_OStream& anOS) const;
106
107   //! Assignment
108   void Assign (const TDF_IDFilter& theFilter)
109   {
110     myIgnore = theFilter.myIgnore;
111     myIDMap  = theFilter.myIDMap;
112   }
113
114 private:
115
116   //! Private, to forbid implicit or hidden accesses to
117   //! the copy constructor.
118   TDF_IDFilter(const TDF_IDFilter& aFilter);
119   TDF_IDFilter& operator= (const TDF_IDFilter& theOther);
120
121 private:
122
123   Standard_Boolean myIgnore;
124   TDF_IDMap myIDMap;
125
126 };
127
128
129 #include <TDF_IDFilter.lxx>
130
131
132
133
134
135 #endif // _TDF_IDFilter_HeaderFile