]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
#1371 Using auxilliary Sketch elements in any Feature
authornds <nds@opencascade.com>
Fri, 25 Mar 2016 16:20:11 +0000 (19:20 +0300)
committerdbv <dbv@opencascade.com>
Wed, 6 Apr 2016 10:25:11 +0000 (13:25 +0300)
15 files changed:
src/ModuleBase/ModuleBase_IModule.cpp
src/ModuleBase/ModuleBase_IModule.h
src/ModuleBase/ModuleBase_ResultPrs.cpp
src/ModuleBase/ModuleBase_ResultPrs.h
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_ResultSketchPrs.cpp [new file with mode: 0755]
src/PartSet/PartSet_ResultSketchPrs.h [new file with mode: 0755]
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Tools.h
src/PartSet/PartSet_WidgetPoint2d.cpp
src/XGUI/XGUI_Displayer.cpp

index 4d89489a42166c11a8b513d186ba93a888db56c1..bf95e40c5fbcea20bbb919decb269b9d6e6eb447 100644 (file)
@@ -66,6 +66,11 @@ void ModuleBase_IModule::sendOperation(ModuleBase_Operation* theOperation)
   Events_Loop::loop()->send(aMessage);
 }
 
+Handle(AIS_InteractiveObject) ModuleBase_IModule::createPresentation(const ResultPtr& theResult)
+{
+  return Handle(AIS_InteractiveObject)();
+}
+
 QString ModuleBase_IModule::getFeatureError(const FeaturePtr& theFeature)
 {
   return ModelAPI_Tools::getFeatureError(theFeature).c_str();
index 45d070997c34b9c430a8325891eeba0b5737d2f2..8a25b2afbe6116f0d9ff831c25adbbad1fd22e00 100755 (executable)
@@ -228,6 +228,11 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
   /// \param theOperation the operation\r
   virtual void sendOperation(ModuleBase_Operation* theOperation);\r
 \r
+  /// Create specific for the module presentation\r
+  /// \param theResult an object for presentation\r
+  /// \return created presentation or NULL(default value)\r
+  virtual Handle(AIS_InteractiveObject) createPresentation(const ResultPtr& theResult);\r
+\r
   //! Returns data object by AIS\r
   virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const = 0;\r
 \r
index 4491b273a64aa0d0c2e105381161c8d810e259a1..0a278d93aa5ccaa34cb0e2af30dae9a6758be1d5 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);
 
@@ -48,18 +41,9 @@ IMPLEMENT_STANDARD_RTTIEXT(ModuleBase_ResultPrs, ViewerData_AISShape);
 
 
 ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult)
-  : ViewerData_AISShape(TopoDS_Shape()), myResult(theResult), myIsSketchMode(false)
+  : ViewerData_AISShape(TopoDS_Shape()), myResult(theResult)
 {
   std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(theResult);
-  std::shared_ptr<GeomAPI_PlanarEdges> aWirePtr = 
-    std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aShapePtr);
-  if (aWirePtr) {
-    if (aWirePtr->hasPlane() ) {
-      // If this is a wire with plane defined thin it is a sketch-like object
-      // It must have invisible faces
-      myIsSketchMode = true;
-    }
-  }
   TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
   Set(aShape);
   Handle(Prs3d_Drawer) aDrawer = Attributes();
@@ -96,17 +80,6 @@ void ModuleBase_ResultPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
     return;
   }
 
