// event: model is updated
static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED);
ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent);
-
- // update results of the appeared feature
- updateResults(aFeature);
} else { // nothing is changed, both iterators are incremented
aFeature = myObjs.Find(aFeatureLabel);
aKeptFeatures.insert(aFeature);
static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED);
ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent);
}
+ }
+ }
+ // update results of thefeatures (after features created because they may be connected, like sketch and sub elements)
+ TDF_ChildIDIterator aLabIter2(featuresLabel(), TDataStd_Comment::GetID());
+ for (; aLabIter2.More(); aLabIter2.Next()) {
+ TDF_Label aFeatureLabel = aLabIter2.Value()->Label();
+ if (myObjs.IsBound(aFeatureLabel)) { // a new feature is inserted
+ FeaturePtr aFeature = myObjs.Find(aFeatureLabel);
updateResults(aFeature);
}
}
+
// check all features are checked: if not => it was removed
NCollection_DataMap<TDF_Label, FeaturePtr>::Iterator aFIter(myObjs);
while (aFIter.More()) {
void Model_Document::updateResults(FeaturePtr theFeature)
{
// for not persistent is will be done by parametric updater automatically
- if (!theFeature->isPersistentResult()) return;
+ //if (!theFeature->isPersistentResult()) return;
// check the existing results and remove them if there is nothing on the label
std::list<ResultPtr>::const_iterator aResIter = theFeature->results().cbegin();
while(aResIter != theFeature->results().cend()) {
- ResultBodyPtr aBody = boost::dynamic_pointer_cast<ModelAPI_ResultBody>(*aResIter);
+ ResultPtr aBody = boost::dynamic_pointer_cast<ModelAPI_Result>(*aResIter);
if (aBody) {
if (!aBody->data()->isValid()) {
// found a disappeared result => remove it
aNewBody = createBody(theFeature->data(), aResIndex);
} else if (aGroup->Get() == ModelAPI_ResultPart::group().c_str()) {
aNewBody = createPart(theFeature->data(), aResIndex);
- } else if (aGroup->Get() != ModelAPI_ResultConstruction::group().c_str() &&
- aGroup->Get() != ModelAPI_ResultGroup::group().c_str()) {
+ } else if (aGroup->Get() == ModelAPI_ResultConstruction::group().c_str()) {
+ theFeature->execute(); // construction shapes are needed for sketch solver
+ break;
+ } else if (aGroup->Get() == ModelAPI_ResultGroup::group().c_str()) {
+ aNewBody = createGroup(theFeature->data(), aResIndex);
+ } else {
Events_Error::send(std::string("Unknown type of result is found in the document:") +
TCollection_AsciiString(aGroup->Get()).ToCString());
}
aLoop->registerListener(this, kCreatedEvent);
static const Events_ID kUpdatedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED);
aLoop->registerListener(this, kUpdatedEvent);
+ static const Events_ID kMovedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED);
+ aLoop->registerListener(this, kMovedEvent);
static const Events_ID kOpFinishEvent = aLoop->eventByName("FinishOperation");
aLoop->registerListener(this, kOpFinishEvent);
static const Events_ID kOpAbortEvent = aLoop->eventByName("AbortOperation");
static const Events_ID kRebuildEvent = aLoop->eventByName("Rebuild");
static const Events_ID kCreatedEvent = aLoop->eventByName(EVENT_OBJECT_CREATED);
static const Events_ID kUpdatedEvent = aLoop->eventByName(EVENT_OBJECT_UPDATED);
+ static const Events_ID kMovedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED);
static const Events_ID kOpFinishEvent = aLoop->eventByName("FinishOperation");
static const Events_ID kOpAbortEvent = aLoop->eventByName("AbortOperation");
static const Events_ID kOpStartEvent = aLoop->eventByName("StartOperation");
isAutomaticChanged = true;
isAutomatic = true;
}
- } else if (theMessage->eventID() == kCreatedEvent || theMessage->eventID() == kUpdatedEvent) {
+ } else if (theMessage->eventID() == kCreatedEvent || theMessage->eventID() == kUpdatedEvent ||
+ theMessage->eventID() == kMovedEvent) {
boost::shared_ptr<ModelAPI_ObjectUpdatedMessage> aMsg =
boost::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
const std::set<ObjectPtr>& anObjs = aMsg->objects();
for(; anObjIter != anObjs.cend(); anObjIter++) {
myJustCreatedOrUpdated.insert(*anObjIter);
}
+ if (theMessage->eventID() == kMovedEvent)
+ return; // this event is for solver update, not here
} else if (theMessage->eventID() == kOpStartEvent) {
myJustCreatedOrUpdated.clear();
return; // we don't need the update only on operation start (caused problems in PartSet_Listener::processEvent)
void SketchPlugin_Circle::attributeChanged() {
static bool myIsUpdated = false; // to avoid infinitive cycle on attrubtes change
boost::shared_ptr<GeomAPI_Shape> aSelection = data()->selection(EXTERNAL_ID())->value();
- if (aSelection && !myIsUpdated) { // update arguments due to the selection value
+ // update arguments due to the selection value
+ if (aSelection && !aSelection->isNull() && aSelection->isEdge() && !myIsUpdated) {
myIsUpdated = true;
boost::shared_ptr<GeomAPI_Edge> anEdge( new GeomAPI_Edge(aSelection));
boost::shared_ptr<GeomAPI_Circ> aCirc = anEdge->circle();
static bool myIsUpdated = false; // to avoid infinitive cycle on attrubtes change
boost::shared_ptr<GeomAPI_Shape> aSelection = data()->selection(EXTERNAL_ID())->value();
// update arguments due to the selection value
- if (aSelection && !aSelection->isNull() && !myIsUpdated) {
+ if (aSelection && !aSelection->isNull() && aSelection->isEdge() && !myIsUpdated) {
myIsUpdated = true;
boost::shared_ptr<GeomAPI_Edge> anEdge( new GeomAPI_Edge(aSelection));
boost::shared_ptr<GeomDataAPI_Point2D> aStartAttr =
for (; anIt != aLast; anIt++) {
aFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(*anIt);
if (aFeature) {
+ if (!aFeature->sketch()) // on load document the back references are missed
+ aFeature->setSketch(this);
// do not include the external edges into the result
if (aFeature->data()->attribute(SketchPlugin_Feature::EXTERNAL_ID())) {
if (aFeature->data()->selection(SketchPlugin_Feature::EXTERNAL_ID())->value())
void SketchSolver_ConstraintManager::processEvent(
const boost::shared_ptr<Events_Message>& theMessage)
{
- if (myIsComputed)
- return;
+ //if (myIsComputed)
+ // return;
if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)
|| theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED)
|| theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_MOVED)) {
}
} else {
std::set<ObjectPtr>::iterator aFeatIter;
+ // iterate sketchers fisrt to create all sketches before (on load may exist several sketches)
for (aFeatIter = aFeatures.begin(); aFeatIter != aFeatures.end(); aFeatIter++) {
FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(*aFeatIter);
if (!aFeature)
continue;
- // Only sketches and constraints can be added by Create event
const std::string& aFeatureKind = aFeature->getKind();
if (aFeatureKind.compare(SketchPlugin_Sketch::ID()) == 0) {
boost::shared_ptr<ModelAPI_CompositeFeature> aSketch = boost::dynamic_pointer_cast<
ModelAPI_CompositeFeature>(aFeature);
- if (aSketch)
- changeWorkplane(aSketch);
- continue;
+ changeWorkplane(aSketch);
}
- // Sketch plugin features can be only updated
- boost::shared_ptr<SketchPlugin_Feature> aSFeature = boost::dynamic_pointer_cast<
- SketchPlugin_Feature>(aFeature);
- if (aSFeature)
- changeConstraintOrEntity(aSFeature);
+ }
+ // then get anything but not the sketch
+ for (aFeatIter = aFeatures.begin(); aFeatIter != aFeatures.end(); aFeatIter++) {
+ boost::shared_ptr<SketchPlugin_Feature> aFeature =
+ boost::dynamic_pointer_cast<SketchPlugin_Feature>(*aFeatIter);
+ if (!aFeature)
+ continue;
+ changeConstraintOrEntity(aFeature);
}
}