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 the data manager of this feature
44 MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Data> data() {return myData;}
46 /// Must return document where the new feature must be added to
47 /// By default it is current document
48 MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Document> documentToAdd()
49 {return ModelAPI_PluginManager::get()->currentDocument();}
51 /// Returns document this feature belongs to
52 MODELAPI_EXPORT virtual boost::shared_ptr<ModelAPI_Document> document()
55 /// To virtually destroy the fields of successors
56 virtual ~ModelAPI_Feature() {}
59 /// Use plugin manager for features creation: this method is
60 /// defined here only for SWIG-wrapping
64 /// Sets the data manager of an object (document does)
65 MODELAPI_EXPORT virtual void setData(boost::shared_ptr<ModelAPI_Data> theData)
67 /// Sets the data manager of an object (document does)
68 MODELAPI_EXPORT void setDoc(boost::shared_ptr<ModelAPI_Document> theDoc) {myDoc = theDoc;}
70 friend class Model_Document;