+ theTypesList << OCCViewer_Viewer::Type() << GraphicsView_Viewer::Type();
+}
+
+void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
+ QMenu* theMenu,
+ QString& theTitle )
+{
+ HYDROGUI_DataModel* aModel = getDataModel();
+
+ bool anIsObjectBrowser = theClient == "ObjectBrowser";
+ bool anIsGraphicsView = theClient == GraphicsView_Viewer::Type();
+ bool anIsOCCView = theClient == OCCViewer_Viewer::Type();
+ if( !anIsObjectBrowser && !anIsGraphicsView && !anIsOCCView )
+ return;
+
+ size_t anActiveViewId = HYDROGUI_Tool::GetActiveViewId( this );
+
+ bool anIsSelectedDataObjects = false;
+ bool anIsVisibleInSelection = false;
+ bool anIsHiddenInSelection = false;
+
+ bool anIsImage = false;
+ bool anIsImportedImage = false;
+ bool anIsCompositeImage = false;
+ bool anIsFusedImage = false;
+ bool anIsCutImage = false;
+ bool anIsSplittedImage = false;
+ bool anIsMustBeUpdatedImage = false;
+ bool anIsPolyline = false;
+ bool anIsCalculation = false;
+ bool anIsImmersibleZone = false;
+ bool anIsVisualState = false;
+
+ // check the selected data model objects
+ HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
+ 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->GetKind() == KIND_IMAGE )
+ {
+ anIsImage = true;
+ Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
+ if( !anImage.IsNull() )
+ {
+ anIsImportedImage = anImage->HasLocalPoints() && !anImage->IsSelfSplitted();
+ anIsCompositeImage = anImage->NbReferences() > 0;
+ 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;
+ }
+ }
+ anIsMustBeUpdatedImage = anImage->MustBeUpdated();
+ }
+ }
+ else if( anObject->GetKind() == KIND_POLYLINE )
+ anIsPolyline = true;
+ else if( anObject->GetKind() == KIND_CALCULATION )
+ anIsCalculation = true;
+ else if( anObject->GetKind() == KIND_IMMERSIBLE_ZONE )
+ anIsImmersibleZone = true;
+ else if( anObject->GetKind() == KIND_VISUAL_STATE )
+ anIsVisualState = true;
+ }
+ }
+
+ // 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_POLYLINE:
+ theMenu->addAction( action( CreatePolylineId ) );
+ break;
+ case KIND_VISUAL_STATE:
+ theMenu->addAction( action( SaveVisualStateId ) );
+ break;
+ case KIND_BATHYMETRY:
+ theMenu->addAction( action( ImportBathymetryId ) );
+ break;
+ case KIND_CALCULATION:
+ theMenu->addAction( action( CreateCalculationId ) );
+ break;
+ case KIND_IMMERSIBLE_ZONE:
+ theMenu->addAction( action( CreateImmersibleZoneId ) );
+ break;
+ }
+ theMenu->addSeparator();
+ }
+ }
+
+ if( anIsSelectedDataObjects && anIsMustBeUpdatedImage )
+ {
+ theMenu->addAction( action( UpdateImageId ) );
+ theMenu->addSeparator();
+ }
+
+ if( anIsSelectedDataObjects && aSeq.Length() == 1 )
+ {
+ if( anIsImage )
+ {
+ if( anIsImportedImage )
+ theMenu->addAction( action( EditImportedImageId ) );
+ else if( anIsCompositeImage )
+ {
+ if( anIsFusedImage )
+ theMenu->addAction( action( EditFusedImageId ) );
+ else if( anIsCutImage )
+ theMenu->addAction( action( EditCutImageId ) );
+ else if( anIsSplittedImage )
+ theMenu->addAction( action( EditSplittedImageId ) );
+ }
+
+ theMenu->addAction( action( ObserveImageId ) );
+ theMenu->addAction( action( ExportImageId ) );
+ theMenu->addSeparator();
+
+ theMenu->addAction( action( FuseImagesId ) );
+ theMenu->addAction( action( CutImagesId ) );
+ theMenu->addAction( action( SplitImageId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsPolyline )
+ {
+ theMenu->addAction( action( EditPolylineId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsCalculation )
+ {
+ theMenu->addAction( action( EditCalculationId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsImmersibleZone )
+ {
+ theMenu->addAction( action( EditImmersibleZoneId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsVisualState && anIsObjectBrowser )
+ {
+ theMenu->addAction( action( SaveVisualStateId ) );
+ theMenu->addAction( action( LoadVisualStateId ) );
+ theMenu->addSeparator();
+ }
+ }
+
+ if( anIsSelectedDataObjects )
+ {
+ theMenu->addAction( action( DeleteId ) );
+ theMenu->addSeparator();
+ }
+
+ if( anIsSelectedDataObjects && ( anIsImage || anIsPolyline || anIsImmersibleZone ) )
+ {
+ if( anIsHiddenInSelection )
+ theMenu->addAction( action( ShowId ) );
+ theMenu->addAction( action( ShowOnlyId ) );
+ if( anIsVisibleInSelection )
+ theMenu->addAction( action( HideId ) );
+ theMenu->addSeparator();
+ }
+
+ if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView )
+ {
+ theMenu->addAction( action( ShowAllId ) );
+ theMenu->addAction( action( HideAllId ) );
+ theMenu->addSeparator();
+ }