1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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 );
187 anObjsLayout->addWidget( aBtnsFrame, 1, 1, Qt::AlignHCenter );
188 anObjsLayout->addWidget( myGeomObjects, 1, 2 );
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 );
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() ) );
242 connect( myGeomObjects, SIGNAL( orderChanged() ), SLOT( onOrderChanged() ) );
247 QWizardPage* HYDROGUI_CalculationDlg::createGroupsPage() {
248 QWizardPage* aPage = new QWizardPage( mainFrame() );
249 QFrame* aFrame = new QFrame( aPage );
251 myGroups = new QListWidget( aPage );
252 myGroups->setSelectionMode( QListWidget::ExtendedSelection );
253 myGroups->setEditTriggers( QListWidget::NoEditTriggers );
254 myGroups->setViewMode( QListWidget::ListMode );
255 myGroups->setSortingEnabled( true );
257 myAvailableGroups = new QListWidget( aPage );
258 myAvailableGroups->setSelectionMode( QListWidget::ExtendedSelection );
259 myAvailableGroups->setEditTriggers( QListWidget::NoEditTriggers );
260 myAvailableGroups->setViewMode( QListWidget::ListMode );
261 myAvailableGroups->setSortingEnabled( true );
263 connect( myGroups, SIGNAL( itemSelectionChanged() ),
264 SIGNAL( groupsSelected() ) );
266 QFrame* aGroupsFrame = new QFrame( aPage );
267 QGridLayout* aGroupsLayout = new QGridLayout( aGroupsFrame );
268 aGroupsLayout->setMargin( 5 );
269 aGroupsLayout->setSpacing( 5 );
270 aGroupsFrame->setLayout( aGroupsLayout );
272 QFrame* aBtnsFrame = new QFrame( aGroupsFrame );
273 QVBoxLayout* aBtnsLayout = new QVBoxLayout( aBtnsFrame );
274 aBtnsLayout->setMargin( 5 );
275 aBtnsLayout->setSpacing( 5 );
276 aBtnsFrame->setLayout( aBtnsLayout );
277 QPushButton* anAddBtn = new QPushButton( tr("INCLUDE"), aBtnsFrame );
278 QPushButton* aRemoveBtn = new QPushButton( tr("EXCLUDE"), aBtnsFrame );
280 // Fill the butons frame with two buttons
281 aBtnsLayout->addWidget( anAddBtn );
282 aBtnsLayout->addWidget( aRemoveBtn );
283 aBtnsLayout->addStretch( 1 );
285 QLabel* anIncludedLabel = new QLabel( tr( "INCLUDED_GROUPS" ), aGroupsFrame );
286 QLabel* anAvailableLabel = new QLabel( tr( "AVAILABLE_GROUPS" ), aGroupsFrame );
288 // Fill the objects frame with two lists, two labels and with buttons frame
289 aGroupsLayout->addWidget( anAvailableLabel, 0, 0, Qt::AlignHCenter );
290 aGroupsLayout->addWidget( anIncludedLabel, 0, 2, Qt::AlignHCenter );
291 aGroupsLayout->addWidget( myAvailableGroups, 1, 0 );
292 aGroupsLayout->addWidget( aBtnsFrame, 1, 1, Qt::AlignHCenter );
293 aGroupsLayout->addWidget( myGroups, 1, 2 );
296 QGridLayout* aPageLayout = new QGridLayout( aPage );
297 aPageLayout->setMargin( 5 );
298 aPageLayout->setSpacing( 5 );
299 aPageLayout->setVerticalSpacing( 10 );
300 aPageLayout->addWidget( aGroupsFrame, 0, 0 );
302 aPage->setLayout( aPageLayout );
304 connect( anAddBtn, SIGNAL( clicked() ), SIGNAL( addGroups() ) );
305 connect( aRemoveBtn, SIGNAL( clicked() ), SIGNAL( removeGroups() ) );
310 QWizardPage* HYDROGUI_CalculationDlg::createZonesPage() {
311 QWizardPage* aPage = new QWizardPage( mainFrame() );
312 QFrame* aFrame = new QFrame( aPage );
314 QGridLayout* aLayout = new QGridLayout( aPage );
316 myBrowser = new HYDROGUI_DataBrowser( module(), NULL, aPage );
317 myBrowser->setAutoOpenLevel( 3 );
318 aLayout->setMargin( 5 );
319 aLayout->setSpacing( 5 );
321 aLayout->addWidget( myBrowser, 0, 0, 1, 2 );
323 myBathymetryLabel = new QLabel( tr( "BATHYMETRY" ), aFrame );
324 myBathymetryChoice = new QComboBox( aFrame );
326 myBathymetryChoice->setVisible( false );
327 myBathymetryLabel->setVisible( false );
329 aLayout->addWidget( myBathymetryLabel, 1, 0 );
330 aLayout->addWidget( myBathymetryChoice, 1, 1 );
332 aPage->setLayout( aLayout );
334 connect( myBrowser, SIGNAL( dataChanged() ), SLOT( onDataChanged() ) );
335 connect( myBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SIGNAL( clickedInZonesBrowser( SUIT_DataObject* ) ) );
336 connect( myBrowser, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
337 connect( myBathymetryChoice, SIGNAL( activated( int ) ), SLOT( onMergeTypeSelected( int ) ) );
339 SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
340 SLOT( onZonesDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
346 bool HYDROGUI_CalculationDlg::acceptCurrent() const
350 if ( false /*myGeomObjects->count() == 0*/ )
352 anErrorMsg = tr( "EMPTY_GEOMETRY_OBJECTS" );
355 if ( !anErrorMsg.isEmpty() )
357 anErrorMsg += "\n" + tr( "INPUT_VALID_DATA" );
359 QString aTitle = tr( "INSUFFICIENT_INPUT_DATA" );
360 SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, anErrorMsg );
363 return anErrorMsg.isEmpty();
366 void HYDROGUI_CalculationDlg::onEmptyName()
368 QString aTitle = tr( "INSUFFICIENT_INPUT_DATA" );
369 QString aMessage = tr( "INCORRECT_OBJECT_NAME" ) + "\n" + tr( "INPUT_VALID_DATA" );
370 SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, aMessage );
373 void HYDROGUI_CalculationDlg::onAlreadyExists( QString theName )
375 QString aTitle = tr( "INSUFFICIENT_INPUT_DATA" );
376 QString aMessage = QObject::tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( theName ) +
377 "\n" + tr( "INPUT_VALID_DATA" );
378 SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, aMessage );
381 void HYDROGUI_CalculationDlg::onZonesDropped( const QList<SUIT_DataObject*>& theList,
382 SUIT_DataObject* theTargetParent, int theTargetRow, Qt::DropAction theDropAction )
384 QList<SUIT_DataObject*> aZonesList;
385 HYDROGUI_Zone* aZone;
386 // Get a list of dropped zones
387 for ( int i = 0; i < theList.length(); i++ )
389 aZone = dynamic_cast<HYDROGUI_Zone*>( theList.at( i ) );
392 aZonesList.append( aZone );
395 if ( aZonesList.length() > 0 )
397 // Get the target region
398 HYDROGUI_NamedObject* aRegionsRoot = dynamic_cast<HYDROGUI_NamedObject*>(theTargetParent);
401 // Create a new region
402 emit createRegion( aZonesList );
406 HYDROGUI_Region* aRegion = dynamic_cast<HYDROGUI_Region*>(theTargetParent);
409 emit moveZones( theTargetParent, aZonesList );
415 void HYDROGUI_CalculationDlg::onMergeTypeSelected( int theIndex )
417 int aType = myBathymetryChoice->itemData( theIndex ).toInt();
418 QString aText = myBathymetryChoice->itemText( theIndex );
419 emit setMergeType( aType, aText );
422 void HYDROGUI_CalculationDlg::onSelected( SUIT_DataObject* theObject )
425 HYDROGUI_Zone* aZone = dynamic_cast<HYDROGUI_Zone*>( theObject );
428 doShow = aZone->isMergingNeed();
433 // Fill the merge type combo box
434 bool prevBlock = myBathymetryChoice->blockSignals( true );
435 myCurrentZone = aZone;
436 myBathymetryChoice->clear();
437 myBathymetryChoice->addItem( tr("MERGE_UNKNOWN"), HYDROData_Zone::Merge_UNKNOWN );
438 myBathymetryChoice->addItem( tr("MERGE_ZMIN"), HYDROData_Zone::Merge_ZMIN );
439 myBathymetryChoice->addItem( tr("MERGE_ZMAX"), HYDROData_Zone::Merge_ZMAX );
440 QStringList aList = aZone->getAltitudes();
441 for ( int i = 0; i < aList.length(); i++ )
443 myBathymetryChoice->addItem( aList.at( i ), HYDROData_Zone::Merge_Object );
445 // Select the current choice if any
447 switch ( aZone->getMergeType() )
449 case HYDROData_Zone::Merge_ZMIN:
452 case HYDROData_Zone::Merge_ZMAX:
455 case HYDROData_Zone::Merge_Object:
456 aCurIndex = 3 + aList.indexOf( aZone->text( HYDROGUI_DataObject::AltitudeObjId ) );
459 aCurIndex = 0; // Select unknown by default
461 myBathymetryChoice->setCurrentIndex( aCurIndex );
462 myBathymetryChoice->blockSignals( prevBlock );
465 myBathymetryChoice->setVisible( doShow );
466 myBathymetryChoice->setEnabled( getMode() == HYDROData_CalculationCase::MANUAL );
467 myBathymetryLabel->setVisible( doShow );
470 void HYDROGUI_CalculationDlg::setObjectName( const QString& theName )
472 myObjectName->setText( theName );
475 QString HYDROGUI_CalculationDlg::getObjectName() const
477 return myObjectName->text();
480 void moveItems( QListWidget* theSource, QListWidget* theDest, const QStringList& theObjects )
482 QList<QListWidgetItem*> aFoundItems;
484 QListWidgetItem* anItem;
486 for ( int i = 0, n = theObjects.length(); i < n; ++i )
488 QString anObjName = theObjects.at( i );
489 aFoundItems = theSource->findItems( anObjName, Qt::MatchExactly );
490 for ( anIdx = 0; anIdx < aFoundItems.length(); anIdx++ )
492 anItem = aFoundItems.at( anIdx );
493 // Remove this object from available objects list
494 anItem = theSource->takeItem( theSource->row( anItem ) );
495 // Add the item to the included objects list
496 theDest->addItem( anItem );
501 void HYDROGUI_CalculationDlg::includeGeomObjects( const QStringList& theObjects )
503 HYDROGUI_ListModel::Object2VisibleList anObjectsToInclude;
504 QList<QListWidgetItem*> aFoundItems;
505 foreach ( const QString& anObjName, theObjects ) {
506 // Hide the object in the available objects list
507 aFoundItems = myAvailableGeomObjects->findItems( anObjName, Qt::MatchExactly );
508 foreach ( QListWidgetItem* anItem, aFoundItems ) {
509 anItem->setHidden( true );
512 // Add the object to the list of included objects
513 Handle(HYDROData_Entity) anObject =
514 HYDROGUI_Tool::FindObjectByName( module(), anObjName );
515 myGeomObjects->addObject( HYDROGUI_ListModel::Object2Visible( anObject, true ) );
518 myPriorityWidget->setObjects( getGeometryObjects() );
521 void HYDROGUI_CalculationDlg::excludeGeomObjects( const QStringList& theObjects )
523 QList<QListWidgetItem*> aFoundItems;
524 foreach ( const QString& anObjName, theObjects ) {
525 // Set visible the object in the available objects list
526 aFoundItems = myAvailableGeomObjects->findItems( anObjName, Qt::MatchExactly );
527 foreach ( QListWidgetItem* anItem, aFoundItems ) {
528 anItem->setHidden( false );
531 // Remove the object from the list of included objects
532 myGeomObjects->removeObjectByName( anObjName );
535 myPriorityWidget->setObjects( getGeometryObjects() );
538 void HYDROGUI_CalculationDlg::setBoundary( const QString& theObjName )
540 bool isBlocked = myPolylineName->blockSignals( true );
541 myPolylineName->setCurrentIndex( myPolylineName->findText( theObjName ) );
542 myPolylineName->blockSignals( isBlocked );
545 void HYDROGUI_CalculationDlg::setPolylineNames( const QStringList& theObjects, const QStringList& theObjectsEntries )
547 myPolylineName->clear();
548 myPolylineName->addItem( "", "" ); // No boundary item
550 for ( int i = 0, n = theObjects.length(); i < n; ++i )
552 myPolylineName->addItem( theObjects.at( i ), theObjectsEntries.at( i ) );
555 void HYDROGUI_CalculationDlg::setAllGeomObjects( const QStringList& theObjects, const QStringList& theObjectsEntries )
557 myAvailableGeomObjects->clear();
559 for ( int i = 0, n = theObjects.length(); i < n; ++i )
561 QString anObjName = theObjects.at( i );
563 QListWidgetItem* aListItem = new QListWidgetItem( anObjName, myAvailableGeomObjects );
564 aListItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
565 aListItem->setData( Qt::UserRole, theObjectsEntries.at( i ) );
569 QStringList getSelected( QListWidget* theWidget )
571 QStringList aResList;
572 QList<QListWidgetItem*> aList = theWidget->selectedItems();
573 for ( int i = 0, n = aList.length(); i < n; ++i )
575 aResList.append( aList.at( i )->text() );
580 QStringList HYDROGUI_CalculationDlg::getSelectedGeomObjects() const
582 return myGeomObjects->getSelectedNames();
585 QStringList HYDROGUI_CalculationDlg::getAllGeomObjects() const
587 return myGeomObjects->getAllNames();
590 QStringList HYDROGUI_CalculationDlg::getSelectedAvailableGeomObjects() const
592 return getSelected( myAvailableGeomObjects );
595 void HYDROGUI_CalculationDlg::setEditedObject( const Handle(HYDROData_CalculationCase) theCase )
597 myEditedObject = theCase;
598 myValidator->setEditedObject( theCase );
600 // Build the calculation case subtree
601 module()->getDataModel()->buildCaseTree( myBrowser->root(), myEditedObject );
603 myBrowser->updateTree();
604 myBrowser->openLevels();
605 myBrowser->adjustColumnsWidth();
606 myBrowser->setAutoUpdate( true );
607 myBrowser->setUpdateModified( true );
610 HYDROGUI_Zone* HYDROGUI_CalculationDlg::getCurrentZone() const
612 return myCurrentZone;
615 void HYDROGUI_CalculationDlg::refreshZonesBrowser()
617 SUIT_DataObject* aRoot = myBrowser->root();
618 module()->getDataModel()->updateObjectTree( myEditedObject );
619 module()->getDataModel()->buildCaseTree( aRoot, myEditedObject );
620 myBrowser->updateTree( aRoot );
623 void HYDROGUI_CalculationDlg::onDataChanged()
625 SUIT_DataObject* aRoot = myBrowser->root();
626 module()->getDataModel()->buildCaseTree( aRoot, myEditedObject );
627 myBrowser->updateTree( aRoot );
630 void HYDROGUI_CalculationDlg::setAvailableGroups( const QStringList& theGroups )
632 myAvailableGroups->clear();
634 foreach( QString aGroup, theGroups )
635 myAvailableGroups->addItem( aGroup );
638 QStringList HYDROGUI_CalculationDlg::getSelectedGroups() const
640 return getSelected( myGroups );
643 QStringList HYDROGUI_CalculationDlg::getSelectedAvailableGroups() const
645 return getSelected( myAvailableGroups );
648 void HYDROGUI_CalculationDlg::includeGroups( const QStringList& theObjects )
650 moveItems( myAvailableGroups, myGroups, theObjects );
653 void HYDROGUI_CalculationDlg::excludeGroups( const QStringList& theObjects )
655 moveItems( myGroups, myAvailableGroups, theObjects );
660 @param theMode the mode
662 int HYDROGUI_CalculationDlg::getMode() const
664 return myModeButtons->checkedId();
669 @param theMode the mode
671 void HYDROGUI_CalculationDlg::setMode( int theMode )
673 bool isBlocked = myModeButtons->blockSignals( true );
674 myModeButtons->button( theMode )->setChecked( true );
675 myModeButtons->blockSignals( isBlocked );
677 bool isAuto = ( theMode == HYDROData_CalculationCase::AUTOMATIC );
679 myGeomObjects->setOrderingEnabled( isAuto );
680 QWidget* aWidget = mySplitter->widget( 1 );
682 aWidget->setVisible( isAuto );
687 Enable/disable zones drag'n'drop and renaming.
688 @param theIsEnabled if true - zones drag'n'drop and renaming will be enabled
690 void HYDROGUI_CalculationDlg::setEditZonesEnabled( const bool theIsEnabled )
692 myBrowser->setReadOnly( !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 );
735 Slot called when objects order is changed.
737 void HYDROGUI_CalculationDlg::onOrderChanged()
739 myPriorityWidget->setObjects( getGeometryObjects() );