- // check the selected GEOM objects
- if ( anIsObjectBrowser && !HYDROGUI_Tool::GetSelectedGeomObjects( this ).isEmpty() ) {
- theMenu->addAction( action( ImportGeomObjectId ) );
- theMenu->addSeparator();
+ SUIT_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
+ SUIT_DataOwnerPtrList anOwners;
+ aSelectionMgr->selected( anOwners );
+ if( anIsObjectBrowser && anOwners.size()==1 )
+ {
+ QString anEntry = anOwners[0]->keyString();
+ LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( getApp()->activeStudy() );
+ if( aStudy )
+ isRoot = aStudy->isComponent( anEntry );
+ }
+
+ // Check the selected GEOM objects (take into account the Object Browser only)
+ if ( anIsObjectBrowser ) {
+ QList<GEOM::shape_type> anObstacleTypes =
+ HYDROGUI_ImportGeomObjectOp::getObstacleTypes();
+ QList<GEOM::shape_type> aPolylineTypes =
+ HYDROGUI_ImportGeomObjectOp::getPolylineTypes();
+
+ bool isCanBeImportedAsObstacle =
+ !HYDROGUI_Tool::GetSelectedGeomObjects( this, anObstacleTypes ).isEmpty();
+ bool isCanBeImportedAsPolyline =
+ !HYDROGUI_Tool::GetSelectedGeomObjects( this, aPolylineTypes ).isEmpty();
+
+ // Add import as obstacle action
+ if ( isCanBeImportedAsObstacle ) {
+ theMenu->addAction( action( ImportGeomObjectAsObstacleId ) );
+ }
+ // Add import as polyline action
+ if ( isCanBeImportedAsPolyline ) {
+ theMenu->addAction( action( ImportGeomObjectAsPolylineId ) );
+ }
+ // Add separator
+ if ( isCanBeImportedAsObstacle || isCanBeImportedAsPolyline ) {
+ theMenu->addSeparator();
+ }