-  if (myIsSketchMode) {
-    myFacesList.clear();
-    ResultConstructionPtr aConstruction = 
-      std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(myResult);
-    if (aConstruction.get()) {
-      int aFacesNum = aConstruction->facesNum();
-      for(int aFaceIndex = 0; aFaceIndex < aFacesNum; aFaceIndex++) {
-        myFacesList.push_back(aConstruction->face(aFaceIndex));
-      }
-    }
-  }
   myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
   if (!myOriginalShape.IsNull()) {
     Set(myOriginalShape);
@@ -119,22 +92,6 @@ 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)
 {
@@ -142,37 +99,6 @@ 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);
-      aBuilder.Add(aComp, myOriginalShape);
-      std::list<std::shared_ptr<GeomAPI_Shape>>::const_iterator aIt;
-      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);
-  } 
   if (aMode == AIS_Shape::SelectionMode(TopAbs_COMPSOLID)) {
     // Limit selection area only by actual object (Shape)
     ResultCompSolidPtr aCompSolid = ModelAPI_Tools::compSolidOwner(myResult);
@@ -200,24 +126,6 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a
   AIS_Shape::ComputeSelection(aSelection, aMode);
 }
 
-
-bool ModuleBase_ResultPrs::hasCompSolidSelectionMode() const
-{
-  if (!HasInteractiveContext()) 
-    return false;
-
-  Handle(AIS_InteractiveContext) aContext = GetContext();
-  TColStd_ListOfInteger aModes;
-  aContext->ActivatedModes(this, aModes);
-
-  TColStd_ListIteratorOfListOfInteger aIt(aModes);
-  for (; aIt.More(); aIt.Next()) {
-    if (aIt.Value() == AIS_Shape::SelectionMode(TopAbs_COMPSOLID)) 
-      return true;
-  }
-  return false;
-}
-
 void ModuleBase_ResultPrs::appendWiresSelection(const Handle(SelectMgr_Selection)& theSelection,
                                                 const TopoDS_Shape& theShape)
 {
@@ -237,21 +145,6 @@ void ModuleBase_ResultPrs::appendWiresSelection(const Handle(SelectMgr_Selection
   }
 }
 
-TopoDS_Shape ModuleBase_ResultPrs::getSelectionShape() const
-{
-  if (hasCompSolidSelectionMode()) {
-    // In case of CompSolid mode use shape from Parent for highlighting
-    ResultCompSolidPtr aCompSolid = ModelAPI_Tools::compSolidOwner(myResult);
-    if (aCompSolid.get()) {
-      std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aCompSolid);
-      if (aShapePtr.get()) 
-        return aShapePtr->impl<TopoDS_Shape>();
-    }
-  } 
-  return myOriginalShape;
-}
-
-
 void ModuleBase_ResultPrs::HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM, 
                                            const SelectMgr_SequenceOfOwner& theOwners)
 {
index e6f2e3e7e41daa59c485b66a6661e6e4328a78d4..729d131aa7675ddfd5545040ec660a7cace23b5f 100644 (file)
@@ -73,13 +73,7 @@ public:
   Standard_EXPORT ResultPtr getResult() const { return myResult; }
 
   /// Returns True if the presentation is in sketch mode
-  Standard_EXPORT bool isSketchMode() const { return myIsSketchMode; }
-
-  /// Returns a list of faces
-  Standard_EXPORT const std::list<std::shared_ptr<GeomAPI_Shape> >& facesList() { return myFacesList; }
-
-  /// Returns true if the object is used in CompSolid selection mode
-  Standard_EXPORT bool hasCompSolidSelectionMode() const;
+  Standard_EXPORT bool isSketchMode() const { return false; }
 
   DEFINE_STANDARD_RTTI(ModuleBase_ResultPrs)
 protected:
@@ -97,21 +91,12 @@ private:
   /// \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;
 
   /// Reference to result object
   ResultPtr myResult;
 
-  /// A sketch mode flag
-  bool myIsSketchMode;
-
   /// Original shape of the result object
   TopoDS_Shape myOriginalShape;
-
-  /// List of faces
-  std::list<std::shared_ptr<GeomAPI_Shape> > myFacesList;
 };
 
 
