X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_Data.cpp;h=e08e565bd5274c0e02cf9083ea1f91d81535f3de;hb=54501278b314fa0a78a2c49d82837b830dcf605c;hp=80eba05b0e5a4cac492a4c0930e6d2e2100fca5e;hpb=b1f57156c63df5b18ade2209c843f902c394d695;p=modules%2Fshaper.git diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 80eba05b0..e08e565bd 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -15,6 +15,8 @@ #include #include "Model_Events.h" #include +#include + using namespace std; @@ -22,12 +24,12 @@ Model_Data::Model_Data() { } -void Model_Data::setLabel(TDF_Label& theLab) +void Model_Data::setLabel(TDF_Label theLab) { myLab = theLab; } -string Model_Data::getName() +string Model_Data::name() { Handle(TDataStd_Name) aName; if (myLab.FindAttribute(TDataStd_Name::GetID(), aName)) @@ -47,11 +49,11 @@ void Model_Data::setName(string theName) if (isModified) aName->Set(theName.c_str()); } - if (isModified) { - static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED); - Model_FeatureUpdatedMessage aMsg(myFeature, anEvent); - Events_Loop::loop()->send(aMsg, false); - } + // to do not cause the update of the result on name change + /*if (isModified) { + static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); + ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent, false); + }*/ } void Model_Data::addAttribute(string theID, string theAttrType) @@ -79,10 +81,11 @@ void Model_Data::addAttribute(string theID, string theAttrType) if (anAttr) { myAttrs[theID] = boost::shared_ptr(anAttr); - anAttr->setFeature(myFeature); + anAttr->setObject(myObject); + } + else { + Events_Error::send("Can not create unknown type of attribute " + theAttrType); } - else - ; // TODO: generate error on unknown attribute request and/or add mechanism for customization } boost::shared_ptr Model_Data::docRef(const string theID) @@ -222,38 +225,8 @@ list > Model_Data::attributes(const string void Model_Data::sendAttributeUpdated(ModelAPI_Attribute* theAttr) { theAttr->setInitialized(); - static const Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED); - Model_FeatureUpdatedMessage aMsg(myFeature, anEvent); - Events_Loop::loop()->send(aMsg); -} - -#include -#include -#include -#include - -void Model_Data::store(const boost::shared_ptr& theShape) -{ - // the simplest way is to keep this attribute here, on Data - // TODO: add naming structure in separated document for shape storage - TNaming_Builder aBuilder(myLab); - if (!theShape) return; // bad shape - TopoDS_Shape aShape = theShape->impl(); - if (aShape.IsNull()) return; // null shape inside - - aBuilder.Generated(aShape); -} - -boost::shared_ptr Model_Data::shape() -{ - Handle(TNaming_NamedShape) aName; - if (myLab.FindAttribute(TNaming_NamedShape::GetID(), aName)) { - TopoDS_Shape aShape = aName->Get(); - if (!aShape.IsNull()) { - boost::shared_ptr aRes(new GeomAPI_Shape); - aRes->setImpl(new TopoDS_Shape(aShape)); - return aRes; - } + if (theAttr->isArgument()) { + static const Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); + ModelAPI_EventCreator::get()->sendUpdated(myObject, anEvent); } - return boost::shared_ptr(); }