]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #728 + minor code revision
authorisn <isn@opencascade.com>
Fri, 20 Nov 2015 08:50:38 +0000 (11:50 +0300)
committerisn <isn@opencascade.com>
Fri, 20 Nov 2015 08:50:38 +0000 (11:50 +0300)
src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.cxx
src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.h
src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.cxx
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 73ec62d09b77e16247f9eb42b095dd8d78fbbfbf..f075284df30f018df491b770965bc76db2d1f07f 100644 (file)
@@ -198,7 +198,7 @@ void HYDROGUI_ImportLandCoverMapDlg::setSelectedPolygonNames( const QStringList&
 
 void HYDROGUI_ImportLandCoverMapDlg::onItemSelectionChanged()
 { 
-  int aCurIndex = GetCurrentWizardIndex();
+  int aCurIndex = getCurrentWizardIndex();
   if (aCurIndex == 0 && getViewerState())
     emit selectionChanged( getSelectedPolygonNames() );
 }
@@ -310,43 +310,37 @@ void HYDROGUI_ImportLandCoverMapDlg::setFirstPageState(bool theState)
   myFirstPageState = theState;
 }
 
+bool HYDROGUI_ImportLandCoverMapDlg::getFirstPageState() const
+{
+  return myFirstPageState;
+}
+
+
 bool HYDROGUI_ImportLandCoverMapDlg::acceptCurrent() const
 {
   //Check the state of the current page
-  int aCurrPage = GetCurrentWizardIndex();
+  int aCurrPage = getCurrentWizardIndex();
   switch ( aCurrPage )
   {
     case 0:
     {
-      if (!myFirstPageState)
-      {
-        SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), tr("FILE_ISNT_CHOSEN"));
+      //this method verifies first page
+      if (!CheckFirstPageFilling())
         return false;
-      }
-      if (myPolygonsListWidget->selectedItems().empty())
-      {
-        SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), tr("POLYGONS_ISNT_SELECTED"));
-        return false;
-      }
-      if (getAttrCheckBoxState() && !getDbfState())
-      {
-         SUIT_MessageBox::critical( module()->getApp()->desktop(), tr( "DBF_LOAD_ERROR" ), tr("DBF_LOAD_ERR_MESS"));
-         return false;
-      }
       break;
     }
     case 1:
     {
       if (myDBFAttrListWidget->selectedItems().empty())
       {
-        SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), "Attribute isn't selected");
+        SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), tr ("ATTRS_ISNT_SELECTED"));
         return false;
       }
       break;
     }
     case 2: //last page
     {
-      if (myPolygonsListWidget->selectedItems().empty())
+      if (this->isPolygonListEmpty())
       {
         SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), tr("POLYGONS_ISNT_SELECTED"));
         return false;
@@ -419,7 +413,7 @@ bool HYDROGUI_ImportLandCoverMapDlg::getDbfState() const
   return myDbfState;
 }
 
-int HYDROGUI_ImportLandCoverMapDlg::GetCurrentWizardIndex() const
+int HYDROGUI_ImportLandCoverMapDlg::getCurrentWizardIndex() const
 {
   return wizard()->currentIndex();
 }
@@ -432,4 +426,29 @@ void HYDROGUI_ImportLandCoverMapDlg::setViewerState(bool theState)
 bool HYDROGUI_ImportLandCoverMapDlg::getViewerState() const
 {
   return myUpdateViewerState;
+}
+
+bool HYDROGUI_ImportLandCoverMapDlg::isPolygonListEmpty() const
+{
+  return myPolygonsListWidget->selectedItems().empty();
+}
+
+bool HYDROGUI_ImportLandCoverMapDlg::CheckFirstPageFilling() const
+{
+  if (!this->getFirstPageState())
+  {
+    SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), tr("FILE_ISNT_CHOSEN"));
+    return false;
+  }
+  if (this->isPolygonListEmpty())
+  {
+    SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), tr("POLYGONS_ISNT_SELECTED"));
+    return false;
+  }
+  if (this->getAttrCheckBoxState() && !this->getDbfState())
+  {
+     SUIT_MessageBox::critical( module()->getApp()->desktop(), tr( "DBF_LOAD_ERROR" ), tr("DBF_LOAD_ERR_MESS"));
+     return false;
+  }
+  return true;
 }
\ No newline at end of file
index e3c05903c96ed0efa14ba23efe1475793677594d..524f41a65455208e03e61538ae0cf007993059e3 100644 (file)
@@ -56,13 +56,17 @@ public:
   QString               getFileName() const;
 
   void                  setFirstPageState(bool theState);
+  bool                  getFirstPageState() const;
   bool                  getAttrCheckBoxState() const;
   void                  getValAttr2StricklerTypeCorr(QStringList& theAttrValues, QStringList& theST);
   QVector<int>          getSelectedPolygonIndices() const;
+  bool                  isPolygonListEmpty() const;
+
+  bool                  CheckFirstPageFilling() const;
 
   void                  setDbfState(bool theState);
   bool                  getDbfState() const;
-  int                   GetCurrentWizardIndex() const;
+  int                   getCurrentWizardIndex() const;
 
   void                  setViewerState(bool theState);
   bool                  getViewerState() const;
index 403a22634b0a72b8ccb03b995849078091a385cf..f40b69a2383616c688aa9d23ed81637d51706af6 100644 (file)
@@ -337,18 +337,16 @@ void HYDROGUI_ImportLandCoverMapOp::onViewerSelectionChanged()
     return;
 
   int aCurIndex = -1;
-  aCurIndex = aPanel->GetCurrentWizardIndex();
+  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() )
   {
@@ -464,6 +462,13 @@ void HYDROGUI_ImportLandCoverMapOp::onNext( 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;
index 31619c9c843ad5555fe9eca3021d391c095f8914..a353368758d9f7c2a61c80173a55b54c76246c38 100644 (file)
@@ -2379,7 +2379,12 @@ file cannot be correctly imported for an Obstacle definition.</translation>
       <source>POLYGONS_ISNT_SELECTED</source>
       <translation>Polygons isn't selected</translation>
     </message>
-    <message>
+   <message>
+      <source>ATTRS_ISNT_SELECTED</source>
+      <translation>Attribute isn't selected</translation>
+    </message>
+   <message>
       <source>DBF_LOAD_ERR_MESS</source>
       <translation>Cant open DBF file or it's corrupted</translation>
     </message>
@@ -2400,7 +2405,10 @@ file cannot be correctly imported for an Obstacle definition.</translation>
       <source>DEF_POLYGON_NAME</source>
       <translation>polygon</translation>
     </message>
-
+    <message>
+      <source>LCM_IMPORT_WARNING</source>
+      <translation>Import of Land cover map</translation>
+    </message>
     <message>
       <source>CANNT_IMPORT_LCM</source>
       <translation>Cannot import land cover map;</translation>