1 // File: ModelAPI_Feature.hxx
2 // Created: 21 Mar 2014
3 // Author: Mikhail PONIKAROV
5 #ifndef ModelAPI_Feature_HeaderFile
6 #define ModelAPI_Feature_HeaderFile
9 #include "ModelAPI_PluginManager.h"
12 #include <boost/shared_ptr.hpp>
15 class ModelAPI_Document;
17 /**\class ModelAPI_Feature
19 * \brief Functionality of the model object: to update result,
20 * to initialize attributes, etc.
22 class ModelAPI_Feature
24 boost::shared_ptr<ModelAPI_Data> myData; ///< manager of the data model of a feature
25 boost::shared_ptr<ModelAPI_Document> myDoc; ///< document this feature belongs to
28 /// Returns the kind of a feature (like "Point")
29 MODELAPI_EXPORT virtual const std::string& getKind() = 0;
31 /// Returns to which group in the document must be added feature
32 MODELAPI_EXPORT virtual const std::string& getGroup() = 0;
34 /// Request for initialization of data model of the feature: adding all attributes
35 MODELAPI_EXPORT virtual void initAttributes() = 0;
37 /// Computes or recomputes the result
38 MODELAPI_EXPORT virtual void execute() = 0;
40 /// Returns true if this feature must be displayed in the history (top level of Part tree)
41 MODELAPI_EXPORT virtual bool isInHistory() {return true;}
43 /// Returns true if this feature must not be created: this is just an action
44 /// that is not stored in the features history (like delete part).
45 MODELAPI_EXPORT virtual bool isAction() {return false;}
47 /// Returns the data manager of this feature
48 MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Data> data() {return myData;}
50 /// Must return document where the new feature must be added to
51 /// By default it is current document
52 MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Document> documentToAdd()
53 {return ModelAPI_PluginManager::get()->currentDocument();}
55 /// Returns document this feature belongs to
56 MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Document> document()
59 /// Returns true if feature refers to the same model data instance
60 MODELAPI_EXPORT virtual bool isSame(const boost::shared_ptr<ModelAPI_Feature>& theFeature)
61 {return theFeature.get() == this;}
63 /// To virtually destroy the fields of successors
64 virtual ~ModelAPI_Feature() {}
67 /// Use plugin manager for features creation: this method is
68 /// defined here only for SWIG-wrapping
72 /// Sets the data manager of an object (document does)
73 MODELAPI_EXPORT virtual void setData(boost::shared_ptr<ModelAPI_Data> theData)
75 /// Sets the data manager of an object (document does)
76 MODELAPI_EXPORT void setDoc(boost::shared_ptr<ModelAPI_Document> theDoc) {myDoc = theDoc;}
78 friend class Model_Document;
81 //! Pointer on feature object
82 typedef boost::shared_ptr<ModelAPI_Feature> FeaturePtr;