FeaturePtr aFeature = aSession->createFeature(theID, this);
if (!aFeature)
return aFeature;
+ aFeature->init();
Model_Document* aDocToAdd;
if (!aFeature->documentToAdd().empty()) { // use the customized document to add
if (aFeature->documentToAdd() != kind()) { // the root document by default
// event: feature is added
static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
ModelAPI_EventCreator::get()->sendUpdated(theFeature, anEvent);
- theFeature->setDisabled(false); // by default created feature is enabled
updateHistory(ModelAPI_Feature::group());
} else { // make feature has not-null data anyway
theFeature->setData(Model_Data::invalidData());
aLabIter.Value()->Label().ForgetAllAttributes();
continue;
}
+ aFeature->init();
// this must be before "setData" to redo the sketch line correctly
myFeatures.Bind(aFeatureLabel, aFeature);
aNewFeatures.insert(aFeature);
initData(aFeature, aFeatureLabel, TAG_FEATURE_ARGUMENTS);
updateHistory(aFeature);
- aFeature->setDisabled(false); // by default created feature is enabled (this allows to recreate the results before "setCurrent" is called)
// event: model is updated
ModelAPI_EventCreator::get()->sendUpdated(aFeature, aCreateEvent);
std::shared_ptr<ModelAPI_Result> theResult,
const int theResultIndex)
{
+ theResult->init();
theResult->setDoc(myDoc);
initData(theResult, resultLabel(theFeatureData, theResultIndex), TAG_FEATURE_ARGUMENTS);
if (theResult->data()->name().empty()) { // if was not initialized, generate event and set a name
Model_ResultBody::Model_ResultBody()
{
myBuilder = new Model_BodyBuilder(this);
-
- myIsDisabled = true; // by default it is not initialized and false to be after created
- setIsConcealed(false);
}
void Model_ResultBody::initAttributes()
{
myBuilder = new Model_BodyBuilder(this);
myLastConcealed = false;
- setIsConcealed(myLastConcealed);
- myIsDisabled = true; // by default it is not initialized and false to be after created
updateSubs(shape()); // in case of open, etc.
}
Model_ResultConstruction::Model_ResultConstruction()
{
- myIsDisabled = true; // by default it is not initialized and false to be after created
myIsInHistory = true;
myIsInfinite = false;
myFacesUpToDate = false;
- setIsConcealed(false);
}
void Model_ResultConstruction::setIsInHistory(const bool isInHistory)
Model_ResultGroup::Model_ResultGroup(std::shared_ptr<ModelAPI_Data> theOwnerData)
{
- myIsDisabled = true; // by default it is not initialized and false to be after created
- setIsConcealed(false);
myOwnerData = theOwnerData;
}
Model_ResultParameter::Model_ResultParameter()
{
- myIsDisabled = true; // by default it is not initialized and false to be after created
- setIsConcealed(false);
}
Model_ResultPart::Model_ResultPart()
{
- myIsDisabled = true; // by default it is not initialized and false to be after created
myIsInLoad = false;
- setIsConcealed(false);
}
void Model_ResultPart::activate()
{
return true;
}
+
+void ModelAPI_Feature::init()
+{
+ myIsDisabled = false;
+}
{
return data()->attribute(theID);
}
- // -----------------------------------------------------------------------------------------------
+ protected:
+ /// This method is called just after creation of the object: it must initialize
+ /// all fields, normally initialized in the constructor
+ MODELAPI_EXPORT virtual void init();
+
+ friend class Model_Document;
+ friend class Model_Objects;
};
//! Pointer on feature object
MODELAPI_EXPORT virtual void setDisplayed(const bool theDisplay);
protected:
+ /// This method is called just after creation of the object: it must initialize
+ /// all fields, normally initialized in the constructor
+ MODELAPI_EXPORT virtual void init() = 0;
+
/// Sets the data manager of an object (document does)
MODELAPI_EXPORT virtual void setData(std::shared_ptr<ModelAPI_Data> theData);
static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
aECreator->sendUpdated(data()->attribute(theID)->owner(), EVENT_DISP);
}
+
+void ModelAPI_Result::init()
+{
+ myIsDisabled = true; // by default it is not initialized and false to be after created
+ myIsConcealed = false;
+}
/// On change of attribute of the result update presentation of this result:
/// for the current moment there are only presentation attributes assigned to results
MODELAPI_EXPORT virtual void attributeChanged(const std::string& theID);
+
+protected:
+ /// This method is called just after creation of the object: it must initialize
+ /// all fields, normally initialized in the constructor
+ MODELAPI_EXPORT virtual void init();
+
+friend class Model_Objects;
};
//! Pointer on feature object