]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1343 Improvement of Extrusion and Revolution operations: wires selection.
authornds <nds@opencascade.com>
Fri, 25 Mar 2016 09:13:23 +0000 (12:13 +0300)
committerdbv <dbv@opencascade.com>
Wed, 6 Apr 2016 10:24:34 +0000 (13:24 +0300)
src/FeaturesPlugin/FeaturesPlugin_ValidatorExtrusionBase.cpp
src/Model/Model_AttributeSelection.cpp
src/ModuleBase/ModuleBase_ResultPrs.cpp
src/ModuleBase/ModuleBase_ResultPrs.h
src/ModuleBase/ModuleBase_WidgetSelector.cpp

index 7f16df44e95d7d2bcac11ced6b23f98e6f4cba93..00f2dc1706937693779e7541be393b8ea2b6c94e 100755 (executable)
@@ -17,7 +17,7 @@ bool FeaturesPlugin_ValidatorExtrusionBase::isValid(const AttributePtr& theAttri
 {
   bool aValid = true;
 
-  GeomValidators_FeatureKind* aValidator = new GeomValidators_FeatureKind();
+  /*GeomValidators_FeatureKind* aValidator = new GeomValidators_FeatureKind();
   // check whether the selection is on the sketch
   bool aFeatureKindValid = aValidator->isValid(theAttribute, theArguments, theError);
   if (!aFeatureKindValid) {
@@ -26,6 +26,6 @@ bool FeaturesPlugin_ValidatorExtrusionBase::isValid(const AttributePtr& theAttri
     std::list<std::string> anArguments;
     anArguments.push_back("face");
     aValid = aShapeType->isValid(theAttribute, anArguments, theError);
-  }
+  }*/
   return aValid;
 }
index f388abb9ea40bbde10328ad009319dbccdebf79d..da94a1206428e9e90a3039d00457b778cc6f2dc5 100644 (file)
@@ -686,6 +686,7 @@ static void registerSubShape(TDF_Label theMainLabel, TopoDS_Shape theShape,
   if (!theAdditionalName.empty())
     aName<<theAdditionalName<<"/";
   if (theShape.ShapeType() == TopAbs_FACE) aName<<"Face";
+  else if (theShape.ShapeType() == TopAbs_WIRE) aName<<"Wire";
   else if (theShape.ShapeType() == TopAbs_EDGE) aName<<"Edge";
   else if (theShape.ShapeType() == TopAbs_VERTEX) aName<<"Vertex";
 
index 3b32e56eef836e75c07ed6542088306ae578a01b..4491b273a64aa0d0c2e105381161c8d810e259a1 100755 (executable)
 #include <AIS_Selection.hxx>
 #include <TColStd_ListIteratorOfListOfInteger.hxx>
 
+//#define DEBUG_WIRE
 
+#ifdef DEBUG_WIRE
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopExp.hxx>
+#endif
 
 IMPLEMENT_STANDARD_HANDLE(ModuleBase_BRepOwner, StdSelect_BRepOwner);
 IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_BRepOwner, StdSelect_BRepOwner);
@@ -68,6 +73,18 @@ ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult)
   SetAutoHilight(aCompSolid.get() == NULL);
 }
 
+bool ModuleBase_ResultPrs::isValidShapeType(const TopAbs_ShapeEnum& theBaseType,
+                                            const TopAbs_ShapeEnum& theCheckedType)
+{
+  bool aValid = theBaseType == theCheckedType;
+  if (!aValid) {
+    // currently this functionality is for all, as we have no separate wire selection mode
+    // lately it should be corrected to have the following check only for sketch presentations
+    aValid = theBaseType == TopAbs_FACE && theCheckedType == TopAbs_WIRE;
+  }
+  return aValid;
+}
+
 
 void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
                                    const Handle(Prs3d_Presentation)& thePresentation, 
@@ -102,6 +119,21 @@ void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
     Events_Error::throwException("An empty AIS presentation: ModuleBase_ResultPrs");
 }
 
+#ifdef DEBUG_WIRE
+void debugInfo(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType)
+{
+  TopTools_IndexedMapOfShape aSubShapes;
+  TopExp::MapShapes (theShape, theType, aSubShapes);
+
+  Standard_Boolean isComesFromDecomposition = !((aSubShapes.Extent() == 1) && (theShape == aSubShapes (1)));
+  int anExtent = aSubShapes.Extent();
+  for (Standard_Integer aShIndex = 1; aShIndex <= aSubShapes.Extent(); ++aShIndex)
+  {
+    const TopoDS_Shape& aSubShape = aSubShapes (aShIndex);
+    int aValue = 0;
+  }
+}
+#endif
 
 void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
                                             const Standard_Integer aMode)
@@ -110,9 +142,15 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a
     // In order to avoid using custom selection modes
     return;
 
