Salome HOME
LOT 15
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImportBathymetryOp.cxx
index 02ea51ac293063d1dff35c8ef40ae345dfa2bcc9..ed80b1d248a6bf0b3c6bb6839f85f7947f7e32f2 100644 (file)
@@ -26,6 +26,8 @@
 #include "HYDROGUI_Tool2.h"
 #include "HYDROGUI_UpdateFlags.h"
 
+#include <HYDROGUI_OCCDisplayer.h>
+
 #include <HYDROData_Bathymetry.h>
 
 #include <LightApp_Application.h>
 #include <SUIT_ViewManager.h>
 #include <SVTK_ViewModel.h>
 
+#include <OCCViewer_ViewManager.h>
 #include <QFileInfo>
 #include <QSet>
 #include <SUIT_MessageBox.h>
 #include <SUIT_Desktop.h>
+#include <HYDROGUI_ShapeBathymetry.h>
 
 
 HYDROGUI_ImportBathymetryOp::HYDROGUI_ImportBathymetryOp( HYDROGUI_Module* theModule, 
@@ -61,6 +65,7 @@ void HYDROGUI_ImportBathymetryOp::startOperation()
     return;
 
   aPanel->reset();
+  aPanel->SetEditMode(myIsEdit);
 
   if( myIsEdit )
   {
@@ -75,7 +80,7 @@ void HYDROGUI_ImportBathymetryOp::startOperation()
       aPanel->setFuseIntoOneOptionChecked( true );
 
       aPanel->setObjectName( aName );
-      aPanel->setFileNames( aFileNames ); 
+      aPanel->addFileNames( aFileNames ); 
       aPanel->setInvertAltitudes( anIsAltitudesInverted );
       aPanel->setFuseIntoOneOptionEnabled( false );
     }
@@ -147,7 +152,7 @@ bool HYDROGUI_ImportBathymetryOp::processApply( int& theUpdateFlags,
 
   if (!inexistWarn.isNull())
     SUIT_MessageBox::warning( module()->getApp()->desktop(), 
-    tr( "BATHEMETRY_IMPORT_WARNING" ), "Can't read the next files:" + inexistWarn );
+    tr( "BATHYMETRY_IMPORT_WARNING" ), "Can't read the next files:" + inexistWarn );
 
   aFileNames = DummyFileList;
 
@@ -163,11 +168,11 @@ bool HYDROGUI_ImportBathymetryOp::processApply( int& theUpdateFlags,
     if (myEditedObject.IsNull())
       return false;
     QStringList anOldFileNames = myEditedObject->GetFilePaths(); 
-    bool anIsInvertAltitudes = aPanel->isInvertAltitudes();
-    myEditedObject->SetAltitudesInverted( anIsInvertAltitudes, false );
+    //bool anIsInvertAltitudes = aPanel->isInvertAltitudes();
+    //myEditedObject->SetAltitudesInverted( anIsInvertAltitudes, false );
     if ( aFileNames.toSet() != anOldFileNames.toSet() )
     {
-      myEditedObject->SetAltitudesInverted( anIsInvertAltitudes, false );
+      myEditedObject->SetAltitudesInverted( anIsInvertAltitudes, true );
       if ( !myEditedObject->ImportFromFiles( aFileNames ) )
       {
         theErrorMsg = tr( "BAD_IMPORTED_BATHYMETRY_FILE" ).arg( aFileNames.join("\n") );
@@ -175,16 +180,9 @@ bool HYDROGUI_ImportBathymetryOp::processApply( int& theUpdateFlags,
       }
     }
     else if ( anIsInvertAltitudes != myEditedObject->IsAltitudesInverted() )
-      myEditedObject->SetAltitudesInverted( anIsInvertAltitudes );
+      myEditedObject->SetAltitudesInverted( anIsInvertAltitudes, true );
 
-    QString aNewObjName;
-    if (CheckNameExistingBathy(anObjectName, aNewObjName))
-    {
-      myEditedObject->SetName( aNewObjName );
-      replacemWarn += "\n'" + anObjectName + "' => '" + aNewObjName + "'";
-    }
-    else
-      myEditedObject->SetName( anObjectName );
+    myEditedObject->SetName( anObjectName );
     myEditedObject->Update();
   }
   else
@@ -256,12 +254,12 @@ bool HYDROGUI_ImportBathymetryOp::processApply( int& theUpdateFlags,
 
   if (!UnreadFilesWarn.isNull())
     SUIT_MessageBox::warning( module()->getApp()->desktop(), 
-    tr( "BATHEMETRY_IMPORT_WARNING" ), "The next files cannot be imported:" + UnreadFilesWarn );
+    tr( "BATHYMETRY_IMPORT_WARNING" ), "The next files cannot be imported:" + UnreadFilesWarn );
 
 
   if (!replacemWarn.isNull())
     SUIT_MessageBox::warning( module()->getApp()->desktop(), 
-    tr( "BATHEMETRY_IMPORT_WARNING" ), "The next objects names are already exist in the document; so the new objects was renamed:" + replacemWarn );
+    tr( "BATHYMETRY_IMPORT_WARNING" ), "The next objects names are already exist in the document; so the new objects was renamed:" + replacemWarn );
 
   // Activate VTK viewer and show the bathymetry
   SUIT_ViewManager* aVTKMgr = 0;
@@ -278,6 +276,19 @@ bool HYDROGUI_ImportBathymetryOp::processApply( int& theUpdateFlags,
       aVTKMgr = module()->getApp()->viewManager( SVTK_Viewer::Type() );
     }
   }
+    
+  OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>(aViewMgr);
+  OCCViewer_Viewer* occ_viewer = mgr->getOCCViewer();
+  int aViewerId = (size_t)(occ_viewer);
+
+  HYDROGUI_Shape* aObjSh = module()->getObjectShape( aViewerId, myEditedObject );
+  HYDROGUI_ShapeBathymetry* aBathSh = dynamic_cast<HYDROGUI_ShapeBathymetry*>( aObjSh );
+  if (aBathSh)
+  {
+    aBathSh->update(false, false);
+    aBathSh->RescaleDefault();
+    module()->getOCCDisplayer()->UpdateColorScale( occ_viewer );
+  }
 
   theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced |
     UF_VTKViewer | UF_VTK_Forced;
@@ -292,25 +303,7 @@ void HYDROGUI_ImportBathymetryOp::onFileSelected()
   if ( !aPanel )
     return;
 
-  QStringList aFileNames = aPanel->getFileNames();
-  if ( !aPanel->isFuseIntoOneOptionEnabled() )
-    aPanel->setFuseIntoOneOptionEnabled( !myIsEdit && aFileNames.count() > 1 );
-
-  QString anObjectName = aPanel->getObjectName().simplified();
-  if ( anObjectName.isEmpty() )
-  {
-    if (aFileNames.count() == 1)
-    {
-      anObjectName = aFileNames[0];
-      if ( !anObjectName.isEmpty() )
-        anObjectName = QFileInfo( anObjectName ).baseName();
-    }
-
-    if ( anObjectName.isEmpty() ) {
-      anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_BATHYMETRY_NAME" ) );
-    }
-    aPanel->setObjectName( anObjectName );
-  }
+  aPanel->UpdateCheckBoxStates();
 }
 
 bool HYDROGUI_ImportBathymetryOp::CheckNameExistingBathy(const QString& InpName, QString& OutputName)