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