]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_0.6' of newgeom:newgeom into Dev_0.6
authorvsv <vitaly.smetannikov@opencascade.com>
Tue, 2 Dec 2014 17:06:33 +0000 (20:06 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Tue, 2 Dec 2014 17:06:33 +0000 (20:06 +0300)
src/GeomAlgoAPI/GeomAlgoAPI_Placement.cpp
src/ModuleBase/ModuleBase_ViewerFilters.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/PartSet/PartSet_WidgetSketchLabel.h
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h
src/XGUI/XGUI_ModuleConnector.cpp

index 6a378adde2ce10d71514694ad793a12805661566..b21ecc64d3f86cabd7c1430b6619098b0f44897f 100644 (file)
@@ -57,17 +57,13 @@ void GeomAlgoAPI_Placement::build(
     setImpl(aBuilder);
     myDone = aBuilder->IsDone() == Standard_True;
     if (myDone) {
-      TopoDS_Shape aResult;
-      if(aBuilder->Shape().ShapeType() == TopAbs_COMPOUND) 
-        aResult = GeomAlgoAPI_DFLoader::refineResult(aBuilder->Shape());
-      else
-        aResult = aBuilder->Shape();
+      TopoDS_Shape aResult = aBuilder->Shape();
       // fill data map to keep correct orientation of sub-shapes 
       for (TopExp_Explorer Exp(aResult,TopAbs_FACE); Exp.More(); Exp.Next()) {
         std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
         aCurrentShape->setImpl(new TopoDS_Shape(Exp.Current()));
         myMap.bind(aCurrentShape, aCurrentShape);
-      }   
+      }
       myShape->setImpl(new TopoDS_Shape(aResult));
       myMkShape = new GeomAlgoAPI_MakeShape (aBuilder);
     }
index e7309ca072b2ee7fb3bdaaf82070f5bef50156ec..94625a48094797a60e63dad02d46e11366f26907 100644 (file)
@@ -39,6 +39,10 @@ Standard_Boolean ModuleBase_ShapeDocumentFilter::IsOk(const Handle(SelectMgr_Ent
         SessionPtr aMgr = ModelAPI_Session::get();
         return (aDoc == aMgr->activeDocument() || aDoc == aMgr->moduleDocument());
       }
+      else {
+        // This is not object controlled by the filter
+        return Standard_True;
+      }
     }
   }
   return Standard_False;
@@ -74,6 +78,10 @@ Standard_Boolean ModuleBase_ShapeInPlaneFilter::IsOk(const Handle(SelectMgr_Enti
           bool aD3 = myPlane.Distance(aLastPnt) < Precision::Confusion();
           return aD1 && aD2 && aD3;
         }
+      default:
+        // This is not object controlled by the filter
+        return Standard_True;
+      break;
       }
     } else {
       // This is not object controlled by the filter
index 39830ef5576aaf32c67ddb31707b383bdaeab0b5..ca49036a681acb908ee57bfb1882608634bbc0c9 100644 (file)
@@ -110,6 +110,10 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
 
 PartSet_Module::~PartSet_Module()
 {
+  if (!myDocumentShapeFilter.IsNull())
+    myDocumentShapeFilter.Nullify();
+  if (!myPlaneFilter.IsNull())
+    myPlaneFilter.Nullify();
 }
 
 void PartSet_Module::registerValidators()
@@ -191,6 +195,9 @@ void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
       myPlaneFilter->setPlane(aPln->impl<gp_Pln>());
     }
   }
+  if (myDocumentShapeFilter.IsNull())
+    myDocumentShapeFilter = new ModuleBase_ShapeDocumentFilter(myWorkshop);
+  myWorkshop->viewer()->addSelectionFilter(myDocumentShapeFilter);
 }
 
 void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
@@ -225,6 +232,7 @@ void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
     myCurrentSketch = CompositeFeaturePtr();
     myWorkshop->viewer()->removeSelectionFilter(myPlaneFilter);
   }
+  myWorkshop->viewer()->removeSelectionFilter(myDocumentShapeFilter);
 }
 
 void PartSet_Module::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
