1 // Copyright (C) 2007-2020 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_Application.h>
44 #include <LightApp_VTKSelector.h>
45 #include <SVTK_ViewWindow.h>
46 #include <LightApp_SelectionMgr.h>
47 #include <LightApp_DataOwner.h>
50 #include <SALOMEconfig.h>
51 #include CORBA_CLIENT_HEADER(SMESH_Gen)
52 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
53 #include CORBA_CLIENT_HEADER(SMESH_Group)
55 //=======================================================================
56 //function : SMESHGUI_Selection
58 //=======================================================================
59 SMESHGUI_Selection::SMESHGUI_Selection()
60 : LightApp_Selection()
64 //=======================================================================
65 //function : ~SMESHGUI_Selection
67 //=======================================================================
68 SMESHGUI_Selection::~SMESHGUI_Selection()
72 //=======================================================================
75 //=======================================================================
76 void SMESHGUI_Selection::init( const QString& client, LightApp_SelectionMgr* mgr )
78 LightApp_Selection::init( client, mgr );
83 mgr->selected(myOwners, client);
84 for( int i=0, n=count(); i<n; i++ ) {
85 myTypes.append( typeName( type( entry( i ) ) ) );
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, false ) );
123 else if ( p=="objElemTypes" ) val = QVariant( elemTypes( ind, true ) );
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() );
147 else if ( p=="canBreakLink") val = QVariant( canBreakLink(ind) );
152 return LightApp_Selection::parameter( ind, p );
155 //=======================================================================
156 //function : parameter
158 //=======================================================================
159 QVariant SMESHGUI_Selection::parameter( const QString& p ) const
162 if ( p=="controlMode" ) val = QVariant( controlMode() );
167 return LightApp_Selection::parameter( p );
170 //=======================================================================
171 //function : getVtkOwner
173 //=======================================================================
175 SMESH_Actor* SMESHGUI_Selection::getActor( int ind ) const
177 if( ind >= 0 && ind < count() )
178 return myActors.isEmpty() ? 0 : myActors.at( ind );
183 //=======================================================================
184 //function : elemTypes
185 //purpose : may return {'Elem0d' 'Edge' 'Face' 'Volume' 'BallElem'} at most
186 //=======================================================================
188 QList<QVariant> SMESHGUI_Selection::elemTypes( int ind, bool fromObj ) const
190 QList<QVariant> types;
191 SMESH_Actor* actor = getActor( ind );
193 TVisualObjPtr object = actor->GetObject();
195 if ( object->GetNbEntities( SMDSAbs_Edge )) types.append( "Edge" );
196 if ( object->GetNbEntities( SMDSAbs_Face )) types.append( "Face" );
197 if ( object->GetNbEntities( SMDSAbs_Volume )) types.append( "Volume" );
198 if ( object->GetNbEntities( SMDSAbs_0DElement )) types.append( "Elem0d" );
199 if ( object->GetNbEntities( SMDSAbs_Ball )) types.append( "BallElem" );
204 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
206 _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID( entry( ind ).toUtf8().data() );
207 CORBA::Object_var obj = SMESH::SObjectToObject( sobj );
208 SMESH::SMESH_IDSource_var idSrc = SMESH::SMESH_IDSource::_narrow( obj );
209 if ( !CORBA::is_nil( idSrc ) )
211 SMESH::array_of_ElementType_var typeVar = idSrc->GetTypes();
212 for ( CORBA::ULong i = 0; i < typeVar->length(); ++i )
213 switch ( typeVar[i] ) {
214 case SMESH::EDGE: types.append( "Edge" ); break;
215 case SMESH::FACE: types.append( "Face" ); break;
216 case SMESH::VOLUME: types.append( "Volume" ); break;
217 case SMESH::ELEM0D: types.append( "Elem0d" ); break;
218 case SMESH::BALL: types.append( "BallElem" ); break;
221 case SMESH::NB_ELEMENT_TYPES: break;
229 //=======================================================================
230 //function : labeledTypes
231 //purpose : may return {'Point' 'Cell'} at most
232 //=======================================================================
234 QList<QVariant> SMESHGUI_Selection::labeledTypes( int ind ) const
236 QList<QVariant> types;
237 SMESH_Actor* actor = getActor( ind );
239 if ( actor->GetPointsLabeled()) types.append( "Point" );
240 if ( actor->GetCellsLabeled()) types.append( "Cell" );
245 //=======================================================================
246 //function : displayMode
247 //purpose : return SMESH_Actor::EReperesent
248 //=======================================================================
250 QString SMESHGUI_Selection::displayMode( int ind ) const
252 SMESH_Actor* actor = getActor( ind );
254 switch( actor->GetRepresentation() ) {
255 case SMESH_Actor::eEdge: return "eEdge";
256 case SMESH_Actor::eSurface: return "eSurface";
257 case SMESH_Actor::ePoint: return "ePoint";
264 //=======================================================================
265 //function : isQuadratic
266 //purpose : return true if the mesh has quadratic/bi-quadratic type
267 //=======================================================================
269 bool SMESHGUI_Selection::isQuadratic( int ind ) const
271 _PTR(SObject) so = SMESH::getStudy()->FindObjectID( entry( ind ).toUtf8().data() );
274 SMESH::SMESH_IDSource_var idSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( so );
275 if ( idSource->_is_nil() )
277 SMESHGUI_ConvToQuadOp::MeshDestinationType meshTgtType = SMESHGUI_ConvToQuadOp::DestinationMesh( idSource );
278 if ( meshTgtType & SMESHGUI_ConvToQuadOp::Linear )
283 //=======================================================================
284 //function : quadratic2DMode
285 //purpose : return SMESH_Actor::EQuadratic2DRepresentation
286 //=======================================================================
287 QString SMESHGUI_Selection::quadratic2DMode( int ind ) const
289 SMESH_Actor* actor = getActor( ind );
291 switch( actor->GetQuadratic2DRepresentation() ) {
292 case SMESH_Actor::eLines: return "eLines";
293 case SMESH_Actor::eArcs: return "eArcs";
300 //=======================================================================
301 //function : isDistributionVisible
302 //purpose : Visible/Invisible distribution of the ScalarBar Actor
303 //=======================================================================
305 bool SMESHGUI_Selection::isDistributionVisible(int ind) const {
306 SMESH_Actor* actor = getActor( ind );
307 return (actor && actor->GetScalarBarActor() && actor->GetScalarBarActor()->GetDistributionVisibility());
310 //=======================================================================
311 //function : isScalarBarVisible
312 //purpose : Visible/Invisible Scalar Bar
313 //=======================================================================
315 bool SMESHGUI_Selection::isScalarBarVisible(int ind) const {
316 SMESH_Actor* actor = getActor( ind );
317 return (actor && actor->GetScalarBarActor() && actor->GetScalarBarActor()->GetVisibility());
320 //=======================================================================
321 //function : shrinkMode
322 //purpose : return either 'IsSrunk', 'IsNotShrunk' or 'IsNotShrinkable'
323 //=======================================================================
325 QString SMESHGUI_Selection::shrinkMode( int ind ) const
327 SMESH_Actor* actor = getActor( ind );
328 if ( actor && actor->IsShrunkable() ) {
329 return actor->IsShrunk() ? "IsShrunk" : "IsNotShrunk";
331 return "IsNotShrinkable";
334 //=======================================================================
335 //function : entityMode
336 //purpose : may return {'Elem0d' 'Edge' 'Face' 'Volume' 'BallElem' } at most
337 //=======================================================================
339 QList<QVariant> SMESHGUI_Selection::entityMode( int ind ) const
341 QList<QVariant> types;
342 SMESH_Actor* actor = getActor( ind );
344 unsigned int aMode = actor->GetEntityMode();
345 if ( aMode & SMESH_Actor::eVolumes ) types.append( "Volume" );
346 if ( aMode & SMESH_Actor::eFaces ) types.append( "Face" );
347 if ( aMode & SMESH_Actor::eEdges ) types.append( "Edge" );
348 if ( aMode & SMESH_Actor::e0DElements ) types.append( "Elem0d" );
349 if ( aMode & SMESH_Actor::eBallElem ) types.append( "BallElem" );
354 //=======================================================================
355 //function : controlMode
356 //purpose : return SMESH_Actor::eControl
357 //=======================================================================
359 QString SMESHGUI_Selection::controlMode( int ind ) const
361 SMESH_Actor* actor = getActor( ind );
362 QString mode = "eNone";
364 switch( actor->GetControlMode() ) {
365 case SMESH_Actor::eLength: mode = "eLength"; break;
366 case SMESH_Actor::eLength2D: mode = "eLength2D"; break;
367 case SMESH_Actor::eDeflection2D: mode = "eDeflection2D"; break;
368 case SMESH_Actor::eFreeEdges: mode = "eFreeEdges"; break;
369 case SMESH_Actor::eFreeNodes: mode = "eFreeNodes"; break;
370 case SMESH_Actor::eFreeBorders: mode = "eFreeBorders"; break;
371 case SMESH_Actor::eFreeFaces: mode = "eFreeFaces"; break;
372 case SMESH_Actor::eMultiConnection: mode = "eMultiConnection"; break;
373 case SMESH_Actor::eMultiConnection2D: mode = "eMultiConnection2D"; break;
374 case SMESH_Actor::eArea: mode = "eArea"; break;
375 case SMESH_Actor::eVolume3D: mode = "eVolume3D"; break;
376 case SMESH_Actor::eMaxElementLength2D: mode = "eMaxElementLength2D"; break;
377 case SMESH_Actor::eMaxElementLength3D: mode = "eMaxElementLength3D"; break;
378 case SMESH_Actor::eTaper: mode = "eTaper"; break;
379 case SMESH_Actor::eAspectRatio: mode = "eAspectRatio"; break;
380 case SMESH_Actor::eAspectRatio3D: mode = "eAspectRatio3D"; break;
381 case SMESH_Actor::eMinimumAngle: mode = "eMinimumAngle"; break;
382 case SMESH_Actor::eWarping: mode = "eWarping"; break;
383 case SMESH_Actor::eSkew: mode = "eSkew"; break;
384 case SMESH_Actor::eBareBorderFace: mode = "eBareBorderFace"; break;
385 case SMESH_Actor::eBareBorderVolume: mode = "eBareBorderVolume"; break;
386 case SMESH_Actor::eOverConstrainedFace: mode = "eOverConstrainedFace"; break;
387 case SMESH_Actor::eOverConstrainedVolume: mode = "eOverConstrainedVolume"; break;
388 case SMESH_Actor::eCoincidentNodes: mode = "eCoincidentNodes"; break;
389 case SMESH_Actor::eCoincidentElems1D: mode = "eCoincidentElems1D"; break;
390 case SMESH_Actor::eCoincidentElems2D: mode = "eCoincidentElems2D"; break;
391 case SMESH_Actor::eCoincidentElems3D: mode = "eCoincidentElems3D"; break;
392 case SMESH_Actor::eCustomControl: mode = "eCustomControl"; break;
399 //=======================================================================
400 //function : controlMode
401 //purpose : gets global control mode; return SMESH_Actor::eControl
402 //=======================================================================
403 QString SMESHGUI_Selection::controlMode() const
405 if( myControls.count() > 0 ) {
406 QString mode = myControls[0];
407 for( int ind = 1; ind < myControls.count(); ind++ ) {
408 if( mode != myControls[ind] )
409 return "eMixed"; // different controls used for different actors
416 //=======================================================================
417 //function : isNumFunctor
418 //purpose : return true if a given actor is shown using a numeric functor
419 //=======================================================================
421 bool SMESHGUI_Selection::isNumFunctor( int ind ) const
424 SMESH_Actor* actor = getActor( ind );
426 switch( actor->GetControlMode() ) {
427 case SMESH_Actor::eLength:
428 case SMESH_Actor::eLength2D:
429 case SMESH_Actor::eDeflection2D:
430 case SMESH_Actor::eMultiConnection:
431 case SMESH_Actor::eMultiConnection2D:
432 case SMESH_Actor::eArea:
433 case SMESH_Actor::eVolume3D:
434 case SMESH_Actor::eMaxElementLength2D:
435 case SMESH_Actor::eMaxElementLength3D:
436 case SMESH_Actor::eTaper:
437 case SMESH_Actor::eAspectRatio:
438 case SMESH_Actor::eAspectRatio3D:
439 case SMESH_Actor::eMinimumAngle:
440 case SMESH_Actor::eWarping:
441 case SMESH_Actor::eSkew:
451 //=======================================================================
452 //function : facesOrientationMode
454 //=======================================================================
456 QString SMESHGUI_Selection::facesOrientationMode( int ind ) const
458 SMESH_Actor* actor = getActor( ind );
460 return actor->GetFacesOriented() ? "IsOriented" : "IsNotOriented";
465 //=======================================================================
466 //function : isAutoColor
468 //=======================================================================
470 bool SMESHGUI_Selection::isAutoColor( int ind ) const
472 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
474 _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID( entry( ind ).toUtf8().data() );
475 CORBA::Object_var obj = SMESH::SObjectToObject( sobj );
477 if ( !CORBA::is_nil( obj ) ) {
478 SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
479 if ( !CORBA::is_nil( mesh ) )
480 return mesh->GetAutoColor();
486 //=======================================================================
487 //function : numberOfNodes
488 //purpose : this method is actually used to check if an object is empty or not
489 //=======================================================================
491 int SMESHGUI_Selection::numberOfNodes( int ind ) const
493 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
495 _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID( entry( ind ).toUtf8().data() );
496 CORBA::Object_var obj = SMESH::SObjectToObject( sobj );
498 if ( !CORBA::is_nil( obj ) ) {
499 SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
500 if ( !CORBA::is_nil( mesh ) )
501 return mesh->NbNodes();
502 SMESH::SMESH_subMesh_var aSubMeshObj = SMESH::SMESH_subMesh::_narrow( obj );
503 if ( !CORBA::is_nil( aSubMeshObj ) )
504 return aSubMeshObj->GetNumberOfNodes(true);
505 SMESH::SMESH_GroupBase_var aGroupObj = SMESH::SMESH_GroupBase::_narrow( obj );
506 if ( !CORBA::is_nil( aGroupObj ) )
507 return aGroupObj->IsEmpty() ? 0 : 1; // aGroupObj->Size();
513 //================================================================================
515 * \brief return dimension of elements of the selected object
517 * \retval int - 0 for 0D elements, -1 for an empty object (the rest as usual)
519 //================================================================================
521 int SMESHGUI_Selection::dim( int ind ) const
524 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
526 _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID( entry( ind ).toUtf8().data() );
527 CORBA::Object_var obj = SMESH::SObjectToObject( sobj );
529 if ( !CORBA::is_nil( obj ) ) {
530 SMESH::SMESH_IDSource_var idSrc = SMESH::SMESH_IDSource::_narrow( obj );
531 if ( !CORBA::is_nil( idSrc ) )
533 SMESH::array_of_ElementType_var types = idSrc->GetTypes();
534 for ( size_t i = 0; i < types->length(); ++ i) {
535 switch ( types[i] ) {
536 case SMESH::EDGE : dim = std::max( dim, 1 ); break;
537 case SMESH::FACE : dim = std::max( dim, 2 ); break;
538 case SMESH::VOLUME: dim = std::max( dim, 3 ); break;
539 case SMESH::ELEM0D: dim = std::max( dim, 0 ); break;
540 case SMESH::BALL : dim = std::max( dim, 0 ); break;
550 //=======================================================================
551 //function : isComputable
552 //purpose : return true for a ready-to-compute mesh
553 //=======================================================================
555 bool SMESHGUI_Selection::isComputable( int ind ) const
557 if ( ind >= 0 && ind < myTypes.count() && ( myTypes[ind] == "Mesh" ||
558 myTypes[ind].startsWith("Mesh " )))
560 QMap<int,int> modeMap;
561 _PTR(SObject) meshSO = SMESH::getStudy()->FindObjectID( entry( ind ).toUtf8().data() );
563 _PTR(SComponent) component = meshSO->GetFatherComponent();
564 if ( meshSO->Depth() - component->Depth() > 1 ) // sub-mesh, get a mesh
565 while ( meshSO->Depth() - component->Depth() > 1 )
566 meshSO = meshSO->GetFather();
568 SMESHGUI_PrecomputeOp::getAssignedAlgos( meshSO, modeMap );
569 return modeMap.size() > 0;
574 //=======================================================================
575 //function : isPreComputable
576 //purpose : returns true for a mesh with algorithms
577 //=======================================================================
579 bool SMESHGUI_Selection::isPreComputable( int ind ) const
581 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] == "Mesh" )
583 int maxDim = dim( ind );
584 if ( maxDim < 2 ) // we can preview 1D or 2D
586 QMap<int,int> modeMap;
587 _PTR(SObject) pMesh = SMESH::getStudy()->FindObjectID( entry( ind ).toUtf8().data() );
588 SMESHGUI_PrecomputeOp::getAssignedAlgos( pMesh, modeMap );
589 if ( modeMap.size() > 1 )
590 return (( modeMap.contains( SMESH::DIM_3D )) ||
591 ( modeMap.contains( SMESH::DIM_2D ) && maxDim < 1 ));
597 //=======================================================================
598 //function : hasGeomReference
599 //purpose : returns true for a mesh or sub-mesh on geometry
600 //=======================================================================
602 bool SMESHGUI_Selection::hasGeomReference( int ind ) const
604 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
606 _PTR(SObject) so = SMESH::getStudy()->FindObjectID( entry( ind ).toUtf8().data() );
607 GEOM::GEOM_Object_var shape = SMESH::GetShapeOnMeshOrSubMesh( so );
608 return !shape->_is_nil();
613 //=======================================================================
614 //function : canBreakLink
615 //purpose : returns true if selected object is a Shaper object and it can break link
616 //=======================================================================
618 bool SMESHGUI_Selection::canBreakLink( int ind ) const
620 if ( ind >= 0 && ind < myTypes.count()) {
621 if (isReference(ind)) {
622 SUIT_DataOwner* aOwn = myOwners.at(ind);
623 LightApp_DataOwner* sowner = dynamic_cast<LightApp_DataOwner*>(aOwn);
624 QString aEntry = sowner->entry();
625 _PTR(SObject) aSObject = SMESH::getStudy()->FindObjectID(aEntry.toStdString());
626 _PTR(SObject) aFatherObj = aSObject->GetFather();
627 _PTR(SComponent) aComponent = aFatherObj->GetFatherComponent();
628 if (aComponent->ComponentDataType() == "SMESH") {
629 QString aObjEntry = entry(ind);
630 _PTR(SObject) aGeomSObject = SMESH::getStudy()->FindObjectID(aObjEntry.toStdString());
631 GEOM::GEOM_Object_var aObject = SMESH::SObjectToInterface<GEOM::GEOM_Object>(aGeomSObject);
632 if (!aObject->_is_nil())
633 return aObject->IsParametrical();
640 //=======================================================================
641 //function : isEditableHyp
643 //=======================================================================
645 bool SMESHGUI_Selection::isEditableHyp( int ind ) const
647 bool isEditable = true;
648 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] == "Hypothesis" )
650 _PTR(SObject) so = SMESH::getStudy()->FindObjectID( entry( ind ).toUtf8().data() );
651 SMESH::SMESH_Hypothesis_var hyp = SMESH::SObjectToInterface<SMESH::SMESH_Hypothesis>( so );
652 if ( !hyp->_is_nil() )
654 isEditable = hyp->HasParameters();
660 //=======================================================================
661 //function : isVisible
663 //=======================================================================
665 bool SMESHGUI_Selection::isVisible( int ind ) const
667 if ( ind >= 0 && ind < myTypes.count() && myTypes[ind] != "Unknown" )
669 SMESH_Actor* actor = SMESH::FindActorByEntry( entry( ind ).toUtf8().data() );
670 if ( actor && actor->hasIO() ) {
671 if ( SVTK_ViewWindow* aViewWindow = SMESH::GetCurrentVtkView() )
672 return aViewWindow->isVisible( actor->getIO() );
678 //=======================================================================
679 //function : hasChildren
681 //=======================================================================
683 bool SMESHGUI_Selection::hasChildren( int ind ) const
687 _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID( entry( ind ).toUtf8().data() );
689 return SMESH::getStudy()->GetUseCaseBuilder()->HasChildren( sobj );
694 //=======================================================================
695 //function : hasChildren
697 //=======================================================================
699 int SMESHGUI_Selection::nbChildren( int ind ) const
704 _PTR(Study) study = SMESH::getStudy();
705 _PTR(SObject) sobj = study->FindObjectID( entry( ind ).toUtf8().data() );
706 if ( sobj && study->GetUseCaseBuilder()->IsUseCaseNode( sobj ) ) {
707 _PTR(UseCaseIterator) it = study->GetUseCaseBuilder()->GetUseCaseIterator( sobj );
708 for ( it->Init( false ); it->More(); it->Next() ) nb++;
714 //=======================================================================
715 //function : isContainer
717 //=======================================================================
719 bool SMESHGUI_Selection::isContainer( int ind ) const
721 return ind >= 0 && ind < myTypes.count() && myTypes[ind] == "Unknown";
724 //=======================================================================
727 //=======================================================================
729 int SMESHGUI_Selection::type( const QString& entry )
732 _PTR(SObject) obj = SalomeApp_Application::getStudy()->FindObjectID( entry.toUtf8().data() );
735 if ( obj->ReferencedObject( ref ) )
738 _PTR(SObject) objFather = obj->GetFather();
739 _PTR(SComponent) objComponent = obj->GetFatherComponent();
741 if ( objComponent->ComponentDataType() == "SMESH" ) {
742 if ( objComponent->GetIOR() == obj->GetIOR() ) {
743 res = SMESH::COMPONENT;
746 int aLevel = obj->Depth() - objComponent->Depth(),
747 aFTag = objFather->Tag(),
753 if ( anOTag >= SMESH::Tag_FirstMeshRoot )
759 case SMESH::Tag_HypothesisRoot: res = SMESH::HYPOTHESIS; break;
760 case SMESH::Tag_AlgorithmsRoot: res = SMESH::ALGORITHM; break;
767 case SMESH::Tag_SubMeshOnVertex: res = SMESH::SUBMESH_VERTEX; break;
768 case SMESH::Tag_SubMeshOnEdge: res = SMESH::SUBMESH_EDGE; break;
769 case SMESH::Tag_SubMeshOnFace: res = SMESH::SUBMESH_FACE; break;
770 case SMESH::Tag_SubMeshOnSolid: res = SMESH::SUBMESH_SOLID; break;
771 case SMESH::Tag_SubMeshOnCompound: res = SMESH::SUBMESH_COMPOUND; break;
773 if ( aFTag >= SMESH::Tag_FirstGroup) res = SMESH::GROUP;
774 else res = SMESH::SUBMESH;
785 //=======================================================================
786 //function : typeName
788 //=======================================================================
790 QString SMESHGUI_Selection::typeName( const int t )
792 QString res = "Unknown";
795 case SMESH::HYPOTHESIS:
796 res = "Hypothesis"; break;
797 case SMESH::ALGORITHM:
798 res = "Algorithm"; break;
802 res = "SubMesh"; break;
803 case SMESH::MESHorSUBMESH:
804 res = "Mesh or submesh"; break;
805 case SMESH::SUBMESH_VERTEX:
806 res = "Mesh vertex"; break;
807 case SMESH::SUBMESH_EDGE:
808 res = "Mesh edge"; break;
809 case SMESH::SUBMESH_FACE:
810 res = "Mesh face"; break;
811 case SMESH::SUBMESH_SOLID:
812 res = "Mesh solid"; break;
813 case SMESH::SUBMESH_COMPOUND:
814 res = "Mesh compound"; break;
816 res = "Group"; break;
817 case SMESH::COMPONENT:
818 res = "Component"; break;
825 bool SMESHGUI_Selection::isImported( const int ind ) const
828 _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID( entry( ind ).toUtf8().constData() );
831 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( SMESH::SObjectToObject( sobj ) );
832 if( !aMesh->_is_nil() )
834 SMESH::MedFileInfo_var inf = aMesh->GetMEDFileInfo();
835 res = strlen( (char*)inf->fileName ) > 0;
841 //=======================================================================
842 //function : guiState
844 //=======================================================================
846 int SMESHGUI_Selection::guiState()
848 return SMESHGUI::GetSMESHGUI() ? SMESHGUI::GetSMESHGUI()->GetState() : -1;
851 //=======================================================================
852 //function : groupType
854 //=======================================================================
856 QString SMESHGUI_Selection::groupType( int ind ) const
858 _PTR(SObject) sobj = SMESH::getStudy()->FindObjectID( entry( ind ).toUtf8().constData() );
861 SMESH::SMESH_Group_var g = SMESH::SObjectToInterface<SMESH::SMESH_Group>( sobj );
862 if ( !CORBA::is_nil( g ) )
864 SMESH::SMESH_GroupOnGeom_var gog = SMESH::SObjectToInterface<SMESH::SMESH_GroupOnGeom>( sobj );
865 if( !CORBA::is_nil( gog ) )
866 return "GroupOnGeom";
867 SMESH::SMESH_GroupOnFilter_var gof = SMESH::SObjectToInterface<SMESH::SMESH_GroupOnFilter>( sobj );
868 if ( !CORBA::is_nil( gof ) )
869 return "GroupOnFilter";