+void HYDROGUI_CalculationOp::setAvailableGroups()
+{
+ HYDROGUI_CalculationDlg* aPanel =
+ ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+
+ HYDROData_SequenceOfObjects aSeq = myEditedObject->GetGeometryGroups();
+ QStringList aList, anEntryList;
+ getNamesAndEntries( aSeq, aList, anEntryList );
+
+ QStringList aGroupsNames;
+
+ HYDROData_SequenceOfObjects anObjs = myEditedObject->GetGeometryObjects();
+ for( int anIndex = 1, aLength = anObjs.Length(); anIndex <= aLength; anIndex++ )
+ {
+ Handle(HYDROData_Object) anObj = Handle(HYDROData_Object)::DownCast( anObjs.Value( anIndex ) );
+ HYDROData_SequenceOfObjects aGroups = anObj->GetGroups();
+ for( int aGIndex = 1, aGLength = aGroups.Length(); aGIndex <= aGLength; aGIndex++ )
+ {
+ Handle(HYDROData_ShapesGroup) aGroup = Handle(HYDROData_ShapesGroup)::DownCast( aGroups.Value( aGIndex ) );
+ aGroupsNames.append( aGroup->GetName() );
+ }
+ }
+ if( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ) {
+ for( int anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ ) {
+ Handle(HYDROData_ShapesGroup) aGeomGroup =
+ Handle(HYDROData_ShapesGroup)::DownCast( aSeq.Value( anIndex ) );
+ if ( !aGeomGroup.IsNull() && !aGroupsNames.contains( aGeomGroup->GetName() ) ) {
+ myEditedObject->RemoveGeometryGroup( aGeomGroup );
+ }
+ }
+ }
+
+ aPanel->setAvailableGroups( aGroupsNames );
+ aPanel->includeGroups( aList );
+
+ //@ASL: bool isUpdated = myEditedObject->IsMustBeUpdated();
+}
+
+void HYDROGUI_CalculationOp::onAddGroups()
+{
+ HYDROGUI_CalculationDlg* aPanel =
+ ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+ if ( !aPanel )
+ return;
+
+ // Add geometry objects selected in the module browser to the calculation case
+ QStringList aSelectedList = aPanel->getSelectedAvailableGroups();
+ if ( aSelectedList.isEmpty() || !confirmRegionsChange() )
+ return;
+
+ QStringList anAddedList;
+ for (int i = 0; i < aSelectedList.length(); i++)
+ {
+ Handle(HYDROData_ShapesGroup) aGroup = Handle(HYDROData_ShapesGroup)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at( i ) ) );
+ if ( aGroup.IsNull() )
+ continue;
+
+ if ( myEditedObject->AddGeometryGroup( aGroup ) )
+ anAddedList.append( aGroup->GetName() );
+ }
+
+ if ( !anAddedList.isEmpty() )
+ {
+ aPanel->includeGroups( anAddedList );
+ }
+}
+
+void HYDROGUI_CalculationOp::onRemoveGroups()
+{
+ // Remove selected objects from the calculation case
+ HYDROGUI_CalculationDlg* aPanel =
+ ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+ if ( !aPanel )
+ return;
+
+ QStringList aSelectedList = aPanel->getSelectedGroups();
+ if ( aSelectedList.isEmpty() || !confirmRegionsChange() )
+ return;
+
+ for (int i = 0; i < aSelectedList.length(); i++)
+ {
+ Handle(HYDROData_ShapesGroup) aGroup = Handle(HYDROData_ShapesGroup)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at(i) ) );
+ if ( aGroup.IsNull() )
+ continue;
+
+ myEditedObject->RemoveGeometryGroup( aGroup );
+ }
+
+ aPanel->excludeGroups( aSelectedList );
+}
+
+
+void HYDROGUI_CalculationOp::setAvailableBoundaryPolygons()
+{
+ HYDROGUI_CalculationDlg* aPanel = ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+
+ HYDROData_Iterator anIter( doc(), KIND_BC_POLYGON );
+ Handle(HYDROData_BCPolygon) aBCP;
+ QStringList aNames;
+ QVector<int> aTypes;
+ for (;anIter.More(); anIter.Next())
+ {
+ aBCP = Handle(HYDROData_BCPolygon)::DownCast( anIter.Current() );
+ aNames.append(aBCP->GetName());
+ aTypes.append(aBCP->GetBoundaryType());
+ }
+ HYDROData_SequenceOfObjects aBCPSeq = myEditedObject->GetBoundaryPolygons();
+
+ QStringList aListCut, aListIS;
+ for (int i=1; i<=aBCPSeq.Size();i++)
+ {
+ int type = Handle(HYDROData_BCPolygon)::DownCast(aBCPSeq(i))->GetBoundaryType();
+ if (type == 1)
+ aListCut << aBCPSeq(i)->GetName();
+ else if (type == 2 || type == 3)
+ aListIS << aBCPSeq(i)->GetName();
+ }
+
+ aPanel->setAvailableBoundaryPolygons( aNames, aTypes );
+ aPanel->includeBoundaryPolygons( aListCut );
+ aPanel->includeISBoundaryPolygons( aListIS );
+}
+
+void HYDROGUI_CalculationOp::onRemoveBoundaryPolygons()
+{
+ HYDROGUI_CalculationDlg* aPanel =
+ ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+ if ( !aPanel )
+ return;
+
+ QStringList aSelectedListCut = aPanel->getSelectedBoundaryPolygons();
+ QStringList aSelectedListIS = aPanel->getSelectedISBoundaryPolygons();
+
+ if ( aSelectedListCut.isEmpty() && aSelectedListIS.isEmpty() )
+ return;
+
+ for (int i = 0; i < aSelectedListCut.length(); i++)
+ {
+ Handle(HYDROData_BCPolygon) aBCPoly = Handle(HYDROData_BCPolygon)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), aSelectedListCut.at(i) ) );
+ if ( aBCPoly.IsNull() )
+ continue;
+ myEditedObject->RemoveBoundaryPolygon( aBCPoly );
+ }
+
+ for (int i = 0; i < aSelectedListIS.length(); i++)
+ {
+ Handle(HYDROData_BCPolygon) aBCPoly = Handle(HYDROData_BCPolygon)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), aSelectedListIS.at(i) ) );
+ if ( aBCPoly.IsNull() )
+ continue;
+ myEditedObject->RemoveBoundaryPolygon( aBCPoly );
+ }
+
+ aPanel->excludeBoundaryPolygons( aSelectedListCut );
+ aPanel->excludeISBoundaryPolygons( aSelectedListIS );
+}
+
+
+void HYDROGUI_CalculationOp::onAddBoundaryPolygons()
+{
+ HYDROGUI_CalculationDlg* aPanel = ::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
+ if ( !aPanel )
+ return;
+
+ QStringList aSelectedList = aPanel->getSelectedAvailableBoundaryPolygons();
+ if ( aSelectedList.isEmpty())
+ return;
+
+ QStringList anAddedListCut, anAddedListIS;
+ for (int i = 0; i < aSelectedList.length(); i++)
+ {
+ Handle(HYDROData_BCPolygon) aBCPoly = Handle(HYDROData_BCPolygon)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at( i ) ) );
+ if ( aBCPoly.IsNull() )
+ continue;
+
+ if ( myEditedObject->AddBoundaryPolygon( aBCPoly ) )
+ {
+ QString aName = aBCPoly->GetName();
+ int type = aBCPoly->GetBoundaryType();
+ if (type == 1)
+ anAddedListCut.append(aName);
+ else if (type == 2 || type == 3)
+ anAddedListIS.append(aName);
+ }
+
+ }