Salome HOME
Task "Make the size of the selection area even bigger, especially for points"
[modules/shaper.git] / src / PartSet / PartSet_ResultSketchPrs.cpp
index 0715850b9c9764cee537e440f25a88750f9b409d..d23125683ca8ae9868af9b340982a876810e5b84 100755 (executable)
 #include <ModelAPI_ResultConstruction.h>
 #include <GeomAPI_PlanarEdges.h>
 
-#include <Events_Error.h>
+#include <Events_InfoMessage.h>
 #include <Events_Loop.h>
 
 #include <SketchPlugin_SketchEntity.h>
 
+#include <SketcherPrs_Tools.h>
+
 #include <Config_PropManager.h>
 
 #include <BRep_Builder.hxx>
@@ -86,7 +88,7 @@ void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d)
   setAuxiliaryPresentationStyle(false);
 
   // change deviation coefficient to provide more precise circle
-  ModuleBase_Tools::setDefaultDeviationCoefficient(Shape(), Attributes());
+  ModuleBase_Tools::setDefaultDeviationCoefficient(myResult, Attributes());
   AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
 
   if (!myAuxiliaryCompound.IsNull()) {
@@ -97,7 +99,7 @@ void PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d)
   }
 
   if (!aReadyToDisplay) {
-    Events_Error::throwException("An empty AIS presentation: PartSet_ResultSketchPrs");
+    Events_InfoMessage("PartSet_ResultSketchPrs", "An empty AIS presentation: PartSet_ResultSketchPrs").send();
     static const Events_ID anEvent = Events_Loop::eventByName(EVENT_EMPTY_AIS_PRESENTATION);
     ModelAPI_EventCreator::get()->sendUpdated(myResult, anEvent);
   }
@@ -120,13 +122,21 @@ void debugInfo(const TopoDS_Shape& theShape, const TopAbs_ShapeEnum theType)
 #endif
 
 void PartSet_ResultSketchPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
-                                            const Standard_Integer aMode)
+                                            const Standard_Integer theMode)
 {
-  if (aMode > 8)
+  int aMode = theMode;
+
+  if (aMode > 8 &&
+      aMode != SketcherPrs_Tools::Sel_Sketch_Face &&
+      aMode != SketcherPrs_Tools::Sel_Sketch_Wire)
     // In order to avoid using custom selection modes
     return;
 
-  if (aMode == AIS_Shape::SelectionMode(TopAbs_FACE)) {
+  bool aShapeIsChanged = false;
+  if (aMode == SketcherPrs_Tools::Sel_Sketch_Face ||
+      aMode == SketcherPrs_Tools::Sel_Sketch_Wire) {
+    aMode = (aMode == SketcherPrs_Tools::Sel_Sketch_Face) ? AIS_Shape::SelectionMode(TopAbs_FACE)
+                                                          : AIS_Shape::SelectionMode(TopAbs_WIRE);
 #ifdef DEBUG_WIRE
     const TopoDS_Shape& aShape = Shape();
     debugInfo(aShape, TopAbs_VERTEX); // 24
@@ -142,9 +152,6 @@ void PartSet_ResultSketchPrs::ComputeSelection(const Handle(SelectMgr_Selection)
     for(NCollection_List<TopoDS_Shape>::Iterator anIt(mySketchFaceList); anIt.More(); anIt.Next()) {
       const TopoDS_Shape& aFace = anIt.Value();
       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
-      appendShapeSelection(aSelection, aFace, TopAbs_WIRE);
     }
 #ifdef DEBUG_WIRE
     debugInfo(aComp, TopAbs_VERTEX); // 24
@@ -153,18 +160,23 @@ void PartSet_ResultSketchPrs::ComputeSelection(const Handle(SelectMgr_Selection)
     debugInfo(aComp, TopAbs_FACE); // 2
 #endif
     Set(aComp);
-  } else
+    aShapeIsChanged = true;
+  }
+  else
     Set(myOriginalShape);
 
   // append auxiliary compound to selection of edges/vertices
   if (aMode == AIS_Shape::SelectionMode(TopAbs_EDGE) ||
       aMode == AIS_Shape::SelectionMode(TopAbs_VERTEX)) {
 
-        bool isVertex = aMode == AIS_Shape::SelectionMode(TopAbs_VERTEX);
+    bool isVertex = aMode == AIS_Shape::SelectionMode(TopAbs_VERTEX);
     appendShapeSelection(aSelection, myAuxiliaryCompound, isVertex ? TopAbs_VERTEX : TopAbs_EDGE);
   }
 
   AIS_Shape::ComputeSelection(aSelection, aMode);
+
+  if (aShapeIsChanged)
+    Set(myOriginalShape);
 }
 
 void PartSet_ResultSketchPrs::appendShapeSelection(const Handle(SelectMgr_Selection)& theSelection,