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>
65 #include <TopoDS_Shape.hxx>
66 #include <TopoDS_Shell.hxx>
67 #include <TopExp_Explorer.hxx>
70 #include <SALOMEconfig.h>
71 #include CORBA_CLIENT_HEADER(SMESH_Gen)
73 //================================================================================
76 * \param theToCreate - if this parameter is true then operation is used for creation,
77 * for editing otherwise
79 * Initialize operation
81 //================================================================================
82 SMESHGUI_MeshOp::SMESHGUI_MeshOp( const bool theToCreate, const bool theIsMesh )
83 : SMESHGUI_SelectionOp(),
84 myToCreate( theToCreate ),
85 myIsMesh( theIsMesh ),
89 if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists
90 GeometryGUI::InitGeomGen();
91 myIsOnGeometry = true;
94 //================================================================================
98 //================================================================================
99 SMESHGUI_MeshOp::~SMESHGUI_MeshOp()
105 //================================================================================
107 * \brief Gets dialog of this operation
108 * \retval LightApp_Dialog* - pointer to dialog of this operation
110 //================================================================================
111 LightApp_Dialog* SMESHGUI_MeshOp::dlg() const
116 //================================================================================
118 * \brief Creates or edits mesh
119 * \retval bool - TRUE if operation is performed successfully, FALSE otherwise
121 * Virtual slot redefined from the base class called when "Apply" button is clicked
122 * creates or edits mesh
124 //================================================================================
125 bool SMESHGUI_MeshOp::onApply()
131 if ( !isValid( aMess ) )
135 SUIT_MessageBox::warning( myDlg, tr( "SMESH_WRN_WARNING" ), aMess );
139 bool aResult = false;
143 if ( myToCreate && myIsMesh )
144 aResult = createMesh( aMess );
145 if ( myToCreate && !myIsMesh )
146 aResult = createSubMesh( aMess );
147 else if ( !myToCreate )
148 aResult = editMeshOrSubMesh( aMess );
150 update( UF_ObjBrowser | UF_Model );
152 catch ( const SALOME::SALOME_Exception& S_ex )
154 SalomeApp_Tools::QtCatchCorbaException( S_ex );
170 aMess = tr( "SMESH_OPERATION_FAILED" );
171 SUIT_MessageBox::warning( myDlg, tr( "SMESH_ERROR" ), aMess );
177 //================================================================================
179 * \brief Creates dialog if necessary and shows it
181 * Virtual method redefined from base class called when operation is started creates
182 * dialog if necessary and shows it, activates selection
184 //================================================================================
185 void SMESHGUI_MeshOp::startOperation()
189 myDlg = new SMESHGUI_MeshDlg( myToCreate, myIsMesh );
190 for ( int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++ )
192 connect( myDlg->tab( i ), SIGNAL( createHyp( const int, const int ) ),
193 this, SLOT( onCreateHyp( const int, const int ) ) );
194 connect( myDlg->tab( i ), SIGNAL( editHyp( const int, const int ) ),
195 this, SLOT( onEditHyp( const int, const int ) ) );
196 connect( myDlg->tab( i ), SIGNAL( selectAlgo( const int ) ),
197 this, SLOT( onAlgoSelected( const int ) ) );
199 connect( myDlg, SIGNAL( hypoSet( const QString& )), SLOT( onHypoSet( const QString& )));
200 connect( myDlg, SIGNAL( geomSelectionByMesh( bool )), SLOT( onGeomSelectionByMesh( bool )));
203 if ( myIsMesh ) myHelpFileName = "constructing_meshes_page.html";
204 else myHelpFileName = "constructing_submeshes_page.html";
205 else myHelpFileName = "editing_meshes_page.html";
207 SMESHGUI_SelectionOp::startOperation();
209 // iterate through dimensions and get available algoritms, set them to the dialog
210 _PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" );
211 for ( int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++ )
213 SMESHGUI_MeshTab* aTab = myDlg->tab( i );
215 // clear available hypotheses
216 aTab->setAvailableHyps( MainHyp, hypList );
217 aTab->setAvailableHyps( AddHyp, hypList );
218 aTab->setExistingHyps( MainHyp, hypList );
219 aTab->setExistingHyps( AddHyp, hypList );
220 myExistingHyps[ i ][ MainHyp ].clear();
221 myExistingHyps[ i ][ AddHyp ].clear();
223 availableHyps( i, Algo, hypList, myAvailableHypData[i][Algo] );
224 aTab->setAvailableHyps( Algo, hypList );
229 myDlg->activateObject( myIsMesh ? SMESHGUI_MeshDlg::Geom : SMESHGUI_MeshDlg::Mesh );
232 myDlg->activateObject( SMESHGUI_MeshDlg::Obj );
234 myDlg->setHypoSets( SMESH::GetHypothesesSets() );
236 myDlg->setCurrentTab( SMESH::DIM_3D );
241 myIgnoreAlgoSelection = false;
244 //================================================================================
246 * \brief Creates selection filter
247 * \param theId - identifier of current selection widget
248 * \retval SUIT_SelectionFilter* - pointer to the created filter or null
250 * Creates selection filter in accordance with identifier of current selection widget
252 //================================================================================
253 SUIT_SelectionFilter* SMESHGUI_MeshOp::createFilter( const int theId ) const
255 if ( theId == SMESHGUI_MeshDlg::Geom )
257 // TColStd_MapOfInteger allTypesMap;
258 // for ( int i = 0; i < 10; i++ )
259 // allTypesMap.Add( i );
260 // return new SMESH_NumberFilter( "GEOM", TopAbs_SHAPE, 0, allTypesMap );
261 return new GEOM_SelectionFilter( (SalomeApp_Study*)study(), true );
263 else if ( theId == SMESHGUI_MeshDlg::Obj && !myToCreate )
264 return new SMESH_TypeFilter( MESHorSUBMESH );
265 else if ( theId == SMESHGUI_MeshDlg::Mesh )
266 return new SMESH_TypeFilter( MESH );
271 //================================================================================
273 * \brief check if selected shape is a subshape of the shape to mesh
274 * \retval bool - check result
276 //================================================================================
278 bool SMESHGUI_MeshOp::isSubshapeOk() const
280 if ( !myToCreate || myIsMesh ) // not submesh creation
284 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
285 _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
286 if (!pMesh) return false;
288 SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
289 if (mesh->_is_nil()) return false;
291 // main shape of the mesh
292 GEOM::GEOM_Object_var mainGeom = mesh->GetShapeToMesh();
293 if (mainGeom->_is_nil()) return false;
297 myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
299 if (aGEOMs.count() > 0) {
300 GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
301 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
302 if (geomGen->_is_nil() || !aStudy) return false;
304 GEOM::GEOM_IGroupOperations_var op =
305 geomGen->GetIGroupOperations(aStudy->StudyId());
306 if (op->_is_nil()) return false;
308 // check all selected shapes
309 QStringList::const_iterator aSubShapesIter = aGEOMs.begin();
310 for ( ; aSubShapesIter != aGEOMs.end(); aSubShapesIter++) {
311 QString aSubGeomEntry = (*aSubShapesIter);
312 _PTR(SObject) pSubGeom = studyDS()->FindObjectID(aSubGeomEntry.toLatin1().data());
313 if (!pSubGeom) return false;
315 GEOM::GEOM_Object_var aSubGeomVar =
316 GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
317 if (aSubGeomVar->_is_nil()) return false;
319 // skl for NPAL14695 - implementation of searching of mainObj
320 GEOM::GEOM_Object_var mainObj = op->GetMainShape(aSubGeomVar);
321 //if (mainObj->_is_nil() ||
322 // string(mainObj->GetEntry()) != string(mainGeom->GetEntry())) return false;
324 if (mainObj->_is_nil())
326 if (std::string(mainObj->GetEntry()) == std::string(mainGeom->GetEntry()))
328 mainObj = op->GetMainShape(mainObj);
337 //================================================================================
339 * \brief find an existing submesh by the selected shape
340 * \retval _PTR(SObject) - the found submesh SObject
342 //================================================================================
344 _PTR(SObject) SMESHGUI_MeshOp::getSubmeshByGeom() const
346 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
347 QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
348 _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
349 _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.toLatin1().data() );
350 if ( pMesh && pGeom ) {
351 GEOM::GEOM_Object_var geom = SMESH::SObjectToInterface<GEOM::GEOM_Object>( pGeom );
352 if ( !geom->_is_nil() ) {
354 switch ( geom->GetShapeType() ) {
355 case GEOM::VERTEX: tag = SMESH::Tag_SubMeshOnVertex; break;
356 case GEOM::EDGE: tag = SMESH::Tag_SubMeshOnEdge; break;
357 case GEOM::WIRE: tag = SMESH::Tag_SubMeshOnWire; break;
358 case GEOM::FACE: tag = SMESH::Tag_SubMeshOnFace; break;
359 case GEOM::SHELL: tag = SMESH::Tag_SubMeshOnShell; break;
360 case GEOM::SOLID: tag = SMESH::Tag_SubMeshOnSolid; break;
361 case GEOM::COMPOUND: tag = SMESH::Tag_SubMeshOnCompound; break;
364 _PTR(GenericAttribute) anAttr;
365 _PTR(SObject) aSubmeshRoot;
366 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
367 if ( pMesh->FindSubObject( tag, aSubmeshRoot ) )
369 _PTR(ChildIterator) smIter = aStudy->NewChildIterator( aSubmeshRoot );
370 for ( ; smIter->More(); smIter->Next() )
372 _PTR(SObject) aSmObj = smIter->Value();
373 if ( ! aSmObj->FindAttribute( anAttr, "AttributeIOR" ))
375 _PTR(ChildIterator) anIter1 = aStudy->NewChildIterator(aSmObj);
376 for ( ; anIter1->More(); anIter1->Next()) {
377 _PTR(SObject) pGeom2 = anIter1->Value();
378 if ( pGeom2->ReferencedObject( pGeom2 ) &&
379 pGeom2->GetID() == pGeom->GetID() )
386 return _PTR(SObject)();
389 //================================================================================
391 * \brief Updates dialog's look and feel
393 * Virtual method redefined from the base class updates dialog's look and feel
395 //================================================================================
396 void SMESHGUI_MeshOp::selectionDone()
398 if (!dlg()->isVisible() || !myDlg->isEnabled())
401 SMESHGUI_SelectionOp::selectionDone();
405 myIsOnGeometry = true;
407 //Check geometry for mesh
408 QString anObjEntry = myDlg->selectedObject(SMESHGUI_MeshDlg::Obj);
409 _PTR(SObject) pObj = studyDS()->FindObjectID(anObjEntry.toLatin1().data());
412 SMESH::SMESH_Mesh_var aMeshVar =
413 SMESH::SMESH_Mesh::_narrow(_CAST(SObject,pObj)->GetObject());
414 if (!aMeshVar->_is_nil()) {
415 if (!myToCreate && !aMeshVar->HasShapeToMesh())
416 myIsOnGeometry = false;
422 // Enable tabs according to shape dimension
427 myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
428 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
430 if (aGEOMs.count() > 0) {
431 // one or more GEOM shape selected
432 aSeq->length(aGEOMs.count());
433 QStringList::const_iterator aSubShapesIter = aGEOMs.begin();
435 for ( ; aSubShapesIter != aGEOMs.end(); aSubShapesIter++, iSubSh++) {
436 QString aSubGeomEntry = (*aSubShapesIter);
437 _PTR(SObject) pSubGeom = studyDS()->FindObjectID(aSubGeomEntry.toLatin1().data());
438 GEOM::GEOM_Object_var aSubGeomVar =
439 GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
440 aSeq[iSubSh] = aSubGeomVar;
443 // get geometry by selected sub-mesh
444 QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
445 _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
446 GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
447 if (!aGeomVar->_is_nil()) {
453 if (aSeq->length() > 0) {
455 for (int iss = 0; iss < aSeq->length() && shapeDim < 3; iss++) {
456 GEOM::GEOM_Object_var aGeomVar = aSeq[iss];
457 switch ( aGeomVar->GetShapeType() ) {
458 case GEOM::SOLID: shapeDim = 3; break;
461 //shapeDim = 3; // Bug 0016155: EDF PAL 447: If the shape is a Shell, disable 3D tab
462 shapeDim = (shapeDim < 2) ? 2 : shapeDim;
464 if (GEOMBase::GetShape(aGeomVar, aShape)) {
470 case GEOM::FACE: shapeDim = (shapeDim < 2) ? 2 : shapeDim; break;
472 case GEOM::EDGE: shapeDim = (shapeDim < 1) ? 1 : shapeDim; break;
473 case GEOM::VERTEX: break;
477 if (GEOMBase::GetShape(aGeomVar, aShape)) {
478 TopExp_Explorer exp (aShape, TopAbs_SHELL);
480 //shapeDim = 3; // Bug 0016155: EDF PAL 447: If the shape is a Shell, disable 3D tab
481 shapeDim = (shapeDim < 2) ? 2 : shapeDim;
482 for (; exp.More() && shapeDim == 2; exp.Next()) {
483 if (exp.Current().Closed())
487 else if ( exp.Init( aShape, TopAbs_FACE ), exp.More() )
488 shapeDim = (shapeDim < 2) ? 2 : shapeDim;
489 else if ( exp.Init( aShape, TopAbs_EDGE ), exp.More() )
490 shapeDim = (shapeDim < 1) ? 1 : shapeDim;
498 myDlg->setMaxHypoDim( shapeDim );
501 if (!myToCreate) // edition: read hypotheses
505 SMESH::SMESH_subMesh_var aVar =
506 SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
507 myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, !aVar->_is_nil() );
508 myDlg->setObjectShown( SMESHGUI_MeshDlg::Geom, true );
509 myDlg->objectWg( SMESHGUI_MeshDlg::Mesh, SMESHGUI_MeshDlg::Btn )->hide();
510 myDlg->objectWg( SMESHGUI_MeshDlg::Geom, SMESHGUI_MeshDlg::Btn )->hide();
511 myDlg->updateGeometry();
518 else if ( !myIsMesh ) // submesh creation
520 // if a submesh on the selected shape already exist, pass to submesh edition mode
521 if ( _PTR(SObject) pSubmesh = getSubmeshByGeom() ) {
522 SMESH::SMESH_subMesh_var sm =
523 SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( pSubmesh );
524 bool editSubmesh = ( !sm->_is_nil() &&
525 SUIT_MessageBox::question( myDlg, tr( "SMESH_WARNING" ),
526 tr( "EDIT_SUBMESH_QUESTION"),
527 SUIT_MessageBox::Yes |
529 SUIT_MessageBox::No )
530 == SUIT_MessageBox::Yes );
533 selectionMgr()->clearFilters();
534 selectObject( pSubmesh );
535 SMESHGUI::GetSMESHGUI()->switchToOperation(704);
540 myDlg->selectObject( "", SMESHGUI_MeshDlg::Geom, "" );
541 selectObject( _PTR(SObject)() );
546 // enable/disable popup for choice of geom selection way
548 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
549 if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() )) {
550 SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
551 if ( !mesh->_is_nil() )
552 enable = ( shapeDim > 1 ) && ( mesh->NbEdges() > 0 );
554 myDlg->setGeomPopupEnabled( enable );
558 myDlg->enableTab( SMESH::DIM_3D );
560 availableHyps( SMESH::DIM_3D, Algo, hypList,
561 myAvailableHypData[SMESH::DIM_3D][Algo]);
563 SMESHGUI_MeshTab* aTab = myDlg->tab( SMESH::DIM_3D );
564 aTab->setAvailableHyps( Algo, hypList );
565 for (int i = SMESH::DIM_0D;i < SMESH::DIM_3D; ++i) {
566 myDlg->disableTab(i);
568 //Hide labels and fields (Mesh ang Geometry)
569 myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, false );
570 myDlg->setObjectShown( SMESHGUI_MeshDlg::Geom, false );
575 catch ( const SALOME::SALOME_Exception& S_ex )
577 SalomeApp_Tools::QtCatchCorbaException( S_ex );
584 //================================================================================
586 * \brief Verifies validity of input data
587 * \param theMess - Output parameter intended for returning error message
588 * \retval bool - TRUE if input data is valid, false otherwise
590 * Verifies validity of input data. This method is called when "Apply" or "OK" button
591 * is pressed before mesh creation or editing.
593 //================================================================================
594 bool SMESHGUI_MeshOp::isValid( QString& theMess ) const
596 // Selected object to be edited
597 if ( !myToCreate && myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ) == "" )
599 theMess = tr( "THERE_IS_NO_OBJECT_FOR_EDITING" );
604 QString aMeshName = myDlg->objectText( SMESHGUI_MeshDlg::Obj ).trimmed();
605 if ( aMeshName.isEmpty() )
607 theMess = myIsMesh ? tr( "NAME_OF_MESH_IS_EMPTY" ) : tr( "NAME_OF_SUBMESH_IS_EMPTY" );
611 /* // Imported mesh, if create sub-mesh or edit mesh
612 if ( !myToCreate || ( myToCreate && !myIsMesh ))
614 QString aMeshEntry = myDlg->selectedObject
615 ( myToCreate ? SMESHGUI_MeshDlg::Mesh : SMESHGUI_MeshDlg::Obj );
616 if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() )) {
617 SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
618 if ( !mesh->_is_nil() && CORBA::is_nil( mesh->GetShapeToMesh() )) {
619 theMess = tr( "IMPORTED_MESH" );
628 QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
629 if ( aGeomEntry == "" )
631 theMess = tr( "GEOMETRY_OBJECT_IS_NOT_DEFINED" );
634 _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.toLatin1().data() );
635 if ( !pGeom || GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() )->_is_nil() )
637 theMess = tr( "GEOMETRY_OBJECT_IS_NULL" );
642 if ( !myIsMesh ) // i.e sub-mesh creation,
644 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
645 if ( aMeshEntry == "" )
647 theMess = tr( "MESH_IS_NOT_DEFINED" );
650 _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
651 if ( !pMesh || SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() )->_is_nil() )
653 theMess = tr( "MESH_IS_NULL" );
656 if ( !isSubshapeOk() )
658 theMess = tr( "INVALID_SUBSHAPE" );
667 //================================================================================
669 * \brief check compatibility of the algorithm and another algorithm or hypothesis
670 * \param theAlgoData - algorithm data
671 * \param theHypData - hypothesis data
672 * \param theHypType - hypothesis type
673 * \param theHypTypeName - hypothesis type name, must be provided if 2-nd arg is not algo
674 * \retval bool - check result
676 //================================================================================
678 static bool isCompatible(const HypothesisData* theAlgoData,
679 const HypothesisData* theHypData,
680 const int theHypType)
685 if ( theHypType == SMESHGUI_MeshOp::Algo )
686 return SMESH::IsCompatibleAlgorithm( theAlgoData, theHypData );
689 return ( SMESH::IsAvailableHypothesis( theAlgoData, theHypData->TypeName, isOptional ));
692 //================================================================================
694 * \brief Gets available hypotheses or algorithms
695 * \param theDim - specifies dimension of returned hypotheses/algorifms
696 * \param theHypType - specifies whether algorims or hypotheses or additional ones
697 * are retrieved (possible values are in HypType enumeration)
698 * \param theHyps - Output list of hypotheses' names
699 * \param theAlgoData - to select hypos able to be used by this algo (optional)
701 * Gets available hypotheses or algorithm in accordance with input parameters
703 //================================================================================
704 void SMESHGUI_MeshOp::availableHyps( const int theDim,
705 const int theHypType,
706 QStringList& theHyps,
707 THypDataList& theDataList,
708 HypothesisData* theAlgoData ) const
712 bool isAlgo = ( theHypType == Algo );
713 bool isAux = ( theHypType == AddHyp );
714 QStringList aHypTypeNameList = SMESH::GetAvailableHypotheses( isAlgo, theDim, isAux, myIsOnGeometry );
716 QStringList::const_iterator anIter;
717 for ( anIter = aHypTypeNameList.begin(); anIter != aHypTypeNameList.end(); ++anIter )
719 HypothesisData* aData = SMESH::GetHypothesisData( *anIter );
720 if ( isCompatible ( theAlgoData, aData, theHypType )) {
721 theDataList.append( aData );
722 theHyps.append( aData->Label );
727 //================================================================================
729 * \brief Gets existing hypotheses or algorithms
730 * \param theDim - specifies dimension of returned hypotheses/algorifms
731 * \param theHypType - specifies whether algorims or hypotheses or additional ones
732 * are retrieved (possible values are in HypType enumeration)
733 * \param theFather - start object for finding ( may be component, mesh, or sub-mesh )
734 * \param theHyps - output list of names.
735 * \param theHypVars - output list of variables.
736 * \param theAlgoData - to select hypos able to be used by this algo (optional)
738 * Gets existing (i.e. already created) hypotheses or algorithm in accordance with
741 //================================================================================
742 void SMESHGUI_MeshOp::existingHyps( const int theDim,
743 const int theHypType,
744 _PTR(SObject) theFather,
745 QStringList& theHyps,
746 THypList& theHypList,
747 HypothesisData* theAlgoData)
749 // Clear hypoheses list
756 const bool isAux = ( theHypType == AddHyp );
758 _PTR(SObject) aHypRoot;
759 _PTR(GenericAttribute) anAttr;
760 _PTR(AttributeName) aName;
761 _PTR(AttributeIOR) anIOR;
763 bool isMesh = !_CAST( SComponent, theFather );
766 aPart = theHypType == Algo ? SMESH::Tag_RefOnAppliedAlgorithms : SMESH::Tag_RefOnAppliedHypothesis;
768 aPart = theHypType == Algo ? SMESH::Tag_AlgorithmsRoot : SMESH::Tag_HypothesisRoot;
770 if ( theFather->FindSubObject( aPart, aHypRoot ) )
772 _PTR(ChildIterator) anIter =
773 SMESH::GetActiveStudyDocument()->NewChildIterator( aHypRoot );
774 for ( ; anIter->More(); anIter->Next() )
776 _PTR(SObject) anObj = anIter->Value();
777 if ( isMesh ) // i.e. mesh or submesh
779 _PTR(SObject) aRefObj;
780 if ( anObj->ReferencedObject( aRefObj ) )
785 if ( anObj->FindAttribute( anAttr, "AttributeName" ) )
788 CORBA::Object_var aVar = _CAST(SObject,anObj)->GetObject();
789 if ( !CORBA::is_nil( aVar ) )
791 SMESH::SMESH_Hypothesis_var aHypVar = SMESH::SMESH_Hypothesis::_narrow( aVar );
792 if ( !aHypVar->_is_nil() )
794 HypothesisData* aData = SMESH::GetHypothesisData( aHypVar->GetName() );
795 if ( ( theDim == -1 || aData->Dim.contains( theDim ) ) &&
796 ( isCompatible ( theAlgoData, aData, theHypType )) &&
797 ( isAux == aData->IsAux ))
799 std::string aHypName = aName->Value();
800 theHyps.append( aHypName.c_str() );
801 theHypList.append( THypItem( aHypVar, aHypName.c_str() ) );
810 //================================================================================
812 * \brief If create or edit a submesh, return a hypothesis holding parameters used
814 * \param aHypType - The hypothesis type name
815 * \param aServerLib - Server library name
816 * \param hypData - The structure holding the hypothesis type etc.
817 * \retval SMESH::SMESH_Hypothesis_var - the hypothesis holding parameter values
819 //================================================================================
821 SMESH::SMESH_Hypothesis_var
822 SMESHGUI_MeshOp::getInitParamsHypothesis( const QString& aHypType,
823 const QString& aServerLib ) const
825 if ( aHypType.isEmpty() || aServerLib.isEmpty() )
826 return SMESH::SMESH_Hypothesis::_nil();
828 const int nbColonsInMeshEntry = 3;
829 bool isSubMesh = myToCreate ?
831 myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ).count(':') > nbColonsInMeshEntry;
835 // get mesh and geom object
836 SMESH::SMESH_Mesh_var aMeshVar = SMESH::SMESH_Mesh::_nil();
837 GEOM::GEOM_Object_var aGeomVar = GEOM::GEOM_Object::_nil();
839 QString anEntry = myDlg->selectedObject
840 ( myToCreate ? SMESHGUI_MeshDlg::Mesh : SMESHGUI_MeshDlg::Obj );
841 if ( _PTR(SObject) pObj = studyDS()->FindObjectID( anEntry.toLatin1().data() ))
843 CORBA::Object_ptr Obj = _CAST( SObject,pObj )->GetObject();
844 if ( myToCreate ) // mesh and geom may be selected
846 aMeshVar = SMESH::SMESH_Mesh::_narrow( Obj );
847 anEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
848 if ( _PTR(SObject) pGeom = studyDS()->FindObjectID( anEntry.toLatin1().data() ))
849 aGeomVar= GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
851 else // edition: sub-mesh may be selected
853 SMESH::SMESH_subMesh_var sm = SMESH::SMESH_subMesh::_narrow( Obj );
854 if ( !sm->_is_nil() ) {
855 aMeshVar = sm->GetFather();
856 aGeomVar = sm->GetSubShape();
861 if ( !aMeshVar->_is_nil() && !aGeomVar->_is_nil() )
862 return SMESHGUI::GetSMESHGen()->GetHypothesisParameterValues( aHypType.toLatin1().data(),
863 aServerLib.toLatin1().data(),
867 return SMESH::SMESH_Hypothesis::_nil();
870 //================================================================================
872 * \Brief Returns tab dimention
873 * \param tab - the tab in the dlg
874 * \param dlg - my dialogue
875 * \retval int - dimention
877 //================================================================================
879 static int getTabDim (const QObject* tab, SMESHGUI_MeshDlg* dlg )
882 for (int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++)
883 if (tab == dlg->tab(i))
888 //================================================================================
890 * \brief Create hypothesis
891 * \param theHypType - hypothesis category (main or additional)
892 * \param theIndex - index of type of hypothesis to be cerated
894 * Specifies dimension of hypothesis to be created (using sender() method),
895 * specifies its type and calls method for hypothesis creation
897 //================================================================================
898 void SMESHGUI_MeshOp::onCreateHyp( const int theHypType, const int theIndex )
900 // Specifies dimension of hypothesis to be created
901 int aDim = getTabDim( sender(), myDlg );
905 // Specifies type of hypothesis to be created
906 THypDataList& dataList = myAvailableHypData[ aDim ][ theHypType ];
907 if (theIndex < 0 || theIndex >= dataList.count())
909 QString aHypTypeName = dataList[ theIndex ]->TypeName;
912 createHypothesis(aDim, theHypType, aHypTypeName);
915 //================================================================================
917 * Create hypothesis and update dialog.
918 * \param theDim - dimension of hypothesis to be created
919 * \param theType - hypothesis category (algorithm, hypothesis, additional hypothesis)
920 * \param theTypeName - specifies hypothesis to be created
922 //================================================================================
925 QString GetUniqueName (const QStringList& theHypNames,
926 const QString& theName,
927 size_t theIteration = 1)
929 QString aName = theName + "_" + QString::number( theIteration );
930 if ( theHypNames.contains( aName ) )
931 return GetUniqueName( theHypNames, theName, ++theIteration );
936 void SMESHGUI_MeshOp::createHypothesis (const int theDim,
938 const QString& theTypeName)
940 // During a hypothesis creation we might need to select some objects.
941 // Main dialog must not update it's own selected objects in this case.
942 dlg()->deactivateAll();
944 HypothesisData* aData = SMESH::GetHypothesisData(theTypeName);
948 QStringList aHypNames;
949 TDim2Type2HypList::const_iterator aDimIter = myExistingHyps.begin();
950 for ( ; aDimIter != myExistingHyps.end(); aDimIter++) {
951 const TType2HypList& aType2HypList = aDimIter.value();
952 TType2HypList::const_iterator aTypeIter = aType2HypList.begin();
953 for ( ; aTypeIter != aType2HypList.end(); aTypeIter++) {
954 const THypList& aHypList = aTypeIter.value();
955 THypList::const_iterator anIter = aHypList.begin();
956 for ( ; anIter != aHypList.end(); anIter++) {
957 const THypItem& aHypItem = *anIter;
958 const QString& aHypName = aHypItem.second;
959 aHypNames.append(aHypName);
963 QString aHypName = GetUniqueName( aHypNames, aData->Label);
966 int nbHyp = myExistingHyps[theDim][theType].count();
968 QString aClientLibName = aData->ClientLibName;
969 if (aClientLibName == "") {
970 // Call hypothesis creation server method (without GUI)
971 SMESH::CreateHypothesis(theTypeName, aHypName, false);
973 // Get hypotheses creator client (GUI)
974 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(theTypeName);
978 // When create or edit a submesh, try to initialize a new hypothesis
979 // with values used to mesh a subshape
980 SMESH::SMESH_Hypothesis_var initParamHyp =
981 getInitParamsHypothesis(theTypeName, aData->ServerLibName);
982 myDlg->setEnabled( false );
983 aCreator->create(initParamHyp, aHypName, myDlg);
984 myDlg->setEnabled( true );
986 SMESH::CreateHypothesis(theTypeName, aHypName, false);
990 _PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
992 HypothesisData* algoData = hypData( theDim, Algo, currentHyp( theDim, Algo ));
993 QStringList aNewHyps;
994 existingHyps(theDim, theType, aFather, aNewHyps, myExistingHyps[theDim][theType], algoData);
995 if (aNewHyps.count() > nbHyp) {
996 for (int i = nbHyp; i < aNewHyps.count(); i++)
997 myDlg->tab(theDim)->addHyp(theType, aNewHyps[i]);
1001 //================================================================================
1003 * \brief Calls plugin methods for hypothesis editing
1004 * \param theHypType - specifies whether main hypothesis or additional one
1006 * \param theIndex - index of existing hypothesis
1008 * Calls plugin methods for hypothesis editing
1010 //================================================================================
1011 void SMESHGUI_MeshOp::onEditHyp( const int theHypType, const int theIndex )
1013 // Speicfies dimension of hypothesis to be created
1014 int aDim = getTabDim( sender(), myDlg );
1018 const THypList& aList = myExistingHyps[ aDim ][ theHypType ];
1019 if ( theIndex < 0 || theIndex >= aList.count() )
1021 const THypItem& aHypItem = aList[ theIndex ];
1022 SMESH::SMESH_Hypothesis_var aHyp = aHypItem.first;
1023 if ( aHyp->_is_nil() )
1026 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator( aHyp->GetName() );
1028 myDlg->setEnabled( false );
1029 aCreator->edit( aHyp.in(), aHypItem.second, dlg() );
1030 myDlg->setEnabled( true );
1034 //================================================================================
1036 * \brief access to hypothesis data
1037 * \param theDim - hyp dimension
1038 * \param theHypType - hyp type (Algo,MainHyp or AddHyp)
1039 * \param theIndex - index in the list
1040 * \retval HypothesisData* - result data, may be 0
1042 //================================================================================
1044 HypothesisData* SMESHGUI_MeshOp::hypData( const int theDim,
1045 const int theHypType,
1048 if ( theDim > -1 && theDim <= SMESH::DIM_3D &&
1049 theHypType > -1 && theHypType < NbHypTypes &&
1050 theIndex > -1 && theIndex < myAvailableHypData[ theDim ][ theHypType ].count() )
1051 return myAvailableHypData[ theDim ][ theHypType ][ theIndex ];
1055 //================================================================================
1057 * \brief Set available algos and hypos according to the selected algorithm
1058 * \param theIndex - algorithm index
1060 //================================================================================
1062 void SMESHGUI_MeshOp::onAlgoSelected( const int theIndex,
1065 if ( myIgnoreAlgoSelection )
1068 int aDim = theDim < 0 ? getTabDim( sender(), myDlg ): theDim;
1072 // find highest available dimension, all algos of this dimension are available for choice
1074 for (int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++)
1075 if (isAccessibleDim( i ))
1080 const bool isSubmesh = ( myToCreate ? !myIsMesh : myDlg->isObjectShown( SMESHGUI_MeshDlg::Mesh ));
1082 HypothesisData* algoData = hypData( aDim, Algo, theIndex );
1083 HypothesisData* algoByDim[4];
1084 algoByDim[ aDim ] = algoData;
1086 QStringList anAvailable;
1087 if ( !algoData ) { // all algos becomes available
1088 availableHyps( aDim, Algo, anAvailable, myAvailableHypData[ aDim ][ Algo ]);
1089 myDlg->tab( aDim )->setAvailableHyps( Algo, anAvailable );
1092 // check that algorithms of other dimentions are compatible with
1095 // 2 loops: backward and forward from algo dimension
1096 for ( int forward = false; forward <= true; ++forward )
1098 int dim = aDim + 1, lastDim = SMESH::DIM_3D, dir = 1;
1100 dim = aDim - 1; lastDim = SMESH::DIM_0D; dir = -1;
1102 HypothesisData* prevAlgo = algoData;
1103 bool noCompatible = false;
1104 for ( ; dim * dir <= lastDim * dir; dim += dir)
1106 if ( !isAccessibleDim( dim ))
1108 if ( noCompatible ) { // the selected algo has no compatible ones
1109 anAvailable.clear();
1110 myDlg->tab( dim )->setAvailableHyps( Algo, anAvailable );
1111 myAvailableHypData[dim][Algo].clear();
1112 algoByDim[ dim ] = 0;
1115 // get currently selected algo
1116 int algoIndex = currentHyp( dim, Algo );
1117 HypothesisData* curAlgo = hypData( dim, Algo, algoIndex );
1118 if ( curAlgo ) { // some algo selected
1119 if ( !isCompatible( prevAlgo, curAlgo, Algo ))
1122 // set new available algoritms
1123 availableHyps( dim, Algo, anAvailable, myAvailableHypData[dim][Algo], prevAlgo );
1124 HypothesisData* soleCompatible = 0;
1125 if ( anAvailable.count() == 1 )
1126 soleCompatible = myAvailableHypData[dim][Algo][0];
1127 if ( dim == aTopDim && prevAlgo ) // all available algoritms should be selectable any way
1128 availableHyps( dim, Algo, anAvailable, myAvailableHypData[dim][Algo], 0 );
1129 myDlg->tab( dim )->setAvailableHyps( Algo, anAvailable );
1130 noCompatible = anAvailable.isEmpty();
1132 // restore previously selected algo
1133 algoIndex = myAvailableHypData[dim][Algo].indexOf( curAlgo );
1134 if ( !isSubmesh && algoIndex < 0 && soleCompatible && !forward && dim != SMESH::DIM_0D)
1135 // select the sole compatible algo
1136 algoIndex = myAvailableHypData[dim][Algo].indexOf( soleCompatible );
1137 setCurrentHyp( dim, Algo, algoIndex );
1139 // remember current algo
1140 prevAlgo = algoByDim[ dim ] = hypData( dim, Algo, algoIndex );
1144 // set hypotheses corresponding to the found algoritms
1146 _PTR(SObject) pObj = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
1148 for ( int dim = SMESH::DIM_0D; dim <= SMESH::DIM_3D; dim++ )
1150 if ( !isAccessibleDim( dim ))
1152 for ( int type = MainHyp; type < NbHypTypes; type++ )
1154 myAvailableHypData[ dim ][ type ].clear();
1155 QStringList anAvailable, anExisting;
1157 HypothesisData* curAlgo = algoByDim[ dim ];
1158 int hypIndex = currentHyp( dim, type );
1160 SMESH::SMESH_Hypothesis_var curHyp;
1161 if ( hypIndex >= 0 && hypIndex < myExistingHyps[ dim ][ type ].count() )
1162 curHyp = myExistingHyps[ dim ][ type ][ hypIndex ].first;
1164 if ( !myToCreate && !curAlgo && !curHyp->_is_nil() ) { // edition, algo not selected
1165 // try to find algo by selected hypothesis in order to keep it selected
1166 bool algoDeselectedByUser = ( theDim < 0 && aDim == dim );
1167 CORBA::String_var curHypType = curHyp->GetName();
1168 if ( !algoDeselectedByUser &&
1169 myObjHyps[ dim ][ type ].count() > 0 &&
1170 curHypType == myObjHyps[ dim ][ type ].first().first->GetName())
1172 HypothesisData* hypData = SMESH::GetHypothesisData( curHyp->GetName() );
1173 for (int i = 0; i < myAvailableHypData[ dim ][ Algo ].count(); ++i) {
1174 curAlgo = myAvailableHypData[ dim ][ Algo ][ i ];
1175 if (curAlgo && hypData && isCompatible(curAlgo, hypData, type))
1182 // get hyps compatible with curAlgo
1185 // check if a selected hyp is compatible with the curAlgo
1186 if ( !curHyp->_is_nil() ) {
1187 HypothesisData* hypData = SMESH::GetHypothesisData( curHyp->GetName() );
1188 if ( !isCompatible( curAlgo, hypData, type ))
1189 curHyp = SMESH::SMESH_Hypothesis::_nil();
1191 existingHyps( dim, type, pObj, anExisting, myExistingHyps[ dim ][ type ], curAlgo);
1192 availableHyps( dim, type, anAvailable, myAvailableHypData[ dim ][ type ], curAlgo);
1194 // set list of hypotheses
1195 myDlg->tab( dim )->setAvailableHyps( type, anAvailable );
1196 myDlg->tab( dim )->setExistingHyps( type, anExisting );
1198 // set current existing hypothesis
1199 if ( !curHyp->_is_nil() && !anExisting.isEmpty() )
1200 hypIndex = this->find( curHyp, myExistingHyps[ dim ][ type ]);
1203 if ( !isSubmesh && hypIndex < 0 && anExisting.count() == 1 ) {
1204 // none is yet selected => select the sole existing if it is not optional
1205 CORBA::String_var hypTypeName = myExistingHyps[ dim ][ type ].first().first->GetName();
1206 bool isOptional = true;
1207 if ( algoByDim[ dim ] &&
1208 SMESH::IsAvailableHypothesis( algoByDim[ dim ], hypTypeName.in(), isOptional ) &&
1212 setCurrentHyp( dim, type, hypIndex );
1217 //================================================================================
1219 * \brief Creates and selects hypothesis of hypotheses set
1220 * \param theSetName - The name of hypotheses set
1222 //================================================================================
1223 void SMESHGUI_MeshOp::onHypoSet( const QString& theSetName )
1225 HypothesesSet* aHypoSet = SMESH::GetHypothesesSet(theSetName);
1226 if (!aHypoSet) return;
1229 for (int dim = SMESH::DIM_0D; dim <= SMESH::DIM_3D; dim++) {
1230 setCurrentHyp(dim, Algo, -1);
1231 setCurrentHyp(dim, AddHyp, -1);
1232 setCurrentHyp(dim, MainHyp, -1);
1235 for (int aHypType = Algo; aHypType < AddHyp; aHypType++) {
1236 bool isAlgo = (aHypType == Algo);
1238 // set hyps from the set
1239 QStringList* aHypoList = isAlgo ? &aHypoSet->AlgoList : &aHypoSet->HypoList;
1240 for (int i = 0, n = aHypoList->count(); i < n; i++) {
1241 const QString& aHypoTypeName = (*aHypoList)[ i ];
1242 HypothesisData* aHypData = SMESH::GetHypothesisData(aHypoTypeName);
1246 int aDim = aHypData->Dim[0];
1247 // create or/and set
1249 int index = myAvailableHypData[aDim][Algo].indexOf( aHypData );
1251 QStringList anAvailable;
1252 availableHyps( aDim, Algo, anAvailable, myAvailableHypData[aDim][Algo] );
1253 myDlg->tab( aDim )->setAvailableHyps( Algo, anAvailable );
1254 index = myAvailableHypData[aDim][Algo].indexOf( aHypData );
1256 setCurrentHyp( aDim, Algo, index );
1257 onAlgoSelected( index, aDim );
1260 bool mainHyp = true;
1261 QStringList anAvailable;
1262 availableHyps( aDim, MainHyp, anAvailable, myAvailableHypData[aDim][MainHyp] );
1263 myDlg->tab( aDim )->setAvailableHyps( MainHyp, anAvailable );
1264 int index = myAvailableHypData[aDim][MainHyp].indexOf( aHypData );
1267 index = myAvailableHypData[aDim][AddHyp].indexOf( aHypData );
1270 createHypothesis(aDim, mainHyp ? MainHyp : AddHyp, aHypoTypeName);
1272 } // loop on hypos in the set
1273 } // loop on algo/hypo
1276 //================================================================================
1278 * \brief Creates mesh
1279 * \param theMess - Output parameter intended for returning error message
1280 * \retval bool - TRUE if mesh is created, FALSE otherwise
1284 //================================================================================
1285 bool SMESHGUI_MeshOp::createMesh( QString& theMess )
1289 //QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
1290 //QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
1293 myDlg->selectedObject( SMESHGUI_MeshDlg::Geom, aList );
1294 QStringList::Iterator it = aList.begin();
1295 for ( ; it!=aList.end(); it++)
1297 QString aGeomEntry = *it;
1298 _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.toLatin1().data() );
1299 GEOM::GEOM_Object_var aGeomVar =
1300 GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
1302 SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
1303 if ( aSMESHGen->_is_nil() )
1306 SUIT_OverrideCursor aWaitCursor;
1309 SMESH::SMESH_Mesh_var aMeshVar = aSMESHGen->CreateMesh( aGeomVar );
1310 if ( aMeshVar->_is_nil() )
1312 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar.in() );
1314 SMESH::SetName( aMeshSO, myDlg->objectText( SMESHGUI_MeshDlg::Obj ) );
1316 for ( int aDim = SMESH::DIM_0D; aDim <= SMESH::DIM_3D; aDim++ ) {
1317 if ( !isAccessibleDim( aDim )) continue;
1319 // assign hypotheses
1320 for ( int aHypType = MainHyp; aHypType <= AddHyp; aHypType++ ) {
1321 int aHypIndex = currentHyp( aDim, aHypType );
1322 if ( aHypIndex >= 0 && aHypIndex < myExistingHyps[ aDim ][ aHypType ].count() ) {
1323 SMESH::SMESH_Hypothesis_var aHypVar = myExistingHyps[ aDim ][ aHypType ][ aHypIndex ].first;
1324 if ( !aHypVar->_is_nil() )
1325 SMESH::AddHypothesisOnMesh( aMeshVar, aHypVar );
1328 // find or create algorithm
1329 SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( aDim );
1330 if ( !anAlgoVar->_is_nil() )
1331 SMESH::AddHypothesisOnMesh( aMeshVar, anAlgoVar );
1338 //================================================================================
1340 * \brief Creates sub-mesh
1341 * \param theMess - Output parameter intended for returning error message
1342 * \retval bool - TRUE if sub-mesh is created, FALSE otherwise
1346 //================================================================================
1347 bool SMESHGUI_MeshOp::createSubMesh( QString& theMess )
1351 SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
1352 if ( aSMESHGen->_is_nil() )
1356 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
1357 _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() );
1358 SMESH::SMESH_Mesh_var aMeshVar =
1359 SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() );
1360 if (aMeshVar->_is_nil())
1363 // GEOM shape of the main mesh
1364 GEOM::GEOM_Object_var mainGeom = aMeshVar->GetShapeToMesh();
1366 // Name for the new sub-mesh
1367 QString aName = myDlg->objectText(SMESHGUI_MeshDlg::Obj);
1370 GEOM::GEOM_Object_var aGeomVar;
1372 myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
1373 if (aGEOMs.count() == 1)
1375 //QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
1376 QString aGeomEntry = aGEOMs.first();
1377 _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.toLatin1().data() );
1378 aGeomVar = GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
1380 else if (aGEOMs.count() > 1)
1382 // create a GEOM group
1383 GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
1384 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1385 if (!geomGen->_is_nil() && aStudy) {
1386 GEOM::GEOM_IGroupOperations_var op =
1387 geomGen->GetIGroupOperations(aStudy->StudyId());
1388 if (!op->_is_nil()) {
1389 // check and add all selected GEOM objects: they must be
1390 // a sub-shapes of the main GEOM and must be of one type
1392 TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE;
1393 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1394 aSeq->length(aGEOMs.count());
1395 QStringList::const_iterator aSubShapesIter = aGEOMs.begin();
1396 for ( ; aSubShapesIter != aGEOMs.end(); aSubShapesIter++, iSubSh++) {
1397 QString aSubGeomEntry = (*aSubShapesIter);
1398 _PTR(SObject) pSubGeom = studyDS()->FindObjectID(aSubGeomEntry.toLatin1().data());
1399 GEOM::GEOM_Object_var aSubGeomVar =
1400 GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
1401 TopAbs_ShapeEnum aSubShapeType = (TopAbs_ShapeEnum)aSubGeomVar->GetShapeType();
1403 aGroupType = aSubShapeType;
1405 if (aSubShapeType != aGroupType)
1406 aGroupType = TopAbs_SHAPE;
1408 aSeq[iSubSh] = aSubGeomVar;
1411 GEOM::GEOM_Object_var aGroupVar = op->CreateGroup(mainGeom, aGroupType);
1412 op->UnionList(aGroupVar, aSeq);
1415 aGeomVar = aGroupVar;
1417 // publish the GEOM group in study
1418 QString aNewGeomGroupName ("Auto_group_for_");
1419 aNewGeomGroupName += aName;
1420 SALOMEDS::SObject_var aNewGroupSO =
1421 geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGeomVar,
1422 aNewGeomGroupName.toLatin1().data(), mainGeom);
1429 if (aGeomVar->_is_nil())
1432 SUIT_OverrideCursor aWaitCursor;
1435 SMESH::SMESH_subMesh_var aSubMeshVar = aMeshVar->GetSubMesh( aGeomVar, aName.toLatin1().data() );
1437 for ( int aDim = SMESH::DIM_0D; aDim <= SMESH::DIM_3D; aDim++ )
1439 if ( !isAccessibleDim( aDim )) continue;
1441 // find or create algorithm
1442 SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( aDim );
1443 if ( !anAlgoVar->_is_nil() )
1444 SMESH::AddHypothesisOnSubMesh( aSubMeshVar, anAlgoVar );
1445 // assign hypotheses
1446 for ( int aHypType = MainHyp; aHypType <= AddHyp; aHypType++ )
1448 int aHypIndex = currentHyp( aDim, aHypType );
1449 if ( aHypIndex >= 0 && aHypIndex < myExistingHyps[ aDim ][ aHypType ].count() )
1451 SMESH::SMESH_Hypothesis_var aHypVar =
1452 myExistingHyps[ aDim ][ aHypType ][ aHypIndex ].first;
1453 if ( !aHypVar->_is_nil() )
1454 SMESH::AddHypothesisOnSubMesh( aSubMeshVar, aHypVar );
1459 // deselect geometry: next submesh should be created on other subshape
1460 myDlg->clearSelection( SMESHGUI_MeshDlg::Geom );
1461 selectObject( _PTR(SObject)() );
1467 //================================================================================
1469 * \brief Gets current hypothesis or algorithms
1470 * \param theDim - dimension of hypothesis or algorithm
1471 * \param theHypType - Type of hypothesis (Algo, MainHyp, AddHyp)
1472 * \retval int - current hypothesis or algorithms
1474 * Gets current hypothesis or algorithms
1476 //================================================================================
1477 int SMESHGUI_MeshOp::currentHyp( const int theDim, const int theHypType ) const
1479 return myDlg->tab( theDim )->currentHyp( theHypType ) - 1;
1482 //================================================================================
1484 * \brief Returns true if hypotheses of given dim can be assigned
1485 * \param theDim - hypotheses dimension
1486 * \retval bool - result
1488 //================================================================================
1489 bool SMESHGUI_MeshOp::isAccessibleDim( const int theDim ) const
1491 return myDlg->tab( theDim )->isEnabled();
1494 //================================================================================
1496 * \brief Sets current hypothesis or algorithms
1497 * \param theDim - dimension of hypothesis or algorithm
1498 * \param theHypType - Type of hypothesis (Algo, MainHyp, AddHyp)
1499 * \param theIndex - Index of hypothesis
1501 * Gets current hypothesis or algorithms
1503 //================================================================================
1504 void SMESHGUI_MeshOp::setCurrentHyp( const int theDim,
1505 const int theHypType,
1506 const int theIndex )
1508 myIgnoreAlgoSelection = true;
1509 myDlg->tab( theDim )->setCurrentHyp( theHypType, theIndex + 1 );
1510 myIgnoreAlgoSelection = false;
1513 //================================================================================
1515 * \brief Generates default and sets mesh/submesh name
1517 * Generates and sets default mesh/submesh name(Mesh_1, Mesh_2, etc.)
1519 //================================================================================
1520 void SMESHGUI_MeshOp::setDefaultName() const
1524 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1526 QString aPrefix = tr( myIsMesh ? "SMESH_OBJECT_MESH" : "SMESH_SUBMESH" ) + "_";
1527 _PTR(SObject) anObj;
1530 aResName = aPrefix + QString::number( i++ );
1531 anObj = aStudy->FindObject( aResName.toLatin1().data() );
1535 QLineEdit* aControl = ( QLineEdit* )myDlg->objectWg(
1536 SMESHGUI_MeshDlg::Obj, SMESHGUI_MeshDlg::Control );
1537 aControl->setText( aResName );
1540 //================================================================================
1542 * \brief Gets algorithm or creates it if necessary
1543 * \param theDim - specifies dimension of returned hypotheses/algorifms
1544 * \retval SMESH::SMESH_Hypothesis_var - algorithm
1546 * Gets algorithm or creates it if necessary
1548 //================================================================================
1549 SMESH::SMESH_Hypothesis_var SMESHGUI_MeshOp::getAlgo( const int theDim )
1551 SMESH::SMESH_Hypothesis_var anAlgoVar;
1553 // get type of the selected algo
1554 int aHypIndex = currentHyp( theDim, Algo );
1555 THypDataList& dataList = myAvailableHypData[ theDim ][ Algo ];
1556 if ( aHypIndex < 0 || aHypIndex >= dataList.count())
1558 QString aHypName = dataList[ aHypIndex ]->TypeName;
1560 // get existing algoritms
1561 _PTR(SObject) pObj = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
1563 existingHyps( theDim, Algo, pObj, tmp, myExistingHyps[ theDim ][ Algo ]);
1565 // look for anexisting algo of such a type
1566 THypList& aHypVarList = myExistingHyps[ theDim ][ Algo ];
1567 THypList::iterator anIter = aHypVarList.begin();
1568 for ( ; anIter != aHypVarList.end(); anIter++)
1570 SMESH::SMESH_Hypothesis_var aHypVar = (*anIter).first;
1571 CORBA::String_var aName = aHypVar->GetName();
1572 if ( !aHypVar->_is_nil() && aHypName == aName )
1574 anAlgoVar = aHypVar;
1579 if (anAlgoVar->_is_nil()) {
1580 HypothesisData* aHypData = SMESH::GetHypothesisData( aHypName );
1582 QString aClientLibName = aHypData->ClientLibName;
1583 if (aClientLibName == "") {
1584 // Call hypothesis creation server method (without GUI)
1585 SMESH::CreateHypothesis(aHypName, aHypData->Label, true);
1587 // Get hypotheses creator client (GUI)
1588 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(aHypName);
1592 aCreator->create(true, aHypName, myDlg);
1594 SMESH::CreateHypothesis(aHypName, aHypData->Label, true);
1596 QStringList tmpList;
1597 _PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" );
1598 existingHyps( theDim, Algo, aFather, tmpList, myExistingHyps[ theDim ][ Algo ] );
1601 THypList& aNewHypVarList = myExistingHyps[ theDim ][ Algo ];
1602 for ( anIter = aNewHypVarList.begin(); anIter != aNewHypVarList.end(); ++anIter )
1604 SMESH::SMESH_Hypothesis_var aHypVar = (*anIter).first;
1605 CORBA::String_var aName = aHypVar->GetName();
1606 if ( !aHypVar->_is_nil() && aHypName == aName )
1608 anAlgoVar = aHypVar;
1614 return anAlgoVar._retn();
1617 //================================================================================
1619 * \brief Reads parameters of edited mesh and assigns them to the dialog
1621 * Reads parameters of edited mesh and assigns them to the dialog (called when
1622 * mesh is edited only)
1624 //================================================================================
1625 void SMESHGUI_MeshOp::readMesh()
1627 QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
1628 _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
1632 if (myIsOnGeometry) {
1633 // Get name of mesh if current object is sub-mesh
1634 SMESH::SMESH_subMesh_var aSubMeshVar =
1635 SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
1636 if ( !aSubMeshVar->_is_nil() )
1638 SMESH::SMESH_Mesh_var aMeshVar = aSubMeshVar->GetFather();
1639 if ( !aMeshVar->_is_nil() )
1641 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar );
1642 QString aMeshName = name( aMeshSO );
1643 myDlg->setObjectText( SMESHGUI_MeshDlg::Mesh, aMeshName );
1647 // Get name of geometry object
1648 GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
1649 if ( !aGeomVar->_is_nil() )
1651 _PTR(SObject) aGeomSO = studyDS()->FindObjectID( aGeomVar->GetStudyEntry() );
1652 QString aShapeName = name( aGeomSO );
1653 myDlg->setObjectText( SMESHGUI_MeshDlg::Geom, aShapeName );
1657 // Get hypotheses and algorithms assigned to the mesh/sub-mesh
1658 QStringList anExisting;
1659 const int aDim = ( myIsOnGeometry ) ? SMESH::DIM_0D : SMESH::DIM_3D;
1660 for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
1663 existingHyps( dim, Algo, pObj, anExisting, myObjHyps[ dim ][ Algo ] );
1664 // find algo index among available ones
1666 if ( myObjHyps[ dim ][ Algo ].count() > 0 )
1668 SMESH::SMESH_Hypothesis_var aVar = myObjHyps[ dim ][ Algo ].first().first;
1669 HypothesisData* algoData = SMESH::GetHypothesisData( aVar->GetName() );
1670 aHypIndex = myAvailableHypData[ dim ][ Algo ].indexOf ( algoData );
1671 // if ( aHypIndex < 0 && algoData ) {
1672 // // assigned algo is incompatible with other algorithms
1673 // myAvailableHypData[ dim ][ Algo ].push_back( algoData );
1674 // aHypIndex = myAvailableHypData[ dim ][ hypType ].count() - 1;
1677 setCurrentHyp( dim, Algo, aHypIndex );
1678 // set existing and available hypothesis according to the selected algo
1679 onAlgoSelected( aHypIndex, dim );
1683 bool hypWithoutAlgo = false;
1684 for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
1686 for ( int hypType = MainHyp; hypType <= AddHyp; hypType++ )
1689 existingHyps( dim, hypType, pObj, anExisting, myObjHyps[ dim ][ hypType ] );
1690 // find index of requered hypothesis among existing ones for this dimension and type
1692 if ( myObjHyps[ dim ][ hypType ].count() > 0 ) {
1693 aHypIndex = find( myObjHyps[ dim ][ hypType ].first().first,
1694 myExistingHyps[ dim ][ hypType ] );
1695 if ( aHypIndex < 0 ) {
1696 // assigned hypothesis is incompatible with the algorithm
1697 if ( currentHyp( dim, Algo ) < 0 )
1698 { // none algo selected; it is edition for sure, of submesh maybe
1699 hypWithoutAlgo = true;
1700 myExistingHyps[ dim ][ hypType ].push_back( myObjHyps[ dim ][ hypType ].first() );
1701 aHypIndex = myExistingHyps[ dim ][ hypType ].count() - 1;
1702 myDlg->tab( dim )->setExistingHyps( hypType, anExisting );
1706 setCurrentHyp( dim, hypType, aHypIndex );
1709 // make available other hyps of same type as one without algo
1710 if ( hypWithoutAlgo )
1711 onAlgoSelected( currentHyp( 0, Algo ), 0 );
1714 //================================================================================
1716 * \brief Gets name of object
1717 * \param theSO - SObject
1718 * \retval QString - name of object
1720 * Gets name of object
1722 //================================================================================
1723 QString SMESHGUI_MeshOp::name( _PTR(SObject) theSO ) const
1728 _PTR(GenericAttribute) anAttr;
1729 _PTR(AttributeName) aNameAttr;
1730 if ( theSO->FindAttribute( anAttr, "AttributeName" ) )
1733 aResName = aNameAttr->Value().c_str();
1739 //================================================================================
1741 * \brief Finds hypothesis in input list
1742 * \param theHyp - hypothesis to be found
1743 * \param theHypList - input list of hypotheses
1744 * \retval int - index of hypothesis or -1 if it is not found
1746 * Finds position of hypothesis in input list
1748 //================================================================================
1749 int SMESHGUI_MeshOp::find( const SMESH::SMESH_Hypothesis_var& theHyp,
1750 const THypList& theHypList ) const
1753 if ( !theHyp->_is_nil() )
1756 THypList::const_iterator anIter = theHypList.begin();
1757 for ( ; anIter != theHypList.end(); ++ anIter)
1759 if ( theHyp->_is_equivalent( (*anIter).first ) )
1770 //================================================================================
1772 * \brief Edits mesh or sub-mesh
1773 * \param theMess - Output parameter intended for returning error message
1774 * \retval bool - TRUE if mesh is edited succesfully, FALSE otherwise
1776 * Assigns new name hypotheses and algoriths to the mesh or sub-mesh
1778 //================================================================================
1779 bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess )
1783 SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
1784 if ( aSMESHGen->_is_nil() )
1787 QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
1788 _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.toLatin1().data() );
1792 SUIT_OverrideCursor aWaitCursor;
1795 QString aName = myDlg->objectText( SMESHGUI_MeshDlg::Obj );
1796 SMESH::SetName( pObj, aName );
1797 int aDim = ( myIsOnGeometry ) ? SMESH::DIM_0D : SMESH::DIM_3D;
1799 // First, remove old algos in order to avoid messages on algorithm hiding
1800 for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
1802 if ( isAccessibleDim( dim ) && myObjHyps[ dim ][ Algo ].count() > 0 )
1804 SMESH::SMESH_Hypothesis_var anOldAlgo = myObjHyps[ dim ][ Algo ].first().first;
1805 SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( dim );
1806 if ( anAlgoVar->_is_nil() || // no new algo selected or
1807 strcmp(anOldAlgo->GetName(), anAlgoVar->GetName()) ) // algo change
1809 // remove old algorithm
1810 SMESH::RemoveHypothesisOrAlgorithmOnMesh ( pObj, myObjHyps[ dim ][ Algo ].first().first );
1811 myObjHyps[ dim ][ Algo ].clear();
1816 // Assign new algorithms and hypotheses
1817 for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
1819 if ( !isAccessibleDim( dim )) continue;
1821 // find or create algorithm
1822 SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( dim );
1824 // assign new algorithm
1825 if ( !anAlgoVar->_is_nil() && // some algo selected and
1826 myObjHyps[ dim ][ Algo ].count() == 0 ) // no algo assigned
1828 SALOMEDS_SObject* aSObject = _CAST(SObject, pObj);
1829 CORBA::Object_var anObject = aSObject->GetObject();
1830 SMESH::SMESH_Mesh_var aMeshVar = SMESH::SMESH_Mesh::_narrow( anObject );
1831 bool isMesh = !aMeshVar->_is_nil();
1833 SMESH::AddHypothesisOnMesh( aMeshVar, anAlgoVar );
1835 SMESH::SMESH_subMesh_var aVar =
1836 SMESH::SMESH_subMesh::_narrow( _CAST(SObject,pObj)->GetObject() );
1837 if ( !aVar->_is_nil() )
1838 SMESH::AddHypothesisOnSubMesh( aVar, anAlgoVar );
1840 myObjHyps[ dim ][ Algo ].append( THypItem( anAlgoVar, aName) );
1843 // assign hypotheses
1844 for ( int hypType = MainHyp; hypType <= AddHyp; hypType++ )
1846 int aNewHypIndex = currentHyp( dim, hypType );
1847 int anOldHypIndex = -1;
1849 // remove old hypotheses
1850 if ( myObjHyps[ dim ][ hypType ].count() > 0 )
1852 anOldHypIndex = find( myObjHyps[ dim ][ hypType ].first().first,
1853 myExistingHyps[ dim ][ hypType ] );
1854 if ( aNewHypIndex != anOldHypIndex || // different hyps
1855 anOldHypIndex == -1 ) // hyps of different algos
1857 SMESH::RemoveHypothesisOrAlgorithmOnMesh
1858 ( pObj, myObjHyps[ dim ][ hypType ].first().first );
1859 myObjHyps[ dim ][ hypType ].clear();
1863 // assign new hypotheses
1864 if ( aNewHypIndex != anOldHypIndex && aNewHypIndex != -1 )
1866 SMESH::SMESH_Mesh_var aMeshVar =
1867 SMESH::SMESH_Mesh::_narrow( _CAST(SObject,pObj)->GetObject() );
1868 bool isMesh = !aMeshVar->_is_nil();
1871 SMESH::AddHypothesisOnMesh
1872 (aMeshVar, myExistingHyps[ dim ][ hypType ][ aNewHypIndex ].first );
1876 SMESH::SMESH_subMesh_var aVar =
1877 SMESH::SMESH_subMesh::_narrow( _CAST(SObject,pObj)->GetObject() );
1878 if ( !aVar->_is_nil() )
1879 SMESH::AddHypothesisOnSubMesh
1880 ( aVar, myExistingHyps[ dim ][ hypType ][ aNewHypIndex ].first );
1883 // reread all hypotheses of mesh if necessary
1884 QStringList anExisting;
1885 existingHyps( dim, hypType, pObj, anExisting, myObjHyps[ dim ][ hypType ] );
1892 //================================================================================
1894 * \brief Verifies whether given operator is valid for this one
1895 * \param theOtherOp - other operation
1896 * \return Returns TRUE if the given operator is valid for this one, FALSE otherwise
1898 * method redefined from base class verifies whether given operator is valid for
1899 * this one (i.e. can be started "above" this operator). In current implementation method
1900 * retuns false if theOtherOp operation is not intended for deleting objects or mesh
1903 //================================================================================
1904 bool SMESHGUI_MeshOp::isValid( SUIT_Operation* theOp ) const
1906 return SMESHGUI_Operation::isValid( theOp ) && !theOp->inherits( "SMESHGUI_MeshOp" );
1909 //================================================================================
1911 * \brief SLOT. Is called when the user selects a way of geometry selection
1912 * \param theByMesh - true if the user wants to find geometry by mesh element
1914 //================================================================================
1916 void SMESHGUI_MeshOp::onGeomSelectionByMesh( bool theByMesh )
1919 if ( !myShapeByMeshOp ) {
1920 myShapeByMeshOp = new SMESHGUI_ShapeByMeshOp();
1921 connect(myShapeByMeshOp, SIGNAL(committed(SUIT_Operation*)),
1922 SLOT(onPublishShapeByMeshDlg(SUIT_Operation*)));
1923 connect(myShapeByMeshOp, SIGNAL(aborted(SUIT_Operation*)),
1924 SLOT(onCloseShapeByMeshDlg(SUIT_Operation*)));
1926 // set mesh object to SMESHGUI_ShapeByMeshOp and start it
1927 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
1928 if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.toLatin1().data() )) {
1929 SMESH::SMESH_Mesh_var aMeshVar =
1930 SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() );
1931 if ( !aMeshVar->_is_nil() ) {
1932 myDlg->hide(); // stop processing selection
1933 myShapeByMeshOp->setModule( getSMESHGUI() );
1934 myShapeByMeshOp->setStudy( 0 ); // it's really necessary
1935 myShapeByMeshOp->SetMesh( aMeshVar );
1936 myShapeByMeshOp->start();
1942 //================================================================================
1944 * \brief SLOT. Is called when Ok is pressed in SMESHGUI_ShapeByMeshDlg
1946 //================================================================================
1948 void SMESHGUI_MeshOp::onPublishShapeByMeshDlg(SUIT_Operation* op)
1950 if ( myShapeByMeshOp == op ) {
1951 SMESHGUI::GetSMESHGUI()->getApp()->updateObjectBrowser(); //MZN: 24.11.2006 IPAL13980 - Object Browser update added
1953 // Select a found geometry object
1954 GEOM::GEOM_Object_var aGeomVar = myShapeByMeshOp->GetShape();
1955 if ( !aGeomVar->_is_nil() )
1957 QString ID = aGeomVar->GetStudyEntry();
1958 if ( _PTR(SObject) aGeomSO = studyDS()->FindObjectID( ID.toLatin1().data() )) {
1959 selectObject( aGeomSO );
1966 //================================================================================
1968 * \brief SLOT. Is called when Close is pressed in SMESHGUI_ShapeByMeshDlg
1970 //================================================================================
1972 void SMESHGUI_MeshOp::onCloseShapeByMeshDlg(SUIT_Operation* op)
1974 if ( myShapeByMeshOp == op && myDlg ) {
1979 //================================================================================
1981 * \brief Selects a SObject
1982 * \param theSObj - the SObject to select
1984 //================================================================================
1986 void SMESHGUI_MeshOp::selectObject( _PTR(SObject) theSObj ) const
1988 if ( LightApp_SelectionMgr* sm = selectionMgr() ) {
1989 SALOME_ListIO anIOList;
1991 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject
1992 ( theSObj->GetID().c_str(), "SMESH", theSObj->GetName().c_str() );
1993 anIOList.Append( anIO );
1995 sm->setSelectedObjects( anIOList, false );