1 // SMESH SMESHGUI : GUI for SMESH component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESHGUI_MeshOp.cxx
23 // Author : Sergey LITONIN, Open CASCADE S.A.S.
27 #include "SMESHGUI_MeshOp.h"
30 #include "SMESHGUI_MeshDlg.h"
31 #include "SMESHGUI_ShapeByMeshDlg.h"
32 #include "SMESHGUI_HypothesesUtils.h"
33 #include "SMESHGUI_Hypotheses.h"
34 #include "SMESHGUI_Utils.h"
35 #include "SMESHGUI_GEOMGenUtils.h"
37 #include <SMESH_TypeFilter.hxx>
38 #include <SMESH_NumberFilter.hxx>
40 // SALOME GEOM includes
41 #include <GEOM_SelectionFilter.h>
43 #include <GeometryGUI.h>
45 // SALOME GUI includes
46 #include <SalomeApp_Tools.h>
47 #include <SalomeApp_Application.h>
48 #include <LightApp_SelectionMgr.h>
49 #include <LightApp_UpdateFlags.h>
50 #include <SUIT_MessageBox.h>
51 #include <SUIT_OverrideCursor.h>
52 #include <SALOME_InteractiveObject.hxx>
53 #include <SALOME_ListIO.hxx>
55 // SALOME KERNEL includes
56 #include <SALOMEDS_SComponent.hxx>
57 #include <SALOMEDS_SObject.hxx>
60 #include <QStringList>
64 #include <TopoDS_Shape.hxx>
65 #include <TopExp_Explorer.hxx>
68 #include <SALOMEconfig.h>
69 #include CORBA_CLIENT_HEADER(SMESH_Gen)
71 //================================================================================
74 * \param theToCreate - if this parameter is true then operation is used for creation,
75 * for editing otherwise
77 * Initialize operation
79 //================================================================================
80 SMESHGUI_MeshOp::SMESHGUI_MeshOp( const bool theToCreate, const bool theIsMesh )
81 : SMESHGUI_SelectionOp(),
82 myToCreate( theToCreate ),
83 myIsMesh( theIsMesh ),
87 if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists
88 GeometryGUI::InitGeomGen();
89 myIsOnGeometry = true;
92 //================================================================================
96 //================================================================================
97 SMESHGUI_MeshOp::~SMESHGUI_MeshOp()
103 //================================================================================
105 * \brief Gets dialog of this operation
106 * \retval LightApp_Dialog* - pointer to dialog of this operation
108 //================================================================================
109 LightApp_Dialog* SMESHGUI_MeshOp::dlg() const
114 //================================================================================
116 * \brief Creates or edits mesh
117 * \retval bool - TRUE if operation is performed successfully, FALSE otherwise
119 * Virtual slot redefined from the base class called when "Apply" button is clicked
120 * creates or edits mesh
122 //================================================================================
123 bool SMESHGUI_MeshOp::onApply()
129 if ( !isValid( aMess ) )
133 SUIT_MessageBox::warning( myDlg, tr( "SMESH_WRN_WARNING" ), aMess );
137 bool aResult = false;
141 if ( myToCreate && myIsMesh )
142 aResult = createMesh( aMess );
143 if ( myToCreate && !myIsMesh )
144 aResult = createSubMesh( aMess );
145 else if ( !myToCreate )
146 aResult = editMeshOrSubMesh( aMess );
148 update( UF_ObjBrowser | UF_Model );
150 catch ( const SALOME::SALOME_Exception& S_ex )
152 SalomeApp_Tools::QtCatchCorbaException( S_ex );
168 aMess = tr( "SMESH_OPERATION_FAILED" );
169 SUIT_MessageBox::warning( myDlg, tr( "SMESH_ERROR" ), aMess );
175 //================================================================================
177 * \brief Creates dialog if necessary and shows it
179 * Virtual method redefined from base class called when operation is started creates
180 * dialog if necessary and shows it, activates selection
182 //================================================================================
183 void SMESHGUI_MeshOp::startOperation()
187 myDlg = new SMESHGUI_MeshDlg( myToCreate, myIsMesh );
188 for ( int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++ )
190 connect( myDlg->tab( i ), SIGNAL( createHyp( const int, const int ) ),
191 this, SLOT( onCreateHyp( const int, const int ) ) );
192 connect( myDlg->tab( i ), SIGNAL( editHyp( const int, const int ) ),
193 this, SLOT( onEditHyp( const int, const int ) ) );
194 connect( myDlg->tab( i ), SIGNAL( selectAlgo( const int ) ),
195 this, SLOT( onAlgoSelected( const int ) ) );
197 connect( myDlg, SIGNAL( hypoSet( const QString& )), SLOT( onHypoSet( const QString& )));
198 connect( myDlg, SIGNAL( geomSelectionByMesh( bool )), SLOT( onGeomSelectionByMesh( bool )));
201 if ( myIsMesh ) myHelpFileName = "constructing_meshes_page.html";
202 else myHelpFileName = "constructing_submeshes_page.html";
203 else myHelpFileName = "editing_meshes_page.html";
205 SMESHGUI_SelectionOp::startOperation();
207 // iterate through dimensions and get available algoritms, set them to the dialog
208 _PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" );
209 for ( int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++ )
211 SMESHGUI_MeshTab* aTab = myDlg->tab( i );
213 // clear available hypotheses
214 aTab->setAvailableHyps( MainHyp, hypList );
215 aTab->setAvailableHyps( AddHyp, hypList );
216 aTab->setExistingHyps( MainHyp, hypList );
217 aTab->setExistingHyps( AddHyp, hypList );
218 myExistingHyps[ i ][ MainHyp ].clear();
219 myExistingHyps[ i ][ AddHyp ].clear();
221 availableHyps( i, Algo, hypList, myAvailableHypData[i][Algo] );
222 aTab->setAvailableHyps( Algo, hypList );
227 myDlg->activateObject( myIsMesh ? SMESHGUI_MeshDlg::Geom : SMESHGUI_MeshDlg::Mesh );
230 myDlg->activateObject( SMESHGUI_MeshDlg::Obj );
232 myDlg->setHypoSets( SMESH::GetHypothesesSets() );
234 myDlg->setCurrentTab( SMESH::DIM_3D );
239 myIgnoreAlgoSelection = false;
242 //================================================================================
244 * \brief Creates selection filter
245 * \param theId - identifier of current selection widget
246 * \retval SUIT_SelectionFilter* - pointer to the created filter or null
248 * Creates selection filter in accordance with identifier of current selection widget
250 //================================================================================
251 SUIT_SelectionFilter* SMESHGUI_MeshOp::createFilter( const int theId ) const
253 if ( theId == SMESHGUI_MeshDlg::Geom )
255 // TColStd_MapOfInteger allTypesMap;
256 // for ( int i = 0; i < 10; i++ )
257 // allTypesMap.Add( i );
258 // return new SMESH_NumberFilter( "GEOM", TopAbs_SHAPE, 0, allTypesMap );
259 return new GEOM_SelectionFilter( (SalomeApp_Study*)study(), true );
261 else if ( theId == SMESHGUI_MeshDlg::Obj && !myToCreate )
262 return new SMESH_TypeFilter( MESHorSUBMESH );
263 else if ( theId == SMESHGUI_MeshDlg::Mesh )
264 return new SMESH_TypeFilter( MESH );
269 //================================================================================
271 * \brief check if selected shape is a subshape of the shape to mesh
272 * \retval bool - check result
274 //================================================================================
276 bool SMESHGUI_MeshOp::isSubshapeOk() const
278 if ( !myToCreate || myIsMesh ) // not submesh creation
282 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
283 _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
284 if (!pMesh) return false;
286 SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
287 if (mesh->_is_nil()) return false;
289 // main shape of the mesh
290 GEOM::GEOM_Object_var mainGeom = mesh->GetShapeToMesh();
291 if (mainGeom->_is_nil()) return false;
295 myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
297 if (aGEOMs.count() > 0) {
298 GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
299 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
300 if (geomGen->_is_nil() || !aStudy) return false;
302 GEOM::GEOM_IGroupOperations_var op =
303 geomGen->GetIGroupOperations(aStudy->StudyId());
304 if (op->_is_nil()) return false;
306 // check all selected shapes
307 QStringList::const_iterator aSubShapesIter = aGEOMs.begin();
308 for ( ; aSubShapesIter != aGEOMs.end(); aSubShapesIter++) {
309 QString aSubGeomEntry = (*aSubShapesIter);
310 _PTR(SObject) pSubGeom = studyDS()->FindObjectID(aSubGeomEntry.toLatin1().data());
311 if (!pSubGeom) return false;
313 GEOM::GEOM_Object_var aSubGeomVar =
314 GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
315 if (aSubGeomVar->_is_nil()) return false;
317 // skl for NPAL14695 - implementation of searching of mainObj
318 GEOM::GEOM_Object_var mainObj = op->GetMainShape(aSubGeomVar);
319 //if (mainObj->_is_nil() ||
320 // string(mainObj->GetEntry()) != string(mainGeom->GetEntry())) return false;
322 if (mainObj->_is_nil())
324 if (std::string(mainObj->GetEntry()) == std::string(mainGeom->GetEntry()))
326 mainObj = op->GetMainShape(mainObj);
335 //================================================================================
337 * \brief find an existing submesh by the selected shape
338 * \retval _PTR(SObject) - the found submesh SObject
340 //================================================================================
342 _PTR(SObject) SMESHGUI_MeshOp::getSubmeshByGeom() const
344 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
345 QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
346 _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
347 _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.toLatin1().data() );
348 if ( pMesh && pGeom ) {
349 GEOM::GEOM_Object_var geom = SMESH::SObjectToInterface<GEOM::GEOM_Object>( pGeom );
350 if ( !geom->_is_nil() ) {
352 switch ( geom->GetShapeType() ) {
353 case GEOM::VERTEX: tag = SMESH::Tag_SubMeshOnVertex; break;
354 case GEOM::EDGE: tag = SMESH::Tag_SubMeshOnEdge; break;
355 case GEOM::WIRE: tag = SMESH::Tag_SubMeshOnWire; break;
356 case GEOM::FACE: tag = SMESH::Tag_SubMeshOnFace; break;
357 case GEOM::SHELL: tag = SMESH::Tag_SubMeshOnShell; break;
358 case GEOM::SOLID: tag = SMESH::Tag_SubMeshOnSolid; break;
359 case GEOM::COMPOUND: tag = SMESH::Tag_SubMeshOnCompound; break;
362 _PTR(GenericAttribute) anAttr;
363 _PTR(SObject) aSubmeshRoot;
364 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
365 if ( pMesh->FindSubObject( tag, aSubmeshRoot ) )
367 _PTR(ChildIterator) smIter = aStudy->NewChildIterator( aSubmeshRoot );
368 for ( ; smIter->More(); smIter->Next() )
370 _PTR(SObject) aSmObj = smIter->Value();
371 if ( ! aSmObj->FindAttribute( anAttr, "AttributeIOR" ))
373 _PTR(ChildIterator) anIter1 = aStudy->NewChildIterator(aSmObj);
374 for ( ; anIter1->More(); anIter1->Next()) {
375 _PTR(SObject) pGeom2 = anIter1->Value();
376 if ( pGeom2->ReferencedObject( pGeom2 ) &&
377 pGeom2->GetID() == pGeom->GetID() )
384 return _PTR(SObject)();
387 //================================================================================
389 * \brief Updates dialog's look and feel
391 * Virtual method redefined from the base class updates dialog's look and feel
393 //================================================================================
394 void SMESHGUI_MeshOp::selectionDone()
396 if (!dlg()->isVisible() || !myDlg->isEnabled())
399 SMESHGUI_SelectionOp::selectionDone();
403 myIsOnGeometry = true;
405 //Check geometry for mesh
406 QString anObjEntry = myDlg->selectedObject(SMESHGUI_MeshDlg::Obj);
407 _PTR(SObject) pObj = studyDS()->FindObjectID(anObjEntry.toLatin1().data());
410 SMESH::SMESH_Mesh_var aMeshVar =
411 SMESH::SMESH_Mesh::_narrow(_CAST(SObject,pObj)->GetObject());
412 if (!aMeshVar->_is_nil()) {
413 if (!myToCreate && !aMeshVar->HasShapeToMesh())
414 myIsOnGeometry = false;
420 // Enable tabs according to shape dimension
425 myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
426 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
428 if (aGEOMs.count() > 0) {
429 // one or more GEOM shape selected
430 aSeq->length(aGEOMs.count());
431 QStringList::const_iterator aSubShapesIter = aGEOMs.begin();
433 for ( ; aSubShapesIter != aGEOMs.end(); aSubShapesIter++, iSubSh++) {
434 QString aSubGeomEntry = (*aSubShapesIter);
435 _PTR(SObject) pSubGeom = studyDS()->FindObjectID(aSubGeomEntry.toLatin1().data());
436 GEOM::GEOM_Object_var aSubGeomVar =
437 GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
438 aSeq[iSubSh] = aSubGeomVar;
441 // get geometry by selected sub-mesh
442 QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
443 _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
444 GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
445 if (!aGeomVar->_is_nil()) {
451 if (aSeq->length() > 0) {
453 for (int iss = 0; iss < aSeq->length() && shapeDim < 3; iss++) {
454 GEOM::GEOM_Object_var aGeomVar = aSeq[iss];
455 switch ( aGeomVar->GetShapeType() ) {
457 case GEOM::SHELL: shapeDim = 3; break;
458 case GEOM::FACE: shapeDim = (shapeDim < 2) ? 2 : shapeDim; break;
460 case GEOM::EDGE: shapeDim = (shapeDim < 1) ? 1 : shapeDim; break;
461 case GEOM::VERTEX: break;
464 if ( GEOMBase::GetShape(aGeomVar, aShape)) {
465 TopExp_Explorer exp( aShape, TopAbs_SHELL );
468 else if ( exp.Init( aShape, TopAbs_FACE ), exp.More() )
469 shapeDim = (shapeDim < 2) ? 2 : shapeDim;
470 else if ( exp.Init( aShape, TopAbs_EDGE ), exp.More() )
471 shapeDim = (shapeDim < 1) ? 1 : shapeDim;
478 myDlg->setMaxHypoDim( shapeDim );
481 if (!myToCreate) // edition: read hypotheses
485 SMESH::SMESH_subMesh_var aVar =
486 SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
487 myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, !aVar->_is_nil() );
488 myDlg->setObjectShown( SMESHGUI_MeshDlg::Geom, true );
489 myDlg->objectWg( SMESHGUI_MeshDlg::Mesh, SMESHGUI_MeshDlg::Btn )->hide();
490 myDlg->objectWg( SMESHGUI_MeshDlg::Geom, SMESHGUI_MeshDlg::Btn )->hide();
491 myDlg->updateGeometry();
498 else if ( !myIsMesh ) // submesh creation
500 // if a submesh on the selected shape already exist, pass to submesh edition mode
501 if ( _PTR(SObject) pSubmesh = getSubmeshByGeom() ) {
502 SMESH::SMESH_subMesh_var sm =
503 SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( pSubmesh );
504 bool editSubmesh = ( !sm->_is_nil() &&
505 SUIT_MessageBox::question( myDlg, tr( "SMESH_WARNING" ),
506 tr( "EDIT_SUBMESH_QUESTION"),
507 SUIT_MessageBox::Yes |
509 SUIT_MessageBox::No )
510 == SUIT_MessageBox::Yes );
513 selectionMgr()->clearFilters();
514 selectObject( pSubmesh );
515 SMESHGUI::GetSMESHGUI()->switchToOperation(704);
520 myDlg->selectObject( "", SMESHGUI_MeshDlg::Geom, "" );
521 selectObject( _PTR(SObject)() );
526 // enable/disable popup for choice of geom selection way
528 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
529 if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() )) {
530 SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
531 if ( !mesh->_is_nil() )
532 enable = ( shapeDim > 1 ) && ( mesh->NbEdges() > 0 );
534 myDlg->setGeomPopupEnabled( enable );
538 myDlg->enableTab( SMESH::DIM_3D );
540 availableHyps( SMESH::DIM_3D, Algo, hypList,
541 myAvailableHypData[SMESH::DIM_3D][Algo]);
543 SMESHGUI_MeshTab* aTab = myDlg->tab( SMESH::DIM_3D );
544 aTab->setAvailableHyps( Algo, hypList );
545 for (int i = SMESH::DIM_0D;i < SMESH::DIM_3D; ++i) {
546 myDlg->disableTab(i);
548 //Hide labels and fields (Mesh ang Geometry)
549 myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, false );
550 myDlg->setObjectShown( SMESHGUI_MeshDlg::Geom, false );
555 catch ( const SALOME::SALOME_Exception& S_ex )
557 SalomeApp_Tools::QtCatchCorbaException( S_ex );
564 //================================================================================
566 * \brief Verifies validity of input data
567 * \param theMess - Output parameter intended for returning error message
568 * \retval bool - TRUE if input data is valid, false otherwise
570 * Verifies validity of input data. This method is called when "Apply" or "OK" button
571 * is pressed before mesh creation or editing.
573 //================================================================================
574 bool SMESHGUI_MeshOp::isValid( QString& theMess ) const
576 // Selected object to be edited
577 if ( !myToCreate && myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ) == "" )
579 theMess = tr( "THERE_IS_NO_OBJECT_FOR_EDITING" );
584 QString aMeshName = myDlg->objectText( SMESHGUI_MeshDlg::Obj ).trimmed();
585 if ( aMeshName.isEmpty() )
587 theMess = myIsMesh ? tr( "NAME_OF_MESH_IS_EMPTY" ) : tr( "NAME_OF_SUBMESH_IS_EMPTY" );
591 /* // Imported mesh, if create sub-mesh or edit mesh
592 if ( !myToCreate || ( myToCreate && !myIsMesh ))
594 QString aMeshEntry = myDlg->selectedObject
595 ( myToCreate ? SMESHGUI_MeshDlg::Mesh : SMESHGUI_MeshDlg::Obj );
596 if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() )) {
597 SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
598 if ( !mesh->_is_nil() && CORBA::is_nil( mesh->GetShapeToMesh() )) {
599 theMess = tr( "IMPORTED_MESH" );
608 QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
609 if ( aGeomEntry == "" )
611 theMess = tr( "GEOMETRY_OBJECT_IS_NOT_DEFINED" );
614 _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.toLatin1().data() );
615 if ( !pGeom || GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() )->_is_nil() )
617 theMess = tr( "GEOMETRY_OBJECT_IS_NULL" );
622 if ( !myIsMesh ) // i.e sub-mesh creation,
624 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
625 if ( aMeshEntry == "" )
627 theMess = tr( "MESH_IS_NOT_DEFINED" );
630 _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
631 if ( !pMesh || SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() )->_is_nil() )
633 theMess = tr( "MESH_IS_NULL" );
636 if ( !isSubshapeOk() )
638 theMess = tr( "INVALID_SUBSHAPE" );
647 //================================================================================
649 * \brief check compatibility of the algorithm and another algorithm or hypothesis
650 * \param theAlgoData - algorithm data
651 * \param theHypData - hypothesis data
652 * \param theHypType - hypothesis type
653 * \param theHypTypeName - hypothesis type name, must be provided if 2-nd arg is not algo
654 * \retval bool - check result
656 //================================================================================
658 static bool isCompatible(const HypothesisData* theAlgoData,
659 const HypothesisData* theHypData,
660 const int theHypType)
665 if ( theHypType == SMESHGUI_MeshOp::Algo )
666 return SMESH::IsCompatibleAlgorithm( theAlgoData, theHypData );
669 return ( SMESH::IsAvailableHypothesis( theAlgoData, theHypData->TypeName, isOptional ));
672 //================================================================================
674 * \brief Gets available hypotheses or algorithms
675 * \param theDim - specifies dimension of returned hypotheses/algorifms
676 * \param theHypType - specifies whether algorims or hypotheses or additional ones
677 * are retrieved (possible values are in HypType enumeration)
678 * \param theHyps - Output list of hypotheses' names
679 * \param theAlgoData - to select hypos able to be used by this algo (optional)
681 * Gets available hypotheses or algorithm in accordance with input parameters
683 //================================================================================
684 void SMESHGUI_MeshOp::availableHyps( const int theDim,
685 const int theHypType,
686 QStringList& theHyps,
687 THypDataList& theDataList,
688 HypothesisData* theAlgoData ) const
692 bool isAlgo = ( theHypType == Algo );
693 bool isAux = ( theHypType == AddHyp );
694 QStringList aHypTypeNameList = SMESH::GetAvailableHypotheses( isAlgo, theDim, isAux, myIsOnGeometry );
696 QStringList::const_iterator anIter;
697 for ( anIter = aHypTypeNameList.begin(); anIter != aHypTypeNameList.end(); ++anIter )
699 HypothesisData* aData = SMESH::GetHypothesisData( *anIter );
700 if ( isCompatible ( theAlgoData, aData, theHypType )) {
701 theDataList.append( aData );
702 theHyps.append( aData->Label );
707 //================================================================================
709 * \brief Gets existing hypotheses or algorithms
710 * \param theDim - specifies dimension of returned hypotheses/algorifms
711 * \param theHypType - specifies whether algorims or hypotheses or additional ones
712 * are retrieved (possible values are in HypType enumeration)
713 * \param theFather - start object for finding ( may be component, mesh, or sub-mesh )
714 * \param theHyps - output list of names.
715 * \param theHypVars - output list of variables.
716 * \param theAlgoData - to select hypos able to be used by this algo (optional)
718 * Gets existing (i.e. already created) hypotheses or algorithm in accordance with
721 //================================================================================
722 void SMESHGUI_MeshOp::existingHyps( const int theDim,
723 const int theHypType,
724 _PTR(SObject) theFather,
725 QStringList& theHyps,
726 THypList& theHypList,
727 HypothesisData* theAlgoData)
729 // Clear hypoheses list
736 const bool isAux = ( theHypType == AddHyp );
738 _PTR(SObject) aHypRoot;
739 _PTR(GenericAttribute) anAttr;
740 _PTR(AttributeName) aName;
741 _PTR(AttributeIOR) anIOR;
743 bool isMesh = !_CAST( SComponent, theFather );
746 aPart = theHypType == Algo ? SMESH::Tag_RefOnAppliedAlgorithms : SMESH::Tag_RefOnAppliedHypothesis;
748 aPart = theHypType == Algo ? SMESH::Tag_AlgorithmsRoot : SMESH::Tag_HypothesisRoot;
750 if ( theFather->FindSubObject( aPart, aHypRoot ) )
752 _PTR(ChildIterator) anIter =
753 SMESH::GetActiveStudyDocument()->NewChildIterator( aHypRoot );
754 for ( ; anIter->More(); anIter->Next() )
756 _PTR(SObject) anObj = anIter->Value();
757 if ( isMesh ) // i.e. mesh or submesh
759 _PTR(SObject) aRefObj;
760 if ( anObj->ReferencedObject( aRefObj ) )
765 if ( anObj->FindAttribute( anAttr, "AttributeName" ) )
768 CORBA::Object_var aVar = _CAST(SObject,anObj)->GetObject();
769 if ( !CORBA::is_nil( aVar ) )
771 SMESH::SMESH_Hypothesis_var aHypVar = SMESH::SMESH_Hypothesis::_narrow( aVar );
772 if ( !aHypVar->_is_nil() )
774 HypothesisData* aData = SMESH::GetHypothesisData( aHypVar->GetName() );
775 if ( ( theDim == -1 || aData->Dim.contains( theDim ) ) &&
776 ( isCompatible ( theAlgoData, aData, theHypType )) &&
777 ( isAux == aData->IsAux ))
779 std::string aHypName = aName->Value();
780 theHyps.append( aHypName.c_str() );
781 theHypList.append( THypItem( aHypVar, aHypName.c_str() ) );
790 //================================================================================
792 * \brief If create or edit a submesh, return a hypothesis holding parameters used
794 * \param aHypType - The hypothesis type name
795 * \param aServerLib - Server library name
796 * \param hypData - The structure holding the hypothesis type etc.
797 * \retval SMESH::SMESH_Hypothesis_var - the hypothesis holding parameter values
799 //================================================================================
801 SMESH::SMESH_Hypothesis_var
802 SMESHGUI_MeshOp::getInitParamsHypothesis( const QString& aHypType,
803 const QString& aServerLib ) const
805 if ( aHypType.isEmpty() || aServerLib.isEmpty() )
806 return SMESH::SMESH_Hypothesis::_nil();
808 const int nbColonsInMeshEntry = 3;
809 bool isSubMesh = myToCreate ?
811 myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ).count(':') > nbColonsInMeshEntry;
815 // get mesh and geom object
816 SMESH::SMESH_Mesh_var aMeshVar = SMESH::SMESH_Mesh::_nil();
817 GEOM::GEOM_Object_var aGeomVar = GEOM::GEOM_Object::_nil();
819 QString anEntry = myDlg->selectedObject
820 ( myToCreate ? SMESHGUI_MeshDlg::Mesh : SMESHGUI_MeshDlg::Obj );
821 if ( _PTR(SObject) pObj = studyDS()->FindObjectID( anEntry.toLatin1().data() ))
823 CORBA::Object_ptr Obj = _CAST( SObject,pObj )->GetObject();
824 if ( myToCreate ) // mesh and geom may be selected
826 aMeshVar = SMESH::SMESH_Mesh::_narrow( Obj );
827 anEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
828 if ( _PTR(SObject) pGeom = studyDS()->FindObjectID( anEntry.toLatin1().data() ))
829 aGeomVar= GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
831 else // edition: sub-mesh may be selected
833 SMESH::SMESH_subMesh_var sm = SMESH::SMESH_subMesh::_narrow( Obj );
834 if ( !sm->_is_nil() ) {
835 aMeshVar = sm->GetFather();
836 aGeomVar = sm->GetSubShape();
841 if ( !aMeshVar->_is_nil() && !aGeomVar->_is_nil() )
842 return SMESHGUI::GetSMESHGen()->GetHypothesisParameterValues( aHypType.toLatin1().data(),
843 aServerLib.toLatin1().data(),
847 return SMESH::SMESH_Hypothesis::_nil();
850 //================================================================================
852 * \Brief Returns tab dimention
853 * \param tab - the tab in the dlg
854 * \param dlg - my dialogue
855 * \retval int - dimention
857 //================================================================================
859 static int getTabDim (const QObject* tab, SMESHGUI_MeshDlg* dlg )
862 for (int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++)
863 if (tab == dlg->tab(i))
868 //================================================================================
870 * \brief Create hypothesis
871 * \param theHypType - hypothesis category (main or additional)
872 * \param theIndex - index of type of hypothesis to be cerated
874 * Specifies dimension of hypothesis to be created (using sender() method),
875 * specifies its type and calls method for hypothesis creation
877 //================================================================================
878 void SMESHGUI_MeshOp::onCreateHyp( const int theHypType, const int theIndex )
880 // Specifies dimension of hypothesis to be created
881 int aDim = getTabDim( sender(), myDlg );
885 // Specifies type of hypothesis to be created
886 THypDataList& dataList = myAvailableHypData[ aDim ][ theHypType ];
887 if (theIndex < 0 || theIndex >= dataList.count())
889 QString aHypTypeName = dataList[ theIndex ]->TypeName;
892 createHypothesis(aDim, theHypType, aHypTypeName);
895 //================================================================================
897 * Create hypothesis and update dialog.
898 * \param theDim - dimension of hypothesis to be created
899 * \param theType - hypothesis category (algorithm, hypothesis, additional hypothesis)
900 * \param theTypeName - specifies hypothesis to be created
902 //================================================================================
905 QString GetUniqueName (const QStringList& theHypNames,
906 const QString& theName,
907 size_t theIteration = 1)
909 QString aName = theName + "_" + QString::number( theIteration );
910 if ( theHypNames.contains( aName ) )
911 return GetUniqueName( theHypNames, theName, ++theIteration );
916 void SMESHGUI_MeshOp::createHypothesis (const int theDim,
918 const QString& theTypeName)
920 // During a hypothesis creation we might need to select some objects.
921 // Main dialog must not update it's own selected objects in this case.
922 dlg()->deactivateAll();
924 HypothesisData* aData = SMESH::GetHypothesisData(theTypeName);
928 QStringList aHypNames;
929 TDim2Type2HypList::const_iterator aDimIter = myExistingHyps.begin();
930 for ( ; aDimIter != myExistingHyps.end(); aDimIter++) {
931 const TType2HypList& aType2HypList = aDimIter.value();
932 TType2HypList::const_iterator aTypeIter = aType2HypList.begin();
933 for ( ; aTypeIter != aType2HypList.end(); aTypeIter++) {
934 const THypList& aHypList = aTypeIter.value();
935 THypList::const_iterator anIter = aHypList.begin();
936 for ( ; anIter != aHypList.end(); anIter++) {
937 const THypItem& aHypItem = *anIter;
938 const QString& aHypName = aHypItem.second;
939 aHypNames.append(aHypName);
943 QString aHypName = GetUniqueName( aHypNames, aData->Label);
946 int nbHyp = myExistingHyps[theDim][theType].count();
948 QString aClientLibName = aData->ClientLibName;
949 if (aClientLibName == "") {
950 // Call hypothesis creation server method (without GUI)
951 SMESH::CreateHypothesis(theTypeName, aHypName, false);
953 // Get hypotheses creator client (GUI)
954 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(theTypeName);
958 // When create or edit a submesh, try to initialize a new hypothesis
959 // with values used to mesh a subshape
960 SMESH::SMESH_Hypothesis_var initParamHyp =
961 getInitParamsHypothesis(theTypeName, aData->ServerLibName);
962 myDlg->setEnabled( false );
963 aCreator->create(initParamHyp, aHypName, myDlg);
964 myDlg->setEnabled( true );
966 SMESH::CreateHypothesis(theTypeName, aHypName, false);
970 _PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
972 HypothesisData* algoData = hypData( theDim, Algo, currentHyp( theDim, Algo ));
973 QStringList aNewHyps;
974 existingHyps(theDim, theType, aFather, aNewHyps, myExistingHyps[theDim][theType], algoData);
975 if (aNewHyps.count() > nbHyp) {
976 for (int i = nbHyp; i < aNewHyps.count(); i++)
977 myDlg->tab(theDim)->addHyp(theType, aNewHyps[i]);
981 //================================================================================
983 * \brief Calls plugin methods for hypothesis editing
984 * \param theHypType - specifies whether main hypothesis or additional one
986 * \param theIndex - index of existing hypothesis
988 * Calls plugin methods for hypothesis editing
990 //================================================================================
991 void SMESHGUI_MeshOp::onEditHyp( const int theHypType, const int theIndex )
993 // Speicfies dimension of hypothesis to be created
994 int aDim = getTabDim( sender(), myDlg );
998 const THypList& aList = myExistingHyps[ aDim ][ theHypType ];
999 if ( theIndex < 0 || theIndex >= aList.count() )
1001 const THypItem& aHypItem = aList[ theIndex ];
1002 SMESH::SMESH_Hypothesis_var aHyp = aHypItem.first;
1003 if ( aHyp->_is_nil() )
1006 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator( aHyp->GetName() );
1008 myDlg->setEnabled( false );
1009 aCreator->edit( aHyp.in(), aHypItem.second, dlg() );
1010 myDlg->setEnabled( true );
1014 //================================================================================
1016 * \brief access to hypothesis data
1017 * \param theDim - hyp dimension
1018 * \param theHypType - hyp type (Algo,MainHyp or AddHyp)
1019 * \param theIndex - index in the list
1020 * \retval HypothesisData* - result data, may be 0
1022 //================================================================================
1024 HypothesisData* SMESHGUI_MeshOp::hypData( const int theDim,
1025 const int theHypType,
1028 if ( theDim > -1 && theDim <= SMESH::DIM_3D &&
1029 theHypType > -1 && theHypType < NbHypTypes &&
1030 theIndex > -1 && theIndex < myAvailableHypData[ theDim ][ theHypType ].count() )
1031 return myAvailableHypData[ theDim ][ theHypType ][ theIndex ];
1035 //================================================================================
1037 * \brief Set available algos and hypos according to the selected algorithm
1038 * \param theIndex - algorithm index
1040 //================================================================================
1042 void SMESHGUI_MeshOp::onAlgoSelected( const int theIndex,
1045 if ( myIgnoreAlgoSelection )
1048 int aDim = theDim < 0 ? getTabDim( sender(), myDlg ): theDim;
1052 // find highest available dimension, all algos of this dimension are available for choice
1054 for (int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++)
1055 if (isAccessibleDim( i ))
1060 const bool isSubmesh = ( myToCreate ? !myIsMesh : myDlg->isObjectShown( SMESHGUI_MeshDlg::Mesh ));
1062 HypothesisData* algoData = hypData( aDim, Algo, theIndex );
1063 HypothesisData* algoByDim[4];
1064 algoByDim[ aDim ] = algoData;
1066 QStringList anAvailable;
1067 if ( !algoData ) { // all algos becomes available
1068 availableHyps( aDim, Algo, anAvailable, myAvailableHypData[ aDim ][ Algo ]);
1069 myDlg->tab( aDim )->setAvailableHyps( Algo, anAvailable );
1072 // check that algorithms of other dimentions are compatible with
1075 // 2 loops: backward and forward from algo dimension
1076 for ( int forward = false; forward <= true; ++forward )
1078 int dim = aDim + 1, lastDim = SMESH::DIM_3D, dir = 1;
1080 dim = aDim - 1; lastDim = SMESH::DIM_0D; dir = -1;
1082 HypothesisData* prevAlgo = algoData;
1083 bool noCompatible = false;
1084 for ( ; dim * dir <= lastDim * dir; dim += dir)
1086 if ( !isAccessibleDim( dim ))
1088 if ( noCompatible ) { // the selected algo has no compatible ones
1089 anAvailable.clear();
1090 myDlg->tab( dim )->setAvailableHyps( Algo, anAvailable );
1091 myAvailableHypData[dim][Algo].clear();
1092 algoByDim[ dim ] = 0;
1095 // get currently selected algo
1096 int algoIndex = currentHyp( dim, Algo );
1097 HypothesisData* curAlgo = hypData( dim, Algo, algoIndex );
1098 if ( curAlgo ) { // some algo selected
1099 if ( !isCompatible( prevAlgo, curAlgo, Algo ))
1102 // set new available algoritms
1103 availableHyps( dim, Algo, anAvailable, myAvailableHypData[dim][Algo], prevAlgo );
1104 HypothesisData* soleCompatible = 0;
1105 if ( anAvailable.count() == 1 )
1106 soleCompatible = myAvailableHypData[dim][Algo][0];
1107 if ( dim == aTopDim && prevAlgo ) // all available algoritms should be selectable any way
1108 availableHyps( dim, Algo, anAvailable, myAvailableHypData[dim][Algo], 0 );
1109 myDlg->tab( dim )->setAvailableHyps( Algo, anAvailable );
1110 noCompatible = anAvailable.isEmpty();
1112 // restore previously selected algo
1113 algoIndex = myAvailableHypData[dim][Algo].indexOf( curAlgo );
1114 if ( !isSubmesh && algoIndex < 0 && soleCompatible && !forward && dim != SMESH::DIM_0D)
1115 // select the sole compatible algo
1116 algoIndex = myAvailableHypData[dim][Algo].indexOf( soleCompatible );
1117 setCurrentHyp( dim, Algo, algoIndex );
1119 // remember current algo
1120 prevAlgo = algoByDim[ dim ] = hypData( dim, Algo, algoIndex );
1124 // set hypotheses corresponding to the found algoritms
1126 _PTR(SObject) pObj = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
1128 for ( int dim = SMESH::DIM_0D; dim <= SMESH::DIM_3D; dim++ )
1130 if ( !isAccessibleDim( dim ))
1132 for ( int type = MainHyp; type < NbHypTypes; type++ )
1134 myAvailableHypData[ dim ][ type ].clear();
1135 QStringList anAvailable, anExisting;
1137 HypothesisData* curAlgo = algoByDim[ dim ];
1138 int hypIndex = currentHyp( dim, type );
1140 SMESH::SMESH_Hypothesis_var curHyp;
1141 if ( hypIndex >= 0 && hypIndex < myExistingHyps[ dim ][ type ].count() )
1142 curHyp = myExistingHyps[ dim ][ type ][ hypIndex ].first;
1144 if ( !myToCreate && !curAlgo && !curHyp->_is_nil() ) { // edition, algo not selected
1145 // try to find algo by selected hypothesis in order to keep it selected
1146 bool algoDeselectedByUser = ( theDim < 0 && aDim == dim );
1147 CORBA::String_var curHypType = curHyp->GetName();
1148 if ( !algoDeselectedByUser &&
1149 myObjHyps[ dim ][ type ].count() > 0 &&
1150 curHypType == myObjHyps[ dim ][ type ].first().first->GetName())
1152 HypothesisData* hypData = SMESH::GetHypothesisData( curHyp->GetName() );
1153 for (int i = 0; i < myAvailableHypData[ dim ][ Algo ].count(); ++i) {
1154 curAlgo = myAvailableHypData[ dim ][ Algo ][ i ];
1155 if (curAlgo && hypData && isCompatible(curAlgo, hypData, type))
1162 // get hyps compatible with curAlgo
1165 // check if a selected hyp is compatible with the curAlgo
1166 if ( !curHyp->_is_nil() ) {
1167 HypothesisData* hypData = SMESH::GetHypothesisData( curHyp->GetName() );
1168 if ( !isCompatible( curAlgo, hypData, type ))
1169 curHyp = SMESH::SMESH_Hypothesis::_nil();
1171 existingHyps( dim, type, pObj, anExisting, myExistingHyps[ dim ][ type ], curAlgo);
1172 availableHyps( dim, type, anAvailable, myAvailableHypData[ dim ][ type ], curAlgo);
1174 // set list of hypotheses
1175 myDlg->tab( dim )->setAvailableHyps( type, anAvailable );
1176 myDlg->tab( dim )->setExistingHyps( type, anExisting );
1178 // set current existing hypothesis
1179 if ( !curHyp->_is_nil() && !anExisting.isEmpty() )
1180 hypIndex = this->find( curHyp, myExistingHyps[ dim ][ type ]);
1183 if ( !isSubmesh && hypIndex < 0 && anExisting.count() == 1 ) {
1184 // none is yet selected => select the sole existing if it is not optional
1185 CORBA::String_var hypTypeName = myExistingHyps[ dim ][ type ].first().first->GetName();
1186 bool isOptional = true;
1187 if ( algoByDim[ dim ] &&
1188 SMESH::IsAvailableHypothesis( algoByDim[ dim ], hypTypeName.in(), isOptional ) &&
1192 setCurrentHyp( dim, type, hypIndex );
1197 //================================================================================
1199 * \brief Creates and selects hypothesis of hypotheses set
1200 * \param theSetName - The name of hypotheses set
1202 //================================================================================
1203 void SMESHGUI_MeshOp::onHypoSet( const QString& theSetName )
1205 HypothesesSet* aHypoSet = SMESH::GetHypothesesSet(theSetName);
1206 if (!aHypoSet) return;
1209 for (int dim = SMESH::DIM_0D; dim <= SMESH::DIM_3D; dim++) {
1210 setCurrentHyp(dim, Algo, -1);
1211 setCurrentHyp(dim, AddHyp, -1);
1212 setCurrentHyp(dim, MainHyp, -1);
1215 for (int aHypType = Algo; aHypType < AddHyp; aHypType++) {
1216 bool isAlgo = (aHypType == Algo);
1218 // set hyps from the set
1219 QStringList* aHypoList = isAlgo ? &aHypoSet->AlgoList : &aHypoSet->HypoList;
1220 for (int i = 0, n = aHypoList->count(); i < n; i++) {
1221 const QString& aHypoTypeName = (*aHypoList)[ i ];
1222 HypothesisData* aHypData = SMESH::GetHypothesisData(aHypoTypeName);
1226 int aDim = aHypData->Dim[0];
1227 // create or/and set
1229 int index = myAvailableHypData[aDim][Algo].indexOf( aHypData );
1231 QStringList anAvailable;
1232 availableHyps( aDim, Algo, anAvailable, myAvailableHypData[aDim][Algo] );
1233 myDlg->tab( aDim )->setAvailableHyps( Algo, anAvailable );
1234 index = myAvailableHypData[aDim][Algo].indexOf( aHypData );
1236 setCurrentHyp( aDim, Algo, index );
1237 onAlgoSelected( index, aDim );
1240 bool mainHyp = true;
1241 QStringList anAvailable;
1242 availableHyps( aDim, MainHyp, anAvailable, myAvailableHypData[aDim][MainHyp] );
1243 myDlg->tab( aDim )->setAvailableHyps( MainHyp, anAvailable );
1244 int index = myAvailableHypData[aDim][MainHyp].indexOf( aHypData );
1247 index = myAvailableHypData[aDim][AddHyp].indexOf( aHypData );
1250 createHypothesis(aDim, mainHyp ? MainHyp : AddHyp, aHypoTypeName);
1252 } // loop on hypos in the set
1253 } // loop on algo/hypo
1256 //================================================================================
1258 * \brief Creates mesh
1259 * \param theMess - Output parameter intended for returning error message
1260 * \retval bool - TRUE if mesh is created, FALSE otherwise
1264 //================================================================================
1265 bool SMESHGUI_MeshOp::createMesh( QString& theMess )
1269 //QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
1270 //QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
1273 myDlg->selectedObject( SMESHGUI_MeshDlg::Geom, aList );
1274 QStringList::Iterator it = aList.begin();
1275 for ( ; it!=aList.end(); it++)
1277 QString aGeomEntry = *it;
1278 _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.toLatin1().data() );
1279 GEOM::GEOM_Object_var aGeomVar =
1280 GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
1282 SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
1283 if ( aSMESHGen->_is_nil() )
1286 SUIT_OverrideCursor aWaitCursor;
1289 SMESH::SMESH_Mesh_var aMeshVar = aSMESHGen->CreateMesh( aGeomVar );
1290 if ( aMeshVar->_is_nil() )
1292 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar.in() );
1294 SMESH::SetName( aMeshSO, myDlg->objectText( SMESHGUI_MeshDlg::Obj ) );
1296 for ( int aDim = SMESH::DIM_0D; aDim <= SMESH::DIM_3D; aDim++ ) {
1297 if ( !isAccessibleDim( aDim )) continue;
1299 // assign hypotheses
1300 for ( int aHypType = MainHyp; aHypType <= AddHyp; aHypType++ ) {
1301 int aHypIndex = currentHyp( aDim, aHypType );
1302 if ( aHypIndex >= 0 && aHypIndex < myExistingHyps[ aDim ][ aHypType ].count() ) {
1303 SMESH::SMESH_Hypothesis_var aHypVar = myExistingHyps[ aDim ][ aHypType ][ aHypIndex ].first;
1304 if ( !aHypVar->_is_nil() )
1305 SMESH::AddHypothesisOnMesh( aMeshVar, aHypVar );
1308 // find or create algorithm
1309 SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( aDim );
1310 if ( !anAlgoVar->_is_nil() )
1311 SMESH::AddHypothesisOnMesh( aMeshVar, anAlgoVar );
1318 //================================================================================
1320 * \brief Creates sub-mesh
1321 * \param theMess - Output parameter intended for returning error message
1322 * \retval bool - TRUE if sub-mesh is created, FALSE otherwise
1326 //================================================================================
1327 bool SMESHGUI_MeshOp::createSubMesh( QString& theMess )
1331 SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
1332 if ( aSMESHGen->_is_nil() )
1336 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
1337 _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
1338 SMESH::SMESH_Mesh_var aMeshVar =
1339 SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() );
1340 if (aMeshVar->_is_nil())
1343 // GEOM shape of the main mesh
1344 GEOM::GEOM_Object_var mainGeom = aMeshVar->GetShapeToMesh();
1346 // Name for the new sub-mesh
1347 QString aName = myDlg->objectText(SMESHGUI_MeshDlg::Obj);
1350 GEOM::GEOM_Object_var aGeomVar;
1352 myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
1353 if (aGEOMs.count() == 1)
1355 //QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
1356 QString aGeomEntry = aGEOMs.first();
1357 _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.toLatin1().data() );
1358 aGeomVar = GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
1360 else if (aGEOMs.count() > 1)
1362 // create a GEOM group
1363 GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
1364 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1365 if (!geomGen->_is_nil() && aStudy) {
1366 GEOM::GEOM_IGroupOperations_var op =
1367 geomGen->GetIGroupOperations(aStudy->StudyId());
1368 if (!op->_is_nil()) {
1369 // check and add all selected GEOM objects: they must be
1370 // a sub-shapes of the main GEOM and must be of one type
1372 TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE;
1373 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1374 aSeq->length(aGEOMs.count());
1375 QStringList::const_iterator aSubShapesIter = aGEOMs.begin();
1376 for ( ; aSubShapesIter != aGEOMs.end(); aSubShapesIter++, iSubSh++) {
1377 QString aSubGeomEntry = (*aSubShapesIter);
1378 _PTR(SObject) pSubGeom = studyDS()->FindObjectID(aSubGeomEntry.toLatin1().data());
1379 GEOM::GEOM_Object_var aSubGeomVar =
1380 GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
1381 TopAbs_ShapeEnum aSubShapeType = (TopAbs_ShapeEnum)aSubGeomVar->GetShapeType();
1383 aGroupType = aSubShapeType;
1385 if (aSubShapeType != aGroupType)
1386 aGroupType = TopAbs_SHAPE;
1388 aSeq[iSubSh] = aSubGeomVar;
1391 GEOM::GEOM_Object_var aGroupVar = op->CreateGroup(mainGeom, aGroupType);
1392 op->UnionList(aGroupVar, aSeq);
1395 aGeomVar = aGroupVar;
1397 // publish the GEOM group in study
1398 QString aNewGeomGroupName ("Auto_group_for_");
1399 aNewGeomGroupName += aName;
1400 SALOMEDS::SObject_var aNewGroupSO =
1401 geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGeomVar,
1402 aNewGeomGroupName.toLatin1().data(), mainGeom);
1409 if (aGeomVar->_is_nil())
1412 SUIT_OverrideCursor aWaitCursor;
1415 SMESH::SMESH_subMesh_var aSubMeshVar = aMeshVar->GetSubMesh( aGeomVar, aName.toLatin1().data() );
1417 for ( int aDim = SMESH::DIM_0D; aDim <= SMESH::DIM_3D; aDim++ )
1419 if ( !isAccessibleDim( aDim )) continue;
1421 // find or create algorithm
1422 SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( aDim );
1423 if ( !anAlgoVar->_is_nil() )
1424 SMESH::AddHypothesisOnSubMesh( aSubMeshVar, anAlgoVar );
1425 // assign hypotheses
1426 for ( int aHypType = MainHyp; aHypType <= AddHyp; aHypType++ )
1428 int aHypIndex = currentHyp( aDim, aHypType );
1429 if ( aHypIndex >= 0 && aHypIndex < myExistingHyps[ aDim ][ aHypType ].count() )
1431 SMESH::SMESH_Hypothesis_var aHypVar =
1432 myExistingHyps[ aDim ][ aHypType ][ aHypIndex ].first;
1433 if ( !aHypVar->_is_nil() )
1434 SMESH::AddHypothesisOnSubMesh( aSubMeshVar, aHypVar );
1439 // deselect geometry: next submesh should be created on other subshape
1440 myDlg->clearSelection( SMESHGUI_MeshDlg::Geom );
1441 selectObject( _PTR(SObject)() );
1447 //================================================================================
1449 * \brief Gets current hypothesis or algorithms
1450 * \param theDim - dimension of hypothesis or algorithm
1451 * \param theHypType - Type of hypothesis (Algo, MainHyp, AddHyp)
1452 * \retval int - current hypothesis or algorithms
1454 * Gets current hypothesis or algorithms
1456 //================================================================================
1457 int SMESHGUI_MeshOp::currentHyp( const int theDim, const int theHypType ) const
1459 return myDlg->tab( theDim )->currentHyp( theHypType ) - 1;
1462 //================================================================================
1464 * \brief Returns true if hypotheses of given dim can be assigned
1465 * \param theDim - hypotheses dimension
1466 * \retval bool - result
1468 //================================================================================
1469 bool SMESHGUI_MeshOp::isAccessibleDim( const int theDim ) const
1471 return myDlg->tab( theDim )->isEnabled();
1474 //================================================================================
1476 * \brief Sets current hypothesis or algorithms
1477 * \param theDim - dimension of hypothesis or algorithm
1478 * \param theHypType - Type of hypothesis (Algo, MainHyp, AddHyp)
1479 * \param theIndex - Index of hypothesis
1481 * Gets current hypothesis or algorithms
1483 //================================================================================
1484 void SMESHGUI_MeshOp::setCurrentHyp( const int theDim,
1485 const int theHypType,
1486 const int theIndex )
1488 myIgnoreAlgoSelection = true;
1489 myDlg->tab( theDim )->setCurrentHyp( theHypType, theIndex + 1 );
1490 myIgnoreAlgoSelection = false;
1493 //================================================================================
1495 * \brief Generates default and sets mesh/submesh name
1497 * Generates and sets default mesh/submesh name(Mesh_1, Mesh_2, etc.)
1499 //================================================================================
1500 void SMESHGUI_MeshOp::setDefaultName() const
1504 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1506 QString aPrefix = tr( myIsMesh ? "SMESH_OBJECT_MESH" : "SMESH_SUBMESH" ) + "_";
1507 _PTR(SObject) anObj;
1510 aResName = aPrefix + QString::number( i++ );
1511 anObj = aStudy->FindObject( aResName.toLatin1().data() );
1515 QLineEdit* aControl = ( QLineEdit* )myDlg->objectWg(
1516 SMESHGUI_MeshDlg::Obj, SMESHGUI_MeshDlg::Control );
1517 aControl->setText( aResName );
1520 //================================================================================
1522 * \brief Gets algorithm or creates it if necessary
1523 * \param theDim - specifies dimension of returned hypotheses/algorifms
1524 * \retval SMESH::SMESH_Hypothesis_var - algorithm
1526 * Gets algorithm or creates it if necessary
1528 //================================================================================
1529 SMESH::SMESH_Hypothesis_var SMESHGUI_MeshOp::getAlgo( const int theDim )
1531 SMESH::SMESH_Hypothesis_var anAlgoVar;
1533 // get type of the selected algo
1534 int aHypIndex = currentHyp( theDim, Algo );
1535 THypDataList& dataList = myAvailableHypData[ theDim ][ Algo ];
1536 if ( aHypIndex < 0 || aHypIndex >= dataList.count())
1538 QString aHypName = dataList[ aHypIndex ]->TypeName;
1540 // get existing algoritms
1541 _PTR(SObject) pObj = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
1543 existingHyps( theDim, Algo, pObj, tmp, myExistingHyps[ theDim ][ Algo ]);
1545 // look for anexisting algo of such a type
1546 THypList& aHypVarList = myExistingHyps[ theDim ][ Algo ];
1547 THypList::iterator anIter = aHypVarList.begin();
1548 for ( ; anIter != aHypVarList.end(); anIter++)
1550 SMESH::SMESH_Hypothesis_var aHypVar = (*anIter).first;
1551 CORBA::String_var aName = aHypVar->GetName();
1552 if ( !aHypVar->_is_nil() && aHypName == aName )
1554 anAlgoVar = aHypVar;
1559 if (anAlgoVar->_is_nil()) {
1560 HypothesisData* aHypData = SMESH::GetHypothesisData( aHypName );
1562 QString aClientLibName = aHypData->ClientLibName;
1563 if (aClientLibName == "") {
1564 // Call hypothesis creation server method (without GUI)
1565 SMESH::CreateHypothesis(aHypName, aHypData->Label, true);
1567 // Get hypotheses creator client (GUI)
1568 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypName);
1572 aCreator->create(true, aHypName, myDlg);
1574 SMESH::CreateHypothesis(aHypName, aHypData->Label, true);
1576 QStringList tmpList;
1577 _PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" );
1578 existingHyps( theDim, Algo, aFather, tmpList, myExistingHyps[ theDim ][ Algo ] );
1581 THypList& aNewHypVarList = myExistingHyps[ theDim ][ Algo ];
1582 for ( anIter = aNewHypVarList.begin(); anIter != aNewHypVarList.end(); ++anIter )
1584 SMESH::SMESH_Hypothesis_var aHypVar = (*anIter).first;
1585 CORBA::String_var aName = aHypVar->GetName();
1586 if ( !aHypVar->_is_nil() && aHypName == aName )
1588 anAlgoVar = aHypVar;
1594 return anAlgoVar._retn();
1597 //================================================================================
1599 * \brief Reads parameters of edited mesh and assigns them to the dialog
1601 * Reads parameters of edited mesh and assigns them to the dialog (called when
1602 * mesh is edited only)
1604 //================================================================================
1605 void SMESHGUI_MeshOp::readMesh()
1607 QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
1608 _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
1612 if (myIsOnGeometry) {
1613 // Get name of mesh if current object is sub-mesh
1614 SMESH::SMESH_subMesh_var aSubMeshVar =
1615 SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
1616 if ( !aSubMeshVar->_is_nil() )
1618 SMESH::SMESH_Mesh_var aMeshVar = aSubMeshVar->GetFather();
1619 if ( !aMeshVar->_is_nil() )
1621 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar );
1622 QString aMeshName = name( aMeshSO );
1623 myDlg->setObjectText( SMESHGUI_MeshDlg::Mesh, aMeshName );
1627 // Get name of geometry object
1628 GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
1629 if ( !aGeomVar->_is_nil() )
1631 _PTR(SObject) aGeomSO = studyDS()->FindObjectID( aGeomVar->GetStudyEntry() );
1632 QString aShapeName = name( aGeomSO );
1633 myDlg->setObjectText( SMESHGUI_MeshDlg::Geom, aShapeName );
1637 // Get hypotheses and algorithms assigned to the mesh/sub-mesh
1638 QStringList anExisting;
1639 const int aDim = ( myIsOnGeometry ) ? SMESH::DIM_0D : SMESH::DIM_3D;
1640 for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
1643 existingHyps( dim, Algo, pObj, anExisting, myObjHyps[ dim ][ Algo ] );
1644 // find algo index among available ones
1646 if ( myObjHyps[ dim ][ Algo ].count() > 0 )
1648 SMESH::SMESH_Hypothesis_var aVar = myObjHyps[ dim ][ Algo ].first().first;
1649 HypothesisData* algoData = SMESH::GetHypothesisData( aVar->GetName() );
1650 aHypIndex = myAvailableHypData[ dim ][ Algo ].indexOf ( algoData );
1651 // if ( aHypIndex < 0 && algoData ) {
1652 // // assigned algo is incompatible with other algorithms
1653 // myAvailableHypData[ dim ][ Algo ].push_back( algoData );
1654 // aHypIndex = myAvailableHypData[ dim ][ hypType ].count() - 1;
1657 setCurrentHyp( dim, Algo, aHypIndex );
1658 // set existing and available hypothesis according to the selected algo
1659 onAlgoSelected( aHypIndex, dim );
1663 bool hypWithoutAlgo = false;
1664 for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
1666 for ( int hypType = MainHyp; hypType <= AddHyp; hypType++ )
1669 existingHyps( dim, hypType, pObj, anExisting, myObjHyps[ dim ][ hypType ] );
1670 // find index of requered hypothesis among existing ones for this dimension and type
1672 if ( myObjHyps[ dim ][ hypType ].count() > 0 ) {
1673 aHypIndex = find( myObjHyps[ dim ][ hypType ].first().first,
1674 myExistingHyps[ dim ][ hypType ] );
1675 if ( aHypIndex < 0 ) {
1676 // assigned hypothesis is incompatible with the algorithm
1677 if ( currentHyp( dim, Algo ) < 0 )
1678 { // none algo selected; it is edition for sure, of submesh maybe
1679 hypWithoutAlgo = true;
1680 myExistingHyps[ dim ][ hypType ].push_back( myObjHyps[ dim ][ hypType ].first() );
1681 aHypIndex = myExistingHyps[ dim ][ hypType ].count() - 1;
1682 myDlg->tab( dim )->setExistingHyps( hypType, anExisting );
1686 setCurrentHyp( dim, hypType, aHypIndex );
1689 // make available other hyps of same type as one without algo
1690 if ( hypWithoutAlgo )
1691 onAlgoSelected( currentHyp( 0, Algo ), 0 );
1694 //================================================================================
1696 * \brief Gets name of object
1697 * \param theSO - SObject
1698 * \retval QString - name of object
1700 * Gets name of object
1702 //================================================================================
1703 QString SMESHGUI_MeshOp::name( _PTR(SObject) theSO ) const
1708 _PTR(GenericAttribute) anAttr;
1709 _PTR(AttributeName) aNameAttr;
1710 if ( theSO->FindAttribute( anAttr, "AttributeName" ) )
1713 aResName = aNameAttr->Value().c_str();
1719 //================================================================================
1721 * \brief Finds hypothesis in input list
1722 * \param theHyp - hypothesis to be found
1723 * \param theHypList - input list of hypotheses
1724 * \retval int - index of hypothesis or -1 if it is not found
1726 * Finds position of hypothesis in input list
1728 //================================================================================
1729 int SMESHGUI_MeshOp::find( const SMESH::SMESH_Hypothesis_var& theHyp,
1730 const THypList& theHypList ) const
1733 if ( !theHyp->_is_nil() )
1736 THypList::const_iterator anIter = theHypList.begin();
1737 for ( ; anIter != theHypList.end(); ++ anIter)
1739 if ( theHyp->_is_equivalent( (*anIter).first ) )
1750 //================================================================================
1752 * \brief Edits mesh or sub-mesh
1753 * \param theMess - Output parameter intended for returning error message
1754 * \retval bool - TRUE if mesh is edited succesfully, FALSE otherwise
1756 * Assigns new name hypotheses and algoriths to the mesh or sub-mesh
1758 //================================================================================
1759 bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess )
1763 SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
1764 if ( aSMESHGen->_is_nil() )
1767 QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
1768 _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
1772 SUIT_OverrideCursor aWaitCursor;
1775 QString aName = myDlg->objectText( SMESHGUI_MeshDlg::Obj );
1776 SMESH::SetName( pObj, aName );
1777 int aDim = ( myIsOnGeometry ) ? SMESH::DIM_0D : SMESH::DIM_3D;
1779 // First, remove old algos in order to avoid messages on algorithm hiding
1780 for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
1782 if ( isAccessibleDim( dim ) && myObjHyps[ dim ][ Algo ].count() > 0 )
1784 SMESH::SMESH_Hypothesis_var anOldAlgo = myObjHyps[ dim ][ Algo ].first().first;
1785 SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( dim );
1786 if ( anAlgoVar->_is_nil() || // no new algo selected or
1787 strcmp(anOldAlgo->GetName(), anAlgoVar->GetName()) ) // algo change
1789 // remove old algorithm
1790 SMESH::RemoveHypothesisOrAlgorithmOnMesh ( pObj, myObjHyps[ dim ][ Algo ].first().first );
1791 myObjHyps[ dim ][ Algo ].clear();
1796 // Assign new algorithms and hypotheses
1797 for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
1799 if ( !isAccessibleDim( dim )) continue;
1801 // find or create algorithm
1802 SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( dim );
1804 // assign new algorithm
1805 if ( !anAlgoVar->_is_nil() && // some algo selected and
1806 myObjHyps[ dim ][ Algo ].count() == 0 ) // no algo assigned
1808 SALOMEDS_SObject* aSObject = _CAST(SObject, pObj);
1809 CORBA::Object_var anObject = aSObject->GetObject();
1810 SMESH::SMESH_Mesh_var aMeshVar = SMESH::SMESH_Mesh::_narrow( anObject );
1811 bool isMesh = !aMeshVar->_is_nil();
1813 SMESH::AddHypothesisOnMesh( aMeshVar, anAlgoVar );
1815 SMESH::SMESH_subMesh_var aVar =
1816 SMESH::SMESH_subMesh::_narrow( _CAST(SObject,pObj)->GetObject() );
1817 if ( !aVar->_is_nil() )
1818 SMESH::AddHypothesisOnSubMesh( aVar, anAlgoVar );
1820 myObjHyps[ dim ][ Algo ].append( THypItem( anAlgoVar, aName) );
1823 // assign hypotheses
1824 for ( int hypType = MainHyp; hypType <= AddHyp; hypType++ )
1826 int aNewHypIndex = currentHyp( dim, hypType );
1827 int anOldHypIndex = -1;
1829 // remove old hypotheses
1830 if ( myObjHyps[ dim ][ hypType ].count() > 0 )
1832 anOldHypIndex = find( myObjHyps[ dim ][ hypType ].first().first,
1833 myExistingHyps[ dim ][ hypType ] );
1834 if ( aNewHypIndex != anOldHypIndex || // different hyps
1835 anOldHypIndex == -1 ) // hyps of different algos
1837 SMESH::RemoveHypothesisOrAlgorithmOnMesh
1838 ( pObj, myObjHyps[ dim ][ hypType ].first().first );
1839 myObjHyps[ dim ][ hypType ].clear();
1843 // assign new hypotheses
1844 if ( aNewHypIndex != anOldHypIndex && aNewHypIndex != -1 )
1846 SMESH::SMESH_Mesh_var aMeshVar =
1847 SMESH::SMESH_Mesh::_narrow( _CAST(SObject,pObj)->GetObject() );
1848 bool isMesh = !aMeshVar->_is_nil();
1851 SMESH::AddHypothesisOnMesh
1852 (aMeshVar, myExistingHyps[ dim ][ hypType ][ aNewHypIndex ].first );
1856 SMESH::SMESH_subMesh_var aVar =
1857 SMESH::SMESH_subMesh::_narrow( _CAST(SObject,pObj)->GetObject() );
1858 if ( !aVar->_is_nil() )
1859 SMESH::AddHypothesisOnSubMesh
1860 ( aVar, myExistingHyps[ dim ][ hypType ][ aNewHypIndex ].first );
1863 // reread all hypotheses of mesh if necessary
1864 QStringList anExisting;
1865 existingHyps( dim, hypType, pObj, anExisting, myObjHyps[ dim ][ hypType ] );
1872 //================================================================================
1874 * \brief Verifies whether given operator is valid for this one
1875 * \param theOtherOp - other operation
1876 * \return Returns TRUE if the given operator is valid for this one, FALSE otherwise
1878 * method redefined from base class verifies whether given operator is valid for
1879 * this one (i.e. can be started "above" this operator). In current implementation method
1880 * retuns false if theOtherOp operation is not intended for deleting objects or mesh
1883 //================================================================================
1884 bool SMESHGUI_MeshOp::isValid( SUIT_Operation* theOp ) const
1886 return SMESHGUI_Operation::isValid( theOp ) && !theOp->inherits( "SMESHGUI_MeshOp" );
1889 //================================================================================
1891 * \brief SLOT. Is called when the user selects a way of geometry selection
1892 * \param theByMesh - true if the user wants to find geometry by mesh element
1894 //================================================================================
1896 void SMESHGUI_MeshOp::onGeomSelectionByMesh( bool theByMesh )
1899 if ( !myShapeByMeshOp ) {
1900 myShapeByMeshOp = new SMESHGUI_ShapeByMeshOp();
1901 connect(myShapeByMeshOp, SIGNAL(committed(SUIT_Operation*)),
1902 SLOT(onPublishShapeByMeshDlg(SUIT_Operation*)));
1903 connect(myShapeByMeshOp, SIGNAL(aborted(SUIT_Operation*)),
1904 SLOT(onCloseShapeByMeshDlg(SUIT_Operation*)));
1906 // set mesh object to SMESHGUI_ShapeByMeshOp and start it
1907 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
1908 if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() )) {
1909 SMESH::SMESH_Mesh_var aMeshVar =
1910 SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() );
1911 if ( !aMeshVar->_is_nil() ) {
1912 myDlg->hide(); // stop processing selection
1913 myShapeByMeshOp->setModule( getSMESHGUI() );
1914 myShapeByMeshOp->setStudy( 0 ); // it's really necessary
1915 myShapeByMeshOp->SetMesh( aMeshVar );
1916 myShapeByMeshOp->start();
1922 //================================================================================
1924 * \brief SLOT. Is called when Ok is pressed in SMESHGUI_ShapeByMeshDlg
1926 //================================================================================
1928 void SMESHGUI_MeshOp::onPublishShapeByMeshDlg(SUIT_Operation* op)
1930 if ( myShapeByMeshOp == op ) {
1931 SMESHGUI::GetSMESHGUI()->getApp()->updateObjectBrowser(); //MZN: 24.11.2006 IPAL13980 - Object Browser update added
1933 // Select a found geometry object
1934 GEOM::GEOM_Object_var aGeomVar = myShapeByMeshOp->GetShape();
1935 if ( !aGeomVar->_is_nil() )
1937 QString ID = aGeomVar->GetStudyEntry();
1938 if ( _PTR(SObject) aGeomSO = studyDS()->FindObjectID( ID.toLatin1().data() )) {
1939 selectObject( aGeomSO );
1946 //================================================================================
1948 * \brief SLOT. Is called when Close is pressed in SMESHGUI_ShapeByMeshDlg
1950 //================================================================================
1952 void SMESHGUI_MeshOp::onCloseShapeByMeshDlg(SUIT_Operation* op)
1954 if ( myShapeByMeshOp == op && myDlg ) {
1959 //================================================================================
1961 * \brief Selects a SObject
1962 * \param theSObj - the SObject to select
1964 //================================================================================
1966 void SMESHGUI_MeshOp::selectObject( _PTR(SObject) theSObj ) const
1968 if ( LightApp_SelectionMgr* sm = selectionMgr() ) {
1969 SALOME_ListIO anIOList;
1971 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject
1972 ( theSObj->GetID().c_str(), "SMESH", theSObj->GetName().c_str() );
1973 anIOList.Append( anIO );
1975 sm->setSelectedObjects( anIOList, false );