Salome HOME
Merge remote-tracking branch 'origin/BR_LAND_COVER' into BR_v14_rc
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_CalculationDlg.cxx
index 889e811462ce568708534b5a5a5693d765d837f1..9e97678e013444cdf67e1a623779faa183daf595 100644 (file)
@@ -30,6 +30,7 @@
 #include "HYDROGUI_Zone.h"
 #include "HYDROGUI_OrderedListWidget.h"
 #include "HYDROGUI_PriorityWidget.h"
+#include "HYDROGUI_PriorityTableModel.h"
 
 #include <HYDROData_Document.h>
 #include <HYDROData_Entity.h>
@@ -95,8 +96,9 @@ void HYDROGUI_CalculationDlg::reset()
   setLandCoverMode( HYDROData_CalculationCase::AUTOMATIC );
 
   // Reset the priority widget state
-  QList<Handle(HYDROData_Object)> anObjects;
+  QList<Handle(HYDROData_Entity)> anObjects;
   myPriorityWidget->setObjects( anObjects );
+  myLandCoverPriorityWidget->setObjects( anObjects );
 }
 
 QWizardPage* HYDROGUI_CalculationDlg::createObjectsPage() {
@@ -405,6 +407,10 @@ QWizardPage* HYDROGUI_CalculationDlg::createLandCoversPage() {
 
   // Bottom of the page
   myLandCoverPriorityWidget = new HYDROGUI_PriorityWidget( mainFrame() );
+  HYDROGUI_PriorityTableModel* aModel = 
+    dynamic_cast<HYDROGUI_PriorityTableModel*>( myLandCoverPriorityWidget->getTable()->model() );
+  if ( aModel )
+    aModel->setColumnCount( 3 );
 
   QGroupBox* aPriorityGroup = new QGroupBox( tr( "PRIORITY" ) );
   QBoxLayout* aPriorityLayout = new QHBoxLayout;
@@ -935,10 +941,10 @@ void HYDROGUI_CalculationDlg::setEditLandCoversEnabled( const bool theIsEnabled
   Get included geometry objects.
   @return the list of geometry objects
  */
-QList<Handle(HYDROData_Object)> HYDROGUI_CalculationDlg::getGeometryObjects()
+QList<Handle(HYDROData_Entity)> HYDROGUI_CalculationDlg::getGeometryObjects()
 {
   QList<Handle(HYDROData_Entity)> anEntities = myGeomObjects->getObjects();
-  QList<Handle(HYDROData_Object)> anObjects;
+  QList<Handle(HYDROData_Entity)> anObjects;
 
   foreach ( Handle(HYDROData_Entity) anEntity, anEntities ) {
     Handle(HYDROData_Object) anObj = Handle(HYDROData_Object)::DownCast( anEntity );
@@ -956,10 +962,10 @@ QList<Handle(HYDROData_Object)> HYDROGUI_CalculationDlg::getGeometryObjects()
   Get included land covers.
   @return the list of land covers
  */
-QList<Handle(HYDROData_LandCover)> HYDROGUI_CalculationDlg::getLandCovers()
+QList<Handle(HYDROData_Entity)> HYDROGUI_CalculationDlg::getLandCovers()
 {
   QList<Handle(HYDROData_Entity)> anEntities = myLandCovers->getObjects();
-  QList<Handle(HYDROData_LandCover)> aLandCovers;
+  QList<Handle(HYDROData_Entity)> aLandCovers;
 
   foreach ( Handle(HYDROData_Entity) anEntity, anEntities ) {
     Handle(HYDROData_LandCover) aLandCover = Handle(HYDROData_LandCover)::DownCast( anEntity );
@@ -991,6 +997,24 @@ void  HYDROGUI_CalculationDlg::setRules( const HYDROData_ListOfRules& theRules )
   myPriorityWidget->setRules( theRules );
 }
 
+/**
+  Get rules defined for land covers.
+  @return the list of rules
+ */
+HYDROData_ListOfRules HYDROGUI_CalculationDlg::getLandCoverRules() const
+{
+  return myLandCoverPriorityWidget->getRules();
+}
+
+/**
+  Set rules for land covers.
+  @param theRules the list of rules
+ */
+void  HYDROGUI_CalculationDlg::setLandCoverRules( const HYDROData_ListOfRules& theRules ) const
+{
+  myLandCoverPriorityWidget->setRules( theRules );
+}
+
 /**
   Slot called when objects order is changed.
  */
@@ -1004,15 +1028,28 @@ void HYDROGUI_CalculationDlg::onOrderChanged()
     myGeomObjects->undoLastMove();
 }
 
-void HYDROGUI_CalculationDlg::setStricklerTable( const QString& theStricklerTableName )
+void HYDROGUI_CalculationDlg::setStricklerTable( const QString& theStricklerTableName, bool theBlockSignals )
 {
-  bool isBlocked = myStricklerTableName->blockSignals( true );
+  bool isBlocked;
+  if ( theBlockSignals )
+    isBlocked = myStricklerTableName->blockSignals( true );
+  
   myStricklerTableName->setCurrentIndex( myStricklerTableName->findText( theStricklerTableName ) );
-  myStricklerTableName->blockSignals( isBlocked );
+
+  if ( theBlockSignals )
+    myStricklerTableName->blockSignals( isBlocked );
+  else
+    emit StricklerTableSelected( theStricklerTableName );
 }
 
-void HYDROGUI_CalculationDlg::includeLandCovers( const QStringList& theLandCovers )
+void HYDROGUI_CalculationDlg::includeLandCovers( const QStringList& theLandCovers, bool theReset )
 {
+  if ( theReset )
+  {
+    HYDROGUI_ListModel::Object2VisibleList anObject2VisibleList;
+    myLandCovers->setObjects(anObject2VisibleList);
+  }
+        
   HYDROGUI_ListModel::Object2VisibleList anObjectsToInclude;
   QList<QListWidgetItem*> aFoundItems;
   foreach ( const QString& anObjName, theLandCovers ) {
@@ -1028,8 +1065,7 @@ void HYDROGUI_CalculationDlg::includeLandCovers( const QStringList& theLandCover
     myLandCovers->addObject( HYDROGUI_ListModel::Object2Visible( anObject, true ) );
   }
 
-  // TODO: adapt HYDROGUI_PriorityWidget to process land covers
-  //myLandCoverPriorityWidget->setObjects( getLandCovers() );
+  myLandCoverPriorityWidget->setObjects( getLandCovers() );
 }
 
 void HYDROGUI_CalculationDlg::excludeLandCovers( const QStringList& theLandCovers )
@@ -1046,8 +1082,7 @@ void HYDROGUI_CalculationDlg::excludeLandCovers( const QStringList& theLandCover
     myLandCovers->removeObjectByName( anObjName );
   }
 
-  // TODO: adapt HYDROGUI_PriorityWidget to process land covers
-  //myLandCoverPriorityWidget->setObjects( getLandCovers() );
+  myLandCoverPriorityWidget->setObjects( getLandCovers() );
 }
 
 /**
@@ -1057,9 +1092,8 @@ void HYDROGUI_CalculationDlg::onOrderLandCoverChanged()
 {
   bool isConfirmed = true;
   emit orderLandCoverChanged( isConfirmed );
-  // TODO: adapt HYDROGUI_PriorityWidget to process land covers
-  /*if( isConfirmed )
+  if( isConfirmed )
     myLandCoverPriorityWidget->setObjects( getLandCovers() );
-  else*/
+  else
     myLandCovers->undoLastMove();  
 }