]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #573, #574: drafts of Land Cover and Land Covers Partition panels; Strickler...
authormkr <mkr@opencascade.com>
Tue, 9 Jun 2015 13:31:45 +0000 (16:31 +0300)
committermkr <mkr@opencascade.com>
Tue, 9 Jun 2015 13:31:45 +0000 (16:31 +0300)
src/HYDROData/HYDROData_CalculationCase.cxx
src/HYDROData/HYDROData_CalculationCase.h
src/HYDROGUI/HYDROGUI_CalculationDlg.cxx
src/HYDROGUI/HYDROGUI_CalculationDlg.h
src/HYDROGUI/HYDROGUI_CalculationOp.cxx
src/HYDROGUI/HYDROGUI_CalculationOp.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index ec18b345c6c57d472b2b97551fca68849579cedf..8ef1bd1b1173c8e30e6c207fa20053c5770d1c3f 100644 (file)
@@ -25,6 +25,8 @@
 #include "HYDROData_Iterator.h"
 #include "HYDROData_NaturalObject.h"
 #include "HYDROData_PolylineXY.h"
+#include "HYDROData_StricklerTable.h"
+#include "HYDROData_LandCover.h"
 #include "HYDROData_SplittedShapesGroup.h"
 #include "HYDROData_Region.h"
 #include "HYDROData_Tool.h"
@@ -560,6 +562,69 @@ void HYDROData_CalculationCase::RemoveBoundaryPolyline()
   SetToUpdate( !aPrevPolyline.IsNull() || IsMustBeUpdated() );
 }
 
+void HYDROData_CalculationCase::SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable )
+{
+  Handle(HYDROData_StricklerTable) aPrevStricklerTable = GetStricklerTable();
+
+  SetReferenceObject( theStricklerTable, DataTag_StricklerTable );
+
+  // Indicate model of the need to update land covers partition
+  SetToUpdate( !IsEqual( aPrevStricklerTable, theStricklerTable ) || IsMustBeUpdated() );
+}
+
+Handle(HYDROData_StricklerTable) HYDROData_CalculationCase::GetStricklerTable() const
+{
+  return Handle(HYDROData_StricklerTable)::DownCast( 
+           GetReferenceObject( DataTag_StricklerTable ) );
+}
+
+void HYDROData_CalculationCase::RemoveStricklerTable()
+{
+  Handle(HYDROData_StricklerTable) aPrevStricklerTable = GetStricklerTable();
+
+  ClearReferenceObjects( DataTag_StricklerTable );
+
+  // Indicate model of the need to update land covers partition
+  SetToUpdate( !aPrevStricklerTable.IsNull() || IsMustBeUpdated() );
+}
+
+bool HYDROData_CalculationCase::AddLandCover( const Handle(HYDROData_LandCover)& theLandCover )
+{
+  if ( HasReference( theLandCover, DataTag_LandCover ) )
+    return false; // Land cover is already in reference list
+
+  AddReferenceObject( theLandCover, DataTag_LandCover );
+  
+  // Indicate model of the need to update land covers partition
+  SetToUpdate( true );
+
+  return true;
+}
+
+HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetLandCovers() const
+{
+  return GetReferenceObjects( DataTag_LandCover );
+}
+
+void HYDROData_CalculationCase::RemoveLandCover( const Handle(HYDROData_LandCover)& theLandCover )
+{
+  if ( theLandCover.IsNull() )
+    return;
+
+  RemoveReferenceObject( theLandCover->Label(), DataTag_LandCover );
+
+  // Indicate model of the need to update land cover partition
+  SetToUpdate( true );
+}
+
+void HYDROData_CalculationCase::RemoveLandCovers()
+{
+  ClearReferenceObjects( DataTag_LandCover );
+
+  // Indicate model of the need to update land cover partition
+  SetToUpdate( true );
+}
+
 Handle(HYDROData_Region) HYDROData_CalculationCase::AddNewRegion( const Handle(HYDROData_Zone)& theZone )
 {
   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
@@ -1248,3 +1313,60 @@ bool HYDROData_CalculationCase::GetRule( int theIndex,
   return HYDROData_PriorityQueue::GetRule( aRulesLab, theIndex,
     theObject1, thePriority, theObject2, theMergeType );
 }
+
+void HYDROData_CalculationCase::SetAssignmentLandCoverMode( AssignmentMode theMode )
+{
+  TDF_Label aModeLab = myLab.FindChild( DataTag_AssignmentLandCoverMode );
+  TDataStd_Integer::Set( aModeLab, ( int ) theMode );
+
+  // Indicate model of the need to update land covers partition
+  SetToUpdate( true );
+}
+
+HYDROData_CalculationCase::AssignmentMode HYDROData_CalculationCase::GetAssignmentLandCoverMode() const
+{
+  Handle(TDataStd_Integer) aModeAttr;
+  bool isOK = myLab.FindChild( DataTag_AssignmentLandCoverMode ).FindAttribute( TDataStd_Integer::GetID(), aModeAttr );
+  if( isOK )
+    return ( AssignmentMode ) aModeAttr->Get();
+  else
+    return MANUAL;
+}
+
+void HYDROData_CalculationCase::ClearLandCoverRules( const bool theIsSetToUpdate )
+{
+  TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomLandCoverRules );
+  // TODO: adapt HYDROData_PriorityQueue to use with land covers
+  //HYDROData_PriorityQueue::ClearRules( aRulesLab );
+
+  // Indicate model of the need to update land covers partition
+  if ( theIsSetToUpdate ) {
+    SetToUpdate( true );
+  }
+}
+
+void HYDROData_CalculationCase::AddLandCoverRule( const Handle(HYDROData_LandCover)& theLandCover1,
+                                                  HYDROData_PriorityType             thePriority,
+                                                  const Handle(HYDROData_LandCover)& theLandCover2/*,
+                                                  HYDROData_LandCover::MergeStricklerCoefficientType theMergeType*/ )
+{
+  TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomLandCoverRules );
+  // TODO: adapt HYDROData_PriorityQueue to use with land covers
+  //HYDROData_PriorityQueue::AddRule( aRulesLab, theLandCover1, thePriority, theLandCover2, theMergeType );
+
+  // Indicate model of the need to update splitting
+  SetToUpdate( true );
+}
+
+bool HYDROData_CalculationCase::GetLandCoverRule( int theIndex, 
+                                                  Handle(HYDROData_LandCover)&        theLandCover1,
+                                                  HYDROData_PriorityType&             thePriority,
+                                                  Handle(HYDROData_LandCover)&        theLandCover2/*,
+                                                  HYDROData_LandCover::MergeStricklerCoefficientType& theMergeType*/ ) const
+{
+  TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomLandCoverRules );
+  // TODO: adapt HYDROData_PriorityQueue to use with land covers
+  //return HYDROData_PriorityQueue::GetRule( aRulesLab, theIndex,
+  //  theLandCover1, thePriority, theLandCover2, theMergeType );
+  return true;
+}
index 35d51d10e4b182b084f560bdbdad26c1981b7c9b..d1a24b4db550ece6f64ae2f5069b7735e274642c 100644 (file)
@@ -42,6 +42,8 @@ class Handle(HYDROData_PolylineXY);
 class Handle(HYDROData_ShapesGroup);
 class Handle(HYDROData_SplittedShapesGroup);
 class Handle(HYDROData_Document);
