]> SALOME platform Git repositories - modules/hydro.git/blobdiff - src/HYDROGUI/HYDROGUI_Module.cxx
Salome HOME
Creat\Edit stream operation.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Module.cxx
index 3b45b680811bfe71cc048aab341e2d488796b888..604ed597512ab270758189fc867e779fdf846210 100644 (file)
@@ -41,6 +41,7 @@
 #include "HYDROGUI_PolylineOp.h"
 
 #include <HYDROData_Image.h>
+#include <HYDROData_Profile.h>
 #include <HYDROData_Lambert93.h>
 #include <HYDROData_Tool.h>
 
@@ -153,6 +154,8 @@ bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
   connect( anApp, SIGNAL( operationFinished( const QString&, const QString&, const QStringList& ) ), 
            this, SLOT( onExternalOperationFinished( const QString&, const QString&, const QStringList& ) ) );
 
+  HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, false );
+
   return aRes;
 }
 
@@ -166,6 +169,7 @@ bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy )
 
   myObjectStateMap.clear();
   myShapesMap.clear();
+  myVTKPrsMap.clear();
 
   // clear the data model's list of copying objects
   HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() );
@@ -178,6 +182,8 @@ bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy )
   disconnect( getApp(), SIGNAL( operationFinished( const QString&, const QString&, const QStringList& ) ), 
               this, SLOT( onExternalOperationFinished( const QString&, const QString&, const QStringList& ) ) );
 
+  HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, true );
+
   return LightApp_Module::deactivateModule( theStudy );
 }
 
@@ -223,6 +229,10 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
   bool anIsSplittedImage = false;
   bool anIsMustBeUpdatedImage = 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;
@@ -230,6 +240,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
   bool anIsRegion = false;
   bool anIsZone = false;
   bool anIsObstacle = false;
+  bool anIsStream = false;
   bool anIsGeomObject = false;
 
   // check the selected GEOM objects
@@ -240,6 +251,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
 
   // 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 );
@@ -251,13 +263,14 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       anIsVisibleInSelection |= aVisibility;
       anIsHiddenInSelection |= !aVisibility;
 
-      if( anObject->GetKind() == KIND_IMAGE )
+      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() && !anImage->IsSelfSplitted();
+          anIsImportedImage = anImage->HasLocalPoints();
           anIsImageHasRefs = anImage->HasReferences();
           if( HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory() )
           {
@@ -278,27 +291,46 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
           }
         }
       }
-      else if( anObject->GetKind() == KIND_POLYLINE )
+      else if( anObjectKind == KIND_POLYLINEXY )
         anIsPolyline = true;
-      else if( anObject->GetKind() == KIND_CALCULATION )
+      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( anObject->GetKind() == KIND_IMMERSIBLE_ZONE )
+      else if( anObjectKind == KIND_IMMERSIBLE_ZONE )
         anIsImmersibleZone = true;
-      else if( anObject->GetKind() == KIND_VISUAL_STATE )
+      else if( anObjectKind == KIND_VISUAL_STATE )
         anIsVisualState = true;
-      else if( anObject->GetKind() == KIND_REGION )
+      else if( anObjectKind == KIND_REGION )
         anIsRegion = true;
-      else if( anObject->GetKind() == KIND_ZONE )
+      else if( anObjectKind == KIND_ZONE )
         anIsZone = true;
-      else if( anObject->GetKind() == KIND_BATHYMETRY )
+      else if( anObjectKind == KIND_BATHYMETRY )
         anIsBathymetry = true;
-      else if( anObject->GetKind() == KIND_OBSTACLE )
+      else if( anObjectKind == KIND_OBSTACLE )
         anIsObstacle = true;
+      else if( anObjectKind == KIND_STREAM )
+        anIsStream = true;
     }
 
     anIsGeomObject = HYDROData_Tool::IsGeometryObject( anObject );
   }
 
