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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _IFSelect_TransformStandard_HeaderFile
18 #define _IFSelect_TransformStandard_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
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;
39 class IFSelect_TransformStandard;
40 DEFINE_STANDARD_HANDLE(IFSelect_TransformStandard, IFSelect_Transformer)
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).
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)
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
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)
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
73 //! Creates a TransformStandard, option StandardCopy, no Modifier
74 Standard_EXPORT IFSelect_TransformStandard();
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);
80 //! Returns the Copy option
81 Standard_EXPORT Standard_Boolean CopyOption() const;
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);
91 //! Returns the Selection, Null by default
92 Standard_EXPORT Handle(IFSelect_Selection) Selection() const;
94 //! Returns the count of recorded Modifiers
95 Standard_EXPORT Standard_Integer NbModifiers() const;
97 //! Returns a Modifier given its rank in the list
98 Standard_EXPORT Handle(IFSelect_Modifier) Modifier (const Standard_Integer num) const;
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;
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);
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);
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);
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;
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;
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;
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;
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;
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;
148 //! Returns a text which defines the way a Transformer works :
149 //! "On the spot edition" or "Standard Copy" followed by
151 Standard_EXPORT TCollection_AsciiString Label() const Standard_OVERRIDE;
156 DEFINE_STANDARD_RTTIEXT(IFSelect_TransformStandard,IFSelect_Transformer)
166 Standard_Boolean thecopy;
167 Handle(IFSelect_Selection) thesel;
168 IFSelect_SequenceOfGeneralModifier themodifs;
169 Handle(Interface_CopyControl) themap;
180 #endif // _IFSelect_TransformStandard_HeaderFile