Salome HOME
Fix for the bug #42: point C is not activated, but point C is shown in preview in...
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Module.cxx
index 51b899a7fef7142b1166c99632d28bcdef3eda79..b36585e22f5de3e928030780271e0b060830d6c4 100644 (file)
@@ -39,7 +39,7 @@
 #include <HYDROData_Image.h>
 #include <HYDROData_Lambert93.h>
 
-#include <HYDROOperations_Factory.h>
+#include <HYDROData_OperationsFactory.h>
 
 #include <GraphicsView_ViewFrame.h>
 #include <GraphicsView_ViewManager.h>
@@ -199,21 +199,21 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
 
   bool anIsImage = false;
   bool anIsImportedImage = false;
-  bool anIsCompositeImage = false;
+  bool anIsImageHasRefs = false;
   bool anIsFusedImage = false;
   bool anIsCutImage = false;
   bool anIsSplittedImage = false;
   bool anIsMustBeUpdatedImage = false;
   bool anIsPolyline = false;
   bool anIsCalculation = false;
-  bool anIsZone = 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_Object) anObject = aSeq.Value( anIndex );
+    Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
     if( !anObject.IsNull() )
     {
       anIsSelectedDataObjects = true;
@@ -228,9 +228,9 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         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() )
+          anIsImportedImage = anImage->HasLocalPoints() && !anImage->IsSelfSplitted();
+          anIsImageHasRefs = anImage->HasReferences();
+          if( HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory() )
           {
             if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
             {
@@ -243,15 +243,15 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
                 anIsSplittedImage = true;
             }
           }
-          anIsMustBeUpdatedImage = anImage->MustBeUpdated();
+          anIsMustBeUpdatedImage = anImage->IsMustBeUpdated();
         }
       }
       else if( anObject->GetKind() == KIND_POLYLINE )
         anIsPolyline = true;
       else if( anObject->GetKind() == KIND_CALCULATION )
         anIsCalculation = true;
-      else if( anObject->GetKind() == KIND_ZONE )
-        anIsZone = true;
+      else if( anObject->GetKind() == KIND_IMMERSIBLE_ZONE )
+        anIsImmersibleZone = true;
       else if( anObject->GetKind() == KIND_VISUAL_STATE )
         anIsVisualState = true;
     }
@@ -280,8 +280,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         case KIND_CALCULATION:
           theMenu->addAction( action( CreateCalculationId ) );
           break;
-        case KIND_ZONE:
-          theMenu->addAction( action( CreateZoneId ) );
+        case KIND_IMMERSIBLE_ZONE:
+          theMenu->addAction( action( CreateImmersibleZoneId ) );
           break;
       }
       theMenu->addSeparator();
@@ -300,7 +300,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
     {
       if( anIsImportedImage )
         theMenu->addAction( action( EditImportedImageId ) );
-      else if( anIsCompositeImage )
+      else if( anIsImageHasRefs )
       {
         if( anIsFusedImage )
           theMenu->addAction( action( EditFusedImageId ) );
@@ -314,6 +314,12 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       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 ) );
@@ -329,9 +335,9 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       theMenu->addAction( action( EditCalculationId ) );
       theMenu->addSeparator();
     }
-    else if( anIsZone )
+    else if( anIsImmersibleZone )
     {
-      theMenu->addAction( action( EditZoneId ) );
+      theMenu->addAction( action( EditImmersibleZoneId ) );
       theMenu->addSeparator();
     }
     else if( anIsVisualState && anIsObjectBrowser )
@@ -348,7 +354,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
     theMenu->addSeparator();
   }
 
-  if( anIsSelectedDataObjects && ( anIsImage || anIsPolyline || anIsZone ) )
+  if( anIsSelectedDataObjects && ( anIsImage || anIsPolyline || anIsImmersibleZone ) )
   {
     if( anIsHiddenInSelection )
       theMenu->addAction( action( ShowId ) );
@@ -396,7 +402,7 @@ void HYDROGUI_Module::update( const int flags )
     // the selection in the object browser.
     // Note: processEvents() should be called after updateGV(),
     // otherwise the application crashes from time to time.
-    qApp->processEvents(); 
+    //RKV: qApp->processEvents(); 
     getApp()->updateObjectBrowser( true );
   }
 
@@ -508,7 +514,7 @@ void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
 }
 
 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
-                                       const Handle(HYDROData_Object)& theObject ) const
+                                       const Handle(HYDROData_Entity)& theObject ) const
 {
   if( theObject.IsNull() )
     return false;
@@ -528,7 +534,7 @@ bool HYDROGUI_Module::isObjectVisible( const int theViewId,
 }
 
 void HYDROGUI_Module::setObjectVisible( const int theViewId,
-                                        const Handle(HYDROData_Object)& theObject,
+                                        const Handle(HYDROData_Entity)& theObject,
                                         const bool theState )
 {
   if( !theObject.IsNull() )
@@ -540,7 +546,7 @@ void HYDROGUI_Module::setObjectVisible( const int theViewId,
 }
 
 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int                       theViewId,
-                                                 const Handle(HYDROData_Object)& theObject ) const
+                                                 const Handle(HYDROData_Entity)& theObject ) const
 {
   HYDROGUI_Shape* aResShape = NULL;
   if( theObject.IsNull() )
@@ -563,7 +569,7 @@ HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int
 }
 
 void HYDROGUI_Module::setObjectShape( const int                       theViewId,
-                                      const Handle(HYDROData_Object)& theObject,
+                                      const Handle(HYDROData_Entity)& theObject,
                                       HYDROGUI_Shape*                 theShape )
 {
   if( theObject.IsNull() )
@@ -574,16 +580,18 @@ void HYDROGUI_Module::setObjectShape( const int                       theViewId,
 }
 
 void HYDROGUI_Module::removeObjectShape( const int                       theViewId,
-                                         const Handle(HYDROData_Object)& theObject )
+                                         const Handle(HYDROData_Entity)& theObject )
 {
   if ( !myShapesMap.contains( theViewId ) )
     return;
 
   ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
+  Handle(HYDROData_Entity) anObject;
   for ( int i = 0; i < aViewShapes.length(); )
   {
     HYDROGUI_Shape* aShape = aViewShapes.at( i );
-    if ( aShape && IsEqual( aShape->getObject(), theObject ) )
+    anObject = aShape->getObject();
+    if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
     {
       delete aShape;
       aViewShapes.removeAt( i );
@@ -630,7 +638,7 @@ void HYDROGUI_Module::customEvent( QEvent* e )
 
         if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
         {
-          if( aRole != VMR_TransformImage )
+          if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
             aViewPort->scale( 1, -1 ); // invert the Y axis direction from down to up
 
           aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
@@ -641,7 +649,7 @@ void HYDROGUI_Module::customEvent( QEvent* e )
           //aViewPort->setViewLabelPosition( GraphicsView_ViewPort::VLP_BottomLeft, true );
         }
 
-        if( aRole != VMR_TransformImage )
+        if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
           update( UF_Viewer );
 
         aViewer->activateTransform( GraphicsView_Viewer::FitAll );