+  // Check if all selected objects are profiles
+  anAllAreProfiles = ( aNbOfSelectedProfiles > 0 ) &&
+                     ( aNbOfSelectedProfiles == aSeq.Length() );
+
   // check the selected partitions
   if( !anIsSelectedDataObjects && anIsObjectBrowser )
   {
@@ -310,9 +342,17 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         case KIND_IMAGE:
           theMenu->addAction( action( ImportImageId ) );
           break;
-        case KIND_POLYLINE:
+        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;
@@ -379,6 +419,17 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         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 ) );
@@ -390,6 +441,11 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         theMenu->addAction( action( EditImmersibleZoneId ) );
         theMenu->addSeparator();
       }
+      else if( anIsStream )
+      {
+        theMenu->addAction( action( EditStreamId ) );
+        theMenu->addSeparator();
+      }
       else if( anIsVisualState && anIsObjectBrowser )
       {
         theMenu->addAction( action( SaveVisualStateId ) );
@@ -403,12 +459,16 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         theMenu->addAction( action( SetColorId ) );
         theMenu->addSeparator();
       }
+    } else if ( anAllAreProfiles ) {
+      theMenu->addAction( action( SelectedGeoreferencementId ) );
+      theMenu->addSeparator();
     }
 
     theMenu->addAction( action( DeleteId ) );
     theMenu->addSeparator();
 
-    if( anIsImage || anIsPolyline || anIsImmersibleZone || anIsZone || anIsRegion || anIsBathymetry || anIsObstacle )
+    if( anIsImage || anIsPolyline || anIsPolyline3D || anIsImmersibleZone || anIsZone || 
+        anIsRegion || anIsBathymetry || anIsObstacle || anIsStream || anIsValidProfile )
     {
       if( anIsHiddenInSelection )
         theMenu->addAction( action( ShowId ) );
@@ -743,6 +803,26 @@ void HYDROGUI_Module::setObjectVTKPrs( const int                       theViewId
   if( theObject.IsNull() )
     return;
 
+  // Compute the new global Z range from the added presentation and the old global Z range.
+  double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
+  double* aRange = theShape->getInternalZRange();
+  bool anIsUpdate = false;
+  if ( aRange[0] < aGlobalRange[0] )
+  {
+    aGlobalRange[0] = aRange[0];
+    anIsUpdate = true;
+  }
+  if ( aRange[1] > aGlobalRange[1] )
+  {
+    aGlobalRange[1] = aRange[1];
+    anIsUpdate = true;
+  }
+
+  //if ( anIsUpdate )
+  //{
+    updateVTKZRange( theViewId, aGlobalRange );
+  //}
+
   ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
   aViewShapes.append( theShape );
 }
@@ -768,6 +848,10 @@ void HYDROGUI_Module::removeObjectVTKPrs( const int                       theVie
 
     ++i;
   }
+
+  // Invalidate global Z range
+  double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
+  getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
 }
 
 void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
@@ -785,6 +869,26 @@ void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
 
   myVTKPrsMap.remove( theViewId );
 }
+
+void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
+{
+  if ( myVTKPrsMap.contains( theViewId ) )
+  {
+    // For the given viewer id update all VTK presentations ...
+    const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
+    HYDROGUI_VTKPrs* aShape;
+    for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
+    {
+      aShape = aViewShapes.at( i );
+      if ( aShape )
+      {
+        aShape->setZRange( theRange );
+      }
+    }
+  }
+  // ... and update the global color legend scalar bar.
+  getVTKDisplayer()->SetZRange( theViewId, theRange );
+}
 /////////////////// END OF VTKPrs PROCESSING
 
 CAM_DataModel* HYDROGUI_Module::createDataModel()
@@ -882,6 +986,16 @@ void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
         removeViewShapes( (size_t)anOCCViewer );
     }
 
+    if ( getVTKDisplayer()->IsApplicable( theViewManager ) )
+    {
+      SVTK_Viewer* aVTKViewer = getVTKViewer( anId );
+      if ( aVTKViewer )
+      {
+        getVTKDisplayer()->DeleteScalarBar( anId );
+        removeViewShapes( (size_t)aVTKViewer );
+      }
+    }
+
     myViewManagerMap.remove( anId );
   }
 }
@@ -905,6 +1019,8 @@ void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
     if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
     {
       aViewFrame->onTopView();
+
+      HYDROGUI_Tool::setOCCActionShown( aViewFrame, OCCViewer_ViewWindow::MaximizedId, false );
     }
   }
 }