index eb8fb58217b6c900be22d30e7a413247540a44ba..085876eb23bbdf83af816698ed20782608e2db75 100644 (file)
@@ -110,6 +110,8 @@ protected slots:
    QList<AttributePtr> myEditingAttr;
 
    Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;
+  /// A filter which provides selection within a current document or whole PartSet
+  Handle(ModuleBase_ShapeDocumentFilter) myDocumentShapeFilter;
 };
 
 #endif
index 37cd834450a68835ba3a0c0d22f29c88fa037067..46f641e00c6c981c4dc36756e33d8b2b1f72ae23 100644 (file)
@@ -102,7 +102,7 @@ void PartSet_WidgetSketchLabel::onPlaneSelected()
 
         // Clear selection mode and define sketching mode
         XGUI_Displayer* aDisp = myWorkshop->displayer();
-        aDisp->removeSelectionFilter(myPlaneFilter);
+        aDisp->removeSelectionFilter(myFaceFilter);
         aDisp->closeLocalContexts();
         emit planeSelected(plane());
         setSketchingMode();
@@ -133,13 +133,13 @@ void PartSet_WidgetSketchLabel::activate()
 
     XGUI_Displayer* aDisp = myWorkshop->displayer();
     aDisp->openLocalContext();
-    aDisp->activateObjectsOutOfContext(QIntList());
-    if (myPlaneFilter.IsNull())
-      myPlaneFilter = new StdSelect_FaceFilter(StdSelect_Plane);
-    aDisp->addSelectionFilter(myPlaneFilter);
+    aDisp->activateObjects(QIntList());
+    if (myFaceFilter.IsNull())
+      myFaceFilter = new StdSelect_FaceFilter(StdSelect_Plane);
+    aDisp->addSelectionFilter(myFaceFilter);
     QIntList aModes;
     aModes << TopAbs_FACE;
-    aDisp->setSelectionModes(aModes);
+    aDisp->activateObjects(aModes);
 
     myLabel->setText(myText);
     myLabel->setToolTip(myTooltip);
@@ -153,7 +153,7 @@ void PartSet_WidgetSketchLabel::deactivate()
 {
 
   XGUI_Displayer* aDisp = myWorkshop->displayer();
-  aDisp->removeSelectionFilter(myPlaneFilter);
+  aDisp->removeSelectionFilter(myFaceFilter);
   //aDisp->removeSelectionFilter(mySketchFilter);
   aDisp->closeLocalContexts();
   erasePreviewPlanes();
@@ -265,7 +265,7 @@ void PartSet_WidgetSketchLabel::setSketchingMode()
   XGUI_Displayer* aDisp = myWorkshop->displayer();
   QIntList aModes;
   // Clear standard selection modes if they are defined
-  aDisp->setSelectionModes(aModes);
+  aDisp->activateObjects(aModes);
   aDisp->openLocalContext();
 
   // Set filter
@@ -283,5 +283,5 @@ void PartSet_WidgetSketchLabel::setSketchingMode()
   aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_VERTEX));
   aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum) TopAbs_EDGE));
 
-  aDisp->activateObjectsOutOfContext(aModes);
+  aDisp->activateObjects(aModes);
 }
index 906e962952a40ef48f2f082cad19b4ba9a47bc0a..5d4ad6f52eebe4a30c4e86e45e81459e754b87de 100644 (file)
@@ -90,7 +90,7 @@ signals:
   AISObjectPtr myXYPlane;
   bool myPreviewDisplayed;
 
-  Handle(StdSelect_FaceFilter) myPlaneFilter;
+  Handle(StdSelect_FaceFilter) myFaceFilter;
   //Handle(ModuleBase_ShapeInPlaneFilter) mySketchFilter;
 };
 
