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 HYDROData_SequenceOfObjects anInterPolyList = myEditedObject->GetInterPolyObjects();
159 aSeq.Append(anInterPolyList);
161 getNamesAndEntries( aSeq, aList, anEntryList );
162 aPanel->includeGeomObjects( aList );
165 setRules( HYDROData_CalculationCase::DataTag_CustomRules );
171 Handle(HYDROData_CalculationCase)::DownCast( doc()->CreateObject( KIND_CALCULATION ) );
172 myEditedObject->SetName( anObjectName );
173 myEditedObject->SetAssignmentMode( (HYDROData_CalculationCase::AssignmentMode)aPanel->getMode() );
176 aPanel->setObjectName( anObjectName );
177 aPanel->setEditedObject( myEditedObject );
179 setGeomObjectsVisible( true );
181 createPreview( false );
184 void HYDROGUI_CalculationOp::AddInterPolylinesToList(QStringList& theList, QStringList& theEntryList)
186 HYDROData_Iterator anIter( doc(), KIND_POLYLINEXY );
187 Handle(HYDROData_PolylineXY) aPolylineObj;
188 QString aPolylineName;
189 for ( ; anIter.More(); anIter.Next() )
191 aPolylineObj = Handle(HYDROData_PolylineXY)::DownCast( anIter.Current() );
192 if ( !aPolylineObj.IsNull())
194 aPolylineName = aPolylineObj->GetName();
195 if ( !aPolylineName.isEmpty() && !theList.contains(aPolylineName) )
197 theList.append( aPolylineName );
198 theEntryList.append(HYDROGUI_DataObject::dataObjectEntry( aPolylineObj ));
204 void HYDROGUI_CalculationOp::getNamesAndEntries( const HYDROData_SequenceOfObjects& theSeq,
205 QStringList& theNames, QStringList& theEntries ) const
210 HYDROData_SequenceOfObjects::Iterator anIter( theSeq );
211 for ( ; anIter.More(); anIter.Next() )
213 Handle(HYDROData_Entity) anEntity = anIter.Value();
214 //if ( !HYDROData_Tool::IsGeometryObject( anEntity ) )
217 theNames.append( anEntity->GetName() );
218 theEntries.append( HYDROGUI_DataObject::dataObjectEntry( anEntity ) );
222 void HYDROGUI_CalculationOp::abortOperation()
227 HYDROGUI_Operation::abortOperation();
228 module()->getApp()->updateObjectBrowser();
231 void HYDROGUI_CalculationOp::commitOperation()
234 // Commit transaction
235 commitDocOperation();
236 HYDROGUI_Operation::commitOperation();
239 HYDROGUI_InputPanel* HYDROGUI_CalculationOp::createInputPanel() const
241 HYDROGUI_CalculationDlg* aPanel = new HYDROGUI_CalculationDlg( module(), getName() );
243 // Connect signals and slots
244 connect( aPanel, SIGNAL( changeMode( int ) ), SLOT( onChangeMode( int ) ) );
245 connect( aPanel, SIGNAL( addObjects() ), SLOT( onAddObjects() ) );
246 connect( aPanel, SIGNAL( removeObjects() ), SLOT( onRemoveObjects() ) );
247 connect( aPanel, SIGNAL( addGroups() ), SLOT( onAddGroups() ) );
248 connect( aPanel, SIGNAL( removeGroups() ), SLOT( onRemoveGroups() ) );
250 connect( aPanel, SIGNAL( orderChanged( bool& ) ), SLOT( onOrderChanged( bool& ) ) );
252 connect( aPanel, SIGNAL( ruleChanged( bool& ) ), SLOT( onRuleChanged( bool& ) ) );
254 connect( aPanel, SIGNAL( Next( const int ) ), SLOT( onNext( const int ) ) );
255 connect( aPanel, SIGNAL( Back( const int ) ), SLOT( onHideZones( const int ) ) );
256 //connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
257 connect( aPanel, SIGNAL( setMergeType( int, QString& ) ), SLOT( onSetMergeType( int, QString& ) ) );
258 connect( aPanel, SIGNAL( moveZones( SUIT_DataObject*, const QList<SUIT_DataObject*>& ) ),
259 SLOT( onMoveZones( SUIT_DataObject*, const QList<SUIT_DataObject*>& ) ) );
260 connect( aPanel, SIGNAL( createRegion( const QList<SUIT_DataObject*>& ) ),
261 SLOT( onCreateRegion( const QList<SUIT_DataObject*>& ) ) );
262 connect( aPanel, SIGNAL( clickedInZonesBrowser( SUIT_DataObject* ) ),
263 SLOT( onClickedInZonesBrowser( SUIT_DataObject* ) ) );
264 connect( aPanel, SIGNAL( objectsSelected() ),
265 SLOT( onObjectsSelected() ) );
266 connect( aPanel, SIGNAL( landCoverMapSelected( const QString & ) ),
267 SLOT( onLandCoverMapSelected( const QString & ) ) );
268 connect( aPanel, SIGNAL( boundarySelected( const QString & ) ),
269 SLOT( onBoundarySelected( const QString & ) ) );
270 connect( aPanel, SIGNAL( StricklerTableSelected( const QString & ) ),
271 SLOT( onStricklerTableSelected( const QString & ) ) );
273 connect( aPanel, SIGNAL( regenerateColors() ), this,
274 SLOT( onRegenerateColors() ) );
279 void HYDROGUI_CalculationOp::onBoundarySelected ( const QString & theObjName )
281 bool anIsToUpdateViewer = false;
283 // Remove the old boundary from the operation viewer
284 Handle(HYDROData_PolylineXY) aPrevPolyline =
285 myEditedObject->GetBoundaryPolyline();
286 if ( !aPrevPolyline.IsNull() )
288 setObjectVisibility( aPrevPolyline, false );
289 anIsToUpdateViewer = true;
292 // Set the selected boundary polyline to the calculation case
293 Handle(HYDROData_PolylineXY) aNewPolyline = Handle(HYDROData_PolylineXY)::DownCast(
294 HYDROGUI_Tool::FindObjectByName( module(), theObjName, KIND_POLYLINEXY ) );
295 myEditedObject->SetBoundaryPolyline( aNewPolyline );
297 if ( myPreviewViewManager )
299 OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
302 if ( !aNewPolyline.IsNull() )
304 Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
305 if ( !aCtx.IsNull() )
307 setObjectVisibility( aNewPolyline, true );
308 anIsToUpdateViewer = true;
312 if ( anIsToUpdateViewer )
313 module()->update( UF_OCCViewer );
318 void HYDROGUI_CalculationOp::onStricklerTableSelected ( const QString & theObjName )
320 bool anIsToUpdateViewer = false;
322 // Remove old presentation of land cover map from the operation viewer
323 Handle(HYDROData_LandCoverMap) aLandCoverMap = myEditedObject->GetLandCoverMap();
324 if ( !aLandCoverMap.IsNull() )
326 setObjectVisibility( aLandCoverMap, false );
327 anIsToUpdateViewer = true;
330 // Set the selected Strickler table to the calculation case
331 Handle(HYDROData_StricklerTable) aNewStricklerTable = Handle(HYDROData_StricklerTable)::DownCast(
332 HYDROGUI_Tool::FindObjectByName( module(), theObjName, KIND_STRICKLER_TABLE ) );
333 myEditedObject->SetStricklerTable( aNewStricklerTable );
335 if ( myPreviewViewManager )
337 OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
340 if ( !aNewStricklerTable.IsNull() )
342 Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
343 if ( !aCtx.IsNull() )
345 if ( !aLandCoverMap.IsNull() )
347 setObjectVisibility( aLandCoverMap, true );
348 anIsToUpdateViewer = true;
353 if ( anIsToUpdateViewer )
354 module()->update( UF_OCCViewer );
359 void HYDROGUI_CalculationOp::onObjectsSelected()
361 HYDROGUI_CalculationDlg* aPanel =
362 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
364 QStringList aSelectedObjs = aPanel->getSelectedGeomObjects();
365 QMap<QString, bool> aSelectedObjsMap;
366 foreach( QString aName, aSelectedObjs )
367 aSelectedObjsMap[aName] = true;
370 // Select the appropriate geometry object shape in the viewer
371 selectionMgr()->clearSelected();
373 // Unhighlight all objects except selected
374 HYDROGUI_Shape* aShape = 0, *aLastShape = 0;
375 Handle(HYDROData_Entity) anEntity;
376 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryObjects();
377 HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
380 for ( ; anIter.More(); anIter.Next() )
382 anEntity = anIter.Value();
383 if ( !anEntity.IsNull() )
385 aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anEntity );
388 aName = anEntity->GetName();
389 isSelected = aSelectedObjsMap.contains( aName );
390 aShape->highlight( isSelected, false );
391 aShape->update( false, false );
397 aLastShape->update( true, false );
400 void HYDROGUI_CalculationOp::onLandCoverMapSelected( const QString & theObjName )
402 bool anIsToUpdateViewer = false;
404 // Remove old presentation of land cover map from the operation viewer
405 Handle(HYDROData_LandCoverMap) aPrevLandCoverMap = myEditedObject->GetLandCoverMap();
406 if ( !aPrevLandCoverMap.IsNull() )
408 setObjectVisibility( aPrevLandCoverMap, false );
409 anIsToUpdateViewer = true;
412 // Select the appropriate land cover map shape in the viewer
413 selectionMgr()->clearSelected();
415 // Set the selected land cover map to the calculation case
416 Handle(HYDROData_LandCoverMap) aNewLandCoverMap = Handle(HYDROData_LandCoverMap)::DownCast(
417 HYDROGUI_Tool::FindObjectByName( module(), theObjName, KIND_LAND_COVER_MAP ) );
418 myEditedObject->SetLandCoverMap( aNewLandCoverMap );
420 createPreview( true );
423 void HYDROGUI_CalculationOp::onClickedInZonesBrowser( SUIT_DataObject* theItem )
425 HYDROGUI_Region* aRegionItem = dynamic_cast<HYDROGUI_Region*>(theItem);
426 HYDROGUI_Zone* aZoneItem;
427 selectionMgr()->clearSelected();
430 // Select a region in preview
431 SUIT_DataOwnerPtrList aList( true );
432 DataObjectList aZones = aRegionItem->children();
433 for ( int i = 0; i < aZones.length(); i++ )
435 aZoneItem = dynamic_cast<HYDROGUI_Zone*>(aZones.at(i));
438 aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( aZoneItem->entry() ) ) );
441 selectionMgr()->setSelected( aList );
445 // select a single zone
446 aZoneItem = dynamic_cast<HYDROGUI_Zone*>(theItem);
449 SUIT_DataOwnerPtrList aList( true );
450 aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( aZoneItem->entry() ) ) );
451 selectionMgr()->setSelected( aList );
456 void HYDROGUI_CalculationOp::onMoveZones( SUIT_DataObject* theRegionItem,
457 const QList<SUIT_DataObject*>& theZonesList )
459 HYDROGUI_Region* aRegion = dynamic_cast<HYDROGUI_Region*>(theRegionItem);
462 QList<HYDROGUI_Zone*> aZonesList;
463 HYDROGUI_Zone* aZone;
464 // Get a list of dropped zones
465 for ( int i = 0; i < theZonesList.length(); i++ )
467 aZone = dynamic_cast<HYDROGUI_Zone*>( theZonesList.at( i ) );
470 aZonesList.append( aZone );
473 if ( aZonesList.length() > 0 )
475 aRegion->addZones( aZonesList );
476 HYDROGUI_CalculationDlg* aPanel =
477 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
479 aPanel->refreshZonesBrowser();
480 createPreview( false, false, false );
485 void HYDROGUI_CalculationOp::onCreateRegion( const QList<SUIT_DataObject*>& theZonesList )
487 if ( createRegion( theZonesList ) )
489 HYDROGUI_CalculationDlg* aPanel =
490 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
493 aPanel->refreshZonesBrowser();
495 createPreview( false );
499 void HYDROGUI_CalculationOp::onSetMergeType( int theMergeType, QString& theMergeObjectName )
501 HYDROGUI_CalculationDlg* aPanel =
502 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
505 HYDROGUI_Zone* aZone = aPanel->getCurrentZone();
508 aZone->setMergeType( theMergeType, theMergeObjectName );
509 HYDROGUI_Shape* aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, aZone->modelObject() );
512 aShape->update( true, false );
515 aPanel->refreshZonesBrowser();
519 void HYDROGUI_CalculationOp::onAddObjects()
521 HYDROGUI_CalculationDlg* aPanel =
522 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
526 // Add geometry objects selected in the module browser to the calculation case
527 QStringList aSelectedList = aPanel->getSelectedAvailableGeomObjects();
528 if ( aSelectedList.isEmpty() || !confirmRegionsChange() )
531 QStringList anAddedList;
532 for (int i = 0; i < aSelectedList.length(); i++)
534 Handle(HYDROData_Object) anObject = Handle(HYDROData_Object)::DownCast(
535 HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at( i ) ) );
536 if ( anObject.IsNull() )
539 if ( myEditedObject->AddGeometryObject( anObject ) )
540 anAddedList.append( anObject->GetName() );
543 for (int i = 0; i < aSelectedList.length(); i++)
545 Handle(HYDROData_PolylineXY) aPoly = Handle(HYDROData_PolylineXY)::DownCast(
546 HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at( i ) ) );
547 if ( aPoly.IsNull() )
550 if ( myEditedObject->AddInterPoly( aPoly ) )
551 anAddedList.append( aPoly->GetName() );
554 if ( !anAddedList.isEmpty() )
556 aPanel->includeGeomObjects( anAddedList );
557 createPreview( false );
561 void HYDROGUI_CalculationOp::onRemoveObjects()
563 // Remove selected objects from the calculation case
564 HYDROGUI_CalculationDlg* aPanel =
565 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
569 QStringList aSelectedList = aPanel->getSelectedGeomObjects();
570 if ( aSelectedList.isEmpty() || !confirmRegionsChange() )
573 for (int i = 0; i < aSelectedList.length(); i++)
575 Handle(HYDROData_Object) anObject = Handle(HYDROData_Object)::DownCast(
576 HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at(i) ) );
577 if ( anObject.IsNull() )
580 setObjectVisibility( anObject, false );
581 myEditedObject->RemoveGeometryObject( anObject );
584 for (int i = 0; i < aSelectedList.length(); i++)
586 Handle(HYDROData_PolylineXY) aPoly = Handle(HYDROData_PolylineXY)::DownCast(
587 HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at(i) ) );
588 if ( aPoly.IsNull() )
591 setObjectVisibility( aPoly, false );
592 myEditedObject->RemoveInterPolyObject ( aPoly );
595 module()->update( UF_OCCViewer );
596 aPanel->excludeGeomObjects( aSelectedList );
599 bool HYDROGUI_CalculationOp::confirmRegionsChange() const
601 // Check if the case is already modified or not
602 bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
605 // If not modified check if the case has already defined regions with zones
606 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions();
607 if ( aSeq.Length() > 0 )
609 // If there are already defined zones then ask a user to confirm zones recalculation
610 isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(),
611 tr( "REGIONS_CHANGED" ),
612 tr( "CONFIRM_SPLITTING_ZONES_RECALCULATION_REGIONS" ),
613 QMessageBox::Yes | QMessageBox::No,
614 QMessageBox::No ) == QMessageBox::Yes );
618 isConfirmed = true; // No regions - no zones - nothing to recalculate
624 bool HYDROGUI_CalculationOp::confirmOrderChange() const
626 // Check if the case is already modified or not
627 bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
630 // If not modified check if the case has already defined regions with zones
631 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions();
632 if ( aSeq.Length() > 0 )
634 // If there are already defined zones then ask a user to confirm zones recalculation
635 isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(),
636 tr( "ORDER_CHANGED" ),
637 tr( "CONFIRM_SPLITTING_ZONES_RECALCULATION_REGIONS" ),
638 QMessageBox::Yes | QMessageBox::No,
639 QMessageBox::No ) == QMessageBox::Yes );
643 isConfirmed = true; // No regions - no zones - nothing to recalculate
649 bool HYDROGUI_CalculationOp::confirmRuleChange() const
651 // Check if the case is already modified or not
652 bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
655 // If not modified check if the case has already defined regions with zones
656 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions();
657 if ( aSeq.Length() > 0 )
659 // If there are already defined zones then ask a user to confirm zones recalculation
660 isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(),
661 tr( "RULE_CHANGED" ),
662 tr( "CONFIRM_SPLITTING_ZONES_RECALCULATION_REGIONS" ),
663 QMessageBox::Yes | QMessageBox::No,
664 QMessageBox::No ) == QMessageBox::Yes );
668 isConfirmed = true; // No regions - no zones - nothing to recalculate
674 bool HYDROGUI_CalculationOp::confirmModeChange() const
676 // Check if the case is already modified or not
677 bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d );
680 // If not modified check if the case has already defined regions with zones
681 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetRegions();
682 if ( aSeq.Length() > 0 )
684 // If there are already defined zones then ask a user to confirm zones recalculation
685 isConfirmed = ( SUIT_MessageBox::question( module()->getApp()->desktop(),
686 tr( "MODE_CHANGED" ),
687 tr( "CONFIRM_SPLITTING_ZONES_RECALCULATION_MODE" ),
688 QMessageBox::Yes | QMessageBox::No,
689 QMessageBox::No ) == QMessageBox::Yes );
693 isConfirmed = true; // No regions - no zones - nothing to recalculate
699 bool HYDROGUI_CalculationOp::confirmContinueWithWarning( const HYDROData_Warning& theWarning ) const
701 HYDROData_WarningType aType = theWarning.Type;
702 if ( aType == WARN_OK ) {
710 case WARN_EMPTY_REGIONS:
711 aTitle = tr( "EMPTY_REGIONS" );
712 aMsg = tr( "CONFIRM_CONTINUE_WITH_OBJECTS_NOT_INCLUDED_TO_REGION" ).arg( theWarning.Data );
715 aTitle = tr( "WARNING" );
716 aMsg = theWarning.Data;
720 int anAnswer = SUIT_MessageBox::warning( module()->getApp()->desktop(),
722 QMessageBox::Yes | QMessageBox::No,
725 return ( anAnswer == QMessageBox::Yes );
728 bool HYDROGUI_CalculationOp::processApply( int& theUpdateFlags,
729 QString& theErrorMsg,
730 QStringList& theBrowseObjectsEntries )
732 HYDROGUI_CalculationDlg* aPanel =
733 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
739 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( myEditedObject );
740 theBrowseObjectsEntries.append( anEntry );
743 // For manual mode priority rules are redundant
744 if ( aPanel->getMode() == HYDROData_CalculationCase::MANUAL ) {
745 myEditedObject->ClearRules( HYDROData_CalculationCase::DataTag_CustomRules, false );
748 theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init;
753 void HYDROGUI_CalculationOp::onApply()
756 HYDROData_Warning aWarning = myEditedObject->GetLastWarning();
757 if ( aWarning.Type != WARN_OK ) {
758 if ( !confirmContinueWithWarning( aWarning ) ) {
759 // Go back to the first page
760 HYDROGUI_CalculationDlg* aPanel =
761 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
763 aPanel->onFirstPage();
769 QApplication::setOverrideCursor( Qt::WaitCursor );
771 int anUpdateFlags = 0;
773 QStringList aBrowseObjectsEntries;
775 bool aResult = false;
779 aResult = processApply( anUpdateFlags, anErrorMsg, aBrowseObjectsEntries );
781 catch ( Standard_Failure )
783 Handle(Standard_Failure) aFailure = Standard_Failure::Caught();
784 anErrorMsg = aFailure->GetMessageString();
792 QApplication::restoreOverrideCursor();
796 module()->update( anUpdateFlags );
798 browseObjects( aBrowseObjectsEntries );
803 QString aMsg = tr( "INPUT_VALID_DATA" );
804 if( !anErrorMsg.isEmpty() )
805 aMsg.prepend( anErrorMsg + "\n" );
806 SUIT_MessageBox::critical( module()->getApp()->desktop(),
807 tr( "INSUFFICIENT_INPUT_DATA" ),
812 void HYDROGUI_CalculationOp::onNext( const int theIndex )
816 setAvailableGroups();
818 else if( theIndex==2 )
820 // Land cover map panel
821 HYDROGUI_CalculationDlg* aPanel =
822 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
826 setLandCoverMapVisible( true );
829 QStringList anEntryList;
831 // Get all land cover map objects to fill in combo-box
832 Handle(HYDROData_LandCoverMap) aLandCoverMapObj;
833 QString aLandCoverMapName;
837 HYDROData_Iterator anIter( doc(), KIND_LAND_COVER_MAP );
838 for ( ; anIter.More(); anIter.Next() )
840 aLandCoverMapObj = Handle(HYDROData_LandCoverMap)::DownCast( anIter.Current() );
842 if ( !aLandCoverMapObj.IsNull() )
844 aLandCoverMapName = aLandCoverMapObj->GetName();
845 if ( !aLandCoverMapName.isEmpty() )
847 aList.append( aLandCoverMapName );
848 anEntryList.append( HYDROGUI_DataObject::dataObjectEntry( aLandCoverMapObj ) );
852 aPanel->setLandCoverMapsNames( aList, anEntryList );
853 aLandCoverMapObj = myEditedObject->GetLandCoverMap();
854 if ( !aList.isEmpty() )
856 if ( aLandCoverMapObj.IsNull() )
857 aPanel->setLandCoverMap( aList.at( 0 ), false );
859 aPanel->setLandCoverMap( aList.at( 0 ), true );
861 aPanel->setLandCoverMap( aList.at( aList.indexOf( aLandCoverMapObj->GetName() ) ), true );
864 // Get all Strickler table objects to fill in combo-box
865 Handle(HYDROData_StricklerTable) aStricklerTableObj;
866 QString aStricklerTableName;
870 anIter = HYDROData_Iterator( doc(), KIND_STRICKLER_TABLE );
871 for ( ; anIter.More(); anIter.Next() )
873 aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( anIter.Current() );
875 if ( !aStricklerTableObj.IsNull() )
877 aStricklerTableName = aStricklerTableObj->GetName();
878 if ( !aStricklerTableName.isEmpty() )
880 aList.append( aStricklerTableName );
881 anEntryList.append( HYDROGUI_DataObject::dataObjectEntry( aStricklerTableObj ) );
885 aPanel->setStricklerTableNames( aList, anEntryList );
886 //@ASL: bool anUpdateState = myEditedObject->IsMustBeUpdated();
887 if ( !aList.isEmpty() )
888 aPanel->setStricklerTable( aList.at( 0 ), false );
889 //@ASL: myEditedObject->SetToUpdate( anUpdateState );
891 if ( !myEditedObject.IsNull() )
895 // Select the certain Strickler table object in combo-box
896 aStricklerTableObj = myEditedObject->GetStricklerTable();
897 if ( aStricklerTableObj.IsNull() )
899 aPanel->setStricklerTable( QString() );
903 aStricklerTableName = aStricklerTableObj->GetName();
904 aPanel->setStricklerTable( aStricklerTableName );
907 // Select the certain land cover map object in combo-box
908 if ( aLandCoverMapObj.IsNull() )
910 aPanel->setLandCoverMap( QString() );
914 aLandCoverMapName = aLandCoverMapObj->GetName();
915 aPanel->setLandCoverMap( aLandCoverMapName );
920 closePreview( false );
921 createPreview( true );
923 else if( theIndex==3 )
925 HYDROGUI_CalculationDlg* aPanel =
926 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
930 QApplication::setOverrideCursor( Qt::WaitCursor );
932 setGeomObjectsVisible( false );
933 setLandCoverMapVisible( false );
935 QString aNewCaseName = aPanel->getObjectName();
936 QString anOldCaseName = myEditedObject->GetName();
937 bool isNameChanged = anOldCaseName != aNewCaseName;
939 bool anIsToUpdateOb = isNameChanged;
941 // At first we must to update the case name because of
942 // automatic names generation for regions and zones
943 myEditedObject->SetName( aNewCaseName );
945 // Zones: set parameters for automatic mode
946 int aMode = aPanel->getMode();
947 if ( aMode == HYDROData_CalculationCase::AUTOMATIC )
949 // Set objects in the specified order
950 if( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) )
952 myEditedObject->RemoveGeometryObjects();
953 foreach ( const QString& aName, aPanel->getAllGeomObjects() )
955 Handle(HYDROData_Object) anObject = Handle(HYDROData_Object)::DownCast(
956 HYDROGUI_Tool::FindObjectByName( module(), aName ) );
957 if ( anObject.IsNull() )
961 myEditedObject->AddGeometryObject( anObject );
964 // Clear priority rules
965 //@ASL if ( myEditedObject->GetRulesCount() > 0 ) {
966 myEditedObject->ClearRules( HYDROData_CalculationCase::DataTag_CustomRules, true );
968 // Set priority rules
969 foreach ( const HYDROData_CustomRule& aRule, aPanel->getRules() ) {
970 myEditedObject->AddRule( aRule.Object1, aRule.Priority,
971 aRule.Object2, aRule.MergeType,
972 HYDROData_CalculationCase::DataTag_CustomRules );
976 aPanel->setEditZonesEnabled( aMode == HYDROData_CalculationCase::MANUAL );
978 if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) )
981 myEditedObject->Update();
983 AssignDefaultZonesColors();
985 //aPanel->setEditedObject( myEditedObject );
986 aPanel->refreshZonesBrowser();
988 closePreview( false );
989 createPreview( false );
991 anIsToUpdateOb = true;
996 setZonesVisible( true );
998 if ( isNameChanged ) {
999 module()->getDataModel()->updateObjectTree( myEditedObject );
1003 QApplication::restoreOverrideCursor();
1007 void HYDROGUI_CalculationOp::onHideZones( const int theIndex )
1011 setGeomObjectsVisible( true );
1013 closePreview( false );
1014 createPreview( false );
1018 setLandCoverMapVisible( true );
1020 closePreview( false );
1021 createPreview( true );
1024 setZonesVisible( false );
1026 else if( theIndex==3 )
1028 AssignDefaultZonesColors();
1030 closePreview( false );
1031 createPreview( false );
1034 setZonesVisible( true );
1038 void HYDROGUI_CalculationOp::setZonesVisible( bool theIsVisible )
1040 myShowZones = theIsVisible;
1041 HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions();
1042 HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions );
1043 HYDROData_SequenceOfObjects aZones;
1044 Handle(HYDROData_Region) aRegion;
1045 if ( myPreviewViewManager )
1047 if ( OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer() )
1049 Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
1050 if ( !aCtx.IsNull() )
1052 for ( ; aRegionsIter.More(); aRegionsIter.Next() )
1054 aRegion = Handle(HYDROData_Region)::DownCast( aRegionsIter.Value() );
1055 if ( !aRegion.IsNull() )
1057 aZones = aRegion->GetZones();
1058 HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
1059 for ( ; aZonesIter.More(); aZonesIter.Next() )
1061 setObjectVisibility( aZonesIter.Value(), theIsVisible );
1067 module()->update( UF_OCCViewer );
1072 void HYDROGUI_CalculationOp::setGeomObjectsVisible( bool theIsVisible )
1074 myShowGeomObjects = theIsVisible;
1076 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryObjects();
1078 HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
1079 for ( ; anIter.More(); anIter.Next() ) {
1080 setObjectVisibility( anIter.Value(), theIsVisible );
1084 void HYDROGUI_CalculationOp::setLandCoverMapVisible( bool theIsVisible )
1086 myShowLandCoverMap = theIsVisible;
1087 setObjectVisibility( myEditedObject->GetLandCoverMap(), theIsVisible );
1090 void HYDROGUI_CalculationOp::AssignDefaultZonesColors()
1092 HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions();
1093 HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions );
1094 HYDROData_SequenceOfObjects aZones;
1095 Handle(HYDROData_Region) aRegion;
1096 if ( myPreviewViewManager )
1098 if ( OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer() )
1100 Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
1101 if ( !aCtx.IsNull() )
1104 for ( ; aRegionsIter.More(); aRegionsIter.Next() )
1106 aRegion = Handle(HYDROData_Region)::DownCast( aRegionsIter.Value() );
1107 if ( !aRegion.IsNull() )
1109 aZones = aRegion->GetZones();
1110 HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
1111 for ( ; aZonesIter.More(); aZonesIter.Next() )
1114 Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( aZonesIter.Value() );
1115 if ( !aZone.IsNull() )
1117 QColor aFillingColor = GenerateDefaultZonesColor(++aCounter);
1118 while (aFillingColor == Qt::red)
1119 aFillingColor = GenerateDefaultZonesColor(++aCounter);
1121 aZone->SetColor(aFillingColor);
1131 QColor HYDROGUI_CalculationOp::GenerateDefaultZonesColor( int theIndex,
1132 float theSaturation/* = 0.5*/,
1133 float theValue/* = 0.95*/ ) const
1135 float aHue = ( rand()%1000 ) * 0.001f;
1138 aColor.setHsl( (int)(aHue*255.), 128, 128 );
1139 int r = aColor.red();
1140 int g = aColor.green();
1141 int b = aColor.blue();
1142 return ( aColor.isValid() ? aColor : Qt::darkBlue );
1145 void HYDROGUI_CalculationOp::setRules( HYDROData_CalculationCase::DataTag theDataTag )
1147 HYDROGUI_CalculationDlg* aPanel =
1148 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
1152 HYDROData_ListOfRules aRules;
1153 Handle(HYDROData_Entity) anObject1, anObject2;
1154 HYDROData_PriorityType aPriority;
1155 HYDROData_Zone::MergeType aMergeType;
1156 HYDROData_CalculationCase::DataTag aDataTag = HYDROData_CalculationCase::DataTag_CustomRules;
1157 for ( int anIndex = 0; ; anIndex++ )
1159 if ( myEditedObject->GetRule( anIndex, anObject1, aPriority, anObject2, aMergeType, theDataTag ) ) {
1160 HYDROData_CustomRule aRule;
1161 aRule.Object1 = anObject1;
1162 aRule.Object2 = anObject2;
1163 aRule.Priority = aPriority;
1164 aRule.MergeType = aMergeType;
1172 if ( theDataTag == HYDROData_CalculationCase::DataTag_CustomRules )
1173 aPanel->setRules( aRules );
1176 bool HYDROGUI_CalculationOp::createRegion( const QList<SUIT_DataObject*>& theZonesList )
1178 bool aRetValue = false;
1180 QList<HYDROGUI_Zone*> aZonesList;
1181 HYDROGUI_Zone* aZone;
1182 // Get a list of dropped zones
1183 for ( int i = 0; i < theZonesList.length(); i++ )
1185 aZone = dynamic_cast<HYDROGUI_Zone*>( theZonesList.at( i ) );
1188 aZonesList.append( aZone );
1191 if ( aZonesList.length() > 0 )
1193 module()->getDataModel()->createNewRegion( myEditedObject, aZonesList );
1200 void HYDROGUI_CalculationOp::createPreview( const bool theLandCoverMap, bool fitAllFlag, bool onTopViewAndFit )
1202 LightApp_Application* anApp = module()->getApp();
1203 HYDROData_SequenceOfObjects aSeq;
1204 if ( theLandCoverMap && myShowLandCoverMap )
1206 aSeq.Append( myEditedObject->GetLandCoverMap() );
1208 else if ( !theLandCoverMap && myShowGeomObjects )
1210 HYDROData_SequenceOfObjects aSeqGO = myEditedObject->GetGeometryObjects();
1211 HYDROData_SequenceOfObjects aSeqP = myEditedObject->GetInterPolyObjects();
1212 aSeq.Append( aSeqGO );
1213 aSeq.Append( aSeqP );
1216 Handle(HYDROData_Entity) anEntity;
1220 // Gather zones for displaying
1221 HYDROData_SequenceOfObjects aRegions = myEditedObject->GetRegions();
1222 HYDROData_SequenceOfObjects::Iterator aRegionsIter( aRegions );
1223 HYDROData_SequenceOfObjects aZones;
1224 Handle(HYDROData_Region) aRegion;
1225 for ( ; aRegionsIter.More(); aRegionsIter.Next() )
1227 anEntity = aRegionsIter.Value();
1228 if ( !anEntity.IsNull() )
1230 aRegion = Handle(HYDROData_Region)::DownCast( anEntity );
1231 if ( !aRegion.IsNull() )
1233 aZones = aRegion->GetZones();
1234 aSeq.Append( aZones );
1240 // Get a boundary polyline if any
1241 if (Handle(HYDROData_PolylineXY) aBPoly = myEditedObject->GetBoundaryPolyline())
1242 aSeq.Append( aBPoly );
1244 module()->removeViewShapes( HYDROGUI_Module::VMR_PreviewCaseZones );
1246 if ( !myActiveViewManager )
1248 if ( aSeq.IsEmpty() )
1251 myActiveViewManager = anApp->activeViewManager();
1254 if ( !myPreviewViewManager )
1256 myPreviewViewManager = ::qobject_cast<OCCViewer_ViewManager*>(
1257 anApp->createViewManager( OCCViewer_Viewer::Type() ) );
1258 if ( myPreviewViewManager )
1260 connect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
1261 this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
1263 module()->setViewManagerRole( myPreviewViewManager, HYDROGUI_Module::VMR_PreviewCaseZones );
1264 myPreviewViewManager->setTitle( tr( "PREVIEW_CASE_ZONES" ) );
1268 if ( !myPreviewViewManager )
1271 if ( OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer() )
1273 Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
1274 if ( !aCtx.IsNull() )
1276 HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
1277 for ( ; anIter.More(); anIter.Next() )
1279 const Handle(HYDROData_Entity)& ent = anIter.Value();
1281 setObjectVisibility( ent, true );
1284 //Process the draw events for viewer
1285 QApplication::processEvents( QEventLoop::ExcludeUserInputEvents );
1288 int UpdateFlags = UF_OCCViewer;
1290 UpdateFlags |= UF_FitAll;
1291 module()->update( UpdateFlags );
1293 OCCViewer_ViewWindow* vw = (OCCViewer_ViewWindow*)myPreviewViewManager->getActiveView();
1294 if ( onTopViewAndFit && vw )
1299 void HYDROGUI_CalculationOp::setObjectVisibility( Handle(HYDROData_Entity) theEntity, const bool theIsVisible )
1301 if ( theEntity.IsNull() || !myPreviewViewManager ) {
1305 OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
1307 module()->setObjectVisible( (size_t)aViewer, theEntity, theIsVisible );
1311 void HYDROGUI_CalculationOp::onLastViewClosed( SUIT_ViewManager* theViewManager )
1316 void HYDROGUI_CalculationOp::closePreview( bool theRemoveViewManager )
1318 SUIT_DataBrowser* aOb = ((LightApp_Application*)module()->application())->objectBrowser();
1319 QList<QShortcut*> aShortcuts = aOb->findChildren<QShortcut*>();
1320 QShortcut* aShortcut;
1321 foreach( aShortcut, aShortcuts )
1323 if ( aShortcut->key() ==
1324 QKeySequence( ((LightApp_Application*)module()->application())->objectBrowser()->shortcutKey(
1325 SUIT_DataBrowser::RenameShortcut ) ) )
1327 aShortcut->setEnabled( true );
1332 if( myPreviewViewManager )
1334 // Hide all the displayed objects in the preview view
1335 OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
1337 size_t aViewId = (size_t)aViewer;
1338 HYDROData_Iterator anIterator( doc() );
1339 for( ; anIterator.More(); anIterator.Next() ) {
1340 Handle(HYDROData_Entity) anObject = anIterator.Current();
1341 if( !anObject.IsNull() ) {
1342 module()->setObjectVisible( aViewId, anObject, false );
1347 if ( theRemoveViewManager )
1349 disconnect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ),
1350 this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) );
1352 module()->getApp()->removeViewManager( myPreviewViewManager ); // myPreviewViewManager is deleted here
1353 myPreviewViewManager = NULL;
1357 if( myActiveViewManager && theRemoveViewManager )
1359 HYDROGUI_Tool::SetActiveViewManager( module(), myActiveViewManager );
1360 myActiveViewManager = NULL;
1364 void HYDROGUI_CalculationOp::setAvailableGroups()
1366 HYDROGUI_CalculationDlg* aPanel =
1367 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
1369 HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryGroups();
1370 QStringList aList, anEntryList;
1371 getNamesAndEntries( aSeq, aList, anEntryList );
1373 QStringList aGroupsNames;
1375 HYDROData_SequenceOfObjects anObjs = myEditedObject->GetGeometryObjects();
1376 for( int anIndex = 1, aLength = anObjs.Length(); anIndex <= aLength; anIndex++ )
1378 Handle(HYDROData_Object) anObj = Handle(HYDROData_Object)::DownCast( anObjs.Value( anIndex ) );
1379 HYDROData_SequenceOfObjects aGroups = anObj->GetGroups();
1380 for( int aGIndex = 1, aGLength = aGroups.Length(); aGIndex <= aGLength; aGIndex++ )
1382 Handle(HYDROData_ShapesGroup) aGroup = Handle(HYDROData_ShapesGroup)::DownCast( aGroups.Value( aGIndex ) );
1383 aGroupsNames.append( aGroup->GetName() );
1386 if( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ) {
1387 for( int anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ ) {
1388 Handle(HYDROData_ShapesGroup) aGeomGroup =
1389 Handle(HYDROData_ShapesGroup)::DownCast( aSeq.Value( anIndex ) );
1390 if ( !aGeomGroup.IsNull() && !aGroupsNames.contains( aGeomGroup->GetName() ) ) {
1391 myEditedObject->RemoveGeometryGroup( aGeomGroup );
1396 aPanel->setAvailableGroups( aGroupsNames );
1397 aPanel->includeGroups( aList );
1399 //@ASL: bool isUpdated = myEditedObject->IsMustBeUpdated();
1402 void HYDROGUI_CalculationOp::onAddGroups()
1404 HYDROGUI_CalculationDlg* aPanel =
1405 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
1409 // Add geometry objects selected in the module browser to the calculation case
1410 QStringList aSelectedList = aPanel->getSelectedAvailableGroups();
1411 if ( aSelectedList.isEmpty() || !confirmRegionsChange() )
1414 QStringList anAddedList;
1415 for (int i = 0; i < aSelectedList.length(); i++)
1417 Handle(HYDROData_ShapesGroup) aGroup = Handle(HYDROData_ShapesGroup)::DownCast(
1418 HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at( i ) ) );
1419 if ( aGroup.IsNull() )
1422 if ( myEditedObject->AddGeometryGroup( aGroup ) )
1423 anAddedList.append( aGroup->GetName() );
1426 if ( !anAddedList.isEmpty() )
1428 aPanel->includeGroups( anAddedList );
1432 void HYDROGUI_CalculationOp::onRemoveGroups()
1434 // Remove selected objects from the calculation case
1435 HYDROGUI_CalculationDlg* aPanel =
1436 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
1440 QStringList aSelectedList = aPanel->getSelectedGroups();
1441 if ( aSelectedList.isEmpty() || !confirmRegionsChange() )
1444 for (int i = 0; i < aSelectedList.length(); i++)
1446 Handle(HYDROData_ShapesGroup) aGroup = Handle(HYDROData_ShapesGroup)::DownCast(
1447 HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at(i) ) );
1448 if ( aGroup.IsNull() )
1451 myEditedObject->RemoveGeometryGroup( aGroup );
1454 aPanel->excludeGroups( aSelectedList );
1457 void HYDROGUI_CalculationOp::onChangeMode( int theMode )
1459 HYDROGUI_CalculationDlg* aPanel =
1460 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
1464 if ( !confirmModeChange() ) {
1465 aPanel->setMode( myEditedObject->GetAssignmentMode() );
1469 myEditedObject->SetAssignmentMode( (HYDROData_CalculationCase::AssignmentMode)theMode );
1470 aPanel->setMode( theMode );
1473 void HYDROGUI_CalculationOp::onOrderChanged( bool& isConfirmed )
1475 HYDROGUI_CalculationDlg* aPanel =
1476 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
1480 isConfirmed = confirmOrderChange();
1482 myEditedObject->Changed( HYDROData_Entity::Geom_2d );
1485 void HYDROGUI_CalculationOp::onRuleChanged( bool& isConfirmed )
1487 HYDROGUI_CalculationDlg* aPanel =
1488 ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
1492 isConfirmed = confirmRuleChange();
1494 myEditedObject->Changed( HYDROData_Entity::Geom_2d );
1497 void HYDROGUI_CalculationOp::onRegenerateColors()
1499 // For geometry zones
1500 AssignDefaultZonesColors();
1501 setZonesVisible( false );
1502 setZonesVisible( true );