From: vsv Date: Wed, 23 Jul 2014 06:12:26 +0000 (+0400) Subject: Check selection for sketcher X-Git-Tag: V_0.4.4~161 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a5ed86373550fa394dfd5d90da16f8eaf01a7ebd;p=modules%2Fshaper.git Check selection for sketcher --- diff --git a/src/ModelAPI/ModelAPI_Feature.cpp b/src/ModelAPI/ModelAPI_Feature.cpp index 882e99aaa..de34edd0a 100644 --- a/src/ModelAPI/ModelAPI_Feature.cpp +++ b/src/ModelAPI/ModelAPI_Feature.cpp @@ -33,6 +33,7 @@ void ModelAPI_Feature::setResult(const boost::shared_ptr& theRe myResults.push_back(theResult); static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED); ModelAPI_EventCreator::get()->sendUpdated(theResult, anEvent); + //TODO VSV:Create event for first Feature Events_Loop::loop()->flush(anEvent); } boost::shared_ptr ModelAPI_Feature::documentToAdd() diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index b41cf3005..91cb98096 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -344,24 +344,36 @@ void PartSet_Module::onCloseLocalContext() void PartSet_Module::onFeatureConstructed(FeaturePtr theFeature, int theMode) { - ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation(); - PartSet_OperationSketchBase* aPrevOp = dynamic_cast(aCurOperation); - if (aPrevOp) { - std::list aList = aPrevOp->subFeatures(); - XGUI_Displayer* aDisplayer = myWorkshop->displayer(); - std::list aModes = aPrevOp->getSelectionModes(aPrevOp->feature()); - std::list::iterator aSFIt; - for (aSFIt = aList.begin(); aSFIt != aList.end(); ++aSFIt) { - std::list aResults = (*aSFIt)->results(); - std::list::iterator aIt; - for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) { - aDisplayer->activateInLocalContext((*aIt), aModes, false); +// bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide; +// if (isDisplay) { + ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation(); + PartSet_OperationSketchBase* aPrevOp = dynamic_cast(aCurOperation); + if (aPrevOp) { + std::list aList = aPrevOp->subFeatures(); + XGUI_Displayer* aDisplayer = myWorkshop->displayer(); + std::list aModes = aPrevOp->getSelectionModes(aPrevOp->feature()); + std::list::iterator aSFIt; + for (aSFIt = aList.begin(); aSFIt != aList.end(); ++aSFIt) { + std::list aResults = (*aSFIt)->results(); + std::list::iterator aIt; + for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) { + aDisplayer->activateInLocalContext((*aIt), aModes, false); + } + } + FeaturePtr aFeature = aPrevOp->feature(); + if (aFeature) { + std::list aResList = aFeature->results(); + std::list::iterator aIt; + for (aIt = aResList.begin(); aIt != aResList.end(); ++aIt) { + aDisplayer->deactivate((*aIt), false); + } } } - } - ModelAPI_EventCreator::get()->sendUpdated(theFeature, - Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); - + ModelAPI_EventCreator::get()->sendUpdated(theFeature, + Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); +// } +// else +// ->erase(theFeature->firstResult(), true); /* bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide; // TODO visualizePreview(theFeature, isDisplay, false); if (!isDisplay) { @@ -509,14 +521,6 @@ void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateVi XGUI_Displayer* aDisplayer = myWorkshop->displayer(); aDisplayer->activateInLocalContext(theFeature, aPreviewOp->getSelectionModes(theFeature), isUpdateViewer); -/* FeaturePtr aFeature = aPreviewOp->feature(); - if (aFeature) { - std::list aResList = aFeature->results(); - std::list::iterator aIt; - for (aIt = aResList.begin(); aIt != aResList.end(); ++aIt) { - aDisplayer->deactivate((*aIt), false); - } - }*/ } } diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index d92a5f6e2..704d5b2de 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -131,6 +131,7 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer) if (!isVisible(theObject)) return; + Handle(AIS_InteractiveObject) aAISIO; boost::shared_ptr aAISObj = getAISObject(theObject); GeomPresentablePtr aPrs = boost::dynamic_pointer_cast(theObject); if (aPrs) { @@ -139,8 +140,7 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer) erase(theObject, isUpdateViewer); return; } - Handle(AIS_InteractiveObject) aAISIO = aAIS_Obj->impl(); - AISContext()->Redisplay(aAISIO, isUpdateViewer); + aAISIO = aAIS_Obj->impl(); } else { ResultPtr aResult = boost::dynamic_pointer_cast(theObject); if (aResult) { @@ -149,11 +149,18 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer) Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(aAISObj->impl()); if (!aAISShape.IsNull()) { aAISShape->Set(aShapePtr->impl()); - AISContext()->Redisplay(aAISShape, isUpdateViewer); + aAISIO = aAISShape; } } } } + if (!aAISIO.IsNull()) { + Handle(AIS_InteractiveContext) aContext = AISContext(); + aContext->Redisplay(aAISIO, isUpdateViewer); + //if (aContext->HasOpenedContext()) { + // aContext->Load(aAISIO, -1, true/*allow decomposition*/); + //} + } } void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult, @@ -189,7 +196,7 @@ void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult, updateViewer(); } -void XGUI_Displayer::deactvate(ObjectPtr theObject, bool toUpdate) +void XGUI_Displayer::deactivate(ObjectPtr theObject, bool toUpdate) { if (isVisible(theObject)) { Handle(AIS_InteractiveContext) aContext = AISContext(); diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index 9a742cb1b..af80496e1 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -120,7 +120,7 @@ public: /// \return feature the feature or NULL if it not visualized ObjectPtr getObject(Handle(AIS_InteractiveObject) theIO) const; - void deactvate(ObjectPtr theFeature, bool toUpdate); + void deactivate(ObjectPtr theFeature, bool toUpdate); protected: /// Deactivate local selection diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 9b0a8f086..de4c5af91 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -307,10 +307,11 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const ModelAPI_ObjectUpdatedMessage* t std::set::const_iterator aIt; for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) { ObjectPtr aObj = (*aIt); - if (aObj->data()) - myDisplayer->display(aObj, false); - else { + if (!aObj->data() ) myDisplayer->erase(aObj, false); + else { + if (myDisplayer->isVisible(aObj)) // TODO VSV: Correction sketch drawing + myDisplayer->display(aObj, false); // In order to update presentation } } myDisplayer->updateViewer(); @@ -325,10 +326,9 @@ void XGUI_Workshop::onFeatureCreatedMsg(const ModelAPI_ObjectUpdatedMessage* the bool aHasPart = false; bool isDisplayed = false; for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) { - ResultPartPtr aPart = boost::dynamic_pointer_cast(*aIt); + ResultPartPtr aPart = boost::dynamic_pointer_cast(*aIt); if (aPart) { aHasPart = true; - //break; } else { myDisplayer->display(*aIt, false); isDisplayed = true;