From: vsv Date: Thu, 1 Aug 2019 08:43:09 +0000 (+0300) Subject: Provide possibility to select compounds of groups in multi-selector X-Git-Tag: VEDF2019Lot4~59^2~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=233f2a476dcdabd080880e4b9cb54a66433a8142;p=modules%2Fshaper.git Provide possibility to select compounds of groups in multi-selector --- diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 3d47d3cde..e8124f80f 100644 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -1299,6 +1299,28 @@ std::string generateName(const AttributePtr& theAttribute, return aName; } +bool isSameShape(const TopoDS_Shape& theShape1, const TopoDS_Shape& theShape2) +{ + // In case of compound we cannot rely on simple comparison method. + // If the compound is generated by Group feature then this compound is alwais new. + // So, we have to compare content of these compounds + if (theShape1.ShapeType() != theShape2.ShapeType()) + return false; + + if (theShape1.ShapeType() != TopAbs_COMPOUND) + return theShape1.IsSame(theShape2); + + TopoDS_Iterator aIt1(theShape1); + TopoDS_Iterator aIt2(theShape2); + + for (; aIt1.More() && aIt2.More(); aIt1.Next(), aIt2.Next()) { + if (!(aIt1.Value()).IsSame(aIt2.Value())) + return false; + } + return true; +} + + } // namespace ModuleBase_Tools diff --git a/src/ModuleBase/ModuleBase_Tools.h b/src/ModuleBase/ModuleBase_Tools.h index 4523b7d80..d6e4c4c55 100644 --- a/src/ModuleBase/ModuleBase_Tools.h +++ b/src/ModuleBase/ModuleBase_Tools.h @@ -389,6 +389,12 @@ bool MODULEBASE_EXPORT isNameExist(const QString& theName, FeaturePtr theIgnoreP /// \theName a name of parameter FeaturePtr MODULEBASE_EXPORT findParameter(const QString& theName); +/// Returns true if both shapes are the same. In case of compounds it +/// compares their contents. +/// \param theShape1 a first shape to compare +/// \param theShape2 a second shape to compare +/// \return true if both shapes are the same +bool MODULEBASE_EXPORT isSameShape(const TopoDS_Shape& theShape1, const TopoDS_Shape& theShape2); //----------- Class members ------------- /// Returns a name in the next form: attribute_feature_name/attribute_id diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 23753cf8c..099d61ad0 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -1097,17 +1097,21 @@ void XGUI_Displayer::AddOrRemoveSelectedShapes(Handle(AIS_InteractiveContext) th ::Iterator aShapeIt(theShapesToBeSelected); for (; aShapeIt.More(); aShapeIt.Next()) { const TopoDS_Shape& aParameterShape = aShapeIt.Key(); - // isSame should be used here as it does not check orientation of shapes - // despite on isEqual of shapes or IsBound for shape in QMap. Orientation is - // different for Edges shapes in model shape and owner even if this is the same shape - if (aParameterShape.IsSame(aShape)) { + // In case of compound we cannot rely on simple comparison method. + // If the compound is generated by Group feature then this compound is alwais new. + // So, we have to compare content of these compounds + + // isSame should be used here as it does not check orientation of shapes + // despite on isEqual of shapes or IsBound for shape in QMap. Orientation is + // different for Edges shapes in model shape and owner even if this is the same shape + if (ModuleBase_Tools::isSameShape(aParameterShape, aShape)) { Handle(AIS_InteractiveObject) anOwnerPresentation = - Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable()); + Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable()); NCollection_Map aPresentations = - theShapesToBeSelected.Find(aParameterShape); + theShapesToBeSelected.Find(aParameterShape); if (aPresentations.Contains(anOwnerPresentation)) { theContext->AddOrRemoveSelected(anOwner, Standard_False); - anOwner->SetSelected (Standard_True); + anOwner->SetSelected(Standard_True); // collect selected presentations to do not select them if compsolid is selected if (!aSelectedPresentations.Contains(anOwnerPresentation)) aSelectedPresentations.Add(anOwnerPresentation);