]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Debug of the filters. Functionality is the same.
authornds <natalia.donis@opencascade.com>
Wed, 8 Jul 2015 08:17:26 +0000 (11:17 +0300)
committernds <natalia.donis@opencascade.com>
Wed, 8 Jul 2015 08:17:26 +0000 (11:17 +0300)
src/ModuleBase/ModuleBase_FilterValidated.cpp
src/ModuleBase/ModuleBase_FilterValidated.h
src/ModuleBase/ModuleBase_ViewerFilters.cpp
src/PartSet/PartSet_FilterInfinite.cpp
src/PartSet/PartSet_Filters.cpp

index 38dc9a3f506b5acd1b9fe6828e8d964430861adb..3fdb61e15506e7cc77360290ccfadba68b760c17 100644 (file)
@@ -19,19 +19,24 @@ IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_FilterValidated, SelectMgr_Filter);
 
 Standard_Boolean ModuleBase_FilterValidated::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
 {
+  bool aValid = true;
   ModuleBase_Operation* anOperation = myWorkshop->module()->currentOperation();
-  if (!anOperation)
-    return true;
-
-  ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
-  ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
-  if (!anActiveWidget)
-    anActiveWidget = aPanel->preselectionWidget();
-  ModuleBase_WidgetValidated* aWidgetValidated = dynamic_cast<ModuleBase_WidgetValidated*>
-                                                                         (anActiveWidget);
-  ModuleBase_ViewerPrs aPrs;
-  myWorkshop->selection()->fillPresentation(aPrs, theOwner);
-
-  return !aWidgetValidated || aWidgetValidated->isValidSelection(aPrs);
+  if (anOperation) {
+    ModuleBase_IPropertyPanel* aPanel = anOperation->propertyPanel();
+    ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
+    if (!anActiveWidget)
+      anActiveWidget = aPanel->preselectionWidget();
+    ModuleBase_WidgetValidated* aWidgetValidated = dynamic_cast<ModuleBase_WidgetValidated*>
+                                                                           (anActiveWidget);
+    ModuleBase_ViewerPrs aPrs;
+    myWorkshop->selection()->fillPresentation(aPrs, theOwner);
+
+    aValid = !aWidgetValidated || aWidgetValidated->isValidSelection(aPrs);
+  }
+
+#ifdef DEBUG_FILTERS
+  qDebug(QString("ModuleBase_FilterValidated::IsOk = %1").arg(aValid).toStdString().c_str());
+#endif
+  return aValid;
 }
 
index 2fd2371b9705cb51b370515761acf6bf95188cc5..d2d58d6c9c4417dce8d0ae19fac90be8793cc0b1 100644 (file)
@@ -13,6 +13,8 @@
 
 class ModuleBase_IWorkshop;
 
