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