From df391f9b952d5e043bd98e40b5a4bffb57597ef6 Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 19 Dec 2007 12:32:56 +0000 Subject: [PATCH] NPAL18352: Selection bug in GEOM GUI. --- src/GEOMGUI/GeometryGUI.cxx | 18 ++++++------ src/GEOMImpl/GEOMImpl_IShapesOperations.cxx | 32 +++++++++++++++++---- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 4519aee0d..ec01947a8 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -212,8 +212,8 @@ GEOMGUI* GeometryGUI::getLibrary( const QString& libraryName ) // try to load library if it is not loaded yet QCString libs; #ifndef WNT - if( ( libs = getenv( "LD_LIBRARY_PATH" ) ) ) { - QStringList dirList = QStringList::split( ":", libs, false ); // skip empty entries + if ( (libs = getenv( "LD_LIBRARY_PATH" )) ) { + QStringList dirList = QStringList::split( ":", libs, false ); // skip empty entries #else if( ( libs = getenv( "PATH" ) ) ) { QStringList dirList = QStringList::split( ";", libs, false ); // skip empty entries @@ -377,7 +377,7 @@ void GeometryGUI::OnGUIEvent( int id ) id == 2175 || // POPUP VIEWER - SELECT ONLY - SHELL id == 2176 || // POPUP VIEWER - SELECT ONLY - SOLID id == 2177 || // POPUP VIEWER - SELECT ONLY - COMPOUND - id == 2178 || // POPUP VIEWER - SELECT ONLY - SELECT ALL + id == 2178 || // POPUP VIEWER - SELECT ONLY - SELECT ALL id == 31 || // MENU EDIT - COPY id == 33 || // MENU EDIT - DELETE id == 411 || // MENU SETTINGS - ADD IN STUDY @@ -860,7 +860,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( 707, "CHECK" ); createGeomAction( 7072, "CHECK_COMPOUND" ); -#ifdef _DEBUG_ // PAL16821 +#ifdef _DEBUG_ // PAL16821 createGeomAction( 5103, "CHECK_GEOMETRY" ); #endif createGeomAction( 412, "SHADING_COLOR" ); @@ -1028,7 +1028,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( 707, measurId, -1 ); createMenu( 7072, measurId, -1 ); -#ifdef _DEBUG_ // PAL16821 +#ifdef _DEBUG_ // PAL16821 int toolsId = createMenu( tr( "MEN_TOOLS" ), -1, -1, 50 ); createMenu( separator(), toolsId, -1 ); createMenu( 5103, toolsId, -1 ); @@ -1164,7 +1164,7 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->setRule( action( 214 ), clientOCCorVTK, true ); QString selectOnly = "(client='OCCViewer' or client='VTKViewer') and (selcount=0)"; - + int selectolnyId = mgr->insert( tr("MEN_SELECT_ONLY"), -1, -1); //select only menu mgr->insert( action(2171), selectolnyId, -1); //Vertex mgr->setRule(action(2171), selectOnly, true); @@ -1191,7 +1191,7 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->insert( action(2178), selectolnyId, -1); //Clear selection filter mgr->setRule(action(2178), selectOnly, true); mgr->setRule(action(2178), selectOnly + " and selectionmode='ALL'", false); - + mgr->insert( action( 213 ), -1, -1 ); // display only mgr->setRule( action( 213 ), rule.arg( types ).arg( "true" ), true ); mgr->insert( separator(), -1, -1 ); @@ -1240,12 +1240,12 @@ bool GeometryGUI::activateModule( SUIT_Study* study ) myVTKSelectors.append( new LightApp_VTKSelector( dynamic_cast( vm->getViewModel() ), sm ) ); // disable OCC selectors - getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() ); + //getApp()->selectionMgr()->setEnabled( false, OCCViewer_Viewer::Type() ); for ( GEOMGUI_OCCSelector* sr = myOCCSelectors.first(); sr; sr = myOCCSelectors.next() ) sr->setEnabled(true); // disable VTK selectors - getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() ); + //getApp()->selectionMgr()->setEnabled( false, SVTK_Viewer::Type() ); for ( LightApp_VTKSelector* sr = myVTKSelectors.first(); sr; sr = myVTKSelectors.next() ) sr->setEnabled(true); diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index a9c54b647..4f09b784d 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -41,6 +41,7 @@ #include "GEOMImpl_Block6Explorer.hxx" #include "GEOM_Function.hxx" +#include "GEOM_ISubShape.hxx" #include "GEOM_PythonDump.hxx" #include "GEOMAlgo_FinderShapeOn1.hxx" @@ -753,9 +754,10 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode TopoDS_Shape aShape = theShape->GetValue(); if (aShape.IsNull()) return NULL; + Handle(GEOM_Function) aMainShape = theShape->GetLastFunction(); + Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; Handle(GEOM_Object) anObj; - Handle(GEOM_Function) aFunction; TopTools_MapOfShape mapShape; TopTools_ListOfShape listShape; @@ -792,13 +794,33 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode TopExp::MapShapes(aShape, anIndices); Handle(TColStd_HArray1OfInteger) anArray; + Standard_Integer nbAllSubShape = anIndices.Extent(); + TopTools_ListIteratorOfListOfShape itSub (listShape); TCollection_AsciiString anAsciiList, anEntry; - for (int index = 1; itSub.More(); itSub.Next(), ++index) { + for (int index = 1; itSub.More(); itSub.Next(), ++index) + { TopoDS_Shape aValue = itSub.Value(); anArray = new TColStd_HArray1OfInteger(1,1); anArray->SetValue(1, anIndices.FindIndex(aValue)); - anObj = GetEngine()->AddSubShape(theShape, anArray); + + //anObj = GetEngine()->AddSubShape(theShape, anArray); + { + anObj = GetEngine()->AddObject(GetDocID(), GEOM_SUBSHAPE); + Handle(GEOM_Function) aFunction = anObj->AddFunction(GEOM_Object::GetSubShapeID(), 1); + if (aFunction.IsNull()) return aSeq; + + GEOM_ISubShape aSSI (aFunction); + aSSI.SetMainShape(aMainShape); + aSSI.SetIndices(anArray); + + // Set function value directly, as we know it. + // Usage of Solver here would lead to significant loss of time, + // because GEOM_SubShapeDriver will build TopTools_IndexedMapOfShape + // on the main shape for each being calculated sub-shape separately. + aFunction->SetValue(aValue); + } + if (!anObj.IsNull()) { aSeq->Append(anObj); @@ -812,9 +834,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::MakeExplode //Make a Python command anAsciiList.Trunc(anAsciiList.Length() - 1); - aFunction = theShape->GetLastFunction(); - - GEOM::TPythonDump pd (aFunction, /*append=*/true); + GEOM::TPythonDump pd (aMainShape, /*append=*/true); pd << "[" << anAsciiList.ToCString(); pd << "] = geompy.SubShapeAll" << (isSorted ? "Sorted(" : "("); pd << theShape << ", " << TopAbs_ShapeEnum(theShapeType) << ")"; -- 2.39.2