+ theTypesList << GraphicsView_Viewer::Type() << OCCViewer_Viewer::Type();
+}
+
+void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
+ QMenu* theMenu,
+ QString& theTitle )
+{
+ HYDROGUI_DataModel* aModel = getDataModel();
+
+ bool anIsObjectBrowser = theClient == getApp()->objectBrowser()->popupClientType();
+ bool anIsGraphicsView = theClient == GraphicsView_Viewer::Type();
+ bool anIsOCCView = theClient == OCCViewer_Viewer::Type();
+ bool anIsVTKView = theClient == SVTK_Viewer::Type();
+ if( !anIsObjectBrowser && !anIsGraphicsView && !anIsOCCView && !anIsVTKView )
+ return;
+
+ size_t anActiveViewId = HYDROGUI_Tool::GetActiveViewId( this );
+
+ bool anIsSelectedDataObjects = false;
+ bool anIsVisibleInSelection = false;
+ bool anIsHiddenInSelection = false;
+
+ bool anIsImage = false;
+ bool anIsImportedImage = false;
+ bool anIsImageHasRefs = false;
+ bool anIsFusedImage = false;
+ bool anIsCutImage = false;
+ bool anIsSplittedImage = false;
+ bool anIsMustObjectBeUpdated = false;
+ bool anIsPolyline = false;
+ bool anIsPolyline3D = false;
+ bool anIsProfile = false;
+ bool anIsValidProfile = false;
+ bool anAllAreProfiles = false;
+ bool anIsBathymetry = false;
+ bool anIsCalculation = false;
+ bool anIsImmersibleZone = false;
+ bool anIsVisualState = false;
+ bool anIsRegion = false;
+ bool anIsZone = false;
+ bool anIsObstacle = false;
+ bool anIsStream = false;
+ bool anIsChannel = false;
+ bool anIsDigue = false;
+ bool anIsDummyObject3D = false;
+ bool anIsGroup = false;
+ bool anIsObjectCanBeColored = false;
+ bool isRoot = false;
+
+ 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();
+ }
+ }
+
+ // check the selected data model objects
+ HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
+ int aNbOfSelectedProfiles = 0;
+ for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
+ {
+ Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
+ if( !anObject.IsNull() )
+ {
+ anIsSelectedDataObjects = true;
+
+ bool aVisibility = isObjectVisible( anActiveViewId, anObject );
+ anIsVisibleInSelection |= aVisibility;
+ anIsHiddenInSelection |= !aVisibility;
+
+ if ( anObject->CanBeUpdated() && anObject->IsMustBeUpdated() )
+ {
+ anIsMustObjectBeUpdated = true;
+ }
+
+ ObjectKind anObjectKind = anObject->GetKind();
+ if( anObjectKind == KIND_IMAGE )
+ {
+ anIsImage = true;
+ Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
+ if( !anImage.IsNull() )
+ {
+ anIsImportedImage = anImage->HasLocalPoints();
+ anIsImageHasRefs = anImage->HasReferences();
+ if( HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory() )
+ {
+ if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
+ {
+ QString anOperatorName = anOperator->name();
+ if( anOperatorName == ImageComposer_FuseOperator::Type() )
+ anIsFusedImage = true;
+ else if( anOperatorName == ImageComposer_CutOperator::Type() )
+ anIsCutImage = true;
+ else if( anOperatorName == ImageComposer_CropOperator::Type() )
+ anIsSplittedImage = true;
+ }
+ }
+ }
+ }
+ else if( anObjectKind == KIND_POLYLINEXY )
+ anIsPolyline = true;
+ else if( anObjectKind == KIND_POLYLINE )
+ anIsPolyline3D = true;
+ else if( anObjectKind == KIND_PROFILE )
+ {
+ anIsProfile = true;
+ aNbOfSelectedProfiles++;
+
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( anObject );
+ if( !aProfile.IsNull() && aProfile->IsValid() ) {
+ anIsValidProfile = true;
+ }
+ }
+ else if( anObjectKind == KIND_CALCULATION )
+ anIsCalculation = true;
+ else if( anObjectKind == KIND_IMMERSIBLE_ZONE )
+ anIsImmersibleZone = true;
+ else if( anObjectKind == KIND_VISUAL_STATE )
+ anIsVisualState = true;
+ else if( anObjectKind == KIND_REGION )
+ anIsRegion = true;
+ else if( anObjectKind == KIND_ZONE )
+ anIsZone = true;
+ else if( anObjectKind == KIND_BATHYMETRY )
+ anIsBathymetry = true;
+ else if( anObjectKind == KIND_OBSTACLE )
+ anIsObstacle = true;
+ else if( anObjectKind == KIND_STREAM )
+ anIsStream = true;
+ else if( anObjectKind == KIND_CHANNEL )
+ anIsChannel = true;
+ else if( anObjectKind == KIND_DIGUE )
+ anIsDigue = true;
+ else if( anObjectKind == KIND_DUMMY_3D )
+ anIsDummyObject3D = true;
+ else if( anObjectKind == KIND_SHAPES_GROUP || anObjectKind == KIND_SPLITTED_GROUP )
+ anIsGroup = true;
+ }
+
+ if ( !anIsObjectCanBeColored )
+ anIsObjectCanBeColored = HYDROGUI_SetColorOp::CanObjectBeColored( anObject );
+ }
+
+ // Check if all selected objects are profiles
+ anAllAreProfiles = ( aNbOfSelectedProfiles > 0 ) &&
+ ( aNbOfSelectedProfiles == aSeq.Length() );
+
+ // check the selected partitions
+ if( !anIsSelectedDataObjects && anIsObjectBrowser )
+ {
+ ObjectKind aSelectedPartition = HYDROGUI_Tool::GetSelectedPartition( this );
+ if( aSelectedPartition != KIND_UNKNOWN )
+ {
+ switch( aSelectedPartition )
+ {
+ case KIND_IMAGE:
+ theMenu->addAction( action( ImportImageId ) );
+ break;
+ case KIND_BATHYMETRY:
+ theMenu->addAction( action( ImportBathymetryId ) );
+ break;
+ case KIND_ARTIFICIAL_OBJECT:
+ theMenu->addAction( action( CreateChannelId ) );
+ theMenu->addAction( action( CreateDigueId ) );
+ break;
+ case KIND_NATURAL_OBJECT:
+ theMenu->addAction( action( CreateImmersibleZoneId ) );
+ theMenu->addAction( action( CreateStreamId ) );
+ break;
+ case KIND_OBSTACLE:
+ theMenu->addAction( action( ImportObstacleFromFileId ) );
+ theMenu->addAction( action( CreateBoxId ) );
+ theMenu->addAction( action( CreateCylinderId ) );
+ break;
+ case KIND_CALCULATION:
+ theMenu->addAction( action( CreateCalculationId ) );
+ break;
+ case KIND_POLYLINEXY:
+ theMenu->addAction( action( CreatePolylineId ) );
+ break;
+ case KIND_POLYLINE:
+ theMenu->addAction( action( CreatePolyline3DId ) );
+ break;
+ case KIND_PROFILE:
+ theMenu->addAction( action( CreateProfileId ) );
+ theMenu->addAction( action( ImportProfilesId ) );
+ theMenu->addAction( action( AllGeoreferencementId ) );
+ break;
+ case KIND_VISUAL_STATE:
+ theMenu->addAction( action( SaveVisualStateId ) );
+ break;
+ }
+ theMenu->addSeparator();
+ }
+ }
+
+ if( anIsSelectedDataObjects )
+ {
+ if ( anIsMustObjectBeUpdated )
+ {
+ theMenu->addAction( action( UpdateObjectId ) );
+ theMenu->addSeparator();
+ }
+ else
+ {
+ theMenu->addAction( action( ForcedUpdateObjectId ) );
+ theMenu->addSeparator();
+ }
+
+
+ if( aSeq.Length() == 1 )
+ {
+ if( anIsImage )
+ {
+ if( anIsImportedImage )
+ theMenu->addAction( action( EditImportedImageId ) );
+ else if( anIsImageHasRefs )
+ {
+ if( anIsFusedImage )
+ theMenu->addAction( action( EditFusedImageId ) );
+ else if( anIsCutImage )
+ theMenu->addAction( action( EditCutImageId ) );
+ else if( anIsSplittedImage )
+ theMenu->addAction( action( EditSplittedImageId ) );
+ }
+
+ //RKV: BUG#98: theMenu->addAction( action( ObserveImageId ) );
+ theMenu->addAction( action( ExportImageId ) );
+ theMenu->addSeparator();
+
+ if( anIsImageHasRefs )
+ {
+ theMenu->addAction( action( RemoveImageRefsId ) );
+ theMenu->addSeparator();
+ }
+
+ theMenu->addAction( action( FuseImagesId ) );
+ theMenu->addAction( action( CutImagesId ) );
+ theMenu->addAction( action( SplitImageId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsBathymetry )
+ {
+ theMenu->addAction( action( EditImportedBathymetryId ) );
+ theMenu->addAction( action( BathymetryBoundsId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsPolyline )
+ {
+ theMenu->addAction( action( EditPolylineId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsPolyline3D )
+ {
+ theMenu->addAction( action( EditPolyline3DId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsProfile )
+ {
+ theMenu->addAction( action( EditProfileId ) );
+ theMenu->addAction( action( SelectedGeoreferencementId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsCalculation )
+ {
+ theMenu->addAction( action( EditCalculationId ) );
+ theMenu->addAction( action( ExportCalculationId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsImmersibleZone )
+ {
+ theMenu->addAction( action( EditImmersibleZoneId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsStream )
+ {
+ theMenu->addAction( action( EditStreamId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsChannel )
+ {
+ theMenu->addAction( action( EditChannelId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsDigue )
+ {
+ theMenu->addAction( action( EditDigueId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsObstacle )
+ {
+ theMenu->addAction( action( TranslateObstacleId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsVisualState && anIsObjectBrowser )
+ {
+ theMenu->addAction( action( SaveVisualStateId ) );
+ theMenu->addAction( action( LoadVisualStateId ) );
+ theMenu->addSeparator();
+ }
+
+ // Add set color action for geometrical objects
+ if ( anIsObjectCanBeColored )
+ {
+ theMenu->addAction( action( SetColorId ) );
+ theMenu->addSeparator();
+ }
+ } else if ( anAllAreProfiles ) {
+ theMenu->addAction( action( SelectedGeoreferencementId ) );
+ theMenu->addSeparator();
+ }
+
+ // Add copy action
+ QAction* aCopyAction = action( CopyId );
+ if( aCopyAction && aCopyAction->isEnabled() ) {
+ theMenu->addAction( action( CopyId ) );
+ theMenu->addSeparator();
+ }
+
+ // Add delete action
+ if( !anIsDummyObject3D )
+ theMenu->addAction( action( DeleteId ) );
+
+ theMenu->addSeparator();
+
+ if( anIsImage || anIsPolyline || anIsPolyline3D ||
+ anIsImmersibleZone || anIsZone || anIsRegion ||
+ anIsBathymetry || anIsObstacle || anIsStream ||
+ anIsChannel || anIsDigue || anIsDummyObject3D ||
+ anIsValidProfile || anIsGroup )
+ {
+ if( anIsHiddenInSelection )
+ theMenu->addAction( action( ShowId ) );
+ theMenu->addAction( action( ShowOnlyId ) );
+ if( anIsVisibleInSelection )
+ theMenu->addAction( action( HideId ) );
+ theMenu->addSeparator();
+ }
+ }
+
+ if ( anIsOCCView )
+ {
+ SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
+ HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
+ if ( aPolylineOp && aPolylineOp->deleteEnabled() )
+ theMenu->addAction( action( DeleteId ) );
+
+ theMenu->addSeparator();
+ theMenu->addAction( action( SetZLevelId ) );
+ theMenu->addSeparator();
+ }
+
+ if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView || anIsVTKView )
+ {
+ theMenu->addAction( action( ShowAllId ) );
+ theMenu->addAction( action( HideAllId ) );
+ theMenu->addSeparator();
+ }
+
+ if ( anIsOCCView || anIsVTKView )
+ {
+ theMenu->addSeparator();
+ theMenu->addAction( action( CopyViewerPositionId ) );
+ }
+
+ if( isRoot )
+ theMenu->addAction( action( EditLocalCSId ) );