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
/// \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
::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<Handle(AIS_InteractiveObject)> 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);