X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_Region.cxx;h=698cfc944925502b5744e9ae3adc281bc39b5523;hb=a95289fabbb6fbf6f32c06207422c65aafd5bd65;hp=bddb644a80f3256ba71f9f449b0bc44c99eac59a;hpb=474c2cd65280d793f1c81ca528bc92e1cff988e6;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_Region.cxx b/src/HYDROData/HYDROData_Region.cxx index bddb644a..698cfc94 100644 --- a/src/HYDROData/HYDROData_Region.cxx +++ b/src/HYDROData/HYDROData_Region.cxx @@ -1,8 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// Copyright (C) 2014-2015 EDF-R&D // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either @@ -48,6 +44,7 @@ #include #include +#include //#define DEB_GET_REGION_SHAPE @@ -56,7 +53,7 @@ IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Region, HYDROData_Entity) HYDROData_Region::HYDROData_Region() - : HYDROData_Entity() + : HYDROData_Entity( Geom_2d ) { } @@ -111,7 +108,7 @@ bool HYDROData_Region::AddZone( const Handle(HYDROData_Zone)& theZone ) if ( !aFatherRegion.IsNull() && aFatherRegion->Label() != myLab ) { Handle(HYDROData_Zone) aNewZone = addNewZone( aDocument, "", TopoDS_Face(), QStringList() ); - theZone->CopyTo( aNewZone ); + theZone->CopyTo( aNewZone, false ); // To prevent changing of stored shape aNewZone->SetShape( theZone->GetShape() ); @@ -178,12 +175,11 @@ Handle(HYDROData_Zone) HYDROData_Region::addNewZone( const Handle(HYDROData_Docu for ( int i = 0, n = theRefObjects.length(); i < n; ++i ) { const QString& anObjName = theRefObjects.at( i ); - Handle(HYDROData_Object) aRefObject = - Handle(HYDROData_Object)::DownCast( theDoc->FindObjectByName( anObjName ) ); + Handle(HYDROData_Entity) aRefObject = theDoc->FindObjectByName( anObjName ); if ( aRefObject.IsNull() ) continue; - aNewZone->AddGeometryObject( aRefObject ); + aNewZone->AddObject( aRefObject ); } return aNewZone; @@ -393,12 +389,14 @@ TopoDS_Shape HYDROData_Region::GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs* return aResShape; } -QStringList HYDROData_Region::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const +QStringList HYDROData_Region::DumpToPython( const QString& thePyScriptPath, + MapOfTreatedObjects& theTreatedObjects, + QString defRegName ) const { QStringList aResList; // Find region - findPythonReferenceObject( theTreatedObjects, aResList ); + findPythonReferenceObject( aResList, defRegName ); // Add zones HYDROData_SequenceOfObjects aZones = GetZones(); @@ -411,12 +409,12 @@ QStringList HYDROData_Region::DumpToPython( MapOfTreatedObjects& theTreatedObjec } // find zone - aZone->findPythonReferenceObject( theTreatedObjects, aResList ); + aZone->findPythonReferenceObject( aResList ); theTreatedObjects.insert( aZone->GetName(), aZone ); // set zone merge type QString aMergeTypeStr; - HYDROData_Zone::MergeAltitudesType aMergeType = aZone->GetMergeType(); + HYDROData_Zone::MergeType aMergeType = aZone->GetMergeType(); if ( aMergeType == HYDROData_Zone::Merge_ZMIN ) { aMergeTypeStr = "HYDROData_Zone.Merge_ZMIN"; } else if ( aMergeType == HYDROData_Zone::Merge_ZMAX ) { @@ -429,17 +427,35 @@ QStringList HYDROData_Region::DumpToPython( MapOfTreatedObjects& theTreatedObjec aResList << QString( "%1.SetMergeType( %2 )" ).arg( aZone->GetObjPyName() ).arg( aMergeTypeStr ); } if ( aMergeType == HYDROData_Zone::Merge_Object ) { - Handle(HYDROData_IAltitudeObject) aMergeAltitude = aZone->GetMergeAltitude(); - if ( !aMergeAltitude.IsNull() ) { - aMergeAltitude->findPythonReferenceObject( theTreatedObjects, aResList ); - aResList << QString( "%1.SetMergeAltitude( %2 )" ).arg( aZone->GetObjPyName() ) - .arg( aMergeAltitude->GetObjPyName() ); + Handle(HYDROData_Entity) aMergeObject = aZone->GetMergeObject(); + if ( !aMergeObject.IsNull() ) { + aMergeObject->findPythonReferenceObject( aResList ); + aResList << QString( "%1.SetMergeObject( %2 )" ).arg( aZone->GetObjPyName() ) + .arg( aMergeObject->GetObjPyName() ); } } - + // set color + QColor zoneColor = aZone->GetColor(Qt::darkBlue); + aResList << QString( "%1.SetColor( QColor( %2, %3, %4 ))" ) + .arg( aZone->GetObjPyName() ).arg( zoneColor.red() ).arg( zoneColor.green() ).arg( zoneColor.blue() ); // add zone - setPythonReferenceObject( theTreatedObjects, aResList, aZone, "AddZone" ); + setPythonReferenceObject( thePyScriptPath, theTreatedObjects, aResList, aZone, "AddZone" ); + } return aResList; -} \ No newline at end of file +} + +bool HYDROData_Region::IsSubmersible() const +{ + HYDROData_SequenceOfObjects aZones = GetZones(); + HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones ); + for ( ; aZonesIter.More(); aZonesIter.Next() ) + { + Handle(HYDROData_Zone) aZone = + Handle(HYDROData_Zone)::DownCast( aZonesIter.Value() ); + if ( !aZone->IsSubmersible() ) + return false; //if one of zones is not submersible the region is considered as not submersible + } + return true; +}