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.
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.
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
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_CalculationDlg.h"
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"
34 #include <HYDROData_Document.h>
35 #include <HYDROData_Entity.h>
37 #include <CAM_Application.h>
38 #include <LightApp_DataObject.h>
40 #include <SUIT_DataObject.h>
41 #include <SUIT_FileDlg.h>
42 #include <SUIT_ResourceMgr.h>
43 #include <SUIT_Session.h>
44 #include <SUIT_Study.h>
46 #include <LightApp_Application.h>
47 #include <LightApp_SelectionMgr.h>
48 #include <SUIT_Desktop.h>
49 #include <SUIT_MessageBox.h>
51 #include <QButtonGroup>
57 #include <QListWidget>
59 #include <QPushButton>
60 #include <QRadioButton>
62 #include <QTableWidget>
63 #include <QToolButton>
65 #include <QWizardPage>
68 HYDROGUI_CalculationDlg::HYDROGUI_CalculationDlg( HYDROGUI_Module* theModule, const QString& theTitle )
69 : HYDROGUI_Wizard( theModule, theTitle )
71 addPage( createObjectsPage() );
72 addPage( createGroupsPage() );
73 addPage( createZonesPage() );
76 HYDROGUI_CalculationDlg::~HYDROGUI_CalculationDlg()
80 void HYDROGUI_CalculationDlg::reset()
82 myObjectName->clear();
83 HYDROGUI_ListModel::Object2VisibleList anObject2VisibleList;
84 myGeomObjects->setObjects(anObject2VisibleList);
85 myPolylineName->clear();
86 myAvailableGeomObjects->clear();
88 // Activate the automatic mode
89 setMode( HYDROData_CalculationCase::AUTOMATIC );
91 // Reset the priority widget state
92 QList<Handle(HYDROData_Object)> anObjects;
93 myPriorityWidget->setObjects( anObjects );
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 );
183 anObjsLayout->addWidget( aBtnsFrame, 1, 1, Qt::AlignHCenter );
184 anObjsLayout->addWidget( myGeomObjects, 1, 2 );
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 );
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() ) );
238 connect( myGeomObjects, SIGNAL( orderChanged() ), SLOT( onOrderChanged() ) );
243 QWizardPage* HYDROGUI_CalculationDlg::createGroupsPage() {
244 QWizardPage* aPage = new QWizardPage( mainFrame() );
245 QFrame* aFrame = new QFrame( aPage );
247 myGroups = new QListWidget( aPage );
248 myGroups->setSelectionMode( QListWidget::ExtendedSelection );
249 myGroups->setEditTriggers( QListWidget::NoEditTriggers );
250 myGroups->setViewMode( QListWidget::ListMode );
251 myGroups->setSortingEnabled( true );
253 myAvailableGroups = new QListWidget( aPage );
254 myAvailableGroups->setSelectionMode( QListWidget::ExtendedSelection );
255 myAvailableGroups->setEditTriggers( QListWidget::NoEditTriggers );
256 myAvailableGroups->setViewMode( QListWidget::ListMode );
257 myAvailableGroups->setSortingEnabled( true );
259 connect( myGroups, SIGNAL( itemSelectionChanged() ),
260 SIGNAL( groupsSelected() ) );
262 QFrame* aGroupsFrame = new QFrame( aPage );
263 QGridLayout* aGroupsLayout = new QGridLayout( aGroupsFrame );
264 aGroupsLayout->setMargin( 5 );
265 aGroupsLayout->setSpacing( 5 );
266 aGroupsFrame->setLayout( aGroupsLayout );
268 QFrame* aBtnsFrame = new QFrame( aGroupsFrame );
269 QVBoxLayout* aBtnsLayout = new QVBoxLayout( aBtnsFrame );
270 aBtnsLayout->setMargin( 5 );
271 aBtnsLayout->setSpacing( 5 );
272 aBtnsFrame->setLayout( aBtnsLayout );
273 QPushButton* anAddBtn = new QPushButton( tr("INCLUDE"), aBtnsFrame );
274 QPushButton* aRemoveBtn = new QPushButton( tr("EXCLUDE"), aBtnsFrame );
276 // Fill the butons frame with two buttons
277 aBtnsLayout->addWidget( anAddBtn );
278 aBtnsLayout->addWidget( aRemoveBtn );
279 aBtnsLayout->addStretch( 1 );
281 QLabel* anIncludedLabel = new QLabel( tr( "INCLUDED_GROUPS" ), aGroupsFrame );
282 QLabel* anAvailableLabel = new QLabel( tr( "AVAILABLE_GROUPS" ), aGroupsFrame );
284 // Fill the objects frame with two lists, two labels and with buttons frame
285 aGroupsLayout->addWidget( anAvailableLabel, 0, 0, Qt::AlignHCenter );
286 aGroupsLayout->addWidget( anIncludedLabel, 0, 2, Qt::AlignHCenter );
287 aGroupsLayout->addWidget( myAvailableGroups, 1, 0 );
288 aGroupsLayout->addWidget( aBtnsFrame, 1, 1, Qt::AlignHCenter );
289 aGroupsLayout->addWidget( myGroups, 1, 2 );
292 QGridLayout* aPageLayout = new QGridLayout( aPage );
293 aPageLayout->setMargin( 5 );
294 aPageLayout->setSpacing( 5 );
295 aPageLayout->setVerticalSpacing( 10 );
296 aPageLayout->addWidget( aGroupsFrame, 0, 0 );
298 aPage->setLayout( aPageLayout );
300 connect( anAddBtn, SIGNAL( clicked() ), SIGNAL( addGroups() ) );
301 connect( aRemoveBtn, SIGNAL( clicked() ), SIGNAL( removeGroups() ) );
306 QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() {
307 QWizardPage* aPage = new QWizardPage( mainFrame() );
308 QFrame* aFrame = new QFrame( aPage );
310 QGridLayout* aLayout = new QGridLayout( aPage );
312 myBrowser = new HYDROGUI_DataBrowser( module(), NULL, aPage );
313 myBrowser->setAutoOpenLevel( 3 );
314 aLayout->setMargin( 5 );
315 aLayout->setSpacing( 5 );
317 aLayout->addWidget( myBrowser, 0, 0, 1, 2 );
319 myBathymetryLabel = new QLabel( tr( "BATHYMETRY" ), aFrame );
320 myBathymetryChoice = new QComboBox( aFrame );
322 myBathymetryChoice->setVisible( false );
323 myBathymetryLabel->setVisible( false );
325 aLayout->addWidget( myBathymetryLabel, 1, 0 );
326 aLayout->addWidget( myBathymetryChoice, 1, 1 );
328 aPage->setLayout( aLayout );
330 connect( myBrowser, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
331 connect( myBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SIGNAL( clickedInZonesBrowser( SUIT_DataObject* ) ) );
332 connect( myBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
333 connect( myBathymetryChoice, SIGNAL( activated( int ) ), SLOT( onMergeTypeSelected( int ) ) );
335 SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
336 SLOT( onZonesDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
337 connect( myBrowser, SIGNAL( newRegion() ), this, SLOT( OnNewRegion() ) );
343 bool HYDROGUI_CalculationDlg::acceptCurrent() const
347 if ( false /*myGeomObjects->count() == 0*/ )
349 anErrorMsg = tr( "EMPTY_GEOMETRY_OBJECTS" );
352 if ( !anErrorMsg.isEmpty() )
354 anErrorMsg += "\n" + tr( "INPUT_VALID_DATA" );
356 QString aTitle = tr( "INSUFFICIENT_INPUT_DATA" );
357 SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, anErrorMsg );
360 return anErrorMsg.isEmpty();
363 void HYDROGUI_CalculationDlg::onEmptyName()
365 QString aTitle = tr( "INSUFFICIENT_INPUT_DATA" );
366 QString aMessage = tr( "INCORRECT_OBJECT_NAME" ) + "\n" + tr( "INPUT_VALID_DATA" );
367 SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, aMessage );
370 void HYDROGUI_CalculationDlg::onAlreadyExists( QString theName )
372 QString aTitle = tr( "INSUFFICIENT_INPUT_DATA" );
373 QString aMessage = QObject::tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( theName ) +
374 "\n" + tr( "INPUT_VALID_DATA" );
375 SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, aMessage );
378 void HYDROGUI_CalculationDlg::onZonesDropped( const QList<SUIT_DataObject*>& theList,
379 SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction )
381 QList<SUIT_DataObject*> aZonesList;
382 HYDROGUI_Zone* aZone;
383 // Get a list of dropped zones
384 for ( int i = 0; i < theList.length(); i++ )
386 aZone = dynamic_cast<HYDROGUI_Zone*>( theList.at( i ) );
389 aZonesList.append( aZone );
392 if ( aZonesList.length() > 0 )
394 // Get the target region
395 HYDROGUI_NamedObject* aRegionsRoot = dynamic_cast<HYDROGUI_NamedObject*>(theTargetParent);
398 // Create a new region
399 emit createRegion( aZonesList );
403 HYDROGUI_Region* aRegion = dynamic_cast<HYDROGUI_Region*>(theTargetParent);
406 emit moveZones( theTargetParent, aZonesList );
412 void HYDROGUI_CalculationDlg::OnNewRegion()
414 emit createRegion( myBrowser->getSelected() );
417 void HYDROGUI_CalculationDlg::onMergeTypeSelected( int theIndex )
419 int aType = myBathymetryChoice->itemData( theIndex ).toInt();
420 QString aText = myBathymetryChoice->itemText( theIndex );
421 emit setMergeType( aType, aText );
424 void HYDROGUI_CalculationDlg::onSelected( SUIT_DataObject* theObject )
427 HYDROGUI_Zone* aZone = dynamic_cast<HYDROGUI_Zone*>( theObject );
430 doShow = aZone->isMergingNeed();
435 // Fill the merge type combo box
436 bool prevBlock = myBathymetryChoice->blockSignals( true );
437 myCurrentZone = aZone;
438 myBathymetryChoice->clear();
439 myBathymetryChoice->addItem( tr("MERGE_UNKNOWN"), HYDROData_Zone::Merge_UNKNOWN );
440 myBathymetryChoice->addItem( tr("MERGE_ZMIN"), HYDROData_Zone::Merge_ZMIN );
441 myBathymetryChoice->addItem( tr("MERGE_ZMAX"), HYDROData_Zone::Merge_ZMAX );
442 QStringList aList = aZone->getAltitudes();
443 for ( int i = 0; i < aList.length(); i++ )
445 myBathymetryChoice->addItem( aList.at( i ), HYDROData_Zone::Merge_Object );
447 // Select the current choice if any
449 switch ( aZone->getMergeType() )
451 case HYDROData_Zone::Merge_ZMIN:
454 case HYDROData_Zone::Merge_ZMAX:
457 case HYDROData_Zone::Merge_Object:
458 aCurIndex = 3 + aList.indexOf( aZone->text( HYDROGUI_DataObject::AltitudeObjId ) );
461 aCurIndex = 0; // Select unknown by default
463 myBathymetryChoice->setCurrentIndex( aCurIndex );
464 myBathymetryChoice->blockSignals( prevBlock );
467 myBathymetryChoice->setVisible( doShow );
468 myBathymetryChoice->setEnabled( getMode() == HYDROData_CalculationCase::MANUAL );
469 myBathymetryLabel->setVisible( doShow );
472 void HYDROGUI_CalculationDlg::setObjectName( const QString& theName )
474 myObjectName->setText( theName );
477 QString HYDROGUI_CalculationDlg::getObjectName() const
479 return myObjectName->text();
482 void moveItems( QListWidget* theSource, QListWidget* theDest, const QStringList& theObjects )
484 QList<QListWidgetItem*> aFoundItems;
486 QListWidgetItem* anItem;
488 for ( int i = 0, n = theObjects.length(); i < n; ++i )
490 QString anObjName = theObjects.at( i );
491 aFoundItems = theSource->findItems( anObjName, Qt::MatchExactly );
492 for ( anIdx = 0; anIdx < aFoundItems.length(); anIdx++ )
494 anItem = aFoundItems.at( anIdx );
495 // Remove this object from available objects list
496 anItem = theSource->takeItem( theSource->row( anItem ) );
497 // Add the item to the included objects list
498 theDest->addItem( anItem );
503 void HYDROGUI_CalculationDlg::includeGeomObjects( const QStringList& theObjects )
505 HYDROGUI_ListModel::Object2VisibleList anObjectsToInclude;
506 QList<QListWidgetItem*> aFoundItems;
507 foreach ( const QString& anObjName, theObjects ) {
508 // Hide the object in the available objects list
509 aFoundItems = myAvailableGeomObjects->findItems( anObjName, Qt::MatchExactly );
510 foreach ( QListWidgetItem* anItem, aFoundItems ) {
511 anItem->setHidden( true );
514 // Add the object to the list of included objects
515 Handle(HYDROData_Entity) anObject =
516 HYDROGUI_Tool::FindObjectByName( module(), anObjName );
517 myGeomObjects->addObject( HYDROGUI_ListModel::Object2Visible( anObject, true ) );
520 myPriorityWidget->setObjects( getGeometryObjects() );
523 void HYDROGUI_CalculationDlg::excludeGeomObjects( const QStringList& theObjects )
525 QList<QListWidgetItem*> aFoundItems;
526 foreach ( const QString& anObjName, theObjects ) {
527 // Set visible the object in the available objects list
528 aFoundItems = myAvailableGeomObjects->findItems( anObjName, Qt::MatchExactly );
529 foreach ( QListWidgetItem* anItem, aFoundItems ) {
530 anItem->setHidden( false );
533 // Remove the object from the list of included objects
534 myGeomObjects->removeObjectByName( anObjName );
537 myPriorityWidget->setObjects( getGeometryObjects() );
540 void HYDROGUI_CalculationDlg::setBoundary( const QString& theObjName )
542 bool isBlocked = myPolylineName->blockSignals( true );
543 myPolylineName->setCurrentIndex( myPolylineName->findText( theObjName ) );
544 myPolylineName->blockSignals( isBlocked );
547 void HYDROGUI_CalculationDlg::setPolylineNames( const QStringList& theObjects, const QStringList& theObjectsEntries )
549 myPolylineName->clear();
550 myPolylineName->addItem( "", "" ); // No boundary item
552 for ( int i = 0, n = theObjects.length(); i < n; ++i )
554 myPolylineName->addItem( theObjects.at( i ), theObjectsEntries.at( i ) );
557 void HYDROGUI_CalculationDlg::setAllGeomObjects( const QStringList& theObjects, const QStringList& theObjectsEntries )
559 myAvailableGeomObjects->clear();
561 for ( int i = 0, n = theObjects.length(); i < n; ++i )
563 QString anObjName = theObjects.at( i );
565 QListWidgetItem* aListItem = new QListWidgetItem( anObjName, myAvailableGeomObjects );
566 aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
567 aListItem->setData( Qt::UserRole, theObjectsEntries.at( i ) );
571 QStringList getSelected( QListWidget* theWidget )
573 QStringList aResList;
574 QList<QListWidgetItem*> aList = theWidget->selectedItems();
575 for ( int i = 0, n = aList.length(); i < n; ++i )
577 aResList.append( aList.at( i )->text() );
582 QStringList HYDROGUI_CalculationDlg::getSelectedGeomObjects() const
584 return myGeomObjects->getSelectedNames();
587 QStringList HYDROGUI_CalculationDlg::getAllGeomObjects() const
589 return myGeomObjects->getAllNames();
592 QStringList HYDROGUI_CalculationDlg::getSelectedAvailableGeomObjects() const
594 return getSelected( myAvailableGeomObjects );
597 void HYDROGUI_CalculationDlg::setEditedObject( const Handle(HYDROData_CalculationCase) theCase )
599 myEditedObject = theCase;
600 myValidator->setEditedObject( theCase );
602 // Build the calculation case subtree
603 module()->getDataModel()->buildCaseTree( myBrowser->root(), myEditedObject );
605 myBrowser->updateTree();
606 myBrowser->openLevels();
607 myBrowser->adjustColumnsWidth();
608 myBrowser->setAutoUpdate( true );
609 myBrowser->setUpdateModified( true );
612 HYDROGUI_Zone* HYDROGUI_CalculationDlg::getCurrentZone() const
614 return myCurrentZone;
617 void HYDROGUI_CalculationDlg::refreshZonesBrowser()
619 SUIT_DataObject* aRoot = myBrowser->root();
620 module()->getDataModel()->updateObjectTree( myEditedObject );
621 module()->getDataModel()->buildCaseTree( aRoot, myEditedObject );
622 myBrowser->updateTree( aRoot );
625 void HYDROGUI_CalculationDlg::onDataChanged()
627 SUIT_DataObject* aRoot = myBrowser->root();
628 module()->getDataModel()->buildCaseTree( aRoot, myEditedObject );
629 myBrowser->updateTree( aRoot );
632 void HYDROGUI_CalculationDlg::setAvailableGroups( const QStringList& theGroups )
634 myAvailableGroups->clear();
636 foreach( QString aGroup, theGroups )
637 myAvailableGroups->addItem( aGroup );
640 QStringList HYDROGUI_CalculationDlg::getSelectedGroups() const
642 return getSelected( myGroups );
645 QStringList HYDROGUI_CalculationDlg::getSelectedAvailableGroups() const
647 return getSelected( myAvailableGroups );
650 void HYDROGUI_CalculationDlg::includeGroups( const QStringList& theObjects )
652 moveItems( myAvailableGroups, myGroups, theObjects );
655 void HYDROGUI_CalculationDlg::excludeGroups( const QStringList& theObjects )
657 moveItems( myGroups, myAvailableGroups, theObjects );
662 @param theMode the mode
664 int HYDROGUI_CalculationDlg::getMode() const
666 return myModeButtons->checkedId();
671 @param theMode the mode
673 void HYDROGUI_CalculationDlg::setMode( int theMode )
675 bool isBlocked = myModeButtons->blockSignals( true );
676 myModeButtons->button( theMode )->setChecked( true );
677 myModeButtons->blockSignals( isBlocked );
679 bool isAuto = ( theMode == HYDROData_CalculationCase::AUTOMATIC );
681 myGeomObjects->setOrderingEnabled( isAuto );
682 QWidget* aWidget = mySplitter->widget( 1 );
684 aWidget->setVisible( isAuto );
689 Enable/disable zones drag'n'drop and renaming.
690 @param theIsEnabled if true - zones drag'n'drop and renaming will be enabled
692 void HYDROGUI_CalculationDlg::setEditZonesEnabled( const bool theIsEnabled )
694 myBrowser->setReadOnly( !theIsEnabled );
698 Get included geometry objects.
699 @return the list of geometry objects
701 QList<Handle(HYDROData_Object)> HYDROGUI_CalculationDlg::getGeometryObjects()
703 QList<Handle(HYDROData_Entity)> anEntities = myGeomObjects->getObjects();
704 QList<Handle(HYDROData_Object)> anObjects;
706 foreach ( Handle(HYDROData_Entity) anEntity, anEntities ) {
707 Handle(HYDROData_Object) anObj = Handle(HYDROData_Object)::DownCast( anEntity );
708 if ( anObj.IsNull() ) {
720 @return the list of rules
722 HYDROData_ListOfRules HYDROGUI_CalculationDlg::getRules() const
724 return myPriorityWidget->getRules();
729 @param theRules the list of rules
731 void HYDROGUI_CalculationDlg::setRules( const HYDROData_ListOfRules& theRules ) const
733 myPriorityWidget->setRules( theRules );
737 Slot called when objects order is changed.
739 void HYDROGUI_CalculationDlg::onOrderChanged()
741 bool isConfirmed = true;
742 emit orderChanged( isConfirmed );
744 myPriorityWidget->setObjects( getGeometryObjects() );
746 myGeomObjects->undoLastMove();