Salome HOME
first part of the porting on OCCT 7.0
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_ImportLandCoverMapOp.cxx
index 540a159242b6a4d657190abfc228e5d27351f75f..deba3d6c38232dba9b102e18ce3f624ece2b3890 100644 (file)
 #include "HYDROGUI_DataModel.h"
 #include "HYDROGUI_Module.h"
 #include "HYDROGUI_UpdateFlags.h"
-#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_Tool2.h"
 #include "HYDROGUI_ImportLandCoverMapDlg.h"
 #include "HYDROGUI_Shape.h"
-#include <HYDROData_LandCoverMap.h>
 #include <HYDROGUI_ZLayers.h>
-
 #include <HYDROGUI_DataObject.h>
 #include <HYDROData_Iterator.h>
 #include <HYDROData_ShapeFile.h>
 #include <HYDROData_Profile.h>
+#include <HYDROData_LandCoverMap.h>
+#include <HYDROData_StricklerTable.h>
 
 #include <SUIT_Desktop.h>
 #include <SUIT_FileDlg.h>
-#include <LightApp_Application.h>
-
-#include <QApplication>
-#include <QFile>
-#include <QFileInfo>
 #include <SUIT_MessageBox.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_ViewManager.h>
 
 #include <OCCViewer_ViewManager.h>
 #include <OCCViewer_ViewModel.h>
 
 #include <SalomeApp_Study.h>
-
 #include <LightApp_Application.h>
 #include <LightApp_DataOwner.h>
 #include <LightApp_Displayer.h>
 #include <LightApp_SelectionMgr.h>
 
-#include <SUIT_Desktop.h>
-#include <SUIT_ViewManager.h>
-
 #include <BRep_Builder.hxx>
 #include <TopoDS.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Wire.hxx>
 
+#include <QSet>
+#include <QFile>
+#include <QFileInfo>
 
-#include <BRepTools.hxx>
+#include <QApplication>
 
+#define MAX_LCM_NAME_INDEX 1000
 
 HYDROGUI_ImportLandCoverMapOp::HYDROGUI_ImportLandCoverMapOp( HYDROGUI_Module* theModule )
 : HYDROGUI_Operation( theModule )
 {
-  setName( tr( "IMPORT_LANDCOVER" ) );
+  setName( tr( "IMPORT_LANDCOVER_MAP" ) );
 }
 
 HYDROGUI_ImportLandCoverMapOp::~HYDROGUI_ImportLandCoverMapOp()
 {
   erasePreview();
+  myImporter.Free();
+  myAttrValue.clear();
 }
 
 void HYDROGUI_ImportLandCoverMapOp::startOperation()
 {
   HYDROGUI_Operation::startOperation();
 
-  if ( !getPreviewManager() ) {
-    setPreviewManager( ::qobject_cast<OCCViewer_ViewManager*>( 
-                       module()->getApp()->getViewManager( OCCViewer_Viewer::Type(), true ) ) );
-  }
+  if ( !getPreviewManager() )
+    setPreviewManager( ::qobject_cast<OCCViewer_ViewManager*>( module()->getApp()->getViewManager( OCCViewer_Viewer::Type(), true ) ) );
 
-  if ( !isApplyAndClose() ) {
-    return;
-  }
-
-  HYDROGUI_ImportLandCoverMapDlg* aPanel = 
-    ::qobject_cast<HYDROGUI_ImportLandCoverMapDlg*>( inputPanel() );
-  if ( !aPanel ) {
+  HYDROGUI_ImportLandCoverMapDlg* aPanel = ::qobject_cast<HYDROGUI_ImportLandCoverMapDlg*>( inputPanel() );
+  if ( !aPanel )
     return;
-  }
 
   aPanel->reset();
 }
@@ -115,96 +106,109 @@ void HYDROGUI_ImportLandCoverMapOp::onFileSelected()
     anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_LANDCOVERMAP_NAME" ) );
   aPanel->setObjectName( anObjectName );
 
-  QString aFileName = aPanel->getFileName();
-  if ( aFileName.isEmpty() )
+  myFileName = aPanel->getFileName();
+  if ( myFileName.isEmpty() )
   {
     abort();
     return;
   }
 
-  QString anExt = aFileName.split('.', QString::SkipEmptyParts).back();
+  startDocOperation();    
+  QApplication::setOverrideCursor(Qt::WaitCursor);
+  
+  QStringList aPolygonsList;
+  myPolygonFaces.Clear();
+  myImporter.Free();
 
