]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Import/Export >> some minor corrections
authorisn <isn@opencascade.com>
Thu, 25 Jun 2015 13:45:46 +0000 (16:45 +0300)
committerisn <isn@opencascade.com>
Thu, 25 Jun 2015 13:45:46 +0000 (16:45 +0300)
src/HYDROGUI/HYDROGUI_ExportFileOp.cxx
src/HYDROGUI/HYDROGUI_ImportLandcoverOp.cxx
src/HYDROGUI/HYDROGUI_ImportPolylineOp.cxx

index 17d24d16cff9e6e7352c55133dfa06cf9b7876db..b52e18b030b71a5ed8ee813e60beab4de588545e 100644 (file)
@@ -64,7 +64,7 @@ void HYDROGUI_ExportFileOp::startOperation()
 {
   HYDROGUI_Operation::startOperation();
   
-  QString aFilter( tr("SHP_FILTER") ); //temp  ext-n; replace with filter; TODO
+  QString aFilter( tr("SHP_FILTER") ); 
   
   Handle(HYDROData_PolylineXY) aPolyXY;
   Handle(HYDROData_Polyline3D) aPoly3D;
@@ -93,7 +93,12 @@ void HYDROGUI_ExportFileOp::startOperation()
     SUIT_MessageBox::warning( module()->getApp()->desktop(), "Export Polyline", "Cannot export polylines of different kind");
   else
   {
-    QString aFileName = SUIT_FileDlg::getFileName( module()->getApp()->desktop(), "", aFilter, tr( "EXPORT_TO_SHAPE_FILE" ), false );
+    QString aPolyName = "";
+    if (aPolyXYSeq.Size() == 1 && aPoly3DSeq.IsEmpty())
+      aPolyName = aPolyXYSeq(1)->GetName();
+    if (aPoly3DSeq.Size() == 1 && aPolyXYSeq.IsEmpty())
+      aPolyName = aPoly3DSeq(1)->GetName();
+    QString aFileName = SUIT_FileDlg::getFileName( module()->getApp()->desktop(), aPolyName, aFilter, tr( "EXPORT_TO_SHAPE_FILE" ), false );
     if (!aFileName.isEmpty())
     {
       SHPHandle hSHPHandle;
index 5151349cb6d608d0cdc1fbd428b8f9154069add2..e706338369a359f30ec3216061c8e4f45eec51cf 100644 (file)
@@ -320,7 +320,7 @@ void HYDROGUI_ImportLandCoverOp::onFileSelected()
       }
     }
     else
-      SUIT_MessageBox::warning( module()->getApp()->desktop(), "Import Land cover", "Cannot land cover;\nThe shape type is not polygon" );
+      SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "IMPORT_LANDCOVER" ), "Cannot import land cover;\nThe shape type is not polygon" );
     QApplication::restoreOverrideCursor();
 
     Handle(HYDROData_LandCover) aLC = Handle(HYDROData_LandCover)::DownCast( doc()->CreateObject( KIND_LAND_COVER ) );
index 1d02a454ce772bb972d0064c67b08a427a622b9d..a3c7f833205e32a8f7d36fafb8656da35172235a 100644 (file)
@@ -41,7 +41,7 @@
 #include <QApplication>
 #include <QFile>
 #include <QFileInfo>
-#include <QMessageBox>
+#include <SUIT_MessageBox.h>
 
 
 HYDROGUI_ImportPolylineOp::HYDROGUI_ImportPolylineOp( HYDROGUI_Module* theModule )
@@ -77,82 +77,91 @@ void HYDROGUI_ImportPolylineOp::onApply()
     return;
   }
 
-  QString aFileName = myFileDlg->selectedFile();
-  if ( aFileName.isEmpty() )
+  QStringList aFileNames = myFileDlg->selectedFiles();
+  
+  QApplication::setOverrideCursor( Qt::WaitCursor );  
+  startDocOperation();
+
+  foreach (QString aFileName, aFileNames) 
   {
-    abort();
-    return;
-  }
+    if ( aFileName.isEmpty() )
+      continue;
 
-  QString anExt = aFileName.split('.', QString::SkipEmptyParts).back();
+    QString anExt = aFileName.split('.', QString::SkipEmptyParts).back();
 
