0032308: Configuration - make Xlib dependency optional
[occt.git] / src / AIS / AIS_ExclusionFilter.hxx
1 // Created on: 1997-11-28
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _AIS_ExclusionFilter_HeaderFile
18 #define _AIS_ExclusionFilter_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <Standard_Boolean.hxx>
24 #include <TColStd_DataMapOfIntegerListOfInteger.hxx>
25 #include <SelectMgr_Filter.hxx>
26 #include <AIS_KindOfInteractive.hxx>
27 #include <Standard_Integer.hxx>
28 #include <TColStd_ListOfInteger.hxx>
29 class SelectMgr_EntityOwner;
30
31 class AIS_ExclusionFilter;
32 DEFINE_STANDARD_HANDLE(AIS_ExclusionFilter, SelectMgr_Filter)
33
34 //! A framework to reject or to accept only objects of
35 //! given types and/or signatures.
36 //! Objects are stored, and the stored objects - along
37 //! with the flag settings - are used to define the filter.
38 //! Objects to be filtered are compared with the stored
39 //! objects added to the filter, and are accepted or
40 //! rejected according to the exclusion flag setting.
41 //! -   Exclusion flag on
42 //! -   the function IsOk answers true for all objects,
43 //! except those of the types and signatures stored
44 //! in the filter framework
45 //! -   Exclusion flag off
46 //! -   the funciton IsOk answers true for all objects
47 //! which have the same type and signature as the stored ones.
48 class AIS_ExclusionFilter : public SelectMgr_Filter
49 {
50
51 public:
52
53   
54   //! Constructs an empty exclusion filter object defined by
55   //! the flag setting ExclusionFlagOn.
56   //! By default, the flag is set to true.
57   Standard_EXPORT AIS_ExclusionFilter(const Standard_Boolean ExclusionFlagOn = Standard_True);
58   
59   //! All the AIS objects of <TypeToExclude>
60   //! Will be rejected by the IsOk Method.
61   Standard_EXPORT AIS_ExclusionFilter(const AIS_KindOfInteractive TypeToExclude, const Standard_Boolean ExclusionFlagOn = Standard_True);
62   
63   //! Constructs an exclusion filter object defined by the
64   //! enumeration value TypeToExclude, the signature
65   //! SignatureInType, and the flag setting ExclusionFlagOn.
66   //! By default, the flag is set to true.
67   Standard_EXPORT AIS_ExclusionFilter(const AIS_KindOfInteractive TypeToExclude, const Standard_Integer SignatureInType, const Standard_Boolean ExclusionFlagOn = Standard_True);
68   
69   Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& anObj) const Standard_OVERRIDE;
70   
71   //! Adds the type TypeToExclude to the list of types.
72   Standard_EXPORT Standard_Boolean Add (const AIS_KindOfInteractive TypeToExclude);
73   
74   Standard_EXPORT Standard_Boolean Add (const AIS_KindOfInteractive TypeToExclude, const Standard_Integer SignatureInType);
75   
76   Standard_EXPORT Standard_Boolean Remove (const AIS_KindOfInteractive TypeToExclude);
77   
78   Standard_EXPORT Standard_Boolean Remove (const AIS_KindOfInteractive TypeToExclude, const Standard_Integer SignatureInType);
79   
80   Standard_EXPORT void Clear();
81
82   Standard_Boolean IsExclusionFlagOn() const { return myIsExclusionFlagOn; }
83
84   void SetExclusionFlag (const Standard_Boolean theStatus) { myIsExclusionFlagOn = theStatus; }
85
86   Standard_EXPORT Standard_Boolean IsStored (const AIS_KindOfInteractive aType) const;
87   
88   Standard_EXPORT void ListOfStoredTypes (TColStd_ListOfInteger& TheList) const;
89   
90   Standard_EXPORT void ListOfSignature (const AIS_KindOfInteractive aType, TColStd_ListOfInteger& TheStoredList) const;
91
92   DEFINE_STANDARD_RTTIEXT(AIS_ExclusionFilter,SelectMgr_Filter)
93
94 private:
95
96   Standard_EXPORT Standard_Boolean IsSignatureIn (const AIS_KindOfInteractive aType, const Standard_Integer aSignature) const;
97
98   Standard_Boolean myIsExclusionFlagOn;
99   TColStd_DataMapOfIntegerListOfInteger myStoredTypes;
100
101 };
102
103 #endif // _AIS_ExclusionFilter_HeaderFile