b311480e |
1 | -- Created on: 1994-11-07 |
2 | -- Created by: Christian CAILLET |
3 | -- Copyright (c) 1994-1999 Matra Datavision |
973c2be1 |
4 | -- Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | -- |
973c2be1 |
6 | -- This file is part of Open CASCADE Technology software library. |
b311480e |
7 | -- |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | -- |
973c2be1 |
14 | -- Alternatively, this file may be used under the terms of Open CASCADE |
15 | -- commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | class SignCounter from IFSelect inherits SignatureList |
18 | |
19 | ---Purpose : SignCounter gives the frame to count signatures associated |
20 | -- with entities, deducted from them. Ex.: their Dynamic Type. |
21 | -- |
22 | -- It can sort a set of Entities according a signature, i.e. : |
23 | -- - list of different values found for this Signature |
24 | -- - for each one, count and list of entities |
25 | -- Results are returned as a SignatureList, which can be queried |
26 | -- on the count (list of strings, count per signature, or list of |
27 | -- entities per signature) |
28 | -- |
29 | -- A SignCounter can be filled, either directly from lists, or |
30 | -- from the result of a Selection : hence, its content can be |
31 | -- automatically recomputed as desired |
32 | -- |
33 | -- SignCounter works by using a Signature in its method AddSign |
34 | -- |
35 | -- Methods can be redefined to, either |
36 | -- - directly compute the value without a Signature |
37 | -- - compute the value in the context of a Graph |
38 | |
39 | uses CString, Transient, MapOfTransient, HAsciiString from TCollection, |
40 | HSequenceOfTransient, |
41 | InterfaceModel, Graph, Selection, Signature |
42 | |
43 | is |
44 | |
45 | Create (withmap : Boolean = Standard_True; |
6e33d3ce |
46 | withlist : Boolean = Standard_False) returns SignCounter; |
7fd59977 |
47 | ---Purpose : Creates a SignCounter, without proper Signature |
48 | -- If <withmap> is True (default), added entities are counted |
49 | -- only if they are not yet recorded in the map |
50 | -- Map control can be set off if the input garantees uniqueness |
51 | -- of data |
52 | -- <withlist> is transmitted to SignatureList (option to list |
53 | -- entities, not only to count them). |
54 | |
6e33d3ce |
55 | Create (matcher : Signature; |
7fd59977 |
56 | withmap : Boolean = Standard_True; |
6e33d3ce |
57 | withlist : Boolean = Standard_False) returns SignCounter; |
7fd59977 |
58 | ---Purpose : Creates a SignCounter, with a predefined Signature |
59 | -- Other arguments as for Create without Signature. |
60 | |
6e33d3ce |
61 | Signature (me) returns Signature; |
7fd59977 |
62 | ---Purpose : Returns the Signature used to count entities. It can be null. |
63 | |
64 | SetMap (me : mutable; withmap : Boolean); |
65 | ---Purpose : Changes the control status. The map is not cleared, simply |
66 | -- its use changes |
67 | |
68 | AddEntity (me : mutable; ent : Transient; model : InterfaceModel) |
69 | returns Boolean is virtual; |
70 | ---Purpose : Adds an entity by considering its signature, which is given by |
71 | -- call to method AddSign |
72 | -- Returns True if added, False if already in the map (and |
73 | -- map control status set) |
74 | |
75 | AddSign (me : mutable; ent : Transient; model : InterfaceModel) |
76 | is virtual; |
77 | ---Purpose : Adds an entity (already filtered by Map) with its signature. |
78 | -- This signature can be computed with the containing model. |
79 | -- Its value is provided by the object Signature given at start, |
80 | -- if no Signature is defined, it does nothing. |
81 | -- |
82 | -- Can be redefined (in this case, see also Sign) |
83 | |
84 | AddList (me : mutable; list : HSequenceOfTransient; model : InterfaceModel); |
85 | ---Purpose : Adds a list of entities by adding each of the items |
86 | |
87 | AddWithGraph (me : mutable; list : HSequenceOfTransient; graph : Graph) |
88 | is virtual; |
89 | ---Purpose : Adds a list of entities in the context given by the graph |
90 | -- Default just call basic AddList |
91 | -- Can be redefined to get a signature computed with the graph |
92 | |
93 | AddModel (me : mutable; model : InterfaceModel); |
94 | ---Purpose : Adds all the entities contained in a Model |
95 | |
96 | AddFromSelection (me : mutable; sel : Selection; G : Graph); |
97 | ---Purpose : Adds the result determined by a Selection from a Graph |
98 | -- Remark : does not impact at all data from SetSelection & Co |
99 | |
100 | -- Counting on selection result -- |
101 | |
102 | SetSelection (me : mutable; sel : Selection); |
103 | ---Purpose : Sets a Selection as input : this causes content to be cleared |
104 | -- then the Selection to be ready to compute (but not immediatly) |
105 | |
106 | Selection (me) returns Selection; |
107 | ---Purpose : Returns the selection, or a null Handle |
108 | |
109 | SetSelMode (me : mutable; selmode : Integer); |
110 | ---Purpose : Changes the mode of working with the selection : |
111 | -- -1 just clears optimisation data and nothing else |
112 | -- 0 clears it 1 inhibits it for computing (but no clearing) |
113 | -- 2 sets it active for computing |
114 | -- Default at creation is 0, after SetSelection (not null) is 2 |
115 | |
116 | SelMode (me) returns Integer; |
117 | ---Purpose : Returns the mode of working with the selection |
118 | |
119 | ComputeSelected (me : mutable; G : Graph; forced : Boolean=Standard_False) |
120 | returns Boolean; |
121 | ---Purpose : Computes from the selection result, if selection is active |
122 | -- (mode 2). If selection is not defined (mode 0) or is inhibited |
123 | -- (mode 1) does nothing. |
124 | -- Returns True if computation is done (or optimised), False else |
125 | -- This method is called by ComputeCounter from WorkSession |
126 | -- |
127 | -- If <forced> is True, recomputes systematically |
128 | -- Else (D), if the counter was not cleared and if the former |
129 | -- computed result started from the same total size of Graph and |
130 | -- same count of selected entities : computation is not redone |
131 | -- unless <forced> is given as True |
132 | |
133 | |
134 | Sign (me; ent : Transient; model : InterfaceModel) |
135 | returns HAsciiString is virtual; |
136 | ---Purpose : Determines and returns the value of the signature for an |
137 | -- entity as an HAsciiString. This method works exactly as |
138 | -- AddSign, which is optimized |
139 | -- |
140 | -- Can be redefined, accorded with AddSign |
141 | |
142 | ComputedSign (me : mutable; ent : Transient; G : Graph) returns CString; |
143 | ---Purpose : Applies AddWithGraph on one entity, and returns the Signature |
144 | -- Value which has been recorded |
145 | -- To do this, Add is called with SignOnly Mode True during the |
146 | -- call, the returned value is LastValue |
147 | |
148 | fields |
149 | |
150 | themapstat : Boolean; |
151 | themap : MapOfTransient; |
152 | thematcher : Signature; |
153 | |
154 | theselect : Selection; |
155 | theselmode : Integer; |
156 | thenbcomp1 : Integer; |
157 | thenbcomp2 : Integer; |
158 | |
159 | end SignCounter; |