42cf5bc1 |
1 | // Created on: 1994-11-07 |
2 | // Created by: Christian CAILLET |
3 | // Copyright (c) 1994-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 _IFSelect_SignCounter_HeaderFile |
18 | #define _IFSelect_SignCounter_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
23 | #include <Standard_Boolean.hxx> |
24 | #include <TColStd_MapOfTransient.hxx> |
25 | #include <Standard_Integer.hxx> |
26 | #include <IFSelect_SignatureList.hxx> |
27 | #include <TColStd_HSequenceOfTransient.hxx> |
28 | #include <Standard_CString.hxx> |
29 | class IFSelect_Signature; |
30 | class IFSelect_Selection; |
31 | class Standard_Transient; |
32 | class Interface_InterfaceModel; |
33 | class Interface_Graph; |
34 | class TCollection_HAsciiString; |
35 | |
36 | |
37 | class IFSelect_SignCounter; |
38 | DEFINE_STANDARD_HANDLE(IFSelect_SignCounter, IFSelect_SignatureList) |
39 | |
40 | //! SignCounter gives the frame to count signatures associated |
41 | //! with entities, deducted from them. Ex.: their Dynamic Type. |
42 | //! |
43 | //! It can sort a set of Entities according a signature, i.e. : |
44 | //! - list of different values found for this Signature |
45 | //! - for each one, count and list of entities |
46 | //! Results are returned as a SignatureList, which can be queried |
47 | //! on the count (list of strings, count per signature, or list of |
48 | //! entities per signature) |
49 | //! |
50 | //! A SignCounter can be filled, either directly from lists, or |
51 | //! from the result of a Selection : hence, its content can be |
52 | //! automatically recomputed as desired |
53 | //! |
54 | //! SignCounter works by using a Signature in its method AddSign |
55 | //! |
56 | //! Methods can be redefined to, either |
57 | //! - directly compute the value without a Signature |
58 | //! - compute the value in the context of a Graph |
59 | class IFSelect_SignCounter : public IFSelect_SignatureList |
60 | { |
61 | |
62 | public: |
63 | |
64 | |
65 | //! Creates a SignCounter, without proper Signature |
66 | //! If <withmap> is True (default), added entities are counted |
67 | //! only if they are not yet recorded in the map |
68 | //! Map control can be set off if the input garantees uniqueness |
69 | //! of data |
70 | //! <withlist> is transmitted to SignatureList (option to list |
71 | //! entities, not only to count them). |
72 | Standard_EXPORT IFSelect_SignCounter(const Standard_Boolean withmap = Standard_True, const Standard_Boolean withlist = Standard_False); |
73 | |
74 | //! Creates a SignCounter, with a predefined Signature |
75 | //! Other arguments as for Create without Signature. |
76 | Standard_EXPORT IFSelect_SignCounter(const Handle(IFSelect_Signature)& matcher, const Standard_Boolean withmap = Standard_True, const Standard_Boolean withlist = Standard_False); |
77 | |
78 | //! Returns the Signature used to count entities. It can be null. |
79 | Standard_EXPORT Handle(IFSelect_Signature) Signature() const; |
80 | |
81 | //! Changes the control status. The map is not cleared, simply |
82 | //! its use changes |
83 | Standard_EXPORT void SetMap (const Standard_Boolean withmap); |
84 | |
85 | //! Adds an entity by considering its signature, which is given by |
86 | //! call to method AddSign |
87 | //! Returns True if added, False if already in the map (and |
88 | //! map control status set) |
89 | Standard_EXPORT virtual Standard_Boolean AddEntity (const Handle(Standard_Transient)& ent, const Handle(Interface_InterfaceModel)& model); |
90 | |
91 | //! Adds an entity (already filtered by Map) with its signature. |
92 | //! This signature can be computed with the containing model. |
93 | //! Its value is provided by the object Signature given at start, |
94 | //! if no Signature is defined, it does nothing. |
95 | //! |
96 | //! Can be redefined (in this case, see also Sign) |
97 | Standard_EXPORT virtual void AddSign (const Handle(Standard_Transient)& ent, const Handle(Interface_InterfaceModel)& model); |
98 | |
99 | //! Adds a list of entities by adding each of the items |
100 | Standard_EXPORT void AddList (const Handle(TColStd_HSequenceOfTransient)& list, const Handle(Interface_InterfaceModel)& model); |
101 | |
102 | //! Adds a list of entities in the context given by the graph |
103 | //! Default just call basic AddList |
104 | //! Can be redefined to get a signature computed with the graph |
105 | Standard_EXPORT virtual void AddWithGraph (const Handle(TColStd_HSequenceOfTransient)& list, const Interface_Graph& graph); |
106 | |
107 | //! Adds all the entities contained in a Model |
108 | Standard_EXPORT void AddModel (const Handle(Interface_InterfaceModel)& model); |
109 | |
110 | //! Adds the result determined by a Selection from a Graph |
111 | //! Remark : does not impact at all data from SetSelection & Co |
112 | Standard_EXPORT void AddFromSelection (const Handle(IFSelect_Selection)& sel, const Interface_Graph& G); |
113 | |
114 | //! Sets a Selection as input : this causes content to be cleared |
115 | //! then the Selection to be ready to compute (but not immediatly) |
116 | Standard_EXPORT void SetSelection (const Handle(IFSelect_Selection)& sel); |
117 | |
118 | //! Returns the selection, or a null Handle |
119 | Standard_EXPORT Handle(IFSelect_Selection) Selection() const; |
120 | |
121 | //! Changes the mode of working with the selection : |
122 | //! -1 just clears optimisation data and nothing else |
123 | //! 0 clears it 1 inhibits it for computing (but no clearing) |
124 | //! 2 sets it active for computing |
125 | //! Default at creation is 0, after SetSelection (not null) is 2 |
126 | Standard_EXPORT void SetSelMode (const Standard_Integer selmode); |
127 | |
128 | //! Returns the mode of working with the selection |
129 | Standard_EXPORT Standard_Integer SelMode() const; |
130 | |
131 | //! Computes from the selection result, if selection is active |
132 | //! (mode 2). If selection is not defined (mode 0) or is inhibited |
133 | //! (mode 1) does nothing. |
134 | //! Returns True if computation is done (or optimised), False else |
135 | //! This method is called by ComputeCounter from WorkSession |
136 | //! |
137 | //! If <forced> is True, recomputes systematically |
138 | //! Else (D), if the counter was not cleared and if the former |
139 | //! computed result started from the same total size of Graph and |
140 | //! same count of selected entities : computation is not redone |
141 | //! unless <forced> is given as True |
142 | Standard_EXPORT Standard_Boolean ComputeSelected (const Interface_Graph& G, const Standard_Boolean forced = Standard_False); |
143 | |
144 | //! Determines and returns the value of the signature for an |
145 | //! entity as an HAsciiString. This method works exactly as |
146 | //! AddSign, which is optimized |
147 | //! |
148 | //! Can be redefined, accorded with AddSign |
149 | Standard_EXPORT virtual Handle(TCollection_HAsciiString) Sign (const Handle(Standard_Transient)& ent, const Handle(Interface_InterfaceModel)& model) const; |
150 | |
151 | //! Applies AddWithGraph on one entity, and returns the Signature |
152 | //! Value which has been recorded |
153 | //! To do this, Add is called with SignOnly Mode True during the |
154 | //! call, the returned value is LastValue |
155 | Standard_EXPORT Standard_CString ComputedSign (const Handle(Standard_Transient)& ent, const Interface_Graph& G); |
156 | |
157 | |
158 | |
159 | |
92efcf78 |
160 | DEFINE_STANDARD_RTTIEXT(IFSelect_SignCounter,IFSelect_SignatureList) |
42cf5bc1 |
161 | |
162 | protected: |
163 | |
164 | |
165 | |
166 | |
167 | private: |
168 | |
169 | |
170 | Standard_Boolean themapstat; |
171 | TColStd_MapOfTransient themap; |
172 | Handle(IFSelect_Signature) thematcher; |
173 | Handle(IFSelect_Selection) theselect; |
174 | Standard_Integer theselmode; |
175 | Standard_Integer thenbcomp1; |
176 | Standard_Integer thenbcomp2; |
177 | |
178 | |
179 | }; |
180 | |
181 | |
182 | |
183 | |
184 | |
185 | |
186 | |
187 | #endif // _IFSelect_SignCounter_HeaderFile |