]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Selection problems
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 22 Jul 2014 09:07:08 +0000 (13:07 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 22 Jul 2014 09:07:08 +0000 (13:07 +0400)
src/PartSet/PartSet_Listener.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/PartSet/PartSet_OperationSketch.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h

index af017fbbaa54d542bd1b7d1d79a53c552ddeeda6..7cef128b199ef70e7039f81d652b1a25b0cd7f6b 100644 (file)
@@ -57,8 +57,7 @@ void PartSet_Listener::processEvent(const Events_Message* theMessage)
     }
     myModule->workshop()->displayer()->updateViewer();
   }
-  if (aType == EVENT_OBJECT_DELETED)
-  {
+  if (aType == EVENT_OBJECT_DELETED) {
     const ModelAPI_ObjectDeletedMessage* aDelMsg = 
       dynamic_cast<const ModelAPI_ObjectDeletedMessage*>(theMessage);
     boost::shared_ptr<ModelAPI_Document> aDoc = aDelMsg->document();
index 757d759c3381b73e8952ccaf7421d916b257546f..b41cf30053ce1651c7b0a3bbc1115b6714ac8be0 100644 (file)
@@ -344,8 +344,23 @@ 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);
+      }
+    }
+  }
   ModelAPI_EventCreator::get()->sendUpdated(theFeature, 
-    Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
+      Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
 
 /*  bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
   // TODO visualizePreview(theFeature, isDisplay, false);
@@ -494,6 +509,14 @@ 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);
+      }
+    }*/
   }
 }
 
@@ -523,7 +546,7 @@ void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
     if (!aSPFeature)
       continue;
     //visualizePreview((*anIt), true, false);
-    aDisplayer->activateInLocalContext((*anIt)->firstResult(), aModes, false);
+    aDisplayer->activateInLocalContext((*anIt), aModes, false);
   }
   aDisplayer->updateViewer();
 }
index 859dbc93f96e371f65dfc31bb312556f9fc5d81f..1c8c5836b19bd31a29e4e498d2550364cf308b18 100644 (file)
@@ -271,7 +271,7 @@ FeaturePtr PartSet_OperationFeatureCreate::createFeature(const bool theFlushMess
   //myFeaturePrs->init(aNewFeature);
   //myFeaturePrs->setFeature(myInitFeature, SM_FirstPoint);
 
-  emit featureConstructed(aNewFeature, FM_Activation);
+//TODO  emit featureConstructed(aNewFeature, FM_Activation);
   if (theFlushMessage)
     flushCreated();
   return aNewFeature;
index 8d2b7e5fcf994d60987d0aa801d6c5ea4c7384e2..5adc7e0354de481ef8255cc24f14ceb98194009a 100644 (file)
@@ -137,7 +137,12 @@ void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View)
 
 std::list<FeaturePtr> PartSet_OperationSketch::subFeatures() const
 {
-  boost::shared_ptr<ModelAPI_Data> aData = feature()->data();
+  std::list<FeaturePtr> aFeaList;
+  FeaturePtr aFeature = feature();
+  if (!aFeature)
+    return aFeaList;
+
+  boost::shared_ptr<ModelAPI_Data> aData = aFeature->data();
   if (!aData->isValid())
     return std::list<FeaturePtr>();
   boost::shared_ptr<ModelAPI_AttributeRefList> aRefList =
@@ -145,7 +150,6 @@ std::list<FeaturePtr> PartSet_OperationSketch::subFeatures() const
 
   std::list<ObjectPtr> aList = aRefList->list();
   std::list<ObjectPtr>::iterator aIt;
-  std::list<FeaturePtr> aFeaList;
   for (aIt = aList.begin(); aIt != aList.end(); ++aIt) {
     FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(*aIt);
     if (aFeature)
index ed92f3845cff22d8ee9102b37f0be743486da20c..d92a5f6e20e00452c0c25a1d7f778c581f0fa902 100644 (file)
@@ -165,14 +165,9 @@ void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult,
     aContext->ClearCurrents(false);
     aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/);
   }
-/*  std::list<int>::const_iterator anIt;
-  for (anIt = theModes.begin(); anIt != theModes.end(); anIt++)
-    aContext->ActivateStandardMode((TopAbs_ShapeEnum)(*anIt));
-    */
   // display or redisplay presentation
   Handle(AIS_InteractiveObject) anAIS;
-  if (isVisible(theResult))
-  {
+  if (isVisible(theResult)) {
     boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theResult];
     if (anObj)
       anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
@@ -180,12 +175,12 @@ void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult,
 
   // Activate selection of objects from prs
   if (!anAIS.IsNull()) {
+    aContext->ClearSelected(false); // ToCheck
     aContext->Load(anAIS, -1, true/*allow decomposition*/);
     aContext->Deactivate(anAIS);
 
     std::list<int>::const_iterator anIt = theModes.begin(), aLast = theModes.end();
-    for (; anIt != aLast; anIt++)
-    {
+    for (; anIt != aLast; anIt++) {
       aContext->Activate(anAIS, (*anIt));
     }
   }
@@ -194,6 +189,17 @@ void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult,
     updateViewer();
 }
 
+void XGUI_Displayer::deactvate(ObjectPtr theObject, bool toUpdate)
+{
+  if (isVisible(theObject)) {
+    Handle(AIS_InteractiveContext) aContext = AISContext();
+
+     boost::shared_ptr<GeomAPI_AISObject> anObj = myResult2AISObjectMap[theObject];
+     Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
+     aContext->Deactivate(anAIS);
+  }
+}
+
 void XGUI_Displayer::stopSelection(const QList<ObjectPtr>& theResults, const bool isStop,
                                    const bool isUpdateViewer)
 {
index 226a18c7b6954009afb813b9623eacac013741e4..9a742cb1b22995a96576b76362bb8c4b8b63a6e9 100644 (file)
@@ -120,6 +120,8 @@ public:
   /// \return feature the feature or NULL if it not visualized
   ObjectPtr getObject(Handle(AIS_InteractiveObject) theIO) const;
 
+  void deactvate(ObjectPtr theFeature, bool toUpdate);
+
 protected:
   /// Deactivate local selection
   /// \param isUpdateViewer the state wether the viewer should be updated immediatelly