X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_GroupOnShapeDlg.cxx;h=258084e05a8228384a6a8b4a1e658b3347844c83;hp=c85a269df519848876fedd33013fec7b55d5d1f6;hb=251f8c052dd12dd29922210dc901b295fe999a0e;hpb=0635c9fc80f67d1e5dc0e94ec85f487286a92070 diff --git a/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx index c85a269df..258084e05 100644 --- a/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx @@ -1,24 +1,22 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, 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 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. // -// 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 // -// 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 +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // SMESH SMESHGUI : GUI for SMESH component // File : SMESHGUI_GroupOnShapeDlg.cxx // Created : Wed Sep 17 18:36:51 2008 @@ -29,14 +27,17 @@ #include "SMESHGUI_GroupOnShapeDlg.h" #include "SMESH_TypeFilter.hxx" +#include "SMESHGUI.h" #include "SMESHGUI_Utils.h" #include "SMESHGUI_GEOMGenUtils.h" #include #include +#include #include #include +#include #include #include @@ -178,7 +179,7 @@ SMESHGUI_GroupOnShapeOp::SMESHGUI_GroupOnShapeOp() : SMESHGUI_SelectionOp(ActorSelection), myDlg( 0 ) { - myHelpFileName = "creating_groups_page.html"; + myHelpFileName = "create_groups_from_geometry_page.html"; } SMESHGUI_GroupOnShapeOp::~SMESHGUI_GroupOnShapeOp() @@ -204,7 +205,7 @@ LightApp_Dialog* SMESHGUI_GroupOnShapeOp::dlg() const */ //================================================================================ -static SMESH::ElementType elementType(GEOM::GEOM_Object_var& geom) +static SMESH::ElementType elementType(GEOM::GEOM_Object_var geom) { if ( !geom->_is_nil() ) { switch ( geom->GetShapeType() ) { @@ -219,17 +220,18 @@ static SMESH::ElementType elementType(GEOM::GEOM_Object_var& geom) default: return SMESH::ALL; } _PTR(Study) aStudy = SMESH::GetActiveStudyDocument(); - GEOM::GEOM_IShapesOperations_var aShapeOp = + GEOM::GEOM_IShapesOperations_wrap aShapeOp = SMESH::GetGEOMGen()->GetIShapesOperations(aStudy->StudyId()); if ( geom->GetType() == 37 ) { // geom group - GEOM::GEOM_IGroupOperations_var aGroupOp = + GEOM::GEOM_IGroupOperations_wrap aGroupOp = SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); if ( !aGroupOp->_is_nil() ) { + // mainShape is an existing servant => GEOM_Object_var not GEOM_Object_wrap GEOM::GEOM_Object_var mainShape = aGroupOp->GetMainShape( geom ); GEOM::ListOfLong_var ids = aGroupOp->GetObjects( geom ); if ( ids->length() && !mainShape->_is_nil() && !aShapeOp->_is_nil() ) { - GEOM::GEOM_Object_var member = aShapeOp->GetSubShape( mainShape, ids[0] ); + GEOM::GEOM_Object_wrap member = aShapeOp->GetSubShape( mainShape, ids[0] ); return elementType( member ); } } @@ -237,7 +239,7 @@ static SMESH::ElementType elementType(GEOM::GEOM_Object_var& geom) else if ( !aShapeOp->_is_nil() ) { // just a compoud shape GEOM::ListOfLong_var ids = aShapeOp->SubShapeAllIDs( geom, GEOM::SHAPE, false ); if ( ids->length() ) { - GEOM::GEOM_Object_var member = aShapeOp->GetSubShape( geom, ids[0] ); + GEOM::GEOM_Object_wrap member = aShapeOp->GetSubShape( geom, ids[0] ); return elementType( member ); } } @@ -302,7 +304,7 @@ bool SMESHGUI_GroupOnShapeOp::onApply() if ( !aStudy ) return false; // mesh - _PTR(SObject) meshSO = aStudy->FindObjectID( myMeshID.toLatin1().data() ); + _PTR(SObject) meshSO = aStudy->FindObjectID( myMeshID.toLatin1().data() ); SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface( meshSO ); if ( mesh->_is_nil() ) return false; @@ -319,6 +321,7 @@ bool SMESHGUI_GroupOnShapeOp::onApply() // create groups SMESH::SMESH_GroupOnGeom_var group; + QStringList anEntryList; for ( int isNode = 0; isNode < 2; ++isNode ) // elems and then nodes { QStringList::iterator geomID = isNode ? myNodeGeoIDs.begin() : myElemGeoIDs.begin(); @@ -347,11 +350,28 @@ bool SMESHGUI_GroupOnShapeOp::onApply() //printf( "apply() %s %s\n", (*geomID).latin1(), name.latin1() ); group = mesh->CreateGroupFromGEOM( elemType, name.toLatin1().data(), geom ); + if( !group->_is_nil() ) + if( _PTR(SObject) aSObject = SMESH::ObjectToSObject( group ) ) + anEntryList.append( aSObject->GetID().c_str() ); } } + SMESHGUI::Modified(); + update( UF_ObjBrowser | UF_Model ); - init(); + // Re-init controls to create the next group + myElemGeoIDs.clear(); + myNodeGeoIDs.clear(); + removeCustomFilters(); + myDlg->myNodeGeomList->clear(); + myDlg->myElemGeomList->clear(); + myDlg->myElemGeomBtn->setChecked(false); + myDlg->myNodeGeomBtn->setChecked(false); + myDlg->updateButtons(); + + if( LightApp_Application* anApp = + dynamic_cast( SUIT_Session::session()->activeApplication() ) ) + anApp->browseObjects( anEntryList, isApplyAndClose() ); return !group->_is_nil(); } @@ -401,7 +421,7 @@ SUIT_SelectionFilter* SMESHGUI_GroupOnShapeOp::createFilter( const int theId ) c if ( theId == _ELEM_GEOM || theId == _NODE_GEOM ) return new GEOM_SelectionFilter( (SalomeApp_Study*)study(), true ); else if ( theId == _MESH ) - return new SMESH_TypeFilter( MESH ); + return new SMESH_TypeFilter( SMESH::MESH ); else return ( SUIT_SelectionFilter*) 0; } @@ -431,6 +451,7 @@ void SMESHGUI_GroupOnShapeOp::selectionDone() myDlg->myElemGeomBtn->setEnabled( nbSelected == 1 ); myDlg->myNodeGeomList->clear(); myDlg->myNodeGeomBtn->setEnabled( nbSelected == 1 ); + myDlg->myElemGeomBtn->click(); return; } @@ -470,13 +491,13 @@ void SMESHGUI_GroupOnShapeOp::selectionDone() } } - if ( myDlg->myElemGeomBtn->isChecked() ) // elem geomerty selection + if ( myDlg->myElemGeomBtn->isChecked() ) // elem geometry selection { myDlg->myElemGeomList->clear(); myDlg->myElemGeomList->addItems( goodNames ); myElemGeoIDs = goodIds; } - else if ( myDlg->myNodeGeomBtn->isChecked() ) // Node geomerty selection + else if ( myDlg->myNodeGeomBtn->isChecked() ) // Node geometry selection { myDlg->myNodeGeomList->clear(); myDlg->myNodeGeomList->addItems( goodNames );