X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMGUI%2FGEOMGUI_OCCSelector.cxx;h=27d2340fdfd5276d254b3fcd800114ec4a2da1df;hb=8b645f521e38dedf374122e23f28450e05399405;hp=c2afc40b993f84b9079c2a194a3834a4fcf6bf2f;hpb=fedf580aaa1cdbe35e069626879b922dc7fbb2ff;p=modules%2Fgeom.git diff --git a/src/GEOMGUI/GEOMGUI_OCCSelector.cxx b/src/GEOMGUI/GEOMGUI_OCCSelector.cxx index c2afc40b9..27d2340fd 100644 --- a/src/GEOMGUI/GEOMGUI_OCCSelector.cxx +++ b/src/GEOMGUI/GEOMGUI_OCCSelector.cxx @@ -1,11 +1,28 @@ +// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #include "GEOMGUI_OCCSelector.h" -#include +#include #include -#include - #include #include #include @@ -16,17 +33,20 @@ #include #include #include +#include #include -#include #include +#include +#include + //================================================================ // Function : GEOMGUI_OCCSelector // Purpose : //================================================================ GEOMGUI_OCCSelector::GEOMGUI_OCCSelector( OCCViewer_Viewer* viewer, SUIT_SelectionMgr* mgr ) -: SalomeApp_OCCSelector( viewer, mgr ) +: LightApp_OCCSelector( viewer, mgr ) { } @@ -54,7 +74,7 @@ void GEOMGUI_OCCSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const { for ( ic->InitSelected(); ic->MoreSelected(); ic->NextSelected() ) { - Handle(SelectMgr_EntityOwner) anOwner = ic->SelectedOwner(); + Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(ic->SelectedOwner()); if ( anOwner.IsNull() ) continue; @@ -79,11 +99,11 @@ void GEOMGUI_OCCSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const if ( !entryStr.isEmpty() ) { - SalomeApp_DataOwner* owner; + LightApp_DataOwner* owner; if ( index > -1 ) // Local Selection - owner = new SalomeApp_DataSubOwner( entryStr, index ); + owner = new LightApp_DataSubOwner( entryStr, index ); else // Global Selection - owner = new SalomeApp_DataOwner( entryStr ); + owner = new LightApp_DataOwner( entryStr ); aList.append( SUIT_DataOwnerPtr( owner ) ); } @@ -99,11 +119,17 @@ void GEOMGUI_OCCSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const if ( !entryStr.isEmpty() ) { - SalomeApp_DataOwner* owner = new SalomeApp_DataOwner( entryStr ); + LightApp_DataOwner* owner = new LightApp_DataOwner( entryStr ); aList.append( SUIT_DataOwnerPtr( owner ) ); } } } + // add externally selected objects + SUIT_DataOwnerPtrList::const_iterator anExtIter; + for(anExtIter = mySelectedExternals.begin(); anExtIter != mySelectedExternals.end(); anExtIter++) { + aList.append(*anExtIter); + } + } //================================================================ @@ -164,13 +190,17 @@ void GEOMGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList ) // "entry - to - list_of_ids" map for ( SUIT_DataOwnerPtrList::const_iterator itr = aList.begin(); itr != aList.end(); ++itr ) { - const SalomeApp_DataSubOwner* subOwner = dynamic_cast( (*itr).operator->() ); + const LightApp_DataSubOwner* subOwner = dynamic_cast( (*itr).operator->() ); if ( subOwner ) { QString entry = subOwner->entry(); - if ( indexesMap.IsBound( TCollection_AsciiString((char*)entry.latin1()))) +#ifndef WNT + if ( indexesMap.IsBound( TCollection_AsciiString(entry.toLatin1().data()))) +#else + if ( indexesMap.IsBound( (char*)entry.toLatin1())) +#endif { - TColStd_IndexedMapOfInteger& subIndexes = indexesMap.ChangeFind((char*)entry.latin1()); + TColStd_IndexedMapOfInteger& subIndexes = indexesMap.ChangeFind(entry.toLatin1().data()); subIndexes.Add( subOwner->index() ); //indexesMap.replace( entry, subIndexes ); } @@ -178,15 +208,18 @@ void GEOMGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList ) { TColStd_IndexedMapOfInteger subIndexes; subIndexes.Add( subOwner->index() ); - indexesMap.Bind((char*)entry.latin1(), subIndexes); + indexesMap.Bind(entry.toLatin1().data(), subIndexes); } } else // the owner is NOT a sub owner, maybe it is a DataOwner == GLOBAL selection { - const SalomeApp_DataOwner* owner = dynamic_cast( (*itr).operator->() ); + const LightApp_DataOwner* owner = dynamic_cast( (*itr).operator->() ); if ( owner ) { - globalSelMap[owner->entry()] = 1; + SalomeApp_Study* appStudy = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); + QString anEntry = appStudy->referencedToEntry( owner->entry() ); + + globalSelMap[anEntry] = 1; } } } @@ -204,7 +237,9 @@ void GEOMGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList ) for ( int i = 1, n = owners.Extent(); i <= n; i++ ) { - Handle(SelectMgr_EntityOwner) anOwner = owners( i ); + + Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(owners( i )); + if ( anOwner.IsNull() || !anOwner->HasShape() ) continue; @@ -212,18 +247,19 @@ void GEOMGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList ) if ( !anOwner->ComesFromDecomposition() && globalSelMap.contains( entryStr ) ) { ownersmap.Add( anOwner ); + globalSelMap[entryStr]++; } // LOCAL selection else { Handle(AIS_Shape) aisShape = Handle(AIS_Shape)::DownCast( io ); - if ( !aisShape.IsNull() && indexesMap.IsBound( (char*)entryStr.latin1() ) ) + if ( !aisShape.IsNull() && indexesMap.IsBound( entryStr.toLatin1().data() ) ) { TopoDS_Shape shape = aisShape->Shape(); TopTools_IndexedMapOfShape aMapOfShapes; TopExp::MapShapes( shape, aMapOfShapes ); - const TColStd_IndexedMapOfInteger& subIndexes = indexesMap.ChangeFind((char*)entryStr.latin1()); + const TColStd_IndexedMapOfInteger& subIndexes = indexesMap.ChangeFind(entryStr.toLatin1().data()); const TopoDS_Shape& aSubShape = anOwner->Shape(); int aSubShapeId = aMapOfShapes.FindIndex( aSubShape ); @@ -256,4 +292,20 @@ void GEOMGUI_OCCSelector::setSelection( const SUIT_DataOwnerPtrList& aList ) } vw->update(); + + // fill extra selected + mySelectedExternals.clear(); + for ( SUIT_DataOwnerPtrList::const_iterator itr2 = aList.begin(); itr2 != aList.end(); ++itr2 ) { + const LightApp_DataSubOwner* subOwner = dynamic_cast( (*itr2).operator->() ); + if ( !subOwner ) + { + const LightApp_DataOwner* owner = dynamic_cast( (*itr2).operator->() ); + if ( owner ) + { + SalomeApp_Study* appStudy = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); + QString anEntry = appStudy->referencedToEntry( owner->entry() ); + if (globalSelMap[anEntry] == 1) mySelectedExternals.append(*itr2); + } + } + } }