-  
   if (myIsSketchMode) {
     if (aMode == AIS_Shape::SelectionMode(TopAbs_FACE)) {
+#ifdef DEBUG_WIRE
+      const TopoDS_Shape& aShape = Shape();
+      debugInfo(aShape, TopAbs_VERTEX); // 24
+      debugInfo(aShape, TopAbs_EDGE); // 12
+      debugInfo(aShape, TopAbs_WIRE); // 0
+      debugInfo(aShape, TopAbs_FACE); // 0
+#endif
       BRep_Builder aBuilder;
       TopoDS_Compound aComp;
       aBuilder.MakeCompound(aComp);
@@ -121,7 +159,16 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a
       for (aIt = myFacesList.cbegin(); aIt != myFacesList.cend(); ++aIt) {
         TopoDS_Shape aFace = (*aIt)->impl<TopoDS_Shape>();
         aBuilder.Add(aComp, aFace);
+        // for sketch presentation in the face mode wires should be selectable also
+        // accoring to #1343 Improvement of Extrusion and Revolution operations
+        appendWiresSelection(aSelection, aFace);
       }
+#ifdef DEBUG_WIRE
+      debugInfo(aComp, TopAbs_VERTEX); // 24
+      debugInfo(aComp, TopAbs_EDGE); // 12
+      debugInfo(aComp, TopAbs_WIRE); // 4
+      debugInfo(aComp, TopAbs_FACE); // 2
+#endif
       Set(aComp);
     } else
       Set(myOriginalShape);
@@ -171,6 +218,24 @@ bool ModuleBase_ResultPrs::hasCompSolidSelectionMode() const
   return false;
 }
 
+void ModuleBase_ResultPrs::appendWiresSelection(const Handle(SelectMgr_Selection)& theSelection,
+                                                const TopoDS_Shape& theShape)
+{
+  static TopAbs_ShapeEnum TypOfSel
+          = AIS_Shape::SelectionType(AIS_Shape::SelectionMode(TopAbs_WIRE));
+  // POP protection against crash in low layers
+  Standard_Real aDeflection = Prs3d::GetDeflection(theShape, myDrawer);
+  try {
+    StdSelect_BRepSelectionTool::Load(theSelection,
+                                      this,
+                                      theShape,
+                                      TypOfSel,
+                                      aDeflection,
+                                      myDrawer->HLRAngle(),
+                                      myDrawer->IsAutoTriangulation());
+  } catch ( Standard_Failure ) {
+  }
+}
 
 TopoDS_Shape ModuleBase_ResultPrs::getSelectionShape() const
 {
index 056d757e18b619639cee7317391eedeafd3d317a..e6f2e3e7e41daa59c485b66a6661e6e4328a78d4 100644 (file)
@@ -53,6 +53,12 @@ public:
   /// \param theResult a result object
   Standard_EXPORT ModuleBase_ResultPrs(ResultPtr theResult);
 
+  /// Returns true if the checked type can be accepted for the base selection type
+  /// It returns true if they are coicide or if the base type is face and the checked type is wire
+  /// @return boolean result
+  static Standard_EXPORT bool isValidShapeType(const TopAbs_ShapeEnum& theBaseType,
+                                               const TopAbs_ShapeEnum& theCheckedType);
+
 
   //! Method which draws selected owners ( for fast presentation draw )
   Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM, 
@@ -86,6 +92,11 @@ protected:
     const Standard_Integer aMode) ;
 
 private:
+  /// Appens sensitive and owners for wires of the given shape into selection
+  /// \param theSelection a current filled selection
+  /// \param theShape a shape
+  void appendWiresSelection(const Handle(SelectMgr_Selection)& theSelection,
+                            const TopoDS_Shape& theShape);
   /// Returns shape dependent on CompSolid selection mode
   /// In case CompSolid selection mode it returns parent's compsolid shape
   TopoDS_Shape getSelectionShape() const;
index 454ed88de5f6efac08c523c516309db07f23e720..e07b726b22d17ab17f93955932b6445288e736f8 100755 (executable)
@@ -13,6 +13,7 @@
 #include <ModuleBase_OperationDescription.h>
 #include <ModuleBase_WidgetFactory.h>
 #include <ModuleBase_IModule.h>
+#include <ModuleBase_ResultPrs.h>
 
 #include <ModelAPI_ResultConstruction.h>
 
@@ -105,15 +106,17 @@ bool ModuleBase_WidgetSelector::acceptSubShape(const GeomShapePtr& theShape,
 
   QIntList::const_iterator anIt = aShapeTypes.begin(), aLast = aShapeTypes.end();
   for (; anIt != aLast; anIt++) {
-    if (aShapeType == *anIt)
+    TopAbs_ShapeEnum aCurrentShapeType = (TopAbs_ShapeEnum)*anIt;
+    if (aShapeType == aCurrentShapeType)
       aValid = true;
-    else if (*anIt == TopAbs_FACE) {
+    else if (aCurrentShapeType == TopAbs_FACE) {
       // try to process the construction shape only if there is no a selected shape in the viewer
       if (!theShape.get() && theResult.get()) {
         ResultConstructionPtr aCResult =
                                 std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(theResult);
         aValid = aCResult.get() && aCResult->facesNum() > 0;
       }
+      aValid = ModuleBase_ResultPrs::isValidShapeType(aCurrentShapeType, aShapeType);
     }
   }
   return aValid;