1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 * Copyright (C) 2005 CEA/DEN, EDF R&D
27 * File : SMESHGUI_MeshOp.h
28 * Author : Sergey LITONIN
32 #include "SMESHGUI_MeshOp.h"
33 #include "SMESHGUI_MeshDlg.h"
34 #include "SMESHGUI_ShapeByMeshDlg.h"
35 #include "SMESH_TypeFilter.hxx"
38 #include "SMESHGUI_HypothesesUtils.h"
39 #include "SMESHGUI_Hypotheses.h"
40 #include "SMESHGUI_Utils.h"
41 #include "SMESHGUI_GEOMGenUtils.h"
42 #include "SMESHGUI_VTKUtils.h"
44 #include "SMESH_TypeFilter.hxx"
45 #include "SMESH_NumberFilter.hxx"
47 #include CORBA_CLIENT_HEADER(SMESH_Gen)
49 #include "GEOM_SelectionFilter.h"
51 #include "GeometryGUI.h"
53 #include "SalomeApp_Tools.h"
54 #include "SalomeApp_Application.h"
55 #include "SALOMEDSClient_Study.hxx"
56 #include "SALOMEDSClient_AttributeIOR.hxx"
57 #include "SALOMEDSClient_AttributeName.hxx"
58 #include "SALOMEDS_SComponent.hxx"
59 #include "SALOMEDS_SObject.hxx"
61 #include "LightApp_SelectionMgr.h"
62 #include "LightApp_UpdateFlags.h"
63 #include "SUIT_MessageBox.h"
64 #include "SUIT_Desktop.h"
65 #include "SUIT_OverrideCursor.h"
66 #include "SALOME_InteractiveObject.hxx"
67 #include "SALOME_ListIO.hxx"
69 #include "utilities.h"
71 #include <qstringlist.h>
72 #include <qlineedit.h>
74 #include <TopoDS_Shape.hxx>
75 #include <TopExp_Explorer.hxx>
77 //================================================================================
80 * \param theToCreate - if this parameter is true then operation is used for creation,
81 * for editing otherwise
83 * Initialize operation
85 //================================================================================
86 SMESHGUI_MeshOp::SMESHGUI_MeshOp( const bool theToCreate, const bool theIsMesh )
87 : SMESHGUI_SelectionOp(),
88 myToCreate( theToCreate ),
89 myIsMesh( theIsMesh ),
93 if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists
94 GeometryGUI::InitGeomGen();
95 myIsOnGeometry = true;
98 //================================================================================
102 //================================================================================
103 SMESHGUI_MeshOp::~SMESHGUI_MeshOp()
109 //================================================================================
111 * \brief Gets dialog of this operation
112 * \retval LightApp_Dialog* - pointer to dialog of this operation
114 //================================================================================
115 LightApp_Dialog* SMESHGUI_MeshOp::dlg() const
120 //================================================================================
122 * \brief Creates or edits mesh
123 * \retval bool - TRUE if operation is performed successfully, FALSE otherwise
125 * Virtual slot redefined from the base class called when "Apply" button is clicked
126 * creates or edits mesh
128 //================================================================================
129 bool SMESHGUI_MeshOp::onApply()
135 if ( !isValid( aMess ) )
139 SUIT_MessageBox::warn1( myDlg,
140 tr( "SMESH_WRN_WARNING" ), aMess, tr( "SMESH_BUT_OK" ) );
144 bool aResult = false;
148 if ( myToCreate && myIsMesh )
149 aResult = createMesh( aMess );
150 if ( myToCreate && !myIsMesh )
151 aResult = createSubMesh( aMess );
152 else if ( !myToCreate )
153 aResult = editMeshOrSubMesh( aMess );
155 update( UF_ObjBrowser | UF_Model );
157 catch ( const SALOME::SALOME_Exception& S_ex )
159 SalomeApp_Tools::QtCatchCorbaException( S_ex );
175 aMess = tr( "SMESH_OPERATION_FAILED" );
176 SUIT_MessageBox::warn1( myDlg,
177 tr( "SMESH_ERROR" ), aMess, tr( "SMESH_BUT_OK" ) );
183 //================================================================================
185 * \brief Creates dialog if necessary and shows it
187 * Virtual method redefined from base class called when operation is started creates
188 * dialog if necessary and shows it, activates selection
190 //================================================================================
191 void SMESHGUI_MeshOp::startOperation()
195 myDlg = new SMESHGUI_MeshDlg( myToCreate, myIsMesh );
196 for ( int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++ )
198 connect( myDlg->tab( i ), SIGNAL( createHyp( const int, const int ) ),
199 this, SLOT( onCreateHyp( const int, const int ) ) );
200 connect( myDlg->tab( i ), SIGNAL( editHyp( const int, const int ) ),
201 this, SLOT( onEditHyp( const int, const int ) ) );
202 connect( myDlg->tab( i ), SIGNAL( selectAlgo( const int ) ),
203 this, SLOT( onAlgoSelected( const int ) ) );
205 connect( myDlg, SIGNAL( hypoSet( const QString& )), SLOT( onHypoSet( const QString& )));
206 connect( myDlg, SIGNAL( geomSelectionByMesh( bool )), SLOT( onGeomSelectionByMesh( bool )));
209 if ( myIsMesh ) myHelpFileName = "constructing_meshes_page.html";
210 else myHelpFileName = "constructing_submeshes_page.html";
211 else myHelpFileName = "editing_meshes_page.html";
213 SMESHGUI_SelectionOp::startOperation();
215 // iterate through dimensions and get available algoritms, set them to the dialog
216 _PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" );
217 for ( int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++ )
219 SMESHGUI_MeshTab* aTab = myDlg->tab( i );
221 // clear available hypotheses
222 aTab->setAvailableHyps( MainHyp, hypList );
223 aTab->setAvailableHyps( AddHyp, hypList );
224 aTab->setExistingHyps( MainHyp, hypList );
225 aTab->setExistingHyps( AddHyp, hypList );
226 myExistingHyps[ i ][ MainHyp ].clear();
227 myExistingHyps[ i ][ AddHyp ].clear();
229 availableHyps( i, Algo, hypList, myAvailableHypData[i][Algo] );
230 aTab->setAvailableHyps( Algo, hypList );
235 myDlg->activateObject( myIsMesh ? SMESHGUI_MeshDlg::Geom : SMESHGUI_MeshDlg::Mesh );
238 myDlg->activateObject( SMESHGUI_MeshDlg::Obj );
240 myDlg->setHypoSets( SMESH::GetHypothesesSets() );
242 myDlg->setCurrentTab( SMESH::DIM_3D );
247 myIgnoreAlgoSelection = false;
250 //================================================================================
252 * \brief Creates selection filter
253 * \param theId - identifier of current selection widget
254 * \retval SUIT_SelectionFilter* - pointer to the created filter or null
256 * Creates selection filter in accordance with identifier of current selection widget
258 //================================================================================
259 SUIT_SelectionFilter* SMESHGUI_MeshOp::createFilter( const int theId ) const
261 if ( theId == SMESHGUI_MeshDlg::Geom )
263 // TColStd_MapOfInteger allTypesMap;
264 // for ( int i = 0; i < 10; i++ )
265 // allTypesMap.Add( i );
266 // return new SMESH_NumberFilter( "GEOM", TopAbs_SHAPE, 0, allTypesMap );
267 return new GEOM_SelectionFilter( (SalomeApp_Study*)study(), true );
269 else if ( theId == SMESHGUI_MeshDlg::Obj && !myToCreate )
270 return new SMESH_TypeFilter( MESHorSUBMESH );
271 else if ( theId == SMESHGUI_MeshDlg::Mesh )
272 return new SMESH_TypeFilter( MESH );
277 //================================================================================
279 * \brief check if selected shape is a subshape of the shape to mesh
280 * \retval bool - check result
282 //================================================================================
284 bool SMESHGUI_MeshOp::isSubshapeOk() const
286 if ( !myToCreate || myIsMesh ) // not submesh creation
290 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
291 _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() );
292 if (!pMesh) return false;
294 SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
295 if (mesh->_is_nil()) return false;
297 // main shape of the mesh
298 GEOM::GEOM_Object_var mainGeom = mesh->GetShapeToMesh();
299 if (mainGeom->_is_nil()) return false;
303 myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
305 if (aGEOMs.count() > 0) {
306 GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
307 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
308 if (geomGen->_is_nil() || !aStudy) return false;
310 GEOM::GEOM_IGroupOperations_var op =
311 geomGen->GetIGroupOperations(aStudy->StudyId());
312 if (op->_is_nil()) return false;
314 // check all selected shapes
315 QStringList::const_iterator aSubShapesIter = aGEOMs.begin();
316 for (; aSubShapesIter != aGEOMs.end(); aSubShapesIter++) {
317 QString aSubGeomEntry = (*aSubShapesIter);
318 _PTR(SObject) pSubGeom = studyDS()->FindObjectID(aSubGeomEntry.latin1());
319 if (!pSubGeom) return false;
321 GEOM::GEOM_Object_var aSubGeomVar =
322 GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
323 if (aSubGeomVar->_is_nil()) return false;
325 // skl for NPAL14695 - implementation of searching of mainObj
326 GEOM::GEOM_Object_var mainObj = op->GetMainShape(aSubGeomVar);
327 //if (mainObj->_is_nil() ||
328 // string(mainObj->GetEntry()) != string(mainGeom->GetEntry())) return false;
330 if (mainObj->_is_nil())
332 if (string(mainObj->GetEntry()) == string(mainGeom->GetEntry()))
334 mainObj = op->GetMainShape(mainObj);
343 //================================================================================
345 * \brief find an existing submesh by the selected shape
346 * \retval _PTR(SObject) - the found submesh SObject
348 //================================================================================
350 _PTR(SObject) SMESHGUI_MeshOp::getSubmeshByGeom() const
352 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
353 QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
354 _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() );
355 _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.latin1() );
356 if ( pMesh && pGeom ) {
357 GEOM::GEOM_Object_var geom = SMESH::SObjectToInterface<GEOM::GEOM_Object>( pGeom );
358 if ( !geom->_is_nil() ) {
360 switch ( geom->GetShapeType() ) {
361 case GEOM::VERTEX: tag = SMESH::Tag_SubMeshOnVertex ; break;
362 case GEOM::EDGE: tag = SMESH::Tag_SubMeshOnEdge ; break;
363 case GEOM::WIRE: tag = SMESH::Tag_SubMeshOnWire ; break;
364 case GEOM::FACE: tag = SMESH::Tag_SubMeshOnFace ; break;
365 case GEOM::SHELL: tag = SMESH::Tag_SubMeshOnShell ; break;
366 case GEOM::SOLID: tag = SMESH::Tag_SubMeshOnSolid ; break;
367 case GEOM::COMPOUND: tag = SMESH::Tag_SubMeshOnCompound; break;
370 _PTR(GenericAttribute) anAttr;
371 _PTR(SObject) aSubmeshRoot;
372 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
373 if ( pMesh->FindSubObject( tag, aSubmeshRoot ) )
375 _PTR(ChildIterator) smIter = aStudy->NewChildIterator( aSubmeshRoot );
376 for (; smIter->More(); smIter->Next() )
378 _PTR(SObject) aSmObj = smIter->Value();
379 if ( ! aSmObj->FindAttribute( anAttr, "AttributeIOR" ))
381 _PTR(ChildIterator) anIter1 = aStudy->NewChildIterator(aSmObj);
382 for (; anIter1->More(); anIter1->Next()) {
383 _PTR(SObject) pGeom2 = anIter1->Value();
384 if ( pGeom2->ReferencedObject( pGeom2 ) &&
385 pGeom2->GetID() == pGeom->GetID() )
392 return _PTR(SObject)();
395 //================================================================================
397 * \brief Updates dialog's look and feel
399 * Virtual method redefined from the base class updates dialog's look and feel
401 //================================================================================
402 void SMESHGUI_MeshOp::selectionDone()
404 if (!dlg()->isShown() || !myDlg->isEnabled())
407 SMESHGUI_SelectionOp::selectionDone();
411 myIsOnGeometry = true;
413 //Check geometry for mesh
414 QString anObjEntry = myDlg->selectedObject(SMESHGUI_MeshDlg::Obj);
415 _PTR(SObject) pObj = studyDS()->FindObjectID(anObjEntry.latin1());
418 SMESH::SMESH_Mesh_var aMeshVar =
419 SMESH::SMESH_Mesh::_narrow(_CAST(SObject,pObj)->GetObject());
420 if (!aMeshVar->_is_nil()) {
421 if (!myToCreate && !aMeshVar->HasShapeToMesh())
422 myIsOnGeometry = false;
428 // Enable tabs according to shape dimension
433 myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
434 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
436 if (aGEOMs.count() > 0) {
437 // one or more GEOM shape selected
438 aSeq->length(aGEOMs.count());
439 QStringList::const_iterator aSubShapesIter = aGEOMs.begin();
441 for (; aSubShapesIter != aGEOMs.end(); aSubShapesIter++, iSubSh++) {
442 QString aSubGeomEntry = (*aSubShapesIter);
443 _PTR(SObject) pSubGeom = studyDS()->FindObjectID(aSubGeomEntry.latin1());
444 GEOM::GEOM_Object_var aSubGeomVar =
445 GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
446 aSeq[iSubSh] = aSubGeomVar;
449 // get geometry by selected sub-mesh
450 QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
451 _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.latin1() );
452 GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
453 if (!aGeomVar->_is_nil()) {
459 if (aSeq->length() > 0) {
461 for (int iss = 0; iss < aSeq->length() && shapeDim < 3; iss++) {
462 GEOM::GEOM_Object_var aGeomVar = aSeq[iss];
463 switch ( aGeomVar->GetShapeType() ) {
465 case GEOM::SHELL: shapeDim = 3; break;
466 case GEOM::FACE: shapeDim = (shapeDim < 2) ? 2 : shapeDim; break;
468 case GEOM::EDGE: shapeDim = (shapeDim < 1) ? 1 : shapeDim; break;
469 case GEOM::VERTEX: break;
472 if ( GEOMBase::GetShape(aGeomVar, aShape)) {
473 TopExp_Explorer exp( aShape, TopAbs_SHELL );
476 else if ( exp.Init( aShape, TopAbs_FACE ), exp.More() )
477 shapeDim = (shapeDim < 2) ? 2 : shapeDim;
478 else if ( exp.Init( aShape, TopAbs_EDGE ), exp.More() )
479 shapeDim = (shapeDim < 1) ? 1 : shapeDim;
486 myDlg->setMaxHypoDim( shapeDim );
489 if (!myToCreate) // edition: read hypotheses
493 SMESH::SMESH_subMesh_var aVar =
494 SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
495 myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, !aVar->_is_nil() );
496 myDlg->setObjectShown( SMESHGUI_MeshDlg::Geom, true );
497 myDlg->objectWg( SMESHGUI_MeshDlg::Mesh, SMESHGUI_MeshDlg::Btn )->hide();
498 myDlg->objectWg( SMESHGUI_MeshDlg::Geom, SMESHGUI_MeshDlg::Btn )->hide();
499 myDlg->updateGeometry();
506 else if ( !myIsMesh ) // submesh creation
508 // if a submesh on the selected shape already exist, pass to submesh edition mode
509 if ( _PTR(SObject) pSubmesh = getSubmeshByGeom() ) {
510 SMESH::SMESH_subMesh_var sm =
511 SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( pSubmesh );
512 bool editSubmesh = ( !sm->_is_nil() &&
513 SUIT_MessageBox::question2( myDlg, tr( "SMESH_WARNING" ),
514 tr( "EDIT_SUBMESH_QUESTION"),
515 tr( "SMESH_BUT_YES" ),
516 tr( "SMESH_BUT_NO" ), 1, 0, 0 ));
519 selectionMgr()->clearFilters();
520 selectObject( pSubmesh );
521 SMESHGUI::GetSMESHGUI()->switchToOperation(704);
526 myDlg->selectObject( "", SMESHGUI_MeshDlg::Geom, "" );
527 selectObject( _PTR(SObject)() );
532 // enable/disable popup for choice of geom selection way
534 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
535 if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() )) {
536 SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
537 if ( !mesh->_is_nil() )
538 enable = ( shapeDim > 1 ) && ( mesh->NbEdges() > 0 );
540 myDlg->setGeomPopupEnabled( enable );
544 myDlg->enableTab( SMESH::DIM_3D );
546 availableHyps( SMESH::DIM_3D, Algo, hypList,
547 myAvailableHypData[SMESH::DIM_3D][Algo]);
549 SMESHGUI_MeshTab* aTab = myDlg->tab( SMESH::DIM_3D );
550 aTab->setAvailableHyps( Algo, hypList );
551 for (int i = SMESH::DIM_0D;i < SMESH::DIM_3D; ++i) {
552 myDlg->disableTab(i);
554 //Hide labels and fields (Mesh ang Geometry)
555 myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, false );
556 myDlg->setObjectShown( SMESHGUI_MeshDlg::Geom, false );
561 catch ( const SALOME::SALOME_Exception& S_ex )
563 SalomeApp_Tools::QtCatchCorbaException( S_ex );
570 //================================================================================
572 * \brief Verifies validity of input data
573 * \param theMess - Output parameter intended for returning error message
574 * \retval bool - TRUE if input data is valid, false otherwise
576 * Verifies validity of input data. This method is called when "Apply" or "OK" button
577 * is pressed before mesh creation or editing.
579 //================================================================================
580 bool SMESHGUI_MeshOp::isValid( QString& theMess ) const
582 // Selected object to be edited
583 if ( !myToCreate && myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ) == "" )
585 theMess = tr( "THERE_IS_NO_OBJECT_FOR_EDITING" );
590 QString aMeshName = myDlg->objectText( SMESHGUI_MeshDlg::Obj );
591 aMeshName = aMeshName.stripWhiteSpace();
592 if ( aMeshName == "" )
594 theMess = myIsMesh ? tr( "NAME_OF_MESH_IS_EMPTY" ) : tr( "NAME_OF_SUBMESH_IS_EMPTY" );
598 /* // Imported mesh, if create sub-mesh or edit mesh
599 if ( !myToCreate || ( myToCreate && !myIsMesh ))
601 QString aMeshEntry = myDlg->selectedObject
602 ( myToCreate ? SMESHGUI_MeshDlg::Mesh : SMESHGUI_MeshDlg::Obj );
603 if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() )) {
604 SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
605 if ( !mesh->_is_nil() && CORBA::is_nil( mesh->GetShapeToMesh() )) {
606 theMess = tr( "IMPORTED_MESH" );
615 QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
616 if ( aGeomEntry == "" )
618 theMess = tr( "GEOMETRY_OBJECT_IS_NOT_DEFINED" );
621 _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.latin1() );
622 if ( !pGeom || GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() )->_is_nil() )
624 theMess = tr( "GEOMETRY_OBJECT_IS_NULL" );
629 if ( !myIsMesh ) // i.e sub-mesh creation,
631 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
632 if ( aMeshEntry == "" )
634 theMess = tr( "MESH_IS_NOT_DEFINED" );
637 _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() );
638 if ( !pMesh || SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() )->_is_nil() )
640 theMess = tr( "MESH_IS_NULL" );
643 if ( !isSubshapeOk() )
645 theMess = tr( "INVALID_SUBSHAPE" );
654 //================================================================================
656 * \brief check compatibility of the algorithm and another algorithm or hypothesis
657 * \param theAlgoData - algorithm data
658 * \param theHypData - hypothesis data
659 * \param theHypType - hypothesis type
660 * \param theHypTypeName - hypothesis type name, must be provided if 2-nd arg is not algo
661 * \retval bool - check result
663 //================================================================================
665 static bool isCompatible(const HypothesisData* theAlgoData,
666 const HypothesisData* theHypData,
667 const int theHypType)
672 if ( theHypType == SMESHGUI_MeshOp::Algo )
673 return SMESH::IsCompatibleAlgorithm( theAlgoData, theHypData );
676 return ( SMESH::IsAvailableHypothesis( theAlgoData, theHypData->TypeName, isOptional ));
679 //================================================================================
681 * \brief Gets available hypotheses or algorithms
682 * \param theDim - specifies dimension of returned hypotheses/algorifms
683 * \param theHypType - specifies whether algorims or hypotheses or additional ones
684 * are retrieved (possible values are in HypType enumeration)
685 * \param theHyps - Output list of hypotheses' names
686 * \param theAlgoData - to select hypos able to be used by this algo (optional)
688 * Gets available hypotheses or algorithm in accordance with input parameters
690 //================================================================================
691 void SMESHGUI_MeshOp::availableHyps( const int theDim,
692 const int theHypType,
693 QStringList& theHyps,
694 THypDataList& theDataList,
695 HypothesisData* theAlgoData ) const
699 bool isAlgo = ( theHypType == Algo );
700 bool isAux = ( theHypType == AddHyp );
701 QStringList aHypTypeNameList = SMESH::GetAvailableHypotheses( isAlgo, theDim, isAux, myIsOnGeometry );
703 QStringList::const_iterator anIter;
704 for ( anIter = aHypTypeNameList.begin(); anIter != aHypTypeNameList.end(); ++anIter )
706 HypothesisData* aData = SMESH::GetHypothesisData( *anIter );
707 if ( isCompatible ( theAlgoData, aData, theHypType )) {
708 theDataList.append( aData );
709 theHyps.append( aData->Label );
714 //================================================================================
716 * \brief Gets existing hypotheses or algorithms
717 * \param theDim - specifies dimension of returned hypotheses/algorifms
718 * \param theHypType - specifies whether algorims or hypotheses or additional ones
719 * are retrieved (possible values are in HypType enumeration)
720 * \param theFather - start object for finding ( may be component, mesh, or sub-mesh )
721 * \param theHyps - output list of names.
722 * \param theHypVars - output list of variables.
723 * \param theAlgoData - to select hypos able to be used by this algo (optional)
725 * Gets existing (i.e. already created) hypotheses or algorithm in accordance with
728 //================================================================================
729 void SMESHGUI_MeshOp::existingHyps( const int theDim,
730 const int theHypType,
731 _PTR(SObject) theFather,
732 QStringList& theHyps,
733 THypList& theHypList,
734 HypothesisData* theAlgoData)
736 // Clear hypoheses list
743 const bool isAux = ( theHypType == AddHyp );
745 _PTR(SObject) aHypRoot;
746 _PTR(GenericAttribute) anAttr;
747 _PTR(AttributeName) aName;
748 _PTR(AttributeIOR) anIOR;
750 bool isMesh = !_CAST( SComponent, theFather );
753 aPart = theHypType == Algo ? SMESH::Tag_RefOnAppliedAlgorithms : SMESH::Tag_RefOnAppliedHypothesis;
755 aPart = theHypType == Algo ? SMESH::Tag_AlgorithmsRoot : SMESH::Tag_HypothesisRoot;
757 if ( theFather->FindSubObject( aPart, aHypRoot ) )
759 _PTR(ChildIterator) anIter =
760 SMESH::GetActiveStudyDocument()->NewChildIterator( aHypRoot );
761 for (; anIter->More(); anIter->Next() )
763 _PTR(SObject) anObj = anIter->Value();
764 if ( isMesh ) // i.e. mesh or submesh
766 _PTR(SObject) aRefObj;
767 if ( anObj->ReferencedObject( aRefObj ) )
772 if ( anObj->FindAttribute( anAttr, "AttributeName" ) )
775 CORBA::Object_var aVar = _CAST(SObject,anObj)->GetObject();
776 if ( !CORBA::is_nil( aVar ) )
778 SMESH::SMESH_Hypothesis_var aHypVar = SMESH::SMESH_Hypothesis::_narrow( aVar );
779 if ( !aHypVar->_is_nil() )
781 CORBA::String_var aHypType( aHypVar->GetName() );
782 HypothesisData* aData = SMESH::GetHypothesisData( aHypType );
783 if ( ( theDim == -1 || aData->Dim.contains( theDim ) ) &&
784 ( isCompatible ( theAlgoData, aData, theHypType )) &&
785 ( isAux == aData->IsAux ))
787 std::string aHypName = aName->Value();
788 theHyps.append( aHypName.c_str() );
789 theHypList.append( THypItem( aHypVar, aHypName.c_str() ) );
798 //================================================================================
800 * \brief If create or edit a submesh, return a hypothesis holding parameters used
802 * \param aHypType - The hypothesis type name
803 * \param aServerLib - Server library name
804 * \param hypData - The structure holding the hypothesis type etc.
805 * \retval SMESH::SMESH_Hypothesis_var - the hypothesis holding parameter values
807 //================================================================================
809 SMESH::SMESH_Hypothesis_var
810 SMESHGUI_MeshOp::getInitParamsHypothesis( const QString& aHypType,
811 const QString& aServerLib ) const
813 if ( aHypType.isEmpty() || aServerLib.isEmpty() )
814 return SMESH::SMESH_Hypothesis::_nil();
816 const int nbColonsInMeshEntry = 3;
817 bool isSubMesh = myToCreate ?
819 myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ).contains(':') > nbColonsInMeshEntry;
823 // get mesh and geom object
824 SMESH::SMESH_Mesh_var aMeshVar = SMESH::SMESH_Mesh::_nil();
825 GEOM::GEOM_Object_var aGeomVar = GEOM::GEOM_Object::_nil();
827 QString anEntry = myDlg->selectedObject
828 ( myToCreate ? SMESHGUI_MeshDlg::Mesh : SMESHGUI_MeshDlg::Obj );
829 if ( _PTR(SObject) pObj = studyDS()->FindObjectID( anEntry.latin1() ))
831 CORBA::Object_ptr Obj = _CAST( SObject,pObj )->GetObject();
832 if ( myToCreate ) // mesh and geom may be selected
834 aMeshVar = SMESH::SMESH_Mesh::_narrow( Obj );
835 anEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
836 if ( _PTR(SObject) pGeom = studyDS()->FindObjectID( anEntry.latin1() ))
837 aGeomVar= GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
839 else // edition: sub-mesh may be selected
841 SMESH::SMESH_subMesh_var sm = SMESH::SMESH_subMesh::_narrow( Obj );
842 if ( !sm->_is_nil() ) {
843 aMeshVar = sm->GetFather();
844 aGeomVar = sm->GetSubShape();
849 if ( !aMeshVar->_is_nil() && !aGeomVar->_is_nil() )
850 return SMESHGUI::GetSMESHGen()->GetHypothesisParameterValues( aHypType,
855 return SMESH::SMESH_Hypothesis::_nil();
858 //================================================================================
860 * \Brief Returns tab dimention
861 * \param tab - the tab in the dlg
862 * \param dlg - my dialogue
863 * \retval int - dimention
865 //================================================================================
867 static int getTabDim (const QObject* tab, SMESHGUI_MeshDlg* dlg )
870 for (int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++)
871 if (tab == dlg->tab(i))
876 //================================================================================
878 * \brief Create hypothesis
879 * \param theHypType - hypothesis category (main or additional)
880 * \param theIndex - index of type of hypothesis to be cerated
882 * Specifies dimension of hypothesis to be created (using sender() method),
883 * specifies its type and calls method for hypothesis creation
885 //================================================================================
886 void SMESHGUI_MeshOp::onCreateHyp( const int theHypType, const int theIndex )
888 // Specifies dimension of hypothesis to be created
889 int aDim = getTabDim( sender(), myDlg );
893 // Specifies type of hypothesis to be created
894 THypDataList& dataList = myAvailableHypData[ aDim ][ theHypType ];
895 if (theIndex < 0 || theIndex >= dataList.count())
897 QString aHypTypeName = dataList[ theIndex ]->TypeName;
900 createHypothesis(aDim, theHypType, aHypTypeName);
903 //================================================================================
905 * Create hypothesis and update dialog.
906 * \param theDim - dimension of hypothesis to be created
907 * \param theType - hypothesis category (algorithm, hypothesis, additional hypothesis)
908 * \param theTypeName - specifies hypothesis to be created
910 //================================================================================
913 QString GetUniqueName (const QStringList& theHypNames,
914 const QString& theName,
915 size_t theIteration = 1)
917 QString aName = theName + "_" + QString::number( theIteration );
918 if ( theHypNames.contains( aName ) )
919 return GetUniqueName( theHypNames, theName, ++theIteration );
924 void SMESHGUI_MeshOp::createHypothesis (const int theDim,
926 const QString& theTypeName)
928 // During a hypothesis creation we might need to select some objects.
929 // Main dialog must not update it's own selected objects in this case.
930 dlg()->deactivateAll();
932 HypothesisData* aData = SMESH::GetHypothesisData(theTypeName.latin1());
936 QStringList aHypNames;
937 TDim2Type2HypList::const_iterator aDimIter = myExistingHyps.begin();
938 for (; aDimIter != myExistingHyps.end(); aDimIter++) {
939 const TType2HypList& aType2HypList = aDimIter.data();
940 TType2HypList::const_iterator aTypeIter = aType2HypList.begin();
941 for (; aTypeIter != aType2HypList.end(); aTypeIter++) {
942 const THypList& aHypList = aTypeIter.data();
943 THypList::const_iterator anIter = aHypList.begin();
944 for (; anIter != aHypList.end(); anIter++) {
945 const THypItem& aHypItem = *anIter;
946 const QString& aHypName = aHypItem.second;
947 aHypNames.append(aHypName);
951 QString aHypName = GetUniqueName( aHypNames, aData->Label);
954 int nbHyp = myExistingHyps[theDim][theType].count();
956 QString aClientLibName = aData->ClientLibName;
957 if (aClientLibName == "") {
958 // Call hypothesis creation server method (without GUI)
959 SMESH::CreateHypothesis(theTypeName, aHypName, false);
961 // Get hypotheses creator client (GUI)
962 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(theTypeName);
966 // When create or edit a submesh, try to initialize a new hypothesis
967 // with values used to mesh a subshape
968 SMESH::SMESH_Hypothesis_var initParamHyp =
969 getInitParamsHypothesis(theTypeName, aData->ServerLibName);
970 myDlg->setEnabled( false );
971 aCreator->create(initParamHyp, aHypName, myDlg);
972 myDlg->setEnabled( true );
974 SMESH::CreateHypothesis(theTypeName, aHypName, false);
978 _PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
980 HypothesisData* algoData = hypData( theDim, Algo, currentHyp( theDim, Algo ));
981 QStringList aNewHyps;
982 existingHyps(theDim, theType, aFather, aNewHyps, myExistingHyps[theDim][theType], algoData);
983 if (aNewHyps.count() > nbHyp) {
984 for (int i = nbHyp; i < aNewHyps.count(); i++)
985 myDlg->tab(theDim)->addHyp(theType, aNewHyps[i]);
989 //================================================================================
991 * \brief Calls plugin methods for hypothesis editing
992 * \param theHypType - specifies whether main hypothesis or additional one
994 * \param theIndex - index of existing hypothesis
996 * Calls plugin methods for hypothesis editing
998 //================================================================================
999 void SMESHGUI_MeshOp::onEditHyp( const int theHypType, const int theIndex )
1001 // Speicfies dimension of hypothesis to be created
1002 int aDim = getTabDim( sender(), myDlg );
1006 const THypList& aList = myExistingHyps[ aDim ][ theHypType ];
1007 if ( theIndex < 0 || theIndex >= aList.count() )
1009 const THypItem& aHypItem = aList[ theIndex ];
1010 SMESH::SMESH_Hypothesis_var aHyp = aHypItem.first;
1011 if ( aHyp->_is_nil() )
1014 CORBA::String_var aTypeName = aHyp->GetName();
1015 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator( aTypeName );
1017 myDlg->setEnabled( false );
1018 aCreator->edit( aHyp.in(), aHypItem.second, dlg() );
1019 myDlg->setEnabled( true );
1023 //================================================================================
1025 * \brief access to hypothesis data
1026 * \param theDim - hyp dimension
1027 * \param theHypType - hyp type (Algo,MainHyp or AddHyp)
1028 * \param theIndex - index in the list
1029 * \retval HypothesisData* - result data, may be 0
1031 //================================================================================
1033 HypothesisData* SMESHGUI_MeshOp::hypData( const int theDim,
1034 const int theHypType,
1037 if ( theDim > -1 && theDim <= SMESH::DIM_3D &&
1038 theHypType > -1 && theHypType < NbHypTypes &&
1039 theIndex > -1 && theIndex < myAvailableHypData[ theDim ][ theHypType ].count() )
1040 return myAvailableHypData[ theDim ][ theHypType ][ theIndex ];
1044 //================================================================================
1046 * \brief Set available algos and hypos according to the selected algorithm
1047 * \param theIndex - algorithm index
1049 //================================================================================
1051 void SMESHGUI_MeshOp::onAlgoSelected( const int theIndex,
1054 if ( myIgnoreAlgoSelection )
1057 int aDim = theDim < 0 ? getTabDim( sender(), myDlg ): theDim;
1061 // find highest available dimension, all algos of this dimension are available for choice
1063 for (int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++)
1064 if (isAccessibleDim( i ))
1069 const bool isSubmesh = ( myToCreate ? !myIsMesh : myDlg->isObjectShown( SMESHGUI_MeshDlg::Mesh ));
1071 HypothesisData* algoData = hypData( aDim, Algo, theIndex );
1072 HypothesisData* algoByDim[4];
1073 algoByDim[ aDim ] = algoData;
1075 QStringList anAvailable;
1076 if ( !algoData ) { // all algos becomes available
1077 availableHyps( aDim, Algo, anAvailable, myAvailableHypData[ aDim ][ Algo ]);
1078 myDlg->tab( aDim )->setAvailableHyps( Algo, anAvailable );
1081 // check that algorithms of other dimentions are compatible with
1084 // 2 loops: backward and forward from algo dimension
1085 for ( int forward = false; forward <= true; ++forward )
1087 int dim = aDim + 1, lastDim = SMESH::DIM_3D, dir = 1;
1089 dim = aDim - 1; lastDim = SMESH::DIM_0D; dir = -1;
1091 HypothesisData* prevAlgo = algoData;
1092 bool noCompatible = false;
1093 for (; dim * dir <= lastDim * dir; dim += dir)
1095 if ( !isAccessibleDim( dim ))
1097 if ( noCompatible ) { // the selected algo has no compatible ones
1098 anAvailable.clear();
1099 myDlg->tab( dim )->setAvailableHyps( Algo, anAvailable );
1100 myAvailableHypData[dim][Algo].clear();
1101 algoByDim[ dim ] = 0;
1104 // get currently selected algo
1105 int algoIndex = currentHyp( dim, Algo );
1106 HypothesisData* curAlgo = hypData( dim, Algo, algoIndex );
1107 if ( curAlgo ) { // some algo selected
1108 if ( !isCompatible( prevAlgo, curAlgo, Algo ))
1111 // set new available algoritms
1112 availableHyps( dim, Algo, anAvailable, myAvailableHypData[dim][Algo], prevAlgo );
1113 HypothesisData* soleCompatible = 0;
1114 if ( anAvailable.count() == 1 )
1115 soleCompatible = myAvailableHypData[dim][Algo][0];
1116 if ( dim == aTopDim && prevAlgo ) // all available algoritms should be selectable any way
1117 availableHyps( dim, Algo, anAvailable, myAvailableHypData[dim][Algo], 0 );
1118 myDlg->tab( dim )->setAvailableHyps( Algo, anAvailable );
1119 noCompatible = anAvailable.isEmpty();
1121 // restore previously selected algo
1122 algoIndex = myAvailableHypData[dim][Algo].findIndex( curAlgo );
1123 if ( !isSubmesh && algoIndex < 0 && soleCompatible && !forward && dim != SMESH::DIM_0D)
1124 // select the sole compatible algo
1125 algoIndex = myAvailableHypData[dim][Algo].findIndex( soleCompatible );
1126 setCurrentHyp( dim, Algo, algoIndex );
1128 // remember current algo
1129 prevAlgo = algoByDim[ dim ] = hypData( dim, Algo, algoIndex );
1133 // set hypotheses corresponding to the found algoritms
1135 _PTR(SObject) pObj = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
1137 for ( int dim = SMESH::DIM_0D; dim <= SMESH::DIM_3D; dim++ )
1139 if ( !isAccessibleDim( dim ))
1141 for ( int type = MainHyp; type < NbHypTypes; type++ )
1143 myAvailableHypData[ dim ][ type ].clear();
1144 QStringList anAvailable, anExisting;
1146 HypothesisData* curAlgo = algoByDim[ dim ];
1147 int hypIndex = currentHyp( dim, type );
1149 SMESH::SMESH_Hypothesis_var curHyp;
1150 if ( hypIndex >= 0 && hypIndex < myExistingHyps[ dim ][ type ].count() )
1151 curHyp = myExistingHyps[ dim ][ type ][ hypIndex ].first;
1153 if ( !myToCreate && !curAlgo && !curHyp->_is_nil() ) { // edition, algo not selected
1154 // try to find algo by selected hypothesis in order to keep it selected
1155 bool algoDeselectedByUser = ( theDim < 0 && aDim == dim );
1156 CORBA::String_var curHypType = curHyp->GetName();
1157 if ( !algoDeselectedByUser &&
1158 myObjHyps[ dim ][ type ].count() > 0 &&
1159 curHypType == myObjHyps[ dim ][ type ].first().first->GetName())
1161 CORBA::String_var aName = curHyp->GetName();
1162 HypothesisData* hypData = SMESH::GetHypothesisData( aName );
1163 for (int i = 0; i < myAvailableHypData[ dim ][ Algo ].count(); ++i) {
1164 curAlgo = myAvailableHypData[ dim ][ Algo ][ i ];
1165 if (curAlgo && hypData && isCompatible(curAlgo, hypData, type))
1172 // get hyps compatible with curAlgo
1175 // check if a selected hyp is compatible with the curAlgo
1176 if ( !curHyp->_is_nil() ) {
1177 CORBA::String_var aName = curHyp->GetName();
1178 HypothesisData* hypData = SMESH::GetHypothesisData( aName );
1179 if ( !isCompatible( curAlgo, hypData, type ))
1180 curHyp = SMESH::SMESH_Hypothesis::_nil();
1182 existingHyps( dim, type, pObj, anExisting, myExistingHyps[ dim ][ type ], curAlgo);
1183 availableHyps( dim, type, anAvailable, myAvailableHypData[ dim ][ type ], curAlgo);
1185 // set list of hypotheses
1186 myDlg->tab( dim )->setAvailableHyps( type, anAvailable );
1187 myDlg->tab( dim )->setExistingHyps( type, anExisting );
1189 // set current existing hypothesis
1190 if ( !curHyp->_is_nil() && !anExisting.isEmpty() )
1191 hypIndex = this->find( curHyp, myExistingHyps[ dim ][ type ]);
1194 if ( !isSubmesh && hypIndex < 0 && anExisting.count() == 1 ) {
1195 // none is yet selected => select the sole existing if it is not optional
1196 CORBA::String_var hypTypeName = myExistingHyps[ dim ][ type ].first().first->GetName();
1197 bool isOptional = true;
1198 if ( algoByDim[ dim ] &&
1199 SMESH::IsAvailableHypothesis( algoByDim[ dim ], hypTypeName.in(), isOptional ) &&
1203 setCurrentHyp( dim, type, hypIndex );
1208 //================================================================================
1210 * \brief Creates and selects hypothesis of hypotheses set
1211 * \param theSetName - The name of hypotheses set
1213 //================================================================================
1214 void SMESHGUI_MeshOp::onHypoSet( const QString& theSetName )
1216 HypothesesSet* aHypoSet = SMESH::GetHypothesesSet(theSetName);
1217 if (!aHypoSet) return;
1220 for (int dim = SMESH::DIM_0D; dim <= SMESH::DIM_3D; dim++) {
1221 setCurrentHyp(dim, Algo, -1);
1222 setCurrentHyp(dim, AddHyp, -1);
1223 setCurrentHyp(dim, MainHyp, -1);
1226 for (int aHypType = Algo; aHypType < AddHyp; aHypType++) {
1227 bool isAlgo = (aHypType == Algo);
1229 // set hyps from the set
1230 QStringList* aHypoList = isAlgo ? &aHypoSet->AlgoList : &aHypoSet->HypoList;
1231 for (int i = 0, n = aHypoList->count(); i < n; i++) {
1232 const QString& aHypoTypeName = (*aHypoList)[ i ];
1233 HypothesisData* aHypData = SMESH::GetHypothesisData(aHypoTypeName);
1237 int aDim = aHypData->Dim[0];
1238 // create or/and set
1240 int index = myAvailableHypData[aDim][Algo].findIndex( aHypData );
1242 QStringList anAvailable;
1243 availableHyps( aDim, Algo, anAvailable, myAvailableHypData[aDim][Algo] );
1244 myDlg->tab( aDim )->setAvailableHyps( Algo, anAvailable );
1245 index = myAvailableHypData[aDim][Algo].findIndex( aHypData );
1247 setCurrentHyp( aDim, Algo, index );
1248 onAlgoSelected( index, aDim );
1251 bool mainHyp = true;
1252 QStringList anAvailable;
1253 availableHyps( aDim, MainHyp, anAvailable, myAvailableHypData[aDim][MainHyp] );
1254 myDlg->tab( aDim )->setAvailableHyps( MainHyp, anAvailable );
1255 int index = myAvailableHypData[aDim][MainHyp].findIndex( aHypData );
1258 index = myAvailableHypData[aDim][AddHyp].findIndex( aHypData );
1261 createHypothesis(aDim, mainHyp ? MainHyp : AddHyp, aHypoTypeName);
1263 } // loop on hypos in the set
1264 } // loop on algo/hypo
1267 //================================================================================
1269 * \brief Creates mesh
1270 * \param theMess - Output parameter intended for returning error message
1271 * \retval bool - TRUE if mesh is created, FALSE otherwise
1275 //================================================================================
1276 bool SMESHGUI_MeshOp::createMesh( QString& theMess )
1280 //QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
1281 //QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
1284 myDlg->selectedObject( SMESHGUI_MeshDlg::Geom, aList );
1285 QStringList::Iterator it = aList.begin();
1286 for (; it!=aList.end(); it++)
1288 QString aGeomEntry = *it;
1289 _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.latin1() );
1290 GEOM::GEOM_Object_var aGeomVar =
1291 GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
1293 SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
1294 if ( aSMESHGen->_is_nil() )
1297 SUIT_OverrideCursor aWaitCursor;
1300 SMESH::SMESH_Mesh_var aMeshVar = aSMESHGen->CreateMesh( aGeomVar );
1301 if ( aMeshVar->_is_nil() )
1303 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar.in() );
1305 SMESH::SetName( aMeshSO, myDlg->objectText( SMESHGUI_MeshDlg::Obj ).latin1() );
1307 for ( int aDim = SMESH::DIM_0D; aDim <= SMESH::DIM_3D; aDim++ ) {
1308 if ( !isAccessibleDim( aDim )) continue;
1310 // assign hypotheses
1311 for ( int aHypType = MainHyp; aHypType <= AddHyp; aHypType++ ) {
1312 int aHypIndex = currentHyp( aDim, aHypType );
1313 if ( aHypIndex >= 0 && aHypIndex < myExistingHyps[ aDim ][ aHypType ].count() ) {
1314 SMESH::SMESH_Hypothesis_var aHypVar = myExistingHyps[ aDim ][ aHypType ][ aHypIndex ].first;
1315 if ( !aHypVar->_is_nil() )
1316 SMESH::AddHypothesisOnMesh( aMeshVar, aHypVar );
1319 // find or create algorithm
1320 SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( aDim );
1321 if ( !anAlgoVar->_is_nil() )
1322 SMESH::AddHypothesisOnMesh( aMeshVar, anAlgoVar );
1329 //================================================================================
1331 * \brief Creates sub-mesh
1332 * \param theMess - Output parameter intended for returning error message
1333 * \retval bool - TRUE if sub-mesh is created, FALSE otherwise
1337 //================================================================================
1338 bool SMESHGUI_MeshOp::createSubMesh( QString& theMess )
1342 SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
1343 if ( aSMESHGen->_is_nil() )
1347 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
1348 _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() );
1349 SMESH::SMESH_Mesh_var aMeshVar =
1350 SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() );
1351 if (aMeshVar->_is_nil())
1354 // GEOM shape of the main mesh
1355 GEOM::GEOM_Object_var mainGeom = aMeshVar->GetShapeToMesh();
1357 // Name for the new sub-mesh
1358 QString aName = myDlg->objectText(SMESHGUI_MeshDlg::Obj);
1361 GEOM::GEOM_Object_var aGeomVar;
1363 myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
1364 if (aGEOMs.count() == 1)
1366 //QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
1367 QString aGeomEntry = aGEOMs.first();
1368 _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.latin1() );
1369 aGeomVar = GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
1371 else if (aGEOMs.count() > 1)
1373 // create a GEOM group
1374 GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
1375 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1376 if (!geomGen->_is_nil() && aStudy) {
1377 GEOM::GEOM_IGroupOperations_var op =
1378 geomGen->GetIGroupOperations(aStudy->StudyId());
1379 if (!op->_is_nil()) {
1380 // check and add all selected GEOM objects: they must be
1381 // a sub-shapes of the main GEOM and must be of one type
1383 TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE;
1384 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1385 aSeq->length(aGEOMs.count());
1386 QStringList::const_iterator aSubShapesIter = aGEOMs.begin();
1387 for (; aSubShapesIter != aGEOMs.end(); aSubShapesIter++, iSubSh++) {
1388 QString aSubGeomEntry = (*aSubShapesIter);
1389 _PTR(SObject) pSubGeom = studyDS()->FindObjectID(aSubGeomEntry.latin1());
1390 GEOM::GEOM_Object_var aSubGeomVar =
1391 GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
1392 TopAbs_ShapeEnum aSubShapeType = (TopAbs_ShapeEnum)aSubGeomVar->GetShapeType();
1394 aGroupType = aSubShapeType;
1396 if (aSubShapeType != aGroupType)
1397 aGroupType = TopAbs_SHAPE;
1399 aSeq[iSubSh] = aSubGeomVar;
1402 GEOM::GEOM_Object_var aGroupVar = op->CreateGroup(mainGeom, aGroupType);
1403 op->UnionList(aGroupVar, aSeq);
1406 aGeomVar = aGroupVar;
1408 // publish the GEOM group in study
1409 QString aNewGeomGroupName ("Auto_group_for_");
1410 aNewGeomGroupName += aName;
1411 SALOMEDS::SObject_var aNewGroupSO =
1412 geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGeomVar, aNewGeomGroupName, mainGeom);
1419 if (aGeomVar->_is_nil())
1422 SUIT_OverrideCursor aWaitCursor;
1425 SMESH::SMESH_subMesh_var aSubMeshVar = aMeshVar->GetSubMesh( aGeomVar, aName.latin1() );
1427 for ( int aDim = SMESH::DIM_0D; aDim <= SMESH::DIM_3D; aDim++ )
1429 if ( !isAccessibleDim( aDim )) continue;
1431 // find or create algorithm
1432 SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( aDim );
1433 if ( !anAlgoVar->_is_nil() )
1434 SMESH::AddHypothesisOnSubMesh( aSubMeshVar, anAlgoVar );
1435 // assign hypotheses
1436 for ( int aHypType = MainHyp; aHypType <= AddHyp; aHypType++ )
1438 int aHypIndex = currentHyp( aDim, aHypType );
1439 if ( aHypIndex >= 0 && aHypIndex < myExistingHyps[ aDim ][ aHypType ].count() )
1441 SMESH::SMESH_Hypothesis_var aHypVar =
1442 myExistingHyps[ aDim ][ aHypType ][ aHypIndex ].first;
1443 if ( !aHypVar->_is_nil() )
1444 SMESH::AddHypothesisOnSubMesh( aSubMeshVar, aHypVar );
1449 // deselect geometry: next submesh should be created on other subshape
1450 myDlg->clearSelection( SMESHGUI_MeshDlg::Geom );
1451 selectObject( _PTR(SObject)() );
1457 //================================================================================
1459 * \brief Gets current hypothesis or algorithms
1460 * \param theDim - dimension of hypothesis or algorithm
1461 * \param theHypType - Type of hypothesis (Algo, MainHyp, AddHyp)
1462 * \retval int - current hypothesis or algorithms
1464 * Gets current hypothesis or algorithms
1466 //================================================================================
1467 int SMESHGUI_MeshOp::currentHyp( const int theDim, const int theHypType ) const
1469 return myDlg->tab( theDim )->currentHyp( theHypType ) - 1;
1472 //================================================================================
1474 * \brief Returns true if hypotheses of given dim can be assigned
1475 * \param theDim - hypotheses dimension
1476 * \retval bool - result
1478 //================================================================================
1479 bool SMESHGUI_MeshOp::isAccessibleDim( const int theDim ) const
1481 return myDlg->tab( theDim )->isEnabled();
1484 //================================================================================
1486 * \brief Sets current hypothesis or algorithms
1487 * \param theDim - dimension of hypothesis or algorithm
1488 * \param theHypType - Type of hypothesis (Algo, MainHyp, AddHyp)
1489 * \param theIndex - Index of hypothesis
1491 * Gets current hypothesis or algorithms
1493 //================================================================================
1494 void SMESHGUI_MeshOp::setCurrentHyp( const int theDim,
1495 const int theHypType,
1496 const int theIndex )
1498 myIgnoreAlgoSelection = true;
1499 myDlg->tab( theDim )->setCurrentHyp( theHypType, theIndex + 1 );
1500 myIgnoreAlgoSelection = false;
1503 //================================================================================
1505 * \brief Generates default and sets mesh/submesh name
1507 * Generates and sets default mesh/submesh name(Mesh_1, Mesh_2, etc.)
1509 //================================================================================
1510 void SMESHGUI_MeshOp::setDefaultName() const
1514 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1516 QString aPrefix = tr( myIsMesh ? "SMESH_OBJECT_MESH" : "SMESH_SUBMESH" ) + "_";
1517 _PTR(SObject) anObj;
1520 aResName = aPrefix + QString::number( i++ );
1521 anObj = aStudy->FindObject( aResName.latin1() );
1525 QLineEdit* aControl = ( QLineEdit* )myDlg->objectWg(
1526 SMESHGUI_MeshDlg::Obj, SMESHGUI_MeshDlg::Control );
1527 aControl->setText( aResName );
1530 //================================================================================
1532 * \brief Gets algorithm or creates it if necessary
1533 * \param theDim - specifies dimension of returned hypotheses/algorifms
1534 * \retval SMESH::SMESH_Hypothesis_var - algorithm
1536 * Gets algorithm or creates it if necessary
1538 //================================================================================
1539 SMESH::SMESH_Hypothesis_var SMESHGUI_MeshOp::getAlgo( const int theDim )
1541 SMESH::SMESH_Hypothesis_var anAlgoVar;
1543 // get type of the selected algo
1544 int aHypIndex = currentHyp( theDim, Algo );
1545 THypDataList& dataList = myAvailableHypData[ theDim ][ Algo ];
1546 if ( aHypIndex < 0 || aHypIndex >= dataList.count())
1548 QString aHypName = dataList[ aHypIndex ]->TypeName;
1550 // get existing algoritms
1551 _PTR(SObject) pObj = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
1553 existingHyps( theDim, Algo, pObj, tmp, myExistingHyps[ theDim ][ Algo ]);
1555 // look for anexisting algo of such a type
1556 THypList& aHypVarList = myExistingHyps[ theDim ][ Algo ];
1557 THypList::iterator anIter = aHypVarList.begin();
1558 for (; anIter != aHypVarList.end(); anIter++)
1560 SMESH::SMESH_Hypothesis_var aHypVar = (*anIter).first;
1561 CORBA::String_var aName = aHypVar->GetName();
1562 if ( !aHypVar->_is_nil() && aHypName == aName )
1564 anAlgoVar = aHypVar;
1569 if (anAlgoVar->_is_nil()) {
1570 HypothesisData* aHypData = SMESH::GetHypothesisData( aHypName );
1572 QString aClientLibName = aHypData->ClientLibName;
1573 if (aClientLibName == "") {
1574 // Call hypothesis creation server method (without GUI)
1575 SMESH::CreateHypothesis(aHypName, aHypData->Label, true);
1577 // Get hypotheses creator client (GUI)
1578 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypName);
1582 aCreator->create(true, aHypName, myDlg);
1584 SMESH::CreateHypothesis(aHypName, aHypData->Label, true);
1586 QStringList tmpList;
1587 _PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" );
1588 existingHyps( theDim, Algo, aFather, tmpList, myExistingHyps[ theDim ][ Algo ] );
1591 THypList& aNewHypVarList = myExistingHyps[ theDim ][ Algo ];
1592 for ( anIter = aNewHypVarList.begin(); anIter != aNewHypVarList.end(); ++anIter )
1594 SMESH::SMESH_Hypothesis_var aHypVar = (*anIter).first;
1595 CORBA::String_var aName = aHypVar->GetName();
1596 if ( !aHypVar->_is_nil() && aHypName == aName )
1598 anAlgoVar = aHypVar;
1604 return anAlgoVar._retn();
1607 //================================================================================
1609 * \brief Reads parameters of edited mesh and assigns them to the dialog
1611 * Reads parameters of edited mesh and assigns them to the dialog (called when
1612 * mesh is edited only)
1614 //================================================================================
1615 void SMESHGUI_MeshOp::readMesh()
1617 QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
1618 _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.latin1() );
1622 if (myIsOnGeometry) {
1623 // Get name of mesh if current object is sub-mesh
1624 SMESH::SMESH_subMesh_var aSubMeshVar =
1625 SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
1626 if ( !aSubMeshVar->_is_nil() )
1628 SMESH::SMESH_Mesh_var aMeshVar = aSubMeshVar->GetFather();
1629 if ( !aMeshVar->_is_nil() )
1631 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar );
1632 QString aMeshName = name( aMeshSO );
1633 myDlg->setObjectText( SMESHGUI_MeshDlg::Mesh, aMeshName );
1637 // Get name of geometry object
1638 GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
1639 if ( !aGeomVar->_is_nil() )
1641 _PTR(SObject) aGeomSO = studyDS()->FindObjectID( aGeomVar->GetStudyEntry() );
1642 QString aShapeName = name( aGeomSO );
1643 myDlg->setObjectText( SMESHGUI_MeshDlg::Geom, aShapeName );
1647 // Get hypotheses and algorithms assigned to the mesh/sub-mesh
1648 QStringList anExisting;
1649 const int aDim = ( myIsOnGeometry ) ? SMESH::DIM_0D : SMESH::DIM_3D;
1650 for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
1653 existingHyps( dim, Algo, pObj, anExisting, myObjHyps[ dim ][ Algo ] );
1654 // find algo index among available ones
1656 if ( myObjHyps[ dim ][ Algo ].count() > 0 )
1658 SMESH::SMESH_Hypothesis_var aVar = myObjHyps[ dim ][ Algo ].first().first;
1659 CORBA::String_var aHypTypeName = aVar->GetName();
1660 HypothesisData* algoData = SMESH::GetHypothesisData( aHypTypeName );
1661 aHypIndex = myAvailableHypData[ dim ][ Algo ].findIndex ( algoData );
1662 // if ( aHypIndex < 0 && algoData ) {
1663 // // assigned algo is incompatible with other algorithms
1664 // myAvailableHypData[ dim ][ Algo ].push_back( algoData );
1665 // aHypIndex = myAvailableHypData[ dim ][ hypType ].count() - 1;
1668 setCurrentHyp( dim, Algo, aHypIndex );
1669 // set existing and available hypothesis according to the selected algo
1670 onAlgoSelected( aHypIndex, dim );
1674 bool hypWithoutAlgo = false;
1675 for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
1677 for ( int hypType = MainHyp; hypType <= AddHyp; hypType++ )
1680 existingHyps( dim, hypType, pObj, anExisting, myObjHyps[ dim ][ hypType ] );
1681 // find index of requered hypothesis among existing ones for this dimension and type
1683 if ( myObjHyps[ dim ][ hypType ].count() > 0 ) {
1684 aHypIndex = find( myObjHyps[ dim ][ hypType ].first().first,
1685 myExistingHyps[ dim ][ hypType ] );
1686 if ( aHypIndex < 0 ) {
1687 // assigned hypothesis is incompatible with the algorithm
1688 if ( currentHyp( dim, Algo ) < 0 )
1689 { // none algo selected; it is edition for sure, of submesh maybe
1690 hypWithoutAlgo = true;
1691 myExistingHyps[ dim ][ hypType ].push_back( myObjHyps[ dim ][ hypType ].first() );
1692 aHypIndex = myExistingHyps[ dim ][ hypType ].count() - 1;
1693 myDlg->tab( dim )->setExistingHyps( hypType, anExisting );
1697 setCurrentHyp( dim, hypType, aHypIndex );
1700 // make available other hyps of same type as one without algo
1701 if ( hypWithoutAlgo )
1702 onAlgoSelected( currentHyp( 0, Algo ), 0 );
1705 //================================================================================
1707 * \brief Gets name of object
1708 * \param theSO - SObject
1709 * \retval QString - name of object
1711 * Gets name of object
1713 //================================================================================
1714 QString SMESHGUI_MeshOp::name( _PTR(SObject) theSO ) const
1719 _PTR(GenericAttribute) anAttr;
1720 _PTR(AttributeName) aNameAttr;
1721 if ( theSO->FindAttribute( anAttr, "AttributeName" ) )
1724 aResName = aNameAttr->Value().c_str();
1730 //================================================================================
1732 * \brief Finds hypothesis in input list
1733 * \param theHyp - hypothesis to be found
1734 * \param theHypList - input list of hypotheses
1735 * \retval int - index of hypothesis or -1 if it is not found
1737 * Finds position of hypothesis in input list
1739 //================================================================================
1740 int SMESHGUI_MeshOp::find( const SMESH::SMESH_Hypothesis_var& theHyp,
1741 const THypList& theHypList ) const
1744 if ( !theHyp->_is_nil() )
1747 THypList::const_iterator anIter = theHypList.begin();
1748 for (; anIter != theHypList.end(); ++ anIter)
1750 if ( theHyp->_is_equivalent( (*anIter).first ) )
1761 //================================================================================
1763 * \brief Edits mesh or sub-mesh
1764 * \param theMess - Output parameter intended for returning error message
1765 * \retval bool - TRUE if mesh is edited succesfully, FALSE otherwise
1767 * Assigns new name hypotheses and algoriths to the mesh or sub-mesh
1769 //================================================================================
1770 bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess )
1774 SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
1775 if ( aSMESHGen->_is_nil() )
1778 QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
1779 _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.latin1() );
1783 SUIT_OverrideCursor aWaitCursor;
1786 QString aName = myDlg->objectText( SMESHGUI_MeshDlg::Obj );
1787 SMESH::SetName( pObj, aName.latin1() );
1788 int aDim = ( myIsOnGeometry ) ? SMESH::DIM_0D : SMESH::DIM_3D;
1790 // First, remove old algos in order to avoid messages on algorithm hiding
1791 for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
1793 if ( isAccessibleDim( dim ) && myObjHyps[ dim ][ Algo ].count() > 0 )
1795 SMESH::SMESH_Hypothesis_var anOldAlgo = myObjHyps[ dim ][ Algo ].first().first;
1796 SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( dim );
1797 if ( anAlgoVar->_is_nil() || // no new algo selected or
1798 strcmp(anOldAlgo->GetName(), anAlgoVar->GetName()) ) // algo change
1800 // remove old algorithm
1801 SMESH::RemoveHypothesisOrAlgorithmOnMesh ( pObj, myObjHyps[ dim ][ Algo ].first().first );
1802 myObjHyps[ dim ][ Algo ].clear();
1807 // Assign new algorithms and hypotheses
1808 for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
1810 if ( !isAccessibleDim( dim )) continue;
1812 // find or create algorithm
1813 SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( dim );
1815 // assign new algorithm
1816 if ( !anAlgoVar->_is_nil() && // some algo selected and
1817 myObjHyps[ dim ][ Algo ].count() == 0 ) // no algo assigned
1819 SALOMEDS_SObject* aSObject = _CAST(SObject, pObj);
1820 CORBA::Object_var anObject = aSObject->GetObject();
1821 SMESH::SMESH_Mesh_var aMeshVar = SMESH::SMESH_Mesh::_narrow( anObject );
1822 bool isMesh = !aMeshVar->_is_nil();
1824 SMESH::AddHypothesisOnMesh( aMeshVar, anAlgoVar );
1826 SMESH::SMESH_subMesh_var aVar =
1827 SMESH::SMESH_subMesh::_narrow( _CAST(SObject,pObj)->GetObject() );
1828 if ( !aVar->_is_nil() )
1829 SMESH::AddHypothesisOnSubMesh( aVar, anAlgoVar );
1831 myObjHyps[ dim ][ Algo ].append( THypItem( anAlgoVar, aName) );
1834 // assign hypotheses
1835 for ( int hypType = MainHyp; hypType <= AddHyp; hypType++ )
1837 int aNewHypIndex = currentHyp( dim, hypType );
1838 int anOldHypIndex = -1;
1840 // remove old hypotheses
1841 if ( myObjHyps[ dim ][ hypType ].count() > 0 )
1843 anOldHypIndex = find( myObjHyps[ dim ][ hypType ].first().first ,
1844 myExistingHyps[ dim ][ hypType ] );
1845 if ( aNewHypIndex != anOldHypIndex || // different hyps
1846 anOldHypIndex == -1 ) // hyps of different algos
1848 SMESH::RemoveHypothesisOrAlgorithmOnMesh
1849 ( pObj, myObjHyps[ dim ][ hypType ].first().first );
1850 myObjHyps[ dim ][ hypType ].clear();
1854 // assign new hypotheses
1855 if ( aNewHypIndex != anOldHypIndex && aNewHypIndex != -1 )
1857 SMESH::SMESH_Mesh_var aMeshVar =
1858 SMESH::SMESH_Mesh::_narrow( _CAST(SObject,pObj)->GetObject() );
1859 bool isMesh = !aMeshVar->_is_nil();
1862 SMESH::AddHypothesisOnMesh
1863 (aMeshVar, myExistingHyps[ dim ][ hypType ][ aNewHypIndex ].first );
1867 SMESH::SMESH_subMesh_var aVar =
1868 SMESH::SMESH_subMesh::_narrow( _CAST(SObject,pObj)->GetObject() );
1869 if ( !aVar->_is_nil() )
1870 SMESH::AddHypothesisOnSubMesh
1871 ( aVar, myExistingHyps[ dim ][ hypType ][ aNewHypIndex ].first );
1874 // reread all hypotheses of mesh if necessary
1875 QStringList anExisting;
1876 existingHyps( dim, hypType, pObj, anExisting, myObjHyps[ dim ][ hypType ] );
1883 //================================================================================
1885 * \brief Verifies whether given operator is valid for this one
1886 * \param theOtherOp - other operation
1887 * \return Returns TRUE if the given operator is valid for this one, FALSE otherwise
1889 * method redefined from base class verifies whether given operator is valid for
1890 * this one (i.e. can be started "above" this operator). In current implementation method
1891 * retuns false if theOtherOp operation is not intended for deleting objects or mesh
1894 //================================================================================
1895 bool SMESHGUI_MeshOp::isValid( SUIT_Operation* theOp ) const
1897 return SMESHGUI_Operation::isValid( theOp ) && !theOp->inherits( "SMESHGUI_MeshOp" );
1900 //================================================================================
1902 * \brief SLOT. Is called when the user selects a way of geometry selection
1903 * \param theByMesh - true if the user wants to find geometry by mesh element
1905 //================================================================================
1907 void SMESHGUI_MeshOp::onGeomSelectionByMesh( bool theByMesh )
1910 if ( !myShapeByMeshOp ) {
1911 myShapeByMeshOp = new SMESHGUI_ShapeByMeshOp();
1912 connect(myShapeByMeshOp, SIGNAL(committed(SUIT_Operation*)),
1913 SLOT(onPublishShapeByMeshDlg(SUIT_Operation*)));
1914 connect(myShapeByMeshOp, SIGNAL(aborted(SUIT_Operation*)),
1915 SLOT(onCloseShapeByMeshDlg(SUIT_Operation*)));
1917 // set mesh object to SMESHGUI_ShapeByMeshOp and start it
1918 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
1919 if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() )) {
1920 SMESH::SMESH_Mesh_var aMeshVar =
1921 SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() );
1922 if ( !aMeshVar->_is_nil() ) {
1923 myDlg->hide(); // stop processing selection
1924 myShapeByMeshOp->setModule( getSMESHGUI() );
1925 myShapeByMeshOp->setStudy( 0 ); // it's really necessary
1926 myShapeByMeshOp->SetMesh( aMeshVar );
1927 myShapeByMeshOp->start();
1933 //================================================================================
1935 * \brief SLOT. Is called when Ok is pressed in SMESHGUI_ShapeByMeshDlg
1937 //================================================================================
1939 void SMESHGUI_MeshOp::onPublishShapeByMeshDlg(SUIT_Operation* op)
1941 if ( myShapeByMeshOp == op ) {
1942 SMESHGUI::GetSMESHGUI()->getApp()->updateObjectBrowser(); //MZN: 24.11.2006 IPAL13980 - Object Browser update added
1944 // Select a found geometry object
1945 GEOM::GEOM_Object_var aGeomVar = myShapeByMeshOp->GetShape();
1946 if ( !aGeomVar->_is_nil() )
1948 QString ID = aGeomVar->GetStudyEntry();
1949 if ( _PTR(SObject) aGeomSO = studyDS()->FindObjectID( ID.latin1() )) {
1950 selectObject( aGeomSO );
1957 //================================================================================
1959 * \brief SLOT. Is called when Close is pressed in SMESHGUI_ShapeByMeshDlg
1961 //================================================================================
1963 void SMESHGUI_MeshOp::onCloseShapeByMeshDlg(SUIT_Operation* op)
1965 if ( myShapeByMeshOp == op && myDlg ) {
1970 //================================================================================
1972 * \brief Selects a SObject
1973 * \param theSObj - the SObject to select
1975 //================================================================================
1977 void SMESHGUI_MeshOp::selectObject( _PTR(SObject) theSObj ) const
1979 if ( LightApp_SelectionMgr* sm = selectionMgr() ) {
1980 SALOME_ListIO anIOList;
1982 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject
1983 ( theSObj->GetID().c_str(), "SMESH", theSObj->GetName().c_str() );
1984 anIOList.Append( anIO );
1986 sm->setSelectedObjects( anIOList, false );