]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
ModuleBase_ViewerPrs should contain GeomShapePtr instead of TopoDS_Shape.
authornds <nds@opencascade.com>
Tue, 5 Apr 2016 16:40:09 +0000 (19:40 +0300)
committernds <nds@opencascade.com>
Tue, 5 Apr 2016 16:40:09 +0000 (19:40 +0300)
15 files changed:
src/ModuleBase/ModuleBase_ISelection.cpp
src/ModuleBase/ModuleBase_ViewerPrs.cpp
src/ModuleBase/ModuleBase_ViewerPrs.h
src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp
src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp
src/PartSet/PartSet_MenuMgr.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationPrs.cpp
src/PartSet/PartSet_SketcherReetntrantMgr.cpp
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Validators.cpp
src/PartSet/PartSet_WidgetPoint2d.cpp
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Selection.cpp

index d5c325558b186df333cc949b379e9a2fef344754..ab8008ad76442616ad8bf965630dffa447c99499 100644 (file)
@@ -27,7 +27,7 @@ void ModuleBase_ISelection::appendSelected(const QList<ModuleBase_ViewerPrs> the
   for (; anIt != aLast; anIt++) {
     ObjectPtr anObject = (*anIt).object();
     if (anObject.get() != NULL && !anExistedObjects.contains(anObject)) {
-      theValuesTo.append(ModuleBase_ViewerPrs(anObject, TopoDS_Shape(), NULL));
+      theValuesTo.append(ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL));
     }
   }
 
