1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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, or (at your option) any later version.
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
23 // SMESH SMESHGUI_Selection
24 // File : SMESHGUI_Selection.cxx
25 // Author : Alexander SOLOVYOV, Open CASCADE S.A.S.
29 #include "SMESHGUI_Selection.h"
31 #include "SMESHGUI_Utils.h"
32 #include "SMESHGUI_VTKUtils.h"
33 #include "SMESHGUI_GEOMGenUtils.h"
34 #include "SMESHGUI_ComputeDlg.h"
35 #include "SMESHGUI_ConvToQuadOp.h"
37 #include <SMESH_Type.h>
38 #include <SMESH_Actor.h>
39 #include <SMESH_ScalarBarActor.h>
41 // SALOME GUI includes
42 #include <SalomeApp_Study.h>
43 #include <LightApp_VTKSelector.h>
44 #include <SVTK_ViewWindow.h>
47 #include <SALOMEconfig.h>
48 #include CORBA_CLIENT_HEADER(SMESH_Gen)
49 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
50 #include CORBA_CLIENT_HEADER(SMESH_Group)
52 //=======================================================================
53 //function : SMESHGUI_Selection
55 //=======================================================================
56 SMESHGUI_Selection::SMESHGUI_Selection()
57 : LightApp_Selection()
61 //=======================================================================
62 //function : ~SMESHGUI_Selection
64 //=======================================================================
65 SMESHGUI_Selection::~SMESHGUI_Selection()
69 //=======================================================================
72 //=======================================================================
73 void SMESHGUI_Selection::init( const QString& client, LightApp_SelectionMgr* mgr )
75 LightApp_Selection::init( client, mgr );
79 SalomeApp_Study* aSStudy = dynamic_cast<SalomeApp_Study*>(study());
82 _PTR(Study) aStudy = aSStudy->studyDS();
84 for( int i=0, n=count(); i<n; i++ ) {
85 myTypes.append( typeName( type( entry( i ), aStudy ) ) );
86 myControls.append( controlMode( i ) );
91 //=======================================================================
92 //function : processOwner
94 //=======================================================================
95 bool SMESHGUI_Selection::processOwner( const LightApp_DataOwner* ow )
97 const LightApp_SVTKDataOwner* owner =
98 dynamic_cast<const LightApp_SVTKDataOwner*> ( ow );
100 myActors.append( dynamic_cast<SMESH_Actor*>( owner->GetActor() ) );
102 else if ( ow ) { // SVTK selection disabled
103 QString entry = ow->entry();
104 myActors.append( SMESH::FindActorByEntry( entry.toStdString().c_str() ));
107 myActors.append( 0 );
112 //=======================================================================
113 //function : parameter
115 //=======================================================================
116 QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const
119 if ( p=="client" ) val = QVariant( LightApp_Selection::parameter( p ) );
120 else if ( p=="type" ) val = QVariant( myTypes[ind] );
121 else if ( p=="elemTypes" ) val = QVariant( elemTypes( ind ) );
122 else if ( p=="isAutoColor" ) val = QVariant( isAutoColor( ind ) );
123 else if ( p=="numberOfNodes" ) val = QVariant( numberOfNodes( ind ) );
124 else if ( p=="dim" ) val = QVariant( dim( ind ) );
125 else if ( p=="labeledTypes" ) val = QVariant( labeledTypes( ind ) );
126 else if ( p=="shrinkMode" ) val = QVariant( shrinkMode( ind ) );
127 else if ( p=="entityMode" ) val = QVariant( entityMode( ind ) );
128 else if ( p=="isNumFunctor" ) val = QVariant( isNumFunctor( ind ) );
129 else if ( p=="displayMode" ) val = QVariant( displayMode( ind ) );
130 else if ( p=="isComputable" ) val = QVariant( isComputable( ind ) );
131 else if ( p=="isPreComputable" ) val = QVariant( isPreComputable( ind ) );
132 else if ( p=="hasGeomReference" ) val = QVariant( hasGeomReference( ind ) );
133 else if ( p=="isEditableHyp" ) val = QVariant( isEditableHyp( ind ) );
134 else if ( p=="isImported" ) val = QVariant( isImported( ind ) );
135 else if ( p=="facesOrientationMode" ) val = QVariant( facesOrientationMode( ind ) );
136 else if ( p=="groupType" ) val = QVariant( groupType( ind ) );
137 else if ( p=="isQuadratic" ) val = QVariant( isQuadratic( ind ) );
138 else if ( p=="quadratic2DMode") val = QVariant( quadratic2DMode( ind ) );
139 else if ( p=="isDistributionVisible") val = QVariant( isDistributionVisible( ind ) );
140 else if ( p=="isScalarBarVisible") val = QVariant( isScalarBarVisible( ind ) );
141 else if ( p=="hasChildren") val = QVariant( hasChildren( ind ) );
142 else if ( p=="nbChildren") val = QVariant( nbChildren( ind ) );
143 else if ( p=="isContainer") val = QVariant( isContainer( ind ) );
148 return LightApp_Selection::parameter( ind, p );
151 //=======================================================================
152 //function : parameter
154 //=======================================================================
155 QVariant SMESHGUI_Selection::parameter( const QString& p ) const
158 if ( p=="controlMode" ) val = QVariant( controlMode() );
163 return LightApp_Selection::parameter( p );
166 //=======================================================================
167 //function : getVtkOwner
169 //=======================================================================
171 SMESH_Actor* SMESHGUI_Selection::getActor( int ind ) const
173 if( ind >= 0 && ind < count() )
174 return myActors.isEmpty() ? 0 : myActors.at( ind );
179 //=======================================================================
180 //function : elemTypes
181 //purpose : may return {'Elem0d' 'Edge' 'Face' 'Volume' 'BallElem'} at most
182 //=======================================================================
184 QList<QVariant> SMESHGUI_Selection::elemTypes( int ind ) const
186 QList<QVariant> types;
187 SMESH_Actor* actor = getActor( ind );
189 TVisualObjPtr object = actor->GetObject();
191 if ( object->GetNbEntities( SMDSAbs_0DElement )) types.append( "Elem0d" );
192 if ( object->GetNbEntities( SMDSAbs_Ball )) types.append( "BallElem" );
193 if ( object->GetNbEntities( SMDSAbs_Edge )) types.append( "Edge" );
194 if ( object->GetNbEntities( SMDSAbs_Face )) types.append( "Face" );
195 if ( object->GetNbEntities( SMDSAbs_Volume )) types.append( "Volume" );
201 //=======================================================================
202 //function : labeledTypes
203 //purpose : may return {'Point' 'Cell'} at most
204 //=======================================================================
206 QList<QVariant> SMESHGUI_Selection::labeledTypes( int ind ) const
208 QList<QVariant> types;
209 SMESH_Actor* actor = getActor( ind );
211 if ( actor->GetPointsLabeled()) types.append( "Point" );
212 if ( actor->GetCellsLabeled()) types.append( "Cell" );
217 //=======================================================================
218 //function : displayMode
219 //purpose : return SMESH_Actor::EReperesent
220 //=======================================================================
222 QString SMESHGUI_Selection::displayMode( int ind ) const
224 SMESH_Actor* actor = getActor( ind );
226 switch( actor->GetRepresentation() ) {
227 case SMESH_Actor::eEdge: return "eEdge";
228 case SMESH_Actor::eSurface: return "eSurface";
229 case SMESH_Actor::ePoint: return "ePoint";
236 //=======================================================================
237 //function : isQuadratic
238 //purpose : return true if the mesh has quadratic/bi-quadratic type
239 //=======================================================================
241 bool SMESHGUI_Selection::isQuadratic( int ind ) const
243 _PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
246 SMESH::SMESH_IDSource_var idSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( so );
247 if ( idSource->_is_nil() )
249 SMESHGUI_ConvToQuadOp::MeshDestinationType meshTgtType = SMESHGUI_ConvToQuadOp::DestinationMesh( idSource );
250 if ( meshTgtType & SMESHGUI_ConvToQuadOp::Linear )
255 //=======================================================================
256 //function : quadratic2DMode
257 //purpose : return SMESH_Actor::EQuadratic2DRepresentation
258 //=======================================================================
259 QString SMESHGUI_Selection::quadratic2DMode( int ind ) const
261 SMESH_Actor* actor = getActor( ind );
263 switch( actor->GetQuadratic2DRepresentation() ) {
264 case SMESH_Actor::eLines: return "eLines";
265 case SMESH_Actor::eArcs: return "eArcs";
272 //=======================================================================
273 //function : isDistributionVisible
274 //purpose : Visible/Invisible distribution of the ScalarBar Actor
275 //=======================================================================
277 bool SMESHGUI_Selection::isDistributionVisible(int ind) const {
278 SMESH_Actor* actor = getActor( ind );
279 return (actor && actor->GetScalarBarActor() && actor->GetScalarBarActor()->GetDistributionVisibility());
282 //=======================================================================
283 //function : isScalarBarVisible
284 //purpose : Visible/Invisible Scalar Bar
285 //=======================================================================
287 bool SMESHGUI_Selection::isScalarBarVisible(int ind) const {
288 SMESH_Actor* actor = getActor( ind );
289 return (actor && actor->GetScalarBarActor() && actor->GetScalarBarActor()->GetVisibility());
292 //=======================================================================
293 //function : shrinkMode
294 //purpose : return either 'IsSrunk', 'IsNotShrunk' or 'IsNotShrinkable'
295 //=======================================================================
297 QString SMESHGUI_Selection::shrinkMode( int ind ) const
299 SMESH_Actor* actor = getActor( ind );
300 if ( actor && actor->IsShrunkable() ) {
301 return actor->IsShrunk() ? "IsShrunk" : "IsNotShrunk";
303 return "IsNotShrinkable";
306 //=======================================================================
307 //function : entityMode
308 //purpose : may return {'Elem0d' 'Edge' 'Face' 'Volume' 'BallElem' } at most
309 //=======================================================================
311 QList<QVariant> SMESHGUI_Selection::entityMode( int ind ) const
313 QList<QVariant> types;
314 SMESH_Actor* actor = getActor( ind );
316 unsigned int aMode = actor->GetEntityMode();
317 if ( aMode & SMESH_Actor::eVolumes ) types.append( "Volume" );
318 if ( aMode & SMESH_Actor::eFaces ) types.append( "Face" );
319 if ( aMode & SMESH_Actor::eEdges ) types.append( "Edge" );
320 if ( aMode & SMESH_Actor::e0DElements ) types.append( "Elem0d" );
321 if ( aMode & SMESH_Actor::eBallElem ) types.append( "BallElem" );
326 //=======================================================================
327 //function : controlMode
328 //purpose : return SMESH_Actor::eControl
329 //=======================================================================
331 QString SMESHGUI_Selection::controlMode( int ind ) const
333 SMESH_Actor* actor = getActor( ind );
334 QString mode = "eNone";
336 switch( actor->GetControlMode() ) {
337 case SMESH_Actor::eLength: mode = "eLength"; break;
338 case SMESH_Actor::eLength2D: mode = "eLength2D"; break;
339 case SMESH_Actor::eFreeEdges: mode = "eFreeEdges"; break;
340 case SMESH_Actor::eFreeNodes: mode = "eFreeNodes"; break;
341 case SMESH_Actor::eFreeBorders: mode = "eFreeBorders"; break;
342 case SMESH_Actor::eFreeFaces: mode = "eFreeFaces"; break;
343 case SMESH_Actor::eMultiConnection: mode = "eMultiConnection"; break;
344 case SMESH_Actor::eMultiConnection2D: mode = "eMultiConnection2D"; break;
345 case SMESH_Actor::eArea: mode = "eArea"; break;
346 case SMESH_Actor::eVolume3D: mode = "eVolume3D"; break;
347 case SMESH_Actor::eMaxElementLength2D: mode = "eMaxElementLength2D"; break;
348 case SMESH_Actor::eMaxElementLength3D: mode = "eMaxElementLength3D"; break;
349 case SMESH_Actor::eTaper: mode = "eTaper"; break;
350 case SMESH_Actor::eAspectRatio: mode = "eAspectRatio"; break;
351 case SMESH_Actor::eAspectRatio3D: mode = "eAspectRatio3D"; break;
352 case SMESH_Actor::eMinimumAngle: mode = "eMinimumAngle"; break;
353 case SMESH_Actor::eWarping: mode = "eWarping"; break;
354 case SMESH_Actor::eSkew: mode = "eSkew"; break;
355 case SMESH_Actor::eBareBorderFace: mode = "eBareBorderFace"; break;
356 case SMESH_Actor::eBareBorderVolume: mode = "eBareBorderVolume"; break;
357 case SMESH_Actor::eOverConstrainedFace: mode = "eOverConstrainedFace"; break;
358 case SMESH_Actor::eOverConstrainedVolume: mode = "eOverConstrainedVolume"; break;
359 case SMESH_Actor::eCoincidentNodes: mode = "eCoincidentNodes"; break;
360 case SMESH_Actor::eCoincidentElems1D: mode = "eCoincidentElems1D"; break;
361 case SMESH_Actor::eCoincidentElems2D: mode = "eCoincidentElems2D"; break;
362 case SMESH_Actor::eCoincidentElems3D: mode = "eCoincidentElems3D"; break;
369 //=======================================================================
370 //function : controlMode
371 //purpose : gets global control mode; return SMESH_Actor::eControl
372 //=======================================================================
373 QString SMESHGUI_Selection::controlMode() const
375 if( myControls.count() > 0 ) {
376 QString mode = myControls[0];
377 for( int ind = 1; ind < myControls.count(); ind++ ) {
378 if( mode != myControls[ind] )
379 return "eMixed"; // different controls used for different actors
386 bool SMESHGUI_Selection::isNumFunctor( int ind ) const
389 SMESH_Actor* actor = getActor( ind );
391 switch( actor->GetControlMode() ) {
392 case SMESH_Actor::eLength:
393 case SMESH_Actor::eLength2D:
394 case SMESH_Actor::eMultiConnection:
395 case SMESH_Actor::eMultiConnection2D:
396 case SMESH_Actor::eArea:
397 case SMESH_Actor::eVolume3D:
398 case SMESH_Actor::eMaxElementLength2D:
399 case SMESH_Actor::eMaxElementLength3D:
400 case SMESH_Actor::eTaper:
401 case SMESH_Actor::eAspectRatio:
402 case SMESH_Actor::eAspectRatio3D:
403 case SMESH_Actor::eMinimumAngle:
404 case SMESH_Actor::eWarping:
405 case SMESH_Actor::eSkew:
415 //=======================================================================
416 //function : facesOrientationMode
418 //=======================================================================
420 QString SMESHGUI_Selection::facesOrientationMode( int ind ) const
422 SMESH_Actor* actor = getActor( ind );
424 return actor->GetFacesOriented() ? "IsOriented" : "IsNotOriented";
429 //=======================================================================
430 //function : isAutoColor
432 //=======================================================================
434 bool SMESHGUI_Selection::isAutoColor( int ind ) const
436 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
438 _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
439 CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() );
441 if ( !CORBA::is_nil( obj ) ) {
442 SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
443 if ( !CORBA::is_nil( mesh ) )
444 return mesh->GetAutoColor();
450 //=======================================================================
451 //function : numberOfNodes
452 //purpose : this method is actually used to check if an object is empty or not
453 //=======================================================================
455 int SMESHGUI_Selection::numberOfNodes( int ind ) const
457 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
459 _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
460 CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() );
462 if ( !CORBA::is_nil( obj ) ) {
463 SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
464 if ( !CORBA::is_nil( mesh ) )
465 return mesh->NbNodes();
466 SMESH::SMESH_subMesh_var aSubMeshObj = SMESH::SMESH_subMesh::_narrow( obj );
467 if ( !CORBA::is_nil( aSubMeshObj ) )
468 return aSubMeshObj->GetNumberOfNodes(true);
469 SMESH::SMESH_GroupBase_var aGroupObj = SMESH::SMESH_GroupBase::_narrow( obj );
470 if ( !CORBA::is_nil( aGroupObj ) )
471 return aGroupObj->IsEmpty() ? 0 : 1; // aGroupObj->Size();
477 //================================================================================
479 * \brief return dimension of elements of the selected object
481 * \retval int - 0 for 0D elements, -1 for an empty object (the rest as usual)
483 //================================================================================
485 int SMESHGUI_Selection::dim( int ind ) const
488 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
490 _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
491 CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() );
493 if ( !CORBA::is_nil( obj ) ) {
494 SMESH::SMESH_IDSource_var idSrc = SMESH::SMESH_IDSource::_narrow( obj );
495 if ( !CORBA::is_nil( idSrc ) )
497 SMESH::array_of_ElementType_var types = idSrc->GetTypes();
498 for ( size_t i = 0; i < types->length(); ++ i) {
499 switch ( types[i] ) {
500 case SMESH::EDGE : dim = std::max( dim, 1 ); break;
501 case SMESH::FACE : dim = std::max( dim, 2 ); break;
502 case SMESH::VOLUME: dim = std::max( dim, 3 ); break;
503 case SMESH::ELEM0D: dim = std::max( dim, 0 ); break;
504 case SMESH::BALL : dim = std::max( dim, 0 ); break;
514 //=======================================================================
515 //function : isComputable
516 //purpose : return true for a ready-to-compute mesh
517 //=======================================================================
519 bool SMESHGUI_Selection::isComputable( int ind ) const
521 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] == "Mesh" )
523 QMap<int,int> modeMap;
524 _PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
525 SMESHGUI_PrecomputeOp::getAssignedAlgos( so, modeMap );
526 return modeMap.size() > 0;
531 //=======================================================================
532 //function : isPreComputable
533 //purpose : returns true for a mesh with algorithms
534 //=======================================================================
536 bool SMESHGUI_Selection::isPreComputable( int ind ) const
538 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] == "Mesh" )
540 int maxDim = dim( ind );
541 if ( maxDim < 2 ) // we can preview 1D or 2D
543 QMap<int,int> modeMap;
544 _PTR(SObject) pMesh = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
545 SMESHGUI_PrecomputeOp::getAssignedAlgos( pMesh, modeMap );
546 if ( modeMap.size() > 1 )
547 return (( modeMap.contains( SMESH::DIM_3D )) ||
548 ( modeMap.contains( SMESH::DIM_2D ) && maxDim < 1 ));
554 //=======================================================================
555 //function : hasGeomReference
556 //purpose : returns true for a mesh or sub-mesh on geometry
557 //=======================================================================
559 bool SMESHGUI_Selection::hasGeomReference( int ind ) const
561 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
563 _PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
564 GEOM::GEOM_Object_var shape = SMESH::GetShapeOnMeshOrSubMesh( so );
565 return !shape->_is_nil();
570 //=======================================================================
571 //function : isEditableHyp
573 //=======================================================================
575 bool SMESHGUI_Selection::isEditableHyp( int ind ) const
577 bool isEditable = true;
578 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] == "Hypothesis" )
580 _PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
581 SMESH::SMESH_Hypothesis_var hyp = SMESH::SObjectToInterface<SMESH::SMESH_Hypothesis>( so );
582 if ( !hyp->_is_nil() )
584 isEditable = hyp->HasParameters();
590 //=======================================================================
591 //function : isVisible
593 //=======================================================================
595 bool SMESHGUI_Selection::isVisible( int ind ) const
597 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
599 SMESH_Actor* actor = SMESH::FindActorByEntry( entry( ind ).toLatin1().data() );
600 if ( actor && actor->hasIO() ) {
601 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView() )
602 return aViewWindow->isVisible( actor->getIO() );
608 //=======================================================================
609 //function : hasChildren
611 //=======================================================================
613 bool SMESHGUI_Selection::hasChildren( int ind ) const
617 _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
619 return SMESH::GetActiveStudyDocument()->GetUseCaseBuilder()->HasChildren( sobj );
624 //=======================================================================
625 //function : hasChildren
627 //=======================================================================
629 int SMESHGUI_Selection::nbChildren( int ind ) const
634 _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
635 if ( sobj && sobj->GetStudy()->GetUseCaseBuilder()->IsUseCaseNode( sobj ) ) {
636 _PTR(UseCaseIterator) it = sobj->GetStudy()->GetUseCaseBuilder()->GetUseCaseIterator( sobj );
637 for ( it->Init( false ); it->More(); it->Next() ) nb++;
643 //=======================================================================
644 //function : isContainer
646 //=======================================================================
648 bool SMESHGUI_Selection::isContainer( int ind ) const
650 return ind >= 0 && ind < myTypes.count() && myTypes[ind] == "Unknown";
653 //=======================================================================
656 //=======================================================================
658 int SMESHGUI_Selection::type( const QString& entry, _PTR(Study) study )
661 _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().data() );
664 if ( obj->ReferencedObject( ref ) )
667 _PTR(SObject) objFather = obj->GetFather();
668 _PTR(SComponent) objComponent = obj->GetFatherComponent();
670 if ( objComponent->ComponentDataType() == "SMESH" ) {
671 if ( objComponent->GetIOR() == obj->GetIOR() ) {
672 res = SMESH::COMPONENT;
675 int aLevel = obj->Depth() - objComponent->Depth(),
676 aFTag = objFather->Tag(),
682 if ( anOTag >= SMESH::Tag_FirstMeshRoot )
688 case SMESH::Tag_HypothesisRoot: res = SMESH::HYPOTHESIS; break;
689 case SMESH::Tag_AlgorithmsRoot: res = SMESH::ALGORITHM; break;
696 case SMESH::Tag_SubMeshOnVertex: res = SMESH::SUBMESH_VERTEX; break;
697 case SMESH::Tag_SubMeshOnEdge: res = SMESH::SUBMESH_EDGE; break;
698 case SMESH::Tag_SubMeshOnFace: res = SMESH::SUBMESH_FACE; break;
699 case SMESH::Tag_SubMeshOnSolid: res = SMESH::SUBMESH_SOLID; break;
700 case SMESH::Tag_SubMeshOnCompound: res = SMESH::SUBMESH_COMPOUND; break;
702 if ( aFTag >= SMESH::Tag_FirstGroup) res = SMESH::GROUP;
703 else res = SMESH::SUBMESH;
714 //=======================================================================
715 //function : typeName
717 //=======================================================================
719 QString SMESHGUI_Selection::typeName( const int t )
721 QString res = "Unknown";
724 case SMESH::HYPOTHESIS:
725 res = "Hypothesis"; break;
726 case SMESH::ALGORITHM:
727 res = "Algorithm"; break;
731 res = "SubMesh"; break;
732 case SMESH::MESHorSUBMESH:
733 res = "Mesh or submesh"; break;
734 case SMESH::SUBMESH_VERTEX:
735 res = "Mesh vertex"; break;
736 case SMESH::SUBMESH_EDGE:
737 res = "Mesh edge"; break;
738 case SMESH::SUBMESH_FACE:
739 res = "Mesh face"; break;
740 case SMESH::SUBMESH_SOLID:
741 res = "Mesh solid"; break;
742 case SMESH::SUBMESH_COMPOUND:
743 res = "Mesh compound"; break;
745 res = "Group"; break;
746 case SMESH::COMPONENT:
747 res = "Component"; break;
754 bool SMESHGUI_Selection::isImported( const int ind ) const
757 _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().constData() );
760 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( SMESH::SObjectToObject( sobj ) );
761 if( !aMesh->_is_nil() )
763 SMESH::MedFileInfo_var inf = aMesh->GetMEDFileInfo();
764 res = strlen( (char*)inf->fileName ) > 0;
770 //=======================================================================
771 //function : groupType
773 //=======================================================================
775 QString SMESHGUI_Selection::groupType( int ind ) const
777 _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().constData() );
780 SMESH::SMESH_Group_var g = SMESH::SObjectToInterface<SMESH::SMESH_Group>( sobj );
781 if ( !CORBA::is_nil( g ) )
783 SMESH::SMESH_GroupOnGeom_var gog = SMESH::SObjectToInterface<SMESH::SMESH_GroupOnGeom>( sobj );
784 if( !CORBA::is_nil( gog ) )
785 return "GroupOnGeom";
786 SMESH::SMESH_GroupOnFilter_var gof = SMESH::SObjectToInterface<SMESH::SMESH_GroupOnFilter>( sobj );
787 if ( !CORBA::is_nil( gof ) )
788 return "GroupOnFilter";