+class Handle(HYDROData_StricklerTable);
+class Handle(HYDROData_LandCover);
 
 DEFINE_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
 
@@ -75,14 +77,18 @@ public:
   enum DataTag
   {
     DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
-    DataTag_GeometryObject,   ///< reference geometry objects
-    DataTag_ChildRegion,      ///< child regions
-    DataTag_Region,           ///< reference regions
-    DataTag_Polyline,         ///< reference boundary polyline
-    DataTag_GeometryGroup,    ///< reference geometry groups
-    DataTag_SplittedGroups,   ///< reference splitted groups
-    DataTag_CustomRules,      ///< custom rules
-    DataTag_AssignmentMode,   ///< assignment mode
+    DataTag_GeometryObject,            ///< reference geometry objects
+    DataTag_ChildRegion,               ///< child regions
+    DataTag_Region,                    ///< reference regions
+    DataTag_Polyline,                  ///< reference boundary polyline
+    DataTag_GeometryGroup,             ///< reference geometry groups
+    DataTag_SplittedGroups,            ///< reference splitted groups
+    DataTag_CustomRules,               ///< custom rules
+    DataTag_AssignmentMode,            ///< assignment mode
+    DataTag_StricklerTable,            ///< reference Strickler table
+    DataTag_LandCover,                 ///< reference land covers
+    DataTag_CustomLandCoverRules,      ///< custom rules for land covers priority
+    DataTag_AssignmentLandCoverMode    ///< assignment mode of land covers priority
   };
 
 public:
@@ -177,6 +183,43 @@ public:
   HYDRODATA_EXPORT virtual void RemoveBoundaryPolyline();
 
 
+    /**
+   * Sets reference Strickler table for calculation case.
+   */
+  HYDRODATA_EXPORT virtual void SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable );
+
+  /**
+   * Returns reference Strickler table of calculation case.
+   */
+  HYDRODATA_EXPORT virtual Handle(HYDROData_StricklerTable) GetStricklerTable() const;
+
+  /**
+   * Remove reference Strickler table from calculation case.
+   */
+  HYDRODATA_EXPORT virtual void RemoveStricklerTable();
+
+
+  /**
+   * Add new one reference land cover for calculation case.
+   */
+  HYDRODATA_EXPORT virtual bool AddLandCover( const Handle(HYDROData_LandCover)& theLandCover );
+
+  /**
+   * Returns all reference land covers of calculation case.
+   */
+  HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetLandCovers() const;
+
+  /**
+   * Removes reference land cover from calculation case.
+   */
+  HYDRODATA_EXPORT virtual void RemoveLandCover( const Handle(HYDROData_LandCover)& theLandCover );
+
+  /**
+   * Removes all reference land covers from calculation case.
+   */
+  HYDRODATA_EXPORT virtual void RemoveLandCovers();
+
+
   /**
    * Add new one child region for calculation case.
    * The new region is added into the list of reference regions.
@@ -326,6 +369,20 @@ public:
                                  Handle(HYDROData_Object)&           theObject2,
                                  HYDROData_Zone::MergeAltitudesType& theMergeType ) const;
 
+  HYDRODATA_EXPORT void SetAssignmentLandCoverMode( AssignmentMode theMode );
+  HYDRODATA_EXPORT AssignmentMode GetAssignmentLandCoverMode() const;
+
+  HYDRODATA_EXPORT void ClearLandCoverRules( const bool theIsSetToUpdate = true );
+  HYDRODATA_EXPORT void AddLandCoverRule( const Handle(HYDROData_LandCover)& theLandCover1,
+                                          HYDROData_PriorityType             thePriority,
+                                          const Handle(HYDROData_LandCover)& theLandCover2/*,
+                                          HYDROData_LandCover::MergeStricklerCoefficientType theMergeType*/ );
+  HYDRODATA_EXPORT bool GetLandCoverRule( int theIndex, 
+                                          Handle(HYDROData_LandCover)&        theLandCover1,
+                                          HYDROData_PriorityType&             thePriority,
+                                          Handle(HYDROData_LandCover)&        theLandCover2/*,
+                                          HYDROData_LandCover::MergeStricklerCoefficientType& theMergeType*/ ) const;
+
   HYDRODATA_EXPORT QString DumpRules() const;
 
   HYDRODATA_EXPORT HYDROData_Warning GetLastWarning() const;
