From d28df32e68f0adcffb0cb7c255add50ed94460ce Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 14 Dec 2010 07:13:38 +0000 Subject: [PATCH] 0021107: EDF 1701 GEOM: deflection value of preferences not taken into account --- src/GEOMGUI/GEOMGUI_Selection.cxx | 17 ++--------- src/GEOMGUI/GEOM_Displayer.cxx | 47 +++++++++++++++---------------- 2 files changed, 25 insertions(+), 39 deletions(-) diff --git a/src/GEOMGUI/GEOMGUI_Selection.cxx b/src/GEOMGUI/GEOMGUI_Selection.cxx index f4aeb8ccf..1730ce200 100644 --- a/src/GEOMGUI/GEOMGUI_Selection.cxx +++ b/src/GEOMGUI/GEOMGUI_Selection.cxx @@ -281,21 +281,8 @@ bool GEOMGUI_Selection::isCompoundOfVertices( GEOM::GEOM_Object_ptr obj ) bool ret = false; SalomeApp_Study* appStudy = dynamic_cast (SUIT_Session::session()->activeApplication()->activeStudy()); - if ( appStudy && !CORBA::is_nil( obj ) && obj->GetShapeType() == GEOM::COMPOUND ) { - GEOM::GEOM_IMeasureOperations_var anOper = GeometryGUI::GetGeomGen()->GetIMeasureOperations( appStudy->id() ); - QString whatIs = anOper->WhatIs( obj ); - QStringList data = whatIs.split( "\n", QString::SkipEmptyParts ); - int nbVertices = 0, nbCompounds = 0, nbOther = 0; - foreach ( QString s, data ) { - QString type = s.section( ":", 0, 0 ).trimmed().toLower(); - int cnt = s.section( ":", 1, 1 ).trimmed().toInt(); - if ( type == "vertex" ) nbVertices += cnt; - else if ( type == "compound" ) nbCompounds += cnt; - else if ( type != "shape" ) nbOther += cnt; - } - ret = nbVertices > 0 && nbCompounds == 1 && nbOther == 0; - anOper->Destroy(); - } + if ( appStudy && !CORBA::is_nil( obj ) ) + ret = obj->GetShapeType() == GEOM::COMPOUND && obj->GetMaxShapeType() == GEOM::VERTEX; return ret; } diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index eb0cf2658..5cd4b18d9 100644 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -129,36 +129,35 @@ static inline int getTopAbsMode( const int implType ) } } -static bool isCompoundOfVertices( const TopoDS_Shape& theShape ) +static int getMinMaxShapeType( const TopoDS_Shape& shape, bool ismin ) { - bool ret = false; - if ( !theShape.IsNull() ) { - int iType, nbTypes [TopAbs_SHAPE]; - for (iType = 0; iType < TopAbs_SHAPE; ++iType) - nbTypes[iType] = 0; - nbTypes[theShape.ShapeType()]++; - - TopTools_MapOfShape aMapOfShape; - aMapOfShape.Add(theShape); - TopTools_ListOfShape aListOfShape; - aListOfShape.Append(theShape); - - TopTools_ListIteratorOfListOfShape itL (aListOfShape); - for (; itL.More(); itL.Next()) { - TopoDS_Iterator it (itL.Value()); - for (; it.More(); it.Next()) { - TopoDS_Shape s = it.Value(); - if (aMapOfShape.Add(s)) { - aListOfShape.Append(s); - nbTypes[s.ShapeType()]++; - } - } + if ( shape.IsNull() ) + return TopAbs_SHAPE; + + int ret = shape.ShapeType(); + + if ( shape.ShapeType() == TopAbs_COMPOUND || shape.ShapeType() == TopAbs_COMPSOLID ) { + TopoDS_Iterator it(shape, Standard_True, Standard_False); + for (; it.More(); it.Next()) { + TopoDS_Shape sub_shape = it.Value(); + if ( sub_shape.IsNull() ) continue; + int stype = getMinMaxShapeType( sub_shape, ismin ); + if ( stype == TopAbs_SHAPE ) continue; + if ( ismin && stype > ret ) + ret = stype; + else if ( !ismin && ( ret < TopAbs_SOLID || stype < ret ) ) + ret = stype; } - ret = nbTypes[TopAbs_VERTEX] > 0 && nbTypes[TopAbs_COMPOUND] == 1; } + return ret; } +static bool isCompoundOfVertices( const TopoDS_Shape& theShape ) +{ + return theShape.ShapeType() == TopAbs_COMPOUND && getMinMaxShapeType( theShape, false ) == TopAbs_VERTEX; +} + //================================================================ // Function : getFilter // Purpose : Get filter corresponding to the type of object -- 2.39.2