#include <HYDROData_Object.h>
#include <HYDROData_Tool.h>
#include <HYDROData_StricklerTable.h>
+#include <HYDROData_BCPolygon.h>
#include <OCCViewer_ViewManager.h>
#include <OCCViewer_ViewModel.h>
connect( aPanel, SIGNAL( addGroups() ), SLOT( onAddGroups() ) );
connect( aPanel, SIGNAL( removeGroups() ), SLOT( onRemoveGroups() ) );
+ connect( aPanel, SIGNAL( addBoundaryPolygons() ), SLOT( onAddBoundaryPolygons() ) );
+ connect( aPanel, SIGNAL( removeBoundaryPolygons() ), SLOT( onRemoveBoundaryPolygons() ) );
+
connect( aPanel, SIGNAL( orderChanged( bool& ) ), SLOT( onOrderChanged( bool& ) ) );
connect( aPanel, SIGNAL( ruleChanged( bool& ) ), SLOT( onRuleChanged( bool& ) ) );
setAvailableGroups();
}
else if( theIndex==2 )
+ {
+ setAvailableBoundaryPolygons();
+ }
+ else if( theIndex==3 )
{
// Land cover map panel
HYDROGUI_CalculationDlg* aPanel =
closePreview( false );
createPreview( true );
}
- else if( theIndex==3 )
+ else if( theIndex==4 )
{
HYDROGUI_CalculationDlg* aPanel =
::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
closePreview( false );
createPreview( false );
}
- if( theIndex==2 )
+ if( theIndex==3 )
{
setLandCoverMapVisible( true );
// Hide zones
setZonesVisible( false );
}
- else if( theIndex==3 )
+ else if( theIndex==4 )
{
AssignDefaultZonesColors();
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);
+ }
+
+ }
+
+ if ( !anAddedListCut.isEmpty() )
+ aPanel->includeBoundaryPolygons(anAddedListCut);
+ if ( !anAddedListIS.isEmpty() )
+ aPanel->includeISBoundaryPolygons(anAddedListIS);
+}
+
void HYDROGUI_CalculationOp::onChangeMode( int theMode )
{
HYDROGUI_CalculationDlg* aPanel =