index c23683e9ac1c16eccefef716e6131012acc106fe..c50679f8f9eed1ac2f602619d9605f9731561f86 100644 (file)
@@ -70,7 +70,9 @@ HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, co
 {
   addPage( createObjectsPage() );
   addPage( createGroupsPage() );
+  addPage( createLandCoversPage() );
   addPage( createZonesPage() );
+  addPage( createLandCoversPartitionPage() );
 }
 
 HYDROGUI_CalculationDlg::~HYDROGUI_CalculationDlg()
@@ -83,10 +85,12 @@ void HYDROGUI_CalculationDlg::reset()
   HYDROGUI_ListModel::Object2VisibleList anObject2VisibleList;
   myGeomObjects->setObjects(anObject2VisibleList);
   myPolylineName->clear();
+  myStricklerTableName->clear();
   myAvailableGeomObjects->clear();
 
   // Activate the automatic mode
   setMode( HYDROData_CalculationCase::AUTOMATIC );
+  setLandCoverMode( HYDROData_CalculationCase::AUTOMATIC );
 
   // Reset the priority widget state
   QList<Handle(HYDROData_Object)> anObjects;
@@ -303,6 +307,141 @@ QWizardPage* HYDROGUI_CalculationDlg::createGroupsPage() {
   return aPage;
 }
 