index 86da38c63a53adaa33137cdc7fbce76eca6bfe6f..bb032d0d76b5f9fd41f0c85761c092c80714e18a 100644 (file)
@@ -26,6 +26,7 @@ SET(PROJECT_HEADERS
        PartSet_WidgetFileSelector.h
        PartSet_Filters.h
        PartSet_FilterInfinite.h
+       PartSet_ResultSketchPrs.h
        PartSet_SketcherMgr.h
        PartSet_SketcherReetntrantMgr.h
        PartSet_MenuMgr.h
@@ -54,6 +55,7 @@ SET(PROJECT_SOURCES
        PartSet_WidgetFileSelector.cpp
        PartSet_Filters.cpp
        PartSet_FilterInfinite.cpp
+       PartSet_ResultSketchPrs.cpp
        PartSet_SketcherMgr.cpp
        PartSet_SketcherReetntrantMgr.cpp
        PartSet_MenuMgr.cpp
index 701a5015ff35d0c89d689abdff2c0dfb7413531b..6cb3178322a0b6addc71f1d05d60846cbc4d96c0 100755 (executable)
@@ -1015,6 +1015,11 @@ void PartSet_Module::onActiveDocPopup(const QPoint& thePnt)
   aMenu.exec(aHeader->mapToGlobal(thePnt));
 }
 
+Handle(AIS_InteractiveObject) PartSet_Module::createPresentation(const ResultPtr& theResult)
+{
+  return mySketchMgr->createPresentation(theResult);
+}
+
 
 ObjectPtr PartSet_Module::findPresentedObject(const AISObjectPtr& theAIS) const
 {
index 0117e96b434e73707aa817d539fc905f9994e1a8..46392a361ec5b8d900a8d1bdf9e3c76656d52162 100755 (executable)
@@ -249,6 +249,11 @@ public:
   /// Returns the viewer Z layer
   int getVisualLayerId() const { return myVisualLayerId; }
 
+  /// Create specific for the module presentation
+  /// \param theResult an object for presentation
+  /// \return created presentation or NULL(default value)
+  virtual Handle(AIS_InteractiveObject) createPresentation(const ResultPtr& theResult);
+
   //! Returns data object by AIS
   virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const;
 
diff --git a/src/PartSet/PartSet_ResultSketchPrs.cpp b/src/PartSet/PartSet_ResultSketchPrs.cpp
new file mode 100755 (executable)
index 0000000..956e60c
--- /dev/null
@@ -0,0 +1,258 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_ResultSketchPrs.h
+// Created:     25 March 2015
+// Author:      Natalia ERMOLAEVA
+
+#include "PartSet_ResultSketchPrs.h"
+#include "PartSet_Tools.h"
+#include "ModuleBase_Tools.h"
+
+#include <ModelAPI_Tools.h>
+#include <ModelAPI_ResultConstruction.h>
+#include <GeomAPI_PlanarEdges.h>
+
+#include <Events_Error.h>
+
+#include <SketchPlugin_SketchEntity.h>
+
+#include <Config_PropManager.h>
+
+#include <BRep_Builder.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d.hxx>
+#include <Prs3d_PointAspect.hxx>
+#include <TopoDS_Builder.hxx>
+#include <SelectMgr_SelectionManager.hxx>
+#include <StdPrs_WFDeflectionShape.hxx>
+#include <StdSelect_BRepSelectionTool.hxx>
+#include <Graphic3d_AspectLine3d.hxx>
+#include <Prs3d_LineAspect.hxx>
+
+#define DEBUG_WIRE
+
+#ifdef DEBUG_WIRE
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <TopExp.hxx>
+#endif
+
+//*******************************************************************************************
+
+IMPLEMENT_STANDARD_HANDLE(PartSet_ResultSketchPrs, ViewerData_AISShape);
+IMPLEMENT_STANDARD_RTTIEXT(PartSet_ResultSketchPrs, ViewerData_AISShape);
+
+PartSet_ResultSketchPrs::PartSet_ResultSketchPrs(ResultPtr theResult)
+  : ViewerData_AISShape(TopoDS_Shape()), myResult(theResult)
+{
+  std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(theResult);
+
+  TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
+  Set(aShape);
+  Handle(Prs3d_Drawer) aDrawer = Attributes();
+  if (aDrawer->HasOwnPointAspect()) 
+    aDrawer->PointAspect()->SetTypeOfMarker(Aspect_TOM_PLUS);
+  else
+    aDrawer->SetPointAspect(new Prs3d_PointAspect(Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.));
+
+  // Activate individual repaintng if this is a part of compsolid
+  ResultCompSolidPtr aCompSolid = ModelAPI_Tools::compSolidOwner(myResult);
+  SetAutoHilight(aCompSolid.get() == NULL);
+}
+
+bool PartSet_ResultSketchPrs::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 PartSet_ResultSketchPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+                                   const Handle(Prs3d_Presentation)& thePresentation, 
+                                   const Standard_Integer theMode)
+{
+  std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(myResult);
+  if (!aShapePtr) {
+    Events_Error::throwException("An empty AIS presentation: PartSet_ResultSketchPrs");
+    return;
+  }
+
+  myFacesList.clear();
+  ResultConstructionPtr aConstruction = 
+    std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(myResult);
+  if (aConstruction.get()) {
+    int aFacesNum = aConstruction->facesNum();
+    for(int aFaceIndex = 0; aFaceIndex < aFacesNum; aFaceIndex++) {
+      myFacesList.push_back(aConstruction->face(aFaceIndex));
+    }
+  }
+
+  myOriginalShape = aShapePtr->impl<TopoDS_Shape>();
+  if (!myOriginalShape.IsNull()) {
+    Set(myOriginalShape);
+
+    // change deviation coefficient to provide more precise circle
+    ModuleBase_Tools::setDefaultDeviationCoefficient(myOriginalShape, Attributes());
+    AIS_Shape::Compute(thePresentationManager, thePresentation, theMode);
+  }
+  else
+    Events_Error::throwException("An empty AIS presentation: PartSet_ResultSketchPrs");
+
+
+  // create auxiliary shapes
+  FeaturePtr aResultFeature = ModelAPI_Feature::feature(myResult);
+  CompositeFeaturePtr aSketchFeature = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>
+                                                                          (aResultFeature);
+  std::list<ResultPtr> anAuxiliaryResults;
+  for (int i = 0; i < aSketchFeature->numberOfSubs(); i++) {
+    FeaturePtr aFeature = aSketchFeature->subFeature(i);
+    if (PartSet_Tools::isAuxiliarySketchEntity(aFeature)) {
+      std::list<ResultPtr> aResults = aFeature->results();
+      std::list<ResultPtr>::const_iterator aIt;
+      for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
+        ResultPtr aResult = *aIt;
+        if (aResult.get() && aResult->shape().get())
+          anAuxiliaryResults.push_back(aResult);
+      }
+    }
+  }
+  if (anAuxiliaryResults.size() > 0) {
+    std::vector<int> aColor;
+    aColor = Config_PropManager::color("Visualization", "sketch_auxiliary_color",
+                                         SKETCH_AUXILIARY_COLOR);
+    Standard_Real anAuxiliaryWidth = 1.;
+    Standard_Integer anAuxiliaryLineStyle = 3;
+
+    SetColor(Quantity_Color(aColor[0] / 255., aColor[1] / 255., aColor[2] / 255., Quantity_TOC_RGB));
+
+    //thePresentation->Clear();
+    Handle(Prs3d_Drawer) aDrawer = Attributes();
+    setWidth(aDrawer, anAuxiliaryWidth);
+    // set line style
+    Handle(Prs3d_LineAspect) aLineAspect;
+
+    Aspect_TypeOfLine aType = (Aspect_TypeOfLine)anAuxiliaryLineStyle;
+    if (aDrawer->HasOwnLineAspect()) {
+      aLineAspect = aDrawer->LineAspect();
+    }
+    if (aDrawer->HasOwnWireAspect()) {
+      aLineAspect = aDrawer->WireAspect();
+    }
+    Quantity_Color aCurrentColor;
+    Aspect_TypeOfLine aCurrentType;
+    Standard_Real aCurrentWidth;
+    aLineAspect->Aspect()->Values(aCurrentColor, aCurrentType, aCurrentWidth);
+    bool isChanged = aType != aCurrentType;
+    if (isChanged) {
+      aLineAspect->SetTypeOfLine(aType);
+    }
+    // end of set line style
+
+    BRep_Builder aBuilder;
+    TopoDS_Compound aComp;
+    aBuilder.MakeCompound(aComp);
+
+    std::list<ResultPtr>::const_iterator anIt = anAuxiliaryResults.begin(),
+                                         aLast = anAuxiliaryResults.end();
+    for (; anIt != aLast; anIt++) {
+      ResultPtr aResult = *anIt;
+      if (aResult.get()) {
+        GeomShapePtr aGeomShape = aResult->shape();
+        if (aGeomShape.get()) {
+          const TopoDS_Shape& aShape = aGeomShape->impl<TopoDS_Shape>();
+          if (!aShape.IsNull())
+            aBuilder.Add(aComp, aShape);
+        }
+      }
+    }
+    myAuxiliaryCompound = aComp;
+    StdPrs_WFDeflectionShape::Add(thePresentation, aComp, aDrawer);
+  }
+}
+
+#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 PartSet_ResultSketchPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+                                            const Standard_Integer aMode)
+{
+  if (aMode > 8)
+    // In order to avoid using custom selection modes
+    return;
+
+  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);
+    aBuilder.Add(aComp, myOriginalShape);
+    std::list<std::shared_ptr<GeomAPI_Shape>>::const_iterator aIt;
+    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
+      appendShapeSelection(aSelection, aFace, TopAbs_WIRE);
+    }
+#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);
+
+  // 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);
+    appendShapeSelection(aSelection, myAuxiliaryCompound, isVertex ? TopAbs_VERTEX : TopAbs_EDGE);
+  }
+
+  AIS_Shape::ComputeSelection(aSelection, aMode);
+}
+
+void PartSet_ResultSketchPrs::appendShapeSelection(const Handle(SelectMgr_Selection)& theSelection,
+                                                   const TopoDS_Shape& theShape,
+                                                   const TopAbs_ShapeEnum& theTypeOfSelection)
+{
+  // POP protection against crash in low layers
+  Standard_Real aDeflection = Prs3d::GetDeflection(theShape, myDrawer);
+  try {
+    StdSelect_BRepSelectionTool::Load(theSelection,
+                                      this,
+                                      theShape,
+                                      theTypeOfSelection,
+                                      aDeflection,
+                                      myDrawer->HLRAngle(),
+                                      myDrawer->IsAutoTriangulation());
+  } catch ( Standard_Failure ) {
+  }
+}
diff --git a/src/PartSet/PartSet_ResultSketchPrs.h b/src/PartSet/PartSet_ResultSketchPrs.h
new file mode 100755 (executable)
index 0000000..dc79c7c
--- /dev/null
@@ -0,0 +1,70 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        PartSet_ResultSketchPrs.h
+// Created:     25 March 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef PartSet_ResultSketchPrs_H
+#define PartSet_ResultSketchPrs_H
+
+#include "ModuleBase.h"
+
+#include <ModelAPI_Result.h>
+
+#include <ViewerData_AISShape.hxx>
+
+#include <TopoDS_Compound.hxx>
+
+DEFINE_STANDARD_HANDLE(PartSet_ResultSketchPrs, ViewerData_AISShape)
+
+/**
+* \ingroup GUI
+* A redefinition of standard AIS Interactive Object in order to provide specific behaviour 
+* for wire presentations based in a one plane
+*/
+class PartSet_ResultSketchPrs: public ViewerData_AISShape
+{
+public:
+  /// Constructor
+  /// \param theResult a result object
+  Standard_EXPORT PartSet_ResultSketchPrs(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);
+
+  DEFINE_STANDARD_RTTI(PartSet_ResultSketchPrs)
+protected:
+  /// Redefinition of virtual function
+  Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+    const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0);
+
+  /// Redefinition of virtual function
+  Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
+    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
+  /// \param theTypeOfSelection type of selection: VERTEX, EDGE, WIRE
+  void appendShapeSelection(const Handle(SelectMgr_Selection)& theSelection,
+                            const TopoDS_Shape& theShape, const TopAbs_ShapeEnum& theTypeOfSelection);
+
+  /// Reference to result object
+  ResultPtr myResult;
+
+  /// Original shape of the result object
+  TopoDS_Shape myOriginalShape;
+
+  /// Compound of auxiliary shapes
+  TopoDS_Compound myAuxiliaryCompound;
+
+  /// List of faces
+  std::list<std::shared_ptr<GeomAPI_Shape> > myFacesList;
+};
+
+
+#endif
\ No newline at end of file
index 1817bc3aa302bdc556539c00c4033fbd2a5c6964..06fbec26cddd5bf4e0e5f2647c27293ae1e39cf2 100755 (executable)
@@ -12,6 +12,7 @@
 #include "PartSet_Tools.h"
 #include "PartSet_WidgetSketchLabel.h"
 #include "PartSet_WidgetEditor.h"
