1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "HYDROGUI_CalculationDlg.h"
25 #include "HYDROGUI_ObjSelector.h"
26 #include "HYDROGUI_Tool.h"
27 #include "HYDROGUI_DataBrowser.h"
28 #include "HYDROGUI_DataModel.h"
29 #include "HYDROGUI_ListSelector.h"
30 #include "HYDROGUI_Module.h"
31 #include "HYDROGUI_DataObject.h"
32 #include "HYDROGUI_NameValidator.h"
33 #include "HYDROGUI_Region.h"
34 #include "HYDROGUI_Zone.h"
35 #include "HYDROGUI_OrderedListWidget.h"
36 #include "HYDROGUI_PriorityWidget.h"
38 #include <HYDROData_Document.h>
39 #include <HYDROData_Entity.h>
41 #include <CAM_Application.h>
42 #include <LightApp_DataObject.h>
44 #include <SUIT_DataObject.h>
45 #include <SUIT_FileDlg.h>
46 #include <SUIT_ResourceMgr.h>
47 #include <SUIT_Session.h>
48 #include <SUIT_Study.h>
50 #include <LightApp_Application.h>
51 #include <LightApp_SelectionMgr.h>
52 #include <SUIT_Desktop.h>
53 #include <SUIT_MessageBox.h>
55 #include <QButtonGroup>
61 #include <QListWidget>
63 #include <QPushButton>
64 #include <QRadioButton>
66 #include <QTableWidget>
67 #include <QToolButton>
69 #include <QWizardPage>
72 HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, const QString& theTitle )
73 : HYDROGUI_Wizard( theModule, theTitle )
75 addPage( createObjectsPage() );
76 addPage( createGroupsPage() );
77 addPage( createZonesPage() );
80 HYDROGUI_CalculationDlg::~HYDROGUI_CalculationDlg()
84 void HYDROGUI_CalculationDlg::reset()
86 myObjectName->clear();
87 HYDROGUI_ListModel::Object2VisibleList anObject2VisibleList;
88 myGeomObjects->setObjects(anObject2VisibleList);
89 myPolylineName->clear();
90 myAvailableGeomObjects->clear();
92 // Activate the automatic mode
93 setMode( HYDROData_CalculationCase::AUTOMATIC );
95 // Reset the priority widget state
96 QList<Handle(HYDROData_Object)> anObjects;
97 myPriorityWidget->setObjects( anObjects );
100 QWizardPage* HYDROGUI_CalculationDlg::createObjectsPage() {
101 QWizardPage* aPage = new QWizardPage( mainFrame() );
102 QFrame* aFrame = new QFrame( aPage );
105 mySplitter = new QSplitter(Qt::Vertical);
108 QWidget* aTopContainer = new QWidget;
111 myObjectName = new QLineEdit( aPage );
112 myValidator = new HYDROGUI_NameValidator(module(), myObjectName);
113 myObjectName->setValidator( myValidator );
115 connect( myValidator, SIGNAL( emptyName() ), SLOT( onEmptyName() ) );
116 connect( myValidator, SIGNAL( alreadyExists( QString ) ), SLOT( onAlreadyExists( QString ) ) );
119 myPolylineName = new QComboBox( aPage );
120 connect( myPolylineName, SIGNAL( activated( const QString & ) ),
121 SIGNAL( boundarySelected( const QString & ) ) );
124 QLabel* aNameLabel = new QLabel( tr( "NAME" ), aPage );
125 QLabel* aLimitsLabel = new QLabel( tr( "LIMITS" ), aPage );
127 // mode selector (auto/manual)
128 QGroupBox* aModeGroup = new QGroupBox( tr( "MODE" ) );
130 QRadioButton* aManualRB = new QRadioButton( tr( "MANUAL" ), mainFrame() );
131 QRadioButton* anAutoRB = new QRadioButton( tr( "AUTO" ), mainFrame() );
133 myModeButtons = new QButtonGroup( mainFrame() );
134 myModeButtons->addButton( anAutoRB, HYDROData_CalculationCase::AUTOMATIC );
135 myModeButtons->addButton( aManualRB, HYDROData_CalculationCase::MANUAL );
137 QBoxLayout* aModeSelectorLayout = new QHBoxLayout;
138 aModeSelectorLayout->setMargin( 5 );
139 aModeSelectorLayout->setSpacing( 5 );
140 aModeSelectorLayout->addWidget( anAutoRB );
141 aModeSelectorLayout->addWidget( aManualRB );
142 aModeGroup->setLayout( aModeSelectorLayout );
145 QLabel* anObjectsLabel = new QLabel( tr( "CALCULATION_REFERENCE_OBJECTS" ) );
146 myGeomObjects = new HYDROGUI_OrderedListWidget( aPage, 16 );
147 myGeomObjects->setHiddenObjectsShown(true);
148 myGeomObjects->setVisibilityIconShown(false);
149 myGeomObjects->setContentsMargins(QMargins());
151 // included geometry objects
152 QLabel* anIncludedLabel = new QLabel( tr( "INCLUDED_OBJECTS" ) );
153 myAvailableGeomObjects = new QListWidget( aPage );
154 myAvailableGeomObjects->setSelectionMode( QListWidget::ExtendedSelection );
155 myAvailableGeomObjects->setEditTriggers( QListWidget::NoEditTriggers );
156 myAvailableGeomObjects->setViewMode( QListWidget::ListMode );
157 myAvailableGeomObjects->setSortingEnabled( true );
160 QFrame* aBtnsFrame = new QFrame;
161 QVBoxLayout* aBtnsLayout = new QVBoxLayout( aBtnsFrame );
162 aBtnsLayout->setMargin( 5 );
163 aBtnsLayout->setSpacing( 5 );
164 aBtnsFrame->setLayout( aBtnsLayout );
165 QPushButton* anAddBtn = new QPushButton( tr("INCLUDE"), aBtnsFrame );
166 QPushButton* aRemoveBtn = new QPushButton( tr("EXCLUDE"), aBtnsFrame );
168 // fill the butons frame with two buttons
169 aBtnsLayout->addWidget( anAddBtn );
170 aBtnsLayout->addWidget( aRemoveBtn );
171 aBtnsLayout->addStretch( 1 );
173 // top of the page layout
176 QFrame* anObjectsFrame = new QFrame( aPage );
177 anObjectsFrame->setFrameStyle( QFrame::Panel | QFrame::Raised );
178 QGridLayout* anObjsLayout = new QGridLayout( anObjectsFrame );
179 anObjsLayout->setMargin( 5 );
180 anObjsLayout->setSpacing( 5 );
181 anObjectsFrame->setLayout( anObjsLayout );
183 // fill the objects frame with two lists, two labels and with buttons frame
184 anObjsLayout->addWidget( anObjectsLabel, 0, 0, Qt::AlignHCenter );
185 anObjsLayout->addWidget( anIncludedLabel, 0, 2, Qt::AlignHCenter );
186 anObjsLayout->addWidget( myAvailableGeomObjects, 1, 0, Qt::AlignHCenter );
187 anObjsLayout->addWidget( aBtnsFrame, 1, 1, Qt::AlignHCenter );
188 anObjsLayout->addWidget( myGeomObjects, 1, 2, Qt::AlignHCenter );
190 // fill the top of the page
191 QGridLayout* aTopLayout = new QGridLayout;
192 aTopLayout->setMargin( 5 );
193 aTopLayout->setSpacing( 5 );
194 aTopLayout->setVerticalSpacing( 10 );
195 aTopLayout->addWidget( aNameLabel, 0, 0, Qt::AlignHCenter );
196 aTopLayout->addWidget( myObjectName, 0, 1 );
197 aTopLayout->addWidget( aLimitsLabel, 1, 0, Qt::AlignHCenter );
198 aTopLayout->addWidget( myPolylineName, 1, 1 );
199 aTopLayout->addWidget( aModeGroup, 2, 0, 1, 2 );
200 aTopLayout->addWidget( anObjectsFrame, 3, 0, 1, 2, Qt::AlignHCenter );
202 aTopContainer->setLayout( aTopLayout );
204 // add the top of the page to the splitter
205 mySplitter->insertWidget(0, aTopContainer);
206 mySplitter->setStretchFactor(0, 2);
208 // Bottom of the page
209 myPriorityWidget = new HYDROGUI_PriorityWidget( mainFrame() );
211 QGroupBox* aPriorityGroup = new QGroupBox( tr( "PRIORITY" ) );
212 QBoxLayout* aPriorityLayout = new QHBoxLayout;
213 aPriorityLayout->setMargin( 5 );
214 aPriorityLayout->setSpacing( 5 );
215 aPriorityLayout->addWidget( myPriorityWidget );
216 aPriorityGroup->setLayout( aPriorityLayout );
218 // add the bottom of the page to the splitter
219 mySplitter->insertWidget(1, aPriorityGroup);
220 mySplitter->setStretchFactor(1, 1);
223 QVBoxLayout* aPageLayout = new QVBoxLayout;
224 aPageLayout->setMargin( 5 );
225 aPageLayout->setSpacing( 5 );
226 aPageLayout->addWidget( mySplitter );
228 aPage->setLayout( aPageLayout );
232 HYDROGUI_ListSelector* aListSelector =
233 new HYDROGUI_ListSelector( myGeomObjects, module()->getApp()->selectionMgr() );
234 aListSelector->setAutoBlock( true );
238 connect( myModeButtons, SIGNAL( buttonClicked( int ) ), SIGNAL( changeMode( int ) ) );
239 connect( anAddBtn, SIGNAL( clicked() ), SIGNAL( addObjects() ) );
240 connect( aRemoveBtn, SIGNAL( clicked() ), SIGNAL( removeObjects() ) );
245 QWizardPage* HYDROGUI_CalculationDlg::createGroupsPage() {
246 QWizardPage* aPage = new QWizardPage( mainFrame() );
247 QFrame* aFrame = new QFrame( aPage );
249 myGroups = new QListWidget( aPage );
250 myGroups->setSelectionMode( QListWidget::ExtendedSelection );
251 myGroups->setEditTriggers( QListWidget::NoEditTriggers );
252 myGroups->setViewMode( QListWidget::ListMode );
253 myGroups->setSortingEnabled( true );
255 myAvailableGroups = new QListWidget( aPage );
256 myAvailableGroups->setSelectionMode( QListWidget::ExtendedSelection );
257 myAvailableGroups->setEditTriggers( QListWidget::NoEditTriggers );
258 myAvailableGroups->setViewMode( QListWidget::ListMode );
259 myAvailableGroups->setSortingEnabled( true );
261 connect( myGroups, SIGNAL( itemSelectionChanged() ),
262 SIGNAL( groupsSelected() ) );
264 QFrame* aGroupsFrame = new QFrame( aPage );
265 QGridLayout* aGroupsLayout = new QGridLayout( aGroupsFrame );
266 aGroupsLayout->setMargin( 5 );
267 aGroupsLayout->setSpacing( 5 );
268 aGroupsFrame->setLayout( aGroupsLayout );
270 QFrame* aBtnsFrame = new QFrame( aGroupsFrame );
271 QVBoxLayout* aBtnsLayout = new QVBoxLayout( aBtnsFrame );
272 aBtnsLayout->setMargin( 5 );
273 aBtnsLayout->setSpacing( 5 );
274 aBtnsFrame->setLayout( aBtnsLayout );
275 QPushButton* anAddBtn = new QPushButton( tr("INCLUDE"), aBtnsFrame );
276 QPushButton* aRemoveBtn = new QPushButton( tr("EXCLUDE"), aBtnsFrame );
278 // Fill the butons frame with two buttons
279 aBtnsLayout->addWidget( anAddBtn );
280 aBtnsLayout->addWidget( aRemoveBtn );
281 aBtnsLayout->addStretch( 1 );
283 QLabel* anIncludedLabel = new QLabel( tr( "INCLUDED_GROUPS" ), aGroupsFrame );
284 QLabel* anAvailableLabel = new QLabel( tr( "AVAILABLE_GROUPS" ), aGroupsFrame );
286 // Fill the objects frame with two lists, two labels and with buttons frame
287 aGroupsLayout->addWidget( anAvailableLabel, 0, 0, Qt::AlignHCenter );
288 aGroupsLayout->addWidget( anIncludedLabel, 0, 2, Qt::AlignHCenter );
289 aGroupsLayout->addWidget( myAvailableGroups, 1, 0, Qt::AlignHCenter );
290 aGroupsLayout->addWidget( aBtnsFrame, 1, 1, Qt::AlignHCenter );
291 aGroupsLayout->addWidget( myGroups, 1, 2, Qt::AlignHCenter );
294 QGridLayout* aPageLayout = new QGridLayout( aPage );
295 aPageLayout->setMargin( 5 );
296 aPageLayout->setSpacing( 5 );
297 aPageLayout->setVerticalSpacing( 10 );
298 aPageLayout->addWidget( aGroupsFrame, 0, 0, Qt::AlignHCenter );
300 aPage->setLayout( aPageLayout );
302 connect( anAddBtn, SIGNAL( clicked() ), SIGNAL( addGroups() ) );
303 connect( aRemoveBtn, SIGNAL( clicked() ), SIGNAL( removeGroups() ) );
308 QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() {
309 QWizardPage* aPage = new QWizardPage( mainFrame() );
310 QFrame* aFrame = new QFrame( aPage );
312 QGridLayout* aLayout = new QGridLayout( aPage );
314 myBrowser = new HYDROGUI_DataBrowser( module(), NULL, aPage );
315 myBrowser->setAutoOpenLevel( 3 );
316 aLayout->setMargin( 5 );
317 aLayout->setSpacing( 5 );
319 aLayout->addWidget( myBrowser, 0, 0, 1, 2 );
321 myBatimetryLabel = new QLabel( tr( "BATHYMETRY" ), aFrame );
322 myBathymetryChoice = new QComboBox( aFrame );
324 myBathymetryChoice->setVisible( false );
325 myBatimetryLabel->setVisible( false );
327 aLayout->addWidget( myBatimetryLabel, 1, 0 );
328 aLayout->addWidget( myBathymetryChoice, 1, 1 );
330 aPage->setLayout( aLayout );
332 connect( myBrowser, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
333 connect( myBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SIGNAL( clickedInZonesBrowser( SUIT_DataObject* ) ) );
334 connect( myBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
335 connect( myBathymetryChoice, SIGNAL( activated( int ) ), SLOT( onMergeTypeSelected( int ) ) );
337 SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
338 SLOT( onZonesDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
344 bool HYDROGUI_CalculationDlg::acceptCurrent() const
348 if ( false /*myGeomObjects->count() == 0*/ )
350 anErrorMsg = tr( "EMPTY_GEOMETRY_OBJECTS" );
353 if ( !anErrorMsg.isEmpty() )
355 anErrorMsg += "\n" + tr( "INPUT_VALID_DATA" );
357 QString aTitle = tr( "INSUFFICIENT_INPUT_DATA" );
358 SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, anErrorMsg );
361 return anErrorMsg.isEmpty();
364 void HYDROGUI_CalculationDlg::onEmptyName()
366 QString aTitle = tr( "INSUFFICIENT_INPUT_DATA" );
367 QString aMessage = tr( "INCORRECT_OBJECT_NAME" ) + "\n" + tr( "INPUT_VALID_DATA" );
368 SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, aMessage );
371 void HYDROGUI_CalculationDlg::onAlreadyExists( QString theName )
373 QString aTitle = tr( "INSUFFICIENT_INPUT_DATA" );
374 QString aMessage = QObject::tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( theName ) +
375 "\n" + tr( "INPUT_VALID_DATA" );
376 SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, aMessage );
379 void HYDROGUI_CalculationDlg::onZonesDropped( const QList<SUIT_DataObject*>& theList,
380 SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction )
382 QList<SUIT_DataObject*> aZonesList;
383 HYDROGUI_Zone* aZone;
384 // Get a list of dropped zones
385 for ( int i = 0; i < theList.length(); i++ )
387 aZone = dynamic_cast<HYDROGUI_Zone*>( theList.at( i ) );
390 aZonesList.append( aZone );
393 if ( aZonesList.length() > 0 )
395 // Get the target region
396 HYDROGUI_NamedObject* aRegionsRoot = dynamic_cast<HYDROGUI_NamedObject*>(theTargetParent);
399 // Create a new region
400 emit createRegion( aZonesList );
404 HYDROGUI_Region* aRegion = dynamic_cast<HYDROGUI_Region*>(theTargetParent);
407 emit moveZones( theTargetParent, aZonesList );
413 void HYDROGUI_CalculationDlg::onMergeTypeSelected( int theIndex )
415 int aType = myBathymetryChoice->itemData( theIndex ).toInt();
416 QString aText = myBathymetryChoice->itemText( theIndex );
417 emit setMergeType( aType, aText );
420 void HYDROGUI_CalculationDlg::onSelected( SUIT_DataObject* theObject )
423 HYDROGUI_Zone* aZone = dynamic_cast<HYDROGUI_Zone*>( theObject );
426 doShow = aZone->isMergingNeed();
431 // Fill the merge type combo box
432 bool prevBlock = myBathymetryChoice->blockSignals( true );
433 myCurrentZone = aZone;
434 myBathymetryChoice->clear();
435 myBathymetryChoice->addItem( tr("MERGE_UNKNOWN"), HYDROData_Zone::Merge_UNKNOWN );
436 myBathymetryChoice->addItem( tr("MERGE_ZMIN"), HYDROData_Zone::Merge_ZMIN );
437 myBathymetryChoice->addItem( tr("MERGE_ZMAX"), HYDROData_Zone::Merge_ZMAX );
438 QStringList aList = aZone->getAltitudes();
439 for ( int i = 0; i < aList.length(); i++ )
441 myBathymetryChoice->addItem( aList.at( i ), HYDROData_Zone::Merge_Object );
443 // Select the current choice if any
445 switch ( aZone->getMergeType() )
447 case HYDROData_Zone::Merge_ZMIN:
450 case HYDROData_Zone::Merge_ZMAX:
453 case HYDROData_Zone::Merge_Object:
454 aCurIndex = 3 + aList.indexOf( aZone->text( HYDROGUI_DataObject::AltitudeObjId ) );
457 aCurIndex = 0; // Select unknown by default
459 myBathymetryChoice->setCurrentIndex( aCurIndex );
460 myBathymetryChoice->blockSignals( prevBlock );
463 myBathymetryChoice->setVisible( doShow );
464 myBatimetryLabel->setVisible( doShow );
467 void HYDROGUI_CalculationDlg::setObjectName( const QString& theName )
469 myObjectName->setText( theName );
472 QString HYDROGUI_CalculationDlg::getObjectName() const
474 return myObjectName->text();
477 void moveItems( QListWidget* theSource, QListWidget* theDest, const QStringList& theObjects )
479 QList<QListWidgetItem*> aFoundItems;
481 QListWidgetItem* anItem;
483 for ( int i = 0, n = theObjects.length(); i < n; ++i )
485 QString anObjName = theObjects.at( i );
486 aFoundItems = theSource->findItems( anObjName, Qt::MatchExactly );
487 for ( anIdx = 0; anIdx < aFoundItems.length(); anIdx++ )
489 anItem = aFoundItems.at( anIdx );
490 // Remove this object from available objects list
491 anItem = theSource->takeItem( theSource->row( anItem ) );
492 // Add the item to the included objects list
493 theDest->addItem( anItem );
498 void HYDROGUI_CalculationDlg::includeGeomObjects( const QStringList& theObjects )
500 HYDROGUI_ListModel::Object2VisibleList anObjectsToInclude;
501 QList<QListWidgetItem*> aFoundItems;
502 foreach ( const QString& anObjName, theObjects ) {
503 // Hide the object in the available objects list
504 aFoundItems = myAvailableGeomObjects->findItems( anObjName, Qt::MatchExactly );
505 foreach ( QListWidgetItem* anItem, aFoundItems ) {
506 anItem->setHidden( true );
509 // Add the object to the list of included objects
510 Handle(HYDROData_Entity) anObject =
511 HYDROGUI_Tool::FindObjectByName( module(), anObjName );
512 myGeomObjects->addObject( HYDROGUI_ListModel::Object2Visible( anObject, true ) );
515 myPriorityWidget->setObjects( getGeometryObjects() );
518 void HYDROGUI_CalculationDlg::excludeGeomObjects( const QStringList& theObjects )
520 QList<QListWidgetItem*> aFoundItems;
521 foreach ( const QString& anObjName, theObjects ) {
522 // Set visible the object in the available objects list
523 aFoundItems = myAvailableGeomObjects->findItems( anObjName, Qt::MatchExactly );
524 foreach ( QListWidgetItem* anItem, aFoundItems ) {
525 anItem->setHidden( false );
528 // Remove the object from the list of included objects
529 myGeomObjects->removeObjectByName( anObjName );
532 myPriorityWidget->setObjects( getGeometryObjects() );
535 void HYDROGUI_CalculationDlg::setBoundary( const QString& theObjName )
537 bool isBlocked = myPolylineName->blockSignals( true );
538 myPolylineName->setCurrentIndex( myPolylineName->findText( theObjName ) );
539 myPolylineName->blockSignals( isBlocked );
542 void HYDROGUI_CalculationDlg::setPolylineNames( const QStringList& theObjects, const QStringList& theObjectsEntries )
544 myPolylineName->clear();
545 myPolylineName->addItem( "", "" ); // No boundary item
547 for ( int i = 0, n = theObjects.length(); i < n; ++i )
549 myPolylineName->addItem( theObjects.at( i ), theObjectsEntries.at( i ) );
552 void HYDROGUI_CalculationDlg::setAllGeomObjects( const QStringList& theObjects, const QStringList& theObjectsEntries )
554 myAvailableGeomObjects->clear();
556 for ( int i = 0, n = theObjects.length(); i < n; ++i )
558 QString anObjName = theObjects.at( i );
560 QListWidgetItem* aListItem = new QListWidgetItem( anObjName, myAvailableGeomObjects );
561 aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
562 aListItem->setData( Qt::UserRole, theObjectsEntries.at( i ) );
566 QStringList getSelected( QListWidget* theWidget )
568 QStringList aResList;
569 QList<QListWidgetItem*> aList = theWidget->selectedItems();
570 for ( int i = 0, n = aList.length(); i < n; ++i )
572 aResList.append( aList.at( i )->text() );
577 QStringList HYDROGUI_CalculationDlg::getSelectedGeomObjects() const
579 return myGeomObjects->getSelectedNames();
582 QStringList HYDROGUI_CalculationDlg::getAllGeomObjects() const
584 return myGeomObjects->getAllNames();
587 QStringList HYDROGUI_CalculationDlg::getSelectedAvailableGeomObjects() const
589 return getSelected( myAvailableGeomObjects );
592 void HYDROGUI_CalculationDlg::setEditedObject( const Handle(HYDROData_CalculationCase) theCase )
594 myEditedObject = theCase;
595 myValidator->setEditedObject( theCase );
597 // Build the calculation case subtree
598 module()->getDataModel()->buildCaseTree( myBrowser->root(), myEditedObject );
600 myBrowser->updateTree();
601 myBrowser->openLevels();
602 myBrowser->adjustColumnsWidth();
603 myBrowser->setAutoUpdate( true );
604 myBrowser->setUpdateModified( true );
607 HYDROGUI_Zone* HYDROGUI_CalculationDlg::getCurrentZone() const
609 return myCurrentZone;
612 void HYDROGUI_CalculationDlg::refreshZonesBrowser()
614 SUIT_DataObject* aRoot = myBrowser->root();
615 module()->getDataModel()->updateObjectTree( myEditedObject );
616 module()->getDataModel()->buildCaseTree( aRoot, myEditedObject );
617 myBrowser->updateTree( aRoot );
620 void HYDROGUI_CalculationDlg::onDataChanged()
622 SUIT_DataObject* aRoot = myBrowser->root();
623 module()->getDataModel()->buildCaseTree( aRoot, myEditedObject );
624 myBrowser->updateTree( aRoot );
627 void HYDROGUI_CalculationDlg::setAvailableGroups( const QStringList& theGroups )
629 myAvailableGroups->clear();
631 foreach( QString aGroup, theGroups )
632 myAvailableGroups->addItem( aGroup );
635 QStringList HYDROGUI_CalculationDlg::getSelectedGroups() const
637 return getSelected( myGroups );
640 QStringList HYDROGUI_CalculationDlg::getSelectedAvailableGroups() const
642 return getSelected( myAvailableGroups );
645 void HYDROGUI_CalculationDlg::includeGroups( const QStringList& theObjects )
647 moveItems( myAvailableGroups, myGroups, theObjects );
650 void HYDROGUI_CalculationDlg::excludeGroups( const QStringList& theObjects )
652 moveItems( myGroups, myAvailableGroups, theObjects );
657 @param theMode the mode
659 int HYDROGUI_CalculationDlg::getMode() const
661 return myModeButtons->checkedId();
666 @param theMode the mode
668 void HYDROGUI_CalculationDlg::setMode( int theMode )
670 bool isBlocked = myModeButtons->blockSignals( true );
671 myModeButtons->button( theMode )->setChecked( true );
672 myModeButtons->blockSignals( isBlocked );
674 bool isAuto = ( theMode == HYDROData_CalculationCase::AUTOMATIC );
676 myGeomObjects->setOrderingEnabled( isAuto );
677 QWidget* aWidget = mySplitter->widget( 1 );
679 aWidget->setVisible( isAuto );
684 Enable/disable zones drag and drop.
685 @param theIsEnabled if true - zones drag and drop will be enabled
687 void HYDROGUI_CalculationDlg::setMoveZonesEnabled( const bool theIsEnabled )
689 //TODO: to be reimplemented
690 foreach ( QTreeView* aView, myBrowser->findChildren<QTreeView*>() ) {
691 aView->setDragEnabled ( theIsEnabled );
696 Get included geometry objects.
697 @return the list of geometry objects
699 QList<Handle(HYDROData_Object)> HYDROGUI_CalculationDlg::getGeometryObjects()
701 QList<Handle(HYDROData_Entity)> anEntities = myGeomObjects->getObjects();
702 QList<Handle(HYDROData_Object)> anObjects;
704 foreach ( Handle(HYDROData_Entity) anEntity, anEntities ) {
705 Handle(HYDROData_Object) anObj = Handle(HYDROData_Object)::DownCast( anEntity );
706 if ( anObj.IsNull() ) {
718 @return the list of rules
720 HYDROData_ListOfRules HYDROGUI_CalculationDlg::getRules() const
722 return myPriorityWidget->getRules();
727 @param theRules the list of rules
729 void HYDROGUI_CalculationDlg::setRules( const HYDROData_ListOfRules& theRules ) const
731 myPriorityWidget->setRules( theRules );