+QWizardPage* HYDROGUI_CalculationDlg::createLandCoversPage() {
+  QWizardPage* aPage = new QWizardPage( mainFrame() );
+  QFrame* aFrame = new QFrame( aPage );
+
+  // Splitter
+  myLandCoverSplitter = new QSplitter(Qt::Vertical);
+
+  // Top of the page
+  QWidget* aTopContainer = new QWidget;
+   
+  // Combo-box to choose Strickler table name
+  QLabel* aStricklerTableLabel = new QLabel( tr( "STRICKLER_TABLE" ), aPage );
+  myStricklerTableName = new QComboBox( aPage );
+  myStricklerTableName->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  connect( myStricklerTableName, SIGNAL( activated( const QString & ) ), 
+                                 SIGNAL( StricklerTableSelected( const QString & ) ) );
+
+  // mode selector (auto/manual)
+  QGroupBox* aModeGroup = new QGroupBox( tr( "MODE" ) );
+
+  QRadioButton* aManualRB = new QRadioButton( tr( "MANUAL" ), mainFrame() );
+  QRadioButton* anAutoRB = new QRadioButton( tr( "AUTO" ), mainFrame() );
+
+  myLandCoverModeButtons = new QButtonGroup( mainFrame() );
+  myLandCoverModeButtons->addButton( anAutoRB, HYDROData_CalculationCase::AUTOMATIC );
+  myLandCoverModeButtons->addButton( aManualRB, HYDROData_CalculationCase::MANUAL );
+  
+  QBoxLayout* aModeSelectorLayout = new QHBoxLayout;
+  aModeSelectorLayout->setMargin( 5 );
+  aModeSelectorLayout->setSpacing( 5 );
+  aModeSelectorLayout->addWidget( anAutoRB );
+  aModeSelectorLayout->addWidget( aManualRB );
+  aModeGroup->setLayout( aModeSelectorLayout );
+
+  // land covers
+  QLabel* aLandCoversLabel = new QLabel( tr( "CALCULATION_REFERENCE_LAND_COVERS" ) );
+  myLandCovers = new HYDROGUI_OrderedListWidget( aPage, 16 );
+  myLandCovers->setHiddenObjectsShown(true);
+  myLandCovers->setVisibilityIconShown(false);
+  myLandCovers->setContentsMargins(QMargins());
+  // included land covers
+  QLabel* anIncludedLabel = new QLabel( tr( "INCLUDED_LAND_COVERS" ) );
+  myAvailableLandCovers = new QListWidget( aPage );
+  myAvailableLandCovers->setSelectionMode( QListWidget::ExtendedSelection );
+  myAvailableLandCovers->setEditTriggers( QListWidget::NoEditTriggers );
+  myAvailableLandCovers->setViewMode( QListWidget::ListMode );
+  myAvailableLandCovers->setSortingEnabled( true );
+
+  // buttons
+  QFrame* aBtnsFrame = new QFrame;
+  QVBoxLayout* aBtnsLayout = new QVBoxLayout( aBtnsFrame );
+  aBtnsLayout->setMargin( 5 );
+  aBtnsLayout->setSpacing( 5 );
+  aBtnsFrame->setLayout( aBtnsLayout );
+  QPushButton* anAddBtn = new QPushButton( tr("INCLUDE"), aBtnsFrame );
+  QPushButton* aRemoveBtn = new QPushButton( tr("EXCLUDE"), aBtnsFrame );
+
+  // fill the butons frame with two buttons
+  aBtnsLayout->addWidget( anAddBtn );
+  aBtnsLayout->addWidget( aRemoveBtn );
+  aBtnsLayout->addStretch( 1 );
+  
+  // top of the page layout
+  
+  // land covers frame
+  QFrame* aLandCoversFrame = new QFrame( aPage );
+  aLandCoversFrame->setFrameStyle( QFrame::Panel | QFrame::Raised );
+  QGridLayout* aLandCoversLayout = new QGridLayout( aLandCoversFrame );
+  aLandCoversLayout->setMargin( 5 );
+  aLandCoversLayout->setSpacing( 5 );
+  aLandCoversFrame->setLayout( aLandCoversLayout );
+  
+  // fill the land covers frame with two lists, two labels and with buttons frame
+  aLandCoversLayout->addWidget( aLandCoversLabel, 0, 0, Qt::AlignHCenter );
+  aLandCoversLayout->addWidget( anIncludedLabel, 0, 2, Qt::AlignHCenter );
+  aLandCoversLayout->addWidget( myAvailableLandCovers, 1, 0 );
+  aLandCoversLayout->addWidget( aBtnsFrame, 1, 1, Qt::AlignHCenter );
+  aLandCoversLayout->addWidget( myLandCovers, 1, 2 );
+  
+  // fill the top of the page
+  QGridLayout* aTopLayout = new QGridLayout;
+  aTopLayout->setMargin( 5 );
+  aTopLayout->setSpacing( 5 );
+  aTopLayout->setVerticalSpacing( 10 );
+  aTopLayout->addWidget( aStricklerTableLabel, 0, 0, Qt::AlignHCenter );
+  aTopLayout->addWidget( myStricklerTableName, 0, 1 );
+  aTopLayout->addWidget( aModeGroup, 1, 0, 1, 2 );
+  aTopLayout->addWidget( aLandCoversFrame, 2, 0, 1, 2 );
+
+  aTopContainer->setLayout( aTopLayout );
+
+  // add the top of the page to the splitter
+  myLandCoverSplitter->insertWidget(0, aTopContainer);
+  myLandCoverSplitter->setStretchFactor(0, 2);
+
+  // Bottom of the page
+  myLandCoverPriorityWidget = new HYDROGUI_PriorityWidget( mainFrame() );
+
+  QGroupBox* aPriorityGroup = new QGroupBox( tr( "PRIORITY" ) );
+  QBoxLayout* aPriorityLayout = new QHBoxLayout;
+  aPriorityLayout->setMargin( 5 );
+  aPriorityLayout->setSpacing( 5 );
+  aPriorityLayout->addWidget( myLandCoverPriorityWidget );
+  aPriorityGroup->setLayout( aPriorityLayout );
+
+  // add the bottom of the page to the splitter
+  myLandCoverSplitter->insertWidget(1, aPriorityGroup);
+  myLandCoverSplitter->setStretchFactor(1, 1);
+
+  // Page layout
+  QVBoxLayout* aPageLayout = new QVBoxLayout;
+  aPageLayout->setMargin( 5 );
+  aPageLayout->setSpacing( 5 );
+  aPageLayout->addWidget( myLandCoverSplitter );
+
+  aPage->setLayout( aPageLayout );
+
+  // Create selector
+  if ( module() ) {
+    HYDROGUI_ListSelector* aListSelector = 
+      new HYDROGUI_ListSelector( myLandCovers, module()->getApp()->selectionMgr() );
+    aListSelector->setAutoBlock( true );
+  }
+
+  // Connections
+  connect( myLandCoverModeButtons, SIGNAL( buttonClicked( int ) ), SIGNAL( changeLandCoverMode( int ) ) );
+  connect( anAddBtn, SIGNAL( clicked() ), SIGNAL( addLandCovers() ) );
+  connect( aRemoveBtn, SIGNAL( clicked() ), SIGNAL( removeLandCovers() ) );
+
+  connect( myLandCovers, SIGNAL( orderLandCoverChanged() ), SLOT( onOrderLandCoverChanged() ) );
+
+  return aPage;
+}
+
 QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() {
   QWizardPage* aPage = new QWizardPage( mainFrame() );
   QFrame* aFrame = new QFrame( aPage );
@@ -339,6 +478,27 @@ QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() {
   return aPage;
 }
 
+QWizardPage* HYDROGUI_CalculationDlg::createLandCoversPartitionPage() {
+  QWizardPage* aPage = new QWizardPage( mainFrame() );
+  QFrame* aFrame = new QFrame( aPage );
+
+  QGridLayout* aLayout = new QGridLayout( aPage );
+  
+  myLandCoverBrowser = new HYDROGUI_DataBrowser( module(), NULL, aPage );
+  myLandCoverBrowser->setAutoOpenLevel( 3 );
+  aLayout->setMargin( 5 );
+  aLayout->setSpacing( 5 );
+
+  aLayout->addWidget( myLandCoverBrowser, 0, 0, 1, 2 );
+
+  aPage->setLayout( aLayout );
+
+  // Connections
+  //...
+
+  return aPage;
+}
+
 
 bool HYDROGUI_CalculationDlg::acceptCurrent() const
 {
@@ -554,6 +714,17 @@ void HYDROGUI_CalculationDlg::setPolylineNames( const QStringList& theObjects, c
     myPolylineName->addItem( theObjects.at( i ), theObjectsEntries.at( i ) );
   }
 }
+
+void HYDROGUI_CalculationDlg::setStricklerTableNames( const QStringList& theObjects, const QStringList& theObjectsEntries )
+{
+  myStricklerTableName->clear();
+
+  for ( int i = 0, n = theObjects.length(); i < n; ++i )
+  {
+    myStricklerTableName->addItem( theObjects.at( i ), theObjectsEntries.at( i ) );
+  }
+}
+
 void HYDROGUI_CalculationDlg::setAllGeomObjects( const QStringList& theObjects, const QStringList& theObjectsEntries )
 {
   myAvailableGeomObjects->clear();
@@ -685,6 +856,34 @@ void HYDROGUI_CalculationDlg::setMode( int theMode )
   }
 }
 
