Salome HOME
83249f3cf77a9639482038896a2a3faa40775d9b
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_CalculationDlg.cxx
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #include "HYDROGUI_CalculationDlg.h"
20
21 #include "HYDROGUI_ObjSelector.h"
22 #include "HYDROGUI_Tool.h"
23 #include "HYDROGUI_DataBrowser.h"
24 #include "HYDROGUI_DataModel.h"
25 #include "HYDROGUI_ListSelector.h"
26 #include "HYDROGUI_Module.h"
27 #include "HYDROGUI_DataObject.h"
28 #include "HYDROGUI_NameValidator.h"
29 #include "HYDROGUI_Region.h"
30 #include "HYDROGUI_Zone.h"
31 #include "HYDROGUI_OrderedListWidget.h"
32 #include "HYDROGUI_PriorityWidget.h"
33 #include "HYDROGUI_PriorityTableModel.h"
34
35 #include <HYDROData_Document.h>
36 #include <HYDROData_Entity.h>
37
38 #include <CAM_Application.h>
39 #include <LightApp_DataObject.h>
40
41 #include <SUIT_DataObject.h>
42 #include <SUIT_FileDlg.h>
43 #include <SUIT_ResourceMgr.h>
44 #include <SUIT_Session.h>
45 #include <SUIT_Study.h>
46
47 #include <LightApp_Application.h>
48 #include <LightApp_SelectionMgr.h>
49 #include <SUIT_Desktop.h>
50 #include <SUIT_MessageBox.h>
51
52 #include <QButtonGroup>
53 #include <QComboBox>
54 #include <QGroupBox>
55 #include <QLabel>
56 #include <QLayout>
57 #include <QLineEdit>
58 #include <QListWidget>
59 #include <QPicture>
60 #include <QPushButton>
61 #include <QRadioButton>
62 #include <QSplitter>
63 #include <QTableWidget>
64 #include <QToolButton>
65 #include <QTreeView>
66 #include <QWizardPage>
67
68
69 HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, const QString& theTitle )
70 : HYDROGUI_Wizard( theModule, theTitle )
71 {
72   addPage( createObjectsPage() );
73   addPage( createGroupsPage() );
74   addPage( createLandCoversPage() );
75   addPage( createZonesPage() );
76   addPage( createLandCoverZonesPage() );
77 }
78
79 HYDROGUI_CalculationDlg::~HYDROGUI_CalculationDlg()
80 {
81 }
82
83 void HYDROGUI_CalculationDlg::reset()
84 {
85   myObjectName->clear();
86   HYDROGUI_ListModel::Object2VisibleList anObject2VisibleList;
87   myGeomObjects->setObjects(anObject2VisibleList);
88   myLandCovers->setObjects(anObject2VisibleList);
89   myPolylineName->clear();
90   myStricklerTableName->clear();
91   myAvailableGeomObjects->clear();
92   myAvailableLandCovers->clear();
93
94   // Activate the automatic mode
95   setMode( HYDROData_CalculationCase::AUTOMATIC );
96   setLandCoverMode( HYDROData_CalculationCase::AUTOMATIC );
97
98   // Reset the priority widget state
99   QList<Handle(HYDROData_Entity)> anObjects;
100   myPriorityWidget->setObjects( anObjects );
101   myLandCoverPriorityWidget->setObjects( anObjects );
102 }
103
104 QWizardPage* HYDROGUI_CalculationDlg::createObjectsPage() {
105   QWizardPage* aPage = new QWizardPage( mainFrame() );
106   QFrame* aFrame = new QFrame( aPage );
107
108   // Splitter
109   mySplitter = new QSplitter(Qt::Vertical);
110
111   // Top of the page
112   QWidget* aTopContainer = new QWidget;
113    
114   // calculation name
115   myObjectName = new QLineEdit( aPage );
116   myValidator = new HYDROGUI_NameValidator(module(), myObjectName);
117   myObjectName->setValidator( myValidator );
118
119   connect( myValidator, SIGNAL( emptyName() ), SLOT( onEmptyName() ) );
120   connect( myValidator, SIGNAL( alreadyExists( QString ) ), SLOT( onAlreadyExists( QString ) ) );
121
122   // polyline name
123   myPolylineName = new QComboBox( aPage );
124   connect( myPolylineName, SIGNAL( activated( const QString & ) ), 
125     SIGNAL( boundarySelected( const QString & ) ) );
126
127   // names labels
128   QLabel* aNameLabel = new QLabel( tr( "NAME" ), aPage );
129   QLabel* aLimitsLabel = new QLabel( tr( "LIMITS" ), aPage );
130
131   // mode selector (auto/manual)
132   QGroupBox* aModeGroup = new QGroupBox( tr( "MODE" ) );
133
134   QRadioButton* aManualRB = new QRadioButton( tr( "MANUAL" ), mainFrame() );
135   QRadioButton* anAutoRB = new QRadioButton( tr( "AUTO" ), mainFrame() );
136
137   myModeButtons = new QButtonGroup( mainFrame() );
138   myModeButtons->addButton( anAutoRB, HYDROData_CalculationCase::AUTOMATIC );
139   myModeButtons->addButton( aManualRB, HYDROData_CalculationCase::MANUAL );
140   
141   QBoxLayout* aModeSelectorLayout = new QHBoxLayout;
142   aModeSelectorLayout->setMargin( 5 );
143   aModeSelectorLayout->setSpacing( 5 );
144   aModeSelectorLayout->addWidget( anAutoRB );
145   aModeSelectorLayout->addWidget( aManualRB );
146   aModeGroup->setLayout( aModeSelectorLayout );
147
148   // geometry objects
149   QLabel* anObjectsLabel = new QLabel( tr( "CALCULATION_REFERENCE_OBJECTS" ) );
150   myGeomObjects = new HYDROGUI_OrderedListWidget( aPage, 16 );
151   myGeomObjects->setHiddenObjectsShown(true);
152   myGeomObjects->setVisibilityIconShown(false);
153   myGeomObjects->setContentsMargins(QMargins());
154  
155   // included geometry objects
156   QLabel* anIncludedLabel = new QLabel( tr( "INCLUDED_OBJECTS" ) );
157   myAvailableGeomObjects = new QListWidget( aPage );
158   myAvailableGeomObjects->setSelectionMode( QListWidget::ExtendedSelection );
159   myAvailableGeomObjects->setEditTriggers( QListWidget::NoEditTriggers );
160   myAvailableGeomObjects->setViewMode( QListWidget::ListMode );
161   myAvailableGeomObjects->setSortingEnabled( true );
162
163   // buttons
164   QFrame* aBtnsFrame = new QFrame;
165   QVBoxLayout* aBtnsLayout = new QVBoxLayout( aBtnsFrame );
166   aBtnsLayout->setMargin( 5 );
167   aBtnsLayout->setSpacing( 5 );
168   aBtnsFrame->setLayout( aBtnsLayout );
169   QPushButton* anAddBtn = new QPushButton( tr("INCLUDE"), aBtnsFrame );
170   QPushButton* aRemoveBtn = new QPushButton( tr("EXCLUDE"), aBtnsFrame );
171
172   // fill the butons frame with two buttons
173   aBtnsLayout->addWidget( anAddBtn );
174   aBtnsLayout->addWidget( aRemoveBtn );
175   aBtnsLayout->addStretch( 1 );
176   
177   // top of the page layout
178   
179   // objects frame
180   QFrame* anObjectsFrame = new QFrame( aPage );
181   anObjectsFrame->setFrameStyle( QFrame::Panel | QFrame::Raised );
182   QGridLayout* anObjsLayout = new QGridLayout( anObjectsFrame );
183   anObjsLayout->setMargin( 5 );
184   anObjsLayout->setSpacing( 5 );
185   anObjectsFrame->setLayout( anObjsLayout );
186   
187   // fill the objects frame with two lists, two labels and with buttons frame
188   anObjsLayout->addWidget( anObjectsLabel, 0, 0, Qt::AlignHCenter );
189   anObjsLayout->addWidget( anIncludedLabel, 0, 2, Qt::AlignHCenter );
190   anObjsLayout->addWidget( myAvailableGeomObjects, 1, 0 );
191   anObjsLayout->addWidget( aBtnsFrame, 1, 1, Qt::AlignHCenter );
192   anObjsLayout->addWidget( myGeomObjects, 1, 2 );
193   
194   // fill the top of the page
195   QGridLayout* aTopLayout = new QGridLayout;
196   aTopLayout->setMargin( 5 );
197   aTopLayout->setSpacing( 5 );
198   aTopLayout->setVerticalSpacing( 10 );
199   aTopLayout->addWidget( aNameLabel,     0, 0, Qt::AlignHCenter );
200   aTopLayout->addWidget( myObjectName,   0, 1 );
201   aTopLayout->addWidget( aLimitsLabel,   1, 0, Qt::AlignHCenter );
202   aTopLayout->addWidget( myPolylineName, 1, 1 );
203   aTopLayout->addWidget( aModeGroup, 2, 0, 1, 2 );
204   aTopLayout->addWidget( anObjectsFrame, 3, 0, 1, 2 );
205
206   aTopContainer->setLayout( aTopLayout );
207
208   // add the top of the page to the splitter
209   mySplitter->insertWidget(0, aTopContainer);
210   mySplitter->setStretchFactor(0, 2);
211
212   // Bottom of the page
213   myPriorityWidget = new HYDROGUI_PriorityWidget( mainFrame() );
214
215   QGroupBox* aPriorityGroup = new QGroupBox( tr( "PRIORITY" ) );
216   QBoxLayout* aPriorityLayout = new QHBoxLayout;
217   aPriorityLayout->setMargin( 5 );
218   aPriorityLayout->setSpacing( 5 );
219   aPriorityLayout->addWidget( myPriorityWidget );
220   aPriorityGroup->setLayout( aPriorityLayout );
221
222   // add the bottom of the page to the splitter
223   mySplitter->insertWidget(1, aPriorityGroup);
224   mySplitter->setStretchFactor(1, 1);
225
226   // Page layout
227   QVBoxLayout* aPageLayout = new QVBoxLayout;
228   aPageLayout->setMargin( 5 );
229   aPageLayout->setSpacing( 5 );
230   aPageLayout->addWidget( mySplitter );
231
232   aPage->setLayout( aPageLayout );
233
234   // Create selector
235   if ( module() ) {
236     HYDROGUI_ListSelector* aListSelector = 
237       new HYDROGUI_ListSelector( myGeomObjects, module()->getApp()->selectionMgr() );
238     aListSelector->setAutoBlock( true );
239   }
240
241   // Connections
242   connect( myModeButtons, SIGNAL( buttonClicked( int ) ), SIGNAL( changeMode( int ) ) );
243   connect( anAddBtn, SIGNAL( clicked() ), SIGNAL( addObjects() ) );
244   connect( aRemoveBtn, SIGNAL( clicked() ), SIGNAL( removeObjects() ) );
245
246   connect( myGeomObjects, SIGNAL( orderChanged() ), SLOT( onOrderChanged() ) );
247
248   return aPage;
249 }
250
251 QWizardPage* HYDROGUI_CalculationDlg::createGroupsPage() {
252   QWizardPage* aPage = new QWizardPage( mainFrame() );
253   QFrame* aFrame = new QFrame( aPage );
254
255   myGroups = new QListWidget( aPage );
256   myGroups->setSelectionMode( QListWidget::ExtendedSelection );
257   myGroups->setEditTriggers( QListWidget::NoEditTriggers );
258   myGroups->setViewMode( QListWidget::ListMode );
259   myGroups->setSortingEnabled( true );
260
261   myAvailableGroups = new QListWidget( aPage );
262   myAvailableGroups->setSelectionMode( QListWidget::ExtendedSelection );
263   myAvailableGroups->setEditTriggers( QListWidget::NoEditTriggers );
264   myAvailableGroups->setViewMode( QListWidget::ListMode );
265   myAvailableGroups->setSortingEnabled( true );
266
267   connect( myGroups, SIGNAL( itemSelectionChanged() ), 
268     SIGNAL( groupsSelected() ) );
269
270   QFrame* aGroupsFrame = new QFrame( aPage );
271   QGridLayout* aGroupsLayout = new QGridLayout( aGroupsFrame );
272   aGroupsLayout->setMargin( 5 );
273   aGroupsLayout->setSpacing( 5 );
274   aGroupsFrame->setLayout( aGroupsLayout );
275
276   QFrame* aBtnsFrame = new QFrame( aGroupsFrame );
277   QVBoxLayout* aBtnsLayout = new QVBoxLayout( aBtnsFrame );
278   aBtnsLayout->setMargin( 5 );
279   aBtnsLayout->setSpacing( 5 );
280   aBtnsFrame->setLayout( aBtnsLayout );
281   QPushButton* anAddBtn = new QPushButton( tr("INCLUDE"), aBtnsFrame );
282   QPushButton* aRemoveBtn = new QPushButton( tr("EXCLUDE"), aBtnsFrame );
283
284   // Fill the butons frame with two buttons
285   aBtnsLayout->addWidget( anAddBtn );
286   aBtnsLayout->addWidget( aRemoveBtn );
287   aBtnsLayout->addStretch( 1 );
288
289   QLabel* anIncludedLabel = new QLabel( tr( "INCLUDED_GROUPS" ), aGroupsFrame );
290   QLabel* anAvailableLabel = new QLabel( tr( "AVAILABLE_GROUPS" ), aGroupsFrame );
291
292   // Fill the objects frame with two lists, two labels and with buttons frame
293   aGroupsLayout->addWidget( anAvailableLabel, 0, 0, Qt::AlignHCenter );
294   aGroupsLayout->addWidget( anIncludedLabel, 0, 2, Qt::AlignHCenter );
295   aGroupsLayout->addWidget( myAvailableGroups, 1, 0 );
296   aGroupsLayout->addWidget( aBtnsFrame, 1, 1, Qt::AlignHCenter );
297   aGroupsLayout->addWidget( myGroups, 1, 2 );
298
299   // Fill the page
300   QGridLayout* aPageLayout = new QGridLayout( aPage );
301   aPageLayout->setMargin( 5 );
302   aPageLayout->setSpacing( 5 );
303   aPageLayout->setVerticalSpacing( 10 );
304   aPageLayout->addWidget( aGroupsFrame, 0, 0 );
305
306   aPage->setLayout( aPageLayout );
307
308   connect( anAddBtn, SIGNAL( clicked() ), SIGNAL( addGroups() ) );
309   connect( aRemoveBtn, SIGNAL( clicked() ), SIGNAL( removeGroups() ) );
310
311   return aPage;
312 }
313
314 QWizardPage* HYDROGUI_CalculationDlg::createLandCoversPage() {
315   QWizardPage* aPage = new QWizardPage( mainFrame() );
316   QFrame* aFrame = new QFrame( aPage );
317
318   // Splitter
319   myLandCoverSplitter = new QSplitter(Qt::Vertical);
320
321   // Top of the page
322   QWidget* aTopContainer = new QWidget;
323    
324   // Combo-box to choose Strickler table name
325   QLabel* aStricklerTableLabel = new QLabel( tr( "STRICKLER_TABLE" ), aPage );
326   myStricklerTableName = new QComboBox( aPage );
327   myStricklerTableName->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
328   connect( myStricklerTableName, SIGNAL( activated( const QString & ) ), 
329                                  SIGNAL( StricklerTableSelected( const QString & ) ) );
330
331   // Mode selector (auto/manual)
332   QGroupBox* aModeGroup = new QGroupBox( tr( "MODE" ) );
333
334   QRadioButton* aManualRB = new QRadioButton( tr( "MANUAL" ), mainFrame() );
335   QRadioButton* anAutoRB = new QRadioButton( tr( "AUTO" ), mainFrame() );
336
337   myLandCoverModeButtons = new QButtonGroup( mainFrame() );
338   myLandCoverModeButtons->addButton( anAutoRB, HYDROData_CalculationCase::AUTOMATIC );
339   myLandCoverModeButtons->addButton( aManualRB, HYDROData_CalculationCase::MANUAL );
340   
341   QBoxLayout* aModeSelectorLayout = new QHBoxLayout;
342   aModeSelectorLayout->setMargin( 5 );
343   aModeSelectorLayout->setSpacing( 5 );
344   aModeSelectorLayout->addWidget( anAutoRB );
345   aModeSelectorLayout->addWidget( aManualRB );
346   aModeGroup->setLayout( aModeSelectorLayout );
347
348   // Available land covers
349   QLabel* aLandCoversLabel = new QLabel( tr( "CALCULATION_REFERENCE_LAND_COVERS" ) );
350   myAvailableLandCovers = new QListWidget( aPage );
351   myAvailableLandCovers->setSelectionMode( QListWidget::ExtendedSelection );
352   myAvailableLandCovers->setEditTriggers( QListWidget::NoEditTriggers );
353   myAvailableLandCovers->setViewMode( QListWidget::ListMode );
354   myAvailableLandCovers->setSortingEnabled( true );
355  
356   // Included land covers
357   QLabel* anIncludedLabel = new QLabel( tr( "INCLUDED_LAND_COVERS" ) );
358   myLandCovers = new HYDROGUI_OrderedListWidget( aPage, 16 );
359   myLandCovers->setHiddenObjectsShown(true);
360   myLandCovers->setVisibilityIconShown(false);
361   myLandCovers->setContentsMargins(QMargins()); 
362
363   // Include/Exclude buttons
364   QFrame* aBtnsFrame = new QFrame;
365   QVBoxLayout* aBtnsLayout = new QVBoxLayout( aBtnsFrame );
366   aBtnsLayout->setMargin( 5 );
367   aBtnsLayout->setSpacing( 5 );
368   aBtnsFrame->setLayout( aBtnsLayout );
369   QPushButton* anAddBtn = new QPushButton( tr("INCLUDE"), aBtnsFrame );
370   QPushButton* aRemoveBtn = new QPushButton( tr("EXCLUDE"), aBtnsFrame );
371
372   // Fill the butons frame with two buttons
373   aBtnsLayout->addWidget( anAddBtn );
374   aBtnsLayout->addWidget( aRemoveBtn );
375   aBtnsLayout->addStretch( 1 );
376   
377   // Land covers frame
378   QFrame* aLandCoversFrame = new QFrame( aPage );
379   aLandCoversFrame->setFrameStyle( QFrame::Panel | QFrame::Raised );
380   QGridLayout* aLandCoversLayout = new QGridLayout( aLandCoversFrame );
381   aLandCoversLayout->setMargin( 5 );
382   aLandCoversLayout->setSpacing( 5 );
383   aLandCoversFrame->setLayout( aLandCoversLayout );
384   
385   // Fill the land covers frame with two lists, two labels and with buttons frame
386   aLandCoversLayout->addWidget( aLandCoversLabel, 0, 0, Qt::AlignHCenter );
387   aLandCoversLayout->addWidget( anIncludedLabel, 0, 2, Qt::AlignHCenter );
388   aLandCoversLayout->addWidget( myAvailableLandCovers, 1, 0 );
389   aLandCoversLayout->addWidget( aBtnsFrame, 1, 1, Qt::AlignHCenter );
390   aLandCoversLayout->addWidget( myLandCovers, 1, 2 );
391   
392   // Fill the top layout of the page
393   QGridLayout* aTopLayout = new QGridLayout;
394   aTopLayout->setMargin( 5 );
395   aTopLayout->setSpacing( 5 );
396   aTopLayout->setVerticalSpacing( 10 );
397   aTopLayout->addWidget( aStricklerTableLabel, 0, 0, Qt::AlignHCenter );
398   aTopLayout->addWidget( myStricklerTableName, 0, 1 );
399   aTopLayout->addWidget( aModeGroup, 1, 0, 1, 2 );
400   aTopLayout->addWidget( aLandCoversFrame, 2, 0, 1, 2 );
401
402   aTopContainer->setLayout( aTopLayout );
403
404   // Add the top of the page to the splitter
405   myLandCoverSplitter->insertWidget(0, aTopContainer);
406   myLandCoverSplitter->setStretchFactor(0, 2);
407
408   // Bottom of the page
409   myLandCoverPriorityWidget = new HYDROGUI_PriorityWidget( mainFrame() );
410   HYDROGUI_PriorityTableModel* aModel = 
411     dynamic_cast<HYDROGUI_PriorityTableModel*>( myLandCoverPriorityWidget->getTable()->model() );
412   if ( aModel )
413     aModel->setColumnCount( 3 );
414
415   QGroupBox* aPriorityGroup = new QGroupBox( tr( "PRIORITY" ) );
416   QBoxLayout* aPriorityLayout = new QHBoxLayout;
417   aPriorityLayout->setMargin( 5 );
418   aPriorityLayout->setSpacing( 5 );
419   aPriorityLayout->addWidget( myLandCoverPriorityWidget );
420   aPriorityGroup->setLayout( aPriorityLayout );
421
422   // Add the bottom of the page to the splitter
423   myLandCoverSplitter->insertWidget(1, aPriorityGroup);
424   myLandCoverSplitter->setStretchFactor(1, 1);
425
426   // Page layout
427   QVBoxLayout* aPageLayout = new QVBoxLayout;
428   aPageLayout->setMargin( 5 );
429   aPageLayout->setSpacing( 5 );
430   aPageLayout->addWidget( myLandCoverSplitter );
431
432   aPage->setLayout( aPageLayout );
433
434   // Create selector
435   if ( module() ) {
436     HYDROGUI_ListSelector* aListSelector = 
437       new HYDROGUI_ListSelector( myLandCovers, module()->getApp()->selectionMgr() );
438     aListSelector->setAutoBlock( true );
439   }
440
441   // Connections
442   connect( myLandCoverModeButtons, SIGNAL( buttonClicked( int ) ), SIGNAL( changeLandCoverMode( int ) ) );
443   connect( anAddBtn, SIGNAL( clicked() ), SIGNAL( addLandCovers() ) );
444   connect( aRemoveBtn, SIGNAL( clicked() ), SIGNAL( removeLandCovers() ) );
445
446   connect( myLandCovers, SIGNAL( orderLandCoverChanged() ), SLOT( onOrderLandCoverChanged() ) );
447
448   return aPage;
449 }
450
451 QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() {
452   QWizardPage* aPage = new QWizardPage( mainFrame() );
453   QFrame* aFrame = new QFrame( aPage );
454
455   QGridLayout* aLayout = new QGridLayout( aPage );
456   
457   myBrowser = new HYDROGUI_DataBrowser( module(), NULL, aPage );
458   myBrowser->setAutoOpenLevel( 3 );
459   aLayout->setMargin( 5 );
460   aLayout->setSpacing( 5 );
461
462   aLayout->addWidget( myBrowser, 0, 0, 1, 2 );
463
464   myBathymetryLabel = new QLabel( tr( "BATHYMETRY" ), aFrame );
465   myBathymetryChoice = new QComboBox( aFrame );
466
467   myBathymetryChoice->setVisible( false );
468   myBathymetryLabel->setVisible( false );
469
470   aLayout->addWidget( myBathymetryLabel, 1, 0 );
471   aLayout->addWidget( myBathymetryChoice, 1, 1 );
472
473   aPage->setLayout( aLayout );
474
475   connect( myBrowser, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
476   connect( myBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SIGNAL( clickedInZonesBrowser( SUIT_DataObject* ) ) );
477   connect( myBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
478   connect( myBathymetryChoice, SIGNAL( activated( int ) ), SLOT( onMergeTypeSelected( int ) ) );
479   connect( myBrowser, 
480       SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
481       SLOT( onZonesDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
482   connect( myBrowser, SIGNAL( newRegion() ), this, SLOT( OnNewRegion() ) );
483
484   return aPage;
485 }
486
487 QWizardPage* HYDROGUI_CalculationDlg::createLandCoverZonesPage() {
488   QWizardPage* aPage = new QWizardPage( mainFrame() );
489   QFrame* aFrame = new QFrame( aPage );
490
491   QGridLayout* aLayout = new QGridLayout( aPage );
492   
493   myLandCoverBrowser = new HYDROGUI_DataBrowser( module(), NULL, aPage );
494   myLandCoverBrowser->setAutoOpenLevel( 3 );
495   aLayout->setMargin( 5 );
496   aLayout->setSpacing( 5 );
497
498   aLayout->addWidget( myLandCoverBrowser, 0, 0, 1, 2 );
499
500   myStricklerTypeLabel = new QLabel( tr( "STRICKLER_TYPE" ), aFrame );
501   myStricklerTypeChoice = new QComboBox( aFrame );
502
503   myStricklerTypeLabel->setVisible( false );
504   myStricklerTypeChoice->setVisible( false );  
505
506   aLayout->addWidget( myBathymetryLabel, 1, 0 );
507   aLayout->addWidget( myBathymetryChoice, 1, 1 );
508
509   aPage->setLayout( aLayout );
510
511   // Connections
512   connect( myLandCoverBrowser, SIGNAL( dataChanged() ), SLOT( onDataLandCoverChanged() ) );
513   connect( myLandCoverBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SIGNAL( clickedInZonesBrowser( SUIT_DataObject* ) ) );
514   connect( myLandCoverBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onLandCoverZoneSelected( SUIT_DataObject* ) ) );
515   connect( myStricklerTypeChoice, SIGNAL( activated( int ) ), SLOT( onMergeStricklerTypeSelected( int ) ) );
516   connect( myLandCoverBrowser, 
517       SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
518       SLOT( onLandCoverZonesDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
519   connect( myLandCoverBrowser, SIGNAL( newRegion() ), this, SLOT( OnNewLandCoverRegion() ) );
520
521   return aPage;
522 }
523
524
525 bool HYDROGUI_CalculationDlg::acceptCurrent() const
526 {
527   QString anErrorMsg;
528
529   if ( false /*myGeomObjects->count() == 0*/ )
530   {
531     anErrorMsg = tr( "EMPTY_GEOMETRY_OBJECTS" );
532   }
533
534   if ( !anErrorMsg.isEmpty() )
535   {
536     anErrorMsg += "\n" + tr( "INPUT_VALID_DATA" );
537     
538     QString aTitle = tr( "INSUFFICIENT_INPUT_DATA" );
539     SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, anErrorMsg );
540   }
541
542   return anErrorMsg.isEmpty();
543 }
544
545 void HYDROGUI_CalculationDlg::onEmptyName()
546 {
547   QString aTitle = tr( "INSUFFICIENT_INPUT_DATA" );
548   QString aMessage = tr( "INCORRECT_OBJECT_NAME" ) + "\n" + tr( "INPUT_VALID_DATA" );
549   SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, aMessage );
550 }
551
552 void HYDROGUI_CalculationDlg::onAlreadyExists( QString theName )
553 {
554   QString aTitle = tr( "INSUFFICIENT_INPUT_DATA" );
555   QString aMessage = QObject::tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( theName ) +
556                      "\n" + tr( "INPUT_VALID_DATA" );
557   SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, aMessage );
558 }
559
560 void HYDROGUI_CalculationDlg::onZonesDropped( const QList<SUIT_DataObject*>& theList, 
561     SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction )
562 {
563   QList<SUIT_DataObject*> aZonesList;
564   HYDROGUI_Zone* aZone;
565   // Get a list of dropped zones
566   for ( int i = 0; i < theList.length(); i++ )
567   {
568     aZone = dynamic_cast<HYDROGUI_Zone*>( theList.at( i ) );
569     if ( aZone )
570     {
571       aZonesList.append( aZone );
572     }
573   }
574   if ( aZonesList.length() > 0 )
575   {
576     // Get the target region
577     HYDROGUI_NamedObject* aRegionsRoot = dynamic_cast<HYDROGUI_NamedObject*>(theTargetParent);
578     if ( aRegionsRoot )
579     {
580       // Create a new region
581       emit createRegion( aZonesList );
582     }
583     else
584     {
585       HYDROGUI_Region* aRegion = dynamic_cast<HYDROGUI_Region*>(theTargetParent);
586       if ( aRegion )
587       {
588         emit moveZones( theTargetParent, aZonesList );
589       }
590     }
591   }
592 }
593
594 void HYDROGUI_CalculationDlg::OnNewRegion()
595 {
596   emit createRegion( myBrowser->getSelected() );
597 }
598
599 void HYDROGUI_CalculationDlg::OnNewLandCoverRegion()
600 {
601   emit createLandCoverRegion( myLandCoverBrowser->getSelected() );
602 }
603
604 void HYDROGUI_CalculationDlg::onMergeTypeSelected( int theIndex )
605 {
606   int aType = myBathymetryChoice->itemData( theIndex ).toInt();
607   QString aText = myBathymetryChoice->itemText( theIndex );
608   emit setMergeType( aType, aText );
609 }
610
611 void HYDROGUI_CalculationDlg::onSelected( SUIT_DataObject* theObject )
612 {
613   bool doShow = false;
614   HYDROGUI_Zone* aZone = dynamic_cast<HYDROGUI_Zone*>( theObject );
615   if ( aZone )
616   {
617     doShow = aZone->isMergingNeed();
618   }
619
620   if ( doShow )
621   {
622     // Fill the merge type combo box
623     bool prevBlock = myBathymetryChoice->blockSignals( true );
624     myCurrentZone = aZone;
625     myBathymetryChoice->clear();
626     myBathymetryChoice->addItem( tr("MERGE_UNKNOWN"), HYDROData_Zone::Merge_UNKNOWN );
627     myBathymetryChoice->addItem( tr("MERGE_ZMIN"), HYDROData_Zone::Merge_ZMIN );
628     myBathymetryChoice->addItem( tr("MERGE_ZMAX"), HYDROData_Zone::Merge_ZMAX );
629     QStringList aList = aZone->getAltitudes();
630     for ( int i = 0; i < aList.length(); i++ )
631     {
632       myBathymetryChoice->addItem( aList.at( i ), HYDROData_Zone::Merge_Object );
633     }
634     // Select the current choice if any
635     int aCurIndex = 0;
636     switch ( aZone->getMergeType() )
637     {
638       case HYDROData_Zone::Merge_ZMIN:
639         aCurIndex = 1;
640         break;
641       case HYDROData_Zone::Merge_ZMAX:
642         aCurIndex = 2;
643         break;
644       case HYDROData_Zone::Merge_Object:
645         aCurIndex = 3 + aList.indexOf( aZone->text( HYDROGUI_DataObject::AltitudeObjId ) );
646         break;
647       default:
648         aCurIndex = 0; // Select unknown by default
649     }
650     myBathymetryChoice->setCurrentIndex( aCurIndex );
651     myBathymetryChoice->blockSignals( prevBlock );
652   }
653
654   myBathymetryChoice->setVisible( doShow );
655   myBathymetryChoice->setEnabled( getMode() == HYDROData_CalculationCase::MANUAL );
656   myBathymetryLabel->setVisible( doShow );
657 }
658
659 void HYDROGUI_CalculationDlg::onLandCoverZoneSelected( SUIT_DataObject* theObject )
660 {
661   // TODO: implement this function
662 }
663
664 void HYDROGUI_CalculationDlg::onMergeStricklerTypeSelected( int theIndex )
665 {
666   // TODO: implement this function
667 }
668
669 void HYDROGUI_CalculationDlg::onLandCoverZonesDropped( const QList<SUIT_DataObject*>& theList, 
670     SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction )
671 {
672   // TODO: implement this function
673 }
674
675 void HYDROGUI_CalculationDlg::setObjectName( const QString& theName )
676 {
677   myObjectName->setText( theName );
678 }
679
680 QString HYDROGUI_CalculationDlg::getObjectName() const
681 {
682   return myObjectName->text();
683 }
684
685 void moveItems( QListWidget* theSource, QListWidget* theDest, const QStringList& theObjects )
686 {
687   QList<QListWidgetItem*> aFoundItems;
688   int anIdx;
689   QListWidgetItem* anItem;
690
691   for ( int i = 0, n = theObjects.length(); i < n; ++i )
692   {
693     QString anObjName = theObjects.at( i );
694     aFoundItems = theSource->findItems( anObjName, Qt::MatchExactly );
695     for ( anIdx = 0; anIdx < aFoundItems.length(); anIdx++ )
696     {
697       anItem = aFoundItems.at( anIdx );
698       // Remove this object from available objects list
699       anItem = theSource->takeItem( theSource->row( anItem ) );
700       // Add the item to the included objects list
701       theDest->addItem( anItem );
702     }
703   }
704 }
705
706 void HYDROGUI_CalculationDlg::includeGeomObjects( const QStringList& theObjects )
707 {
708   QList<QListWidgetItem*> aFoundItems;
709   foreach ( const QString& anObjName, theObjects ) {
710     // Hide the object in the available objects list
711     aFoundItems = myAvailableGeomObjects->findItems( anObjName, Qt::MatchExactly );
712     foreach ( QListWidgetItem* anItem, aFoundItems ) {
713       anItem->setHidden( true );
714     }
715
716     // Add the object to the list of included objects
717     Handle(HYDROData_Entity) anObject = 
718       HYDROGUI_Tool::FindObjectByName( module(), anObjName );
719     myGeomObjects->addObject( HYDROGUI_ListModel::Object2Visible( anObject, true ) );
720   }
721
722   myPriorityWidget->setObjects( getGeometryObjects() );
723 }
724
725 void HYDROGUI_CalculationDlg::excludeGeomObjects( const QStringList& theObjects )
726 {
727   QList<QListWidgetItem*> aFoundItems;
728   foreach ( const QString& anObjName, theObjects ) {
729     // Set visible the object in the available objects list
730     aFoundItems = myAvailableGeomObjects->findItems( anObjName, Qt::MatchExactly );
731     foreach ( QListWidgetItem* anItem, aFoundItems ) {
732       anItem->setHidden( false );
733     }
734
735     // Remove the object from the list of included objects
736     myGeomObjects->removeObjectByName( anObjName );
737   }
738
739   myPriorityWidget->setObjects( getGeometryObjects() );
740 }
741
742 void HYDROGUI_CalculationDlg::setBoundary( const QString& theObjName )
743 {
744   bool isBlocked = myPolylineName->blockSignals( true );
745   myPolylineName->setCurrentIndex( myPolylineName->findText( theObjName ) );
746   myPolylineName->blockSignals( isBlocked );
747 }
748
749 void HYDROGUI_CalculationDlg::setPolylineNames( const QStringList& theObjects, const QStringList& theObjectsEntries )
750 {
751   myPolylineName->clear();
752   myPolylineName->addItem( "", "" ); // No boundary item
753
754   for ( int i = 0, n = theObjects.length(); i < n; ++i )
755   {
756     myPolylineName->addItem( theObjects.at( i ), theObjectsEntries.at( i ) );
757   }
758 }
759
760 void HYDROGUI_CalculationDlg::setStricklerTableNames( const QStringList& theObjects, const QStringList& theObjectsEntries )
761 {
762   myStricklerTableName->clear();
763
764   for ( int i = 0, n = theObjects.length(); i < n; ++i )
765   {
766     myStricklerTableName->addItem( theObjects.at( i ), theObjectsEntries.at( i ) );
767   }
768 }
769
770 void HYDROGUI_CalculationDlg::setAllGeomObjects( const QStringList& theObjects, const QStringList& theObjectsEntries )
771 {
772   myAvailableGeomObjects->clear();
773
774   for ( int i = 0, n = theObjects.length(); i < n; ++i )
775   {
776     QString anObjName = theObjects.at( i );
777
778     QListWidgetItem* aListItem = new QListWidgetItem( anObjName, myAvailableGeomObjects );
779     aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
780     aListItem->setData( Qt::UserRole, theObjectsEntries.at( i ) );
781   }
782 }
783
784 void HYDROGUI_CalculationDlg::setAllLandCovers( const QStringList& theObjects, const QStringList& theObjectsEntries )
785 {
786   myAvailableLandCovers->clear();
787
788   for ( int i = 0, n = theObjects.length(); i < n; ++i )
789   {
790     QString anObjName = theObjects.at( i );
791
792     QListWidgetItem* aListItem = new QListWidgetItem( anObjName, myAvailableLandCovers );
793     aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
794     aListItem->setData( Qt::UserRole, theObjectsEntries.at( i ) );
795   }
796 }
797
798 QStringList getSelected( QListWidget* theWidget )
799 {
800   QStringList aResList;
801   QList<QListWidgetItem*> aList = theWidget->selectedItems();
802   for ( int i = 0, n = aList.length(); i < n; ++i )
803   {
804     aResList.append( aList.at( i )->text() );
805   }
806   return aResList;
807 }
808
809 QStringList HYDROGUI_CalculationDlg::getSelectedGeomObjects() const
810 {
811   return myGeomObjects->getSelectedNames();
812 }
813
814 QStringList HYDROGUI_CalculationDlg::getSelectedLandCovers() const
815 {
816   return myLandCovers->getSelectedNames();
817 }
818
819 QStringList HYDROGUI_CalculationDlg::getAllGeomObjects() const
820 {
821   return myGeomObjects->getAllNames();
822 }
823
824 QStringList HYDROGUI_CalculationDlg::getAllLandCovers() const
825 {
826   return myLandCovers->getAllNames();
827 }
828
829 QStringList HYDROGUI_CalculationDlg::getSelectedAvailableGeomObjects() const
830 {
831   return getSelected( myAvailableGeomObjects );
832 }
833
834 QStringList HYDROGUI_CalculationDlg::getSelectedAvailableLandCovers() const
835 {
836   return getSelected( myAvailableLandCovers );
837 }
838
839 void HYDROGUI_CalculationDlg::setEditedObject( const Handle(HYDROData_CalculationCase) theCase )
840 {
841   myEditedObject = theCase;
842   myValidator->setEditedObject( theCase );
843
844   // Build the calculation case subtree
845   module()->getDataModel()->buildCaseTree( myBrowser->root(), myEditedObject, false );
846   
847   myBrowser->updateTree();
848   myBrowser->openLevels();
849   myBrowser->adjustColumnsWidth();
850   myBrowser->setAutoUpdate( true );
851   myBrowser->setUpdateModified( true );
852
853   // Build the calculation case subtree for Land Cover regions
854   module()->getDataModel()->buildCaseTree( myLandCoverBrowser->root(), myEditedObject, true );
855
856   myLandCoverBrowser->updateTree();
857   myLandCoverBrowser->openLevels();
858   myLandCoverBrowser->adjustColumnsWidth();
859   myLandCoverBrowser->setAutoUpdate( true );
860   myLandCoverBrowser->setUpdateModified( true );
861 }
862
863 HYDROGUI_Zone* HYDROGUI_CalculationDlg::getCurrentZone() const
864 {
865   return myCurrentZone;
866 }
867
868 void HYDROGUI_CalculationDlg::refreshZonesBrowser()
869 {
870   SUIT_DataObject* aRoot = myBrowser->root();
871   module()->getDataModel()->updateObjectTree( myEditedObject );
872   module()->getDataModel()->buildCaseTree( aRoot, myEditedObject, false );
873   myBrowser->updateTree( aRoot );
874 }
875
876 void HYDROGUI_CalculationDlg::onDataChanged()
877 {
878   SUIT_DataObject* aRoot = myBrowser->root();
879   module()->getDataModel()->buildCaseTree( aRoot, myEditedObject, false );
880   myBrowser->updateTree( aRoot );
881 }
882
883 void HYDROGUI_CalculationDlg::setAvailableGroups( const QStringList& theGroups )
884 {
885   myAvailableGroups->clear();
886   myGroups->clear();
887   foreach( QString aGroup, theGroups )
888     myAvailableGroups->addItem( aGroup );
889 }
890
891 QStringList HYDROGUI_CalculationDlg::getSelectedGroups() const
892 {
893   return getSelected( myGroups );
894 }
895
896 QStringList HYDROGUI_CalculationDlg::getSelectedAvailableGroups() const
897 {
898   return getSelected( myAvailableGroups );
899 }
900
901 void HYDROGUI_CalculationDlg::includeGroups( const QStringList& theObjects )
902 {
903   moveItems( myAvailableGroups, myGroups, theObjects );
904 }
905
906 void HYDROGUI_CalculationDlg::excludeGroups( const QStringList& theObjects )
907 {
908   moveItems( myGroups, myAvailableGroups, theObjects );
909 }
910
911 /**
912   Get creation mode.
913   @param theMode the mode
914 */
915 int HYDROGUI_CalculationDlg::getMode() const
916 {
917   return myModeButtons->checkedId();
918 }
919
920 /**
921   Set creation mode.
922   @param theMode the mode
923 */
924 void HYDROGUI_CalculationDlg::setMode( int theMode )
925 {
926   bool isBlocked = myModeButtons->blockSignals( true );
927   myModeButtons->button( theMode )->setChecked( true );
928   myModeButtons->blockSignals( isBlocked );
929
930   bool isAuto = ( theMode == HYDROData_CalculationCase::AUTOMATIC );
931
932   myGeomObjects->setOrderingEnabled( isAuto );
933   QWidget* aWidget = mySplitter->widget( 1 );
934   if ( aWidget ) {
935     aWidget->setVisible( isAuto );
936   }
937 }
938
939 /**
940   Get creation mode for land covers panel.
941   @param theMode the mode
942 */
943 int HYDROGUI_CalculationDlg::getLandCoverMode() const
944 {
945   return myLandCoverModeButtons->checkedId();
946 }
947
948 /**
949   Set creation mode for land cover panel.
950   @param theMode the mode
951 */
952 void HYDROGUI_CalculationDlg::setLandCoverMode( int theMode )
953 {
954   bool isBlocked = myLandCoverModeButtons->blockSignals( true );
955   myLandCoverModeButtons->button( theMode )->setChecked( true );
956   myLandCoverModeButtons->blockSignals( isBlocked );
957
958   bool isAuto = ( theMode == HYDROData_CalculationCase::AUTOMATIC );
959
960   myLandCovers->setOrderingEnabled( isAuto );
961   QWidget* aWidget = myLandCoverSplitter->widget( 1 );
962   if ( aWidget ) {
963     aWidget->setVisible( isAuto );
964   }
965 }
966
967 /**
968   Enable/disable zones drag'n'drop and renaming.
969   @param theIsEnabled if true - zones drag'n'drop and renaming will be enabled
970 */
971 void HYDROGUI_CalculationDlg::setEditZonesEnabled( const bool theIsEnabled )
972 {
973   myBrowser->setReadOnly( !theIsEnabled );
974 }
975
976 /**
977   Enable/disable land covers drag'n'drop and renaming.
978   @param theIsEnabled if true - land covers drag'n'drop and renaming will be enabled
979 */
980 void HYDROGUI_CalculationDlg::setEditLandCoversEnabled( const bool theIsEnabled )
981 {
982   myLandCoverBrowser->setReadOnly( !theIsEnabled );
983 }
984
985 /**
986   Get included geometry objects.
987   @return the list of geometry objects
988  */
989 QList<Handle(HYDROData_Entity)> HYDROGUI_CalculationDlg::getGeometryObjects()
990 {
991   QList<Handle(HYDROData_Entity)> anEntities = myGeomObjects->getObjects();
992   QList<Handle(HYDROData_Entity)> anObjects;
993
994   foreach ( Handle(HYDROData_Entity) anEntity, anEntities ) {
995     Handle(HYDROData_Object) anObj = Handle(HYDROData_Object)::DownCast( anEntity );
996     if ( anObj.IsNull() ) {
997       continue;
998     }
999
1000     anObjects << anObj;
1001   }
1002
1003   return anObjects;
1004 }
1005
1006 /**
1007   Get included land covers.
1008   @return the list of land covers
1009  */
1010 QList<Handle(HYDROData_Entity)> HYDROGUI_CalculationDlg::getLandCovers()
1011 {
1012   QList<Handle(HYDROData_Entity)> anEntities = myLandCovers->getObjects();
1013   QList<Handle(HYDROData_Entity)> aLandCovers;
1014
1015   foreach ( Handle(HYDROData_Entity) anEntity, anEntities ) {
1016     Handle(HYDROData_LandCover) aLandCover = Handle(HYDROData_LandCover)::DownCast( anEntity );
1017     if ( aLandCover.IsNull() ) {
1018       continue;
1019     }
1020
1021     aLandCovers << aLandCover;
1022   }
1023
1024   return aLandCovers;
1025 }
1026
1027 /**
1028   Get rules.
1029   @return the list of rules
1030  */
1031 HYDROData_ListOfRules HYDROGUI_CalculationDlg::getRules() const
1032 {
1033   return myPriorityWidget->getRules();
1034 }
1035
1036 /**
1037   Set rules.
1038   @param theRules the list of rules
1039  */
1040 void  HYDROGUI_CalculationDlg::setRules( const HYDROData_ListOfRules& theRules ) const
1041 {
1042   myPriorityWidget->setRules( theRules );
1043 }
1044
1045 /**
1046   Get rules defined for land covers.
1047   @return the list of rules
1048  */
1049 HYDROData_ListOfRules HYDROGUI_CalculationDlg::getLandCoverRules() const
1050 {
1051   return myLandCoverPriorityWidget->getRules();
1052 }
1053
1054 /**
1055   Set rules for land covers.
1056   @param theRules the list of rules
1057  */
1058 void  HYDROGUI_CalculationDlg::setLandCoverRules( const HYDROData_ListOfRules& theRules ) const
1059 {
1060   myLandCoverPriorityWidget->setRules( theRules );
1061 }
1062
1063 /**
1064   Slot called when objects order is changed.
1065  */
1066 void HYDROGUI_CalculationDlg::onOrderChanged()
1067 {
1068   bool isConfirmed = true;
1069   emit orderChanged( isConfirmed );
1070   if( isConfirmed )
1071     myPriorityWidget->setObjects( getGeometryObjects() );
1072   else
1073     myGeomObjects->undoLastMove();
1074 }
1075
1076 void HYDROGUI_CalculationDlg::setStricklerTable( const QString& theStricklerTableName, bool theBlockSignals )
1077 {
1078   bool isBlocked;
1079   if ( theBlockSignals )
1080     isBlocked = myStricklerTableName->blockSignals( true );
1081   
1082   myStricklerTableName->setCurrentIndex( myStricklerTableName->findText( theStricklerTableName ) );
1083
1084   if ( theBlockSignals )
1085     myStricklerTableName->blockSignals( isBlocked );
1086   else
1087     emit StricklerTableSelected( theStricklerTableName );
1088 }
1089
1090 void HYDROGUI_CalculationDlg::includeLandCovers( const QStringList& theLandCovers, bool theReset )
1091 {
1092   if ( theReset )
1093   {
1094     HYDROGUI_ListModel::Object2VisibleList anObject2VisibleList;
1095     myLandCovers->setObjects(anObject2VisibleList);
1096   }
1097         
1098   QList<QListWidgetItem*> aFoundItems;
1099   foreach ( const QString& anObjName, theLandCovers ) {
1100     // Hide the land cover in the available land covers list
1101     aFoundItems = myAvailableLandCovers->findItems( anObjName, Qt::MatchExactly );
1102     foreach ( QListWidgetItem* anItem, aFoundItems ) {
1103       anItem->setHidden( true );
1104     }
1105
1106     // Add the land cover to the list of included objects
1107     Handle(HYDROData_Entity) anObject = 
1108       HYDROGUI_Tool::FindObjectByName( module(), anObjName );
1109     myLandCovers->addObject( HYDROGUI_ListModel::Object2Visible( anObject, true ) );
1110   }
1111
1112   myLandCoverPriorityWidget->setObjects( getLandCovers() );
1113 }
1114
1115 void HYDROGUI_CalculationDlg::excludeLandCovers( const QStringList& theLandCovers )
1116 {
1117   QList<QListWidgetItem*> aFoundItems;
1118   foreach ( const QString& anObjName, theLandCovers ) {
1119     // Set visible the land cover in the available objects list
1120     aFoundItems = myAvailableLandCovers->findItems( anObjName, Qt::MatchExactly );
1121     foreach ( QListWidgetItem* anItem, aFoundItems ) {
1122       anItem->setHidden( false );
1123     }
1124
1125     // Remove the land cover from the list of included objects
1126     myLandCovers->removeObjectByName( anObjName );
1127   }
1128
1129   myLandCoverPriorityWidget->setObjects( getLandCovers() );
1130 }
1131
1132 void HYDROGUI_CalculationDlg::refreshLandCoverZonesBrowser()
1133 {
1134   SUIT_DataObject* aRoot = myLandCoverBrowser->root();
1135   module()->getDataModel()->updateObjectTree( myEditedObject );
1136   module()->getDataModel()->buildCaseTree( aRoot, myEditedObject, true );
1137   myLandCoverBrowser->updateTree( aRoot );
1138 }
1139
1140 /**
1141   Slot called when zones created on land covers are changed.
1142  */
1143 void HYDROGUI_CalculationDlg::onDataLandCoverChanged()
1144 {
1145   SUIT_DataObject* aRoot = myLandCoverBrowser->root();
1146   module()->getDataModel()->buildCaseTree( aRoot, myEditedObject, true );
1147   myLandCoverBrowser->updateTree( aRoot );
1148 }
1149
1150 /**
1151   Slot called when land covers order is changed.
1152  */
1153 void HYDROGUI_CalculationDlg::onOrderLandCoverChanged()
1154 {
1155   bool isConfirmed = true;
1156   emit orderLandCoverChanged( isConfirmed );
1157   if( isConfirmed )
1158     myLandCoverPriorityWidget->setObjects( getLandCovers() );
1159   else
1160     myLandCovers->undoLastMove();  
1161 }