index 9ca390ecb243023847224d61da0b94d02839fea9..3a46b77b13db6ef825687f7513b37b5e2634fb5c 100644 (file)
@@ -274,15 +274,15 @@ void XGUI_Displayer::clearSelected()
 
 void XGUI_Displayer::eraseAll(const bool isUpdateViewer)
 {
-  Handle(AIS_InteractiveContext) ic = AISContext();
-  if (ic.IsNull())
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  if (aContext.IsNull())
     return;
 
    foreach (AISObjectPtr aAISObj, myResult2AISObjectMap) {
      // erase an object
      Handle(AIS_InteractiveObject) anIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
      if (!anIO.IsNull())
-       ic->Remove(anIO, false);
+       aContext->Remove(anIO, false);
    }
    myResult2AISObjectMap.clear();
    if (isUpdateViewer)
@@ -328,10 +328,15 @@ void XGUI_Displayer::openLocalContext()
     //for (aContext->InitCurrent(); aContext->MoreCurrent(); aContext->NextCurrent())
     //  aAisList.Append(aContext->Current());
 
+    // get the filters from the global context and append them to the local context
+    // a list of filters in the global context is not cleared and should be cleared here
     SelectMgr_ListOfFilter aFilters;
     aFilters.Assign(aContext->Filters());
+    // it is important to remove the filters in the global context, because there is a code
+    // in the closeLocalContex, which restore the global context filters
+    aContext->RemoveFilters();
 
-    aContext->ClearCurrents();
+    //aContext->ClearCurrents();
     aContext->OpenLocalContext();
     aContext->NotUseDisplayedObjects();
 
@@ -353,25 +358,38 @@ void XGUI_Displayer::openLocalContext()
 
 void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer)
 {
-  Handle(AIS_InteractiveContext) ic = AISContext();
-  if ( (!ic.IsNull()) && (ic->HasOpenedContext()) ) {
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  if ( (!aContext.IsNull()) && (aContext->HasOpenedContext()) ) {
     // Preserve selected objects
     //AIS_ListOfInteractive aAisList;
-    //for (ic->InitSelected(); ic->MoreSelected(); ic->NextSelected())
-    //  aAisList.Append(ic->SelectedInteractive());
+    //for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
+    //  aAisList.Append(aContext->SelectedInteractive());
+
+    // get the filters from the local context and append them to the global context
+    // a list of filters in the local context is cleared
+    SelectMgr_ListOfFilter aFilters;
+    aFilters.Assign(aContext->Filters());
 
-    ic->ClearSelected();
-    ic->CloseAllContexts(false);
+    //aContext->ClearSelected();
+    aContext->CloseAllContexts(false);
 
     // Redisplay all object if they were displayed in localContext
     Handle(AIS_InteractiveObject) aAISIO;
     foreach (AISObjectPtr aAIS, myResult2AISObjectMap) {
       aAISIO = aAIS->impl<Handle(AIS_InteractiveObject)>();
-      if (ic->DisplayStatus(aAISIO) != AIS_DS_Displayed) {
-        ic->Display(aAISIO, false);
-        ic->SetDisplayMode(aAISIO, Shading, false);
+      if (aContext->DisplayStatus(aAISIO) != AIS_DS_Displayed) {
+        aContext->Display(aAISIO, false);
+        aContext->SetDisplayMode(aAISIO, Shading, false);
       }
     }
+
+    // Append the filters from the local selection in the global selection context
+    SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
+    for (;aIt.More(); aIt.Next()) {
+      Handle(SelectMgr_Filter) aFilter = aIt.Value();
+      aContext->AddFilter(aFilter);
+    }
+
     if (isUpdateViewer)
       updateViewer();
     myUseExternalObjects = false;
@@ -380,8 +398,8 @@ void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer)
     // Restore selection
     //AIS_ListIteratorOfListOfInteractive aIt(aAisList);
     //for(; aIt.More(); aIt.Next()) {
-    //  if (ic->IsDisplayed(aIt.Value()))
-    //    ic->SetCurrentObject(aIt.Value(), false);
+    //  if (aContext->IsDisplayed(aIt.Value()))
+    //    aContext->SetCurrentObject(aIt.Value(), false);
     //}
   }
 }
@@ -414,9 +432,9 @@ ObjectPtr XGUI_Displayer::getObject(const Handle(AIS_InteractiveObject)& theIO)
 
 void XGUI_Displayer::updateViewer()
 {
-  Handle(AIS_InteractiveContext) ic = AISContext();
-  if (!ic.IsNull())
-    ic->UpdateCurrentViewer();
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  if (!aContext.IsNull())
+    aContext->UpdateCurrentViewer();
 }
 
 Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const
@@ -424,6 +442,16 @@ Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const
   return myWorkshop->viewer()->AISContext();
 }
 