+/**
+  Get creation mode for land covers panel.
+  @param theMode the mode
+*/
+int HYDROGUI_CalculationDlg::getLandCoverMode() const
+{
+  return myLandCoverModeButtons->checkedId();
+}
+
+/**
+  Set creation mode for land cover panel.
+  @param theMode the mode
+*/
+void HYDROGUI_CalculationDlg::setLandCoverMode( int theMode )
+{
+  bool isBlocked = myLandCoverModeButtons->blockSignals( true );
+  myLandCoverModeButtons->button( theMode )->setChecked( true );
+  myLandCoverModeButtons->blockSignals( isBlocked );
+
+  bool isAuto = ( theMode == HYDROData_CalculationCase::AUTOMATIC );
+
+  myLandCovers->setOrderingEnabled( isAuto );
+  QWidget* aWidget = myLandCoverSplitter->widget( 1 );
+  if ( aWidget ) {
+    aWidget->setVisible( isAuto );
+  }
+}
+
 /**
   Enable/disable zones drag'n'drop and renaming.
   @param theIsEnabled if true - zones drag'n'drop and renaming will be enabled
@@ -694,6 +893,15 @@ void HYDROGUI_CalculationDlg::setEditZonesEnabled( const bool theIsEnabled )
   myBrowser->setReadOnly( !theIsEnabled );
 }
 
+/**
+  Enable/disable land covers drag'n'drop and renaming.
+  @param theIsEnabled if true - land covers drag'n'drop and renaming will be enabled
+*/
+void HYDROGUI_CalculationDlg::setEditLandCoversEnabled( const bool theIsEnabled )
+{
+  myLandCoverBrowser->setReadOnly( !theIsEnabled );
+}
+
 /**
   Get included geometry objects.
   @return the list of geometry objects
@@ -715,6 +923,27 @@ QList<Handle(HYDROData_Object)> HYDROGUI_CalculationDlg::getGeometryObjects()
   return anObjects;
 }
 
+/**
+  Get included land covers.
+  @return the list of land covers
+ */
+QList<Handle(HYDROData_LandCover)> HYDROGUI_CalculationDlg::getLandCovers()
+{
+  QList<Handle(HYDROData_Entity)> anEntities = myLandCovers->getObjects();
+  QList<Handle(HYDROData_LandCover)> aLandCovers;
+
+  foreach ( Handle(HYDROData_Entity) anEntity, anEntities ) {
+    Handle(HYDROData_LandCover) aLandCover = Handle(HYDROData_LandCover)::DownCast( anEntity );
+    if ( aLandCover.IsNull() ) {
+      continue;
+    }
+
+    aLandCovers << aLandCover;
+  }
+
+  return aLandCovers;
+}
+
 /**
   Get rules.
   @return the list of rules
@@ -745,3 +974,24 @@ void HYDROGUI_CalculationDlg::onOrderChanged()
   else
     myGeomObjects->undoLastMove();
 }
+
+void HYDROGUI_CalculationDlg::setStricklerTable( const QString& theStricklerTableName )
+{
+  bool isBlocked = myStricklerTableName->blockSignals( true );
+  myStricklerTableName->setCurrentIndex( myStricklerTableName->findText( theStricklerTableName ) );
+  myStricklerTableName->blockSignals( isBlocked );
+}
+
+/**
+  Slot called when land covers order is changed.
+ */
+void HYDROGUI_CalculationDlg::onOrderLandCoverChanged()
+{
+  bool isConfirmed = true;
+  emit orderLandCoverChanged( isConfirmed );
+  /*if( isConfirmed )
+    myLandCoverPriorityWidget->setObjects( getLandCovers() );
+  else
+    myLandCovers->undoLastMove();
+  */
+}
index a769f3d44ddd8eecdd81bb41a939568eba419d1f..566ea281381e748c390641cfaef6d3402858989b 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "HYDROGUI_Wizard.h"
 #include <HYDROData_CalculationCase.h>
+#include <HYDROData_LandCover.h>
 
 class HYDROGUI_ObjSelector;
 class HYDROGUI_DataBrowser;
@@ -53,6 +54,7 @@ public:
   void                       reset();
 
   int                        getMode() const;
+  int                        getLandCoverMode() const;
 
   void                       setObjectName( const QString& theName );
   QString                    getObjectName() const;
@@ -62,6 +64,7 @@ public:
   void                       setAllGeomObjects( const QStringList& theObjects, const QStringList& theObjectsEntries );
   QStringList                getAllGeomObjects() const;
   void                       setPolylineNames( const QStringList& theObjects, const QStringList& theObjectsEntries );
+  void                       setStricklerTableNames( const QStringList& theObjects, const QStringList& theObjectsEntries );
   QStringList                getSelectedGeomObjects() const;
   QStringList                getSelectedAvailableGeomObjects() const;
   QStringList                getSelectedGroups() const;
@@ -71,6 +74,7 @@ public:
   void                       setAvailableGroups( const QStringList& );
 
   void                       setEditZonesEnabled( const bool theIsEnabled );
+  void                       setEditLandCoversEnabled( const bool theIsEnabled );
 
   HYDROData_ListOfRules      getRules() const;
   void                       setRules( const HYDROData_ListOfRules& theRules ) const;
@@ -88,6 +92,10 @@ public slots:
   void                       onDataChanged();
   void                       onOrderChanged();
 
+  void                       setLandCoverMode( int theMode );
+  void                       setStricklerTable( const QString& theStricklerTableName );
+  void                       onOrderLandCoverChanged();
+
   /**
    * Process items selection: hide/show bathymetry merge type selector.
    */
