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 );
96 QWizardPage* HYDROGUI_CalculationDlg::createObjectsPage() {
97 QWizardPage* aPage = new QWizardPage( mainFrame() );
98 QFrame* aFrame = new QFrame( aPage );
101 mySplitter = new QSplitter(Qt::Vertical);
104 QWidget* aTopContainer = new QWidget;
107 myObjectName = new QLineEdit( aPage );
108 myValidator = new HYDROGUI_NameValidator(module(), myObjectName);
109 myObjectName->setValidator( myValidator );
111 connect( myValidator, SIGNAL( emptyName() ), SLOT( onEmptyName() ) );
112 connect( myValidator, SIGNAL( alreadyExists( QString ) ), SLOT( onAlreadyExists( QString ) ) );
115 myPolylineName = new QComboBox( aPage );
116 connect( myPolylineName, SIGNAL( activated( const QString & ) ),
117 SIGNAL( boundarySelected( const QString & ) ) );
120 QLabel* aNameLabel = new QLabel( tr( "NAME" ), aPage );
121 QLabel* aLimitsLabel = new QLabel( tr( "LIMITS" ), aPage );
123 // mode selector (auto/manual)
124 QGroupBox* aModeGroup = new QGroupBox( tr( "MODE" ) );
126 QRadioButton* aManualRB = new QRadioButton( tr( "MANUAL" ), mainFrame() );
127 QRadioButton* anAutoRB = new QRadioButton( tr( "AUTO" ), mainFrame() );
129 myModeButtons = new QButtonGroup( mainFrame() );
130 myModeButtons->addButton( anAutoRB, HYDROData_CalculationCase::AUTOMATIC );
131 myModeButtons->addButton( aManualRB, HYDROData_CalculationCase::MANUAL );
133 QBoxLayout* aModeSelectorLayout = new QHBoxLayout;
134 aModeSelectorLayout->setMargin( 5 );
135 aModeSelectorLayout->setSpacing( 5 );
136 aModeSelectorLayout->addWidget( anAutoRB );
137 aModeSelectorLayout->addWidget( aManualRB );
138 aModeGroup->setLayout( aModeSelectorLayout );
141 QLabel* anObjectsLabel = new QLabel( tr( "CALCULATION_REFERENCE_OBJECTS" ) );
142 myGeomObjects = new HYDROGUI_OrderedListWidget( aPage, 16 );
143 myGeomObjects->setHiddenObjectsShown(true);
144 myGeomObjects->setVisibilityIconShown(false);
145 myGeomObjects->setContentsMargins(QMargins());
147 // included geometry objects
148 QLabel* anIncludedLabel = new QLabel( tr( "INCLUDED_OBJECTS" ) );
149 myAvailableGeomObjects = new QListWidget( aPage );
150 myAvailableGeomObjects->setSelectionMode( QListWidget::ExtendedSelection );
151 myAvailableGeomObjects->setEditTriggers( QListWidget::NoEditTriggers );
152 myAvailableGeomObjects->setViewMode( QListWidget::ListMode );
153 myAvailableGeomObjects->setSortingEnabled( true );
156 QFrame* aBtnsFrame = new QFrame;
157 QVBoxLayout* aBtnsLayout = new QVBoxLayout( aBtnsFrame );
158 aBtnsLayout->setMargin( 5 );
159 aBtnsLayout->setSpacing( 5 );
160 aBtnsFrame->setLayout( aBtnsLayout );
161 QPushButton* anAddBtn = new QPushButton( tr("INCLUDE"), aBtnsFrame );
162 QPushButton* aRemoveBtn = new QPushButton( tr("EXCLUDE"), aBtnsFrame );
164 // fill the butons frame with two buttons
165 aBtnsLayout->addWidget( anAddBtn );
166 aBtnsLayout->addWidget( aRemoveBtn );
167 aBtnsLayout->addStretch( 1 );
169 // top of the page layout
172 QFrame* anObjectsFrame = new QFrame( aPage );
173 anObjectsFrame->setFrameStyle( QFrame::Panel | QFrame::Raised );
174 QGridLayout* anObjsLayout = new QGridLayout( anObjectsFrame );
175 anObjsLayout->setMargin( 5 );
176 anObjsLayout->setSpacing( 5 );
177 anObjectsFrame->setLayout( anObjsLayout );
179 // fill the objects frame with two lists, two labels and with buttons frame
180 anObjsLayout->addWidget( anObjectsLabel, 0, 0, Qt::AlignHCenter );
181 anObjsLayout->addWidget( anIncludedLabel, 0, 2, Qt::AlignHCenter );
182 anObjsLayout->addWidget( myAvailableGeomObjects, 1, 0, Qt::AlignHCenter );
183 anObjsLayout->addWidget( aBtnsFrame, 1, 1, Qt::AlignHCenter );
184 anObjsLayout->addWidget( myGeomObjects, 1, 2, Qt::AlignHCenter );
186 // fill the top of the page
187 QGridLayout* aTopLayout = new QGridLayout;
188 aTopLayout->setMargin( 5 );
189 aTopLayout->setSpacing( 5 );
190 aTopLayout->setVerticalSpacing( 10 );
191 aTopLayout->addWidget( aNameLabel, 0, 0, Qt::AlignHCenter );
192 aTopLayout->addWidget( myObjectName, 0, 1 );
193 aTopLayout->addWidget( aLimitsLabel, 1, 0, Qt::AlignHCenter );
194 aTopLayout->addWidget( myPolylineName, 1, 1 );
195 aTopLayout->addWidget( aModeGroup, 2, 0, 1, 2 );
196 aTopLayout->addWidget( anObjectsFrame, 3, 0, 1, 2, Qt::AlignHCenter );
198 aTopContainer->setLayout( aTopLayout );
200 // add the top of the page to the splitter
201 mySplitter->insertWidget(0, aTopContainer);
202 mySplitter->setStretchFactor(0, 2);
204 // Bottom of the page
205 myPriorityWidget = new HYDROGUI_PriorityWidget( mainFrame() );
207 QGroupBox* aPriorityGroup = new QGroupBox( tr( "PRIORITY" ) );
208 QBoxLayout* aPriorityLayout = new QHBoxLayout;
209 aPriorityLayout->setMargin( 5 );
210 aPriorityLayout->setSpacing( 5 );
211 aPriorityLayout->addWidget( myPriorityWidget );
212 aPriorityGroup->setLayout( aPriorityLayout );
214 // add the bottom of the page to the splitter
215 mySplitter->insertWidget(1, aPriorityGroup);
216 mySplitter->setStretchFactor(1, 1);
219 QVBoxLayout* aPageLayout = new QVBoxLayout;
220 aPageLayout->setMargin( 5 );
221 aPageLayout->setSpacing( 5 );
222 aPageLayout->addWidget( mySplitter );
224 aPage->setLayout( aPageLayout );
228 HYDROGUI_ListSelector* aListSelector =
229 new HYDROGUI_ListSelector( myGeomObjects, module()->getApp()->selectionMgr() );
230 aListSelector->setAutoBlock( true );
234 connect( myModeButtons, SIGNAL( buttonClicked( int ) ), SIGNAL( changeMode( int ) ) );
235 connect( anAddBtn, SIGNAL( clicked() ), SIGNAL( addObjects() ) );
236 connect( aRemoveBtn, SIGNAL( clicked() ), SIGNAL( removeObjects() ) );
241 QWizardPage* HYDROGUI_CalculationDlg::createGroupsPage() {
242 QWizardPage* aPage = new QWizardPage( mainFrame() );
243 QFrame* aFrame = new QFrame( aPage );
245 myGroups = new QListWidget( aPage );
246 myGroups->setSelectionMode( QListWidget::ExtendedSelection );
247 myGroups->setEditTriggers( QListWidget::NoEditTriggers );
248 myGroups->setViewMode( QListWidget::ListMode );
249 myGroups->setSortingEnabled( true );
251 myAvailableGroups = new QListWidget( aPage );
252 myAvailableGroups->setSelectionMode( QListWidget::ExtendedSelection );
253 myAvailableGroups->setEditTriggers( QListWidget::NoEditTriggers );
254 myAvailableGroups->setViewMode( QListWidget::ListMode );
255 myAvailableGroups->setSortingEnabled( true );
257 connect( myGroups, SIGNAL( itemSelectionChanged() ),
258 SIGNAL( groupsSelected() ) );
260 QFrame* aGroupsFrame = new QFrame( aPage );
261 QGridLayout* aGroupsLayout = new QGridLayout( aGroupsFrame );
262 aGroupsLayout->setMargin( 5 );
263 aGroupsLayout->setSpacing( 5 );
264 aGroupsFrame->setLayout( aGroupsLayout );
266 QFrame* aBtnsFrame = new QFrame( aGroupsFrame );
267 QVBoxLayout* aBtnsLayout = new QVBoxLayout( aBtnsFrame );
268 aBtnsLayout->setMargin( 5 );
269 aBtnsLayout->setSpacing( 5 );
270 aBtnsFrame->setLayout( aBtnsLayout );
271 QPushButton* anAddBtn = new QPushButton( tr("INCLUDE"), aBtnsFrame );
272 QPushButton* aRemoveBtn = new QPushButton( tr("EXCLUDE"), aBtnsFrame );
274 // Fill the butons frame with two buttons
275 aBtnsLayout->addWidget( anAddBtn );
276 aBtnsLayout->addWidget( aRemoveBtn );
277 aBtnsLayout->addStretch( 1 );
279 QLabel* anIncludedLabel = new QLabel( tr( "INCLUDED_GROUPS" ), aGroupsFrame );
280 QLabel* anAvailableLabel = new QLabel( tr( "AVAILABLE_GROUPS" ), aGroupsFrame );
282 // Fill the objects frame with two lists, two labels and with buttons frame
283 aGroupsLayout->addWidget( anAvailableLabel, 0, 0, Qt::AlignHCenter );
284 aGroupsLayout->addWidget( anIncludedLabel, 0, 2, Qt::AlignHCenter );
285 aGroupsLayout->addWidget( myAvailableGroups, 1, 0, Qt::AlignHCenter );
286 aGroupsLayout->addWidget( aBtnsFrame, 1, 1, Qt::AlignHCenter );
287 aGroupsLayout->addWidget( myGroups, 1, 2, Qt::AlignHCenter );
290 QGridLayout* aPageLayout = new QGridLayout( aPage );
291 aPageLayout->setMargin( 5 );
292 aPageLayout->setSpacing( 5 );
293 aPageLayout->setVerticalSpacing( 10 );
294 aPageLayout->addWidget( aGroupsFrame, 0, 0, Qt::AlignHCenter );
296 aPage->setLayout( aPageLayout );
298 connect( anAddBtn, SIGNAL( clicked() ), SIGNAL( addGroups() ) );
299 connect( aRemoveBtn, SIGNAL( clicked() ), SIGNAL( removeGroups() ) );
304 QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() {
305 QWizardPage* aPage = new QWizardPage( mainFrame() );
306 QFrame* aFrame = new QFrame( aPage );
308 QGridLayout* aLayout = new QGridLayout( aPage );
310 myBrowser = new HYDROGUI_DataBrowser( module(), NULL, aPage );
311 myBrowser->setAutoOpenLevel( 3 );
312 aLayout->setMargin( 5 );
313 aLayout->setSpacing( 5 );
315 aLayout->addWidget( myBrowser, 0, 0, 1, 2 );
317 myBatimetryLabel = new QLabel( tr( "BATHYMETRY" ), aFrame );
318 myBathymetryChoice = new QComboBox( aFrame );
320 myBathymetryChoice->setVisible( false );
321 myBatimetryLabel->setVisible( false );
323 aLayout->addWidget( myBatimetryLabel, 1, 0 );
324 aLayout->addWidget( myBathymetryChoice, 1, 1 );
326 aPage->setLayout( aLayout );
328 connect( myBrowser, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
329 connect( myBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SIGNAL( clickedInZonesBrowser( SUIT_DataObject* ) ) );
330 connect( myBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
331 connect( myBathymetryChoice, SIGNAL( activated( int ) ), SLOT( onMergeTypeSelected( int ) ) );
333 SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
334 SLOT( onZonesDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
340 bool HYDROGUI_CalculationDlg::acceptCurrent() const
344 if ( false /*myGeomObjects->count() == 0*/ )
346 anErrorMsg = tr( "EMPTY_GEOMETRY_OBJECTS" );
349 if ( !anErrorMsg.isEmpty() )
351 anErrorMsg += "\n" + tr( "INPUT_VALID_DATA" );
353 QString aTitle = tr( "INSUFFICIENT_INPUT_DATA" );
354 SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, anErrorMsg );
357 return anErrorMsg.isEmpty();
360 void HYDROGUI_CalculationDlg::onEmptyName()
362 QString aTitle = tr( "INSUFFICIENT_INPUT_DATA" );
363 QString aMessage = tr( "INCORRECT_OBJECT_NAME" ) + "\n" + tr( "INPUT_VALID_DATA" );
364 SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, aMessage );
367 void HYDROGUI_CalculationDlg::onAlreadyExists( QString theName )
369 QString aTitle = tr( "INSUFFICIENT_INPUT_DATA" );
370 QString aMessage = QObject::tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( theName ) +
371 "\n" + tr( "INPUT_VALID_DATA" );
372 SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, aMessage );
375 void HYDROGUI_CalculationDlg::onZonesDropped( const QList<SUIT_DataObject*>& theList,
376 SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction )
378 QList<SUIT_DataObject*> aZonesList;
379 HYDROGUI_Zone* aZone;
380 // Get a list of dropped zones
381 for ( int i = 0; i < theList.length(); i++ )
383 aZone = dynamic_cast<HYDROGUI_Zone*>( theList.at( i ) );
386 aZonesList.append( aZone );
389 if ( aZonesList.length() > 0 )
391 // Get the target region
392 HYDROGUI_NamedObject* aRegionsRoot = dynamic_cast<HYDROGUI_NamedObject*>(theTargetParent);
395 // Create a new region
396 emit createRegion( aZonesList );
400 HYDROGUI_Region* aRegion = dynamic_cast<HYDROGUI_Region*>(theTargetParent);
403 emit moveZones( theTargetParent, aZonesList );
409 void HYDROGUI_CalculationDlg::onMergeTypeSelected( int theIndex )
411 int aType = myBathymetryChoice->itemData( theIndex ).toInt();
412 QString aText = myBathymetryChoice->itemText( theIndex );
413 emit setMergeType( aType, aText );
416 void HYDROGUI_CalculationDlg::onSelected( SUIT_DataObject* theObject )
419 HYDROGUI_Zone* aZone = dynamic_cast<HYDROGUI_Zone*>( theObject );
422 doShow = aZone->isMergingNeed();
427 // Fill the merge type combo box
428 bool prevBlock = myBathymetryChoice->blockSignals( true );
429 myCurrentZone = aZone;
430 myBathymetryChoice->clear();
431 myBathymetryChoice->addItem( tr("MERGE_UNKNOWN"), HYDROData_Zone::Merge_UNKNOWN );
432 myBathymetryChoice->addItem( tr("MERGE_ZMIN"), HYDROData_Zone::Merge_ZMIN );
433 myBathymetryChoice->addItem( tr("MERGE_ZMAX"), HYDROData_Zone::Merge_ZMAX );
434 QStringList aList = aZone->getAltitudes();
435 for ( int i = 0; i < aList.length(); i++ )
437 myBathymetryChoice->addItem( aList.at( i ), HYDROData_Zone::Merge_Object );
439 // Select the current choice if any
441 switch ( aZone->getMergeType() )
443 case HYDROData_Zone::Merge_ZMIN:
446 case HYDROData_Zone::Merge_ZMAX:
449 case HYDROData_Zone::Merge_Object:
450 aCurIndex = 3 + aList.indexOf( aZone->text( HYDROGUI_DataObject::AltitudeObjId ) );
453 aCurIndex = 0; // Select unknown by default
455 myBathymetryChoice->setCurrentIndex( aCurIndex );
456 myBathymetryChoice->blockSignals( prevBlock );
459 myBathymetryChoice->setVisible( doShow );
460 myBatimetryLabel->setVisible( doShow );
463 void HYDROGUI_CalculationDlg::setObjectName( const QString& theName )
465 myObjectName->setText( theName );
468 QString HYDROGUI_CalculationDlg::getObjectName() const
470 return myObjectName->text();
473 void moveItems( QListWidget* theSource, QListWidget* theDest, const QStringList& theObjects )
475 QList<QListWidgetItem*> aFoundItems;
477 QListWidgetItem* anItem;
479 for ( int i = 0, n = theObjects.length(); i < n; ++i )
481 QString anObjName = theObjects.at( i );
482 aFoundItems = theSource->findItems( anObjName, Qt::MatchExactly );
483 for ( anIdx = 0; anIdx < aFoundItems.length(); anIdx++ )
485 anItem = aFoundItems.at( anIdx );
486 // Remove this object from available objects list
487 anItem = theSource->takeItem( theSource->row( anItem ) );
488 // Add the item to the included objects list
489 theDest->addItem( anItem );
494 void HYDROGUI_CalculationDlg::includeGeomObjects( const QStringList& theObjects )
496 HYDROGUI_ListModel::Object2VisibleList anObjectsToInclude;
497 QList<QListWidgetItem*> aFoundItems;
498 foreach ( const QString& anObjName, theObjects ) {
499 // Hide the object in the available objects list
500 aFoundItems = myAvailableGeomObjects->findItems( anObjName, Qt::MatchExactly );
501 foreach ( QListWidgetItem* anItem, aFoundItems ) {
502 anItem->setHidden( true );
505 // Add the object to the list of included objects
506 Handle(HYDROData_Entity) anObject =
507 HYDROGUI_Tool::FindObjectByName( module(), anObjName );
508 myGeomObjects->addObject( HYDROGUI_ListModel::Object2Visible( anObject, true ) );
511 myPriorityWidget->setObjects( getGeometryObjects() );
514 void HYDROGUI_CalculationDlg::excludeGeomObjects( const QStringList& theObjects )
516 QList<QListWidgetItem*> aFoundItems;
517 foreach ( const QString& anObjName, theObjects ) {
518 // Set visible the object in the available objects list
519 aFoundItems = myAvailableGeomObjects->findItems( anObjName, Qt::MatchExactly );
520 foreach ( QListWidgetItem* anItem, aFoundItems ) {
521 anItem->setHidden( false );
524 // Remove the object from the list of included objects
525 myGeomObjects->removeObjectByName( anObjName );
528 myPriorityWidget->setObjects( getGeometryObjects() );
531 void HYDROGUI_CalculationDlg::setBoundary( const QString& theObjName )
533 bool isBlocked = myPolylineName->blockSignals( true );
534 myPolylineName->setCurrentIndex( myPolylineName->findText( theObjName ) );
535 myPolylineName->blockSignals( isBlocked );
538 void HYDROGUI_CalculationDlg::setPolylineNames( const QStringList& theObjects, const QStringList& theObjectsEntries )
540 myPolylineName->clear();
541 myPolylineName->addItem( "", "" ); // No boundary item
543 for ( int i = 0, n = theObjects.length(); i < n; ++i )
545 myPolylineName->addItem( theObjects.at( i ), theObjectsEntries.at( i ) );
548 void HYDROGUI_CalculationDlg::setAllGeomObjects( const QStringList& theObjects, const QStringList& theObjectsEntries )
550 myAvailableGeomObjects->clear();
552 for ( int i = 0, n = theObjects.length(); i < n; ++i )
554 QString anObjName = theObjects.at( i );
556 QListWidgetItem* aListItem = new QListWidgetItem( anObjName, myAvailableGeomObjects );
557 aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
558 aListItem->setData( Qt::UserRole, theObjectsEntries.at( i ) );
562 QStringList getSelected( QListWidget* theWidget )
564 QStringList aResList;
565 QList<QListWidgetItem*> aList = theWidget->selectedItems();
566 for ( int i = 0, n = aList.length(); i < n; ++i )
568 aResList.append( aList.at( i )->text() );
573 QStringList HYDROGUI_CalculationDlg::getSelectedGeomObjects() const
575 return myGeomObjects->getSelectedNames();
578 QStringList HYDROGUI_CalculationDlg::getAllGeomObjects() const
580 return myGeomObjects->getAllNames();
583 QStringList HYDROGUI_CalculationDlg::getSelectedAvailableGeomObjects() const
585 return getSelected( myAvailableGeomObjects );
588 void HYDROGUI_CalculationDlg::setEditedObject( const Handle(HYDROData_CalculationCase) theCase )
590 myEditedObject = theCase;
591 myValidator->setEditedObject( theCase );
593 // Build the calculation case subtree
594 module()->getDataModel()->buildCaseTree( myBrowser->root(), myEditedObject );
596 myBrowser->updateTree();
597 myBrowser->openLevels();
598 myBrowser->adjustColumnsWidth();
599 myBrowser->setAutoUpdate( true );
600 myBrowser->setUpdateModified( true );
603 HYDROGUI_Zone* HYDROGUI_CalculationDlg::getCurrentZone() const
605 return myCurrentZone;
608 void HYDROGUI_CalculationDlg::refreshZonesBrowser()
610 SUIT_DataObject* aRoot = myBrowser->root();
611 module()->getDataModel()->updateObjectTree( myEditedObject );
612 module()->getDataModel()->buildCaseTree( aRoot, myEditedObject );
613 myBrowser->updateTree( aRoot );
616 void HYDROGUI_CalculationDlg::onDataChanged()
618 SUIT_DataObject* aRoot = myBrowser->root();
619 module()->getDataModel()->buildCaseTree( aRoot, myEditedObject );
620 myBrowser->updateTree( aRoot );
623 void HYDROGUI_CalculationDlg::setAvailableGroups( const QStringList& theGroups )
625 myAvailableGroups->clear();
627 foreach( QString aGroup, theGroups )
628 myAvailableGroups->addItem( aGroup );
631 QStringList HYDROGUI_CalculationDlg::getSelectedGroups() const
633 return getSelected( myGroups );
636 QStringList HYDROGUI_CalculationDlg::getSelectedAvailableGroups() const
638 return getSelected( myAvailableGroups );
641 void HYDROGUI_CalculationDlg::includeGroups( const QStringList& theObjects )
643 moveItems( myAvailableGroups, myGroups, theObjects );
646 void HYDROGUI_CalculationDlg::excludeGroups( const QStringList& theObjects )
648 moveItems( myGroups, myAvailableGroups, theObjects );
653 @param theMode the mode
655 int HYDROGUI_CalculationDlg::getMode() const
657 return myModeButtons->checkedId();
662 @param theMode the mode
664 void HYDROGUI_CalculationDlg::setMode( int theMode )
666 bool isBlocked = myModeButtons->blockSignals( true );
667 myModeButtons->button( theMode )->setChecked( true );
668 myModeButtons->blockSignals( isBlocked );
670 bool isAuto = ( theMode == HYDROData_CalculationCase::AUTOMATIC );
672 myGeomObjects->setOrderingEnabled( isAuto );
673 QWidget* aWidget = mySplitter->widget( 1 );
675 aWidget->setVisible( isAuto );
680 Enable/disable zones drag and drop.
681 @param theIsEnabled if true - zones drag and drop will be enabled
683 void HYDROGUI_CalculationDlg::setMoveZonesEnabled( const bool theIsEnabled )
685 //TODO: to be reimplemented
686 foreach ( QTreeView* aView, myBrowser->findChildren<QTreeView*>() ) {
687 aView->setDragEnabled ( theIsEnabled );
692 Get included geometry objects.
693 @return the list of geometry objects
695 QList<Handle(HYDROData_Object)> HYDROGUI_CalculationDlg::getGeometryObjects()
697 QList<Handle(HYDROData_Entity)> anEntities = myGeomObjects->getObjects();
698 QList<Handle(HYDROData_Object)> anObjects;
700 foreach ( Handle(HYDROData_Entity) anEntity, anEntities ) {
701 Handle(HYDROData_Object) anObj = Handle(HYDROData_Object)::DownCast( anEntity );
702 if ( anObj.IsNull() ) {
714 @return the list of rules
716 HYDROData_ListOfRules HYDROGUI_CalculationDlg::getRules() const
718 return myPriorityWidget->getRules();
723 @param theRules the list of rules
725 void HYDROGUI_CalculationDlg::setRules( const HYDROData_ListOfRules& theRules ) const
727 myPriorityWidget->setRules( theRules );