1 // Copyright (C) 2007-2016 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=="hasActor" ) val = QVariant( getActor( ind ) != 0 );
122 else if ( p=="elemTypes" ) val = QVariant( elemTypes( ind ) );
123 else if ( p=="isAutoColor" ) val = QVariant( isAutoColor( ind ) );
124 else if ( p=="numberOfNodes" ) val = QVariant( numberOfNodes( ind ) );
125 else if ( p=="dim" ) val = QVariant( dim( ind ) );
126 else if ( p=="labeledTypes" ) val = QVariant( labeledTypes( ind ) );
127 else if ( p=="shrinkMode" ) val = QVariant( shrinkMode( ind ) );
128 else if ( p=="entityMode" ) val = QVariant( entityMode( ind ) );
129 else if ( p=="isNumFunctor" ) val = QVariant( isNumFunctor( ind ) );
130 else if ( p=="displayMode" ) val = QVariant( displayMode( ind ) );
131 else if ( p=="isComputable" ) val = QVariant( isComputable( ind ) );
132 else if ( p=="isPreComputable" ) val = QVariant( isPreComputable( ind ) );
133 else if ( p=="hasGeomReference" ) val = QVariant( hasGeomReference( ind ) );
134 else if ( p=="isEditableHyp" ) val = QVariant( isEditableHyp( ind ) );
135 else if ( p=="isImported" ) val = QVariant( isImported( ind ) );
136 else if ( p=="facesOrientationMode" ) val = QVariant( facesOrientationMode( ind ) );
137 else if ( p=="groupType" ) val = QVariant( groupType( ind ) );
138 else if ( p=="isQuadratic" ) val = QVariant( isQuadratic( ind ) );
139 else if ( p=="quadratic2DMode") val = QVariant( quadratic2DMode( ind ) );
140 else if ( p=="isDistributionVisible") val = QVariant( isDistributionVisible( ind ) );
141 else if ( p=="isScalarBarVisible") val = QVariant( isScalarBarVisible( ind ) );
142 else if ( p=="hasChildren") val = QVariant( hasChildren( ind ) );
143 else if ( p=="nbChildren") val = QVariant( nbChildren( ind ) );
144 else if ( p=="isContainer") val = QVariant( isContainer( ind ) );
149 return LightApp_Selection::parameter( ind, p );
152 //=======================================================================
153 //function : parameter
155 //=======================================================================
156 QVariant SMESHGUI_Selection::parameter( const QString& p ) const
159 if ( p=="controlMode" ) val = QVariant( controlMode() );
164 return LightApp_Selection::parameter( p );
167 //=======================================================================
168 //function : getVtkOwner
170 //=======================================================================
172 SMESH_Actor* SMESHGUI_Selection::getActor( int ind ) const
174 if( ind >= 0 && ind < count() )
175 return myActors.isEmpty() ? 0 : myActors.at( ind );
180 //=======================================================================
181 //function : elemTypes
182 //purpose : may return {'Elem0d' 'Edge' 'Face' 'Volume' 'BallElem'} at most
183 //=======================================================================
185 QList<QVariant> SMESHGUI_Selection::elemTypes( int ind ) const
187 QList<QVariant> types;
188 SMESH_Actor* actor = getActor( ind );
190 TVisualObjPtr object = actor->GetObject();
192 if ( object->GetNbEntities( SMDSAbs_0DElement )) types.append( "Elem0d" );
193 if ( object->GetNbEntities( SMDSAbs_Ball )) types.append( "BallElem" );
194 if ( object->GetNbEntities( SMDSAbs_Edge )) types.append( "Edge" );
195 if ( object->GetNbEntities( SMDSAbs_Face )) types.append( "Face" );
196 if ( object->GetNbEntities( SMDSAbs_Volume )) types.append( "Volume" );
202 //=======================================================================
203 //function : labeledTypes
204 //purpose : may return {'Point' 'Cell'} at most
205 //=======================================================================
207 QList<QVariant> SMESHGUI_Selection::labeledTypes( int ind ) const
209 QList<QVariant> types;
210 SMESH_Actor* actor = getActor( ind );
212 if ( actor->GetPointsLabeled()) types.append( "Point" );
213 if ( actor->GetCellsLabeled()) types.append( "Cell" );
218 //=======================================================================
219 //function : displayMode
220 //purpose : return SMESH_Actor::EReperesent
221 //=======================================================================
223 QString SMESHGUI_Selection::displayMode( int ind ) const
225 SMESH_Actor* actor = getActor( ind );
227 switch( actor->GetRepresentation() ) {
228 case SMESH_Actor::eEdge: return "eEdge";
229 case SMESH_Actor::eSurface: return "eSurface";
230 case SMESH_Actor::ePoint: return "ePoint";
237 //=======================================================================
238 //function : isQuadratic
239 //purpose : return true if the mesh has quadratic/bi-quadratic type
240 //=======================================================================
242 bool SMESHGUI_Selection::isQuadratic( int ind ) const
244 _PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
247 SMESH::SMESH_IDSource_var idSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( so );
248 if ( idSource->_is_nil() )
250 SMESHGUI_ConvToQuadOp::MeshDestinationType meshTgtType = SMESHGUI_ConvToQuadOp::DestinationMesh( idSource );
251 if ( meshTgtType & SMESHGUI_ConvToQuadOp::Linear )
256 //=======================================================================
257 //function : quadratic2DMode
258 //purpose : return SMESH_Actor::EQuadratic2DRepresentation
259 //=======================================================================
260 QString SMESHGUI_Selection::quadratic2DMode( int ind ) const
262 SMESH_Actor* actor = getActor( ind );
264 switch( actor->GetQuadratic2DRepresentation() ) {
265 case SMESH_Actor::eLines: return "eLines";
266 case SMESH_Actor::eArcs: return "eArcs";
273 //=======================================================================
274 //function : isDistributionVisible
275 //purpose : Visible/Invisible distribution of the ScalarBar Actor
276 //=======================================================================
278 bool SMESHGUI_Selection::isDistributionVisible(int ind) const {
279 SMESH_Actor* actor = getActor( ind );
280 return (actor && actor->GetScalarBarActor() && actor->GetScalarBarActor()->GetDistributionVisibility());
283 //=======================================================================
284 //function : isScalarBarVisible
285 //purpose : Visible/Invisible Scalar Bar
286 //=======================================================================
288 bool SMESHGUI_Selection::isScalarBarVisible(int ind) const {
289 SMESH_Actor* actor = getActor( ind );
290 return (actor && actor->GetScalarBarActor() && actor->GetScalarBarActor()->GetVisibility());
293 //=======================================================================
294 //function : shrinkMode
295 //purpose : return either 'IsSrunk', 'IsNotShrunk' or 'IsNotShrinkable'
296 //=======================================================================
298 QString SMESHGUI_Selection::shrinkMode( int ind ) const
300 SMESH_Actor* actor = getActor( ind );
301 if ( actor && actor->IsShrunkable() ) {
302 return actor->IsShrunk() ? "IsShrunk" : "IsNotShrunk";
304 return "IsNotShrinkable";
307 //=======================================================================
308 //function : entityMode
309 //purpose : may return {'Elem0d' 'Edge' 'Face' 'Volume' 'BallElem' } at most
310 //=======================================================================
312 QList<QVariant> SMESHGUI_Selection::entityMode( int ind ) const
314 QList<QVariant> types;
315 SMESH_Actor* actor = getActor( ind );
317 unsigned int aMode = actor->GetEntityMode();
318 if ( aMode & SMESH_Actor::eVolumes ) types.append( "Volume" );
319 if ( aMode & SMESH_Actor::eFaces ) types.append( "Face" );
320 if ( aMode & SMESH_Actor::eEdges ) types.append( "Edge" );
321 if ( aMode & SMESH_Actor::e0DElements ) types.append( "Elem0d" );
322 if ( aMode & SMESH_Actor::eBallElem ) types.append( "BallElem" );
327 //=======================================================================
328 //function : controlMode
329 //purpose : return SMESH_Actor::eControl
330 //=======================================================================
332 QString SMESHGUI_Selection::controlMode( int ind ) const
334 SMESH_Actor* actor = getActor( ind );
335 QString mode = "eNone";
337 switch( actor->GetControlMode() ) {
338 case SMESH_Actor::eLength: mode = "eLength"; break;
339 case SMESH_Actor::eLength2D: mode = "eLength2D"; break;
340 case SMESH_Actor::eFreeEdges: mode = "eFreeEdges"; break;
341 case SMESH_Actor::eFreeNodes: mode = "eFreeNodes"; break;
342 case SMESH_Actor::eFreeBorders: mode = "eFreeBorders"; break;
343 case SMESH_Actor::eFreeFaces: mode = "eFreeFaces"; break;
344 case SMESH_Actor::eMultiConnection: mode = "eMultiConnection"; break;
345 case SMESH_Actor::eMultiConnection2D: mode = "eMultiConnection2D"; break;
346 case SMESH_Actor::eArea: mode = "eArea"; break;
347 case SMESH_Actor::eVolume3D: mode = "eVolume3D"; break;
348 case SMESH_Actor::eMaxElementLength2D: mode = "eMaxElementLength2D"; break;
349 case SMESH_Actor::eMaxElementLength3D: mode = "eMaxElementLength3D"; break;
350 case SMESH_Actor::eTaper: mode = "eTaper"; break;
351 case SMESH_Actor::eAspectRatio: mode = "eAspectRatio"; break;
352 case SMESH_Actor::eAspectRatio3D: mode = "eAspectRatio3D"; break;
353 case SMESH_Actor::eMinimumAngle: mode = "eMinimumAngle"; break;
354 case SMESH_Actor::eWarping: mode = "eWarping"; break;
355 case SMESH_Actor::eSkew: mode = "eSkew"; break;
356 case SMESH_Actor::eBareBorderFace: mode = "eBareBorderFace"; break;
357 case SMESH_Actor::eBareBorderVolume: mode = "eBareBorderVolume"; break;
358 case SMESH_Actor::eOverConstrainedFace: mode = "eOverConstrainedFace"; break;
359 case SMESH_Actor::eOverConstrainedVolume: mode = "eOverConstrainedVolume"; break;
360 case SMESH_Actor::eCoincidentNodes: mode = "eCoincidentNodes"; break;
361 case SMESH_Actor::eCoincidentElems1D: mode = "eCoincidentElems1D"; break;
362 case SMESH_Actor::eCoincidentElems2D: mode = "eCoincidentElems2D"; break;
363 case SMESH_Actor::eCoincidentElems3D: mode = "eCoincidentElems3D"; break;
370 //=======================================================================
371 //function : controlMode
372 //purpose : gets global control mode; return SMESH_Actor::eControl
373 //=======================================================================
374 QString SMESHGUI_Selection::controlMode() const
376 if( myControls.count() > 0 ) {
377 QString mode = myControls[0];
378 for( int ind = 1; ind < myControls.count(); ind++ ) {
379 if( mode != myControls[ind] )
380 return "eMixed"; // different controls used for different actors
387 bool SMESHGUI_Selection::isNumFunctor( int ind ) const
390 SMESH_Actor* actor = getActor( ind );
392 switch( actor->GetControlMode() ) {
393 case SMESH_Actor::eLength:
394 case SMESH_Actor::eLength2D:
395 case SMESH_Actor::eMultiConnection:
396 case SMESH_Actor::eMultiConnection2D:
397 case SMESH_Actor::eArea:
398 case SMESH_Actor::eVolume3D:
399 case SMESH_Actor::eMaxElementLength2D:
400 case SMESH_Actor::eMaxElementLength3D:
401 case SMESH_Actor::eTaper:
402 case SMESH_Actor::eAspectRatio:
403 case SMESH_Actor::eAspectRatio3D:
404 case SMESH_Actor::eMinimumAngle:
405 case SMESH_Actor::eWarping:
406 case SMESH_Actor::eSkew:
416 //=======================================================================
417 //function : facesOrientationMode
419 //=======================================================================
421 QString SMESHGUI_Selection::facesOrientationMode( int ind ) const
423 SMESH_Actor* actor = getActor( ind );
425 return actor->GetFacesOriented() ? "IsOriented" : "IsNotOriented";
430 //=======================================================================
431 //function : isAutoColor
433 //=======================================================================
435 bool SMESHGUI_Selection::isAutoColor( int ind ) const
437 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
439 _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
440 CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() );
442 if ( !CORBA::is_nil( obj ) ) {
443 SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
444 if ( !CORBA::is_nil( mesh ) )
445 return mesh->GetAutoColor();
451 //=======================================================================
452 //function : numberOfNodes
453 //purpose : this method is actually used to check if an object is empty or not
454 //=======================================================================
456 int SMESHGUI_Selection::numberOfNodes( int ind ) const
458 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
460 _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
461 CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() );
463 if ( !CORBA::is_nil( obj ) ) {
464 SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
465 if ( !CORBA::is_nil( mesh ) )
466 return mesh->NbNodes();
467 SMESH::SMESH_subMesh_var aSubMeshObj = SMESH::SMESH_subMesh::_narrow( obj );
468 if ( !CORBA::is_nil( aSubMeshObj ) )
469 return aSubMeshObj->GetNumberOfNodes(true);
470 SMESH::SMESH_GroupBase_var aGroupObj = SMESH::SMESH_GroupBase::_narrow( obj );
471 if ( !CORBA::is_nil( aGroupObj ) )
472 return aGroupObj->IsEmpty() ? 0 : 1; // aGroupObj->Size();
478 //================================================================================
480 * \brief return dimension of elements of the selected object
482 * \retval int - 0 for 0D elements, -1 for an empty object (the rest as usual)
484 //================================================================================
486 int SMESHGUI_Selection::dim( int ind ) const
489 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
491 _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
492 CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() );
494 if ( !CORBA::is_nil( obj ) ) {
495 SMESH::SMESH_IDSource_var idSrc = SMESH::SMESH_IDSource::_narrow( obj );
496 if ( !CORBA::is_nil( idSrc ) )
498 SMESH::array_of_ElementType_var types = idSrc->GetTypes();
499 for ( size_t i = 0; i < types->length(); ++ i) {
500 switch ( types[i] ) {
501 case SMESH::EDGE : dim = std::max( dim, 1 ); break;
502 case SMESH::FACE : dim = std::max( dim, 2 ); break;
503 case SMESH::VOLUME: dim = std::max( dim, 3 ); break;
504 case SMESH::ELEM0D: dim = std::max( dim, 0 ); break;
505 case SMESH::BALL : dim = std::max( dim, 0 ); break;
515 //=======================================================================
516 //function : isComputable
517 //purpose : return true for a ready-to-compute mesh
518 //=======================================================================
520 bool SMESHGUI_Selection::isComputable( int ind ) const
522 if ( ind >= 0 && ind < myTypes.count() && ( myTypes[ind] == "Mesh" ||
523 myTypes[ind].startsWith("Mesh " )))
525 QMap<int,int> modeMap;
526 _PTR(SObject) meshSO = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
528 _PTR(SComponent) component = meshSO->GetFatherComponent();
529 if ( meshSO->Depth() - component->Depth() > 1 ) // sub-mesh, get a mesh
530 while ( meshSO->Depth() - component->Depth() > 1 )
531 meshSO = meshSO->GetFather();
533 SMESHGUI_PrecomputeOp::getAssignedAlgos( meshSO, modeMap );
534 return modeMap.size() > 0;
539 //=======================================================================
540 //function : isPreComputable
541 //purpose : returns true for a mesh with algorithms
542 //=======================================================================
544 bool SMESHGUI_Selection::isPreComputable( int ind ) const
546 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] == "Mesh" )
548 int maxDim = dim( ind );
549 if ( maxDim < 2 ) // we can preview 1D or 2D
551 QMap<int,int> modeMap;
552 _PTR(SObject) pMesh = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
553 SMESHGUI_PrecomputeOp::getAssignedAlgos( pMesh, modeMap );
554 if ( modeMap.size() > 1 )
555 return (( modeMap.contains( SMESH::DIM_3D )) ||
556 ( modeMap.contains( SMESH::DIM_2D ) && maxDim < 1 ));
562 //=======================================================================
563 //function : hasGeomReference
564 //purpose : returns true for a mesh or sub-mesh on geometry
565 //=======================================================================
567 bool SMESHGUI_Selection::hasGeomReference( int ind ) const
569 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
571 _PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
572 GEOM::GEOM_Object_var shape = SMESH::GetShapeOnMeshOrSubMesh( so );
573 return !shape->_is_nil();
578 //=======================================================================
579 //function : isEditableHyp
581 //=======================================================================
583 bool SMESHGUI_Selection::isEditableHyp( int ind ) const
585 bool isEditable = true;
586 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] == "Hypothesis" )
588 _PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
589 SMESH::SMESH_Hypothesis_var hyp = SMESH::SObjectToInterface<SMESH::SMESH_Hypothesis>( so );
590 if ( !hyp->_is_nil() )
592 isEditable = hyp->HasParameters();
598 //=======================================================================
599 //function : isVisible
601 //=======================================================================
603 bool SMESHGUI_Selection::isVisible( int ind ) const
605 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
607 SMESH_Actor* actor = SMESH::FindActorByEntry( entry( ind ).toLatin1().data() );
608 if ( actor && actor->hasIO() ) {
609 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView() )
610 return aViewWindow->isVisible( actor->getIO() );
616 //=======================================================================
617 //function : hasChildren
619 //=======================================================================
621 bool SMESHGUI_Selection::hasChildren( int ind ) const
625 _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
627 return SMESH::GetActiveStudyDocument()->GetUseCaseBuilder()->HasChildren( sobj );
632 //=======================================================================
633 //function : hasChildren
635 //=======================================================================
637 int SMESHGUI_Selection::nbChildren( int ind ) const
642 _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
643 if ( sobj && sobj->GetStudy()->GetUseCaseBuilder()->IsUseCaseNode( sobj ) ) {
644 _PTR(UseCaseIterator) it = sobj->GetStudy()->GetUseCaseBuilder()->GetUseCaseIterator( sobj );
645 for ( it->Init( false ); it->More(); it->Next() ) nb++;
651 //=======================================================================
652 //function : isContainer
654 //=======================================================================
656 bool SMESHGUI_Selection::isContainer( int ind ) const
658 return ind >= 0 && ind < myTypes.count() && myTypes[ind] == "Unknown";
661 //=======================================================================
664 //=======================================================================
666 int SMESHGUI_Selection::type( const QString& entry, _PTR(Study) study )
669 _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().data() );
672 if ( obj->ReferencedObject( ref ) )
675 _PTR(SObject) objFather = obj->GetFather();
676 _PTR(SComponent) objComponent = obj->GetFatherComponent();
678 if ( objComponent->ComponentDataType() == "SMESH" ) {
679 if ( objComponent->GetIOR() == obj->GetIOR() ) {
680 res = SMESH::COMPONENT;
683 int aLevel = obj->Depth() - objComponent->Depth(),
684 aFTag = objFather->Tag(),
690 if ( anOTag >= SMESH::Tag_FirstMeshRoot )
696 case SMESH::Tag_HypothesisRoot: res = SMESH::HYPOTHESIS; break;
697 case SMESH::Tag_AlgorithmsRoot: res = SMESH::ALGORITHM; break;
704 case SMESH::Tag_SubMeshOnVertex: res = SMESH::SUBMESH_VERTEX; break;
705 case SMESH::Tag_SubMeshOnEdge: res = SMESH::SUBMESH_EDGE; break;
706 case SMESH::Tag_SubMeshOnFace: res = SMESH::SUBMESH_FACE; break;
707 case SMESH::Tag_SubMeshOnSolid: res = SMESH::SUBMESH_SOLID; break;
708 case SMESH::Tag_SubMeshOnCompound: res = SMESH::SUBMESH_COMPOUND; break;
710 if ( aFTag >= SMESH::Tag_FirstGroup) res = SMESH::GROUP;
711 else res = SMESH::SUBMESH;
722 //=======================================================================
723 //function : typeName
725 //=======================================================================
727 QString SMESHGUI_Selection::typeName( const int t )
729 QString res = "Unknown";
732 case SMESH::HYPOTHESIS:
733 res = "Hypothesis"; break;
734 case SMESH::ALGORITHM:
735 res = "Algorithm"; break;
739 res = "SubMesh"; break;
740 case SMESH::MESHorSUBMESH:
741 res = "Mesh or submesh"; break;
742 case SMESH::SUBMESH_VERTEX:
743 res = "Mesh vertex"; break;
744 case SMESH::SUBMESH_EDGE:
745 res = "Mesh edge"; break;
746 case SMESH::SUBMESH_FACE:
747 res = "Mesh face"; break;
748 case SMESH::SUBMESH_SOLID:
749 res = "Mesh solid"; break;
750 case SMESH::SUBMESH_COMPOUND:
751 res = "Mesh compound"; break;
753 res = "Group"; break;
754 case SMESH::COMPONENT:
755 res = "Component"; break;
762 bool SMESHGUI_Selection::isImported( const int ind ) const
765 _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().constData() );
768 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( SMESH::SObjectToObject( sobj ) );
769 if( !aMesh->_is_nil() )
771 SMESH::MedFileInfo_var inf = aMesh->GetMEDFileInfo();
772 res = strlen( (char*)inf->fileName ) > 0;
778 //=======================================================================
779 //function : groupType
781 //=======================================================================
783 QString SMESHGUI_Selection::groupType( int ind ) const
785 _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().constData() );
788 SMESH::SMESH_Group_var g = SMESH::SObjectToInterface<SMESH::SMESH_Group>( sobj );
789 if ( !CORBA::is_nil( g ) )
791 SMESH::SMESH_GroupOnGeom_var gog = SMESH::SObjectToInterface<SMESH::SMESH_GroupOnGeom>( sobj );
792 if( !CORBA::is_nil( gog ) )
793 return "GroupOnGeom";
794 SMESH::SMESH_GroupOnFilter_var gof = SMESH::SObjectToInterface<SMESH::SMESH_GroupOnFilter>( sobj );
795 if ( !CORBA::is_nil( gof ) )
796 return "GroupOnFilter";