@@ -103,7 +111,7 @@ public slots:
     SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction );
 
 signals:
-  void                       changeMode( int theMode );
+  void                       changeMode( int theMode );  
 
   void                       addObjects();
   void                       removeObjects();
@@ -120,6 +128,14 @@ signals:
   void                       moveZones( SUIT_DataObject* theRegion, const QList<SUIT_DataObject*>& theZonesList );
   void                       clickedInZonesBrowser( SUIT_DataObject* );
 
+  void                       changeLandCoverMode( int theMode );
+
+  void                       addLandCovers();
+  void                       removeLandCovers();
+  void                       orderLandCoverChanged( bool& isConfirmed );
+  
+  void                       StricklerTableSelected( const QString & theObjName );
+
 protected:
 
   virtual bool               acceptCurrent() const;
@@ -129,34 +145,46 @@ protected slots:
 
 private:
   QList<Handle(HYDROData_Object)> getGeometryObjects();
+  QList<Handle(HYDROData_LandCover)> getLandCovers();
 
   QWizardPage*               createObjectsPage();
   QWizardPage*               createGroupsPage();
+  QWizardPage*               createLandCoversPage();
   QWizardPage*               createZonesPage();
+  QWizardPage*               createLandCoversPartitionPage();
 
   QSplitter*                 mySplitter;
+  QSplitter*                 myLandCoverSplitter;
 
   QGroupBox*                 myObjectNameGroup;
   QLineEdit*                 myObjectName;
   HYDROGUI_NameValidator*    myValidator;
 
   QComboBox*                 myPolylineName;
+  QComboBox*                 myStricklerTableName;
 
   QButtonGroup*              myModeButtons;
+  QButtonGroup*              myLandCoverModeButtons;
 
   QListWidget*               myAvailableGeomObjects;
   HYDROGUI_OrderedListWidget* myGeomObjects;
 
   HYDROGUI_PriorityWidget*   myPriorityWidget;
+  HYDROGUI_PriorityWidget*   myLandCoverPriorityWidget;
 
   QListWidget*               myAvailableGroups;
   QListWidget*               myGroups;
 
+  QListWidget*               myAvailableLandCovers;
+  HYDROGUI_OrderedListWidget* myLandCovers;
+
   HYDROGUI_DataBrowser*      myBrowser;
   Handle(HYDROData_CalculationCase) myEditedObject;
   QComboBox*                 myBathymetryChoice;
   QLabel*                    myBathymetryLabel;
   HYDROGUI_Zone*             myCurrentZone;
+
+  HYDROGUI_DataBrowser*      myLandCoverBrowser;
 };
 
 #endif
index ec7c4c83a479e3b759fd08f99be4b807b7e755a6..d0fc53d5cfb4893c5bb72e50102292adcdd3570f 100644 (file)
@@ -32,6 +32,7 @@
 #include <HYDROData_ImmersibleZone.h>
 #include <HYDROData_Object.h>
 #include <HYDROData_Tool.h>
+#include <HYDROData_StricklerTable.h>
 
 #include <OCCViewer_ViewManager.h>
 #include <OCCViewer_ViewModel.h>
@@ -224,11 +225,13 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const
 
   // Connect signals and slots
   connect( aPanel, SIGNAL( changeMode( int ) ), SLOT( onChangeMode( int ) ) );
+  connect( aPanel, SIGNAL( changeLandCoverMode( int ) ), SLOT( onChangeLandCoverMode( int ) ) );
   connect( aPanel, SIGNAL( addObjects() ), SLOT( onAddObjects() ) );
   connect( aPanel, SIGNAL( removeObjects() ), SLOT( onRemoveObjects() ) );
   connect( aPanel, SIGNAL( addGroups() ), SLOT( onAddGroups() ) );
   connect( aPanel, SIGNAL( removeGroups() ), SLOT( onRemoveGroups() ) );
   connect( aPanel, SIGNAL( orderChanged( bool& ) ), SLOT( onOrderChanged( bool& ) ) );
+  connect( aPanel, SIGNAL( orderLandCoverChanged( bool& ) ), SLOT( onOrderLandCoverChanged( bool& ) ) );
   connect( aPanel, SIGNAL( Next( const int ) ), SLOT( onNext( const int ) ) );
   connect( aPanel, SIGNAL( Back( const int ) ), SLOT( onHideZones() ) );
   //connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
@@ -243,6 +246,8 @@ HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const
            SLOT( onObjectsSelected() ) );
   connect( aPanel, SIGNAL( boundarySelected( const QString & ) ), 
     SLOT( onBoundarySelected( const QString & ) ) );
+  connect( aPanel, SIGNAL( StricklerTableSelected( const QString & ) ), 
+    SLOT( onStricklerTableSelected( const QString & ) ) );
 
   return aPanel;
 }
@@ -286,6 +291,69 @@ void HYDROGUI_CalculationOp::onBoundarySelected ( const QString & theObjName )
   }
 }
 
