+void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
+ QMenu* theMenu,
+ QString& theTitle )
+{
+ HYDROGUI_DataModel* aModel = getDataModel();
+
+ size_t aViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( this );
+
+ bool anIsSelection = 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 anIsVisualState = false;
+
+ HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
+ for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
+ {
+ Handle(HYDROData_Object) anObject = aSeq.Value( anIndex );
+ if( !anObject.IsNull() )
+ {
+ anIsSelection = true;
+
+ bool aVisibility = isObjectVisible( aViewId, 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->HasTrsfPoints() && !anImage->IsSelfSplitted();
+ anIsCompositeImage = anImage->NbReferences() > 0;
+ if( HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory() )
+ {
+ if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
+ {
+ if( dynamic_cast<ImageComposer_FuseOperator*>( anOperator ) )
+ anIsFusedImage = true;
+ else if( dynamic_cast<ImageComposer_CutOperator*>( anOperator ) )
+ anIsCutImage = true;
+ else if( dynamic_cast<ImageComposer_CropOperator*>( anOperator ) )
+ anIsSplittedImage = true;
+ }
+ }
+ anIsMustBeUpdatedImage = anImage->MustBeUpdated();
+ }
+ }
+ else if( anObject->GetKind() == KIND_POLYLINE )
+ anIsPolyline = true;
+ else if( anObject->GetKind() == KIND_VISUAL_STATE )
+ anIsVisualState = true;
+ }
+ }
+
+ if( aSeq.IsEmpty() )
+ {
+ theMenu->addAction( action( SaveVisualStateId ) );
+ theMenu->addSeparator();
+ }
+
+ if( anIsSelection && anIsMustBeUpdatedImage )
+ {
+ theMenu->addAction( action( UpdateImageId ) );
+ theMenu->addSeparator();
+ }
+
+ if( anIsSelection && 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();
+ }
+ else if( anIsPolyline )
+ {
+ theMenu->addAction( action( EditPolylineId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsVisualState )
+ {
+ theMenu->addAction( action( SaveVisualStateId ) );
+ theMenu->addAction( action( LoadVisualStateId ) );
+ theMenu->addSeparator();
+ }
+ }
+
+ if( anIsSelection )
+ {
+ theMenu->addAction( action( DeleteId ) );
+ theMenu->addSeparator();
+ }
+
+ if( anIsSelection && ( anIsImage || anIsPolyline ) )
+ {
+ if( anIsHiddenInSelection )
+ theMenu->addAction( action( ShowId ) );
+ theMenu->addAction( action( ShowOnlyId ) );
+ if( anIsVisibleInSelection )
+ theMenu->addAction( action( HideId ) );
+ theMenu->addSeparator();
+ }
+
+ theMenu->addAction( action( ShowAllId ) );
+ theMenu->addAction( action( HideAllId ) );
+ theMenu->addSeparator();
+}
+