-  if (anExt == "shp")
-  {     
-    startDocOperation();    
-    QApplication::setOverrideCursor(Qt::WaitCursor);
-    
-    QStringList aPolygonsList;
-    TopTools_SequenceOfShape aFaces;
-    HYDROData_ShapeFile anImporter;
+  SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( module()->getApp()->activeStudy() );
+  if ( !aStudy )
+    return;
 
-    SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( module()->getApp()->activeStudy() );
-    if ( !aStudy )
-      return;
+  erasePreview();
 
-    erasePreview();
+  Handle(AIS_InteractiveContext) aCtx = NULL;
+  int aShapeTypeOfFile = -1;
 
-    Handle(AIS_InteractiveContext) aCtx = NULL;
-    int aShapeTypeOfFile = -1;
-    int aStat = anImporter.ImportLandCovers(aFileName, aPolygonsList, aFaces, aShapeTypeOfFile);
-    if (aStat == 1)
-    {
-      aPanel->setPolygonNames(aPolygonsList);
+  //Import polygons from SHP file as faces
+  //This faces should be added to the new LCM object
 
-      LightApp_Application* anApp = module()->getApp();
-      if ( !getPreviewManager() )
-        setPreviewManager( ::qobject_cast<OCCViewer_ViewManager*>( anApp->getViewManager( OCCViewer_Viewer::Type(), true ) ) );
-      OCCViewer_ViewManager* aViewManager = getPreviewManager();
+  int aStat = myImporter.ImportPolygons(doc(), myFileName, aPolygonsList, myPolygonFaces, aShapeTypeOfFile);
+  if (aStat == 1)
+  {
+    aPanel->setPolygonNames(aPolygonsList);
 
-      if ( aViewManager )
-      {
-        if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() )
-        {
-          aCtx = aViewer->getAISContext();
-          connect( aViewer, SIGNAL( selectionChanged() ), this, SLOT( onViewerSelectionChanged() ) );
-        }
-      }
+    LightApp_Application* anApp = module()->getApp();
+    if ( !getPreviewManager() )
+      setPreviewManager( ::qobject_cast<OCCViewer_ViewManager*>( anApp->getViewManager( OCCViewer_Viewer::Type(), true ) ) );
+    OCCViewer_ViewManager* aViewManager = getPreviewManager();
 
-      for ( int i = 1; i <= aFaces.Length(); i++ ) 
+    if ( aViewManager )
+    {
+      if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() )
       {
-        TopoDS_Face aFace = TopoDS::Face(aFaces.Value( i ));
-        if ( aViewManager && !aCtx.IsNull() )
-        {
-          HYDROGUI_Shape* aShape = new HYDROGUI_Shape( aCtx, NULL, getPreviewZLayer() );
-          //Green color for now..
-          aShape->setFillingColor(QColor(0,255,0), false, false);
-          aShape->setBorderColor(QColor(0,255,0), false, false);
-          if( !aFace.IsNull() )
-            aShape->setShape( aFace);
-
-          myPolygonName2PrsShape.insert( "polygon_" + QString::number(i), aShape);
-        }
+        aCtx = aViewer->getAISContext();
+        connect( aViewer, SIGNAL( selectionChanged() ), this, SLOT( onViewerSelectionChanged() ) );
       }
-      if ( !aCtx.IsNull() ) 
+    }
+
+    for ( int i = 1; i <= myPolygonFaces.Length(); i++ ) 
+    {
+      TopoDS_Face aFace = TopoDS::Face(myPolygonFaces.Value( i ));
+      if ( aViewManager && !aCtx.IsNull() )
       {
-        UpdateZLayersOfHilightPresentationsOfDisplayedObjects( aCtx, Graphic3d_ZLayerId_TopOSD );
-        aCtx->UpdateCurrentViewer();
+        HYDROGUI_Shape* aShape = new HYDROGUI_Shape( aCtx, NULL, getPreviewZLayer() );
+        //Preview color is grey
+        aShape->setFillingColor(QColor(50,50,50), false, false);
+        aShape->setBorderColor(QColor(50,50,50), false, false);
+        if( !aFace.IsNull() )
+          aShape->setShape( aFace);
+
+        myPolygonName2PrsShape.insert( tr( "DEF_POLYGON_NAME" ) + "_" + QString::number(i), aShape);
       }
-      
-      QApplication::restoreOverrideCursor();
-      commitDocOperation();
     }
-    else
+
+    if ( !aCtx.IsNull() ) 
     {
-      erasePreview();
-      aPanel->setPolygonNames(QStringList());
-      aPanel->setObjectName("");
-      QApplication::restoreOverrideCursor();
-      QString aMess = "Cannot import land cover;\n";
-      if (aStat == -1)
-        aMess += "Cannot open SHP file";
-      else if (aStat == -2)
-        aMess += "Cannot open SHX file";
-      else 
-        aMess += "The shape type of file is " + anImporter.GetShapeTypeName(aShapeTypeOfFile);
-      SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "IMPORT_LANDCOVER" ), aMess);
-      commitDocOperation();
-      //abort();
+      UpdateZLayersOfHilightPresentationsOfDisplayedObjects( aCtx, Graphic3d_ZLayerId_TopOSD );
+      aCtx->UpdateCurrentViewer();
     }