+void HYDROGUI_CalculationOp::onStricklerTableSelected ( const QString & theObjName )
+{
+  bool anIsToUpdateViewer = false;
+
+  // Remove old presentations of land covers from the operation viewer  
+  Handle(HYDROData_Entity) anEntity;
+  Handle(HYDROData_LandCover) aLandCover;
+  HYDROData_SequenceOfObjects aLandCovers;
+  HYDROData_SequenceOfObjects aSeq = myEditedObject->GetLandCovers();
+  HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
+  for ( ; anIter.More(); anIter.Next() )
+  {
+    anEntity = anIter.Value();
+    if ( !anEntity.IsNull() )
+    {
+      aLandCover = Handle(HYDROData_LandCover)::DownCast( anEntity );
+      if ( !aLandCover.IsNull() )
+      {
+        aLandCovers.Append( aLandCover );
+        setObjectVisibility( aLandCover, false );
+        anIsToUpdateViewer = true;
+      }
+    }
+  }
+
+  // Set the selected Strickler table to the calculation case
+  Handle(HYDROData_StricklerTable) aNewStricklerTable = Handle(HYDROData_StricklerTable)::DownCast(
+    HYDROGUI_Tool::FindObjectByName( module(), theObjName, KIND_STRICKLER_TABLE ) );
+  myEditedObject->SetStricklerTable( aNewStricklerTable );
+
+  if ( myPreviewViewManager )
+  {
+    OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
+    if ( aViewer )
+    {
+      if ( !aNewStricklerTable.IsNull() )
+      {
+        Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
+        if ( !aCtx.IsNull() )
+        {
+          HYDROData_SequenceOfObjects::Iterator anIter( aLandCovers );
+          for ( ; anIter.More(); anIter.Next() )
+          {
+            anEntity = anIter.Value();
+            if ( !anEntity.IsNull() )
+            {
+              aLandCover = Handle(HYDROData_LandCover)::DownCast( anEntity );
+              if ( !aLandCover.IsNull() )
+              {
+                setObjectVisibility( aLandCover, true );
+                anIsToUpdateViewer = true;
+              }
+            }
+          }          
+        }
+      }
+
+      if ( anIsToUpdateViewer )
+        module()->update( UF_OCCViewer );
+    }
+  }
+}
+
 void HYDROGUI_CalculationOp::onObjectsSelected()
 {
   HYDROGUI_CalculationDlg* aPanel = 
@@ -598,6 +666,32 @@ bool HYDROGUI_CalculationOp::confirmContinueWithWarning( const HYDROData_Warning
   return ( anAnswer == QMessageBox::Yes );
 }
 
+bool HYDROGUI_CalculationOp::confirmLandCoverModeChange() const
+{
+  // Check if the case is already modified or not
+  bool isConfirmed = myEditedObject->IsMustBeUpdated();
+  if ( !isConfirmed )
+  {
+    // If not modified check if the case has already defined regions with zones
+    // TODO: adapt HYDROData_CalculationCase class to process regions constructed for land covers
+    /*HYDROData_SequenceOfObjects aSeq = myEditedObject->GetLandCoverRegions();
+    if ( aSeq.Length() > 0 )
+    {*/
+      // If there are already defined zones then ask a user to confirm zones recalculation
+      isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(),
+                               tr( "MODE_CHANGED" ),
+                               tr( "CONFIRM_LAND_COVER_PARTITION_RECALCULATION_MODE" ),
+                               QMessageBox::Yes | QMessageBox::No,
+                               QMessageBox::No ) == QMessageBox::Yes );
+    /*}
+    else
+    {
+      isConfirmed = true; // No regions - no zones - nothing to recalculate
+    }*/
+  }
+  return isConfirmed;
+}
+
 bool HYDROGUI_CalculationOp::processApply( int&     theUpdateFlags,
                                            QString& theErrorMsg,
                                            QStringList& theBrowseObjectsEntries )
@@ -617,6 +711,9 @@ bool HYDROGUI_CalculationOp::processApply( int&     theUpdateFlags,
   if ( aPanel->getMode() == HYDROData_CalculationCase::MANUAL ) {
     myEditedObject->ClearRules( false );
   }
+  if ( aPanel->getLandCoverMode() == HYDROData_CalculationCase::MANUAL ) {
+    myEditedObject->ClearLandCoverRules( false );
+  }
  
   theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init;
 
@@ -689,6 +786,68 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex )
     setAvailableGroups();
   }
   else if( theIndex==2 )
+  {
+    // Land covers panel
+     HYDROGUI_CalculationDlg* aPanel = 
+      ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+    if ( !aPanel )
+      return;
+
+    QStringList aList;
+    QStringList anEntryList;
+
+    // Get all Strickler table objects to fill in combo-box
+    aList.clear();
+    anEntryList.clear();
+    HYDROData_Iterator anIter( doc(), KIND_STRICKLER_TABLE );
+    Handle(HYDROData_StricklerTable) aStricklerTableObj;
+    QString aStricklerTableName;
+    for ( ; anIter.More(); anIter.Next() )
+    {
+      aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( anIter.Current() );
+
+      if ( !aStricklerTableObj.IsNull() )
+      { 
+        aStricklerTableName = aStricklerTableObj->GetName();
+        if ( !aStricklerTableName.isEmpty() )
+        {
+          aList.append( aStricklerTableName );
+          anEntryList.append( HYDROGUI_DataObject::dataObjectEntry( aStricklerTableObj ) );
+        }        
+      }
+    }
+    aPanel->setStricklerTableNames( aList, anEntryList );
+
+    //HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetGeometryObjects( module() );
+    //getNamesAndEntries( aSeq, aList, anEntryList );
+    //aPanel->setAllGeomObjects( aList, anEntryList );
+
+    if ( !myEditedObject.IsNull() )
+    {
+      if ( myIsEdit )
+      {      
+        // Select the certain Strickler table object in combo-box
+        aStricklerTableObj = myEditedObject->GetStricklerTable();
+        if ( aStricklerTableObj.IsNull() )
+        {
+          aPanel->setStricklerTable( QString() );
+        }
+        else
+        {
+          aStricklerTableName = aStricklerTableObj->GetName();
+          aPanel->setStricklerTable( aStricklerTableName );
+        }
+
+        // Set mode (Auto or Manual) to defined priority of land covers
+        aPanel->setLandCoverMode( myEditedObject->GetAssignmentLandCoverMode() );
+      }
+      else
+      {
+        myEditedObject->SetAssignmentLandCoverMode( (HYDROData_CalculationCase::AssignmentMode)aPanel->getLandCoverMode() );
+      }
+    }
+  }
+  else if( theIndex==3 )
   {
     HYDROGUI_CalculationDlg* aPanel = 
       ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
@@ -770,6 +929,32 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex )
       }
     }
 
