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"
32 #include "SMESHGUI_ComputeDlg.h"
33 #include "SMESHGUI_ConvToQuadOp.h"
34 #include "SMESHGUI_GEOMGenUtils.h"
35 #include "SMESHGUI_Utils.h"
36 #include "SMESHGUI_VTKUtils.h"
38 #include <SMESH_Type.h>
39 #include <SMESH_Actor.h>
40 #include <SMESH_ScalarBarActor.h>
42 // SALOME GUI includes
43 #include <SalomeApp_Study.h>
44 #include <LightApp_VTKSelector.h>
45 #include <SVTK_ViewWindow.h>
48 #include <SALOMEconfig.h>
49 #include CORBA_CLIENT_HEADER(SMESH_Gen)
50 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
51 #include CORBA_CLIENT_HEADER(SMESH_Group)
53 //=======================================================================
54 //function : SMESHGUI_Selection
56 //=======================================================================
57 SMESHGUI_Selection::SMESHGUI_Selection()
58 : LightApp_Selection()
62 //=======================================================================
63 //function : ~SMESHGUI_Selection
65 //=======================================================================
66 SMESHGUI_Selection::~SMESHGUI_Selection()
70 //=======================================================================
73 //=======================================================================
74 void SMESHGUI_Selection::init( const QString& client, LightApp_SelectionMgr* mgr )
76 LightApp_Selection::init( client, mgr );
80 SalomeApp_Study* aSStudy = dynamic_cast<SalomeApp_Study*>(study());
83 _PTR(Study) aStudy = aSStudy->studyDS();
85 for( int i=0, n=count(); i<n; i++ ) {
86 myTypes.append( typeName( type( entry( i ), aStudy ) ) );
87 myControls.append( controlMode( i ) );
92 //=======================================================================
93 //function : processOwner
95 //=======================================================================
96 bool SMESHGUI_Selection::processOwner( const LightApp_DataOwner* ow )
98 const LightApp_SVTKDataOwner* owner =
99 dynamic_cast<const LightApp_SVTKDataOwner*> ( ow );
101 myActors.append( dynamic_cast<SMESH_Actor*>( owner->GetActor() ) );
103 else if ( ow ) { // SVTK selection disabled
104 QString entry = ow->entry();
105 myActors.append( SMESH::FindActorByEntry( entry.toStdString().c_str() ));
108 myActors.append( 0 );
113 //=======================================================================
114 //function : parameter
116 //=======================================================================
117 QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const
120 if ( p=="client" ) val = QVariant( LightApp_Selection::parameter( p ) );
121 else if ( p=="type" ) val = QVariant( myTypes[ind] );
122 else if ( p=="hasActor" ) val = QVariant( getActor( ind ) != 0 );
123 else if ( p=="elemTypes" ) val = QVariant( elemTypes( ind ) );
124 else if ( p=="isAutoColor" ) val = QVariant( isAutoColor( ind ) );
125 else if ( p=="numberOfNodes" ) val = QVariant( numberOfNodes( ind ) );
126 else if ( p=="dim" ) val = QVariant( dim( ind ) );
127 else if ( p=="labeledTypes" ) val = QVariant( labeledTypes( ind ) );
128 else if ( p=="shrinkMode" ) val = QVariant( shrinkMode( ind ) );
129 else if ( p=="entityMode" ) val = QVariant( entityMode( ind ) );
130 else if ( p=="isNumFunctor" ) val = QVariant( isNumFunctor( ind ) );
131 else if ( p=="displayMode" ) val = QVariant( displayMode( ind ) );
132 else if ( p=="isComputable" ) val = QVariant( isComputable( ind ) );
133 else if ( p=="isPreComputable" ) val = QVariant( isPreComputable( ind ) );
134 else if ( p=="hasGeomReference" ) val = QVariant( hasGeomReference( ind ) );
135 else if ( p=="isEditableHyp" ) val = QVariant( isEditableHyp( ind ) );
136 else if ( p=="isImported" ) val = QVariant( isImported( ind ) );
137 else if ( p=="facesOrientationMode" ) val = QVariant( facesOrientationMode( ind ) );
138 else if ( p=="groupType" ) val = QVariant( groupType( ind ) );
139 else if ( p=="isQuadratic" ) val = QVariant( isQuadratic( ind ) );
140 else if ( p=="quadratic2DMode") val = QVariant( quadratic2DMode( ind ) );
141 else if ( p=="isDistributionVisible") val = QVariant( isDistributionVisible( ind ) );
142 else if ( p=="isScalarBarVisible") val = QVariant( isScalarBarVisible( ind ) );
143 else if ( p=="hasChildren") val = QVariant( hasChildren( ind ) );
144 else if ( p=="nbChildren") val = QVariant( nbChildren( ind ) );
145 else if ( p=="isContainer") val = QVariant( isContainer( ind ) );
146 else if ( p=="guiState") val = QVariant( guiState() );
151 return LightApp_Selection::parameter( ind, p );
154 //=======================================================================
155 //function : parameter
157 //=======================================================================
158 QVariant SMESHGUI_Selection::parameter( const QString& p ) const
161 if ( p=="controlMode" ) val = QVariant( controlMode() );
166 return LightApp_Selection::parameter( p );
169 //=======================================================================
170 //function : getVtkOwner
172 //=======================================================================
174 SMESH_Actor* SMESHGUI_Selection::getActor( int ind ) const
176 if( ind >= 0 && ind < count() )
177 return myActors.isEmpty() ? 0 : myActors.at( ind );
182 //=======================================================================
183 //function : elemTypes
184 //purpose : may return {'Elem0d' 'Edge' 'Face' 'Volume' 'BallElem'} at most
185 //=======================================================================
187 QList<QVariant> SMESHGUI_Selection::elemTypes( int ind ) const
189 QList<QVariant> types;
190 SMESH_Actor* actor = getActor( ind );
192 TVisualObjPtr object = actor->GetObject();
194 if ( object->GetNbEntities( SMDSAbs_0DElement )) types.append( "Elem0d" );
195 if ( object->GetNbEntities( SMDSAbs_Ball )) types.append( "BallElem" );
196 if ( object->GetNbEntities( SMDSAbs_Edge )) types.append( "Edge" );
197 if ( object->GetNbEntities( SMDSAbs_Face )) types.append( "Face" );
198 if ( object->GetNbEntities( SMDSAbs_Volume )) types.append( "Volume" );
204 //=======================================================================
205 //function : labeledTypes
206 //purpose : may return {'Point' 'Cell'} at most
207 //=======================================================================
209 QList<QVariant> SMESHGUI_Selection::labeledTypes( int ind ) const
211 QList<QVariant> types;
212 SMESH_Actor* actor = getActor( ind );
214 if ( actor->GetPointsLabeled()) types.append( "Point" );
215 if ( actor->GetCellsLabeled()) types.append( "Cell" );
220 //=======================================================================
221 //function : displayMode
222 //purpose : return SMESH_Actor::EReperesent
223 //=======================================================================
225 QString SMESHGUI_Selection::displayMode( int ind ) const
227 SMESH_Actor* actor = getActor( ind );
229 switch( actor->GetRepresentation() ) {
230 case SMESH_Actor::eEdge: return "eEdge";
231 case SMESH_Actor::eSurface: return "eSurface";
232 case SMESH_Actor::ePoint: return "ePoint";
239 //=======================================================================
240 //function : isQuadratic
241 //purpose : return true if the mesh has quadratic/bi-quadratic type
242 //=======================================================================
244 bool SMESHGUI_Selection::isQuadratic( int ind ) const
246 _PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
249 SMESH::SMESH_IDSource_var idSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( so );
250 if ( idSource->_is_nil() )
252 SMESHGUI_ConvToQuadOp::MeshDestinationType meshTgtType = SMESHGUI_ConvToQuadOp::DestinationMesh( idSource );
253 if ( meshTgtType & SMESHGUI_ConvToQuadOp::Linear )
258 //=======================================================================
259 //function : quadratic2DMode
260 //purpose : return SMESH_Actor::EQuadratic2DRepresentation
261 //=======================================================================
262 QString SMESHGUI_Selection::quadratic2DMode( int ind ) const
264 SMESH_Actor* actor = getActor( ind );
266 switch( actor->GetQuadratic2DRepresentation() ) {
267 case SMESH_Actor::eLines: return "eLines";
268 case SMESH_Actor::eArcs: return "eArcs";
275 //=======================================================================
276 //function : isDistributionVisible
277 //purpose : Visible/Invisible distribution of the ScalarBar Actor
278 //=======================================================================
280 bool SMESHGUI_Selection::isDistributionVisible(int ind) const {
281 SMESH_Actor* actor = getActor( ind );
282 return (actor && actor->GetScalarBarActor() && actor->GetScalarBarActor()->GetDistributionVisibility());
285 //=======================================================================
286 //function : isScalarBarVisible
287 //purpose : Visible/Invisible Scalar Bar
288 //=======================================================================
290 bool SMESHGUI_Selection::isScalarBarVisible(int ind) const {
291 SMESH_Actor* actor = getActor( ind );
292 return (actor && actor->GetScalarBarActor() && actor->GetScalarBarActor()->GetVisibility());
295 //=======================================================================
296 //function : shrinkMode
297 //purpose : return either 'IsSrunk', 'IsNotShrunk' or 'IsNotShrinkable'
298 //=======================================================================
300 QString SMESHGUI_Selection::shrinkMode( int ind ) const
302 SMESH_Actor* actor = getActor( ind );
303 if ( actor && actor->IsShrunkable() ) {
304 return actor->IsShrunk() ? "IsShrunk" : "IsNotShrunk";
306 return "IsNotShrinkable";
309 //=======================================================================
310 //function : entityMode
311 //purpose : may return {'Elem0d' 'Edge' 'Face' 'Volume' 'BallElem' } at most
312 //=======================================================================
314 QList<QVariant> SMESHGUI_Selection::entityMode( int ind ) const
316 QList<QVariant> types;
317 SMESH_Actor* actor = getActor( ind );
319 unsigned int aMode = actor->GetEntityMode();
320 if ( aMode & SMESH_Actor::eVolumes ) types.append( "Volume" );
321 if ( aMode & SMESH_Actor::eFaces ) types.append( "Face" );
322 if ( aMode & SMESH_Actor::eEdges ) types.append( "Edge" );
323 if ( aMode & SMESH_Actor::e0DElements ) types.append( "Elem0d" );
324 if ( aMode & SMESH_Actor::eBallElem ) types.append( "BallElem" );
329 //=======================================================================
330 //function : controlMode
331 //purpose : return SMESH_Actor::eControl
332 //=======================================================================
334 QString SMESHGUI_Selection::controlMode( int ind ) const
336 SMESH_Actor* actor = getActor( ind );
337 QString mode = "eNone";
339 switch( actor->GetControlMode() ) {
340 case SMESH_Actor::eLength: mode = "eLength"; break;
341 case SMESH_Actor::eLength2D: mode = "eLength2D"; break;
342 case SMESH_Actor::eFreeEdges: mode = "eFreeEdges"; break;
343 case SMESH_Actor::eFreeNodes: mode = "eFreeNodes"; break;
344 case SMESH_Actor::eFreeBorders: mode = "eFreeBorders"; break;
345 case SMESH_Actor::eFreeFaces: mode = "eFreeFaces"; break;
346 case SMESH_Actor::eMultiConnection: mode = "eMultiConnection"; break;
347 case SMESH_Actor::eMultiConnection2D: mode = "eMultiConnection2D"; break;
348 case SMESH_Actor::eArea: mode = "eArea"; break;
349 case SMESH_Actor::eVolume3D: mode = "eVolume3D"; break;
350 case SMESH_Actor::eMaxElementLength2D: mode = "eMaxElementLength2D"; break;
351 case SMESH_Actor::eMaxElementLength3D: mode = "eMaxElementLength3D"; break;
352 case SMESH_Actor::eTaper: mode = "eTaper"; break;
353 case SMESH_Actor::eAspectRatio: mode = "eAspectRatio"; break;
354 case SMESH_Actor::eAspectRatio3D: mode = "eAspectRatio3D"; break;
355 case SMESH_Actor::eMinimumAngle: mode = "eMinimumAngle"; break;
356 case SMESH_Actor::eWarping: mode = "eWarping"; break;
357 case SMESH_Actor::eSkew: mode = "eSkew"; break;
358 case SMESH_Actor::eBareBorderFace: mode = "eBareBorderFace"; break;
359 case SMESH_Actor::eBareBorderVolume: mode = "eBareBorderVolume"; break;
360 case SMESH_Actor::eOverConstrainedFace: mode = "eOverConstrainedFace"; break;
361 case SMESH_Actor::eOverConstrainedVolume: mode = "eOverConstrainedVolume"; break;
362 case SMESH_Actor::eCoincidentNodes: mode = "eCoincidentNodes"; break;
363 case SMESH_Actor::eCoincidentElems1D: mode = "eCoincidentElems1D"; break;
364 case SMESH_Actor::eCoincidentElems2D: mode = "eCoincidentElems2D"; break;
365 case SMESH_Actor::eCoincidentElems3D: mode = "eCoincidentElems3D"; break;
372 //=======================================================================
373 //function : controlMode
374 //purpose : gets global control mode; return SMESH_Actor::eControl
375 //=======================================================================
376 QString SMESHGUI_Selection::controlMode() const
378 if( myControls.count() > 0 ) {
379 QString mode = myControls[0];
380 for( int ind = 1; ind < myControls.count(); ind++ ) {
381 if( mode != myControls[ind] )
382 return "eMixed"; // different controls used for different actors
389 bool SMESHGUI_Selection::isNumFunctor( int ind ) const
392 SMESH_Actor* actor = getActor( ind );
394 switch( actor->GetControlMode() ) {
395 case SMESH_Actor::eLength:
396 case SMESH_Actor::eLength2D:
397 case SMESH_Actor::eMultiConnection:
398 case SMESH_Actor::eMultiConnection2D:
399 case SMESH_Actor::eArea:
400 case SMESH_Actor::eVolume3D:
401 case SMESH_Actor::eMaxElementLength2D:
402 case SMESH_Actor::eMaxElementLength3D:
403 case SMESH_Actor::eTaper:
404 case SMESH_Actor::eAspectRatio:
405 case SMESH_Actor::eAspectRatio3D:
406 case SMESH_Actor::eMinimumAngle:
407 case SMESH_Actor::eWarping:
408 case SMESH_Actor::eSkew:
418 //=======================================================================
419 //function : facesOrientationMode
421 //=======================================================================
423 QString SMESHGUI_Selection::facesOrientationMode( int ind ) const
425 SMESH_Actor* actor = getActor( ind );
427 return actor->GetFacesOriented() ? "IsOriented" : "IsNotOriented";
432 //=======================================================================
433 //function : isAutoColor
435 //=======================================================================
437 bool SMESHGUI_Selection::isAutoColor( int ind ) const
439 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
441 _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
442 CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() );
444 if ( !CORBA::is_nil( obj ) ) {
445 SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
446 if ( !CORBA::is_nil( mesh ) )
447 return mesh->GetAutoColor();
453 //=======================================================================
454 //function : numberOfNodes
455 //purpose : this method is actually used to check if an object is empty or not
456 //=======================================================================
458 int SMESHGUI_Selection::numberOfNodes( int ind ) const
460 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
462 _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
463 CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() );
465 if ( !CORBA::is_nil( obj ) ) {
466 SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
467 if ( !CORBA::is_nil( mesh ) )
468 return mesh->NbNodes();
469 SMESH::SMESH_subMesh_var aSubMeshObj = SMESH::SMESH_subMesh::_narrow( obj );
470 if ( !CORBA::is_nil( aSubMeshObj ) )
471 return aSubMeshObj->GetNumberOfNodes(true);
472 SMESH::SMESH_GroupBase_var aGroupObj = SMESH::SMESH_GroupBase::_narrow( obj );
473 if ( !CORBA::is_nil( aGroupObj ) )
474 return aGroupObj->IsEmpty() ? 0 : 1; // aGroupObj->Size();
480 //================================================================================
482 * \brief return dimension of elements of the selected object
484 * \retval int - 0 for 0D elements, -1 for an empty object (the rest as usual)
486 //================================================================================
488 int SMESHGUI_Selection::dim( int ind ) const
491 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
493 _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
494 CORBA::Object_var obj = SMESH::SObjectToObject( sobj, SMESH::GetActiveStudyDocument() );
496 if ( !CORBA::is_nil( obj ) ) {
497 SMESH::SMESH_IDSource_var idSrc = SMESH::SMESH_IDSource::_narrow( obj );
498 if ( !CORBA::is_nil( idSrc ) )
500 SMESH::array_of_ElementType_var types = idSrc->GetTypes();
501 for ( size_t i = 0; i < types->length(); ++ i) {
502 switch ( types[i] ) {
503 case SMESH::EDGE : dim = std::max( dim, 1 ); break;
504 case SMESH::FACE : dim = std::max( dim, 2 ); break;
505 case SMESH::VOLUME: dim = std::max( dim, 3 ); break;
506 case SMESH::ELEM0D: dim = std::max( dim, 0 ); break;
507 case SMESH::BALL : dim = std::max( dim, 0 ); break;
517 //=======================================================================
518 //function : isComputable
519 //purpose : return true for a ready-to-compute mesh
520 //=======================================================================
522 bool SMESHGUI_Selection::isComputable( int ind ) const
524 if ( ind >= 0 && ind < myTypes.count() && ( myTypes[ind] == "Mesh" ||
525 myTypes[ind].startsWith("Mesh " )))
527 QMap<int,int> modeMap;
528 _PTR(SObject) meshSO = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
530 _PTR(SComponent) component = meshSO->GetFatherComponent();
531 if ( meshSO->Depth() - component->Depth() > 1 ) // sub-mesh, get a mesh
532 while ( meshSO->Depth() - component->Depth() > 1 )
533 meshSO = meshSO->GetFather();
535 SMESHGUI_PrecomputeOp::getAssignedAlgos( meshSO, modeMap );
536 return modeMap.size() > 0;
541 //=======================================================================
542 //function : isPreComputable
543 //purpose : returns true for a mesh with algorithms
544 //=======================================================================
546 bool SMESHGUI_Selection::isPreComputable( int ind ) const
548 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] == "Mesh" )
550 int maxDim = dim( ind );
551 if ( maxDim < 2 ) // we can preview 1D or 2D
553 QMap<int,int> modeMap;
554 _PTR(SObject) pMesh = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
555 SMESHGUI_PrecomputeOp::getAssignedAlgos( pMesh, modeMap );
556 if ( modeMap.size() > 1 )
557 return (( modeMap.contains( SMESH::DIM_3D )) ||
558 ( modeMap.contains( SMESH::DIM_2D ) && maxDim < 1 ));
564 //=======================================================================
565 //function : hasGeomReference
566 //purpose : returns true for a mesh or sub-mesh on geometry
567 //=======================================================================
569 bool SMESHGUI_Selection::hasGeomReference( int ind ) const
571 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
573 _PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
574 GEOM::GEOM_Object_var shape = SMESH::GetShapeOnMeshOrSubMesh( so );
575 return !shape->_is_nil();
580 //=======================================================================
581 //function : isEditableHyp
583 //=======================================================================
585 bool SMESHGUI_Selection::isEditableHyp( int ind ) const
587 bool isEditable = true;
588 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] == "Hypothesis" )
590 _PTR(SObject) so = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
591 SMESH::SMESH_Hypothesis_var hyp = SMESH::SObjectToInterface<SMESH::SMESH_Hypothesis>( so );
592 if ( !hyp->_is_nil() )
594 isEditable = hyp->HasParameters();
600 //=======================================================================
601 //function : isVisible
603 //=======================================================================
605 bool SMESHGUI_Selection::isVisible( int ind ) const
607 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
609 SMESH_Actor* actor = SMESH::FindActorByEntry( entry( ind ).toLatin1().data() );
610 if ( actor && actor->hasIO() ) {
611 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView() )
612 return aViewWindow->isVisible( actor->getIO() );
618 //=======================================================================
619 //function : hasChildren
621 //=======================================================================
623 bool SMESHGUI_Selection::hasChildren( int ind ) const
627 _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
629 return SMESH::GetActiveStudyDocument()->GetUseCaseBuilder()->HasChildren( sobj );
634 //=======================================================================
635 //function : hasChildren
637 //=======================================================================
639 int SMESHGUI_Selection::nbChildren( int ind ) const
644 _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().data() );
645 if ( sobj && sobj->GetStudy()->GetUseCaseBuilder()->IsUseCaseNode( sobj ) ) {
646 _PTR(UseCaseIterator) it = sobj->GetStudy()->GetUseCaseBuilder()->GetUseCaseIterator( sobj );
647 for ( it->Init( false ); it->More(); it->Next() ) nb++;
653 //=======================================================================
654 //function : isContainer
656 //=======================================================================
658 bool SMESHGUI_Selection::isContainer( int ind ) const
660 return ind >= 0 && ind < myTypes.count() && myTypes[ind] == "Unknown";
663 //=======================================================================
666 //=======================================================================
668 int SMESHGUI_Selection::type( const QString& entry, _PTR(Study) study )
671 _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().data() );
674 if ( obj->ReferencedObject( ref ) )
677 _PTR(SObject) objFather = obj->GetFather();
678 _PTR(SComponent) objComponent = obj->GetFatherComponent();
680 if ( objComponent->ComponentDataType() == "SMESH" ) {
681 if ( objComponent->GetIOR() == obj->GetIOR() ) {
682 res = SMESH::COMPONENT;
685 int aLevel = obj->Depth() - objComponent->Depth(),
686 aFTag = objFather->Tag(),
692 if ( anOTag >= SMESH::Tag_FirstMeshRoot )
698 case SMESH::Tag_HypothesisRoot: res = SMESH::HYPOTHESIS; break;
699 case SMESH::Tag_AlgorithmsRoot: res = SMESH::ALGORITHM; break;
706 case SMESH::Tag_SubMeshOnVertex: res = SMESH::SUBMESH_VERTEX; break;
707 case SMESH::Tag_SubMeshOnEdge: res = SMESH::SUBMESH_EDGE; break;
708 case SMESH::Tag_SubMeshOnFace: res = SMESH::SUBMESH_FACE; break;
709 case SMESH::Tag_SubMeshOnSolid: res = SMESH::SUBMESH_SOLID; break;
710 case SMESH::Tag_SubMeshOnCompound: res = SMESH::SUBMESH_COMPOUND; break;
712 if ( aFTag >= SMESH::Tag_FirstGroup) res = SMESH::GROUP;
713 else res = SMESH::SUBMESH;
724 //=======================================================================
725 //function : typeName
727 //=======================================================================
729 QString SMESHGUI_Selection::typeName( const int t )
731 QString res = "Unknown";
734 case SMESH::HYPOTHESIS:
735 res = "Hypothesis"; break;
736 case SMESH::ALGORITHM:
737 res = "Algorithm"; break;
741 res = "SubMesh"; break;
742 case SMESH::MESHorSUBMESH:
743 res = "Mesh or submesh"; break;
744 case SMESH::SUBMESH_VERTEX:
745 res = "Mesh vertex"; break;
746 case SMESH::SUBMESH_EDGE:
747 res = "Mesh edge"; break;
748 case SMESH::SUBMESH_FACE:
749 res = "Mesh face"; break;
750 case SMESH::SUBMESH_SOLID:
751 res = "Mesh solid"; break;
752 case SMESH::SUBMESH_COMPOUND:
753 res = "Mesh compound"; break;
755 res = "Group"; break;
756 case SMESH::COMPONENT:
757 res = "Component"; break;
764 bool SMESHGUI_Selection::isImported( const int ind ) const
767 _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().constData() );
770 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( SMESH::SObjectToObject( sobj ) );
771 if( !aMesh->_is_nil() )
773 SMESH::MedFileInfo_var inf = aMesh->GetMEDFileInfo();
774 res = strlen( (char*)inf->fileName ) > 0;
780 //=======================================================================
781 //function : guiState
783 //=======================================================================
785 int SMESHGUI_Selection::guiState()
787 return SMESHGUI::GetSMESHGUI() ? SMESHGUI::GetSMESHGUI()->GetState() : -1;
790 //=======================================================================
791 //function : groupType
793 //=======================================================================
795 QString SMESHGUI_Selection::groupType( int ind ) const
797 _PTR(SObject) sobj = SMESH::GetActiveStudyDocument()->FindObjectID( entry( ind ).toLatin1().constData() );
800 SMESH::SMESH_Group_var g = SMESH::SObjectToInterface<SMESH::SMESH_Group>( sobj );
801 if ( !CORBA::is_nil( g ) )
803 SMESH::SMESH_GroupOnGeom_var gog = SMESH::SObjectToInterface<SMESH::SMESH_GroupOnGeom>( sobj );
804 if( !CORBA::is_nil( gog ) )
805 return "GroupOnGeom";
806 SMESH::SMESH_GroupOnFilter_var gof = SMESH::SObjectToInterface<SMESH::SMESH_GroupOnFilter>( sobj );
807 if ( !CORBA::is_nil( gof ) )
808 return "GroupOnFilter";