+Handle(SelectMgr_AndFilter) XGUI_Displayer::GetFilter()
+{
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  if (myAndFilter.IsNull() && !aContext.IsNull()) {
+    myAndFilter = new SelectMgr_AndFilter();
+    aContext->AddFilter(myAndFilter);
+  }
+  return myAndFilter;
+}
+
 void XGUI_Displayer::displayAIS(AISObjectPtr theAIS, bool isUpdate)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -453,7 +481,7 @@ void XGUI_Displayer::eraseAIS(AISObjectPtr theAIS, const bool isUpdate)
   }
 }
 
-void XGUI_Displayer::activateObjectsOutOfContext(const QIntList& theModes)
+void XGUI_Displayer::activateObjects(const QIntList& theModes)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
   // Open local context if there is no one
@@ -478,9 +506,18 @@ void XGUI_Displayer::activateObjectsOutOfContext(const QIntList& theModes)
     }
   }
 
+  //Activate all displayed objects with the module modes
+  //AIS_ListOfInteractive aPrsList;
+  //aContext->DisplayedObjects(aPrsList, true);
+
+  //AIS_ListIteratorOfListOfInteractive aLIt(aPrsList);
   Handle(AIS_InteractiveObject) anAISIO;
-  foreach (AISObjectPtr aAIS, myResult2AISObjectMap) {
-  anAISIO = aAIS->impl<Handle(AIS_InteractiveObject)>();
+  for(aLIt.Initialize(aPrsList); aLIt.More(); aLIt.Next()){
+    anAISIO = aLIt.Value();
+    aTrihedron = Handle(AIS_Trihedron)::DownCast(anAISIO);
+    if (!aTrihedron.IsNull())
+      continue;
+
     aContext->Load(anAISIO, -1, true);
     if (theModes.size() == 0)
       aContext->Activate(anAISIO);
@@ -493,7 +530,7 @@ void XGUI_Displayer::activateObjectsOutOfContext(const QIntList& theModes)
 }
 
 
-void XGUI_Displayer::deactivateObjectsOutOfContext()
+void XGUI_Displayer::deactivateObjects()
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
   // Open local context if there is no one
@@ -521,28 +558,6 @@ void XGUI_Displayer::setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bo
   aContext->SetDisplayMode(aAISIO, theMode, toUpdate);
 }
 
-void XGUI_Displayer::setSelectionModes(const QIntList& theModes)
-{
-  Handle(AIS_InteractiveContext) aContext = AISContext();
-  if (aContext.IsNull())
-    return;
-  if (!aContext->HasOpenedContext())
-    return;
-  // Clear previous mode
-  const TColStd_ListOfInteger& aModes = aContext->ActivatedStandardModes();
-  if (!aModes.IsEmpty()) {
-    TColStd_ListOfInteger aMModes;
-    aMModes.Assign(aModes);
-    TColStd_ListIteratorOfListOfInteger it(aMModes);
-    for(; it.More(); it.Next()) {
-      aContext->DeactivateStandardMode((TopAbs_ShapeEnum)it.Value());
-    }
-  }
-  foreach(int aMode, theModes) {
-    aContext->ActivateStandardMode((TopAbs_ShapeEnum)aMode);
-  }
-}
-
 XGUI_Displayer::DisplayMode XGUI_Displayer::displayMode(ObjectPtr theObject) const
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
@@ -568,7 +583,7 @@ void XGUI_Displayer::addSelectionFilter(const Handle(SelectMgr_Filter)& theFilte
     if (theFilter.Access() == aIt.Value().Access())
       return;
   }
