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 "GEOM_SelectionFilter.h"
49 #include "GeometryGUI.h"
51 #include "SalomeApp_Tools.h"
52 #include "SalomeApp_Application.h"
53 #include "SALOMEDSClient_Study.hxx"
54 #include "SALOMEDSClient_AttributeIOR.hxx"
55 #include "SALOMEDSClient_AttributeName.hxx"
56 #include "SALOMEDS_SComponent.hxx"
57 #include "SALOMEDS_SObject.hxx"
59 #include "LightApp_SelectionMgr.h"
60 #include "LightApp_UpdateFlags.h"
61 #include "SUIT_MessageBox.h"
62 #include "SUIT_Desktop.h"
63 #include "SUIT_OverrideCursor.h"
64 #include "SALOME_InteractiveObject.hxx"
65 #include "SALOME_ListIO.hxx"
67 #include "utilities.h"
69 #include <qstringlist.h>
70 #include <qlineedit.h>
72 #include <TopoDS_Shape.hxx>
73 #include <TopExp_Explorer.hxx>
75 enum { GLOBAL_ALGO_TAG =3,
79 SUBMESH_ON_VERTEX_TAG =4,
80 SUBMESH_ON_EDGE_TAG =5,
81 SUBMESH_ON_WIRE_TAG =6,
82 SUBMESH_ON_FACE_TAG =7,
83 SUBMESH_ON_SHELL_TAG =8,
84 SUBMESH_ON_SOLID_TAG =9,
85 SUBMESH_ON_COMPOUND_TAG=10 };
87 //================================================================================
90 * \param theToCreate - if this parameter is true then operation is used for creation,
91 * for editing otherwise
93 * Initialize operation
95 //================================================================================
96 SMESHGUI_MeshOp::SMESHGUI_MeshOp( const bool theToCreate, const bool theIsMesh )
97 : SMESHGUI_SelectionOp(),
98 myToCreate( theToCreate ),
99 myIsMesh( theIsMesh ),
103 if ( GeometryGUI::GetGeomGen()->_is_nil() )// check that GEOM_Gen exists
104 GeometryGUI::InitGeomGen();
105 myIsOnGeometry = true;
108 //================================================================================
112 //================================================================================
113 SMESHGUI_MeshOp::~SMESHGUI_MeshOp()
119 //================================================================================
121 * \brief Gets dialog of this operation
122 * \retval LightApp_Dialog* - pointer to dialog of this operation
124 //================================================================================
125 LightApp_Dialog* SMESHGUI_MeshOp::dlg() const
130 //================================================================================
132 * \brief Creates or edits mesh
133 * \retval bool - TRUE if operation is performed successfully, FALSE otherwise
135 * Virtual slot redefined from the base class called when "Apply" button is clicked
136 * creates or edits mesh
138 //================================================================================
139 bool SMESHGUI_MeshOp::onApply()
145 if ( !isValid( aMess ) )
149 SUIT_MessageBox::warn1( myDlg,
150 tr( "SMESH_WRN_WARNING" ), aMess, tr( "SMESH_BUT_OK" ) );
154 bool aResult = false;
158 if ( myToCreate && myIsMesh )
159 aResult = createMesh( aMess );
160 if ( myToCreate && !myIsMesh )
161 aResult = createSubMesh( aMess );
162 else if ( !myToCreate )
163 aResult = editMeshOrSubMesh( aMess );
165 update( UF_ObjBrowser | UF_Model );
167 catch ( const SALOME::SALOME_Exception& S_ex )
169 SalomeApp_Tools::QtCatchCorbaException( S_ex );
185 aMess = tr( "SMESH_OPERATION_FAILED" );
186 SUIT_MessageBox::warn1( myDlg,
187 tr( "SMESH_ERROR" ), aMess, tr( "SMESH_BUT_OK" ) );
193 //================================================================================
195 * \brief Creates dialog if necessary and shows it
197 * Virtual method redefined from base class called when operation is started creates
198 * dialog if necessary and shows it, activates selection
200 //================================================================================
201 void SMESHGUI_MeshOp::startOperation()
205 myDlg = new SMESHGUI_MeshDlg( myToCreate, myIsMesh );
206 for ( int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++ )
208 connect( myDlg->tab( i ), SIGNAL( createHyp( const int, const int ) ),
209 this, SLOT( onCreateHyp( const int, const int ) ) );
210 connect( myDlg->tab( i ), SIGNAL( editHyp( const int, const int ) ),
211 this, SLOT( onEditHyp( const int, const int ) ) );
212 connect( myDlg->tab( i ), SIGNAL( selectAlgo( const int ) ),
213 this, SLOT( onAlgoSelected( const int ) ) );
215 connect( myDlg, SIGNAL( hypoSet( const QString& )), SLOT( onHypoSet( const QString& )));
216 connect( myDlg, SIGNAL( geomSelectionByMesh( bool )), SLOT( onGeomSelectionByMesh( bool )));
219 if ( myIsMesh ) myHelpFileName = "constructing_meshes_page.html";
220 else myHelpFileName = "constructing_submeshes_page.html";
221 else myHelpFileName = "editing_meshes_page.html";
223 SMESHGUI_SelectionOp::startOperation();
225 // iterate through dimensions and get available algoritms, set them to the dialog
226 _PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent( "SMESH" );
227 for ( int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++ )
229 SMESHGUI_MeshTab* aTab = myDlg->tab( i );
231 // clear available hypotheses
232 aTab->setAvailableHyps( MainHyp, hypList );
233 aTab->setAvailableHyps( AddHyp, hypList );
234 aTab->setExistingHyps( MainHyp, hypList );
235 aTab->setExistingHyps( AddHyp, hypList );
236 myExistingHyps[ i ][ MainHyp ].clear();
237 myExistingHyps[ i ][ AddHyp ].clear();
239 availableHyps( i, Algo, hypList, myAvailableHypData[i][Algo] );
240 aTab->setAvailableHyps( Algo, hypList );
245 myDlg->activateObject( myIsMesh ? SMESHGUI_MeshDlg::Geom : SMESHGUI_MeshDlg::Mesh );
248 myDlg->activateObject( SMESHGUI_MeshDlg::Obj );
250 myDlg->setHypoSets( SMESH::GetHypothesesSets() );
252 myDlg->setCurrentTab( SMESH::DIM_3D );
257 myIgnoreAlgoSelection = false;
260 //================================================================================
262 * \brief Creates selection filter
263 * \param theId - identifier of current selection widget
264 * \retval SUIT_SelectionFilter* - pointer to the created filter or null
266 * Creates selection filter in accordance with identifier of current selection widget
268 //================================================================================
269 SUIT_SelectionFilter* SMESHGUI_MeshOp::createFilter( const int theId ) const
271 if ( theId == SMESHGUI_MeshDlg::Geom )
273 // TColStd_MapOfInteger allTypesMap;
274 // for ( int i = 0; i < 10; i++ )
275 // allTypesMap.Add( i );
276 // return new SMESH_NumberFilter( "GEOM", TopAbs_SHAPE, 0, allTypesMap );
277 return new GEOM_SelectionFilter( (SalomeApp_Study*)study(), true );
279 else if ( theId == SMESHGUI_MeshDlg::Obj && !myToCreate )
280 return new SMESH_TypeFilter( MESHorSUBMESH );
281 else if ( theId == SMESHGUI_MeshDlg::Mesh )
282 return new SMESH_TypeFilter( MESH );
287 //================================================================================
289 * \brief check if selected shape is a subshape of the shape to mesh
290 * \retval bool - check result
292 //================================================================================
294 bool SMESHGUI_MeshOp::isSubshapeOk() const
296 if ( !myToCreate || myIsMesh ) // not submesh creation
300 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
301 _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() );
302 if (!pMesh) return false;
304 SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
305 if (mesh->_is_nil()) return false;
307 // main shape of the mesh
308 GEOM::GEOM_Object_var mainGeom = mesh->GetShapeToMesh();
309 if (mainGeom->_is_nil()) return false;
313 myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
315 if (aGEOMs.count() > 0) {
316 GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
317 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
318 if (geomGen->_is_nil() || !aStudy) return false;
320 GEOM::GEOM_IGroupOperations_var op =
321 geomGen->GetIGroupOperations(aStudy->StudyId());
322 if (op->_is_nil()) return false;
324 // check all selected shapes
325 QStringList::const_iterator aSubShapesIter = aGEOMs.begin();
326 for (; aSubShapesIter != aGEOMs.end(); aSubShapesIter++) {
327 QString aSubGeomEntry = (*aSubShapesIter);
328 _PTR(SObject) pSubGeom = studyDS()->FindObjectID(aSubGeomEntry.latin1());
329 if (!pSubGeom) return false;
331 GEOM::GEOM_Object_var aSubGeomVar =
332 GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
333 if (aSubGeomVar->_is_nil()) return false;
335 // skl for NPAL14695 - implementation of searching of mainObj
336 GEOM::GEOM_Object_var mainObj = op->GetMainShape(aSubGeomVar);
337 //if (mainObj->_is_nil() ||
338 // string(mainObj->GetEntry()) != string(mainGeom->GetEntry())) return false;
340 if (mainObj->_is_nil())
342 if (string(mainObj->GetEntry()) == string(mainGeom->GetEntry()))
344 mainObj = op->GetMainShape(mainObj);
353 //================================================================================
355 * \brief find an existing submesh by the selected shape
356 * \retval _PTR(SObject) - the found submesh SObject
358 //================================================================================
360 _PTR(SObject) SMESHGUI_MeshOp::getSubmeshByGeom() const
362 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
363 QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
364 _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() );
365 _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.latin1() );
366 if ( pMesh && pGeom ) {
367 GEOM::GEOM_Object_var geom = SMESH::SObjectToInterface<GEOM::GEOM_Object>( pGeom );
368 if ( !geom->_is_nil() ) {
370 switch ( geom->GetShapeType() ) {
371 case GEOM::VERTEX: tag = SUBMESH_ON_VERTEX_TAG ; break;
372 case GEOM::EDGE: tag = SUBMESH_ON_EDGE_TAG ; break;
373 case GEOM::WIRE: tag = SUBMESH_ON_WIRE_TAG ; break;
374 case GEOM::FACE: tag = SUBMESH_ON_FACE_TAG ; break;
375 case GEOM::SHELL: tag = SUBMESH_ON_SHELL_TAG ; break;
376 case GEOM::SOLID: tag = SUBMESH_ON_SOLID_TAG ; break;
377 case GEOM::COMPOUND: tag = SUBMESH_ON_COMPOUND_TAG; break;
380 _PTR(GenericAttribute) anAttr;
381 _PTR(SObject) aSubmeshRoot;
382 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
383 if ( pMesh->FindSubObject( tag, aSubmeshRoot ) )
385 _PTR(ChildIterator) smIter = aStudy->NewChildIterator( aSubmeshRoot );
386 for (; smIter->More(); smIter->Next() )
388 _PTR(SObject) aSmObj = smIter->Value();
389 if ( ! aSmObj->FindAttribute( anAttr, "AttributeIOR" ))
391 _PTR(ChildIterator) anIter1 = aStudy->NewChildIterator(aSmObj);
392 for (; anIter1->More(); anIter1->Next()) {
393 _PTR(SObject) pGeom2 = anIter1->Value();
394 if ( pGeom2->ReferencedObject( pGeom2 ) &&
395 pGeom2->GetID() == pGeom->GetID() )
402 return _PTR(SObject)();
405 //================================================================================
407 * \brief Updates dialog's look and feel
409 * Virtual method redefined from the base class updates dialog's look and feel
411 //================================================================================
412 void SMESHGUI_MeshOp::selectionDone()
414 if (!dlg()->isShown() || !myDlg->isEnabled())
417 SMESHGUI_SelectionOp::selectionDone();
421 myIsOnGeometry = true;
423 //Check geometry for mesh
424 QString anObjEntry = myDlg->selectedObject(SMESHGUI_MeshDlg::Obj);
425 _PTR(SObject) pObj = studyDS()->FindObjectID(anObjEntry.latin1());
428 SMESH::SMESH_Mesh_var aMeshVar =
429 SMESH::SMESH_Mesh::_narrow(_CAST(SObject,pObj)->GetObject());
430 if (!aMeshVar->_is_nil()) {
431 if (!myToCreate && !aMeshVar->HasShapeToMesh())
432 myIsOnGeometry = false;
438 // Enable tabs according to shape dimension
443 myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
444 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
446 if (aGEOMs.count() > 0) {
447 // one or more GEOM shape selected
448 aSeq->length(aGEOMs.count());
449 QStringList::const_iterator aSubShapesIter = aGEOMs.begin();
451 for (; aSubShapesIter != aGEOMs.end(); aSubShapesIter++, iSubSh++) {
452 QString aSubGeomEntry = (*aSubShapesIter);
453 _PTR(SObject) pSubGeom = studyDS()->FindObjectID(aSubGeomEntry.latin1());
454 GEOM::GEOM_Object_var aSubGeomVar =
455 GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
456 aSeq[iSubSh] = aSubGeomVar;
459 // get geometry by selected sub-mesh
460 QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
461 _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.latin1() );
462 GEOM::GEOM_Object_var aGeomVar = SMESH::GetShapeOnMeshOrSubMesh( pObj );
463 if (!aGeomVar->_is_nil()) {
469 if (aSeq->length() > 0) {
471 for (int iss = 0; iss < aSeq->length() && shapeDim < 3; iss++) {
472 GEOM::GEOM_Object_var aGeomVar = aSeq[iss];
473 switch ( aGeomVar->GetShapeType() ) {
475 case GEOM::SHELL: shapeDim = 3; break;
476 case GEOM::FACE: shapeDim = (shapeDim < 2) ? 2 : shapeDim; break;
478 case GEOM::EDGE: shapeDim = (shapeDim < 1) ? 1 : shapeDim; break;
479 case GEOM::VERTEX: break;
482 if ( GEOMBase::GetShape(aGeomVar, aShape)) {
483 TopExp_Explorer exp( aShape, TopAbs_SHELL );
486 else if ( exp.Init( aShape, TopAbs_FACE ), exp.More() )
487 shapeDim = (shapeDim < 2) ? 2 : shapeDim;
488 else if ( exp.Init( aShape, TopAbs_EDGE ), exp.More() )
489 shapeDim = (shapeDim < 1) ? 1 : shapeDim;
496 myDlg->setMaxHypoDim( shapeDim );
499 if (!myToCreate) // edition: read hypotheses
503 SMESH::SMESH_subMesh_var aVar =
504 SMESH::SMESH_subMesh::_narrow( _CAST( SObject,pObj )->GetObject() );
505 myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, !aVar->_is_nil() );
506 myDlg->setObjectShown( SMESHGUI_MeshDlg::Geom, true );
507 myDlg->objectWg( SMESHGUI_MeshDlg::Mesh, SMESHGUI_MeshDlg::Btn )->hide();
508 myDlg->objectWg( SMESHGUI_MeshDlg::Geom, SMESHGUI_MeshDlg::Btn )->hide();
509 myDlg->updateGeometry();
516 else if ( !myIsMesh ) // submesh creation
518 // if a submesh on the selected shape already exist, pass to submesh edition mode
519 if ( _PTR(SObject) pSubmesh = getSubmeshByGeom() ) {
520 SMESH::SMESH_subMesh_var sm =
521 SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( pSubmesh );
522 bool editSubmesh = ( !sm->_is_nil() &&
523 SUIT_MessageBox::question2( myDlg, tr( "SMESH_WARNING" ),
524 tr( "EDIT_SUBMESH_QUESTION"),
525 tr( "SMESH_BUT_YES" ),
526 tr( "SMESH_BUT_NO" ), 1, 0, 0 ));
529 selectionMgr()->clearFilters();
530 selectObject( pSubmesh );
531 SMESHGUI::GetSMESHGUI()->switchToOperation(704);
536 myDlg->selectObject( "", SMESHGUI_MeshDlg::Geom, "" );
537 selectObject( _PTR(SObject)() );
542 // enable/disable popup for choice of geom selection way
544 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
545 if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() )) {
546 SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
547 if ( !mesh->_is_nil() )
548 enable = ( shapeDim > 1 ) && ( mesh->NbEdges() > 0 );
550 myDlg->setGeomPopupEnabled( enable );
554 myDlg->enableTab( SMESH::DIM_3D );
556 availableHyps( SMESH::DIM_3D, Algo, hypList,
557 myAvailableHypData[SMESH::DIM_3D][Algo]);
559 SMESHGUI_MeshTab* aTab = myDlg->tab( SMESH::DIM_3D );
560 aTab->setAvailableHyps( Algo, hypList );
561 for (int i = SMESH::DIM_0D;i < SMESH::DIM_3D; ++i) {
562 myDlg->disableTab(i);
564 //Hide labels and fields (Mesh ang Geometry)
565 myDlg->setObjectShown( SMESHGUI_MeshDlg::Mesh, false );
566 myDlg->setObjectShown( SMESHGUI_MeshDlg::Geom, false );
571 catch ( const SALOME::SALOME_Exception& S_ex )
573 SalomeApp_Tools::QtCatchCorbaException( S_ex );
580 //================================================================================
582 * \brief Verifies validity of input data
583 * \param theMess - Output parameter intended for returning error message
584 * \retval bool - TRUE if input data is valid, false otherwise
586 * Verifies validity of input data. This method is called when "Apply" or "OK" button
587 * is pressed before mesh creation or editing.
589 //================================================================================
590 bool SMESHGUI_MeshOp::isValid( QString& theMess ) const
592 // Selected object to be edited
593 if ( !myToCreate && myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ) == "" )
595 theMess = tr( "THERE_IS_NO_OBJECT_FOR_EDITING" );
600 QString aMeshName = myDlg->objectText( SMESHGUI_MeshDlg::Obj );
601 aMeshName = aMeshName.stripWhiteSpace();
602 if ( aMeshName == "" )
604 theMess = myIsMesh ? tr( "NAME_OF_MESH_IS_EMPTY" ) : tr( "NAME_OF_SUBMESH_IS_EMPTY" );
608 /* // Imported mesh, if create sub-mesh or edit mesh
609 if ( !myToCreate || ( myToCreate && !myIsMesh ))
611 QString aMeshEntry = myDlg->selectedObject
612 ( myToCreate ? SMESHGUI_MeshDlg::Mesh : SMESHGUI_MeshDlg::Obj );
613 if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() )) {
614 SMESH::SMESH_Mesh_var mesh = SMESH::SObjectToInterface<SMESH::SMESH_Mesh>( pMesh );
615 if ( !mesh->_is_nil() && CORBA::is_nil( mesh->GetShapeToMesh() )) {
616 theMess = tr( "IMPORTED_MESH" );
625 QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
626 if ( aGeomEntry == "" )
628 theMess = tr( "GEOMETRY_OBJECT_IS_NOT_DEFINED" );
631 _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.latin1() );
632 if ( !pGeom || GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() )->_is_nil() )
634 theMess = tr( "GEOMETRY_OBJECT_IS_NULL" );
639 if ( !myIsMesh ) // i.e sub-mesh creation,
641 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
642 if ( aMeshEntry == "" )
644 theMess = tr( "MESH_IS_NOT_DEFINED" );
647 _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() );
648 if ( !pMesh || SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() )->_is_nil() )
650 theMess = tr( "MESH_IS_NULL" );
653 if ( !isSubshapeOk() )
655 theMess = tr( "INVALID_SUBSHAPE" );
664 //================================================================================
666 * \brief check compatibility of the algorithm and another algorithm or hypothesis
667 * \param theAlgoData - algorithm data
668 * \param theHypData - hypothesis data
669 * \param theHypType - hypothesis type
670 * \param theHypTypeName - hypothesis type name, must be provided if 2-nd arg is not algo
671 * \retval bool - check result
673 //================================================================================
675 static bool isCompatible(const HypothesisData* theAlgoData,
676 const HypothesisData* theHypData,
677 const int theHypType)
682 if ( theHypType == SMESHGUI_MeshOp::Algo )
683 return SMESH::IsCompatibleAlgorithm( theAlgoData, theHypData );
686 return ( SMESH::IsAvailableHypothesis( theAlgoData, theHypData->TypeName, isOptional ));
689 //================================================================================
691 * \brief Gets available hypotheses or algorithms
692 * \param theDim - specifies dimension of returned hypotheses/algorifms
693 * \param theHypType - specifies whether algorims or hypotheses or additional ones
694 * are retrieved (possible values are in HypType enumeration)
695 * \param theHyps - Output list of hypotheses' names
696 * \param theAlgoData - to select hypos able to be used by this algo (optional)
698 * Gets available hypotheses or algorithm in accordance with input parameters
700 //================================================================================
701 void SMESHGUI_MeshOp::availableHyps( const int theDim,
702 const int theHypType,
703 QStringList& theHyps,
704 THypDataList& theDataList,
705 HypothesisData* theAlgoData ) const
709 bool isAlgo = ( theHypType == Algo );
710 bool isAux = ( theHypType == AddHyp );
711 QStringList aHypTypeNameList = SMESH::GetAvailableHypotheses( isAlgo, theDim, isAux, myIsOnGeometry );
713 QStringList::const_iterator anIter;
714 for ( anIter = aHypTypeNameList.begin(); anIter != aHypTypeNameList.end(); ++anIter )
716 HypothesisData* aData = SMESH::GetHypothesisData( *anIter );
717 if ( isCompatible ( theAlgoData, aData, theHypType )) {
718 theDataList.append( aData );
719 theHyps.append( aData->Label );
724 //================================================================================
726 * \brief Gets existing hypotheses or algorithms
727 * \param theDim - specifies dimension of returned hypotheses/algorifms
728 * \param theHypType - specifies whether algorims or hypotheses or additional ones
729 * are retrieved (possible values are in HypType enumeration)
730 * \param theFather - start object for finding ( may be component, mesh, or sub-mesh )
731 * \param theHyps - output list of names.
732 * \param theHypVars - output list of variables.
733 * \param theAlgoData - to select hypos able to be used by this algo (optional)
735 * Gets existing (i.e. already created) hypotheses or algorithm in accordance with
738 //================================================================================
739 void SMESHGUI_MeshOp::existingHyps( const int theDim,
740 const int theHypType,
741 _PTR(SObject) theFather,
742 QStringList& theHyps,
743 THypList& theHypList,
744 HypothesisData* theAlgoData)
746 // Clear hypoheses list
753 const bool isAux = ( theHypType == AddHyp );
755 _PTR(SObject) aHypRoot;
756 _PTR(GenericAttribute) anAttr;
757 _PTR(AttributeName) aName;
758 _PTR(AttributeIOR) anIOR;
760 bool isMesh = !_CAST( SComponent, theFather );
763 aPart = theHypType == Algo ? GLOBAL_ALGO_TAG : GLOBAL_HYPO_TAG;
765 aPart = theHypType == Algo ? LOCAL_ALGO_TAG : LOCAL_HYPO_TAG;
767 if ( theFather->FindSubObject( aPart, aHypRoot ) )
769 _PTR(ChildIterator) anIter =
770 SMESH::GetActiveStudyDocument()->NewChildIterator( aHypRoot );
771 for (; anIter->More(); anIter->Next() )
773 _PTR(SObject) anObj = anIter->Value();
774 if ( isMesh ) // i.e. mesh or submesh
776 _PTR(SObject) aRefObj;
777 if ( anObj->ReferencedObject( aRefObj ) )
782 if ( anObj->FindAttribute( anAttr, "AttributeName" ) )
785 CORBA::Object_var aVar = _CAST(SObject,anObj)->GetObject();
786 if ( !CORBA::is_nil( aVar ) )
788 SMESH::SMESH_Hypothesis_var aHypVar = SMESH::SMESH_Hypothesis::_narrow( aVar );
789 if ( !aHypVar->_is_nil() )
791 CORBA::String_var aHypType( aHypVar->GetName() );
792 HypothesisData* aData = SMESH::GetHypothesisData( aHypType );
793 if ( ( theDim == -1 || aData->Dim.contains( theDim ) ) &&
794 ( isCompatible ( theAlgoData, aData, theHypType )) &&
795 ( isAux == aData->IsAux ))
797 std::string aHypName = aName->Value();
798 theHyps.append( aHypName.c_str() );
799 theHypList.append( THypItem( aHypVar, aHypName.c_str() ) );
808 //================================================================================
810 * \brief If create or edit a submesh, return a hypothesis holding parameters used
812 * \param aHypType - The hypothesis type name
813 * \param aServerLib - Server library name
814 * \param hypData - The structure holding the hypothesis type etc.
815 * \retval SMESH::SMESH_Hypothesis_var - the hypothesis holding parameter values
817 //================================================================================
819 SMESH::SMESH_Hypothesis_var
820 SMESHGUI_MeshOp::getInitParamsHypothesis( const QString& aHypType,
821 const QString& aServerLib ) const
823 if ( aHypType.isEmpty() || aServerLib.isEmpty() )
824 return SMESH::SMESH_Hypothesis::_nil();
826 const int nbColonsInMeshEntry = 3;
827 bool isSubMesh = myToCreate ?
829 myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ).contains(':') > nbColonsInMeshEntry;
833 // get mesh and geom object
834 SMESH::SMESH_Mesh_var aMeshVar = SMESH::SMESH_Mesh::_nil();
835 GEOM::GEOM_Object_var aGeomVar = GEOM::GEOM_Object::_nil();
837 QString anEntry = myDlg->selectedObject
838 ( myToCreate ? SMESHGUI_MeshDlg::Mesh : SMESHGUI_MeshDlg::Obj );
839 if ( _PTR(SObject) pObj = studyDS()->FindObjectID( anEntry.latin1() ))
841 CORBA::Object_ptr Obj = _CAST( SObject,pObj )->GetObject();
842 if ( myToCreate ) // mesh and geom may be selected
844 aMeshVar = SMESH::SMESH_Mesh::_narrow( Obj );
845 anEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
846 if ( _PTR(SObject) pGeom = studyDS()->FindObjectID( anEntry.latin1() ))
847 aGeomVar= GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
849 else // edition: sub-mesh may be selected
851 SMESH::SMESH_subMesh_var sm = SMESH::SMESH_subMesh::_narrow( Obj );
852 if ( !sm->_is_nil() ) {
853 aMeshVar = sm->GetFather();
854 aGeomVar = sm->GetSubShape();
859 if ( !aMeshVar->_is_nil() && !aGeomVar->_is_nil() )
860 return SMESHGUI::GetSMESHGen()->GetHypothesisParameterValues( aHypType,
865 return SMESH::SMESH_Hypothesis::_nil();
868 //================================================================================
870 * \Brief Returns tab dimention
871 * \param tab - the tab in the dlg
872 * \param dlg - my dialogue
873 * \retval int - dimention
875 //================================================================================
877 static int getTabDim (const QObject* tab, SMESHGUI_MeshDlg* dlg )
880 for (int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++)
881 if (tab == dlg->tab(i))
886 //================================================================================
888 * \brief Create hypothesis
889 * \param theHypType - hypothesis category (main or additional)
890 * \param theIndex - index of type of hypothesis to be cerated
892 * Specifies dimension of hypothesis to be created (using sender() method),
893 * specifies its type and calls method for hypothesis creation
895 //================================================================================
896 void SMESHGUI_MeshOp::onCreateHyp( const int theHypType, const int theIndex )
898 // Specifies dimension of hypothesis to be created
899 int aDim = getTabDim( sender(), myDlg );
903 // Specifies type of hypothesis to be created
904 THypDataList& dataList = myAvailableHypData[ aDim ][ theHypType ];
905 if (theIndex < 0 || theIndex >= dataList.count())
907 QString aHypTypeName = dataList[ theIndex ]->TypeName;
910 createHypothesis(aDim, theHypType, aHypTypeName);
913 //================================================================================
915 * Create hypothesis and update dialog.
916 * \param theDim - dimension of hypothesis to be created
917 * \param theType - hypothesis category (algorithm, hypothesis, additional hypothesis)
918 * \param theTypeName - specifies hypothesis to be created
920 //================================================================================
923 QString GetUniqueName (const QStringList& theHypNames,
924 const QString& theName,
925 size_t theIteration = 1)
927 QString aName = theName + "_" + QString::number( theIteration );
928 if ( theHypNames.contains( aName ) )
929 return GetUniqueName( theHypNames, theName, ++theIteration );
934 void SMESHGUI_MeshOp::createHypothesis (const int theDim,
936 const QString& theTypeName)
938 // During a hypothesis creation we might need to select some objects.
939 // Main dialog must not update it's own selected objects in this case.
940 dlg()->deactivateAll();
942 HypothesisData* aData = SMESH::GetHypothesisData(theTypeName.latin1());
946 QStringList aHypNames;
947 TDim2Type2HypList::const_iterator aDimIter = myExistingHyps.begin();
948 for (; aDimIter != myExistingHyps.end(); aDimIter++) {
949 const TType2HypList& aType2HypList = aDimIter.data();
950 TType2HypList::const_iterator aTypeIter = aType2HypList.begin();
951 for (; aTypeIter != aType2HypList.end(); aTypeIter++) {
952 const THypList& aHypList = aTypeIter.data();
953 THypList::const_iterator anIter = aHypList.begin();
954 for (; anIter != aHypList.end(); anIter++) {
955 const THypItem& aHypItem = *anIter;
956 const QString& aHypName = aHypItem.second;
957 aHypNames.append(aHypName);
961 QString aHypName = GetUniqueName( aHypNames, aData->Label);
964 int nbHyp = myExistingHyps[theDim][theType].count();
966 QString aClientLibName = aData->ClientLibName;
967 if (aClientLibName == "") {
968 // Call hypothesis creation server method (without GUI)
969 SMESH::CreateHypothesis(theTypeName, aHypName, false);
971 // Get hypotheses creator client (GUI)
972 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(theTypeName);
976 // When create or edit a submesh, try to initialize a new hypothesis
977 // with values used to mesh a subshape
978 SMESH::SMESH_Hypothesis_var initParamHyp =
979 getInitParamsHypothesis(theTypeName, aData->ServerLibName);
980 myDlg->setEnabled( false );
981 aCreator->create(initParamHyp, aHypName, myDlg);
982 myDlg->setEnabled( true );
984 SMESH::CreateHypothesis(theTypeName, aHypName, false);
988 _PTR(SComponent) aFather = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
990 HypothesisData* algoData = hypData( theDim, Algo, currentHyp( theDim, Algo ));
991 QStringList aNewHyps;
992 existingHyps(theDim, theType, aFather, aNewHyps, myExistingHyps[theDim][theType], algoData);
993 if (aNewHyps.count() > nbHyp) {
994 for (int i = nbHyp; i < aNewHyps.count(); i++)
995 myDlg->tab(theDim)->addHyp(theType, aNewHyps[i]);
999 //================================================================================
1001 * \brief Calls plugin methods for hypothesis editing
1002 * \param theHypType - specifies whether main hypothesis or additional one
1004 * \param theIndex - index of existing hypothesis
1006 * Calls plugin methods for hypothesis editing
1008 //================================================================================
1009 void SMESHGUI_MeshOp::onEditHyp( const int theHypType, const int theIndex )
1011 // Speicfies dimension of hypothesis to be created
1012 int aDim = getTabDim( sender(), myDlg );
1016 const THypList& aList = myExistingHyps[ aDim ][ theHypType ];
1017 if ( theIndex < 0 || theIndex >= aList.count() )
1019 const THypItem& aHypItem = aList[ theIndex ];
1020 SMESH::SMESH_Hypothesis_var aHyp = aHypItem.first;
1021 if ( aHyp->_is_nil() )
1024 CORBA::String_var aTypeName = aHyp->GetName();
1025 SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator( aTypeName );
1027 myDlg->setEnabled( false );
1028 aCreator->edit( aHyp.in(), aHypItem.second, dlg() );
1029 myDlg->setEnabled( true );
1033 //================================================================================
1035 * \brief access to hypothesis data
1036 * \param theDim - hyp dimension
1037 * \param theHypType - hyp type (Algo,MainHyp or AddHyp)
1038 * \param theIndex - index in the list
1039 * \retval HypothesisData* - result data, may be 0
1041 //================================================================================
1043 HypothesisData* SMESHGUI_MeshOp::hypData( const int theDim,
1044 const int theHypType,
1047 if ( theDim > -1 && theDim <= SMESH::DIM_3D &&
1048 theHypType > -1 && theHypType < NbHypTypes &&
1049 theIndex > -1 && theIndex < myAvailableHypData[ theDim ][ theHypType ].count() )
1050 return myAvailableHypData[ theDim ][ theHypType ][ theIndex ];
1054 //================================================================================
1056 * \brief Set available algos and hypos according to the selected algorithm
1057 * \param theIndex - algorithm index
1059 //================================================================================
1061 void SMESHGUI_MeshOp::onAlgoSelected( const int theIndex,
1064 if ( myIgnoreAlgoSelection )
1067 int aDim = theDim < 0 ? getTabDim( sender(), myDlg ): theDim;
1071 // find highest available dimension, all algos of this dimension are available for choice
1073 for (int i = SMESH::DIM_0D; i <= SMESH::DIM_3D; i++)
1074 if (isAccessibleDim( i ))
1079 const bool isSubmesh = ( myToCreate ? !myIsMesh : myDlg->isObjectShown( SMESHGUI_MeshDlg::Mesh ));
1081 HypothesisData* algoData = hypData( aDim, Algo, theIndex );
1082 HypothesisData* algoByDim[4];
1083 algoByDim[ aDim ] = algoData;
1085 QStringList anAvailable;
1086 if ( !algoData ) { // all algos becomes available
1087 availableHyps( aDim, Algo, anAvailable, myAvailableHypData[ aDim ][ Algo ]);
1088 myDlg->tab( aDim )->setAvailableHyps( Algo, anAvailable );
1091 // check that algorithms of other dimentions are compatible with
1094 // 2 loops: backward and forward from algo dimension
1095 for ( int forward = false; forward <= true; ++forward )
1097 int dim = aDim + 1, lastDim = SMESH::DIM_3D, dir = 1;
1099 dim = aDim - 1; lastDim = SMESH::DIM_0D; dir = -1;
1101 HypothesisData* prevAlgo = algoData;
1102 bool noCompatible = false;
1103 for (; dim * dir <= lastDim * dir; dim += dir)
1105 if ( !isAccessibleDim( dim ))
1107 if ( noCompatible ) { // the selected algo has no compatible ones
1108 anAvailable.clear();
1109 myDlg->tab( dim )->setAvailableHyps( Algo, anAvailable );
1110 myAvailableHypData[dim][Algo].clear();
1111 algoByDim[ dim ] = 0;
1114 // get currently selected algo
1115 int algoIndex = currentHyp( dim, Algo );
1116 HypothesisData* curAlgo = hypData( dim, Algo, algoIndex );
1117 if ( curAlgo ) { // some algo selected
1118 if ( !isCompatible( prevAlgo, curAlgo, Algo ))
1121 // set new available algoritms
1122 availableHyps( dim, Algo, anAvailable, myAvailableHypData[dim][Algo], prevAlgo );
1123 HypothesisData* soleCompatible = 0;
1124 if ( anAvailable.count() == 1 )
1125 soleCompatible = myAvailableHypData[dim][Algo][0];
1126 if ( dim == aTopDim && prevAlgo ) // all available algoritms should be selectable any way
1127 availableHyps( dim, Algo, anAvailable, myAvailableHypData[dim][Algo], 0 );
1128 myDlg->tab( dim )->setAvailableHyps( Algo, anAvailable );
1129 noCompatible = anAvailable.isEmpty();
1131 // restore previously selected algo
1132 algoIndex = myAvailableHypData[dim][Algo].findIndex( curAlgo );
1133 if ( !isSubmesh && algoIndex < 0 && soleCompatible && !forward && dim != SMESH::DIM_0D)
1134 // select the sole compatible algo
1135 algoIndex = myAvailableHypData[dim][Algo].findIndex( soleCompatible );
1136 setCurrentHyp( dim, Algo, algoIndex );
1138 // remember current algo
1139 prevAlgo = algoByDim[ dim ] = hypData( dim, Algo, algoIndex );
1143 // set hypotheses corresponding to the found algoritms
1145 _PTR(SObject) pObj = SMESH::GetActiveStudyDocument()->FindComponent("SMESH");
1147 for ( int dim = SMESH::DIM_0D; dim <= SMESH::DIM_3D; dim++ )
1149 if ( !isAccessibleDim( dim ))
1151 for ( int type = MainHyp; type < NbHypTypes; type++ )
1153 myAvailableHypData[ dim ][ type ].clear();
1154 QStringList anAvailable, anExisting;
1156 HypothesisData* curAlgo = algoByDim[ dim ];
1157 int hypIndex = currentHyp( dim, type );
1159 SMESH::SMESH_Hypothesis_var curHyp;
1160 if ( hypIndex >= 0 && hypIndex < myExistingHyps[ dim ][ type ].count() )
1161 curHyp = myExistingHyps[ dim ][ type ][ hypIndex ].first;
1163 if ( !myToCreate && !curAlgo && !curHyp->_is_nil() ) { // edition, algo not selected
1164 // try to find algo by selected hypothesis in order to keep it selected
1165 bool algoDeselectedByUser = ( theDim < 0 && aDim == dim );
1166 CORBA::String_var curHypType = curHyp->GetName();
1167 if ( !algoDeselectedByUser &&
1168 myObjHyps[ dim ][ type ].count() > 0 &&
1169 curHypType == myObjHyps[ dim ][ type ].first().first->GetName())
1171 CORBA::String_var aName = curHyp->GetName();
1172 HypothesisData* hypData = SMESH::GetHypothesisData( aName );
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 CORBA::String_var aName = curHyp->GetName();
1188 HypothesisData* hypData = SMESH::GetHypothesisData( aName );
1189 if ( !isCompatible( curAlgo, hypData, type ))
1190 curHyp = SMESH::SMESH_Hypothesis::_nil();
1192 existingHyps( dim, type, pObj, anExisting, myExistingHyps[ dim ][ type ], curAlgo);
1193 availableHyps( dim, type, anAvailable, myAvailableHypData[ dim ][ type ], curAlgo);
1195 // set list of hypotheses
1196 myDlg->tab( dim )->setAvailableHyps( type, anAvailable );
1197 myDlg->tab( dim )->setExistingHyps( type, anExisting );
1199 // set current existing hypothesis
1200 if ( !curHyp->_is_nil() && !anExisting.isEmpty() )
1201 hypIndex = this->find( curHyp, myExistingHyps[ dim ][ type ]);
1204 if ( !isSubmesh && hypIndex < 0 && anExisting.count() == 1 ) {
1205 // none is yet selected => select the sole existing if it is not optional
1206 CORBA::String_var hypTypeName = myExistingHyps[ dim ][ type ].first().first->GetName();
1207 bool isOptional = true;
1208 if ( algoByDim[ dim ] &&
1209 SMESH::IsAvailableHypothesis( algoByDim[ dim ], hypTypeName.in(), isOptional ) &&
1213 setCurrentHyp( dim, type, hypIndex );
1218 //================================================================================
1220 * \brief Creates and selects hypothesis of hypotheses set
1221 * \param theSetName - The name of hypotheses set
1223 //================================================================================
1224 void SMESHGUI_MeshOp::onHypoSet( const QString& theSetName )
1226 HypothesesSet* aHypoSet = SMESH::GetHypothesesSet(theSetName);
1227 if (!aHypoSet) return;
1230 for (int dim = SMESH::DIM_0D; dim <= SMESH::DIM_3D; dim++) {
1231 setCurrentHyp(dim, Algo, -1);
1232 setCurrentHyp(dim, AddHyp, -1);
1233 setCurrentHyp(dim, MainHyp, -1);
1236 for (int aHypType = Algo; aHypType < AddHyp; aHypType++) {
1237 bool isAlgo = (aHypType == Algo);
1239 // set hyps from the set
1240 QStringList* aHypoList = isAlgo ? &aHypoSet->AlgoList : &aHypoSet->HypoList;
1241 for (int i = 0, n = aHypoList->count(); i < n; i++) {
1242 const QString& aHypoTypeName = (*aHypoList)[ i ];
1243 HypothesisData* aHypData = SMESH::GetHypothesisData(aHypoTypeName);
1247 int aDim = aHypData->Dim[0];
1248 // create or/and set
1250 int index = myAvailableHypData[aDim][Algo].findIndex( aHypData );
1252 QStringList anAvailable;
1253 availableHyps( aDim, Algo, anAvailable, myAvailableHypData[aDim][Algo] );
1254 myDlg->tab( aDim )->setAvailableHyps( Algo, anAvailable );
1255 index = myAvailableHypData[aDim][Algo].findIndex( aHypData );
1257 setCurrentHyp( aDim, Algo, index );
1258 onAlgoSelected( index, aDim );
1261 bool mainHyp = true;
1262 QStringList anAvailable;
1263 availableHyps( aDim, MainHyp, anAvailable, myAvailableHypData[aDim][MainHyp] );
1264 myDlg->tab( aDim )->setAvailableHyps( MainHyp, anAvailable );
1265 int index = myAvailableHypData[aDim][MainHyp].findIndex( aHypData );
1268 index = myAvailableHypData[aDim][AddHyp].findIndex( aHypData );
1271 createHypothesis(aDim, mainHyp ? MainHyp : AddHyp, aHypoTypeName);
1273 } // loop on hypos in the set
1274 } // loop on algo/hypo
1277 //================================================================================
1279 * \brief Creates mesh
1280 * \param theMess - Output parameter intended for returning error message
1281 * \retval bool - TRUE if mesh is created, FALSE otherwise
1285 //================================================================================
1286 bool SMESHGUI_MeshOp::createMesh( QString& theMess )
1290 //QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
1291 //QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
1294 myDlg->selectedObject( SMESHGUI_MeshDlg::Geom, aList );
1295 QStringList::Iterator it = aList.begin();
1296 for (; it!=aList.end(); it++)
1298 QString aGeomEntry = *it;
1299 _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.latin1() );
1300 GEOM::GEOM_Object_var aGeomVar =
1301 GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
1303 SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
1304 if ( aSMESHGen->_is_nil() )
1307 SUIT_OverrideCursor aWaitCursor;
1310 SMESH::SMESH_Mesh_var aMeshVar = aSMESHGen->CreateMesh( aGeomVar );
1311 if ( aMeshVar->_is_nil() )
1313 _PTR(SObject) aMeshSO = SMESH::FindSObject( aMeshVar.in() );
1315 SMESH::SetName( aMeshSO, myDlg->objectText( SMESHGUI_MeshDlg::Obj ).latin1() );
1317 for ( int aDim = SMESH::DIM_0D; aDim <= SMESH::DIM_3D; aDim++ ) {
1318 if ( !isAccessibleDim( aDim )) continue;
1320 // assign hypotheses
1321 for ( int aHypType = MainHyp; aHypType <= AddHyp; aHypType++ ) {
1322 int aHypIndex = currentHyp( aDim, aHypType );
1323 if ( aHypIndex >= 0 && aHypIndex < myExistingHyps[ aDim ][ aHypType ].count() ) {
1324 SMESH::SMESH_Hypothesis_var aHypVar = myExistingHyps[ aDim ][ aHypType ][ aHypIndex ].first;
1325 if ( !aHypVar->_is_nil() )
1326 SMESH::AddHypothesisOnMesh( aMeshVar, aHypVar );
1329 // find or create algorithm
1330 SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( aDim );
1331 if ( !anAlgoVar->_is_nil() )
1332 SMESH::AddHypothesisOnMesh( aMeshVar, anAlgoVar );
1339 //================================================================================
1341 * \brief Creates sub-mesh
1342 * \param theMess - Output parameter intended for returning error message
1343 * \retval bool - TRUE if sub-mesh is created, FALSE otherwise
1347 //================================================================================
1348 bool SMESHGUI_MeshOp::createSubMesh( QString& theMess )
1352 SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
1353 if ( aSMESHGen->_is_nil() )
1357 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
1358 _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() );
1359 SMESH::SMESH_Mesh_var aMeshVar =
1360 SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() );
1361 if (aMeshVar->_is_nil())
1364 // GEOM shape of the main mesh
1365 GEOM::GEOM_Object_var mainGeom = aMeshVar->GetShapeToMesh();
1367 // Name for the new sub-mesh
1368 QString aName = myDlg->objectText(SMESHGUI_MeshDlg::Obj);
1371 GEOM::GEOM_Object_var aGeomVar;
1373 myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
1374 if (aGEOMs.count() == 1)
1376 //QString aGeomEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Geom );
1377 QString aGeomEntry = aGEOMs.first();
1378 _PTR(SObject) pGeom = studyDS()->FindObjectID( aGeomEntry.latin1() );
1379 aGeomVar = GEOM::GEOM_Object::_narrow( _CAST( SObject,pGeom )->GetObject() );
1381 else if (aGEOMs.count() > 1)
1383 // create a GEOM group
1384 GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
1385 _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
1386 if (!geomGen->_is_nil() && aStudy) {
1387 GEOM::GEOM_IGroupOperations_var op =
1388 geomGen->GetIGroupOperations(aStudy->StudyId());
1389 if (!op->_is_nil()) {
1390 // check and add all selected GEOM objects: they must be
1391 // a sub-shapes of the main GEOM and must be of one type
1393 TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE;
1394 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1395 aSeq->length(aGEOMs.count());
1396 QStringList::const_iterator aSubShapesIter = aGEOMs.begin();
1397 for (; aSubShapesIter != aGEOMs.end(); aSubShapesIter++, iSubSh++) {
1398 QString aSubGeomEntry = (*aSubShapesIter);
1399 _PTR(SObject) pSubGeom = studyDS()->FindObjectID(aSubGeomEntry.latin1());
1400 GEOM::GEOM_Object_var aSubGeomVar =
1401 GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
1402 TopAbs_ShapeEnum aSubShapeType = (TopAbs_ShapeEnum)aSubGeomVar->GetShapeType();
1404 aGroupType = aSubShapeType;
1406 if (aSubShapeType != aGroupType)
1407 aGroupType = TopAbs_SHAPE;
1409 aSeq[iSubSh] = aSubGeomVar;
1412 GEOM::GEOM_Object_var aGroupVar = op->CreateGroup(mainGeom, aGroupType);
1413 op->UnionList(aGroupVar, aSeq);
1416 aGeomVar = aGroupVar;
1418 // publish the GEOM group in study
1419 QString aNewGeomGroupName ("Auto_group_for_");
1420 aNewGeomGroupName += aName;
1421 SALOMEDS::SObject_var aNewGroupSO =
1422 geomGen->AddInStudy(aSMESHGen->GetCurrentStudy(), aGeomVar, aNewGeomGroupName, mainGeom);
1429 if (aGeomVar->_is_nil())
1432 SUIT_OverrideCursor aWaitCursor;
1435 SMESH::SMESH_subMesh_var aSubMeshVar = aMeshVar->GetSubMesh( aGeomVar, aName.latin1() );
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.latin1() );
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.latin1() );
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 CORBA::String_var aHypTypeName = aVar->GetName();
1670 HypothesisData* algoData = SMESH::GetHypothesisData( aHypTypeName );
1671 aHypIndex = myAvailableHypData[ dim ][ Algo ].findIndex ( algoData );
1672 // if ( aHypIndex < 0 && algoData ) {
1673 // // assigned algo is incompatible with other algorithms
1674 // myAvailableHypData[ dim ][ Algo ].push_back( algoData );
1675 // aHypIndex = myAvailableHypData[ dim ][ hypType ].count() - 1;
1678 setCurrentHyp( dim, Algo, aHypIndex );
1679 // set existing and available hypothesis according to the selected algo
1680 onAlgoSelected( aHypIndex, dim );
1684 bool hypWithoutAlgo = false;
1685 for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
1687 for ( int hypType = MainHyp; hypType <= AddHyp; hypType++ )
1690 existingHyps( dim, hypType, pObj, anExisting, myObjHyps[ dim ][ hypType ] );
1691 // find index of requered hypothesis among existing ones for this dimension and type
1693 if ( myObjHyps[ dim ][ hypType ].count() > 0 ) {
1694 aHypIndex = find( myObjHyps[ dim ][ hypType ].first().first,
1695 myExistingHyps[ dim ][ hypType ] );
1696 if ( aHypIndex < 0 ) {
1697 // assigned hypothesis is incompatible with the algorithm
1698 if ( currentHyp( dim, Algo ) < 0 )
1699 { // none algo selected; it is edition for sure, of submesh maybe
1700 hypWithoutAlgo = true;
1701 myExistingHyps[ dim ][ hypType ].push_back( myObjHyps[ dim ][ hypType ].first() );
1702 aHypIndex = myExistingHyps[ dim ][ hypType ].count() - 1;
1703 myDlg->tab( dim )->setExistingHyps( hypType, anExisting );
1707 setCurrentHyp( dim, hypType, aHypIndex );
1710 // make available other hyps of same type as one without algo
1711 if ( hypWithoutAlgo )
1712 onAlgoSelected( currentHyp( 0, Algo ), 0 );
1715 //================================================================================
1717 * \brief Gets name of object
1718 * \param theSO - SObject
1719 * \retval QString - name of object
1721 * Gets name of object
1723 //================================================================================
1724 QString SMESHGUI_MeshOp::name( _PTR(SObject) theSO ) const
1729 _PTR(GenericAttribute) anAttr;
1730 _PTR(AttributeName) aNameAttr;
1731 if ( theSO->FindAttribute( anAttr, "AttributeName" ) )
1734 aResName = aNameAttr->Value().c_str();
1740 //================================================================================
1742 * \brief Finds hypothesis in input list
1743 * \param theHyp - hypothesis to be found
1744 * \param theHypList - input list of hypotheses
1745 * \retval int - index of hypothesis or -1 if it is not found
1747 * Finds position of hypothesis in input list
1749 //================================================================================
1750 int SMESHGUI_MeshOp::find( const SMESH::SMESH_Hypothesis_var& theHyp,
1751 const THypList& theHypList ) const
1754 if ( !theHyp->_is_nil() )
1757 THypList::const_iterator anIter = theHypList.begin();
1758 for (; anIter != theHypList.end(); ++ anIter)
1760 if ( theHyp->_is_equivalent( (*anIter).first ) )
1771 //================================================================================
1773 * \brief Edits mesh or sub-mesh
1774 * \param theMess - Output parameter intended for returning error message
1775 * \retval bool - TRUE if mesh is edited succesfully, FALSE otherwise
1777 * Assigns new name hypotheses and algoriths to the mesh or sub-mesh
1779 //================================================================================
1780 bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess )
1784 SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
1785 if ( aSMESHGen->_is_nil() )
1788 QString anObjEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Obj );
1789 _PTR(SObject) pObj = studyDS()->FindObjectID( anObjEntry.latin1() );
1793 SUIT_OverrideCursor aWaitCursor;
1796 QString aName = myDlg->objectText( SMESHGUI_MeshDlg::Obj );
1797 SMESH::SetName( pObj, aName.latin1() );
1798 int aDim = ( myIsOnGeometry ) ? SMESH::DIM_0D : SMESH::DIM_3D;
1800 // First, remove old algos in order to avoid messages on algorithm hiding
1801 for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
1803 if ( isAccessibleDim( dim ) && myObjHyps[ dim ][ Algo ].count() > 0 )
1805 SMESH::SMESH_Hypothesis_var anOldAlgo = myObjHyps[ dim ][ Algo ].first().first;
1806 CORBA::String_var anOldName = anOldAlgo->GetName();
1807 SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( dim );
1808 // CORBA::String_var anAlgoName = anAlgoVar->GetName();
1809 if ( anAlgoVar->_is_nil() || // no new algo selected or
1810 strcmp(anOldName.in(), anAlgoVar->GetName()) ) // algo change
1812 // remove old algorithm
1813 SMESH::RemoveHypothesisOrAlgorithmOnMesh ( pObj, myObjHyps[ dim ][ Algo ].first().first );
1814 myObjHyps[ dim ][ Algo ].clear();
1819 // Assign new algorithms and hypotheses
1820 for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
1822 if ( !isAccessibleDim( dim )) continue;
1824 // find or create algorithm
1825 SMESH::SMESH_Hypothesis_var anAlgoVar = getAlgo( dim );
1827 // assign new algorithm
1828 if ( !anAlgoVar->_is_nil() && // some algo selected and
1829 myObjHyps[ dim ][ Algo ].count() == 0 ) // no algo assigned
1831 SALOMEDS_SObject* aSObject = _CAST(SObject, pObj);
1832 CORBA::Object_var anObject = aSObject->GetObject();
1833 SMESH::SMESH_Mesh_var aMeshVar = SMESH::SMESH_Mesh::_narrow( anObject );
1834 bool isMesh = !aMeshVar->_is_nil();
1836 SMESH::AddHypothesisOnMesh( aMeshVar, anAlgoVar );
1838 SMESH::SMESH_subMesh_var aVar =
1839 SMESH::SMESH_subMesh::_narrow( _CAST(SObject,pObj)->GetObject() );
1840 if ( !aVar->_is_nil() )
1841 SMESH::AddHypothesisOnSubMesh( aVar, anAlgoVar );
1843 myObjHyps[ dim ][ Algo ].append( THypItem( anAlgoVar, aName) );
1846 // assign hypotheses
1847 for ( int hypType = MainHyp; hypType <= AddHyp; hypType++ )
1849 int aNewHypIndex = currentHyp( dim, hypType );
1850 int anOldHypIndex = -1;
1852 // remove old hypotheses
1853 if ( myObjHyps[ dim ][ hypType ].count() > 0 )
1855 anOldHypIndex = find( myObjHyps[ dim ][ hypType ].first().first ,
1856 myExistingHyps[ dim ][ hypType ] );
1857 if ( aNewHypIndex != anOldHypIndex || // different hyps
1858 anOldHypIndex == -1 ) // hyps of different algos
1860 SMESH::RemoveHypothesisOrAlgorithmOnMesh
1861 ( pObj, myObjHyps[ dim ][ hypType ].first().first );
1862 myObjHyps[ dim ][ hypType ].clear();
1866 // assign new hypotheses
1867 if ( aNewHypIndex != anOldHypIndex && aNewHypIndex != -1 )
1869 SMESH::SMESH_Mesh_var aMeshVar =
1870 SMESH::SMESH_Mesh::_narrow( _CAST(SObject,pObj)->GetObject() );
1871 bool isMesh = !aMeshVar->_is_nil();
1874 SMESH::AddHypothesisOnMesh
1875 (aMeshVar, myExistingHyps[ dim ][ hypType ][ aNewHypIndex ].first );
1879 SMESH::SMESH_subMesh_var aVar =
1880 SMESH::SMESH_subMesh::_narrow( _CAST(SObject,pObj)->GetObject() );
1881 if ( !aVar->_is_nil() )
1882 SMESH::AddHypothesisOnSubMesh
1883 ( aVar, myExistingHyps[ dim ][ hypType ][ aNewHypIndex ].first );
1886 // reread all hypotheses of mesh if necessary
1887 QStringList anExisting;
1888 existingHyps( dim, hypType, pObj, anExisting, myObjHyps[ dim ][ hypType ] );
1895 //================================================================================
1897 * \brief Verifies whether given operator is valid for this one
1898 * \param theOtherOp - other operation
1899 * \return Returns TRUE if the given operator is valid for this one, FALSE otherwise
1901 * method redefined from base class verifies whether given operator is valid for
1902 * this one (i.e. can be started "above" this operator). In current implementation method
1903 * retuns false if theOtherOp operation is not intended for deleting objects or mesh
1906 //================================================================================
1907 bool SMESHGUI_MeshOp::isValid( SUIT_Operation* theOp ) const
1909 return SMESHGUI_Operation::isValid( theOp ) && !theOp->inherits( "SMESHGUI_MeshOp" );
1912 //================================================================================
1914 * \brief SLOT. Is called when the user selects a way of geometry selection
1915 * \param theByMesh - true if the user wants to find geometry by mesh element
1917 //================================================================================
1919 void SMESHGUI_MeshOp::onGeomSelectionByMesh( bool theByMesh )
1922 if ( !myShapeByMeshOp ) {
1923 myShapeByMeshOp = new SMESHGUI_ShapeByMeshOp();
1924 connect(myShapeByMeshOp, SIGNAL(committed(SUIT_Operation*)),
1925 SLOT(onPublishShapeByMeshDlg(SUIT_Operation*)));
1926 connect(myShapeByMeshOp, SIGNAL(aborted(SUIT_Operation*)),
1927 SLOT(onCloseShapeByMeshDlg(SUIT_Operation*)));
1929 // set mesh object to SMESHGUI_ShapeByMeshOp and start it
1930 QString aMeshEntry = myDlg->selectedObject( SMESHGUI_MeshDlg::Mesh );
1931 if ( _PTR(SObject) pMesh = studyDS()->FindObjectID( aMeshEntry.latin1() )) {
1932 SMESH::SMESH_Mesh_var aMeshVar =
1933 SMESH::SMESH_Mesh::_narrow( _CAST( SObject,pMesh )->GetObject() );
1934 if ( !aMeshVar->_is_nil() ) {
1935 myDlg->hide(); // stop processing selection
1936 myShapeByMeshOp->setModule( getSMESHGUI() );
1937 myShapeByMeshOp->setStudy( 0 ); // it's really necessary
1938 myShapeByMeshOp->SetMesh( aMeshVar );
1939 myShapeByMeshOp->start();
1945 //================================================================================
1947 * \brief SLOT. Is called when Ok is pressed in SMESHGUI_ShapeByMeshDlg
1949 //================================================================================
1951 void SMESHGUI_MeshOp::onPublishShapeByMeshDlg(SUIT_Operation* op)
1953 if ( myShapeByMeshOp == op ) {
1954 SMESHGUI::GetSMESHGUI()->getApp()->updateObjectBrowser(); //MZN: 24.11.2006 IPAL13980 - Object Browser update added
1956 // Select a found geometry object
1957 GEOM::GEOM_Object_var aGeomVar = myShapeByMeshOp->GetShape();
1958 if ( !aGeomVar->_is_nil() )
1960 QString ID = aGeomVar->GetStudyEntry();
1961 if ( _PTR(SObject) aGeomSO = studyDS()->FindObjectID( ID.latin1() )) {
1962 selectObject( aGeomSO );
1969 //================================================================================
1971 * \brief SLOT. Is called when Close is pressed in SMESHGUI_ShapeByMeshDlg
1973 //================================================================================
1975 void SMESHGUI_MeshOp::onCloseShapeByMeshDlg(SUIT_Operation* op)
1977 if ( myShapeByMeshOp == op && myDlg ) {
1982 //================================================================================
1984 * \brief Selects a SObject
1985 * \param theSObj - the SObject to select
1987 //================================================================================
1989 void SMESHGUI_MeshOp::selectObject( _PTR(SObject) theSObj ) const
1991 if ( LightApp_SelectionMgr* sm = selectionMgr() ) {
1992 SALOME_ListIO anIOList;
1994 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject
1995 ( theSObj->GetID().c_str(), "SMESH", theSObj->GetName().c_str() );
1996 anIOList.Append( anIO );
1998 sm->setSelectedObjects( anIOList, false );