-    anImporter.Free();
-
+    //
+    QApplication::restoreOverrideCursor();
+    aPanel->setFirstPageState(true); 
+    //
+    //Try to load DBF-database...
+    QString aDBFFileName;
+    aDBFFileName = myFileName.simplified().replace( myFileName.simplified().size() - 4, 4, ".dbf");
+    bool DBF_Stat = myImporter.DBF_OpenDBF(aDBFFileName);
+    // TODO:
+    // add MSG BOX if stat is bad
+    if (DBF_Stat)
+    {
+      myFieldList = myImporter.DBF_GetFieldList();
+      aPanel->setAttributeNames(myFieldList);
+    }
+    aPanel->setDbfState(DBF_Stat);
   }
-  
+  else
+  {
+    erasePreview();
+    aPanel->setPolygonNames(QStringList());
+    aPanel->setObjectName("");
+    QApplication::restoreOverrideCursor();
+    QString aMess = tr( "CANNT_IMPORT_LCM" ) + "\n"; 
+    if (aStat == -1)
+      aMess += tr( "CANNT_OPEN_SHP" );
+    else if (aStat == -2)
+      aMess += tr( "CANNT_OPEN_SHX" );
+    else 
+      aMess += tr ("SHP_TYPEFORMAT_MESS") + myImporter.GetShapeTypeName(aShapeTypeOfFile);
+    SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "IMPORT_LANDCOVER_MAP" ), aMess);
+    commitDocOperation();
+    myImporter.Free();
+    //abort();
+    aPanel->setFirstPageState(false);
+  }
+
 }
 
 HYDROGUI_InputPanel* HYDROGUI_ImportLandCoverMapOp::createInputPanel() const
@@ -212,84 +216,80 @@ HYDROGUI_InputPanel* HYDROGUI_ImportLandCoverMapOp::createInputPanel() const
   HYDROGUI_InputPanel* aPanel = new HYDROGUI_ImportLandCoverMapDlg( module(), getName() );
 
   connect( aPanel, SIGNAL( FileSelected( const QString& ) ), SLOT( onFileSelected() ) );
-
   connect( aPanel, SIGNAL( selectionChanged( const QStringList& ) ), this, SLOT( onSelectionChanged( const QStringList& ) ) );
-
   connect( aPanel, SIGNAL( Next( const int ) ), SLOT( onNext( const int ) ) );
