20 #ifndef ModelAPI_Feature_H_
21 #define ModelAPI_Feature_H_
24 #include <ModelAPI_Object.h>
25 #include <ModelAPI_Data.h>
26 #include <ModelAPI_Document.h>
33 typedef std::list<std::shared_ptr<GeomAPI_Shape> > ListOfShape;
43 std::list<std::shared_ptr<ModelAPI_Result> > myResults;
54 inline static std::string
group()
56 static std::string MY_GROUP =
"Features";
61 virtual std::shared_ptr<ModelAPI_Document>
document()
const
78 virtual bool compute(
const std::string& ) {
return false; };
81 MODELAPI_EXPORT
virtual void setError(
const std::string& theError,
83 bool isTranslate =
true);
86 virtual std::string
error()
const {
87 return data()->error();
91 MODELAPI_EXPORT
const std::list<std::shared_ptr<ModelAPI_Result> >&
results();
93 MODELAPI_EXPORT std::shared_ptr<ModelAPI_Result>
firstResult()
const;
95 MODELAPI_EXPORT std::shared_ptr<ModelAPI_Result>
lastResult();
97 MODELAPI_EXPORT
void setResult(
const std::shared_ptr<ModelAPI_Result>& theResult);
99 MODELAPI_EXPORT
void setResult(
const std::shared_ptr<ModelAPI_Result>& theResult,
106 const bool theForever =
true,
const bool theFlush =
true);
108 MODELAPI_EXPORT
void eraseResults(
const bool theForever =
true);
110 MODELAPI_EXPORT
virtual void erase();
113 MODELAPI_EXPORT
void eraseResultFromList(
const std::shared_ptr<ModelAPI_Result>& theResult);
128 MODELAPI_EXPORT
virtual bool isMacro()
const;
142 MODELAPI_EXPORT
virtual bool setDisabled(
const bool theFlag);
151 MODELAPI_EXPORT
static std::shared_ptr<ModelAPI_Feature>
feature(ObjectPtr theObject);
155 MODELAPI_EXPORT
virtual bool setStable(
const bool theFlag);
158 MODELAPI_EXPORT
virtual bool isStable();
166 MODELAPI_EXPORT
virtual bool customAction(
const std::string& theActionId);
169 MODELAPI_EXPORT
virtual ListOfShape
170 vertices(
const bool theOnlyUnique =
false);
173 MODELAPI_EXPORT
virtual ListOfShape
174 edges(
const bool theOnlyUnique =
false);
177 MODELAPI_EXPORT
virtual ListOfShape
178 wires(
const bool theOnlyUnique =
false);
181 MODELAPI_EXPORT
virtual ListOfShape
182 faces(
const bool theOnlyUnique =
false);
185 MODELAPI_EXPORT
virtual ListOfShape
186 shells(
const bool theOnlyUnique =
false);
189 MODELAPI_EXPORT
virtual ListOfShape
190 solids(
const bool theOnlyUnique =
false);
198 return data()->name();
201 inline std::shared_ptr<ModelAPI_AttributeBoolean>
boolean(
const std::string& theID)
203 return data()->boolean(theID);
206 inline std::shared_ptr<ModelAPI_AttributeDocRef>
document(
const std::string& theID)
208 return data()->document(theID);
211 inline std::shared_ptr<ModelAPI_AttributeDouble>
real(
const std::string& theID)
213 return data()->real(theID);
216 inline std::shared_ptr<ModelAPI_AttributeInteger>
integer(
const std::string& theID)
218 return data()->integer(theID);
221 inline std::shared_ptr<ModelAPI_AttributeIntArray>
intArray(
const std::string& theID)
223 return data()->intArray(theID);
226 inline std::shared_ptr<ModelAPI_AttributeRefAttr>
refattr(
const std::string& theID)
228 return data()->refattr(theID);
231 inline std::shared_ptr<ModelAPI_AttributeRefAttrList>
refattrlist(
const std::string& theID)
233 return data()->refattrlist(theID);
236 inline std::shared_ptr<ModelAPI_AttributeReference>
reference(
const std::string& theID)
238 return data()->reference(theID);
241 inline std::shared_ptr<ModelAPI_AttributeRefList>
reflist(
const std::string& theID)
243 return data()->reflist(theID);
246 inline std::shared_ptr<ModelAPI_AttributeSelection>
selection(
const std::string& theID)
248 return data()->selection(theID);
251 inline std::shared_ptr<ModelAPI_AttributeSelectionList>
selectionList(
const std::string& theID)
253 return data()->selectionList(theID);
256 inline std::shared_ptr<ModelAPI_AttributeString>
string(
const std::string& theID)
258 return data()->string(theID);
261 inline std::shared_ptr<ModelAPI_AttributeStringArray>
stringArray(
const std::string& theID)
263 return data()->stringArray(theID);
266 inline std::shared_ptr<ModelAPI_AttributeTables>
tables(
const std::string& theID)
268 return data()->tables(theID);
271 inline std::shared_ptr<ModelAPI_Attribute>
attribute(
const std::string& theID)
273 return data()->attribute(theID);
278 void showErrorMessage();
283 MODELAPI_EXPORT
virtual void init();
290 typedef std::shared_ptr<ModelAPI_Feature> FeaturePtr;
302 virtual void getCopies(ObjectPtr theContext, std::shared_ptr<GeomAPI_Shape> theValue,
303 std::list<ObjectPtr>& theCopyContext,
304 std::list<std::shared_ptr<GeomAPI_Shape> >& theCopyVals) = 0;
An interface for performing special copy actions.
Definition: ModelAPI_Feature.h:294
virtual void getCopies(ObjectPtr theContext, std::shared_ptr< GeomAPI_Shape > theValue, std::list< ObjectPtr > &theCopyContext, std::list< std::shared_ptr< GeomAPI_Shape > > &theCopyVals)=0
An algorithm to update the moved feature by the separate Copy feature.
Feature function that represents the particular functionality of this operation.
Definition: ModelAPI_Feature.h:41
virtual void execute()=0
Computes or recomputes the results.
MODELAPI_EXPORT std::shared_ptr< ModelAPI_Result > firstResult() const
returns the first result in the list or NULL reference
Definition: ModelAPI_Feature.cpp:51
virtual const std::string & getKind()=0
Returns the unique kind of a feature (like "Point")
virtual MODELAPI_EXPORT bool isStable()
Returns the feature is stable or not.
Definition: ModelAPI_Feature.cpp:256
virtual MODELAPI_EXPORT bool isEditable()
Returns the feature is editable or not. Most of features are editable.
Definition: ModelAPI_Feature.cpp:261
MODELAPI_EXPORT void eraseResults(const bool theForever=true)
removes all results from the feature
Definition: ModelAPI_Feature.cpp:155
std::shared_ptr< ModelAPI_AttributeString > string(const std::string &theID)
Returns the string attribute by the identifier.
Definition: ModelAPI_Feature.h:256
MODELAPI_EXPORT const std::list< std::shared_ptr< ModelAPI_Result > > & results()
returns the current results of the feature
Definition: ModelAPI_Feature.cpp:46
virtual MODELAPI_EXPORT bool isDisabled()
Returns the feature is disabled or not.
Definition: ModelAPI_Feature.cpp:235
virtual std::string error() const
Returns error, arose during the execution.
Definition: ModelAPI_Feature.h:86
std::shared_ptr< ModelAPI_AttributeTables > tables(const std::string &theID)
Returns the tables attribute by the identifier.
Definition: ModelAPI_Feature.h:266
MODELAPI_EXPORT std::shared_ptr< ModelAPI_Result > lastResult()
returns the last result in the list or NULL reference
Definition: ModelAPI_Feature.cpp:56
virtual bool isPersistentResult()
Returns true if result is persistent (stored in document) and on undo-redo, save-open it is not neede...
Definition: ModelAPI_Feature.h:117
std::shared_ptr< ModelAPI_Attribute > attribute(const std::string &theID)
Returns the attribute by the identifier.
Definition: ModelAPI_Feature.h:271
virtual MODELAPI_EXPORT ListOfShape vertices(const bool theOnlyUnique=false)
Returns all the vertices produced by this feature.
Definition: ModelAPI_Feature.cpp:294
virtual bool compute(const std::string &)
Computes the attribute value on the base of other attributes if the value can be computed.
Definition: ModelAPI_Feature.h:78
virtual MODELAPI_EXPORT ListOfShape solids(const bool theOnlyUnique=false)
Returns all the solids produced by this feature.
Definition: ModelAPI_Feature.cpp:344
std::shared_ptr< ModelAPI_AttributeDouble > real(const std::string &theID)
Returns the real attribute by the identifier.
Definition: ModelAPI_Feature.h:211
std::shared_ptr< ModelAPI_AttributeSelectionList > selectionList(const std::string &theID)
Returns the list of shape selections attribute by the identifier.
Definition: ModelAPI_Feature.h:251
virtual MODELAPI_EXPORT void init()
This method is called just after creation of the object: it must initialize all fields,...
Definition: ModelAPI_Feature.cpp:276
MODELAPI_EXPORT void removeResults(const int theSinceIndex, const bool theForever=true, const bool theFlush=true)
removes all results starting from the given index (zero-based)
Definition: ModelAPI_Feature.cpp:126
virtual MODELAPI_EXPORT bool isMacro() const
Returns true if this feature is used as macro: creates other features and then removed.
Definition: ModelAPI_Feature.cpp:204
std::shared_ptr< ModelAPI_AttributeIntArray > intArray(const std::string &theID)
Returns the integer array attribute by the identifier.
Definition: ModelAPI_Feature.h:221
virtual MODELAPI_EXPORT ListOfShape edges(const bool theOnlyUnique=false)
Returns all the edges produced by this feature.
Definition: ModelAPI_Feature.cpp:304
virtual MODELAPI_EXPORT ListOfShape wires(const bool theOnlyUnique=false)
Returns all the wires produced by this feature.
Definition: ModelAPI_Feature.cpp:314
static std::string group()
Returns the group identifier of all features.
Definition: ModelAPI_Feature.h:54
std::shared_ptr< ModelAPI_AttributeSelection > selection(const std::string &theID)
Returns the shape selection attribute by the identifier.
Definition: ModelAPI_Feature.h:246
virtual MODELAPI_EXPORT void setError(const std::string &theError, bool isSend=true, bool isTranslate=true)
Registers error during the execution, causes the ExecutionFailed state.
Definition: ModelAPI_Feature.cpp:37
MODELAPI_EXPORT void eraseResultFromList(const std::shared_ptr< ModelAPI_Result > &theResult)
removes the result from the list of feature (not doing in disabled): normally this method is not used...
Definition: ModelAPI_Feature.cpp:105
std::shared_ptr< ModelAPI_AttributeRefAttrList > refattrlist(const std::string &theID)
Returns the refattrlist attribute by the identifier.
Definition: ModelAPI_Feature.h:231
std::shared_ptr< ModelAPI_AttributeBoolean > boolean(const std::string &theID)
Returns the Boolean attribute by the identifier.
Definition: ModelAPI_Feature.h:201
virtual MODELAPI_EXPORT ListOfShape shells(const bool theOnlyUnique=false)
Returns all the shells produced by this feature.
Definition: ModelAPI_Feature.cpp:334
std::shared_ptr< ModelAPI_AttributeStringArray > stringArray(const std::string &theID)
Returns the string array attribute by the identifier.
Definition: ModelAPI_Feature.h:261
virtual MODELAPI_EXPORT ListOfShape faces(const bool theOnlyUnique=false)
Returns all the faces produced by this feature.
Definition: ModelAPI_Feature.cpp:324
virtual MODELAPI_EXPORT bool setStable(const bool theFlag)
Set the stable feature flag.
Definition: ModelAPI_Feature.cpp:241
std::shared_ptr< ModelAPI_AttributeRefList > reflist(const std::string &theID)
Returns the list of references attribute by the identifier.
Definition: ModelAPI_Feature.h:241
std::shared_ptr< ModelAPI_AttributeInteger > integer(const std::string &theID)
Returns the integer attribute by the identifier.
Definition: ModelAPI_Feature.h:216
virtual std::shared_ptr< ModelAPI_Document > document() const
Returns document this feature belongs to.
Definition: ModelAPI_Feature.h:61
virtual MODELAPI_EXPORT const std::string & documentToAdd()
Must return document where the new feature must be added to By default it is empty: it is added to th...
Definition: ModelAPI_Feature.cpp:160
std::shared_ptr< ModelAPI_AttributeDocRef > document(const std::string &theID)
Returns the document reference attribute.
Definition: ModelAPI_Feature.h:206
std::wstring name()
Returns the name stored in the attribute.
Definition: ModelAPI_Feature.h:196
virtual MODELAPI_EXPORT void erase()
removes all fields from this feature: results, data, etc
Definition: ModelAPI_Feature.cpp:167
std::shared_ptr< ModelAPI_AttributeRefAttr > refattr(const std::string &theID)
Returns the reference attribute by the identifier.
Definition: ModelAPI_Feature.h:226
static MODELAPI_EXPORT std::shared_ptr< ModelAPI_Feature > feature(ObjectPtr theObject)
Returns the feature by the object (result).
Definition: ModelAPI_Feature.cpp:191
std::shared_ptr< ModelAPI_AttributeReference > reference(const std::string &theID)
Returns the reference attribute by the identifier.
Definition: ModelAPI_Feature.h:236
virtual MODELAPI_EXPORT bool customAction(const std::string &theActionId)
Performs some custom feature specific functionality (normally called by some GUI button)
Definition: ModelAPI_Feature.cpp:266
virtual MODELAPI_EXPORT bool isPreviewNeeded() const
Returns true if preview update during the edition needed.
Definition: ModelAPI_Feature.cpp:271
virtual MODELAPI_EXPORT bool setDisabled(const bool theFlag)
Enables/disables the feature.
Definition: ModelAPI_Feature.cpp:209
MODELAPI_EXPORT void setResult(const std::shared_ptr< ModelAPI_Result > &theResult)
sets the alone result
Definition: ModelAPI_Feature.cpp:61
virtual bool isAction()
Returns true if this feature must not be created: this is just an action that is not stored in the fe...
Definition: ModelAPI_Feature.h:121
virtual std::string groupName()
Returns the group identifier of this result.
Definition: ModelAPI_Feature.h:67
virtual MODELAPI_EXPORT ~ModelAPI_Feature()
To virtually destroy the fields of successors.
Definition: ModelAPI_Feature.cpp:185
Represents any object in the data model and in the object browser.
Definition: ModelAPI_Object.h:45
virtual std::shared_ptr< ModelAPI_Data > data() const
Returns the data manager of this object: attributes.
Definition: ModelAPI_Object.cpp:45
virtual std::shared_ptr< ModelAPI_Document > document() const
Returns document this feature belongs to.
Definition: ModelAPI_Object.cpp:55
Document for internal data structure of any object storage.
Definition: Model_Document.h:45
Manager of objects of the document.
Definition: Model_Objects.h:46