+#include "PartSet_ResultSketchPrs.h"
 
 #include <XGUI_ModuleConnector.h>
 #include <XGUI_Displayer.h>
@@ -612,8 +613,7 @@ void PartSet_SketcherMgr::onMouseDoubleClick(ModuleBase_IViewWindow* theWnd, QMo
       QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
       // Find corresponded widget to activate value editing
       foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
-        if (aWgt->attributeID() == "ConstraintValue" ||
-            aWgt->attributeID() == "AngleValue") {
+        if (aWgt->attributeID() == "ConstraintValue") {
           PartSet_WidgetEditor* anEditor = dynamic_cast<PartSet_WidgetEditor*>(aWgt);
           if (anEditor)
             anEditor->showPopupEditor();
@@ -786,6 +786,17 @@ void PartSet_SketcherMgr::sketchSelectionModes(QIntList& theModes)
   theModes.append(TopAbs_EDGE);
 }
 
+Handle(AIS_InteractiveObject) PartSet_SketcherMgr::createPresentation(const ResultPtr& theResult)
+{
+  Handle(AIS_InteractiveObject) aPrs;
+
+  FeaturePtr aFeature = ModelAPI_Feature::feature(theResult);
+  if (aFeature.get() && aFeature->getKind() == SketchPlugin_Sketch::ID()) {
+    aPrs = new PartSet_ResultSketchPrs(theResult);
+  }
+  return aPrs;
+}
+
 bool PartSet_SketcherMgr::isSketchOperation(ModuleBase_Operation* theOperation)
 {
   return theOperation && theOperation->id().toStdString() == SketchPlugin_Sketch::ID();
index aa99353aa9e911718f42fb5c5d5eb16a98969393..06edf86e151dbab4e2a3ba1603cd728c890fb27c 100644 (file)
@@ -238,6 +238,11 @@ public:
   /// \param theModes a list of modes
   static void sketchSelectionModes(QIntList& theModes);
 
+  /// Create specific for the module presentation
+  /// \param theResult an object for presentation
+  /// \return created presentation or NULL(default value)
+  virtual Handle(AIS_InteractiveObject) createPresentation(const ResultPtr& theResult);
+
   /// Connects or disconnects to the value changed signal of the property panel widgets
   /// \param theWidget a property contol widget
   /// \param isToConnect a boolean value whether connect or disconnect
index 6d46988ea3a6dcb1ad12522bcca2ea7acd4dbbdb..0616192d954da2bda3cee9c7e30d38c7a6421079 100755 (executable)
@@ -942,3 +942,18 @@ void PartSet_Tools::sendSubFeaturesEvent(const CompositeFeaturePtr& theComposite
   }
   Events_Loop::loop()->flush(theEventId);
 }
+
+bool PartSet_Tools::isAuxiliarySketchEntity(const ObjectPtr& theObject)
+{
+  bool isAuxiliaryFeature = false;
+
+  FeaturePtr anObjectFeature = ModelAPI_Feature::feature(theObject);
+  std::string anAuxiliaryAttribute = SketchPlugin_SketchEntity::AUXILIARY_ID();
+  AttributeBooleanPtr anAuxiliaryAttr = std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(
+                                    anObjectFeature->data()->attribute(anAuxiliaryAttribute));
+  if (anAuxiliaryAttr.get())
+    isAuxiliaryFeature = anAuxiliaryAttr->value();
+
+
+  return isAuxiliaryFeature;
+}
index 8db945e80eb58f24647e82aceb9e2b0a11a776df..fe133ede0ef8b6753ed0183fb2429de8705ab9a0 100755 (executable)
@@ -256,6 +256,13 @@ public:
   /// Sends redisplay event for all sub-features of the composite. Flush it.
   static void sendSubFeaturesEvent(const CompositeFeaturePtr& theComposite,
                                    const Events_ID theId);
+
+  /**
+   * Returns true if the object is a sketch entity, where auxiliary attribute has true vlaue
+   * \param theObject a result or feature
+   * \return boolean result
+   */
+  static bool isAuxiliarySketchEntity(const ObjectPtr& theObject);
 };
 
 #endif
index 004fd0d3c9db6694d18e9cfee901e59db9e87570..11f698ad1ff04c13d248213a37536284e136db61 100644 (file)
@@ -513,13 +513,7 @@ void PartSet_WidgetPoint2D::onMouseRelease(ModuleBase_IViewWindow* theWnd, QMous
             setPoint(aX, aY);
           }
           setValueState(Stored); // in case of edge selection, Apply state should also be updated
-
-          FeaturePtr anObjectFeature = ModelAPI_Feature::feature(aObject);
-          std::string anAuxiliaryAttribute = SketchPlugin_SketchEntity::AUXILIARY_ID();
-          AttributeBooleanPtr anAuxiliaryAttr = std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(
-                                            anObjectFeature->data()->attribute(anAuxiliaryAttribute));
-          if (anAuxiliaryAttr.get())
-            isAuxiliaryFeature = anAuxiliaryAttr->value();
+          isAuxiliaryFeature = PartSet_Tools::isAuxiliarySketchEntity(aObject);
         }
         // it is important to perform updateObject() in order to the current value is 
         // processed by Sketch Solver. Test case: line is created from a previous point
index 7833d748c3710165169f16e2873a89ede5c1fc25..27798a128e22ab4d261c13b53dff70cbbe3c1a20 100644 (file)
@@ -161,7 +161,10 @@ bool XGUI_Displayer::display(ObjectPtr theObject, bool theUpdateViewer)
         std::shared_ptr<GeomAPI_Shape> aShapePtr = ModelAPI_Tools::shape(aResult);
         if (aShapePtr.get() != NULL) {
           anAIS = AISObjectPtr(new GeomAPI_AISObject());
-          anAIS->setImpl(new Handle(AIS_InteractiveObject)(new ModuleBase_ResultPrs(aResult)));
+          Handle(AIS_InteractiveObject) anAISPrs = myWorkshop->module()->createPresentation(aResult);
+          if (anAISPrs.IsNull())
+            anAISPrs = new ModuleBase_ResultPrs(aResult);
+          anAIS->setImpl(new Handle(AIS_InteractiveObject)(anAISPrs));
           //anAIS->createShape(aShapePtr);
           isShading = true;
         }