#include <HYDROData_Object.h>
#include <HYDROData_Tool.h>
#include <HYDROData_StricklerTable.h>
+#include <HYDROData_BCPolygon.h>
#include <OCCViewer_ViewManager.h>
#include <OCCViewer_ViewModel.h>
QStringList anEntryList;
HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetGeometryObjects( module() );
getNamesAndEntries( aSeq, aList, anEntryList );
+
+ QStringList List1;
+ QStringList EList1;
+
+ //add intersection polylines
+ AddInterPolylinesToList(aList, anEntryList);
+
aPanel->setAllGeomObjects( aList, anEntryList );
// Get all polylines
{
aPolylineObj = Handle(HYDROData_PolylineXY)::DownCast( anIter.Current() );
- if ( !aPolylineObj.IsNull() && aPolylineObj->IsClosed() )
+ if ( !aPolylineObj.IsNull() && aPolylineObj->IsClosed(false) )
{
- // Check the polyline shape
- TopoDS_Shape aPolylineShape = aPolylineObj->GetShape();
- if ( !aPolylineShape.IsNull() && aPolylineShape.ShapeType() == TopAbs_WIRE ) {
+// // Check the polyline shape
+// TopoDS_Shape aPolylineShape = aPolylineObj->GetShape();
+// if ( !aPolylineShape.IsNull() && aPolylineShape.ShapeType() == TopAbs_WIRE ) {
aPolylineName = aPolylineObj->GetName();
if ( !aPolylineName.isEmpty() )
{
aList.append( aPolylineName );
anEntryList.append( HYDROGUI_DataObject::dataObjectEntry( aPolylineObj ) );
}
- }
+// }
}
}
aPanel->setPolylineNames( aList, anEntryList );
aPanel->setBoundary( aPolylineName );
}
- aSeq = myEditedObject->GetGeometryObjects();
+ aSeq = myEditedObject->GetGeometryObjects();
+ HYDROData_SequenceOfObjects anInterPolyList = myEditedObject->GetInterPolyObjects();
+ aSeq.Append(anInterPolyList);
+
getNamesAndEntries( aSeq, aList, anEntryList );
aPanel->includeGeomObjects( aList );
aPanel->setObjectName( anObjectName );
aPanel->setEditedObject( myEditedObject );
+ setGeomObjectsVisible( true );
+
createPreview( false );
}
+void HYDROGUI_CalculationOp::AddInterPolylinesToList(QStringList& theList, QStringList& theEntryList)
+{
+ HYDROData_Iterator anIter( doc(), KIND_POLYLINEXY );
+ Handle(HYDROData_PolylineXY) aPolylineObj;
+ QString aPolylineName;
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ aPolylineObj = Handle(HYDROData_PolylineXY)::DownCast( anIter.Current() );
+ if ( !aPolylineObj.IsNull())
+ {
+ aPolylineName = aPolylineObj->GetName();
+ if ( !aPolylineName.isEmpty() && !theList.contains(aPolylineName) )
+ {
+ theList.append( aPolylineName );
+ theEntryList.append(HYDROGUI_DataObject::dataObjectEntry( aPolylineObj ));
+ }
+ }
+ }
+}
+
void HYDROGUI_CalculationOp::getNamesAndEntries( const HYDROData_SequenceOfObjects& theSeq,
QStringList& theNames, QStringList& theEntries ) const
{
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& ) ) );
connect( aPanel, SIGNAL( Back( const int ) ), SLOT( onHideZones( const int ) ) );
//connect( aPanel, SIGNAL( clicked( SUIT_DataObject* ) ), SLOT( onSelected( SUIT_DataObject* ) ) );
connect( aPanel, SIGNAL( setMergeType( int, QString& ) ), SLOT( onSetMergeType( int, QString& ) ) );
- connect( aPanel, SIGNAL( moveZones( SUIT_DataObject*, const QList<SUIT_DataObject*>&, bool ) ),
- SLOT( onMoveZones( SUIT_DataObject*, const QList<SUIT_DataObject*>&, bool ) ) );
+ connect( aPanel, SIGNAL( moveZones( SUIT_DataObject*, const QList<SUIT_DataObject*>& ) ),
+ SLOT( onMoveZones( SUIT_DataObject*, const QList<SUIT_DataObject*>& ) ) );
connect( aPanel, SIGNAL( createRegion( const QList<SUIT_DataObject*>& ) ),
SLOT( onCreateRegion( const QList<SUIT_DataObject*>& ) ) );
connect( aPanel, SIGNAL( clickedInZonesBrowser( SUIT_DataObject* ) ),
::qobject_cast<HYDROGUI_CalculationDlg*>( inputPanel() );
if ( aPanel )
aPanel->refreshZonesBrowser();
- createPreview( false );
+ createPreview( false, false, false );
}
}
}
{
aPanel->refreshZonesBrowser();
}
- createPreview( false );
+ createPreview( false, false, false );
}
}
anAddedList.append( anObject->GetName() );
}
+ for (int i = 0; i < aSelectedList.length(); i++)
+ {
+ Handle(HYDROData_PolylineXY) aPoly = Handle(HYDROData_PolylineXY)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at( i ) ) );
+ if ( aPoly.IsNull() )
+ continue;
+
+ if ( myEditedObject->AddInterPoly( aPoly ) )
+ anAddedList.append( aPoly->GetName() );
+ }
+
if ( !anAddedList.isEmpty() )
{
aPanel->includeGeomObjects( anAddedList );
myEditedObject->RemoveGeometryObject( anObject );
}
+ for (int i = 0; i < aSelectedList.length(); i++)
+ {
+ Handle(HYDROData_PolylineXY) aPoly = Handle(HYDROData_PolylineXY)::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), aSelectedList.at(i) ) );
+ if ( aPoly.IsNull() )
+ continue;
+
+ setObjectVisibility( aPoly, false );
+ myEditedObject->RemoveInterPolyObject ( aPoly );
+ }
+
module()->update( UF_OCCViewer );
aPanel->excludeGeomObjects( aSelectedList );
}
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();
{
Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
if ( !aCtx.IsNull() )
- {
- int aCounter = 0;
+ {
for ( ; aRegionsIter.More(); aRegionsIter.Next() )
{
aRegion = Handle(HYDROData_Region)::DownCast( aRegionsIter.Value() );
Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( aZonesIter.Value() );
if ( !aZone.IsNull() )
{
- QColor aFillingColor = GenerateDefaultZonesColor(++aCounter);
+ QColor aFillingColor = HYDROData_Tool::GenerateRandColor();
while (aFillingColor == Qt::red)
- aFillingColor = GenerateDefaultZonesColor(++aCounter);
+ aFillingColor = HYDROData_Tool::GenerateRandColor();
aZone->SetColor(aFillingColor);
}
}
}
-QColor HYDROGUI_CalculationOp::GenerateDefaultZonesColor( int theIndex,
- float theSaturation/* = 0.5*/,
- float theValue/* = 0.95*/ ) const
-{
- float aHue = ( rand()%1000 ) * 0.001f;
-
- QColor aColor;
- aColor.setHsl( (int)(aHue*255.), 128, 128 );
- int r = aColor.red();
- int g = aColor.green();
- int b = aColor.blue();
- return ( aColor.isValid() ? aColor : Qt::darkBlue );
-}
-
void HYDROGUI_CalculationOp::setRules( HYDROData_CalculationCase::DataTag theDataTag )
{
HYDROGUI_CalculationDlg* aPanel =
return aRetValue;
}
-void HYDROGUI_CalculationOp::createPreview( const bool theLandCoverMap )
+void HYDROGUI_CalculationOp::createPreview( const bool theLandCoverMap, bool fitAllFlag, bool onTopViewAndFit )
{
LightApp_Application* anApp = module()->getApp();
HYDROData_SequenceOfObjects aSeq;
else if ( !theLandCoverMap && myShowGeomObjects )
{
HYDROData_SequenceOfObjects aSeqGO = myEditedObject->GetGeometryObjects();
+ HYDROData_SequenceOfObjects aSeqP = myEditedObject->GetInterPolyObjects();
aSeq.Append( aSeqGO );
+ aSeq.Append( aSeqP );
}
Handle(HYDROData_Entity) anEntity;
}
// Get a boundary polyline if any
- aSeq.Append( myEditedObject->GetBoundaryPolyline() );
+ if (Handle(HYDROData_PolylineXY) aBPoly = myEditedObject->GetBoundaryPolyline())
+ aSeq.Append( aBPoly );
module()->removeViewShapes( HYDROGUI_Module::VMR_PreviewCaseZones );
HYDROData_SequenceOfObjects::Iterator anIter( aSeq );
for ( ; anIter.More(); anIter.Next() )
{
- setObjectVisibility( anIter.Value(), true );
+ const Handle(HYDROData_Entity)& ent = anIter.Value();
+ if (!ent.IsNull())
+ setObjectVisibility( ent, true );
}
//Process the draw events for viewer
QApplication::processEvents( QEventLoop::ExcludeUserInputEvents );
- if ( OCCViewer_ViewWindow* vw = (OCCViewer_ViewWindow*)myPreviewViewManager->getActiveView() )
- vw->onTopView();
}
- module()->update( UF_OCCViewer | UF_FitAll );
+ int UpdateFlags = UF_OCCViewer;
+ if (fitAllFlag)
+ UpdateFlags |= UF_FitAll;
+ module()->update( UpdateFlags );
+
+ OCCViewer_ViewWindow* vw = (OCCViewer_ViewWindow*)myPreviewViewManager->getActiveView();
+ if ( onTopViewAndFit && vw )
+ vw->onTopView();
}
}
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 ) );
+ 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 ) );
+ Handle(HYDROData_ShapesGroup) aGroup = Handle(HYDROData_ShapesGroup)::DownCast( aGroups.Value( aGIndex ) );
aGroupsNames.append( aGroup->GetName() );
}
}
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 =