-  connect( aPanel, SIGNAL( Back( const int ) ), SLOT( onBack( const int ) ) );
-  connect( aPanel, SIGNAL( Finish( const int ) ), SLOT( onFinish( const int ) ) );
     
   return aPanel;
 }
 
 bool HYDROGUI_ImportLandCoverMapOp::processApply( int& theUpdateFlags,
-                                                QString& theErrorMsg,
-                                                QStringList& theBrowseObjectsEntries )
+                                                  QString& theErrorMsg,
+                                                  QStringList& theBrowseObjectsEntries )
 {
 
   HYDROGUI_ImportLandCoverMapDlg* aPanel = ::qobject_cast<HYDROGUI_ImportLandCoverMapDlg*>( inputPanel() );
-  if ( !aPanel ) {
+  if ( !aPanel ) 
     return false;
-  }
-  
-  QStringList aSelectedtPolygons = aPanel->getSelectedPolygonNames();
-  aPanel->removePolygonNames( aSelectedtPolygons );
-    
-  if (!aSelectedtPolygons.empty())
+
+  myLCM = Handle(HYDROData_LandCoverMap)::DownCast( doc()->CreateObject( KIND_LAND_COVER_MAP ) );
+  HYDROData_MapOfFaceToStricklerType aMapFace2ST;
+
+  QStringList aAttrV_T;
+  QStringList aSTL;
+  aPanel->getValAttr2StricklerTypeCorr(aAttrV_T, aSTL);
+
+  QVector<int> aSelIndices = aPanel->getSelectedPolygonIndices();
+  foreach ( int Ind, aSelIndices )
   {
-    Handle(HYDROData_LandCoverMap) aLCM =  Handle(HYDROData_LandCoverMap)::DownCast( doc()->CreateObject( KIND_LAND_COVER_MAP ) );
-    TopoDS_Shape aResShape;
-    if (aSelectedtPolygons.size() > 1) 
-    {
-      TopoDS_Compound cmp;
-      BRep_Builder BB;
-      BB.MakeCompound(cmp);
-
-      foreach ( QString aName, aSelectedtPolygons ) {
-        TopoDS_Shape aShape = myPolygonName2PrsShape.value( aName )->getTopoShape();
-        if ( aShape.IsNull() ) 
-          continue;
-        BB.Add(cmp, aShape);
-        HYDROGUI_Shape* aShapeToDelete = myPolygonName2PrsShape.take( aName );
-        delete aShapeToDelete;
-      }
-      aResShape = cmp;
-    }
-    else
-    {         
-      TopoDS_Shape aShape = myPolygonName2PrsShape.value( aSelectedtPolygons.first() )->getTopoShape();
-      if ( !aShape.IsNull() ) 
-      {
-        HYDROGUI_Shape* aShapeToDelete = myPolygonName2PrsShape.take( aSelectedtPolygons.first() );
-        delete aShapeToDelete;
-        aResShape = aShape;
-      }
-    }
-    if( !aLCM.IsNull() ) 
+    TopoDS_Shape aShape = myPolygonFaces(Ind + 1);
+    if ( aShape.IsNull() ) 
+      continue;
+    QString aST = "";
+    if (aPanel->getAttrCheckBoxState())
     {
-      QString aLCName = aPanel->getObjectName() + "_polygon";
-      int i = 0;
-      for( ;HYDROGUI_Tool::FindObjectByName(module(), aLCName); i++)
-        aLCName = aPanel->getObjectName() + "_polygon_" + QString::number(i);
-      aLCM->SetName( aLCName );
-      //TODO add color
-      //aLCM->SetFillingColor( aLCM->DefaultFillingColor() );
-      //aLCM->SetBorderColor( aLCM->DefaultBorderColor() );
-      
-      //aLCM->SetShape(aResShape);
-      aLCM->Show();
-            
-      //erasePreview();
-      
-      module()->setIsToUpdate( aLCM );
-      
+      HYDROData_ShapeFile::DBF_AttrValue aDataVal = myAttrValue[Ind];
+      int aStricklerTypesInd = aAttrV_T.indexOf(QString(aDataVal.myStrVal));
+      aST = aSTL.at(aStricklerTypesInd);
     }
+    // else => ST is empty
+    aMapFace2ST.Add( TopoDS::Face( aShape ), aST );
+  }
+
+  //
+  myLCM->StoreLandCovers(aMapFace2ST);
+
+  QString anObjName;
+  if ( !aPanel->getFileName().isEmpty() )
+    anObjName = aPanel->getObjectName();
+  
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( application()->activeStudy()->id() );
+
+  //check if name of LCM is already exists
+  QSet<QString> aNameList;
+  if (aDoc)
+  {
+    HYDROData_Iterator anIt( aDoc, KIND_LAND_COVER_MAP );
+    for( ; anIt.More(); anIt.Next() )
+      aNameList << anIt.Current()->GetName();
   }
+
+  QString aNewName = anObjName;
+  for ( int i = 1; i < MAX_LCM_NAME_INDEX && aNameList.contains(aNewName); i++)
+    aNewName = anObjName + "_" + QString::number(i);
+
+  if( !myLCM.IsNull() ) 
+  {
+    myLCM->SetName( aNewName );
+    myLCM->SetColor( Qt::gray );
+    myLCM->Show();
+    module()->setIsToUpdate( myLCM );
+  }
+  
   module()->update( UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init );
 
-  if ( isApplyAndClose() )
-    erasePreview();
+  erasePreview();
+  myImporter.Free();
+  myAttrValue.clear();
 
   return true;
 }