+    QApplication::restoreOverrideCursor();
+  }
+  else if( theIndex==4 )
+  {
+    // Partition of Land covers panel
+    HYDROGUI_CalculationDlg* aPanel = 
+      ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+    if ( !aPanel )
+      return;
+
+    QApplication::setOverrideCursor( Qt::WaitCursor );
+
+    //...
+
+    // Set parameters for automatic mode
+    int aMode = aPanel->getLandCoverMode();
+    if ( aMode == HYDROData_CalculationCase::AUTOMATIC )
+    {
+      // Set objects in the specified order
+      if( myEditedObject->IsMustBeUpdated() )
+      {
+        //...
+      }
+    }
+    aPanel->setEditLandCoversEnabled( aMode == HYDROData_CalculationCase::MANUAL );
+
     QApplication::restoreOverrideCursor();
   }
 }
@@ -1134,6 +1319,22 @@ void HYDROGUI_CalculationOp::onChangeMode( int theMode )
   aPanel->setMode( theMode );
 }
 
+void HYDROGUI_CalculationOp::onChangeLandCoverMode( int theMode )
+{
+  HYDROGUI_CalculationDlg* aPanel = 
+    ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+  if ( !aPanel )
+    return;
+
+  if ( !confirmLandCoverModeChange() ) {
+    aPanel->setLandCoverMode( myEditedObject->GetAssignmentLandCoverMode() );
+    return;
+  }
+
+  myEditedObject->SetAssignmentLandCoverMode( (HYDROData_CalculationCase::AssignmentMode)theMode );
+  aPanel->setLandCoverMode( theMode );
+}
+
 void HYDROGUI_CalculationOp::onOrderChanged( bool& isConfirmed )
 {
   HYDROGUI_CalculationDlg* aPanel = 
@@ -1145,3 +1346,15 @@ void HYDROGUI_CalculationOp::onOrderChanged( bool& isConfirmed )
   if( isConfirmed )
     myEditedObject->SetToUpdate( true );
 }
+
+void HYDROGUI_CalculationOp::onOrderLandCoverChanged( bool& isConfirmed )
+{
+  /*HYDROGUI_CalculationDlg* aPanel = 
+    ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+  if ( !aPanel )
+    return;
+
+  isConfirmed = confirmOrderChange();
+  if( isConfirmed )
+    myEditedObject->SetToUpdate( true );*/
+}
index 5ae6b3d887c8235401b685bac3a031c08eca0e26..467d1a39f53e2716ad0dde57497c763af6b626cb 100644 (file)
@@ -62,6 +62,12 @@ protected slots:
    */
   void                            onChangeMode( int theMode );
 
+  /**
+   * Change the creation mode related to land covers.
+   * @param theMode the mode to set
+   */
+  void                            onChangeLandCoverMode( int theMode );
+
   /**
    * Add geometry objects selected in the module browser to the calculation case.
    */
@@ -113,9 +119,14 @@ protected slots:
   /** 
    * Boundary polyline is selected in the list on the first wizard page
    */
-  void                            onBoundarySelected ( const QString & theObjName );
+  void                            onBoundarySelected( const QString & theObjName );
+  /** 
+   * Strickler table name is selected in the list on the third wizard page
+   */
+  void                            onStricklerTableSelected( const QString & theObjName );
 
   void onOrderChanged( bool& isConfirmed );
+  void onOrderLandCoverChanged( bool& isConfirmed );
 
 private:
   void                            createPreview();
@@ -150,6 +161,8 @@ private:
   bool confirmOrderChange() const;
   bool confirmContinueWithWarning( const HYDROData_Warning& theWarning ) const;
 
+  bool confirmLandCoverModeChange() const;
+
 private:
   bool                            myIsEdit;
   bool                            myShowZones;
index 33ac9fb27a9b13ac63c41fbf211c86b48255f14c..a511731b5d2d57c0fda770f68f3ed9bb7ccf9803 100644 (file)
@@ -345,6 +345,18 @@ All supported formats (*.brep *.iges *.igs *.step *.stp)</translation>
       <source>PRIORITY</source>
       <translation>Priority</translation>
     </message>
+    <message>
+      <source>STRICKLER_TABLE</source>
+      <translation>Strickler table</translation>
+    </message>
+    <message>
+      <source>CALCULATION_REFERENCE_LAND_COVERS</source>
+      <translation>Land covers</translation>
+    </message>
+    <message>
+      <source>INCLUDED_LAND_COVERS</source>
+      <translation>Included land covers</translation>
+    </message>
   </context>
 
   <context>
@@ -389,6 +401,10 @@ All supported formats (*.brep *.iges *.igs *.step *.stp)</translation>
       <source>CONFIRM_CONTINUE_WITH_OBJECTS_NOT_INCLUDED_TO_REGION</source>
       <translation>Region(s): %1 do not contain any objects. Do you want to continue?</translation>
     </message>
+    <message>
+      <source>CONFIRM_LAND_COVER_PARTITION_RECALCULATION_MODE</source>
+      <translation>Case land covers partition already exists and will be recalculated after mode change. Do you confirm the recalculation?</translation>
+    </message>
   </context>
 
   <context>