-  if (anExt == "shp")
-  {
-    SHPHandle aHSHP;
-    aHSHP = SHPOpen( aFileName.toAscii().data(), "rb" );
-    Parse(aHSHP);
-    
-    QApplication::setOverrideCursor( Qt::WaitCursor );
-    
-    startDocOperation();
+    if (anExt == "shp")
+    {
+      SHPHandle aHSHP;
+      aHSHP = SHPOpen( aFileName.toAscii().data(), "rb" );
+      Parse(aHSHP);
 
-    HYDROData_Iterator anIter( doc() );
-    int anInd = 0;
-    QStringList anExistingNames;
-    std::vector<int> anAllowedIndexes;
-    for( ; anIter.More(); anIter.Next() )
-      anExistingNames.push_back(anIter.Current()->GetName());
+      HYDROData_Iterator anIter( doc() );
+      int anInd = 0;
+      QStringList anExistingNames;
+      std::vector<int> anAllowedIndexes;
+      for( ; anIter.More(); anIter.Next() )
+        anExistingNames.push_back(anIter.Current()->GetName());
 
-    QFileInfo aFileInfo(aFileName);
-    QString aBaseFileName = aFileInfo.baseName();
+      QFileInfo aFileInfo(aFileName);
+      QString aBaseFileName = aFileInfo.baseName();
 
-    if (aHSHP->nShapeType == 3 || aHSHP->nShapeType == 23)
-    {
-      anInd = 0;
-      for (;anAllowedIndexes.size() < mySHPObjects.size();)
+      if (aHSHP->nShapeType == 3 || aHSHP->nShapeType == 23)
       {
-        if (!anExistingNames.contains(aBaseFileName + "_PolyXY_" + QString::number(anInd)))
+        anInd = 0;
+        for (;anAllowedIndexes.size() < mySHPObjects.size();)
         {
-          anAllowedIndexes.push_back(anInd);
-          anInd++;
+          if (!anExistingNames.contains(aBaseFileName + "_PolyXY_" + QString::number(anInd)))
+          {
+            anAllowedIndexes.push_back(anInd);
+            anInd++;
+          }
+          else
+            anInd++;
+        }
+        
+        for (size_t i = 0; i < mySHPObjects.size(); i++ )
+        {
+          ProcessSHPPolyXY(mySHPObjects[i], aBaseFileName, anAllowedIndexes[i]);
         }
-        else
-          anInd++;
-      }
-      
-      for (size_t i = 0; i < mySHPObjects.size(); i++ )
-      {
-        ProcessSHPPolyXY(mySHPObjects[i], aBaseFileName, anAllowedIndexes[i]);
       }
-    }
-    else if (aHSHP->nShapeType == 13)
-    {
-      anInd = 0;
-      for (;anAllowedIndexes.size() < mySHPObjects.size();)
+      else if (aHSHP->nShapeType == 13)
       {
-        if (!anExistingNames.contains(aBaseFileName + "_PolyXY_" + QString::number(anInd)) &&
-            !anExistingNames.contains(aBaseFileName + "_Poly3D_" + QString::number(anInd)) &&
-            !anExistingNames.contains(aBaseFileName + "_Bath_" + QString::number(anInd)))
+        anInd = 0;
+        for (;anAllowedIndexes.size() < mySHPObjects.size();)
         {
-          anAllowedIndexes.push_back(anInd);
-          anInd++;
+          if (!anExistingNames.contains(aBaseFileName + "_PolyXY_" + QString::number(anInd)) &&
+              !anExistingNames.contains(aBaseFileName + "_Poly3D_" + QString::number(anInd)) &&
+              !anExistingNames.contains(aBaseFileName + "_Bath_" + QString::number(anInd)))
+          {
+            anAllowedIndexes.push_back(anInd);
+            anInd++;
+          }
+          else
+            anInd++;
         }
-        else
-          anInd++;
+        for (size_t i = 0; i < mySHPObjects.size(); i++ )
+          ProcessSHPPoly3D(mySHPObjects[i], aBaseFileName, anAllowedIndexes[i]);
       }
+      else  
+      {
+        SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "IMPORT_POLYLINE" ), "Cannot import polyline;\nThe shape type is incorrect" );
+      }
+    
       for (size_t i = 0; i < mySHPObjects.size(); i++ )
-        ProcessSHPPoly3D(mySHPObjects[i], aBaseFileName, anAllowedIndexes[i]);
+        free (mySHPObjects[i]);
+
+      mySHPObjects.clear();
+      SHPClose(aHSHP);
     }
+  }
+  if (!aFileNames.empty())
+  {
     commitDocOperation();
     commit();
-    
-    for (size_t i = 0; i < mySHPObjects.size(); i++ )
-      free (mySHPObjects[i]);
-
-    mySHPObjects.clear();
-    SHPClose(aHSHP);
+    module()->update( UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init );
   }
-  module()->update( UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init );
+  else
+    abort();
   
   QApplication::restoreOverrideCursor();
 }