+void HYDROGUI_CalculationOp::onBoundarySelected ( const QString & theObjName )
+{
+ bool anIsToUpdateViewer = false;
+
+ // Remove the old boundary from the operation viewer
+ Handle(HYDROData_PolylineXY) aPrevPolyline =
+ myEditedObject->GetBoundaryPolyline();
+ if ( !aPrevPolyline.IsNull() )
+ {
+ setObjectVisibility( aPrevPolyline, false );
+ anIsToUpdateViewer = true;
+ }
+
+ // Set the selected boundary polyline to the calculation case
+ Handle(HYDROData_PolylineXY) aNewPolyline = Handle(HYDROData_PolylineXY)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), theObjName, KIND_POLYLINEXY ) );
+ myEditedObject->SetBoundaryPolyline( aNewPolyline );
+
+ if ( myPreviewViewManager )
+ {
+ OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
+ if ( aViewer )
+ {
+ if ( !aNewPolyline.IsNull() )
+ {
+ Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
+ if ( !aCtx.IsNull() )
+ {
+ setObjectVisibility( aNewPolyline, true );
+ anIsToUpdateViewer = true;
+ }
+ }
+
+ if ( anIsToUpdateViewer )
+ module()->update( UF_OCCViewer );
+ }
+ }
+}
+
+void HYDROGUI_CalculationOp::onStricklerTableSelected ( const QString & theObjName )
+{
+ bool anIsToUpdateViewer = false;
+
+ // Remove old presentations of land covers from the operation viewer
+ Handle(HYDROData_Entity) anEntity;
+ Handle(HYDROData_LandCover) aLandCover;
+ HYDROData_SequenceOfObjects aLandCovers;
+ HYDROData_SequenceOfObjects aSeq = myEditedObject->GetLandCovers();
+ HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ anEntity = anIter.Value();
+ if ( !anEntity.IsNull() )
+ {
+ aLandCover = Handle(HYDROData_LandCover)::DownCast( anEntity );
+ if ( !aLandCover.IsNull() )
+ {
+ aLandCovers.Append( aLandCover );
+ setObjectVisibility( aLandCover, false );
+ anIsToUpdateViewer = true;
+ }
+ }
+ }
+
+ // Set the selected Strickler table to the calculation case
+ Handle(HYDROData_StricklerTable) aNewStricklerTable = Handle(HYDROData_StricklerTable)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), theObjName, KIND_STRICKLER_TABLE ) );
+ myEditedObject->SetStricklerTable( aNewStricklerTable );
+
+ if ( myPreviewViewManager )
+ {
+ OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
+ if ( aViewer )
+ {
+ if ( !aNewStricklerTable.IsNull() )
+ {
+ Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
+ if ( !aCtx.IsNull() )
+ {
+ HYDROData_SequenceOfObjects::Iterator anIter( aLandCovers );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ anEntity = anIter.Value();
+ if ( !anEntity.IsNull() )
+ {
+ aLandCover = Handle(HYDROData_LandCover)::DownCast( anEntity );
+ if ( !aLandCover.IsNull() )
+ {
+ setObjectVisibility( aLandCover, true );
+ anIsToUpdateViewer = true;
+ }
+ }
+ }
+ }
+ }
+
+ if ( anIsToUpdateViewer )
+ module()->update( UF_OCCViewer );
+ }
+ }
+}
+
+void HYDROGUI_CalculationOp::onObjectsSelected()
+{
+ HYDROGUI_CalculationDlg* aPanel =
+ ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+
+ QStringList aSelectedObjs = aPanel->getSelectedGeomObjects();
+ QMap<QString, bool> aSelectedObjsMap;
+ foreach( QString aName, aSelectedObjs )
+ aSelectedObjsMap[aName] = true;
+
+
+ // Select the appropriate geometry object shape in the viewer
+ selectionMgr()->clearSelected();
+
+ // Unhighlight all objects except selected
+ HYDROGUI_Shape* aShape = 0, *aLastShape = 0;
+ Handle(HYDROData_Entity) anEntity;
+ HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryObjects();
+ HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
+ bool isSelected;
+ QString aName;
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ anEntity = anIter.Value();
+ if ( !anEntity.IsNull() )
+ {
+ aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anEntity );
+ if ( aShape )
+ {
+ aName = anEntity->GetName();
+ isSelected = aSelectedObjsMap.contains( aName );
+ aShape->highlight( isSelected, false );
+ aShape->update( false, false );
+ aLastShape = aShape;
+ }
+ }
+ }
+ if( aLastShape )
+ aLastShape->update( true, false );
+}
+
+void HYDROGUI_CalculationOp::onLandCoversSelected()
+{
+ HYDROGUI_CalculationDlg* aPanel =
+ ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+
+ QStringList aSelectedObjs = aPanel->getSelectedLandCovers();
+ QMap<QString, bool> aSelectedObjsMap;
+ foreach( QString aName, aSelectedObjs )
+ aSelectedObjsMap[aName] = true;
+
+
+ // Select the appropriate land cover shape in the viewer
+ selectionMgr()->clearSelected();
+
+ // Unhighlight all land covers except selected
+ HYDROGUI_Shape* aShape = 0, *aLastShape = 0;
+ Handle(HYDROData_Entity) anEntity;
+ HYDROData_SequenceOfObjects aSeq = myEditedObject->GetLandCovers();
+ HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
+ bool isSelected;
+ QString aName;
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ anEntity = anIter.Value();
+ if ( !anEntity.IsNull() )
+ {
+ aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, anEntity );
+ if ( aShape )
+ {
+ aName = anEntity->GetName();
+ isSelected = aSelectedObjsMap.contains( aName );
+ aShape->highlight( isSelected, false );
+ aShape->update( false, false );
+ aLastShape = aShape;
+ }
+ }
+ }
+ if( aLastShape )
+ aLastShape->update( true, false );
+}
+
+void HYDROGUI_CalculationOp::onClickedInZonesBrowser( SUIT_DataObject* theItem )
+{
+ HYDROGUI_Region* aRegionItem = dynamic_cast<HYDROGUI_Region*>(theItem);
+ HYDROGUI_Zone* aZoneItem;
+ selectionMgr()->clearSelected();
+ if ( aRegionItem )
+ {
+ // Select a region in preview
+ SUIT_DataOwnerPtrList aList( true );
+ DataObjectList aZones = aRegionItem->children();
+ for ( int i = 0; i < aZones.length(); i++ )
+ {
+ aZoneItem = dynamic_cast<HYDROGUI_Zone*>(aZones.at(i));
+ if ( aZoneItem )
+ {
+ aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( aZoneItem->entry() ) ) );
+ }
+ }
+ selectionMgr()->setSelected( aList );
+ }
+ else
+ {
+ // select a single zone
+ aZoneItem = dynamic_cast<HYDROGUI_Zone*>(theItem);
+ if ( aZoneItem )
+ {
+ SUIT_DataOwnerPtrList aList( true );
+ aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( aZoneItem->entry() ) ) );
+ selectionMgr()->setSelected( aList );
+ }
+ }
+}
+
+void HYDROGUI_CalculationOp::onMoveZones( SUIT_DataObject* theRegionItem, const QList<SUIT_DataObject*>& theZonesList )
+{
+ HYDROGUI_Region* aRegion = dynamic_cast<HYDROGUI_Region*>(theRegionItem);
+ if ( aRegion )
+ {
+ QList<HYDROGUI_Zone*> aZonesList;
+ HYDROGUI_Zone* aZone;
+ // Get a list of dropped zones
+ for ( int i = 0; i < theZonesList.length(); i++ )
+ {
+ aZone = dynamic_cast<HYDROGUI_Zone*>( theZonesList.at( i ) );
+ if ( aZone )
+ {
+ aZonesList.append( aZone );
+ }
+ }
+ if ( aZonesList.length() > 0 )
+ {
+ aRegion->addZones( aZonesList );
+ HYDROGUI_CalculationDlg* aPanel =
+ ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+ if ( aPanel )
+ {
+ aPanel->refreshZonesBrowser();
+ }
+ createPreview();
+ }
+ }
+}
+
+void HYDROGUI_CalculationOp::onCreateRegion( const QList<SUIT_DataObject*>& theZonesList )
+{
+ QList<HYDROGUI_Zone*> aZonesList;
+ HYDROGUI_Zone* aZone;
+ // Get a list of dropped zones
+ for ( int i = 0; i < theZonesList.length(); i++ )
+ {
+ aZone = dynamic_cast<HYDROGUI_Zone*>( theZonesList.at( i ) );
+ if ( aZone )
+ {
+ aZonesList.append( aZone );
+ }
+ }
+ if ( aZonesList.length() > 0 )
+ {
+ module()->getDataModel()->createNewRegion( myEditedObject, aZonesList );
+ HYDROGUI_CalculationDlg* aPanel =
+ ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+ if ( aPanel )
+ {
+ aPanel->refreshZonesBrowser();
+ }
+ createPreview();
+ }
+}
+
+void HYDROGUI_CalculationOp::onSetMergeType( int theMergeType, QString& theAltitudeName )
+{
+ HYDROGUI_CalculationDlg* aPanel =
+ ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+ if ( aPanel )
+ {
+ HYDROGUI_Zone* aZone = aPanel->getCurrentZone();
+ if ( aZone )
+ {
+ aZone->setMergeType( theMergeType, theAltitudeName );
+ HYDROGUI_Shape* aShape = module()->getObjectShape( HYDROGUI_Module::VMR_PreviewCaseZones, aZone->modelObject() );
+ if ( aShape )
+ {
+ aShape->update( true, false );
+ }
+ }
+ aPanel->refreshZonesBrowser();
+ }
+}
+
+void HYDROGUI_CalculationOp::onAddObjects()