]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Provide selection only in plane of sketcher
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 28 Nov 2014 16:23:29 +0000 (19:23 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 28 Nov 2014 16:23:29 +0000 (19:23 +0300)
src/ModuleBase/ModuleBase_ViewerFilters.h
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

index e4aa93ae29b299bc3713a20f0424f7d5f6f1f712..4860776f4126689ef296c0244e619a5c2d49469c 100644 (file)
@@ -44,8 +44,10 @@ DEFINE_STANDARD_HANDLE(ModuleBase_ShapeInPlaneFilter, SelectMgr_Filter);
 class ModuleBase_ShapeInPlaneFilter: public SelectMgr_Filter
 {
 public:
-  Standard_EXPORT ModuleBase_ShapeInPlaneFilter(const gp_Pln& thePane): 
-      SelectMgr_Filter(), myPlane(thePane) {}
+  Standard_EXPORT ModuleBase_ShapeInPlaneFilter(): SelectMgr_Filter() {}
+
+  void setPlane(const gp_Pln& thePane) { myPlane = thePane; }
+  gp_Pln plane() const { return myPlane; }
 
   Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const;
 
index 9ced217aa2e12849bfe9cd70a957f7fe63590b47..2f4fbb47a0b8e0692af5d7537d1d218dd605c904 100644 (file)
@@ -159,6 +159,16 @@ void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
       aDisplayer->erase((*aIt), false);
     }
     aDisplayer->erase(myCurrentSketch);
+
+
+    if (myPlaneFilter.IsNull()) 
+      myPlaneFilter = new ModuleBase_ShapeInPlaneFilter();
+    myWorkshop->viewer()->addSelectionFilter(myPlaneFilter);
+    if (theOperation->isEditOperation()) {
+      // If it is editing of sketch then it means that plane is already defined
+      std::shared_ptr<GeomAPI_Pln> aPln = PartSet_Tools::sketchPlane(myCurrentSketch);
+      myPlaneFilter->setPlane(aPln->impl<gp_Pln>());
+    }
   }
 }
 
@@ -192,9 +202,14 @@ void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
     aDisplayer->display(myCurrentSketch);
     
     myCurrentSketch = CompositeFeaturePtr();
+    myWorkshop->viewer()->removeSelectionFilter(myPlaneFilter);
   }
 }
 
+void PartSet_Module::onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln)
+{
+  myPlaneFilter->setPlane(thePln->impl<gp_Pln>());
+}
 
 
 void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation)
@@ -409,6 +424,8 @@ QWidget* PartSet_Module::createWidgetByType(const std::string& theType, QWidget*
   if (theType == "sketch-start-label") {
     PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId);
     aWgt->setWorkshop(aWorkshop);
+    connect(aWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)), 
+      this, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
     theModelWidgets.append(aWgt);
     return aWgt->getControl();
 
index 7c90584b8548ce9914254f306e0c1f18acba31a8..305cd88e7f6b09487f9a19c0e01e8a5c37b3f6cb 100644 (file)
@@ -82,6 +82,8 @@ protected slots:
  private slots:
    void onVertexSelected(ObjectPtr theObject, const TopoDS_Shape& theShape);
 
+   void onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
+
  private:
    /// Converts mouse position to 2d coordinates. 
    /// Member myCurrentSketch has to be correctly defined
@@ -104,6 +106,8 @@ protected slots:
    double myCurX, myCurY;
    CompositeFeaturePtr myCurrentSketch;
    QList<FeaturePtr> myEditingFeatures;
+
+   Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;
 };
 
 #endif
index a766918818c43b5f06ddeae28c6d4336c019b055..37cd834450a68835ba3a0c0d22f29c88fa037067 100644 (file)
@@ -104,7 +104,10 @@ void PartSet_WidgetSketchLabel::onPlaneSelected()
         XGUI_Displayer* aDisp = myWorkshop->displayer();
         aDisp->removeSelectionFilter(myPlaneFilter);
         aDisp->closeLocalContexts();
+        emit planeSelected(plane());
         setSketchingMode();
+
+        // Update sketcher actions
         XGUI_ActionsMgr* anActMgr = myWorkshop->actionsMgr();
         anActMgr->update();
       }
index 7c1d460be11dc0e221cd15eca254353d83b6d3b0..906e962952a40ef48f2f082cad19b4ba9a47bc0a 100644 (file)
@@ -61,6 +61,9 @@ Q_OBJECT
 
   std::shared_ptr<GeomAPI_Pln> plane() const;
 
+signals:
+  void planeSelected(const std::shared_ptr<GeomAPI_Pln>& thePln);
+
  private slots:
   void onPlaneSelected();
 
index 74041948eb72e9a2ea85189a52c9dc2818612736..0ebba5866f740bcac44bf6e9adbf8788fe1bc970 100644 (file)
@@ -328,6 +328,9 @@ void XGUI_Displayer::openLocalContext()
     //for (aContext->InitCurrent(); aContext->MoreCurrent(); aContext->NextCurrent())
     //  aAisList.Append(aContext->Current());
 
+    SelectMgr_ListOfFilter aFilters;
+    aFilters.Assign(aContext->Filters());
+
     aContext->ClearCurrents();
     aContext->OpenLocalContext();
     aContext->NotUseDisplayedObjects();
@@ -335,6 +338,10 @@ void XGUI_Displayer::openLocalContext()
     myUseExternalObjects = false;
     myActiveSelectionModes.clear();
 
+    SelectMgr_ListIteratorOfListOfFilter aIt(aFilters);
+    for (;aIt.More(); aIt.Next()) {
+      aContext->AddFilter(aIt.Value());
+    }
     // Restore selection
     //AIS_ListIteratorOfListOfInteractive aIt(aAisList);
     //for(; aIt.More(); aIt.Next()) {