@@ -306,61 +306,67 @@ void HYDROGUI_ImportLandCoverMapOp::onSelectionChanged( const QStringList& theSe
   }
 
   if ( !aCtx.IsNull() ) {
-    foreach ( QString aName, myPolygonName2PrsShape.keys() ) {
+    bool bSelChanged = false;
+    foreach ( QString aName, myPolygonName2PrsShape.keys() ) 
+    {
       Handle(AIS_InteractiveObject) anObject = 
         myPolygonName2PrsShape.value(aName)->getAISObject();
 
       bool isSelected = theSelectedNames.contains( aName );
-      if ( ( isSelected && !aCtx->IsSelected( anObject) ) ||
-           ( !isSelected && aCtx->IsSelected( anObject) ) ) {
+      if ( ( isSelected && !aCtx->IsSelected( anObject) ) || ( !isSelected && aCtx->IsSelected( anObject) ) )
+      {
         aCtx->AddOrRemoveSelected( anObject, Standard_False );
+        bSelChanged = true;
       }
-      /*if (isSelected)
-      {
-        HYDROGUI_Shape* aHydroSh = myPolygonName2PrsShape.value( aName );
-        aHydroSh->setFillingColor(QColor(0,255,255), true, true);
-      }*/
     }
-    aCtx->UpdateCurrentViewer();
+
+    HYDROGUI_ImportLandCoverMapDlg* aPanel = ::qobject_cast<HYDROGUI_ImportLandCoverMapDlg*>( inputPanel() );
+    if ( !aPanel ) 
+      return;
+
+    if (bSelChanged && aPanel->getViewerState())
+      aCtx->UpdateCurrentViewer();
   }
 }
 
 
 void HYDROGUI_ImportLandCoverMapOp::onViewerSelectionChanged()
 {
-  // Get panel
   HYDROGUI_ImportLandCoverMapDlg* aPanel = ::qobject_cast<HYDROGUI_ImportLandCoverMapDlg*>( inputPanel() );
-  if ( !aPanel ) {
+  if ( !aPanel )
+    return;
+
+  int aCurIndex = -1;
+  aCurIndex = aPanel->getCurrentWizardIndex();
+
+  if (aCurIndex != 0)
     return;
-  }
 
   OCCViewer_ViewManager* aViewManager = getPreviewManager();
   Handle(AIS_InteractiveContext) aCtx = NULL;
-  if ( aViewManager ) {
-    if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) {
+  if ( aViewManager )
+    if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() )
       aCtx = aViewer->getAISContext();
-    }
-  }
   
   if ( !aCtx.IsNull() )
   {
     QStringList aSelectedNames;
     foreach ( QString aName, myPolygonName2PrsShape.keys() ) {
       bool isSelected = aCtx->IsSelected( myPolygonName2PrsShape.value(aName)->getAISObject() );
-      if ( isSelected ) {
+      if ( isSelected )
         aSelectedNames << aName;
-      }
     }
+    aPanel->setViewerState(false);
     aPanel->setSelectedPolygonNames( aSelectedNames );
+    aPanel->setViewerState(true);
   }
 }
 
 
 void HYDROGUI_ImportLandCoverMapOp::erasePreview()
 {
-  foreach ( HYDROGUI_Shape* aShape, myPolygonName2PrsShape ) {
+  foreach ( HYDROGUI_Shape* aShape, myPolygonName2PrsShape )
     delete aShape;
-  }
 
   myPolygonName2PrsShape.clear();
 }
@@ -369,22 +375,130 @@ void HYDROGUI_ImportLandCoverMapOp::erasePreview()
 void HYDROGUI_ImportLandCoverMapOp::abortOperation()
 {
   LightApp_Application* anApp = module()->getApp();
-  if ( anApp ) {
+  if ( anApp )
     anApp->disconnect( this );
-  }
 
   erasePreview();
-
+  myImporter.Free();
   HYDROGUI_Operation::abortOperation();
 }
 
-
 void HYDROGUI_ImportLandCoverMapOp::onNext( const int theIndex )
