From: nds Date: Tue, 5 Apr 2016 16:40:09 +0000 (+0300) Subject: ModuleBase_ViewerPrs should contain GeomShapePtr instead of TopoDS_Shape. X-Git-Tag: V_2.3.0~342 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3b1b1527a60ec9d92b332e3df9056c5a16c22ff9;p=modules%2Fshaper.git ModuleBase_ViewerPrs should contain GeomShapePtr instead of TopoDS_Shape. --- diff --git a/src/ModuleBase/ModuleBase_ISelection.cpp b/src/ModuleBase/ModuleBase_ISelection.cpp index d5c325558..ab8008ad7 100644 --- a/src/ModuleBase/ModuleBase_ISelection.cpp +++ b/src/ModuleBase/ModuleBase_ISelection.cpp @@ -27,7 +27,7 @@ void ModuleBase_ISelection::appendSelected(const QList 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_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; diff --git a/src/ModuleBase/ModuleBase_ViewerPrs.cpp b/src/ModuleBase/ModuleBase_ViewerPrs.cpp index deb08fd53..f11b3b077 100644 --- a/src/ModuleBase/ModuleBase_ViewerPrs.cpp +++ b/src/ModuleBase/ModuleBase_ViewerPrs.cpp @@ -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()); diff --git a/src/ModuleBase/ModuleBase_ViewerPrs.h b/src/ModuleBase/ModuleBase_ViewerPrs.h index 723a15fb6..39513240b 100644 --- a/src/ModuleBase/ModuleBase_ViewerPrs.h +++ b/src/ModuleBase/ModuleBase_ViewerPrs.h @@ -10,11 +10,11 @@ #include "ModuleBase.h" #include -#include #include #include #include +#include /**\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 }; diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index f5c1ef251..43a879c57 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -628,14 +628,8 @@ void ModuleBase_WidgetMultiSelector::convertIndicesToViewerSelection(std::setvalue(i); ResultPtr anObject = anAttr->context(); - if (anObject.get()) { - TopoDS_Shape aShape; - std::shared_ptr aShapePtr = anAttr->value(); - if (aShapePtr.get()) { - aShape = aShapePtr->impl(); - } - 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::setobject(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::setattribute(i); if (anAttribute.get()) { GeomShapePtr aGeomShape = myWorkshop->module()->findShape(anAttribute); - if (aGeomShape.get()) { - aShape = aGeomShape->impl(); - } - theValues.append(ModuleBase_ViewerPrs(anObject, aShape, NULL)); + theValues.append(ModuleBase_ViewerPrs(anObject, aGeomShape, NULL)); } } } diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index 55b9e9dc1..0a3d15bbc 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -148,12 +148,8 @@ QList ModuleBase_WidgetShapeSelector::getAttributeSelectio AttributePtr anAttribute = myFeature->attribute(attributeID()); ObjectPtr anObject = ModuleBase_Tools::getObject(anAttribute); - TopoDS_Shape aShape; std::shared_ptr aShapePtr = getShape(); - if (aShapePtr.get()) { - aShape = aShapePtr->impl(); - } - ModuleBase_ViewerPrs aPrs(anObject, aShape, NULL); + ModuleBase_ViewerPrs aPrs(anObject, aShapePtr, NULL); aSelected.append(aPrs); } return aSelected; diff --git a/src/PartSet/PartSet_MenuMgr.cpp b/src/PartSet/PartSet_MenuMgr.cpp index a18ac9a53..a970e4979 100644 --- a/src/PartSet/PartSet_MenuMgr.cpp +++ b/src/PartSet/PartSet_MenuMgr.cpp @@ -120,14 +120,13 @@ bool PartSet_MenuMgr::addViewerMenu(QMenu* theMenu, const QMap aPrsList = aSelection->getSelected(ModuleBase_ISelection::Viewer); - TopoDS_Shape aShape; ResultPtr aResult; FeaturePtr aFeature; foreach(ModuleBase_ViewerPrs aPrs, aPrsList) { aResult = std::dynamic_pointer_cast(aPrs.object()); if (aResult.get() != NULL) { - aShape = aPrs.shape(); - if (aShape.IsEqual(aResult->shape()->impl())) + 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 QMapisNull() && 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(); + gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aTDShape)); std::shared_ptr aPnt3d(new GeomAPI_Pnt(aPnt.X(), aPnt.Y(), aPnt.Z())); std::shared_ptr aSelPnt = PartSet_Tools::convertTo2D(aSketchFea, aPnt3d); diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 709c8fb5d..f580bcb11 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -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(); + AttributePtr anAttribute = PartSet_Tools::findAttributeBy2dPoint(anObject, aTDShape, mySketchMgr->activeSketch()); if (anAttribute.get()) { QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation(); diff --git a/src/PartSet/PartSet_OperationPrs.cpp b/src/PartSet/PartSet_OperationPrs.cpp index 1640f4137..a231a9b98 100755 --- a/src/PartSet/PartSet_OperationPrs.cpp +++ b/src/PartSet/PartSet_OperationPrs.cpp @@ -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 aShape = aGeomShape.get() ? aGeomShape->impl() : 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(anObject); if (aResult.get()) { aGeomShape = aResult->shape(); diff --git a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp index 534ddb465..f02f52b4b 100755 --- a/src/PartSet/PartSet_SketcherReetntrantMgr.cpp +++ b/src/PartSet/PartSet_SketcherReetntrantMgr.cpp @@ -153,7 +153,7 @@ bool PartSet_SketcherReetntrantMgr::processMouseMoved(ModuleBase_IViewWindow* /* PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast(anActiveWidget); if (aPoint2DWdg) { // line, start point should be equal last point of the last feature line QList aSelection; - aSelection.append(ModuleBase_ViewerPrs(aLastFeature, TopoDS_Shape(), NULL)); + aSelection.append(ModuleBase_ViewerPrs(aLastFeature, GeomShapePtr(), NULL)); aWidgetIsFilled = aPoint2DWdg->setSelection(aSelection, true); } } diff --git a/src/PartSet/PartSet_Tools.cpp b/src/PartSet/PartSet_Tools.cpp index 7edba2413..6d46988ea 100755 --- a/src/PartSet/PartSet_Tools.cpp +++ b/src/PartSet/PartSet_Tools.cpp @@ -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(); + const TopoDS_Vertex& aVertex = TopoDS::Vertex(aTDShape); if (!aVertex.IsNull()) { gp_Pnt aPoint = BRep_Tool::Pnt(aVertex); diff --git a/src/PartSet/PartSet_Validators.cpp b/src/PartSet/PartSet_Validators.cpp index 7cb22655f..6baf8589d 100755 --- a/src/PartSet/PartSet_Validators.cpp +++ b/src/PartSet/PartSet_Validators.cpp @@ -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 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_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_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 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 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 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()) { diff --git a/src/PartSet/PartSet_WidgetPoint2d.cpp b/src/PartSet/PartSet_WidgetPoint2d.cpp index 8543f3143..004fd0d3c 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.cpp +++ b/src/PartSet/PartSet_WidgetPoint2d.cpp @@ -155,11 +155,12 @@ bool PartSet_WidgetPoint2D::setSelection(QList& 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(); + if (getPoint2d(aView, aTDShape, aX, aY)) { isDone = setPoint(aX, aY); PartSet_Tools::setConstraints(mySketch, feature(), attributeID(), aX, aY); } diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 76a50444c..8718bf149 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -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 aGShape; std::shared_ptr 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(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 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(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(); + aDir = setSketchPlane(aTDShape); isOwnerSet = aDir.get(); } return isOwnerSet; diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 978d61549..7833d748c 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -550,8 +550,9 @@ void XGUI_Displayer::setSelected(const QList& 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(); aContext->AddOrRemoveSelected(aShape, false); } else { ObjectPtr anObject = aPrs.object(); diff --git a/src/XGUI/XGUI_Selection.cpp b/src/XGUI/XGUI_Selection.cpp index 079c30cba..27fbd63de 100644 --- a/src/XGUI/XGUI_Selection.cpp +++ b/src/XGUI/XGUI_Selection.cpp @@ -110,7 +110,7 @@ void XGUI_Selection::getSelectedInBrowser(QList& 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 aGeomShape = std::shared_ptr(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 aGeomShape = std::shared_ptr(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 aGeomShape = std::shared_ptr(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(); - 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 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 aGeomShape = std::shared_ptr(new GeomAPI_Shape()); + aGeomShape->setImpl(new TopoDS_Shape(aShape)); + aPrs.setShape(aGeomShape); + } } aPresentations.push_back(aPrs); }