+//#define DEBUG_FILTERS
+
 /**
 * \ingroup GUI
 * \class ModuleBase_FilterValidated
index a7c1e7f644f80e491b0f75c58c3bd179b57524e2..6406ccca612aca59840aa253b243fbecf8c65f55 100644 (file)
@@ -31,31 +31,37 @@ IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_ShapeDocumentFilter, SelectMgr_Filter);
 //TODO (VSV): Check bug in OCCT: Filter result is ignored (bug25340)
 Standard_Boolean ModuleBase_ShapeDocumentFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
 {
+  bool aValid = true;
+
   ModuleBase_Operation* anOperation = myWorkshop->module()->currentOperation();
   // the shapes from different documents should be provided if there is no started operation
   // in order to show/hide results
-  if (!anOperation)
-    return true;
-
-  std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
-  if (theOwner->HasSelectable()) {
-    Handle(AIS_InteractiveObject) aAisObj =
-                     Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
-    if (!aAisObj.IsNull()) {
-      aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj));
+  if (anOperation) {
+    aValid = Standard_False;
+    std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+    if (theOwner->HasSelectable()) {
+      Handle(AIS_InteractiveObject) aAisObj =
+                       Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
+      if (!aAisObj.IsNull()) {
+        aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj));
+      }
+    }
+    ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj);
+    if (aObj) {
+      DocumentPtr aDoc = aObj->document();
+      SessionPtr aMgr = ModelAPI_Session::get();
+      aValid = (aDoc == aMgr->activeDocument() || aDoc == aMgr->moduleDocument());
+    }
+    else {
+      // This object is not controlled by the filter
+      aValid = Standard_True;
     }
   }
-  ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj);
-  if (aObj) {
-    DocumentPtr aDoc = aObj->document();
-    SessionPtr aMgr = ModelAPI_Session::get();
-    return (aDoc == aMgr->activeDocument() || aDoc == aMgr->moduleDocument());
-  }
-  else {
-    // This object is not controlled by the filter
-    return Standard_True;
-  }
-  return Standard_False;
+
+#ifdef DEBUG_FILTERS
+  qDebug(QString("ModuleBase_ShapeDocumentFilter::IsOk = %1").arg(aValid).toStdString().c_str());
+#endif
+  return aValid;
 }
 
 IMPLEMENT_STANDARD_HANDLE(ModuleBase_ShapeInPlaneFilter, SelectMgr_Filter);
@@ -63,44 +69,49 @@ IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_ShapeInPlaneFilter, SelectMgr_Filter);
 
 Standard_Boolean ModuleBase_ShapeInPlaneFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
 {
-  if (!myPlane.get())
-    return Standard_True;
+  bool aValid = true;
 
-  if (theOwner->HasSelectable()) {
-    Handle(StdSelect_BRepOwner) aShapeOwner = Handle(StdSelect_BRepOwner)::DownCast(theOwner);
-    if (!aShapeOwner.IsNull()) {
-      TopoDS_Shape aShape = aShapeOwner->Shape();
-      TopAbs_ShapeEnum aType = aShape.ShapeType();
-      gp_Pln aPlane = myPlane->impl<gp_Pln>();
-      switch (aType) {
-      case TopAbs_VERTEX:
-        {
-          gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
-          return aPlane.Distance(aPnt) < Precision::Confusion();
-        }
-      case TopAbs_EDGE:
-        {
-          TopoDS_Edge aEdge = TopoDS::Edge(aShape);
-          Standard_Real aFirst, aLast;
-          Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aFirst, aLast);
-          gp_Pnt aFirstPnt = aCurve->Value(aFirst);
-          gp_Pnt aMidPnt = aCurve->Value((aFirst + aLast) / 2.);
-          gp_Pnt aLastPnt = aCurve->Value(aLast);
-          bool aD1 = aPlane.Distance(aFirstPnt) < Precision::Confusion();
-          bool aD2 = aPlane.Distance(aMidPnt) < Precision::Confusion();
-          bool aD3 = aPlane.Distance(aLastPnt) < Precision::Confusion();
-          return aD1 && aD2 && aD3;
+  if (myPlane.get()) {
+    aValid = Standard_False;
+    if (theOwner->HasSelectable()) {
+      Handle(StdSelect_BRepOwner) aShapeOwner = Handle(StdSelect_BRepOwner)::DownCast(theOwner);
+      if (!aShapeOwner.IsNull()) {
+        TopoDS_Shape aShape = aShapeOwner->Shape();
+        TopAbs_ShapeEnum aType = aShape.ShapeType();
+        gp_Pln aPlane = myPlane->impl<gp_Pln>();
+        switch (aType) {
+        case TopAbs_VERTEX:
+          {
+            gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
+            return aPlane.Distance(aPnt) < Precision::Confusion();
+          }
+        case TopAbs_EDGE:
+          {
+            TopoDS_Edge aEdge = TopoDS::Edge(aShape);
+            Standard_Real aFirst, aLast;
+            Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aFirst, aLast);
+            gp_Pnt aFirstPnt = aCurve->Value(aFirst);
+            gp_Pnt aMidPnt = aCurve->Value((aFirst + aLast) / 2.);
+            gp_Pnt aLastPnt = aCurve->Value(aLast);
+            bool aD1 = aPlane.Distance(aFirstPnt) < Precision::Confusion();
+            bool aD2 = aPlane.Distance(aMidPnt) < Precision::Confusion();
+            bool aD3 = aPlane.Distance(aLastPnt) < Precision::Confusion();
+            return aD1 && aD2 && aD3;
+          }
+        default:
+          // The object can be selected in Object browser and contain, for example, compound.
+          // The compound could not belong to any plane, so the result is false
+          aValid = Standard_False;
+        break;
         }
-      default:
-        // The object can be selected in Object browser and contain, for example, compound.
-        // The compound could not belong to any plane, so the result is false
-        return Standard_False;
-      break;
+      } else {
+        // This is not object controlled by the filter
+        aValid = Standard_True;
       }
-    } else {
-      // This is not object controlled by the filter
-      return Standard_True;
     }
   }
-  return Standard_False;
+#ifdef DEBUG_FILTERS
+  qDebug(QString("ModuleBase_ShapeDocumentFilter::IsOk = %1").arg(aValid).toStdString().c_str());
+#endif
+  return aValid;
 }
index 3feadea09acb818fc002f474a9e88860ec8201c9..b26ad156fae12cb6fd815269971925b1ec018719 100755 (executable)
@@ -52,5 +52,8 @@ Standard_Boolean PartSet_FilterInfinite::IsOk(const Handle(SelectMgr_EntityOwner
       }
     }
   }
+#ifdef DEBUG_FILTERS
+  qDebug(QString("ModuleBase_ShapeDocumentFilter::IsOk = %1").arg(aValid).toStdString().c_str());
+#endif
   return aValid;
 }
index 0921844d6456fbb13161d1b1e255052c935dd598..3842bc8b9ca21b3913dfb84adc468302e6ec749c 100644 (file)
@@ -21,31 +21,35 @@ IMPLEMENT_STANDARD_RTTIEXT(PartSet_GlobalFilter, ModuleBase_ShapeDocumentFilter)
 
 Standard_Boolean PartSet_GlobalFilter::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
 {
+  bool aValid = true;
   ModuleBase_Operation* anOperation = myWorkshop->module()->currentOperation();
   // the shapes from different documents should be provided if there is no started operation
   // in order to show/hide results
-  if (!anOperation)
-    return true;
-
-  if (ModuleBase_ShapeDocumentFilter::IsOk(theOwner)) {
-    std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
-    if (theOwner->HasSelectable()) {
-      Handle(AIS_InteractiveObject) aAisObj = 
-        Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
-      if (!aAisObj.IsNull()) {
-        aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj));
+  if (!anOperation) {
+    aValid = false;
+    if (ModuleBase_ShapeDocumentFilter::IsOk(theOwner)) {
+      std::shared_ptr<GeomAPI_AISObject> aAISObj = AISObjectPtr(new GeomAPI_AISObject());
+      if (theOwner->HasSelectable()) {
+        Handle(AIS_InteractiveObject) aAisObj = 
+          Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
+        if (!aAisObj.IsNull()) {
+          aAISObj->setImpl(new Handle(AIS_InteractiveObject)(aAisObj));
+        }
       }
+      ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj);
+      if (aObj) {
+        FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
+        if (aFeature) {
+          aValid = aFeature->getKind() != FeaturesPlugin_Group::ID();
+        } else 
+          aValid = Standard_True;
+      } else
+        // This is not object controlled by the filter
+        aValid = Standard_True;
     }
-    ObjectPtr aObj = myWorkshop->findPresentedObject(aAISObj);
-    if (aObj) {
-      FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
-      if (aFeature) {
-        return aFeature->getKind() != FeaturesPlugin_Group::ID();
-      } else 
-        return Standard_True;
-    } else
-      // This is not object controlled by the filter
-      return Standard_True;
   }
-  return Standard_False;
+#ifdef DEBUG_FILTERS
+  qDebug(QString("PartSet_GlobalFilter::IsOk = %1").arg(aValid).toStdString().c_str());
+#endif
+  return aValid;
 }