@@ -53,13 +53,12 @@ GeomShapePtr ModuleBase_ISelection::getShape(const ModuleBase_ViewerPrs& thePrs)
 {
   GeomShapePtr aShape;
 
-  const TopoDS_Shape& aTDSShape = thePrs.shape();
+  const GeomShapePtr& aPrsShape = thePrs.shape();
   // if only result is selected, an empty shape is set to the model
-  if (aTDSShape.IsNull()) {
+  if (!aPrsShape.get() || aPrsShape->isNull()) {
   }
   else {
-    aShape = GeomShapePtr(new GeomAPI_Shape());
-    aShape->setImpl(new TopoDS_Shape(aTDSShape));
+    aShape = aPrsShape;
     // If the result object is built on the same shape, the result shape here is empty one
     ResultPtr aResult = getResult(thePrs);
     if (aResult.get() && aShape->isEqual(aResult->shape()))
@@ -76,7 +75,7 @@ QList<ModuleBase_ViewerPrs> ModuleBase_ISelection::getViewerPrs(const QObjectPtr
   for (; anIt != aLast; anIt++) {
     ObjectPtr anObject = *anIt;
     if (anObject.get() != NULL) {
-      aSelectedPrs.append(ModuleBase_ViewerPrs(anObject, TopoDS_Shape(), NULL));
+      aSelectedPrs.append(ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL));
     }
   }
   return aSelectedPrs;
index deb08fd53e92d2ac1d750b7214a2935cacb89ad7..f11b3b0773ef0330cb50669abf288b9dbd95a923 100644 (file)
@@ -14,7 +14,7 @@ ModuleBase_ViewerPrs::ModuleBase_ViewerPrs()
 }
 
 ModuleBase_ViewerPrs::ModuleBase_ViewerPrs(ObjectPtr theResult, 
-                                           const TopoDS_Shape& theShape, 
+                                           const GeomShapePtr& theShape, 
                                            Handle_SelectMgr_EntityOwner theOwner) 
 : myResult(theResult),
   myShape(theShape),
@@ -29,7 +29,8 @@ ModuleBase_ViewerPrs::~ModuleBase_ViewerPrs()
 bool ModuleBase_ViewerPrs::operator==(const ModuleBase_ViewerPrs& thePrs)
 {
   bool isEqualResult = (myResult.get() == thePrs.object().get());
-  bool isEqualShape = myShape.IsEqual(thePrs.shape()) == Standard_True;
+  bool isEqualShape = (!myShape.get() && !thePrs.shape().get()) ||
+                       (myShape.get() && myShape->isEqual(thePrs.shape()));
   bool isEqualIO = (myInteractive == thePrs.interactive()) == Standard_True;
 
   bool isEqualOwner = (myOwner.Access() == thePrs.owner().Access());
index 723a15fb6445e723648e197cbef92173c0acbb6d..39513240bce2657b4936570109be66bc48a2ac54 100644 (file)
 #include "ModuleBase.h"
 
 #include <memory>
-#include <TopoDS_Shape.hxx>
 #include <SelectMgr_EntityOwner.hxx>
 #include <AIS_InteractiveObject.hxx>
 
 #include <ModelAPI_Result.h>
+#include <GeomAPI_Shape.h>
 
 /**\class ModuleBase_ViewerPrs
  * \ingroup GUI
@@ -30,7 +30,7 @@ class ModuleBase_ViewerPrs
   /// \param theResult an object
   /// \param theShape a viewer shape
   /// \param theOwner a selection owner
-  MODULEBASE_EXPORT ModuleBase_ViewerPrs(ObjectPtr theResult, const TopoDS_Shape& theShape,
+  MODULEBASE_EXPORT ModuleBase_ViewerPrs(ObjectPtr theResult, const GeomShapePtr& theShape,
                        Handle_SelectMgr_EntityOwner theOwner);
 
   /// Destructor
@@ -66,14 +66,14 @@ class ModuleBase_ViewerPrs
 
   /// Sets the shape
   /// \param theShape a shape instance
-  MODULEBASE_EXPORT void setShape(const TopoDS_Shape& theShape)
+  MODULEBASE_EXPORT void setShape(const GeomShapePtr& theShape)
   {
     myShape = theShape;
   }
 
   /// Returns the shape
   /// \return a shape instance
-  MODULEBASE_EXPORT const TopoDS_Shape& shape() const
+  MODULEBASE_EXPORT const GeomShapePtr& shape() const
   {
     return myShape;
   }
@@ -95,7 +95,7 @@ class ModuleBase_ViewerPrs
   /// \return boolean value
   MODULEBASE_EXPORT bool isEmpty() const
   {
-    return myShape.IsNull() &&
+    return (!myShape.get() || myShape->isNull()) &&
            myOwner.IsNull() && !myResult.get();
   }
 
@@ -106,7 +106,7 @@ class ModuleBase_ViewerPrs
  private:
   ObjectPtr myResult;  /// the feature
   Handle(SelectMgr_EntityOwner) myOwner;  /// the selection owner
-  TopoDS_Shape myShape;  /// the shape
+  GeomShapePtr myShape;  /// the shape
   Handle(AIS_InteractiveObject) myInteractive;  /// interactive object
 };
 
index f5c1ef25189538e99e380c7265321c6785bd7132..43a879c57048ef3b1019e4a51ffde574985395df 100755 (executable)
@@ -628,14 +628,8 @@ void ModuleBase_WidgetMultiSelector::convertIndicesToViewerSelection(std::set<in
         continue;
       AttributeSelectionPtr anAttr = aSelectionListAttr->value(i);
       ResultPtr anObject = anAttr->context();
-      if (anObject.get()) {
-        TopoDS_Shape aShape;
-        std::shared_ptr<GeomAPI_Shape> aShapePtr = anAttr->value();
-        if (aShapePtr.get()) {
-          aShape = aShapePtr->impl<TopoDS_Shape>();
-        }
-        theValues.append(ModuleBase_ViewerPrs(anObject, aShape, NULL));
-      }
+      if (anObject.get())
+        theValues.append(ModuleBase_ViewerPrs(anObject, anAttr->value(), NULL));
     }
   }
   else if (aType == ModelAPI_AttributeRefList::typeId()) {
@@ -646,7 +640,7 @@ void ModuleBase_WidgetMultiSelector::convertIndicesToViewerSelection(std::set<in
         continue;
       ObjectPtr anObject = aRefListAttr->object(i);
       if (anObject.get()) {
-        theValues.append(ModuleBase_ViewerPrs(anObject, TopoDS_Shape(), NULL));
+        theValues.append(ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL));
       }
     }
   }
@@ -663,10 +657,7 @@ void ModuleBase_WidgetMultiSelector::convertIndicesToViewerSelection(std::set<in
       AttributePtr anAttribute = aRefAttrListAttr->attribute(i);
       if (anAttribute.get()) {
         GeomShapePtr aGeomShape = myWorkshop->module()->findShape(anAttribute);
-        if (aGeomShape.get()) {
-          aShape = aGeomShape->impl<TopoDS_Shape>();
-        }
-        theValues.append(ModuleBase_ViewerPrs(anObject, aShape, NULL));
+        theValues.append(ModuleBase_ViewerPrs(anObject, aGeomShape, NULL));
       }
     }
   }
index 55b9e9dc14fdce37693a2fb9c4b61791192c0535..0a3d15bbc78892824f726cf0cb09f412460b310b 100644 (file)
@@ -148,12 +148,8 @@ QList<ModuleBase_ViewerPrs> ModuleBase_WidgetShapeSelector::getAttributeSelectio
     AttributePtr anAttribute = myFeature->attribute(attributeID());
 
     ObjectPtr anObject = ModuleBase_Tools::getObject(anAttribute);
-    TopoDS_Shape aShape;
     std::shared_ptr<GeomAPI_Shape> aShapePtr = getShape();
-    if (aShapePtr.get()) {
-      aShape = aShapePtr->impl<TopoDS_Shape>();
-    }
-    ModuleBase_ViewerPrs aPrs(anObject, aShape, NULL);
+    ModuleBase_ViewerPrs aPrs(anObject, aShapePtr, NULL);
     aSelected.append(aPrs);
   }
   return aSelected;
index a18ac9a530d015a35773ee251ea16ff33e83bf2a..a970e4979bb85fa6464b2d42c0d4c6c440d26f37 100644 (file)
@@ -120,14 +120,13 @@ bool PartSet_MenuMgr::addViewerMenu(QMenu* theMenu, const QMap<QString, QAction*
   bool hasFeature = false;
 
   QList<ModuleBase_ViewerPrs> aPrsList = aSelection->getSelected(ModuleBase_ISelection::Viewer);
-  TopoDS_Shape aShape;
   ResultPtr aResult;
   FeaturePtr aFeature;
   foreach(ModuleBase_ViewerPrs aPrs, aPrsList) {
     aResult = std::dynamic_pointer_cast<ModelAPI_Result>(aPrs.object());
     if (aResult.get() != NULL) {
-      aShape = aPrs.shape();
-      if (aShape.IsEqual(aResult->shape()->impl<TopoDS_Shape>()))
+      const GeomShapePtr& aShape = aPrs.shape();
+      if (aShape.get() && aShape->isEqual(aResult->shape()))
         hasFeature = true;
       else
         hasAttribute = true;
@@ -138,12 +137,13 @@ bool PartSet_MenuMgr::addViewerMenu(QMenu* theMenu, const QMap<QString, QAction*
   }
 
   if (aPrsList.size() == 1) {
-    TopoDS_Shape aShape = aPrsList.first().shape();
-    if ((!aShape.IsNull()) && aShape.ShapeType() == TopAbs_VERTEX) {
+    const GeomShapePtr& aShape = aPrsList.first().shape();
+    if (aShape.get() && !aShape->isNull() && aShape->shapeType() == GeomAPI_Shape::VERTEX) {
       // Find 2d coordinates
       FeaturePtr aSketchFea = myModule->sketchMgr()->activeSketch();
       if (aSketchFea->getKind() == SketchPlugin_Sketch::ID()) {
-        gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
+        const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
+        gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aTDShape));
         std::shared_ptr<GeomAPI_Pnt> aPnt3d(new GeomAPI_Pnt(aPnt.X(), aPnt.Y(), aPnt.Z()));
         std::shared_ptr<GeomAPI_Pnt2d> aSelPnt = PartSet_Tools::convertTo2D(aSketchFea, aPnt3d);
 
index 709c8fb5df089630f312c5b7b9a763f12a055b80..f580bcb11c1c2227d4564a45580fbf88cec96160 100755 (executable)
@@ -570,10 +570,11 @@ bool PartSet_Module::createWidgets(ModuleBase_Operation* theOperation,
 
       FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
       FeaturePtr anOpFeature = aFOperation->feature();
-      TopoDS_Shape aShape = aSelectedPrs.shape();
+      GeomShapePtr aShape = aSelectedPrs.shape();
       // click on the digit of dimension constrain comes here with an empty shape, so we need the check
-      if (aFeature == anOpFeature && !aShape.IsNull()) {
-        AttributePtr anAttribute = PartSet_Tools::findAttributeBy2dPoint(anObject, aShape,
+      if (aFeature == anOpFeature && aShape.get() && !aShape->isNull()) {
+        const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
+        AttributePtr anAttribute = PartSet_Tools::findAttributeBy2dPoint(anObject, aTDShape,
                                                                          mySketchMgr->activeSketch());
         if (anAttribute.get()) {
           QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
index 1640f4137f7cc76a4c1f7902dc460feb7036456a..a231a9b98a41b20bb59c7b6a025eab3be90cbc0f 100755 (executable)
@@ -95,7 +95,7 @@ void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& t
       // appendShapeIfVisible() on the step of filling myFeatureShapes list
       // the reason is to avoid empty AIS object visualized in the viewer
       //if (!aGeomShape.get()) continue;
-      TopoDS_Shape aShape = aGeomShape->impl<TopoDS_Shape>();
+      TopoDS_Shape aShape = aGeomShape.get() ? aGeomShape->impl<TopoDS_Shape>() : TopoDS_Shape();
       // change deviation coefficient to provide more precise circle
       ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, aDrawer);
 
@@ -339,14 +339,8 @@ void PartSet_OperationPrs::getHighlightedShapes(ModuleBase_IWorkshop* theWorksho
     ModuleBase_ViewerPrs aPrs = *anIIt;
     ObjectPtr anObject = aPrs.object();
 
-    GeomShapePtr aGeomShape;
-
-    TopoDS_Shape aShape = aPrs.shape();
-    if (!aShape.IsNull()) {
-      aGeomShape = GeomShapePtr(new GeomAPI_Shape());
-      aGeomShape->setImpl(new TopoDS_Shape(aShape));
-    }
-    else {
+    GeomShapePtr aGeomShape = aPrs.shape();
+    if (!aGeomShape.get() || aGeomShape->isNull()) {
       ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
       if (aResult.get()) {
         aGeomShape = aResult->shape();
index 534ddb465fc0fd85f97cf8c7f8fbbb3b55739a66..f02f52b4ba2c59ff7d6114643966d28303c5aba0 100755 (executable)
@@ -153,7 +153,7 @@ bool PartSet_SketcherReetntrantMgr::processMouseMoved(ModuleBase_IViewWindow* /*
           PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast<PartSet_WidgetPoint2D*>(anActiveWidget);
           if (aPoint2DWdg) { // line, start point should be equal last point of the last feature line
             QList<ModuleBase_ViewerPrs> aSelection;
-            aSelection.append(ModuleBase_ViewerPrs(aLastFeature, TopoDS_Shape(), NULL));
+            aSelection.append(ModuleBase_ViewerPrs(aLastFeature, GeomShapePtr(), NULL));
             aWidgetIsFilled = aPoint2DWdg->setSelection(aSelection, true);
           }
         }
index 7edba2413699d20eab7c83742c2fd3503b5a6ec1..6d46988ea3a6dcb1ad12522bcca2ea7acd4dbbdb 100755 (executable)
@@ -657,10 +657,11 @@ bool PartSet_Tools::hasVertexShape(const ModuleBase_ViewerPrs& thePrs, FeaturePt
 {
   bool aHasVertex = false;
 
-  const TopoDS_Shape& aShape = thePrs.shape();
-  if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX)
+  const GeomShapePtr& aShape = thePrs.shape();
+  if (aShape.get() && !aShape->isNull() && aShape->shapeType() == GeomAPI_Shape::VERTEX)
   {
-    const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape);
+    const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
+    const TopoDS_Vertex& aVertex = TopoDS::Vertex(aTDShape);
     if (!aVertex.IsNull())
     {
       gp_Pnt aPoint = BRep_Tool::Pnt(aVertex);
index 7cb22655f9b8fb4d571622a4238aeeb946a32f2d..6baf8589d272a2fc6b4e819ff4ad074bdb89c0ca 100755 (executable)
@@ -44,9 +44,9 @@ int shapesNbPoints(const ModuleBase_ISelection* theSelection)
 
   int aCount = 0;
   foreach (ModuleBase_ViewerPrs aPrs, aList) {
-    const TopoDS_Shape& aShape = aPrs.shape();
-    if (!aShape.IsNull()) {
-      if (aShape.ShapeType() == TopAbs_VERTEX)
+    const GeomShapePtr& aShape = aPrs.shape();
+    if (aShape.get() && !aShape->isNull()) {
+      if (aShape->shapeType() == GeomAPI_Shape::VERTEX)
         aCount++;
     }
   }
@@ -58,10 +58,11 @@ int shapesNbLines(const ModuleBase_ISelection* theSelection)
   QList<ModuleBase_ViewerPrs> aList = theSelection->getSelected(ModuleBase_ISelection::Viewer);
   int aCount = 0;
   foreach(ModuleBase_ViewerPrs aPrs, aList) {
-    const TopoDS_Shape& aShape = aPrs.shape();
-    if (!aShape.IsNull()) {
-      if (aShape.ShapeType() == TopAbs_EDGE) {
-        TopoDS_Edge aEdge = TopoDS::Edge(aShape);
+    const GeomShapePtr& aShape = aPrs.shape();
+    if (aShape.get() && !aShape->isNull()) {
+      if (aShape->shapeType() == GeomAPI_Shape::EDGE) {
+        const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
+        TopoDS_Edge aEdge = TopoDS::Edge(aTDShape);
         Standard_Real aStart, aEnd;
         Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
         GeomAdaptor_Curve aAdaptor(aCurve);
@@ -159,10 +160,11 @@ bool PartSet_RadiusSelection::isValid(const ModuleBase_ISelection* theSelection,
     ModuleBase_ViewerPrs aPrs;
     int aCount = 0;
     foreach (ModuleBase_ViewerPrs aPrs, aList) {
-      const TopoDS_Shape& aShape = aPrs.shape();
-      if (!aShape.IsNull()) {
-        if (aShape.ShapeType() == TopAbs_EDGE) {
-          TopoDS_Edge aEdge = TopoDS::Edge(aShape);
+      const GeomShapePtr& aShape = aPrs.shape();
+      if (aShape.get() && !aShape->isNull()) {
+        if (aShape->shapeType() == GeomAPI_Shape::EDGE) {
+          const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
+          TopoDS_Edge aEdge = TopoDS::Edge(aTDShape);
           Standard_Real aStart, aEnd;
           Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
           GeomAdaptor_Curve aAdaptor(aCurve);
@@ -228,31 +230,20 @@ bool PartSet_TangentSelection::isValid(const ModuleBase_ISelection* theSelection
       return false;
 
     ModuleBase_ViewerPrs aPrs = aList.first();
-    const TopoDS_Shape& aShape = aPrs.shape();
-    if (aShape.IsNull())
+    const GeomShapePtr& aShape = aPrs.shape();
+    if (!aShape.get() || aShape->isNull() || aShape->shapeType() != GeomAPI_Shape::EDGE)
       return false;
-
-    if (aShape.ShapeType() != TopAbs_EDGE)
-      return false;
-
-    std::shared_ptr<GeomAPI_Shape> aShapePtr(new GeomAPI_Shape);
-    aShapePtr->setImpl(new TopoDS_Shape(aShape));
-    GeomAPI_Edge aEdge1(aShapePtr);
+    GeomAPI_Edge aEdge1(aShape);
 
     if (aEdge1.isLine() || aEdge1.isArc()) {
       if (aList.size() == 2) {
         // Check second selection
         aPrs = aList.last();
-        const TopoDS_Shape& aShape2 = aPrs.shape();
-        if (aShape2.IsNull())
-          return false;
-
-        if (aShape2.ShapeType() != TopAbs_EDGE)
+        const GeomShapePtr& aShape2 = aPrs.shape();
+        if (!aShape2.get() || aShape2->isNull() || aShape2->shapeType() != GeomAPI_Shape::EDGE)
           return false;
+        GeomAPI_Edge aEdge2(aShape2);
 
-        std::shared_ptr<GeomAPI_Shape> aShapePtr2(new GeomAPI_Shape);
-        aShapePtr2->setImpl(new TopoDS_Shape(aShape2));
-        GeomAPI_Edge aEdge2(aShapePtr2);
         if (aEdge1.isLine() && aEdge2.isArc())
           return true;
         else if (aEdge1.isArc() && aEdge2.isLine())
@@ -286,9 +277,8 @@ bool PartSet_EqualSelection::isValid(const ModuleBase_ISelection* theSelection,
     int aCount = 0;
     int aType = 0;
     foreach (ModuleBase_ViewerPrs aPrs, aList) {
-      std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape);
-      aShape->setImpl(new TopoDS_Shape(aPrs.shape()));
-      if (aShape->isEdge()) {
+      GeomShapePtr aShape = aPrs.shape();
+      if (aShape.get() && aShape->isEdge()) {
         aCount++;
         GeomAPI_Edge aEdge(aShape);
         if (aEdge.isLine()) {
index 8543f3143a8f1497c1e8cce4358270865d37853a..004fd0d3c9db6694d18e9cfee901e59db9e87570 100644 (file)
@@ -155,11 +155,12 @@ bool PartSet_WidgetPoint2D::setSelection(QList<ModuleBase_ViewerPrs>& theValues,
     return isDone;
 
   ModuleBase_ViewerPrs aValue = theValues.takeFirst();
-  TopoDS_Shape aShape = aValue.shape();
-  if (!aShape.IsNull()) {
+  GeomShapePtr aShape = aValue.shape();
+  if (aShape.get() && !aShape->isNull()) {
     Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
     double aX, aY;
-    if (getPoint2d(aView, aShape, aX, aY)) {
+    const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
+    if (getPoint2d(aView, aTDShape, aX, aY)) {
       isDone = setPoint(aX, aY);
       PartSet_Tools::setConstraints(mySketch, feature(), attributeID(), aX, aY);
     }
index 76a50444c1f38320639616171ec2d4c513835498..8718bf149bf848714b8e31653d5096b58f2fd0c2 100644 (file)
@@ -211,7 +211,7 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs
   // 1. hide main planes if they have been displayed
   erasePreviewPlanes();
   // 2. if the planes were displayed, change the view projection
-  TopoDS_Shape aShape = thePrs.shape();
+  const GeomShapePtr& aShape = thePrs.shape();
   std::shared_ptr<GeomAPI_Shape> aGShape;
   std::shared_ptr<GeomAPI_Shape> aBaseShape;
 
@@ -220,9 +220,8 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs
                             (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
 
   // selection happens in OCC viewer
-  if (!aShape.IsNull()) {
-    aGShape =  std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
-    aGShape->setImpl(new TopoDS_Shape(aShape));
+  if (aShape.get() && !aShape->isNull()) {
+    aGShape = aShape;
 
     if (aSelAttr && aSelAttr->context()) {
       aBaseShape = aSelAttr->context()->shape();
@@ -320,7 +319,7 @@ bool PartSet_WidgetSketchLabel::setSelectionCustom(const ModuleBase_ViewerPrs& t
 {
   bool isOwnerSet = false;
 
-  const TopoDS_Shape& aShape = thePrs.shape();
+  const GeomShapePtr& aShape = thePrs.shape();
   std::shared_ptr<GeomAPI_Dir> aDir;
 
   if (thePrs.object() && (feature() != thePrs.object())) {
@@ -332,11 +331,11 @@ bool PartSet_WidgetSketchLabel::setSelectionCustom(const ModuleBase_ViewerPrs& t
       ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(thePrs.object());
       if (aRes) {
         GeomShapePtr aShapePtr(new GeomAPI_Shape());
-        if (aShape.IsNull()) {  // selection happens in the OCC viewer
+        if (!aShape.get() || aShape->isNull()) {  // selection happens in the OCC viewer
           aShapePtr = ModelAPI_Tools::shape(aRes);
         }
         else { // selection happens in OB browser
-          aShapePtr->setImpl(new TopoDS_Shape(aShape));
+          aShapePtr = aShape;
         }
         if (aShapePtr.get() != NULL) {
           aSelAttr->setValue(aRes, aShapePtr);
@@ -345,8 +344,9 @@ bool PartSet_WidgetSketchLabel::setSelectionCustom(const ModuleBase_ViewerPrs& t
       }
     }
   }
-  else if (!aShape.IsNull()) {
-    aDir = setSketchPlane(aShape);
+  else if (aShape.get() && !aShape->isNull()) {
+    const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
+    aDir = setSketchPlane(aTDShape);
     isOwnerSet = aDir.get();
   }
   return isOwnerSet;
index 978d6154936421e9f0332bbd4520b7a4e65fb3b4..7833d748c3710165169f16e2873a89ede5c1fc25 100644 (file)
@@ -550,8 +550,9 @@ void XGUI_Displayer::setSelected(const  QList<ModuleBase_ViewerPrs>& theValues,
     aContext->UnhilightSelected(false);
     aContext->ClearSelected(false);
     foreach (ModuleBase_ViewerPrs aPrs, theValues) {
-      const TopoDS_Shape& aShape = aPrs.shape();
-      if (!aShape.IsNull()) {
+      const GeomShapePtr& aGeomShape = aPrs.shape();
+      if (aGeomShape.get() && !aGeomShape->isNull()) {
+        const TopoDS_Shape& aShape = aGeomShape->impl<TopoDS_Shape>();
         aContext->AddOrRemoveSelected(aShape, false);
       } else {
         ObjectPtr anObject = aPrs.object();
index 079c30cba599938890356ce430a0cb9d2c1727d2..27fbd63de850028ad13b3f62c4df321f8c75891f 100644 (file)
@@ -110,7 +110,7 @@ void XGUI_Selection::getSelectedInBrowser(QList<ModuleBase_ViewerPrs>& thePresen
   for (; anIt != aLast; anIt++) {
     ObjectPtr anObject = *anIt;
     if (anObject.get() != NULL && !aPresentationObjects.contains(anObject)) {
-      thePresentations.append(ModuleBase_ViewerPrs(anObject, TopoDS_Shape(), NULL));
+      thePresentations.append(ModuleBase_ViewerPrs(anObject, GeomShapePtr(), NULL));
     }
   }
 }
@@ -135,8 +135,11 @@ void XGUI_Selection::fillPresentation(ModuleBase_ViewerPrs& thePrs,
     if (aShape.IsNull())
       aShape = findAxisShape(anIO);
 #endif
-    if (!aShape.IsNull())
-      thePrs.setShape(aShape);
+    if (!aShape.IsNull()) {
+      std::shared_ptr<GeomAPI_Shape> aGeomShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
+      aGeomShape->setImpl(new TopoDS_Shape(aShape));
+      thePrs.setShape(aGeomShape);
+    }
   } else {
 #ifdef DEBUG_DELIVERY
     // Fill by trihedron shapes
@@ -150,8 +153,11 @@ void XGUI_Selection::fillPresentation(ModuleBase_ViewerPrs& thePrs,
       BRep_Builder aBuilder;      
       TopoDS_Edge aEdge;
       aBuilder.MakeEdge(aEdge, aTLine, Precision::Confusion());
-      if (!aEdge.IsNull())
-        thePrs.setShape(aEdge);
+      if (!aEdge.IsNull()) {
+        std::shared_ptr<GeomAPI_Shape> aGeomShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
+        aGeomShape->setImpl(new TopoDS_Shape(aEdge));
+        thePrs.setShape(aGeomShape);
+      }
     } else {
       Handle(AIS_Point) aPoint = Handle(AIS_Point)::DownCast(anIO);
       if (!aPoint.IsNull()) {
@@ -160,8 +166,11 @@ void XGUI_Selection::fillPresentation(ModuleBase_ViewerPrs& thePrs,
         BRep_Builder aBuilder;
         TopoDS_Vertex aVertex;
         aBuilder.MakeVertex(aVertex, aPnt->Pnt(), Precision::Confusion());
-        if (!aVertex.IsNull())
-          thePrs.setShape(aVertex);
+        if (!aVertex.IsNull()) {
+          std::shared_ptr<GeomAPI_Shape> aGeomShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
+          aGeomShape->setImpl(new TopoDS_Shape(aVertex));
+          thePrs.setShape(aGeomShape);
+        }
       }
     }
 #endif
@@ -178,13 +187,10 @@ void XGUI_Selection::fillPresentation(ModuleBase_ViewerPrs& thePrs,
     if (aResult.get()) {
       ResultCompSolidPtr aCompSolid = ModelAPI_Tools::compSolidOwner(aResult);
       if (aCompSolid.get()) {
-        GeomShapePtr aShapePtr = aCompSolid->shape();
-        if (aShapePtr.get()) {
-          TopoDS_Shape aShape = aShapePtr->impl<TopoDS_Shape>();
-          if (aShape.IsEqual(thePrs.shape())) {
-            thePrs.setObject(aCompSolid);
-            return;
-          }
+        GeomShapePtr aShape = aCompSolid->shape();
+        if (aShape.get() && aShape->isEqual(thePrs.shape())) {
+          thePrs.setObject(aCompSolid);
+          return;
         }
       }
     }
@@ -216,8 +222,11 @@ QList<ModuleBase_ViewerPrs> XGUI_Selection::getHighlighted() const
     aPrs.setObject(aResult);
     if (aContext->HasOpenedContext()) {
       TopoDS_Shape aShape = aContext->DetectedShape();
-      if (!aShape.IsNull())
-        aPrs.setShape(aShape);
+      if (!aShape.IsNull()) {
+        std::shared_ptr<GeomAPI_Shape> aGeomShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
+        aGeomShape->setImpl(new TopoDS_Shape(aShape));
+        aPrs.setShape(aGeomShape);
+      }
     }
     aPresentations.push_back(aPrs);
   }