]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
many corrections
authorisn <isn@opencascade.com>
Wed, 24 Jun 2015 12:05:39 +0000 (15:05 +0300)
committerisn <isn@opencascade.com>
Wed, 24 Jun 2015 13:21:19 +0000 (16:21 +0300)
ShapeFix on landcover-faces disabled (temporary)

src/HYDROGUI/HYDROGUI_ImportLandCoverDlg.cxx
src/HYDROGUI/HYDROGUI_ImportLandcoverOp.cxx
src/HYDROGUI/HYDROGUI_ImportLandcoverOp.h

index ed68774ed4a5cf2a5b257cec994f8fb3b90f229a..213f8c751de0cbb16f639b07b26725b7b07d9e9c 100644 (file)
@@ -53,14 +53,14 @@ HYDROGUI_ImportLandCoverDlg::HYDROGUI_ImportLandCoverDlg( HYDROGUI_Module* theMo
 
   myObjectNameGroup = new QGroupBox( tr( "FILE_NAME" ) );
 
-  QLabel* aBathymetryNameLabel = new QLabel( tr( "NAME" ), myObjectNameGroup );
+  QLabel* aLandcoverNameLabel = new QLabel( tr( "NAME" ), myObjectNameGroup );
   myObjectName = new QLineEdit( myObjectNameGroup );
 
-  QBoxLayout* aBathymetryNameLayout = new QHBoxLayout( myObjectNameGroup );
-  aBathymetryNameLayout->setMargin( 5 );
-  aBathymetryNameLayout->setSpacing( 5 );
-  aBathymetryNameLayout->addWidget( aBathymetryNameLabel );
-  aBathymetryNameLayout->addWidget( myObjectName );
+  QBoxLayout* aLandcoverNameLayout = new QHBoxLayout( myObjectNameGroup );
+  aLandcoverNameLayout->setMargin( 5 );
+  aLandcoverNameLayout->setSpacing( 5 );
+  aLandcoverNameLayout->addWidget( aLandcoverNameLabel );
+  aLandcoverNameLayout->addWidget( myObjectName );
 
   QGroupBox* aPolygonsGroup = new QGroupBox( tr( "FOUND_POLYGONS_OF_SHP_FILE" ), mainFrame() );
   myPolygons = new QListWidget( aPolygonsGroup );
index c67bd1adcd1037684fd5202567989c97470e7dc9..bad1844c170260e63ed3e3c37050776c59ead81e 100644 (file)
@@ -32,7 +32,6 @@
 #include <HYDROGUI_ZLayers.h>
 
 #include <HYDROGUI_DataObject.h>
-#include <HYDROData_Bathymetry.h>
 #include <HYDROData_Iterator.h>
 
 #include <HYDROData_Profile.h>
@@ -79,7 +78,7 @@ HYDROGUI_ImportLandCoverOp::HYDROGUI_ImportLandCoverOp( HYDROGUI_Module* theModu
 
 HYDROGUI_ImportLandCoverOp::~HYDROGUI_ImportLandCoverOp()
 {
-
+  erasePreview();
 }
 
 void HYDROGUI_ImportLandCoverOp::startOperation()
@@ -99,12 +98,14 @@ HYDROGUI_InputPanel* HYDROGUI_ImportLandCoverOp::createInputPanel() const
   return aPanel;
 }
 
-void HYDROGUI_ImportLandCoverOp::onApply()
+bool HYDROGUI_ImportLandCoverOp::processApply( int& theUpdateFlags,
+                                                QString& theErrorMsg,
+                                                QStringList& theBrowseObjectsEntries )
 {
 
   HYDROGUI_ImportLandCoverDlg* aPanel = ::qobject_cast<HYDROGUI_ImportLandCoverDlg*>( inputPanel() );
   if ( !aPanel ) {
-    return;
+    return false;
   }
   
   QStringList aSelectedtPolygons = aPanel->getSelectedPolygonNames();
@@ -142,7 +143,11 @@ void HYDROGUI_ImportLandCoverOp::onApply()
     }
     if( !aLC.IsNull() ) 
     {
-      aLC->SetName( aPanel->getFileName() + "_polygon_" );
+      QString aLCName = aPanel->getObjectName() + "_polygon";
+      int i = 0;
+      for( ;HYDROGUI_Tool::FindObjectByName(module(), aLCName); i++)
+        aLCName = aPanel->getObjectName() + "_polygon_" + QString::number(i);
+      aLC->SetName( aLCName );
       aLC->SetFillingColor( HYDROData_LandCover::DefaultFillingColor() );
       aLC->SetBorderColor( HYDROData_LandCover::DefaultBorderColor() );
       
@@ -157,10 +162,12 @@ void HYDROGUI_ImportLandCoverOp::onApply()
   }
  
   module()->update( UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init );
-  
-  QApplication::restoreOverrideCursor();
-}
 
+  if ( isApplyAndClose() )
+    erasePreview();
+
+  return true;
+}
 
 
 void HYDROGUI_ImportLandCoverOp::Parse(SHPHandle theHandle)
