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_CalculationOp.h"
21 #include "HYDROGUI_DataModel.h"
22 #include "HYDROGUI_CalculationDlg.h"
23 #include "HYDROGUI_Module.h"
24 #include "HYDROGUI_Tool2.h"
25 #include "HYDROGUI_UpdateFlags.h"
26 #include "HYDROGUI_Zone.h"
27 #include "HYDROGUI_Region.h"
29 #include <HYDROData_PolylineXY.h>
30 #include <HYDROData_ShapesGroup.h>
31 #include <HYDROData_Iterator.h>
32 #include <HYDROData_ImmersibleZone.h>
33 #include <HYDROData_Object.h>
34 #include <HYDROData_Tool.h>
35 #include <HYDROData_StricklerTable.h>
37 #include <OCCViewer_ViewManager.h>
38 #include <OCCViewer_ViewModel.h>
39 #include <OCCViewer_ViewWindow.h>
41 #include <LightApp_Application.h>
42 #include <LightApp_UpdateFlags.h>
43 #include <LightApp_SelectionMgr.h>
44 #include <LightApp_DataOwner.h>
46 #include <SUIT_MessageBox.h>
47 #include <SUIT_Desktop.h>
48 #include <SUIT_DataBrowser.h>
50 #include <QApplication>
51 #include <QKeySequence>
54 HYDROGUI_CalculationOp::HYDROGUI_CalculationOp( HYDROGUI_Module* theModule, bool theIsEdit )
55 : HYDROGUI_Operation( theModule ),
56 myIsEdit( theIsEdit ),
57 myActiveViewManager( NULL ),
58 myPreviewViewManager( NULL ),
59 myShowGeomObjects( true ),
60 myShowLandCoverMap( false ),
63 setName( myIsEdit ? tr( "EDIT_CALCULATION" ) : tr( "CREATE_CALCULATION" ) );
66 HYDROGUI_CalculationOp::~HYDROGUI_CalculationOp()
71 void HYDROGUI_CalculationOp::startOperation()
73 HYDROGUI_Operation::startOperation();
78 HYDROGUI_CalculationDlg* aPanel =
79 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
83 SUIT_DataBrowser* aOb = ((LightApp_Application*)module()->application())->objectBrowser();
84 QList<QShortcut*> aShortcuts = aOb->findChildren<QShortcut*>();
86 foreach( aShortcut, aShortcuts )
88 if ( aShortcut->key() ==
89 QKeySequence(((LightApp_Application*)module()->application())->objectBrowser()->shortcutKey(
90 SUIT_DataBrowser::RenameShortcut ) ) )
92 aShortcut->setEnabled( false );
98 QStringList anEntryList;
99 HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetGeometryObjects( module() );
100 getNamesAndEntries( aSeq, aList, anEntryList );
105 //add intersection polylines
106 AddInterPolylinesToList(aList, anEntryList);
108 aPanel->setAllGeomObjects( aList, anEntryList );
113 HYDROData_Iterator anIter( doc(), KIND_POLYLINEXY );
114 Handle(HYDROData_PolylineXY) aPolylineObj;
115 QString aPolylineName;
116 for ( ; anIter.More(); anIter.Next() )
118 aPolylineObj = Handle(HYDROData_PolylineXY)::DownCast( anIter.Current() );
120 if ( !aPolylineObj.IsNull() && aPolylineObj->IsClosed(false) )
122 // // Check the polyline shape
123 // TopoDS_Shape aPolylineShape = aPolylineObj->GetShape();
124 // if ( !aPolylineShape.IsNull() && aPolylineShape.ShapeType() == TopAbs_WIRE ) {
125 aPolylineName = aPolylineObj->GetName();
126 if ( !aPolylineName.isEmpty() )
128 aList.append( aPolylineName );
129 anEntryList.append( HYDROGUI_DataObject::dataObjectEntry( aPolylineObj ) );
134 aPanel->setPolylineNames( aList, anEntryList );
136 QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_CALCULATION_CASE_NAME" ) );
138 myEditedObject.Nullify();
141 myEditedObject = Handle(HYDROData_CalculationCase)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
142 if ( !myEditedObject.IsNull() )
144 aPanel->setMode( myEditedObject->GetAssignmentMode() );
145 anObjectName = myEditedObject->GetName();
146 aPolylineObj = myEditedObject->GetBoundaryPolyline();
147 if ( aPolylineObj.IsNull() )
149 aPanel->setBoundary( QString() );
153 aPolylineName = aPolylineObj->GetName();
154 aPanel->setBoundary( aPolylineName );
157 aSeq = myEditedObject->GetGeometryObjects();
158 getNamesAndEntries( aSeq, aList, anEntryList );
159 aPanel->includeGeomObjects( aList );
162 setRules( HYDROData_CalculationCase::DataTag_CustomRules );
168 Handle(HYDROData_CalculationCase)::DownCast( doc()->CreateObject( KIND_CALCULATION ) );
169 myEditedObject->SetName( anObjectName );
170 myEditedObject->SetAssignmentMode( (HYDROData_CalculationCase::AssignmentMode)aPanel->getMode() );
173 aPanel->setObjectName( anObjectName );
174 aPanel->setEditedObject( myEditedObject );
176 setGeomObjectsVisible( true );
178 createPreview( false );
181 void HYDROGUI_CalculationOp::AddInterPolylinesToList(QStringList& theList, QStringList& theEntryList)
183 HYDROData_Iterator anIter( doc(), KIND_POLYLINEXY );
184 Handle(HYDROData_PolylineXY) aPolylineObj;
185 QString aPolylineName;
186 for ( ; anIter.More(); anIter.Next() )
188 aPolylineObj = Handle(HYDROData_PolylineXY)::DownCast( anIter.Current() );
189 if ( !aPolylineObj.IsNull())
191 aPolylineName = aPolylineObj->GetName();
192 if ( !aPolylineName.isEmpty() && !theList.contains(aPolylineName) )
194 theList.append( aPolylineName );
195 theEntryList.append(HYDROGUI_DataObject::dataObjectEntry( aPolylineObj ));
201 void HYDROGUI_CalculationOp::getNamesAndEntries( const HYDROData_SequenceOfObjects& theSeq,
202 QStringList& theNames, QStringList& theEntries ) const
207 HYDROData_SequenceOfObjects::Iterator anIter( theSeq );
208 for ( ; anIter.More(); anIter.Next() )
210 Handle(HYDROData_Entity) anEntity = anIter.Value();
211 //if ( !HYDROData_Tool::IsGeometryObject( anEntity ) )
214 theNames.append( anEntity->GetName() );
215 theEntries.append( HYDROGUI_DataObject::dataObjectEntry( anEntity ) );
219 void HYDROGUI_CalculationOp::abortOperation()
224 HYDROGUI_Operation::abortOperation();
225 module()->getApp()->updateObjectBrowser();
228 void HYDROGUI_CalculationOp::commitOperation()
231 // Commit transaction
232 commitDocOperation();
233 HYDROGUI_Operation::commitOperation();
236 HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const
238 HYDROGUI_CalculationDlg* aPanel = new HYDROGUI_CalculationDlg( module(), getName() );
240 // Connect signals and slots
241 connect( aPanel, SIGNAL( changeMode( int ) ), SLOT( onChangeMode( int ) ) );
242 connect( aPanel, SIGNAL( addObjects() ), SLOT( onAddObjects() ) );
243 connect( aPanel, SIGNAL( removeObjects() ), SLOT( onRemoveObjects() ) );
244 connect( aPanel, SIGNAL( addGroups() ), SLOT( onAddGroups() ) );
245 connect( aPanel, SIGNAL( removeGroups() ), SLOT( onRemoveGroups() ) );
247 connect( aPanel, SIGNAL( orderChanged( bool& ) ), SLOT( onOrderChanged( bool& ) ) );
249 connect( aPanel, SIGNAL( ruleChanged( bool& ) ), SLOT( onRuleChanged( bool& ) ) );
251 connect( aPanel, SIGNAL( Next( const int ) ), SLOT( onNext( const int ) ) );
252 connect( aPanel, SIGNAL( Back( const int ) ), SLOT( onHideZones( const int ) ) );
253 //connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
254 connect( aPanel, SIGNAL( setMergeType( int, QString& ) ), SLOT( onSetMergeType( int, QString& ) ) );
255 connect( aPanel, SIGNAL( moveZones( SUIT_DataObject*, const QList<SUIT_DataObject*>& ) ),
256 SLOT( onMoveZones( SUIT_DataObject*, const QList<SUIT_DataObject*>& ) ) );
257 connect( aPanel, SIGNAL( createRegion( const QList<SUIT_DataObject*>& ) ),
258 SLOT( onCreateRegion( const QList<SUIT_DataObject*>& ) ) );
259 connect( aPanel, SIGNAL( clickedInZonesBrowser( SUIT_DataObject* ) ),
260 SLOT( onClickedInZonesBrowser( SUIT_DataObject* ) ) );
261 connect( aPanel, SIGNAL( objectsSelected() ),
262 SLOT( onObjectsSelected() ) );
263 connect( aPanel, SIGNAL( landCoverMapSelected( const QString & ) ),
264 SLOT( onLandCoverMapSelected( const QString & ) ) );
265 connect( aPanel, SIGNAL( boundarySelected( const QString & ) ),
266 SLOT( onBoundarySelected( const QString & ) ) );
267 connect( aPanel, SIGNAL( StricklerTableSelected( const QString & ) ),
268 SLOT( onStricklerTableSelected( const QString & ) ) );
270 connect( aPanel, SIGNAL( regenerateColors() ), this,
271 SLOT( onRegenerateColors() ) );
276 void HYDROGUI_CalculationOp::onBoundarySelected ( const QString & theObjName )
278 bool anIsToUpdateViewer = false;
280 // Remove the old boundary from the operation viewer
281 Handle(HYDROData_PolylineXY) aPrevPolyline =
282 myEditedObject->GetBoundaryPolyline();
283 if ( !aPrevPolyline.IsNull() )
285 setObjectVisibility( aPrevPolyline, false );
286 anIsToUpdateViewer = true;
289 // Set the selected boundary polyline to the calculation case
290 Handle(HYDROData_PolylineXY) aNewPolyline = Handle(HYDROData_PolylineXY)::DownCast(
291 HYDROGUI_Tool::FindObjectByName( module(), theObjName, KIND_POLYLINEXY ) );
292 myEditedObject->SetBoundaryPolyline( aNewPolyline );
294 if ( myPreviewViewManager )
296 OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
299 if ( !aNewPolyline.IsNull() )
301 Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
302 if ( !aCtx.IsNull() )
304 setObjectVisibility( aNewPolyline, true );
305 anIsToUpdateViewer = true;
309 if ( anIsToUpdateViewer )
310 module()->update( UF_OCCViewer );
315 void HYDROGUI_CalculationOp::onStricklerTableSelected ( const QString & theObjName )
317 bool anIsToUpdateViewer = false;
319 // Remove old presentation of land cover map from the operation viewer
320 Handle(HYDROData_LandCoverMap) aLandCoverMap = myEditedObject->GetLandCoverMap();
321 if ( !aLandCoverMap.IsNull() )
323 setObjectVisibility( aLandCoverMap, false );
324 anIsToUpdateViewer = true;
327 // Set the selected Strickler table to the calculation case
328 Handle(HYDROData_StricklerTable) aNewStricklerTable = Handle(HYDROData_StricklerTable)::DownCast(
329 HYDROGUI_Tool::FindObjectByName( module(), theObjName, KIND_STRICKLER_TABLE ) );
330 myEditedObject->SetStricklerTable( aNewStricklerTable );
332 if ( myPreviewViewManager )
334 OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
337 if ( !aNewStricklerTable.IsNull() )
339 Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
340 if ( !aCtx.IsNull() )
342 if ( !aLandCoverMap.IsNull() )
344 setObjectVisibility( aLandCoverMap, true );
345 anIsToUpdateViewer = true;
350 if ( anIsToUpdateViewer )
351 module()->update( UF_OCCViewer );
356 void HYDROGUI_CalculationOp::onObjectsSelected()
358 HYDROGUI_CalculationDlg* aPanel =
359 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
361 QStringList aSelectedObjs = aPanel->getSelectedGeomObjects();
362 QMap<QString, bool> aSelectedObjsMap;
363 foreach( QString aName, aSelectedObjs )
364 aSelectedObjsMap[aName] = true;
367 // Select the appropriate geometry object shape in the viewer
368 selectionMgr()->clearSelected();
370 // Unhighlight all objects except selected
371 HYDROGUI_Shape* aShape = 0, *aLastShape = 0;
372 Handle(HYDROData_Entity) anEntity;
373 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryObjects();
374 HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
377 for ( ; anIter.More(); anIter.Next() )
379 anEntity = anIter.Value();
380 if ( !anEntity.IsNull() )
382 aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anEntity );
385 aName = anEntity->GetName();
386 isSelected = aSelectedObjsMap.contains( aName );
387 aShape->highlight( isSelected, false );
388 aShape->update( false, false );
394 aLastShape->update( true, false );
397 void HYDROGUI_CalculationOp::onLandCoverMapSelected( const QString & theObjName )
399 bool anIsToUpdateViewer = false;
401 // Remove old presentation of land cover map from the operation viewer
402 Handle(HYDROData_LandCoverMap) aPrevLandCoverMap = myEditedObject->GetLandCoverMap();
403 if ( !aPrevLandCoverMap.IsNull() )
405 setObjectVisibility( aPrevLandCoverMap, false );
406 anIsToUpdateViewer = true;
409 // Select the appropriate land cover map shape in the viewer
410 selectionMgr()->clearSelected();
412 // Set the selected land cover map to the calculation case
413 Handle(HYDROData_LandCoverMap) aNewLandCoverMap = Handle(HYDROData_LandCoverMap)::DownCast(
414 HYDROGUI_Tool::FindObjectByName( module(), theObjName, KIND_LAND_COVER_MAP ) );
415 myEditedObject->SetLandCoverMap( aNewLandCoverMap );
417 createPreview( true );
420 void HYDROGUI_CalculationOp::onClickedInZonesBrowser( SUIT_DataObject* theItem )
422 HYDROGUI_Region* aRegionItem = dynamic_cast<HYDROGUI_Region*>(theItem);
423 HYDROGUI_Zone* aZoneItem;
424 selectionMgr()->clearSelected();
427 // Select a region in preview
428 SUIT_DataOwnerPtrList aList( true );
429 DataObjectList aZones = aRegionItem->children();
430 for ( int i = 0; i < aZones.length(); i++ )
432 aZoneItem = dynamic_cast<HYDROGUI_Zone*>(aZones.at(i));
435 aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( aZoneItem->entry() ) ) );
438 selectionMgr()->setSelected( aList );
442 // select a single zone
443 aZoneItem = dynamic_cast<HYDROGUI_Zone*>(theItem);
446 SUIT_DataOwnerPtrList aList( true );
447 aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( aZoneItem->entry() ) ) );
448 selectionMgr()->setSelected( aList );
453 void HYDROGUI_CalculationOp::onMoveZones( SUIT_DataObject* theRegionItem,
454 const QList<SUIT_DataObject*>& theZonesList )
456 HYDROGUI_Region* aRegion = dynamic_cast<HYDROGUI_Region*>(theRegionItem);
459 QList<HYDROGUI_Zone*> aZonesList;
460 HYDROGUI_Zone* aZone;
461 // Get a list of dropped zones
462 for ( int i = 0; i < theZonesList.length(); i++ )
464 aZone = dynamic_cast<HYDROGUI_Zone*>( theZonesList.at( i ) );
467 aZonesList.append( aZone );
470 if ( aZonesList.length() > 0 )
472 aRegion->addZones( aZonesList );
473 HYDROGUI_CalculationDlg* aPanel =
474 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
476 aPanel->refreshZonesBrowser();
477 createPreview( false );
482 void HYDROGUI_CalculationOp::onCreateRegion( const QList<SUIT_DataObject*>& theZonesList )
484 if ( createRegion( theZonesList ) )
486 HYDROGUI_CalculationDlg* aPanel =
487 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
490 aPanel->refreshZonesBrowser();
492 createPreview( false );
496 void HYDROGUI_CalculationOp::onSetMergeType( int theMergeType, QString& theMergeObjectName )
498 HYDROGUI_CalculationDlg* aPanel =
499 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
502 HYDROGUI_Zone* aZone = aPanel->getCurrentZone();
505 aZone->setMergeType( theMergeType, theMergeObjectName );
506 HYDROGUI_Shape* aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, aZone->modelObject() );
509 aShape->update( true, false );
512 aPanel->refreshZonesBrowser();
516 void HYDROGUI_CalculationOp::onAddObjects()
518 HYDROGUI_CalculationDlg* aPanel =
519 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
523 // Add geometry objects selected in the module browser to the calculation case
524 QStringList aSelectedList = aPanel->getSelectedAvailableGeomObjects();
525 if ( aSelectedList.isEmpty() || !confirmRegionsChange() )
528 QStringList anAddedList;
529 for (int i = 0; i < aSelectedList.length(); i++)
531 Handle(HYDROData_Object) anObject = Handle(HYDROData_Object)::DownCast(
532 HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at( i ) ) );
533 if ( anObject.IsNull() )
536 if ( myEditedObject->AddGeometryObject( anObject ) )
537 anAddedList.append( anObject->GetName() );
540 for (int i = 0; i < aSelectedList.length(); i++)
542 Handle(HYDROData_PolylineXY) aPoly = Handle(HYDROData_PolylineXY)::DownCast(
543 HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at( i ) ) );
544 if ( aPoly.IsNull() )
547 if ( myEditedObject->AddInterPoly( aPoly ) )
548 anAddedList.append( aPoly->GetName() );
551 if ( !anAddedList.isEmpty() )
553 aPanel->includeGeomObjects( anAddedList );
554 createPreview( false );
558 void HYDROGUI_CalculationOp::onRemoveObjects()
560 // Remove selected objects from the calculation case
561 HYDROGUI_CalculationDlg* aPanel =
562 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
566 QStringList aSelectedList = aPanel->getSelectedGeomObjects();
567 if ( aSelectedList.isEmpty() || !confirmRegionsChange() )
570 for (int i = 0; i < aSelectedList.length(); i++)
572 Handle(HYDROData_Object) anObject = Handle(HYDROData_Object)::DownCast(
573 HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at(i) ) );
574 if ( anObject.IsNull() )
577 setObjectVisibility( anObject, false );
578 myEditedObject->RemoveGeometryObject( anObject );
581 for (int i = 0; i < aSelectedList.length(); i++)
583 Handle(HYDROData_PolylineXY) aPoly = Handle(HYDROData_PolylineXY)::DownCast(
584 HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at(i) ) );
585 if ( aPoly.IsNull() )
588 setObjectVisibility( aPoly, false );
589 myEditedObject->RemoveInterPolyObject ( aPoly );
592 module()->update( UF_OCCViewer );
593 aPanel->excludeGeomObjects( aSelectedList );
596 bool HYDROGUI_CalculationOp::confirmRegionsChange() const
598 // Check if the case is already modified or not
599 bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
602 // If not modified check if the case has already defined regions with zones
603 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions();
604 if ( aSeq.Length() > 0 )
606 // If there are already defined zones then ask a user to confirm zones recalculation
607 isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(),
608 tr( "REGIONS_CHANGED" ),
609 tr( "CONFIRM_SPLITTING_ZONES_RECALCULATION_REGIONS" ),
610 QMessageBox::Yes | QMessageBox::No,
611 QMessageBox::No ) == QMessageBox::Yes );
615 isConfirmed = true; // No regions - no zones - nothing to recalculate
621 bool HYDROGUI_CalculationOp::confirmOrderChange() const
623 // Check if the case is already modified or not
624 bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
627 // If not modified check if the case has already defined regions with zones
628 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions();
629 if ( aSeq.Length() > 0 )
631 // If there are already defined zones then ask a user to confirm zones recalculation
632 isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(),
633 tr( "ORDER_CHANGED" ),
634 tr( "CONFIRM_SPLITTING_ZONES_RECALCULATION_REGIONS" ),
635 QMessageBox::Yes | QMessageBox::No,
636 QMessageBox::No ) == QMessageBox::Yes );
640 isConfirmed = true; // No regions - no zones - nothing to recalculate
646 bool HYDROGUI_CalculationOp::confirmRuleChange() const
648 // Check if the case is already modified or not
649 bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
652 // If not modified check if the case has already defined regions with zones
653 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions();
654 if ( aSeq.Length() > 0 )
656 // If there are already defined zones then ask a user to confirm zones recalculation
657 isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(),
658 tr( "RULE_CHANGED" ),
659 tr( "CONFIRM_SPLITTING_ZONES_RECALCULATION_REGIONS" ),
660 QMessageBox::Yes | QMessageBox::No,
661 QMessageBox::No ) == QMessageBox::Yes );
665 isConfirmed = true; // No regions - no zones - nothing to recalculate
671 bool HYDROGUI_CalculationOp::confirmModeChange() const
673 // Check if the case is already modified or not
674 bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
677 // If not modified check if the case has already defined regions with zones
678 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions();
679 if ( aSeq.Length() > 0 )
681 // If there are already defined zones then ask a user to confirm zones recalculation
682 isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(),
683 tr( "MODE_CHANGED" ),
684 tr( "CONFIRM_SPLITTING_ZONES_RECALCULATION_MODE" ),
685 QMessageBox::Yes | QMessageBox::No,
686 QMessageBox::No ) == QMessageBox::Yes );
690 isConfirmed = true; // No regions - no zones - nothing to recalculate
696 bool HYDROGUI_CalculationOp::confirmContinueWithWarning( const HYDROData_Warning& theWarning ) const
698 HYDROData_WarningType aType = theWarning.Type;
699 if ( aType == WARN_OK ) {
707 case WARN_EMPTY_REGIONS:
708 aTitle = tr( "EMPTY_REGIONS" );
709 aMsg = tr( "CONFIRM_CONTINUE_WITH_OBJECTS_NOT_INCLUDED_TO_REGION" ).arg( theWarning.Data );
712 aTitle = tr( "WARNING" );
713 aMsg = theWarning.Data;
717 int anAnswer = SUIT_MessageBox::warning( module()->getApp()->desktop(),
719 QMessageBox::Yes | QMessageBox::No,
722 return ( anAnswer == QMessageBox::Yes );
725 bool HYDROGUI_CalculationOp::processApply( int& theUpdateFlags,
726 QString& theErrorMsg,
727 QStringList& theBrowseObjectsEntries )
729 HYDROGUI_CalculationDlg* aPanel =
730 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
736 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( myEditedObject );
737 theBrowseObjectsEntries.append( anEntry );
740 // For manual mode priority rules are redundant
741 if ( aPanel->getMode() == HYDROData_CalculationCase::MANUAL ) {
742 myEditedObject->ClearRules( HYDROData_CalculationCase::DataTag_CustomRules, false );
745 theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init;
750 void HYDROGUI_CalculationOp::onApply()
753 HYDROData_Warning aWarning = myEditedObject->GetLastWarning();
754 if ( aWarning.Type != WARN_OK ) {
755 if ( !confirmContinueWithWarning( aWarning ) ) {
756 // Go back to the first page
757 HYDROGUI_CalculationDlg* aPanel =
758 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
760 aPanel->onFirstPage();
766 QApplication::setOverrideCursor( Qt::WaitCursor );
768 int anUpdateFlags = 0;
770 QStringList aBrowseObjectsEntries;
772 bool aResult = false;
776 aResult = processApply( anUpdateFlags, anErrorMsg, aBrowseObjectsEntries );
778 catch ( Standard_Failure )
780 Handle(Standard_Failure) aFailure = Standard_Failure::Caught();
781 anErrorMsg = aFailure->GetMessageString();
789 QApplication::restoreOverrideCursor();
793 module()->update( anUpdateFlags );
795 browseObjects( aBrowseObjectsEntries );
800 QString aMsg = tr( "INPUT_VALID_DATA" );
801 if( !anErrorMsg.isEmpty() )
802 aMsg.prepend( anErrorMsg + "\n" );
803 SUIT_MessageBox::critical( module()->getApp()->desktop(),
804 tr( "INSUFFICIENT_INPUT_DATA" ),
809 void HYDROGUI_CalculationOp::onNext( const int theIndex )
813 setAvailableGroups();
815 else if( theIndex==2 )
817 // Land cover map panel
818 HYDROGUI_CalculationDlg* aPanel =
819 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
823 setLandCoverMapVisible( true );
826 QStringList anEntryList;
828 // Get all land cover map objects to fill in combo-box
829 Handle(HYDROData_LandCoverMap) aLandCoverMapObj;
830 QString aLandCoverMapName;
834 HYDROData_Iterator anIter( doc(), KIND_LAND_COVER_MAP );
835 for ( ; anIter.More(); anIter.Next() )
837 aLandCoverMapObj = Handle(HYDROData_LandCoverMap)::DownCast( anIter.Current() );
839 if ( !aLandCoverMapObj.IsNull() )
841 aLandCoverMapName = aLandCoverMapObj->GetName();
842 if ( !aLandCoverMapName.isEmpty() )
844 aList.append( aLandCoverMapName );
845 anEntryList.append( HYDROGUI_DataObject::dataObjectEntry( aLandCoverMapObj ) );
849 aPanel->setLandCoverMapsNames( aList, anEntryList );
850 aLandCoverMapObj = myEditedObject->GetLandCoverMap();
851 if ( !aList.isEmpty() )
853 if ( aLandCoverMapObj.IsNull() )
854 aPanel->setLandCoverMap( aList.at( 0 ), false );
856 aPanel->setLandCoverMap( aList.at( 0 ), true );
858 aPanel->setLandCoverMap( aList.at( aList.indexOf( aLandCoverMapObj->GetName() ) ), true );
861 // Get all Strickler table objects to fill in combo-box
862 Handle(HYDROData_StricklerTable) aStricklerTableObj;
863 QString aStricklerTableName;
867 anIter = HYDROData_Iterator( doc(), KIND_STRICKLER_TABLE );
868 for ( ; anIter.More(); anIter.Next() )
870 aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( anIter.Current() );
872 if ( !aStricklerTableObj.IsNull() )
874 aStricklerTableName = aStricklerTableObj->GetName();
875 if ( !aStricklerTableName.isEmpty() )
877 aList.append( aStricklerTableName );
878 anEntryList.append( HYDROGUI_DataObject::dataObjectEntry( aStricklerTableObj ) );
882 aPanel->setStricklerTableNames( aList, anEntryList );
883 //@ASL: bool anUpdateState = myEditedObject->IsMustBeUpdated();
884 if ( !aList.isEmpty() )
885 aPanel->setStricklerTable( aList.at( 0 ), false );
886 //@ASL: myEditedObject->SetToUpdate( anUpdateState );
888 if ( !myEditedObject.IsNull() )
892 // Select the certain Strickler table object in combo-box
893 aStricklerTableObj = myEditedObject->GetStricklerTable();
894 if ( aStricklerTableObj.IsNull() )
896 aPanel->setStricklerTable( QString() );
900 aStricklerTableName = aStricklerTableObj->GetName();
901 aPanel->setStricklerTable( aStricklerTableName );
904 // Select the certain land cover map object in combo-box
905 if ( aLandCoverMapObj.IsNull() )
907 aPanel->setLandCoverMap( QString() );
911 aLandCoverMapName = aLandCoverMapObj->GetName();
912 aPanel->setLandCoverMap( aLandCoverMapName );
917 closePreview( false );
918 createPreview( true );
920 else if( theIndex==3 )
922 HYDROGUI_CalculationDlg* aPanel =
923 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
927 QApplication::setOverrideCursor( Qt::WaitCursor );
929 setGeomObjectsVisible( false );
930 setLandCoverMapVisible( false );
932 QString aNewCaseName = aPanel->getObjectName();
933 QString anOldCaseName = myEditedObject->GetName();
934 bool isNameChanged = anOldCaseName != aNewCaseName;
936 bool anIsToUpdateOb = isNameChanged;
938 // At first we must to update the case name because of
939 // automatic names generation for regions and zones
940 myEditedObject->SetName( aNewCaseName );
942 // Zones: set parameters for automatic mode
943 int aMode = aPanel->getMode();
944 if ( aMode == HYDROData_CalculationCase::AUTOMATIC )
946 // Set objects in the specified order
947 if( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) )
949 myEditedObject->RemoveGeometryObjects();
950 foreach ( const QString& aName, aPanel->getAllGeomObjects() )
952 Handle(HYDROData_Object) anObject = Handle(HYDROData_Object)::DownCast(
953 HYDROGUI_Tool::FindObjectByName( module(), aName ) );
954 if ( anObject.IsNull() )
958 myEditedObject->AddGeometryObject( anObject );
961 // Clear priority rules
962 //@ASL if ( myEditedObject->GetRulesCount() > 0 ) {
963 myEditedObject->ClearRules( HYDROData_CalculationCase::DataTag_CustomRules, true );
965 // Set priority rules
966 foreach ( const HYDROData_CustomRule& aRule, aPanel->getRules() ) {
967 myEditedObject->AddRule( aRule.Object1, aRule.Priority,
968 aRule.Object2, aRule.MergeType,
969 HYDROData_CalculationCase::DataTag_CustomRules );
973 aPanel->setEditZonesEnabled( aMode == HYDROData_CalculationCase::MANUAL );
975 if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) )
978 myEditedObject->Update();
980 AssignDefaultZonesColors();
982 //aPanel->setEditedObject( myEditedObject );
983 aPanel->refreshZonesBrowser();
985 closePreview( false );
986 createPreview( false );
988 anIsToUpdateOb = true;
993 setZonesVisible( true );
995 if ( isNameChanged ) {
996 module()->getDataModel()->updateObjectTree( myEditedObject );
1000 QApplication::restoreOverrideCursor();
1004 void HYDROGUI_CalculationOp::onHideZones( const int theIndex )
1008 setGeomObjectsVisible( true );
1010 closePreview( false );
1011 createPreview( false );
1015 setLandCoverMapVisible( true );
1017 closePreview( false );
1018 createPreview( true );
1021 setZonesVisible( false );
1023 else if( theIndex==3 )
1025 AssignDefaultZonesColors();
1027 closePreview( false );
1028 createPreview( false );
1031 setZonesVisible( true );
1035 void HYDROGUI_CalculationOp::setZonesVisible( bool theIsVisible )
1037 myShowZones = theIsVisible;
1038 HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions();
1039 HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions );
1040 HYDROData_SequenceOfObjects aZones;
1041 Handle(HYDROData_Region) aRegion;
1042 if ( myPreviewViewManager )
1044 if ( OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer() )
1046 Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
1047 if ( !aCtx.IsNull() )
1049 for ( ; aRegionsIter.More(); aRegionsIter.Next() )
1051 aRegion = Handle(HYDROData_Region)::DownCast( aRegionsIter.Value() );
1052 if ( !aRegion.IsNull() )
1054 aZones = aRegion->GetZones();
1055 HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
1056 for ( ; aZonesIter.More(); aZonesIter.Next() )
1058 setObjectVisibility( aZonesIter.Value(), theIsVisible );
1064 module()->update( UF_OCCViewer );
1069 void HYDROGUI_CalculationOp::setGeomObjectsVisible( bool theIsVisible )
1071 myShowGeomObjects = theIsVisible;
1073 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryObjects();
1075 HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
1076 for ( ; anIter.More(); anIter.Next() ) {
1077 setObjectVisibility( anIter.Value(), theIsVisible );
1081 void HYDROGUI_CalculationOp::setLandCoverMapVisible( bool theIsVisible )
1083 myShowLandCoverMap = theIsVisible;
1084 setObjectVisibility( myEditedObject->GetLandCoverMap(), theIsVisible );
1087 void HYDROGUI_CalculationOp::AssignDefaultZonesColors()
1089 HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions();
1090 HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions );
1091 HYDROData_SequenceOfObjects aZones;
1092 Handle(HYDROData_Region) aRegion;
1093 if ( myPreviewViewManager )
1095 if ( OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer() )
1097 Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
1098 if ( !aCtx.IsNull() )
1101 for ( ; aRegionsIter.More(); aRegionsIter.Next() )
1103 aRegion = Handle(HYDROData_Region)::DownCast( aRegionsIter.Value() );
1104 if ( !aRegion.IsNull() )
1106 aZones = aRegion->GetZones();
1107 HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
1108 for ( ; aZonesIter.More(); aZonesIter.Next() )
1111 Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( aZonesIter.Value() );
1112 if ( !aZone.IsNull() )
1114 QColor aFillingColor = GenerateDefaultZonesColor(++aCounter);
1115 while (aFillingColor == Qt::red)
1116 aFillingColor = GenerateDefaultZonesColor(++aCounter);
1118 aZone->SetColor(aFillingColor);
1128 QColor HYDROGUI_CalculationOp::GenerateDefaultZonesColor( int theIndex,
1129 float theSaturation/* = 0.5*/,
1130 float theValue/* = 0.95*/ ) const
1132 float aHue = ( rand()%1000 ) * 0.001f;
1135 aColor.setHsl( (int)(aHue*255.), 128, 128 );
1136 int r = aColor.red();
1137 int g = aColor.green();
1138 int b = aColor.blue();
1139 return ( aColor.isValid() ? aColor : Qt::darkBlue );
1142 void HYDROGUI_CalculationOp::setRules( HYDROData_CalculationCase::DataTag theDataTag )
1144 HYDROGUI_CalculationDlg* aPanel =
1145 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
1149 HYDROData_ListOfRules aRules;
1150 Handle(HYDROData_Entity) anObject1, anObject2;
1151 HYDROData_PriorityType aPriority;
1152 HYDROData_Zone::MergeType aMergeType;
1153 HYDROData_CalculationCase::DataTag aDataTag = HYDROData_CalculationCase::DataTag_CustomRules;
1154 for ( int anIndex = 0; ; anIndex++ )
1156 if ( myEditedObject->GetRule( anIndex, anObject1, aPriority, anObject2, aMergeType, theDataTag ) ) {
1157 HYDROData_CustomRule aRule;
1158 aRule.Object1 = anObject1;
1159 aRule.Object2 = anObject2;
1160 aRule.Priority = aPriority;
1161 aRule.MergeType = aMergeType;
1169 if ( theDataTag == HYDROData_CalculationCase::DataTag_CustomRules )
1170 aPanel->setRules( aRules );
1173 bool HYDROGUI_CalculationOp::createRegion( const QList<SUIT_DataObject*>& theZonesList )
1175 bool aRetValue = false;
1177 QList<HYDROGUI_Zone*> aZonesList;
1178 HYDROGUI_Zone* aZone;
1179 // Get a list of dropped zones
1180 for ( int i = 0; i < theZonesList.length(); i++ )
1182 aZone = dynamic_cast<HYDROGUI_Zone*>( theZonesList.at( i ) );
1185 aZonesList.append( aZone );
1188 if ( aZonesList.length() > 0 )
1190 module()->getDataModel()->createNewRegion( myEditedObject, aZonesList );
1197 void HYDROGUI_CalculationOp::createPreview( const bool theLandCoverMap )
1199 LightApp_Application* anApp = module()->getApp();
1200 HYDROData_SequenceOfObjects aSeq;
1201 if ( theLandCoverMap && myShowLandCoverMap )
1203 aSeq.Append( myEditedObject->GetLandCoverMap() );
1205 else if ( !theLandCoverMap && myShowGeomObjects )
1207 HYDROData_SequenceOfObjects aSeqGO = myEditedObject->GetGeometryObjects();
1208 HYDROData_SequenceOfObjects aSeqP = myEditedObject->GetInterPolyObjects();
1209 aSeq.Append( aSeqGO );
1210 aSeq.Append( aSeqP );
1213 Handle(HYDROData_Entity) anEntity;
1217 // Gather zones for displaying
1218 HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions();
1219 HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions );
1220 HYDROData_SequenceOfObjects aZones;
1221 Handle(HYDROData_Region) aRegion;
1222 for ( ; aRegionsIter.More(); aRegionsIter.Next() )
1224 anEntity = aRegionsIter.Value();
1225 if ( !anEntity.IsNull() )
1227 aRegion = Handle(HYDROData_Region)::DownCast( anEntity );
1228 if ( !aRegion.IsNull() )
1230 aZones = aRegion->GetZones();
1231 aSeq.Append( aZones );
1237 // Get a boundary polyline if any
1238 aSeq.Append( myEditedObject->GetBoundaryPolyline() );
1240 module()->removeViewShapes( HYDROGUI_Module::VMR_PreviewCaseZones );
1242 if ( !myActiveViewManager )
1244 if ( aSeq.IsEmpty() )
1247 myActiveViewManager = anApp->activeViewManager();
1250 if ( !myPreviewViewManager )
1252 myPreviewViewManager = ::qobject_cast<OCCViewer_ViewManager*>(
1253 anApp->createViewManager( OCCViewer_Viewer::Type() ) );
1254 if ( myPreviewViewManager )
1256 connect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
1257 this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
1259 module()->setViewManagerRole( myPreviewViewManager, HYDROGUI_Module::VMR_PreviewCaseZones );
1260 myPreviewViewManager->setTitle( tr( "PREVIEW_CASE_ZONES" ) );
1264 if ( !myPreviewViewManager )
1267 if ( OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer() )
1269 Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
1270 if ( !aCtx.IsNull() )
1272 HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
1273 for ( ; anIter.More(); anIter.Next() )
1275 setObjectVisibility( anIter.Value(), true );
1278 //Process the draw events for viewer
1279 QApplication::processEvents( QEventLoop::ExcludeUserInputEvents );
1280 if ( OCCViewer_ViewWindow* vw = (OCCViewer_ViewWindow*)myPreviewViewManager->getActiveView() )
1284 module()->update( UF_OCCViewer | UF_FitAll );
1288 void HYDROGUI_CalculationOp::setObjectVisibility( Handle(HYDROData_Entity) theEntity, const bool theIsVisible )
1290 if ( theEntity.IsNull() || !myPreviewViewManager ) {
1294 OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
1296 module()->setObjectVisible( (size_t)aViewer, theEntity, theIsVisible );
1300 void HYDROGUI_CalculationOp::onLastViewClosed( SUIT_ViewManager* theViewManager )
1305 void HYDROGUI_CalculationOp::closePreview( bool theRemoveViewManager )
1307 SUIT_DataBrowser* aOb = ((LightApp_Application*)module()->application())->objectBrowser();
1308 QList<QShortcut*> aShortcuts = aOb->findChildren<QShortcut*>();
1309 QShortcut* aShortcut;
1310 foreach( aShortcut, aShortcuts )
1312 if ( aShortcut->key() ==
1313 QKeySequence( ((LightApp_Application*)module()->application())->objectBrowser()->shortcutKey(
1314 SUIT_DataBrowser::RenameShortcut ) ) )
1316 aShortcut->setEnabled( true );
1321 if( myPreviewViewManager )
1323 // Hide all the displayed objects in the preview view
1324 OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
1326 size_t aViewId = (size_t)aViewer;
1327 HYDROData_Iterator anIterator( doc() );
1328 for( ; anIterator.More(); anIterator.Next() ) {
1329 Handle(HYDROData_Entity) anObject = anIterator.Current();
1330 if( !anObject.IsNull() ) {
1331 module()->setObjectVisible( aViewId, anObject, false );
1336 if ( theRemoveViewManager )
1338 disconnect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
1339 this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
1341 module()->getApp()->removeViewManager( myPreviewViewManager ); // myPreviewViewManager is deleted here
1342 myPreviewViewManager = NULL;
1346 if( myActiveViewManager && theRemoveViewManager )
1348 HYDROGUI_Tool::SetActiveViewManager( module(), myActiveViewManager );
1349 myActiveViewManager = NULL;
1353 void HYDROGUI_CalculationOp::setAvailableGroups()
1355 HYDROGUI_CalculationDlg* aPanel =
1356 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
1358 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryGroups();
1359 QStringList aList, anEntryList;
1360 getNamesAndEntries( aSeq, aList, anEntryList );
1362 QStringList aGroupsNames;
1364 HYDROData_SequenceOfObjects anObjs = myEditedObject->GetGeometryObjects();
1365 for( int anIndex = 1, aLength = anObjs.Length(); anIndex <= aLength; anIndex++ )
1367 Handle_HYDROData_Object anObj = Handle_HYDROData_Object::DownCast( anObjs.Value( anIndex ) );
1368 HYDROData_SequenceOfObjects aGroups = anObj->GetGroups();
1369 for( int aGIndex = 1, aGLength = aGroups.Length(); aGIndex <= aGLength; aGIndex++ )
1371 Handle_HYDROData_ShapesGroup aGroup = Handle_HYDROData_ShapesGroup::DownCast( aGroups.Value( aGIndex ) );
1372 aGroupsNames.append( aGroup->GetName() );
1375 if( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ) {
1376 for( int anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ ) {
1377 Handle(HYDROData_ShapesGroup) aGeomGroup =
1378 Handle(HYDROData_ShapesGroup)::DownCast( aSeq.Value( anIndex ) );
1379 if ( !aGeomGroup.IsNull() && !aGroupsNames.contains( aGeomGroup->GetName() ) ) {
1380 myEditedObject->RemoveGeometryGroup( aGeomGroup );
1385 aPanel->setAvailableGroups( aGroupsNames );
1386 aPanel->includeGroups( aList );
1388 //@ASL: bool isUpdated = myEditedObject->IsMustBeUpdated();
1391 void HYDROGUI_CalculationOp::onAddGroups()
1393 HYDROGUI_CalculationDlg* aPanel =
1394 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
1398 // Add geometry objects selected in the module browser to the calculation case
1399 QStringList aSelectedList = aPanel->getSelectedAvailableGroups();
1400 if ( aSelectedList.isEmpty() || !confirmRegionsChange() )
1403 QStringList anAddedList;
1404 for (int i = 0; i < aSelectedList.length(); i++)
1406 Handle(HYDROData_ShapesGroup) aGroup = Handle(HYDROData_ShapesGroup)::DownCast(
1407 HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at( i ) ) );
1408 if ( aGroup.IsNull() )
1411 if ( myEditedObject->AddGeometryGroup( aGroup ) )
1412 anAddedList.append( aGroup->GetName() );
1415 if ( !anAddedList.isEmpty() )
1417 aPanel->includeGroups( anAddedList );
1421 void HYDROGUI_CalculationOp::onRemoveGroups()
1423 // Remove selected objects from the calculation case
1424 HYDROGUI_CalculationDlg* aPanel =
1425 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
1429 QStringList aSelectedList = aPanel->getSelectedGroups();
1430 if ( aSelectedList.isEmpty() || !confirmRegionsChange() )
1433 for (int i = 0; i < aSelectedList.length(); i++)
1435 Handle(HYDROData_ShapesGroup) aGroup = Handle(HYDROData_ShapesGroup)::DownCast(
1436 HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at(i) ) );
1437 if ( aGroup.IsNull() )
1440 myEditedObject->RemoveGeometryGroup( aGroup );
1443 aPanel->excludeGroups( aSelectedList );
1446 void HYDROGUI_CalculationOp::onChangeMode( int theMode )
1448 HYDROGUI_CalculationDlg* aPanel =
1449 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
1453 if ( !confirmModeChange() ) {
1454 aPanel->setMode( myEditedObject->GetAssignmentMode() );
1458 myEditedObject->SetAssignmentMode( (HYDROData_CalculationCase::AssignmentMode)theMode );
1459 aPanel->setMode( theMode );
1462 void HYDROGUI_CalculationOp::onOrderChanged( bool& isConfirmed )
1464 HYDROGUI_CalculationDlg* aPanel =
1465 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
1469 isConfirmed = confirmOrderChange();
1471 myEditedObject->Changed( HYDROData_Entity::Geom_2d );
1474 void HYDROGUI_CalculationOp::onRuleChanged( bool& isConfirmed )
1476 HYDROGUI_CalculationDlg* aPanel =
1477 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
1481 isConfirmed = confirmRuleChange();
1483 myEditedObject->Changed( HYDROData_Entity::Geom_2d );
1486 void HYDROGUI_CalculationOp::onRegenerateColors()
1488 // For geometry zones
1489 AssignDefaultZonesColors();
1490 setZonesVisible( false );
1491 setZonesVisible( true );