-{
+{  
+  HYDROGUI_ImportLandCoverMapDlg* aPanel = ::qobject_cast<HYDROGUI_ImportLandCoverMapDlg*>( inputPanel() );
+  if ( !aPanel )
+    return;
+
+  if (theIndex == 2)
+  {
+    //std::vector<HYDROData_ShapeFile::DBF_AttrValue> myAttrValue;
+    int anIndOfSelField = myFieldList.indexOf(aPanel->getSelectedFieldName());
+    if (anIndOfSelField == -1)
+      return;
+    //aPanel->setSecondPageState(true);
+    myAttrValue.clear();
+    myImporter.DBF_GetAttributeList(anIndOfSelField, myAttrValue ); 
+
+    mySetOfAttrValues.clear();
+    for (size_t i = 0; i < myAttrValue.size(); i++)
+    {
+      HYDROData_ShapeFile::DBF_AttrValue aV = myAttrValue[i];
+      mySetOfAttrValues << QString(aV.myStrVal);  //take myStrVal for now..
+    }
+
+    //Collect all strickler_types
+    QSet<QString> aSTSet;
+    Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( application()->activeStudy()->id() );
+    Handle(HYDROData_StricklerTable) DefStricklerTableObj;
+    if ( aDoc )
+    {
+      HYDROData_Iterator It( aDoc, KIND_STRICKLER_TABLE );
+      for( ; It.More(); It.Next() )
+      {
+        Handle(HYDROData_StricklerTable) aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( It.Current() );
+        if (DefStricklerTableObj.IsNull())
+          DefStricklerTableObj = aStricklerTableObj;
+        if ( !aStricklerTableObj.IsNull())
+        {
+          const QStringList& aStricklerList = aStricklerTableObj->GetTypes();
+          foreach (QString aStr, aStricklerList)
+            aSTSet << aStr;
+        }
+      }
+    }
+
+    QList<QString> aSetOfAttrValuesList = mySetOfAttrValues.toList();
+    QList<QString> aSTSetList = aSTSet.toList();
+    QVector<QColor> aSTColors;
+    aSTColors.reserve(aSTSetList.size());
+    foreach (QString str, aSTSetList)
+    {
+      QColor col = aDoc->GetAssociatedColor(str, NULL);
+      aSTColors.append (col);
+    }
+
+    //add an empty Strickler type
+    aSTSetList.prepend(""); 
+    aSTColors.prepend(QColor(Qt::gray));
+    
+    QVector<int> aCurCBIndices(aSetOfAttrValuesList.size());
+    if (DefStricklerTableObj->GetAttrName().trimmed() == aPanel->getSelectedFieldName().trimmed())
+      for (int i = 0; i < aSetOfAttrValuesList.size(); i++)
+      {
+        QString aST = DefStricklerTableObj->GetType(aSetOfAttrValuesList[i]);
+        int anIndOfSt = aSTSetList.indexOf(aST);
+        aCurCBIndices[i] = anIndOfSt;
+      }
+    else
+      //TODO add warning ???
+      for (int i = 0; i < aSetOfAttrValuesList.size(); i++)
+        aCurCBIndices[i] = 0;
+
+    aPanel->FillCorrespondenceTable(aSetOfAttrValuesList, aSTSetList, aCurCBIndices, aSTColors);    
+  }
 
 }
 
-void HYDROGUI_ImportLandCoverMapOp::onBack( const int theIndex )
+
+void HYDROGUI_ImportLandCoverMapOp::onApply()
 {
+  HYDROGUI_ImportLandCoverMapDlg* aPanel = ::qobject_cast<HYDROGUI_ImportLandCoverMapDlg*>( inputPanel() );
+  if ( !aPanel )
+    return;
+
+  if (!aPanel->CheckFirstPageFilling())
+    return;
+  
+  QApplication::setOverrideCursor( Qt::WaitCursor );
+  int anUpdateFlags = 0;
+  QString anErrorMsg;
+  QStringList aBrowseObjectsEntries;
+
+  bool aResult = false;
+  try
+  {
+    aResult = processApply( anUpdateFlags, anErrorMsg, aBrowseObjectsEntries );
+  }
+  catch (...)
+  {
+    SUIT_MessageBox::critical( module()->getApp()->desktop(), tr( "LCM_IMPORT_ERROR" ), tr ("CANNT_IMPORT_POLYGONS_FROM_SHP"));
+    aResult = false;
+  }
+  
+  QApplication::restoreOverrideCursor();
 
+  if ( aResult )
+  {
+    module()->update( anUpdateFlags );
+    commit();
+    browseObjects( aBrowseObjectsEntries );
+  }
+  else
+  {
+    Handle(HYDROData_Entity) LCM = Handle(HYDROData_Entity)::DownCast( myLCM );
+    LCM->Remove();
+    module()->setObjectRemoved( myLCM );
+    abort();
+  }
 }
+