@@ -183,9 +190,9 @@ void HYDROGUI_ImportLandCoverOp::ProcessSHP(SHPObject* anObj, int i, TopoDS_Face
   gp_Pln pln(gp_Pnt(0,0,0), gp_Dir(0,0,1));
   BRepBuilderAPI_MakeFace aFBuilder(pln);
 
-  Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
-  sfs->FixFaceTool()->FixOrientationMode() = 1;
+  //Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
+  //sfs->FixFaceTool()->FixOrientationMode() = 1;
+  
   for ( int i = 0 ; i < nParts ; i++ )
   { 
     BRepBuilderAPI_MakeWire aBuilder;
@@ -215,9 +222,9 @@ void HYDROGUI_ImportLandCoverOp::ProcessSHP(SHPObject* anObj, int i, TopoDS_Face
   BRepLib::BuildCurves3d(DF);
   if(!DF.IsNull()) 
   {
-    sfs->Init ( DF );
-    sfs->Perform();
-    F = TopoDS::Face(sfs->Shape());
+    //sfs->Init ( DF );
+    //sfs->Perform();
+    F = DF; //TopoDS::Face(sfs->Shape());
   }
 }
 
@@ -226,19 +233,17 @@ void HYDROGUI_ImportLandCoverOp::onFileSelected()
   HYDROGUI_ImportLandCoverDlg* aPanel = ::qobject_cast<HYDROGUI_ImportLandCoverDlg*>( inputPanel() );
   if ( !aPanel )
     return;
-
+  
   QString anObjectName = aPanel->getObjectName().simplified();
-   anObjectName = aPanel->getFileName();
-   if ( !anObjectName.isEmpty() ) {
-       anObjectName = QFileInfo( anObjectName ).baseName();
-   }
+  anObjectName = aPanel->getFileName();
+  if ( !anObjectName.isEmpty() ) 
+      anObjectName = QFileInfo( anObjectName ).baseName();
 
-   if ( anObjectName.isEmpty() ) {
-     anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_BATHYMETRY_NAME" ) );
-   }
-   aPanel->setObjectName( anObjectName );
+  if ( anObjectName.isEmpty() ) 
+    anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_LANDCOVER_NAME" ) );
+  aPanel->setObjectName( anObjectName );
 
-   QString aFileName = aPanel->getFileName();
+  QString aFileName = aPanel->getFileName();
   if ( aFileName.isEmpty() )
   {
     abort();
@@ -252,7 +257,7 @@ void HYDROGUI_ImportLandCoverOp::onFileSelected()
     SHPHandle aHSHP;
     aHSHP = SHPOpen( aFileName.toAscii().data(), "rb" );
     Parse(aHSHP);
-  
+    
     startDocOperation();
     QStringList aPolygonsList;
     for (int i = 1; i < mySHPObjects.size(); i++)
@@ -282,18 +287,21 @@ void HYDROGUI_ImportLandCoverOp::onFileSelected()
       }
     }
 
+    QApplication::setOverrideCursor(Qt::WaitCursor);
+
     TopTools_SequenceOfShape aFaces;
     TopoDS_Face aF;
     if (aHSHP->nShapeType == 5)
     {
-      for (int i = 1; i < 4 /*mySHPObjects.size()*/; i++) {   ///TODO temp
+      for (int i = 0; i < mySHPObjects.size(); i++) 
+      {
          ProcessSHP(mySHPObjects[i], i, aF);
          aFaces.Append(aF);
       }
     }
     else
       SUIT_MessageBox::warning( module()->getApp()->desktop(), "Import Land cover", "Cannot land cover;\nThe shape type is not polygon" );
-    
+    QApplication::restoreOverrideCursor();
 
     Handle(HYDROData_LandCover) aLC = Handle(HYDROData_LandCover)::DownCast( doc()->CreateObject( KIND_LAND_COVER ) );
     for ( int i = 1; i <= aFaces.Length(); i++ ) 
@@ -311,9 +319,7 @@ void HYDROGUI_ImportLandCoverOp::onFileSelected()
         if( !aFace.IsNull() )
           aShape->setShape( aLC->GetShape() );
         myPolygonName2PrsShape.insert( "polygon_" + QString::number(i), aShape);
-
       }
-
     }
     aLC->Remove();
 
@@ -376,16 +382,15 @@ void HYDROGUI_ImportLandCoverOp::onViewerSelectionChanged()
     }
   }
   
-  if ( !aCtx.IsNull() ) {
+  if ( !aCtx.IsNull() )
+  {
     QStringList aSelectedNames;
-
     foreach ( QString aName, myPolygonName2PrsShape.keys() ) {
       bool isSelected = aCtx->IsSelected( myPolygonName2PrsShape.value(aName)->getAISObject() );
       if ( isSelected ) {
         aSelectedNames << aName;
       }
     }
-
     aPanel->setSelectedPolygonNames( aSelectedNames );
   }
 }
index 181948a910ea82b4fd65e8f60d3d392242cd75f9..35c8ef8405df287f840ac8133cef010b11e45473 100644 (file)
@@ -48,7 +48,7 @@ protected:
   virtual void startOperation();
   virtual void abortOperation();
 
-  virtual void onApply();
+  virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, QStringList& theBrowseObjectsEntries );
   HYDROGUI_InputPanel* createInputPanel() const;
   void Parse(SHPHandle theHandle);
   void ProcessSHP(SHPObject* anObj, int i, TopoDS_Face& F);