From: vsv Date: Fri, 15 May 2020 09:28:47 +0000 (+0300) Subject: Issue #3245: Use plane objects on selection of a Sketcher plane as an abstract plane... X-Git-Tag: V9_5_0b1~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=913b93e33d6eea6618560d2fa913004e4e65df2e;p=modules%2Fshaper.git Issue #3245: Use plane objects on selection of a Sketcher plane as an abstract plane (like colored ones) --- diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 171cf3abc..df0124eb8 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -510,48 +511,61 @@ bool PartSet_WidgetSketchLabel::fillSketchPlaneBySelection(const ModuleBase_View { bool isOwnerSet = false; - const GeomShapePtr& aShape = thePrs->shape(); + GeomShapePtr aShape = thePrs->shape(); std::shared_ptr aDir; + if (!aShape.get() || aShape->isNull()) { + if (thePrs->object() && (feature() != thePrs->object())) { + if (thePrs->object()->groupName() == ModelAPI_ResultConstruction::group()) { + ResultConstructionPtr aConstruction = + std::dynamic_pointer_cast(thePrs->object()); + if (aConstruction.get()) + aShape = aConstruction->shape(); + } + } + } + if (aShape.get() && !aShape->isNull()) { const TopoDS_Shape& aTDShape = aShape->impl(); aDir = setSketchPlane(aTDShape); isOwnerSet = aDir.get(); } if (thePrs->object() && (feature() != thePrs->object())) { - FeaturePtr aFeature = ModelAPI_Feature::feature(thePrs->object()); - DataPtr aData = feature()->data(); - AttributeSelectionPtr aSelAttr = - std::dynamic_pointer_cast - (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())); - if (aSelAttr.get()) { - ResultPtr aRes = std::dynamic_pointer_cast(thePrs->object()); - if (aRes.get()) { - GeomShapePtr aShapePtr; - if (!aShape.get() || aShape->isNull()) { // selection happens in the OCC viewer - aShapePtr = ModelAPI_Tools::shape(aRes); - } - else { // selection happens in OB browser - aShapePtr = aShape; - } - if (aShapePtr.get() && aShapePtr->isFace()) { - const TopoDS_Shape& aTDShape = aShapePtr->impl(); - setSketchPlane(aTDShape); - aSelAttr->setValue(aRes, aShapePtr); - isOwnerSet = true; - } - } - else { - aSelAttr->setValue(aFeature, GeomShapePtr()); - GeomShapePtr aShape = aSelAttr->value(); - if (!aShape.get() && aSelAttr->contextFeature().get() && - aSelAttr->contextFeature()->firstResult().get()) { - aShape = aSelAttr->contextFeature()->firstResult()->shape(); + if (thePrs->object()->groupName() != ModelAPI_ResultConstruction::group()) { + FeaturePtr aFeature = ModelAPI_Feature::feature(thePrs->object()); + DataPtr aData = feature()->data(); + AttributeSelectionPtr aSelAttr = + std::dynamic_pointer_cast + (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID())); + if (aSelAttr.get()) { + ResultPtr aRes = std::dynamic_pointer_cast(thePrs->object()); + if (aRes.get()) { + GeomShapePtr aShapePtr; + if (!aShape.get() || aShape->isNull()) { // selection happens in the OCC viewer + aShapePtr = ModelAPI_Tools::shape(aRes); + } + else { // selection happens in OB browser + aShapePtr = aShape; + } + if (aShapePtr.get() && aShapePtr->isFace()) { + const TopoDS_Shape& aTDShape = aShapePtr->impl(); + setSketchPlane(aTDShape); + aSelAttr->setValue(aRes, aShapePtr); + isOwnerSet = true; + } } - if (aShape.get() && aShape->isPlanar()) { - const TopoDS_Shape& aTDShape = aShape->impl(); - setSketchPlane(aTDShape); - isOwnerSet = true; + else { + aSelAttr->setValue(aFeature, GeomShapePtr()); + GeomShapePtr aShape = aSelAttr->value(); + if (!aShape.get() && aSelAttr->contextFeature().get() && + aSelAttr->contextFeature()->firstResult().get()) { + aShape = aSelAttr->contextFeature()->firstResult()->shape(); + } + if (aShape.get() && aShape->isPlanar()) { + const TopoDS_Shape& aTDShape = aShape->impl(); + setSketchPlane(aTDShape); + isOwnerSet = true; + } } } }