X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_SelectionOp.cxx;h=fd509d47cb43127398f39b566d48dd32dd8ab950;hp=2e620f71cb574453cdb7e2b6813ba2ad06a7f6b7;hb=HEAD;hpb=c63ee099ad2b149bd70136839c973e8910137bc5 diff --git a/src/SMESHGUI/SMESHGUI_SelectionOp.cxx b/src/SMESHGUI/SMESHGUI_SelectionOp.cxx index 2e620f71c..c5d81acae 100644 --- a/src/SMESHGUI/SMESHGUI_SelectionOp.cxx +++ b/src/SMESHGUI/SMESHGUI_SelectionOp.cxx @@ -1,50 +1,52 @@ -// Copyright (C) 2003 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 +// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE +// +// Copyright (C) 2003-2007 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, or (at your option) any later version. // +// 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 // + +// File : SMESHGUI_SelectionOp.cxx +// Author : Alexander SOLOVYOV, Open CASCADE S.A.S. +// SMESH includes // -// File : SMESHGUI_SelectionOp.cxx -// Author : Alexander SOLOVYOV -// Module : SMESH - -#include -#include -#include -#include -#include +#include "SMESHGUI_SelectionOp.h" + +#include "SMESHGUI.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_MeshUtils.h" +#include "SMESHGUI_Selection.h" + +#include +#include +#include + +// SALOME GUI includes #include #include #include -#include #include #include -#include -#include -#include -#include +#include -#include CORBA_SERVER_HEADER(GEOM_Gen) +// SALOME KERNEL includes #include -#include - /* Class : SMESHGUI_SelectionOp Description : Base operation for all operations using object selection in viewer or objectbrowser @@ -101,10 +103,10 @@ void SMESHGUI_SelectionOp::removeCustomFilters() LightApp_SelectionMgr* mgr = selectionMgr(); Filters::const_iterator anIt = myFilters.begin(), aLast = myFilters.end(); - for (; anIt != aLast; anIt++) { - if (anIt.data()) { - if (mgr) mgr->removeFilter(anIt.data()); - delete anIt.data(); + for ( ; anIt != aLast; anIt++) { + if (anIt.value()) { + if (mgr) mgr->removeFilter(anIt.value()); + delete anIt.value(); } } @@ -193,7 +195,7 @@ void SMESHGUI_SelectionOp::onActivateObject( int id ) // name : onDeactivateObject // purpose : //================================================================================= -void SMESHGUI_SelectionOp::onDeactivateObject( int id ) +void SMESHGUI_SelectionOp::onDeactivateObject( int /*id*/ ) { removeCustomFilters(); } @@ -248,11 +250,11 @@ void SMESHGUI_SelectionOp::setSelectionMode( const Selection_Mode mode ) // Purpose : Highlight object in 3d viewer //======================================================================= void SMESHGUI_SelectionOp::highlight( const Handle( SALOME_InteractiveObject )& obj, - const bool hilight, const bool immediately ) + const bool highlight, const bool immediately ) { SVTK_ViewWindow* wnd = viewWindow(); if( wnd ) - wnd->highlight( obj, hilight, immediately ); + wnd->highlight( obj, highlight, immediately ); } //======================================================================= @@ -260,7 +262,7 @@ void SMESHGUI_SelectionOp::highlight( const Handle( SALOME_InteractiveObject )& // Purpose : Select/deselect cells of mesh //======================================================================= void SMESHGUI_SelectionOp::addOrRemoveIndex( const Handle( SALOME_InteractiveObject )& obj, - const TColStd_MapOfInteger& indices, + const SVTK_TVtkIDsMap& indices, const bool isModeShift ) { SVTK_Selector* sel = selector(); @@ -293,45 +295,39 @@ SVTK_Selector* SMESHGUI_SelectionOp::selector() const //======================================================================= int SMESHGUI_SelectionOp::typeById( const QString& str, const EntityType objtype ) const { - SalomeApp_Study* _study = dynamic_cast( study() ); - if( !_study ) - return -1; - - _PTR( Study ) st = _study->studyDS(); + _PTR(Study) aStudy = SMESH::getStudy(); int res = -1; if( objtype == Object ) { - SalomeApp_Study* _study = dynamic_cast( study() ); - if( _study ) + int t = SMESHGUI_Selection::type( str ); + if( t<0 ) { - int t = SMESHGUI_Selection::type( str, _study->studyDS() ); - if( t<0 ) + //try to get GEOM type + _PTR( SObject ) sobj = aStudy->FindObjectID( str.toUtf8().data() ); + if( sobj ) { - //try to get GEOM type - _PTR( SObject ) sobj = st->FindObjectID( str.latin1() ); - if( sobj ) - { - GEOM::GEOM_Object_var obj = GEOM::GEOM_Object::_narrow( - dynamic_cast( sobj.get() )->GetObject() ); - if( !CORBA::is_nil( obj ) ) - res = SMESHGUI_Dialog::prefix( "GEOM" ) + obj->GetType(); - } + GEOM::GEOM_Object_var obj = GEOM::GEOM_Object::_narrow( + dynamic_cast( sobj.get() )->GetObject() ); + if( !CORBA::is_nil( obj ) ) + // as decoding of type id is not realized in LightApp_Dialog, + //make all GEOM objects have same type id + res = SMESHGUI_Dialog::prefix( "GEOM" );// + obj->GetType(); } - else - res = SMESHGUI_Dialog::prefix( "SMESH" ) + t; } + else + res = SMESHGUI_Dialog::prefix( "SMESH" ) + t; } else { - int pos = str.find( idChar() ); + int pos = str.indexOf( idChar() ); QString entry = str.left( pos ), _id = str.mid( pos+1 ); bool ok; int id = _id.toInt( &ok ); if( ok ) { - _PTR( SObject ) sobj = st->FindObjectID( entry.latin1() ); + _PTR( SObject ) sobj = aStudy->FindObjectID( entry.toUtf8().data() ); SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( dynamic_cast( sobj.get() )->GetObject() ); SMESH::SMESH_subMesh_var submesh = SMESH::SMESH_subMesh::_narrow( @@ -418,13 +414,9 @@ void SMESHGUI_SelectionOp::selected( QStringList& names, QString id = anIt.Value()->getEntry(); ids.append( id ); types.append( typeById( id, Object ) ); - SalomeApp_Study* _study = dynamic_cast( study() ); - if( _study ) - { - _PTR(SObject) obj = _study->studyDS()->FindObjectID( anIt.Value()->getEntry() ); - if( obj ) - names.append( obj->GetName().c_str() ); - } + _PTR(SObject) obj = SMESH::getStudy()->FindObjectID( anIt.Value()->getEntry() ); + if( obj ) + names.append( QString( obj->GetName().c_str() ).trimmed() ); } } } @@ -476,7 +468,7 @@ void SMESHGUI_SelectionOp::onTextChanged( int, const QStringList& list ) if( !dlg() ) return; - TColStd_MapOfInteger newIndices; + SVTK_TVtkIDsMap newIndices; SALOME_ListIO sel; selectionMgr()->selectedObjects( sel ); SMESH_Actor* anActor = actor(); @@ -488,9 +480,16 @@ void SMESHGUI_SelectionOp::onTextChanged( int, const QStringList& list ) IdList ids; extractIds( list, ids, '\0' ); IdList::const_iterator anIt = ids.begin(), aLast = ids.end(); - for( ; anIt!=aLast; anIt++ ) - if( const SMDS_MeshNode * n = aMesh->FindNode( *anIt ) ) - newIndices.Add( n->GetID() ); + if ( selectionMode() == NodeSelection ) + for( ; anIt!=aLast; anIt++ ) { + if( const SMDS_MeshNode * n = aMesh->FindNode( *anIt ) ) + newIndices.Add( n->GetID() ); + } + else + for( ; anIt!=aLast; anIt++ ) { + if( const SMDS_MeshElement* e = aMesh->FindElement( *anIt ) ) + newIndices.Add( e->GetID() ); + } selector()->AddOrRemoveIndex( sel.First(), newIndices, false ); highlight( sel.First(), true, true ); @@ -525,7 +524,7 @@ void SMESHGUI_SelectionOp::extractIds( const QStringList& ids, IdList& list, con for( ; anIt!=aLast; anIt++ ) { id_str = *anIt; - int pos = idchar=='\0' ? -1 : id_str.find( idchar ); + int pos = idchar=='\0' ? -1 : id_str.indexOf( idchar ); int id = -1; if( idchar=='\0' || pos>=0 ) {