-  aContext->AddFilter(theFilter);
+  GetFilter()->Add(theFilter);
 }
 
 void XGUI_Displayer::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter)
@@ -576,7 +591,7 @@ void XGUI_Displayer::removeSelectionFilter(const Handle(SelectMgr_Filter)& theFi
   Handle(AIS_InteractiveContext) aContext = AISContext();
   if (aContext.IsNull())
     return;
-  aContext->RemoveFilter(theFilter);
+  GetFilter()->Remove(theFilter);
 }
 
 void XGUI_Displayer::removeFilters()
@@ -584,5 +599,5 @@ void XGUI_Displayer::removeFilters()
   Handle(AIS_InteractiveContext) aContext = AISContext();
   if (aContext.IsNull())
     return;
-  aContext->RemoveFilters();
+  GetFilter()->Clear();
 }
index f563223280a444faf49eeeea1918cae78bb1210f..b18eb0f8dc33baafa655ef85c202fbb606389d7d 100644 (file)
@@ -18,6 +18,8 @@
 #include <ModuleBase_Definitions.h>
 #include <ModuleBase_ViewerPrs.h>
 
+#include <SelectMgr_AndFilter.hxx>
+
 #include <QString>
 #include <QMap>
 
@@ -94,13 +96,6 @@ class XGUI_EXPORT XGUI_Displayer
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
   void closeLocalContexts(const bool isUpdateViewer = true);
 
-  /*
-  * Set modes of selections. Selection mode has to be defined by TopAbs_ShapeEnum.
-  * It doesn't manages a local context
-  * \param theModes - list of selection modes. If the list is empty then all selectoin modes will be cleared.
-  */
-  void setSelectionModes(const QIntList& theModes);
-
   void addSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
 
   void removeSelectionFilter(const Handle(SelectMgr_Filter)& theFilter);
@@ -136,10 +131,10 @@ class XGUI_EXPORT XGUI_Displayer
 
   /// Activates in local context displayed outside of the context.
   /// \param theModes - modes on which it has to be activated (can be empty)
-  void activateObjectsOutOfContext(const QIntList& theModes);
+  void activateObjects(const QIntList& theModes);
 
   /// Activates in local context displayed outside of the context.
-  void deactivateObjectsOutOfContext();
+  void deactivateObjects();
 
   /// Sets display mode for the given object if this object is displayed
   void setDisplayMode(ObjectPtr theObject, DisplayMode theMode, bool toUpdate = true);
@@ -155,6 +150,10 @@ class XGUI_EXPORT XGUI_Displayer
   /// Returns currently installed AIS_InteractiveContext
   Handle(AIS_InteractiveContext) AISContext() const;
 
+  /// Returns the viewer context top filter. If there is no a filter, it is created and set into
+  /// The context should have only this filter inside. Other filters should be add to the filter
+  Handle(SelectMgr_AndFilter) GetFilter();
+
   /// Display the feature and a shape. This shape would be associated to the given feature
   /// \param theFeature a feature instance
   /// \param theAIS AIS presentation
@@ -181,6 +180,8 @@ class XGUI_EXPORT XGUI_Displayer
  protected:
   XGUI_Workshop* myWorkshop;
 
+  Handle(SelectMgr_AndFilter) myAndFilter;
+
   typedef QMap<ObjectPtr, AISObjectPtr> ResultToAISMap;
   ResultToAISMap myResult2AISObjectMap;
 
index cd13a987be12da53666ee1e9b286089b4e66ab3b..e45a52ccea18854b72d5bb65bd3e6ff39689fbd5 100644 (file)
@@ -73,7 +73,7 @@ void XGUI_ModuleConnector::activateSubShapesSelection(const QIntList& theTypes)
   foreach(int aType, theTypes) {
     aModes.append(AIS_Shape::SelectionMode((TopAbs_ShapeEnum)aType));
   }
-  aDisp->activateObjectsOutOfContext(aModes);
+  aDisp->activateObjects(aModes);
   //TODO: We have to open Local context because at neutral point filters don't work (bug 25340)
   //aDisp->addSelectionFilter(myDocumentShapeFilter);
 }