]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Selection of planar faces provided for sketcher
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 1 Sep 2014 16:09:48 +0000 (20:09 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 1 Sep 2014 16:09:48 +0000 (20:09 +0400)
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketchBase.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h

index ec21e026619bcc21858f88d50e4c5a3254956d19..993d467577ebcdba596dbb8499f0e7a071c1756f 100644 (file)
@@ -49,6 +49,9 @@
 #include <GeomAPI_AISObject.h>
 #include <AIS_Shape.hxx>
 
+#include <StdSelect_FaceFilter.hxx>
+#include <StdSelect_TypeOfFace.hxx>
+
 #include <QObject>
 #include <QMouseEvent>
 #include <QString>
@@ -347,6 +350,7 @@ void PartSet_Module::onSetSelection(const QList<ObjectPtr>& theFeatures)
 void PartSet_Module::onCloseLocalContext()
 {
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+  aDisplayer->deactivateObjectsOutOfContext();
   aDisplayer->closeLocalContexts();
 }
 
@@ -519,6 +523,13 @@ void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateVi
     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
     std::list<int> aModes = aPreviewOp->getSelectionModes(theFeature);
     aDisplayer->activateInLocalContext(theFeature, aModes, isUpdateViewer);
+
+    // If this is a Sketcher then activate objects (planar faces) outside of context
+    PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
+    if (aSketchOp) {
+      Handle(StdSelect_FaceFilter) aFilter = new StdSelect_FaceFilter(StdSelect_Plane);
+      aDisplayer->activateObjectsOutOfContext(aModes, aFilter);
+    }
   }
 }
 
index ece230157c94da4da77546438e8eab2b52385497..acd79461dc773c4fb58ba4c62a7b4c97329fe1e3 100644 (file)
@@ -115,13 +115,7 @@ void PartSet_OperationSketch::mouseReleased(QMouseEvent* theEvent, Handle_V3d_Vi
     if (theSelected.size() == 1) {
       ObjectPtr aObject = theSelected.front().object();
       if (aObject) {
-        FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
-        if (aFeature) {
-          QStringList aNested = this->nestedFeatures();
-          if ((!aNested.isEmpty()) && aNested.contains(QString(aFeature->getKind().c_str()))) {
-            restartOperation(PartSet_OperationFeatureEdit::Type(), aObject);
-          }
-        }
+        restartOperation(PartSet_OperationFeatureEdit::Type(), aObject);
       }
     }
   }
@@ -263,4 +257,5 @@ bool PartSet_OperationSketch::isValid(ModuleBase_IOperation* theOperation) const
 {
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
   return aPreviewOp != NULL;
-}
\ No newline at end of file
+}
+
index d90de1d2902bfa87aa78305a1f297c36cb329ab7..9272c8c9e6c8dd48dc84c8e59c51b20d6b6df01e 100644 (file)
@@ -124,5 +124,15 @@ void PartSet_OperationSketchBase::keyReleased(std::string theName, QKeyEvent* th
 
 void PartSet_OperationSketchBase::restartOperation(const std::string& theType, ObjectPtr theFeature)
 {
+  FeaturePtr aFeature = ModelAPI_Feature::feature(theFeature);
+  if (aFeature) {
+    QStringList aNested = this->nestedFeatures();
+    if (!aNested.isEmpty()) {
+      if (aNested.contains(QString(aFeature->getKind().c_str()))) 
+        emit launchOperation(theType, theFeature);
+      else
+        return;
+    }
+  }
   emit launchOperation(theType, theFeature);
 }
index 7d397b1960925b772b7f6357634e2982db1d1c58..26def2f04855d27112bc55dee573509876f2d47d 100644 (file)
@@ -20,7 +20,6 @@
 #include <AIS_ListOfInteractive.hxx>
 #include <AIS_ListIteratorOfListOfInteractive.hxx>
 #include <AIS_DimensionSelectionMode.hxx>
-
 #include <AIS_Shape.hxx>
 
 #include <set>
@@ -169,17 +168,10 @@ void XGUI_Displayer::activateInLocalContext(ObjectPtr theResult, const std::list
   // Open local context if there is no one
   if (!aContext->HasOpenedContext()) {
     aContext->ClearCurrents(false);
-    aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/);
-    //aContext->OpenLocalContext();
-    //aContext->NotUseDisplayedObjects();
+    //aContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/);
+    aContext->OpenLocalContext();
+    aContext->NotUseDisplayedObjects();
   }
-  //!!! Test
-  //aContext->UseDisplayedObjects();
-  //std::list<int>::const_iterator anIt = theModes.begin(), aLast = theModes.end();
-  //for (; anIt != aLast; anIt++) {
-  //  aContext->ActivateStandardMode((TopAbs_ShapeEnum)(*anIt));
-  //}
-  //!!! Test end
   // display or redisplay presentation
   Handle(AIS_InteractiveObject) anAIS;
   if (isVisible(theResult)) {
@@ -338,6 +330,7 @@ void XGUI_Displayer::eraseDeletedResults(const bool isUpdateViewer)
 
 void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer)
 {
+  AISContext()->ClearSelected(false);
   closeAllContexts(true);
 }
 
@@ -405,3 +398,32 @@ void XGUI_Displayer::erase(boost::shared_ptr<GeomAPI_AISObject> theAIS, const bo
   }
 }
 
+void XGUI_Displayer::activateObjectsOutOfContext(const std::list<int>& theModes, 
+                                                 Handle(SelectMgr_Filter) theFilter)
+{
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  // Open local context if there is no one
+  if (!aContext->HasOpenedContext()) 
+    return;
+
+  aContext->UseDisplayedObjects();
+  std::list<int>::const_iterator anIt = theModes.begin(), aLast = theModes.end();
+  for (; anIt != aLast; anIt++) {
+    aContext->ActivateStandardMode((TopAbs_ShapeEnum)(*anIt));
+  }
+
+  if (!theFilter.IsNull())
+    aContext->AddFilter(theFilter);
+}
+
+
+void XGUI_Displayer::deactivateObjectsOutOfContext()
+{
+  Handle(AIS_InteractiveContext) aContext = AISContext();
+  // Open local context if there is no one
+  if (!aContext->HasOpenedContext()) 
+    return;
+
+  aContext->RemoveFilters();
+  aContext->NotUseDisplayedObjects();
+}
\ No newline at end of file
index ef3a3308db2a6c046469782c7d27c50e25a80595..5c54857d07bf4cab3ef6ca813907ce91e2703f94 100644 (file)
@@ -124,6 +124,14 @@ class XGUI_EXPORT XGUI_Displayer
 
   void activate(ObjectPtr theFeature);
 
+  /// Activates in local context displayed outside of the context.
+  /// \param theModes - selection modes to activate
+  /// \param theFilter - filter for selection
+  void activateObjectsOutOfContext(const std::list<int>& theModes, 
+                                   Handle(SelectMgr_Filter) theFilter);
+
+  void deactivateObjectsOutOfContext();
+
  protected:
   /// Deactivate local selection
   /// \param isUpdateViewer the state wether the viewer should be updated immediatelly