]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Check selection for sketcher
authorvsv <vitaly.smetannikov@opencascade.com>
Wed, 23 Jul 2014 06:12:26 +0000 (10:12 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Wed, 23 Jul 2014 06:12:26 +0000 (10:12 +0400)
src/ModelAPI/ModelAPI_Feature.cpp
src/PartSet/PartSet_Module.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_Workshop.cpp

index 882e99aaa18cde1f762c4f8b0eb7edde3d3e82ca..de34edd0a6f6c4b64bf0c51accf09ea75ff031a0 100644 (file)
@@ -33,6 +33,7 @@ void ModelAPI_Feature::setResult(const boost::shared_ptr<ModelAPI_Result>& 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_Document> ModelAPI_Feature::documentToAdd()
index b41cf30053ce1651c7b0a3bbc1115b6714ac8be0..91cb98096808d85a4a41d63ab060eb851be7874b 100644 (file)
@@ -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<PartSet_OperationSketchBase*>(aCurOperation);
-  if (aPrevOp) {
-    std::list<FeaturePtr> aList = aPrevOp->subFeatures();
-    XGUI_Displayer* aDisplayer = myWorkshop->displayer();
-    std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
-    std::list<FeaturePtr>::iterator aSFIt; 
-    for (aSFIt = aList.begin(); aSFIt != aList.end(); ++aSFIt) {
-      std::list<ResultPtr> aResults = (*aSFIt)->results();
-      std::list<ResultPtr>::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<PartSet_OperationSketchBase*>(aCurOperation);
+    if (aPrevOp) {
+      std::list<FeaturePtr> aList = aPrevOp->subFeatures();
+      XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+      std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
+      std::list<FeaturePtr>::iterator aSFIt; 
+      for (aSFIt = aList.begin(); aSFIt != aList.end(); ++aSFIt) {
+        std::list<ResultPtr> aResults = (*aSFIt)->results();
+        std::list<ResultPtr>::iterator aIt;
+        for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
+          aDisplayer->activateInLocalContext((*aIt), aModes, false);
+        }
+      }
+      FeaturePtr aFeature = aPrevOp->feature();
+      if (aFeature) {
+        std::list<ResultPtr> aResList = aFeature->results();
+        std::list<ResultPtr>::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<ResultPtr> aResList = aFeature->results();
-      std::list<ResultPtr>::iterator aIt;
-      for (aIt = aResList.begin(); aIt != aResList.end(); ++aIt) {
-        aDisplayer->deactivate((*aIt), false);
-      }
-    }*/
   }
 }
 
index d92a5f6e20e00452c0c25a1d7f778c581f0fa902..704d5b2decf2f24ca6c50e2f68c37995719ce547 100644 (file)
@@ -131,6 +131,7 @@ void XGUI_Displayer::redisplay(ObjectPtr theObject, bool isUpdateViewer)
   if (!isVisible(theObject))
     return;
 
+  Handle(AIS_InteractiveObject) aAISIO;
   boost::shared_ptr<GeomAPI_AISObject> aAISObj = getAISObject(theObject);
   GeomPresentablePtr aPrs = boost::dynamic_pointer_cast<GeomAPI_IPresentable>(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<Handle(AIS_InteractiveObject)>();
-    AISContext()->Redisplay(aAISIO, isUpdateViewer);
+    aAISIO = aAIS_Obj->impl<Handle(AIS_InteractiveObject)>();
   } else {
     ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(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<Handle(AIS_InteractiveObject)>());
         if (!aAISShape.IsNull()) {
           aAISShape->Set(aShapePtr->impl<TopoDS_Shape>());
-          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();
index 9a742cb1b22995a96576b76362bb8c4b8b63a6e9..af80496e1911dad066b078c9f2568db786e9b4af 100644 (file)
@@ -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
index 9b0a8f0867a8183a040da712b69b4a81db6cc7d7..de4c5af919d48a6337f680b9781dd941724e5944 100644 (file)
@@ -307,10 +307,11 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const ModelAPI_ObjectUpdatedMessage* t
   std::set<ObjectPtr>::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<ModelAPI_ResultPart>(*aIt);
+    ResultPartPtr aPart = boost::dynamic_pointer_cast<ModelAPI_ResultPart>(*aIt);
     if (aPart) {
       aHasPart = true;
-      //break;
     } else {
       myDisplayer->display(*aIt, false);
       isDisplayed = true;