1 // Created on: 1994-05-27 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_TransformStandard_HeaderFile 18 #define _IFSelect_TransformStandard_HeaderFile 19 20 #include <Standard.hxx> 21 #include <Standard_Type.hxx> 22 23 #include <Standard_Boolean.hxx> 24 #include <IFSelect_SequenceOfGeneralModifier.hxx> 25 #include <IFSelect_Transformer.hxx> 26 #include <Standard_Integer.hxx> 27 class IFSelect_Selection; 28 class Interface_CopyControl; 29 class IFSelect_Modifier; 30 class Interface_Graph; 31 class Interface_Protocol; 32 class Interface_CheckIterator; 33 class Interface_InterfaceModel; 34 class Interface_CopyTool; 35 class Standard_Transient; 36 class TCollection_AsciiString; 37 38 39 class IFSelect_TransformStandard; 40 DEFINE_STANDARD_HANDLE(IFSelect_TransformStandard, IFSelect_Transformer) 41 42 //! This class runs transformations made by Modifiers, as 43 //! the ModelCopier does when it produces files (the same set 44 //! of Modifiers can then be used, as to transform the starting 45 //! Model, as at file sending time). 46 //! 47 //! First, considering the resulting model, two options : 48 //! - modifications are made directly on the starting model 49 //! (OnTheSpot option), or 50 //! - data are copied by the standard service Copy, only the 51 //! remaining (not yet sent in a file) entities are copied 52 //! (StandardCopy option) 53 //! 54 //! If a Selection is set, it forces the list of Entities on which 55 //! the Modifiers are applied. Else, each Modifier is considered 56 //! its Selection. By default, it is for the whole Model 57 //! 58 //! Then, the Modifiers are sequentially applied 59 //! If at least one Modifier "May Change Graph", or if the option 60 //! StandardCopy is selected, the graph will be recomputed 61 //! (by the WorkSession, see method RunTransformer) 62 //! 63 //! Remark that a TransformStandard with option StandardCopy 64 //! and no Modifier at all has the effect of computing the 65 //! remaining data (those not yet sent in any output file). 66 //! Moreover, the Protocol is not changed 67 class IFSelect_TransformStandard : public IFSelect_Transformer 68 { 69 70 public: 71 72 73 //! Creates a TransformStandard, option StandardCopy, no Modifier 74 Standard_EXPORT IFSelect_TransformStandard(); 75 76 //! Sets the Copy option to a new value : 77 //! - True for StandardCopy - False for OnTheSpot 78 Standard_EXPORT void SetCopyOption (const Standard_Boolean option); 79 80 //! Returns the Copy option 81 Standard_EXPORT Standard_Boolean CopyOption() const; 82 83 //! Sets a Selection (or unsets if Null) 84 //! This Selection then defines the list of entities on which the 85 //! Modifiers will be applied 86 //! If it is set, it has priority on Selections of Modifiers 87 //! Else, for each Modifier its Selection is evaluated 88 //! By default, all the Model is taken 89 Standard_EXPORT void SetSelection (const Handle(IFSelect_Selection)& sel); 90 91 //! Returns the Selection, Null by default 92 Standard_EXPORT Handle(IFSelect_Selection) Selection() const; 93 94 //! Returns the count of recorded Modifiers 95 Standard_EXPORT Standard_Integer NbModifiers() const; 96 97 //! Returns a Modifier given its rank in the list 98 Standard_EXPORT Handle(IFSelect_Modifier) Modifier (const Standard_Integer num) const; 99 100 //! Returns the rank of a Modifier in the list, 0 if unknown 101 Standard_EXPORT Standard_Integer ModifierRank (const Handle(IFSelect_Modifier)& modif) const; 102 103 //! Adds a Modifier to the list : 104 //! - <atnum> = 0 (default) : at the end of the list 105 //! - <atnum> > 0 : at rank <atnum> 106 //! Returns True if done, False if <atnum> is out of range 107 Standard_EXPORT Standard_Boolean AddModifier (const Handle(IFSelect_Modifier)& modif, const Standard_Integer atnum = 0); 108 109 //! Removes a Modifier from the list 110 //! Returns True if done, False if <modif> not in the list 111 Standard_EXPORT Standard_Boolean RemoveModifier (const Handle(IFSelect_Modifier)& modif); 112 113 //! Removes a Modifier from the list, given its rank 114 //! Returns True if done, False if <num> is out of range 115 Standard_EXPORT Standard_Boolean RemoveModifier (const Standard_Integer num); 116 117 //! Performs the Standard Transformation, by calling Copy then 118 //! ApplyModifiers (which can return an error status) 119 Standard_EXPORT Standard_Boolean Perform (const Interface_Graph& G, const Handle(Interface_Protocol)& protocol, Interface_CheckIterator& checks, Handle(Interface_InterfaceModel)& newmod) Standard_OVERRIDE; 120 121 //! This the first operation. It calls StandardCopy or OnTheSpot 122 //! according the option 123 Standard_EXPORT void Copy (const Interface_Graph& G, Interface_CopyTool& TC, Handle(Interface_InterfaceModel)& newmod) const; 124 125 //! This is the standard action of Copy : its takes into account 126 //! only the remaining entities (noted by Graph Status positive) 127 //! and their proper dependances of course. Produces a new model. 128 Standard_EXPORT void StandardCopy (const Interface_Graph& G, Interface_CopyTool& TC, Handle(Interface_InterfaceModel)& newmod) const; 129 130 //! This is the OnTheSpot action : each entity is bound with ... 131 //! itself. The produced model is the same as the starting one. 132 Standard_EXPORT void OnTheSpot (const Interface_Graph& G, Interface_CopyTool& TC, Handle(Interface_InterfaceModel)& newmod) const; 133 134 //! Applies the modifiers sequencially. 135 //! For each one, prepares required data (if a Selection is 136 //! associated as a filter). 137 //! For the option OnTheSpot, it determines if the graph may be 138 //! changed and updates <newmod> if required 139 //! If a Modifier causes an error (check "HasFailed"), 140 //! ApplyModifier stops : the following Modifiers are ignored 141 Standard_EXPORT Standard_Boolean ApplyModifiers (const Interface_Graph& G, const Handle(Interface_Protocol)& protocol, Interface_CopyTool& TC, Interface_CheckIterator& checks, Handle(Interface_InterfaceModel)& newmod) const; 142 143 //! This methods allows to know what happened to a starting 144 //! entity after the last Perform. It reads result from the map 145 //! which was filled by Perform. 146 Standard_EXPORT Standard_Boolean Updated (const Handle(Standard_Transient)& entfrom, Handle(Standard_Transient)& entto) const Standard_OVERRIDE; 147 148 //! Returns a text which defines the way a Transformer works : 149 //! "On the spot edition" or "Standard Copy" followed by 150 //! "<nn> Modifiers" 151 Standard_EXPORT TCollection_AsciiString Label() const Standard_OVERRIDE; 152 153 154 155 156 DEFINE_STANDARD_RTTIEXT(IFSelect_TransformStandard,IFSelect_Transformer) 157 158 protected: 159 160 161 162 163 private: 164 165 166 Standard_Boolean thecopy; 167 Handle(IFSelect_Selection) thesel; 168 IFSelect_SequenceOfGeneralModifier themodifs; 169 Handle(Interface_CopyControl) themap; 170 171 172 }; 173 174 175 176 177 178 179 180 #endif // _IFSelect_TransformStandard_HeaderFile 181