From d6a8c59ee076938a924fcfd1e3f83ef1395b7336 Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Wed, 28 Oct 2015 08:24:21 +0100 Subject: [PATCH] merge BR_v14_rc --- CMakeLists.txt | 6 + bin/hydro_setenv.py | 8 + doc/salome/CMakeLists.txt | 1 + src/HYDROData/HYDROData_ArtificialObject.cxx | 4 +- src/HYDROData/HYDROData_ArtificialObject.h | 2 +- src/HYDROData/HYDROData_Bathymetry.cxx | 16 +- src/HYDROData/HYDROData_CalculationCase.cxx | 40 ++- src/HYDROData/HYDROData_Channel.cxx | 23 +- src/HYDROData/HYDROData_Channel.h | 10 + src/HYDROData/HYDROData_Confluence.cxx | 2 +- src/HYDROData/HYDROData_DummyObject3D.cxx | 2 +- src/HYDROData/HYDROData_Entity.cxx | 103 ++++-- src/HYDROData/HYDROData_Entity.h | 41 ++- src/HYDROData/HYDROData_IAltitudeObject.cxx | 2 +- src/HYDROData/HYDROData_IPolyline.cxx | 2 +- src/HYDROData/HYDROData_Image.cxx | 40 +-- src/HYDROData/HYDROData_ImmersibleZone.cxx | 9 +- src/HYDROData/HYDROData_LandCover.cxx | 3 +- src/HYDROData/HYDROData_NaturalObject.cxx | 4 +- src/HYDROData/HYDROData_NaturalObject.h | 2 +- src/HYDROData/HYDROData_Object.cxx | 31 +- src/HYDROData/HYDROData_Object.h | 4 +- src/HYDROData/HYDROData_Obstacle.cxx | 2 +- src/HYDROData/HYDROData_Polyline3D.cxx | 10 +- src/HYDROData/HYDROData_PolylineXY.cxx | 22 +- src/HYDROData/HYDROData_Profile.cxx | 12 +- src/HYDROData/HYDROData_Region.cxx | 4 +- src/HYDROData/HYDROData_River.cxx | 2 +- src/HYDROData/HYDROData_ShapesGroup.cxx | 2 +- src/HYDROData/HYDROData_Stream.cxx | 50 +-- src/HYDROData/HYDROData_Stream.h | 3 +- src/HYDROData/HYDROData_StreamAltitude.cxx | 349 +++++++++++-------- src/HYDROData/HYDROData_StreamAltitude.h | 8 +- src/HYDROData/HYDROData_StricklerTable.cxx | 3 +- src/HYDROData/HYDROData_Tool.cxx | 122 +++++-- src/HYDROData/HYDROData_Tool.h | 27 +- src/HYDROData/HYDROData_VisualState.cxx | 2 +- src/HYDROData/HYDROData_Zone.cxx | 2 +- src/HYDROData/test_HYDROData_Bathymetry.cxx | 2 +- src/HYDROData/test_HYDROData_Entity.cxx | 2 +- src/HYDROData/test_HYDROData_Image.cxx | 2 +- src/HYDROData/test_HYDROData_PolylineXY.cxx | 2 +- src/HYDROGUI/HYDROGUI_CalculationOp.cxx | 38 +- src/HYDROGUI/HYDROGUI_ChannelOp.cxx | 2 +- src/HYDROGUI/HYDROGUI_DataModel.cxx | 2 +- src/HYDROGUI/HYDROGUI_DataObject.cxx | 6 +- src/HYDROGUI/HYDROGUI_LandCoverOp.cxx | 2 +- src/HYDROGUI/HYDROGUI_Module.cxx | 2 +- src/HYDROGUI/HYDROGUI_Polyline.cxx | 38 +- src/HYDROGUI/HYDROGUI_ProfileOp.cxx | 2 +- src/HYDROGUI/HYDROGUI_StreamOp.cxx | 2 +- src/HYDROGUI/HYDROGUI_UpdateObjectOp.cxx | 2 +- src/HYDROGUI/HYDROGUI_ViewerDlg.cxx | 2 +- src/HYDROPy/HYDROData_Entity.sip | 43 +-- 54 files changed, 664 insertions(+), 460 deletions(-) create mode 100644 bin/hydro_setenv.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d87ed59..601d0ab6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -251,3 +251,9 @@ INSTALL(FILES # Install the export set for use with the install-tree INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}" FILE ${PROJECT_NAME}Targets.cmake) + + + +SET(_bin_scripts bin/hydro_setenv.py) +SALOME_INSTALL_SCRIPTS("${_bin_scripts}" ${SALOME_INSTALL_SCRIPT_SCRIPTS}) + diff --git a/bin/hydro_setenv.py b/bin/hydro_setenv.py new file mode 100644 index 00000000..866a0f2d --- /dev/null +++ b/bin/hydro_setenv.py @@ -0,0 +1,8 @@ +#! /usr/bin/env python +# -*- coding: iso-8859-1 -*- + +import os + +def set_env( args ): + os.environ["SALOME_MODULES_ORDER"] = "HYDRO,GEOM,SMESH" + pass diff --git a/doc/salome/CMakeLists.txt b/doc/salome/CMakeLists.txt index c4b6fb90..9a0a069e 100644 --- a/doc/salome/CMakeLists.txt +++ b/doc/salome/CMakeLists.txt @@ -21,3 +21,4 @@ # ADD_SUBDIRECTORY(gui) +ADD_SUBDIRECTORY(examples) diff --git a/src/HYDROData/HYDROData_ArtificialObject.cxx b/src/HYDROData/HYDROData_ArtificialObject.cxx index 170477a8..80a47654 100644 --- a/src/HYDROData/HYDROData_ArtificialObject.cxx +++ b/src/HYDROData/HYDROData_ArtificialObject.cxx @@ -21,8 +21,8 @@ IMPLEMENT_STANDARD_HANDLE(HYDROData_ArtificialObject,HYDROData_Object) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ArtificialObject,HYDROData_Object) -HYDROData_ArtificialObject::HYDROData_ArtificialObject() -: HYDROData_Object() +HYDROData_ArtificialObject::HYDROData_ArtificialObject( Geometry theGeometry ) +: HYDROData_Object( theGeometry ) { } diff --git a/src/HYDROData/HYDROData_ArtificialObject.h b/src/HYDROData/HYDROData_ArtificialObject.h index e12d6a3f..dc91253b 100644 --- a/src/HYDROData/HYDROData_ArtificialObject.h +++ b/src/HYDROData/HYDROData_ArtificialObject.h @@ -48,7 +48,7 @@ protected: * Creates new object in the internal data structure. Use higher level objects * to create objects with real content. */ - HYDRODATA_EXPORT HYDROData_ArtificialObject(); + HYDRODATA_EXPORT HYDROData_ArtificialObject( Geometry ); /** * Destructs properties of the object and object itself, removes it from the document. diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx index 2f09868e..1e819a86 100644 --- a/src/HYDROData/HYDROData_Bathymetry.cxx +++ b/src/HYDROData/HYDROData_Bathymetry.cxx @@ -113,7 +113,7 @@ void HYDROData_Bathymetry::SetAltitudePoints( const AltitudePoints& thePoints ) aCoordsArray->SetValue( i * 3 + 2, aPoint.Z() ); } - SetToUpdate( true ); + Changed( Geom_Z ); } HYDROData_Bathymetry::AltitudePoints HYDROData_Bathymetry::GetAltitudePoints(bool IsConvertToGlobal) const @@ -192,12 +192,12 @@ HYDROData_QuadtreeNode* HYDROData_Bathymetry::GetQuadtreeNodes() const void HYDROData_Bathymetry::RemoveAltitudePoints() { - TDF_Label aLabel = myLab.FindChild(DataTag_AltitudePoints, false); - if (!aLabel.IsNull()) - { - aLabel.ForgetAllAttributes(); - SetToUpdate(true); - } + TDF_Label aLabel = myLab.FindChild( DataTag_AltitudePoints, false ); + if ( !aLabel.IsNull() ) + { + aLabel.ForgetAllAttributes(); + Changed( Geom_Z ); + } } void interpolateAltitudeForPoints( const gp_XY& thePoint, @@ -449,7 +449,7 @@ void HYDROData_Bathymetry::SetAltitudesInverted( const bool theIsInverted, TDataStd_Integer::Set( myLab.FindChild( DataTag_AltitudesInverted ), (Standard_Integer)theIsInverted ); - SetToUpdate( true ); + Changed( Geom_Z ); if ( !theIsUpdate ) return; diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index 4f95d9ec..07397d1a 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -86,7 +86,7 @@ IMPLEMENT_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_CalculationCase, HYDROData_Entity) HYDROData_CalculationCase::HYDROData_CalculationCase() -: HYDROData_Entity() +: HYDROData_Entity( Geom_2d_and_groups ) { } @@ -508,7 +508,7 @@ bool HYDROData_CalculationCase::AddGeometryObject( const Handle(HYDROData_Object AddReferenceObject( theObject, DataTag_GeometryObject ); // Indicate model of the need to update splitting - SetToUpdate( true ); + Changed( Geom_2d ); return true; } @@ -526,7 +526,7 @@ void HYDROData_CalculationCase::RemoveGeometryObject( const Handle(HYDROData_Obj RemoveReferenceObject( theObject->Label(), DataTag_GeometryObject ); // Indicate model of the need to update splitting - SetToUpdate( true ); + Changed( Geom_2d ); } void HYDROData_CalculationCase::RemoveGeometryObjects() @@ -534,7 +534,7 @@ void HYDROData_CalculationCase::RemoveGeometryObjects() ClearReferenceObjects( DataTag_GeometryObject ); // Indicate model of the need to update splitting - SetToUpdate( true ); + Changed( Geom_2d ); } bool HYDROData_CalculationCase::AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup ) @@ -548,7 +548,7 @@ bool HYDROData_CalculationCase::AddGeometryGroup( const Handle(HYDROData_ShapesG AddReferenceObject( theGroup, DataTag_GeometryGroup ); // Indicate model of the need to update splitting - SetToUpdate( true ); + Changed( Geom_Groups ); return true; } @@ -566,7 +566,7 @@ void HYDROData_CalculationCase::RemoveGeometryGroup( const Handle(HYDROData_Shap RemoveReferenceObject( theGroup->Label(), DataTag_GeometryGroup ); // Indicate model of the need to update splitting - SetToUpdate( true ); + Changed( Geom_Groups ); } void HYDROData_CalculationCase::RemoveGeometryGroups() @@ -574,7 +574,7 @@ void HYDROData_CalculationCase::RemoveGeometryGroups() ClearReferenceObjects( DataTag_GeometryGroup ); // Indicate model of the need to update splitting - SetToUpdate( true ); + Changed( Geom_Groups ); } void HYDROData_CalculationCase::SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline ) @@ -584,7 +584,8 @@ void HYDROData_CalculationCase::SetBoundaryPolyline( const Handle(HYDROData_Poly SetReferenceObject( thePolyline, DataTag_Polyline ); // Indicate model of the need to update zones splitting - SetToUpdate( !IsEqual( aPrevPolyline, thePolyline ) || IsMustBeUpdated() ); + if( !IsEqual( aPrevPolyline, thePolyline ) ) + Changed( Geom_2d ); } Handle(HYDROData_PolylineXY) HYDROData_CalculationCase::GetBoundaryPolyline() const @@ -600,7 +601,7 @@ void HYDROData_CalculationCase::RemoveBoundaryPolyline() ClearReferenceObjects( DataTag_Polyline ); // Indicate model of the need to update zones splitting - SetToUpdate( !aPrevPolyline.IsNull() || IsMustBeUpdated() ); + Changed( Geom_2d ); } void HYDROData_CalculationCase::SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable ) @@ -610,7 +611,8 @@ void HYDROData_CalculationCase::SetStricklerTable( const Handle(HYDROData_Strick SetReferenceObject( theStricklerTable, DataTag_StricklerTable ); // Indicate model of the need to update land covers partition - SetToUpdate( !IsEqual( aPrevStricklerTable, theStricklerTable ) || IsMustBeUpdated() ); + if( !IsEqual( aPrevStricklerTable, theStricklerTable ) ) + Changed( Geom_No ); } Handle(HYDROData_StricklerTable) HYDROData_CalculationCase::GetStricklerTable() const @@ -626,7 +628,7 @@ void HYDROData_CalculationCase::RemoveStricklerTable() ClearReferenceObjects( DataTag_StricklerTable ); // Indicate model of the need to update land covers partition - SetToUpdate( !aPrevStricklerTable.IsNull() || IsMustBeUpdated() ); + Changed( Geom_No ); } bool HYDROData_CalculationCase::AddLandCover( const Handle(HYDROData_LandCover)& theLandCover ) @@ -637,7 +639,7 @@ bool HYDROData_CalculationCase::AddLandCover( const Handle(HYDROData_LandCover)& AddReferenceObject( theLandCover, DataTag_LandCover ); // Indicate model of the need to update land covers partition - SetToUpdate( true ); + Changed( Geom_No ); return true; } @@ -655,7 +657,7 @@ void HYDROData_CalculationCase::RemoveLandCover( const Handle(HYDROData_LandCove RemoveReferenceObject( theLandCover->Label(), DataTag_LandCover ); // Indicate model of the need to update land cover partition - SetToUpdate( true ); + Changed( Geom_No ); } void HYDROData_CalculationCase::RemoveLandCovers() @@ -663,7 +665,7 @@ void HYDROData_CalculationCase::RemoveLandCovers() ClearReferenceObjects( DataTag_LandCover ); // Indicate model of the need to update land cover partition - SetToUpdate( true ); + Changed( Geom_No ); } Handle(HYDROData_Region) HYDROData_CalculationCase::AddNewRegion( const Handle(HYDROData_Zone)& theZone, @@ -699,7 +701,7 @@ bool HYDROData_CalculationCase::AddRegion( const Handle(HYDROData_Region)& theRe if ( !aFatherCalc.IsNull() && aFatherCalc->Label() != myLab ) { Handle(HYDROData_Region) aNewRegion = addNewRegion( aDocument, CALCULATION_REGIONS_PREF, theLandCover ); - theRegion->CopyTo( aNewRegion ); + theRegion->CopyTo( aNewRegion, true ); aFatherCalc->RemoveRegion( theRegion, theLandCover ); @@ -1328,7 +1330,7 @@ void HYDROData_CalculationCase::ClearRules( HYDROData_CalculationCase::DataTag t // Indicate model of the need to update splitting if ( theIsSetToUpdate ) { - SetToUpdate( true ); + Changed( Geom_2d ); } } @@ -1342,7 +1344,7 @@ void HYDROData_CalculationCase::AddRule( const Handle(HYDROData_Entity)& theO HYDROData_PriorityQueue::AddRule( aRulesLab, theObject1, thePriority, theObject2, theMergeType ); // Indicate model of the need to update splitting - SetToUpdate( true ); + Changed( Geom_2d ); } QString HYDROData_CalculationCase::DumpRules() const @@ -1363,7 +1365,7 @@ void HYDROData_CalculationCase::SetAssignmentMode( AssignmentMode theMode ) TDataStd_Integer::Set( aModeLab, ( int ) theMode ); // Indicate model of the need to update splitting - SetToUpdate( true ); + Changed( Geom_2d ); } HYDROData_CalculationCase::AssignmentMode HYDROData_CalculationCase::GetAssignmentMode() const @@ -1466,7 +1468,7 @@ void HYDROData_CalculationCase::SetAssignmentLandCoverMode( AssignmentMode theMo TDataStd_Integer::Set( aModeLab, ( int ) theMode ); // Indicate model of the need to update land covers partition - SetToUpdate( true ); + Changed( Geom_No ); } HYDROData_CalculationCase::AssignmentMode HYDROData_CalculationCase::GetAssignmentLandCoverMode() const diff --git a/src/HYDROData/HYDROData_Channel.cxx b/src/HYDROData/HYDROData_Channel.cxx index 84135941..a2e84537 100644 --- a/src/HYDROData/HYDROData_Channel.cxx +++ b/src/HYDROData/HYDROData_Channel.cxx @@ -27,6 +27,7 @@ #include "HYDROData_ShapesTool.h" #include "HYDROData_Pipes.h" #include "HYDROData_Stream.h" +#include "HYDROData_Tool.h" #include @@ -75,7 +76,7 @@ IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Channel,HYDROData_ArtificialObject) HYDROData_Channel::HYDROData_Channel() -: HYDROData_ArtificialObject() +: HYDROData_ArtificialObject( Geom_3d ) { } @@ -401,7 +402,7 @@ bool HYDROData_Channel::SetGuideLine( const Handle(HYDROData_Polyline3D)& theGui SetReferenceObject( theGuideLine, DataTag_GuideLine ); // Indicate model of the need to update the chanel presentation - SetToUpdate( true ); + Changed( Geom_3d ); return true; } @@ -421,7 +422,7 @@ void HYDROData_Channel::RemoveGuideLine() ClearReferenceObjects( DataTag_GuideLine ); // Indicate model of the need to update the chanel presentation - SetToUpdate( true ); + Changed( Geom_3d ); } bool HYDROData_Channel::SetProfile( const Handle(HYDROData_Profile)& theProfile ) @@ -440,7 +441,7 @@ bool HYDROData_Channel::SetProfile( const Handle(HYDROData_Profile)& theProfile SetReferenceObject( theProfile, DataTag_Profile ); // Indicate model of the need to update the chanel presentation - SetToUpdate( true ); + Changed( Geom_3d ); return true; } @@ -460,12 +461,24 @@ void HYDROData_Channel::RemoveProfile() ClearReferenceObjects( DataTag_Profile ); // Indicate model of the need to update the chanel presentation - SetToUpdate( true ); + Changed( Geom_3d ); } ObjectKind HYDROData_Channel::getAltitudeObjectType() const { DEBTRACE("HYDROData_Channel::getAltitudeObjectType"); return KIND_CHANNEL_ALTITUDE; + //return KIND_STREAM_ALTITUDE; } +TopoDS_Shape HYDROData_Channel::GetLeftShape() const +{ + HYDROData_SequenceOfObjects aGroups = GetGroups(); + return HYDROData_Tool::getFirstShapeFromGroup( aGroups, 1); +} + +TopoDS_Shape HYDROData_Channel::GetRightShape() const +{ + HYDROData_SequenceOfObjects aGroups = GetGroups(); + return HYDROData_Tool::getFirstShapeFromGroup( aGroups, 2); +} diff --git a/src/HYDROData/HYDROData_Channel.h b/src/HYDROData/HYDROData_Channel.h index a53db842..5b4e694f 100644 --- a/src/HYDROData/HYDROData_Channel.h +++ b/src/HYDROData/HYDROData_Channel.h @@ -100,6 +100,16 @@ public: */ HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const; + /** + * Returns the left edge of the channel. + */ + HYDRODATA_EXPORT virtual TopoDS_Shape GetLeftShape() const; + + /** + * Returns the right edge of the channel. + */ + HYDRODATA_EXPORT virtual TopoDS_Shape GetRightShape() const; + /** * Update the shape presentations of stream. * Call this method whenever you made changes for channel data. diff --git a/src/HYDROData/HYDROData_Confluence.cxx b/src/HYDROData/HYDROData_Confluence.cxx index 12f19b5a..6efb1a7f 100644 --- a/src/HYDROData/HYDROData_Confluence.cxx +++ b/src/HYDROData/HYDROData_Confluence.cxx @@ -29,7 +29,7 @@ IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Confluence,HYDROData_NaturalObject) HYDROData_Confluence::HYDROData_Confluence() -: HYDROData_NaturalObject() +: HYDROData_NaturalObject( Geom_3d ) { } diff --git a/src/HYDROData/HYDROData_DummyObject3D.cxx b/src/HYDROData/HYDROData_DummyObject3D.cxx index f4f665b6..fbc4851d 100644 --- a/src/HYDROData/HYDROData_DummyObject3D.cxx +++ b/src/HYDROData/HYDROData_DummyObject3D.cxx @@ -29,7 +29,7 @@ IMPLEMENT_STANDARD_HANDLE(HYDROData_DummyObject3D,HYDROData_Entity) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_DummyObject3D,HYDROData_Entity) HYDROData_DummyObject3D::HYDROData_DummyObject3D() -: HYDROData_Entity() +: HYDROData_Entity( Geom_3d ) { } diff --git a/src/HYDROData/HYDROData_Entity.cxx b/src/HYDROData/HYDROData_Entity.cxx index ac0c5962..6af65981 100644 --- a/src/HYDROData/HYDROData_Entity.cxx +++ b/src/HYDROData/HYDROData_Entity.cxx @@ -41,7 +41,7 @@ #define _DEVDEBUG_ #include "HYDRO_trace.hxx" -static const Standard_GUID GUID_MUST_BE_UPDATED("80f2bb81-3873-4631-8ddd-940d2119f000"); +//static const Standard_GUID GUID_MUST_BE_UPDATED("80f2bb81-3873-4631-8ddd-940d2119f000"); IMPLEMENT_STANDARD_HANDLE(HYDROData_Entity,MMgt_TShared) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Entity,MMgt_TShared) @@ -85,7 +85,7 @@ QStringList HYDROData_Entity::DumpToPython( MapOfTreatedObjects& theTreatedObjec void HYDROData_Entity::Update() { - SetToUpdate( false ); + ClearChanged(); } void HYDROData_Entity::UpdateLocalCS( double theDx, double theDy ) @@ -115,31 +115,59 @@ QVariant HYDROData_Entity::GetDataVariant() return QVariant(); } -void HYDROData_Entity::SetToUpdate( bool theFlag ) +void HYDROData_Entity::ClearChanged() { - if ( IsMustBeUpdated() == theFlag ) + TDataStd_Integer::Set( myLab.FindChild( DataTag_GeomChange ), 0 ); +} + +int HYDROData_Entity::GetGeomChangeFlag() const +{ + int aGeomChangeFlag = 0; + Handle(TDataStd_Integer) aGeomChangeAttr; + TDF_Label aGeomChangeLab = myLab.FindChild( DataTag_GeomChange ); + aGeomChangeLab.FindAttribute( TDataStd_Integer::GetID(), aGeomChangeAttr ); + if ( !aGeomChangeAttr.IsNull() ) + aGeomChangeFlag = aGeomChangeAttr->Get(); + return aGeomChangeFlag; +} + +void HYDROData_Entity::Changed( Geometry theChangedGeometry ) +{ + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); + if( aDocument.IsNull() ) return; - if ( theFlag ) - { - TDataStd_UAttribute::Set( myLab, GUID_MUST_BE_UPDATED ); + int aGeomChangeFlag = 0; + Handle(TDataStd_Integer) aGeomChangeAttr; + TDF_Label aGeomChangeLab = myLab.FindChild( DataTag_GeomChange ); + aGeomChangeLab.FindAttribute( TDataStd_Integer::GetID(), aGeomChangeAttr ); + if ( !aGeomChangeAttr.IsNull() ) + aGeomChangeFlag = aGeomChangeAttr->Get(); + + int aBitsToChange = ( myGeom & theChangedGeometry ); + if( aBitsToChange == 0 ) + return; - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); - if ( !aDocument.IsNull() ) + aGeomChangeFlag = ( aGeomChangeFlag | aBitsToChange ); + TDataStd_Integer::Set( aGeomChangeLab, aGeomChangeFlag ); + + HYDROData_Iterator anIter( aDocument ); + for ( ; anIter.More(); anIter.Next() ) + { + Handle(HYDROData_Entity) anObject = anIter.Current(); + HYDROData_SequenceOfObjects aRefSeq = anObject->GetAllReferenceObjects(); + for ( int i = 1, n = aRefSeq.Length(); i <= n; ++i ) { - // Change the states of this and all depended objects - HYDROData_Tool::SetMustBeUpdatedObjects( aDocument ); + Handle(HYDROData_Entity) aRefObject = aRefSeq.Value( i ); + if( aRefObject->Label()==myLab ) + anObject->Changed( theChangedGeometry ); } } - else - { - myLab.ForgetAttribute( GUID_MUST_BE_UPDATED ); - } } -bool HYDROData_Entity::IsMustBeUpdated() const +bool HYDROData_Entity::IsMustBeUpdated( Geometry theGeom ) const { - return myLab.IsAttribute( GUID_MUST_BE_UPDATED ); + return ( ( GetGeomChangeFlag() & theGeom ) != 0 ); } bool HYDROData_Entity::CanBeUpdated() const @@ -162,7 +190,8 @@ bool HYDROData_Entity::CanRemove() return true; } -HYDROData_Entity::HYDROData_Entity() +HYDROData_Entity::HYDROData_Entity( Geometry theGeom ) + : myGeom( theGeom ) { } @@ -170,7 +199,8 @@ HYDROData_Entity::~HYDROData_Entity() { } -void HYDROData_Entity::CopyTo( const Handle(HYDROData_Entity)& theDestination ) const +void HYDROData_Entity::CopyTo( const Handle(HYDROData_Entity)& theDestination, + bool isGenerateNewName ) const { Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); if ( aDocument.IsNull() ) { @@ -180,23 +210,26 @@ void HYDROData_Entity::CopyTo( const Handle(HYDROData_Entity)& theDestination ) TDF_CopyLabel aCopy(myLab, theDestination->Label()); aCopy.Perform(); - // generate a new unique name for the clone object: - // case 1: Image_1 -> Image_2 - // case 2: ImageObj -> ImageObj_1 - QString aName = theDestination->GetName(); - QString aPrefix = aName; - if( aName.contains( '_' ) ) { // case 1 - QString aSuffix = aName.section( '_', -1 ); - bool anIsInteger = false; - aSuffix.toInt( &anIsInteger ); - if( anIsInteger ) - aPrefix = aName.section( '_', 0, -2 ); - } else { // case 2 - aPrefix = aName; - } + if( isGenerateNewName ) + { + // generate a new unique name for the clone object: + // case 1: Image_1 -> Image_2 + // case 2: ImageObj -> ImageObj_1 + QString aName = theDestination->GetName(); + QString aPrefix = aName; + if( aName.contains( '_' ) ) { // case 1 + QString aSuffix = aName.section( '_', -1 ); + bool anIsInteger = false; + aSuffix.toInt( &anIsInteger ); + if( anIsInteger ) + aPrefix = aName.section( '_', 0, -2 ); + } else { // case 2 + aPrefix = aName; + } - aName = HYDROData_Tool::GenerateObjectName( aDocument, aPrefix ); - theDestination->SetName( aName ); + aName = HYDROData_Tool::GenerateObjectName( aDocument, aPrefix ); + theDestination->SetName( aName ); + } } Handle(HYDROData_Entity) HYDROData_Entity::GetFatherObject() const diff --git a/src/HYDROData/HYDROData_Entity.h b/src/HYDROData/HYDROData_Entity.h index 8661f3e2..833751ee 100644 --- a/src/HYDROData/HYDROData_Entity.h +++ b/src/HYDROData/HYDROData_Entity.h @@ -86,9 +86,7 @@ HYDRODATA_EXPORT bool IsEqual(const Handle_HYDROData_Entity& theObj1, const Hand */ class HYDROData_Entity : public MMgt_TShared { - protected: - /** * Enumeration of tags corresponding to the persistent object parameters. */ @@ -96,6 +94,20 @@ protected: { DataTag_First = 0, ///< first tag, to reserve DataTag_ZLevel, ///< z-level of object presentation + DataTag_GeomChange, + }; + +public: + enum Geometry + { + Geom_No = 1, + Geom_2d = 2, + Geom_Z = 4, + Geom_Groups = 8, + + Geom_3d = Geom_2d | Geom_Z, + Geom_2d_and_groups = Geom_2d | Geom_Groups, + Geom_All = Geom_3d | Geom_Groups | Geom_No, }; public: @@ -114,7 +126,7 @@ public: /** * Updates the name of this object. */ - HYDRODATA_EXPORT virtual void SetName( const QString& theName ); + HYDRODATA_EXPORT void SetName( const QString& theName ); /** * Returns the name of this object valid for Python script. @@ -154,17 +166,11 @@ public: HYDRODATA_EXPORT virtual QVariant GetDataVariant(); - /** - * Sets the "MustBeUpdated" flag: if object is depended on updated features. - * \param theFlag is true for objects that must be updated, false for up-to-date - */ - HYDRODATA_EXPORT virtual void SetToUpdate( bool theFlag ); - /** - * Returns the "MustBeUpdated" flag: is object data must be updated or not - * \returns false if object is up to date - */ - HYDRODATA_EXPORT virtual bool IsMustBeUpdated() const; + HYDRODATA_EXPORT virtual void ClearChanged(); + HYDRODATA_EXPORT virtual void Changed( Geometry ); + + HYDRODATA_EXPORT bool IsMustBeUpdated( Geometry ) const; /** * Returns flag indicating that object is updateble or not. @@ -196,7 +202,8 @@ public: * Objects must be the same type. * \param theDestination initialized object (from any document) - target of copying */ - HYDRODATA_EXPORT virtual void CopyTo( const Handle(HYDROData_Entity)& theDestination ) const; + HYDRODATA_EXPORT virtual void CopyTo( const Handle(HYDROData_Entity)& theDestination, + bool isGenerateNewName ) const; /** * Returns the label of this object. @@ -263,7 +270,7 @@ protected: * Creates new object in the internal data structure. Use higher level objects * to create objects with real content. */ - HYDRODATA_EXPORT HYDROData_Entity(); + HYDRODATA_EXPORT HYDROData_Entity( Geometry ); /** * Destructs properties of the object and object itself, removes it from the document. @@ -410,16 +417,18 @@ protected: const QColor& theColor, const QColor& theDefaultColor, const QString& theMethod ) const; - protected: Handle(TDataStd_ReferenceList) getReferenceList( const int theTag, const bool theIsCreate ) const; + int GetGeomChangeFlag() const; + protected: /// Array of pointers to the properties of this object; index in this array is returned by \a AddProperty. TDF_Label myLab; ///< label of this object + Geometry myGeom; }; #endif diff --git a/src/HYDROData/HYDROData_IAltitudeObject.cxx b/src/HYDROData/HYDROData_IAltitudeObject.cxx index 521308af..3bafc988 100644 --- a/src/HYDROData/HYDROData_IAltitudeObject.cxx +++ b/src/HYDROData/HYDROData_IAltitudeObject.cxx @@ -26,7 +26,7 @@ IMPLEMENT_STANDARD_HANDLE(HYDROData_IAltitudeObject, HYDROData_Entity) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_IAltitudeObject, HYDROData_Entity) HYDROData_IAltitudeObject::HYDROData_IAltitudeObject() -: HYDROData_Entity() +: HYDROData_Entity( Geom_Z ) { } diff --git a/src/HYDROData/HYDROData_IPolyline.cxx b/src/HYDROData/HYDROData_IPolyline.cxx index df150b0a..695bf84a 100755 --- a/src/HYDROData/HYDROData_IPolyline.cxx +++ b/src/HYDROData/HYDROData_IPolyline.cxx @@ -36,7 +36,7 @@ IMPLEMENT_STANDARD_HANDLE(HYDROData_IPolyline, HYDROData_Entity) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_IPolyline, HYDROData_Entity) HYDROData_IPolyline::HYDROData_IPolyline() -: HYDROData_Entity() +: HYDROData_Entity( Geom_2d ) { } diff --git a/src/HYDROData/HYDROData_Image.cxx b/src/HYDROData/HYDROData_Image.cxx index b7ec1096..e1787ada 100644 --- a/src/HYDROData/HYDROData_Image.cxx +++ b/src/HYDROData/HYDROData_Image.cxx @@ -46,7 +46,7 @@ IMPLEMENT_STANDARD_HANDLE(HYDROData_Image, HYDROData_Entity) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Image, HYDROData_Entity) HYDROData_Image::HYDROData_Image() -: HYDROData_Entity() +: HYDROData_Entity( Geom_2d ) { } @@ -175,7 +175,7 @@ QStringList HYDROData_Image::DumpToPython( MapOfTreatedObjects& theTreatedObject void HYDROData_Image::Update() { - bool anIsToUpdate = IsMustBeUpdated(); + bool anIsToUpdate = IsMustBeUpdated( Geom_2d ); HYDROData_Entity::Update(); @@ -226,7 +226,7 @@ void HYDROData_Image::Update() UpdateTrsf(); } - SetToUpdate( false ); + ClearChanged(); } bool HYDROData_Image::IsHas2dPrs() const @@ -294,7 +294,7 @@ void HYDROData_Image::SetImage(const QImage& theImage) SaveByteArray(0, aData, anImage.byteCount()); } - SetToUpdate( true ); + Changed( Geom_2d ); } bool HYDROData_Image::LoadImage( const QString& theFilePath ) @@ -326,7 +326,7 @@ void HYDROData_Image::SetFilePath( const QString& theFilePath ) TCollection_AsciiString anAsciiStr( theFilePath.toStdString().c_str() ); TDataStd_AsciiString::Set( myLab.FindChild( DataTag_FilePath ), anAsciiStr ); - SetToUpdate( true ); + Changed( Geom_2d ); } QString HYDROData_Image::GetFilePath() const @@ -362,7 +362,7 @@ void HYDROData_Image::SetTrsf(const QTransform& theTrsf) anArray->SetValue(8, theTrsf.m32()); anArray->SetValue(9, theTrsf.m33()); - SetToUpdate( true ); + Changed( Geom_2d ); } QTransform HYDROData_Image::Trsf() const @@ -507,7 +507,7 @@ void HYDROData_Image::RemoveAllReferences() QImage anImage = Image(); if ( anImage.isNull() ) { - SetToUpdate( false ); + ClearChanged(); return; } @@ -528,7 +528,7 @@ void HYDROData_Image::RemoveAllReferences() SetGlobalPoints( ManualCartesian, aTrsfPointA, aTrsfPointB, aTrsfPointC ); - SetToUpdate( false ); + ClearChanged(); } void HYDROData_Image::SetLocalPoints( const QPoint& thePointA, @@ -552,7 +552,7 @@ void HYDROData_Image::SetLocalPoints( const QPoint& thePointA, if ( theIsUpdate ) UpdateTrsf(); - SetToUpdate( true ); + Changed( Geom_2d ); } bool HYDROData_Image::GetLocalPoints( QPoint& thePointA, @@ -607,7 +607,7 @@ void HYDROData_Image::SetGlobalPoints( const TransformationMode& theMode, if ( theIsUpdate ) UpdateTrsf(); - SetToUpdate( true ); + Changed( Geom_2d ); } bool HYDROData_Image::GetGlobalPoints( TransformationMode& theMode, @@ -759,7 +759,7 @@ bool HYDROData_Image::HasReferencePoints() const void HYDROData_Image::SetTrsfMode( const TransformationMode& theMode ) { TDataStd_Integer::Set( myLab.FindChild( DataTag_TrsfMode ), (int)theMode ); - SetToUpdate( true ); + Changed( Geom_2d ); } HYDROData_Image::TransformationMode HYDROData_Image::GetTrsfMode() const @@ -780,7 +780,7 @@ HYDROData_Image::TransformationMode HYDROData_Image::GetTrsfMode() const void HYDROData_Image::SetTrsfReferenceImage( const Handle(HYDROData_Image)& theRefImage ) { SetReferenceObject( theRefImage, DataTag_TrsfImage ); - SetToUpdate( true ); + Changed( Geom_2d ); } Handle(HYDROData_Image) HYDROData_Image::GetTrsfReferenceImage() const @@ -791,13 +791,13 @@ Handle(HYDROData_Image) HYDROData_Image::GetTrsfReferenceImage() const void HYDROData_Image::RemoveTrsfReferenceImage() { RemoveReferenceObject( DataTag_TrsfImage ); - SetToUpdate( true ); + Changed( Geom_2d ); } void HYDROData_Image::AppendReference( const Handle(HYDROData_Entity)& theReferenced ) { AddReferenceObject( theReferenced, 0 ); - SetToUpdate( true ); + Changed( Geom_2d ); } int HYDROData_Image::NbReferences() const @@ -814,26 +814,26 @@ void HYDROData_Image::ChangeReference( const int theIndex, Handle(HYDROData_Entity) theReferenced) { SetReferenceObject( theReferenced, 0, theIndex ); - SetToUpdate( true ); + Changed( Geom_2d ); } void HYDROData_Image::RemoveReference(const int theIndex) { RemoveReferenceObject( 0, theIndex ); - SetToUpdate( true ); + Changed( Geom_2d ); } void HYDROData_Image::ClearReferences() { ClearReferenceObjects( 0 ); - SetToUpdate( true ); + Changed( Geom_2d ); } void HYDROData_Image::SetOperatorName( const QString theOpName ) { TCollection_AsciiString anAsciiStr( theOpName.toStdString().c_str() ); TDataStd_AsciiString::Set( myLab.FindChild( DataTag_Operator ), anAsciiStr ); - SetToUpdate( true ); + Changed( Geom_2d ); } QString HYDROData_Image::OperatorName() const @@ -854,7 +854,7 @@ QString HYDROData_Image::OperatorName() const void HYDROData_Image::SetArgs(const QByteArray& theArgs) { SaveByteArray(DataTag_Operator, theArgs.constData(), theArgs.length()); - SetToUpdate( true ); + Changed( Geom_2d ); } QByteArray HYDROData_Image::Args() const @@ -873,7 +873,7 @@ void HYDROData_Image::SetIsSelfSplitted(bool theFlag) } else { myLab.ForgetAttribute(GUID_SELF_SPLITTED); } - SetToUpdate( true ); + Changed( Geom_2d ); } bool HYDROData_Image::IsSelfSplitted() const diff --git a/src/HYDROData/HYDROData_ImmersibleZone.cxx b/src/HYDROData/HYDROData_ImmersibleZone.cxx index ae2b7ddd..9b0cfdd8 100644 --- a/src/HYDROData/HYDROData_ImmersibleZone.cxx +++ b/src/HYDROData/HYDROData_ImmersibleZone.cxx @@ -49,7 +49,7 @@ IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ImmersibleZone,HYDROData_NaturalObject) HYDROData_ImmersibleZone::HYDROData_ImmersibleZone() -: HYDROData_NaturalObject() +: HYDROData_NaturalObject( Geom_2d ) { } @@ -261,8 +261,11 @@ QColor HYDROData_ImmersibleZone::getDefaultBorderColor() const void HYDROData_ImmersibleZone::SetPolyline( const Handle(HYDROData_PolylineXY)& thePolyline ) { + if( IsEqual( GetPolyline(), thePolyline ) ) + return; + SetReferenceObject( thePolyline, DataTag_Polyline ); - SetToUpdate( true ); + Changed( Geom_2d ); } Handle(HYDROData_PolylineXY) HYDROData_ImmersibleZone::GetPolyline() const @@ -274,7 +277,7 @@ Handle(HYDROData_PolylineXY) HYDROData_ImmersibleZone::GetPolyline() const void HYDROData_ImmersibleZone::RemovePolyline() { ClearReferenceObjects( DataTag_Polyline ); - SetToUpdate( true ); + Changed( Geom_2d ); } diff --git a/src/HYDROData/HYDROData_LandCover.cxx b/src/HYDROData/HYDROData_LandCover.cxx index 278f42c5..d17b5243 100644 --- a/src/HYDROData/HYDROData_LandCover.cxx +++ b/src/HYDROData/HYDROData_LandCover.cxx @@ -46,6 +46,7 @@ IMPLEMENT_STANDARD_HANDLE( HYDROData_LandCover, HYDROData_Entity ) IMPLEMENT_STANDARD_RTTIEXT( HYDROData_LandCover, HYDROData_Entity ) HYDROData_LandCover::HYDROData_LandCover() +: HYDROData_Entity( Geom_2d ) { } @@ -133,7 +134,7 @@ void HYDROData_LandCover::Update() void HYDROData_LandCover::SetPolylines( const HYDROData_SequenceOfObjects& thePolylines ) { SetReferenceObjects( thePolylines, DataTag_Polylines ); - SetToUpdate( true ); + Changed( Geom_2d ); } HYDROData_SequenceOfObjects HYDROData_LandCover::GetPolylines() const diff --git a/src/HYDROData/HYDROData_NaturalObject.cxx b/src/HYDROData/HYDROData_NaturalObject.cxx index fb7e9314..d1142455 100644 --- a/src/HYDROData/HYDROData_NaturalObject.cxx +++ b/src/HYDROData/HYDROData_NaturalObject.cxx @@ -21,8 +21,8 @@ IMPLEMENT_STANDARD_HANDLE(HYDROData_NaturalObject,HYDROData_Object) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_NaturalObject,HYDROData_Object) -HYDROData_NaturalObject::HYDROData_NaturalObject() -: HYDROData_Object() +HYDROData_NaturalObject::HYDROData_NaturalObject( Geometry theGeometry ) +: HYDROData_Object( theGeometry ) { } diff --git a/src/HYDROData/HYDROData_NaturalObject.h b/src/HYDROData/HYDROData_NaturalObject.h index 4454437d..e002b9a7 100644 --- a/src/HYDROData/HYDROData_NaturalObject.h +++ b/src/HYDROData/HYDROData_NaturalObject.h @@ -48,7 +48,7 @@ protected: * Creates new object in the internal data structure. Use higher level objects * to create objects with real content. */ - HYDRODATA_EXPORT HYDROData_NaturalObject(); + HYDRODATA_EXPORT HYDROData_NaturalObject( Geometry ); /** * Destructs properties of the object and object itself, removes it from the document. diff --git a/src/HYDROData/HYDROData_Object.cxx b/src/HYDROData/HYDROData_Object.cxx index 6a8ee297..3683d30c 100644 --- a/src/HYDROData/HYDROData_Object.cxx +++ b/src/HYDROData/HYDROData_Object.cxx @@ -39,8 +39,8 @@ IMPLEMENT_STANDARD_HANDLE(HYDROData_Object,HYDROData_Entity) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Object,HYDROData_Entity) -HYDROData_Object::HYDROData_Object() -: HYDROData_Entity() +HYDROData_Object::HYDROData_Object( Geometry theGeometry ) + : HYDROData_Entity( theGeometry ) { } @@ -79,9 +79,14 @@ void HYDROData_Object::SetName( const QString& theName ) void HYDROData_Object::Update() { - removeTopShape(); - removeShape3D(); - removeGroupObjects(); + if( IsMustBeUpdated( Geom_2d ) ) + { + removeTopShape(); + removeGroupObjects(); + } + if( IsMustBeUpdated( Geom_3d ) ) + removeShape3D(); + checkAndSetAltitudeObject(); HYDROData_Entity::Update(); } @@ -97,13 +102,13 @@ HYDROData_SequenceOfObjects HYDROData_Object::GetAllReferenceObjects() const return aResSeq; } -void HYDROData_Object::SetToUpdate( bool theFlag ) +void HYDROData_Object::Changed( Geometry theChangedGeometry ) { - HYDROData_Entity::SetToUpdate( theFlag ); + HYDROData_Entity::Changed( theChangedGeometry ); Handle(HYDROData_DummyObject3D) anObject3D = GetObject3D(); if ( !anObject3D.IsNull() ) - anObject3D->SetToUpdate( theFlag ); + anObject3D->Changed( theChangedGeometry ); } void HYDROData_Object::SetTopShape( const TopoDS_Shape& theShape ) @@ -198,8 +203,9 @@ bool HYDROData_Object::SetAltitudeObject( SetReferenceObject( theAltitude, DataTag_AltitudeObject ); - // Indicate model of the need to update object - SetToUpdate( true ); + // #636: In the case of the altitude object change the geometry of the main object is not changed, + // to the object should not be marked as updated + //SetToUpdate( true ); return true; } @@ -218,8 +224,9 @@ void HYDROData_Object::RemoveAltitudeObject() ClearReferenceObjects( DataTag_AltitudeObject ); - // Indicate model of the need to update object - SetToUpdate( true ); + // #636: In the case of the altitude object change the geometry of the main object is not changed, + // to the object should not be marked as updated + //SetToUpdate( true ); } void HYDROData_Object::SetFillingColor( const QColor& theColor ) diff --git a/src/HYDROData/HYDROData_Object.h b/src/HYDROData/HYDROData_Object.h index 56e1c4a0..e97144aa 100644 --- a/src/HYDROData/HYDROData_Object.h +++ b/src/HYDROData/HYDROData_Object.h @@ -76,7 +76,7 @@ public: * Sets the "MustBeUpdated" flag: if object is depended on updated features. * Reimplemented to update the state of child 3D object. */ - HYDRODATA_EXPORT virtual void SetToUpdate( bool theFlag ); + HYDRODATA_EXPORT virtual void Changed( Geometry ); /** @@ -178,7 +178,7 @@ protected: * Creates new object in the internal data structure. Use higher level objects * to create objects with real content. */ - HYDRODATA_EXPORT HYDROData_Object(); + HYDRODATA_EXPORT HYDROData_Object( Geometry ); /** * Destructs properties of the object and object itself, removes it from the document. diff --git a/src/HYDROData/HYDROData_Obstacle.cxx b/src/HYDROData/HYDROData_Obstacle.cxx index 00f332b9..2f37ee1d 100644 --- a/src/HYDROData/HYDROData_Obstacle.cxx +++ b/src/HYDROData/HYDROData_Obstacle.cxx @@ -65,7 +65,7 @@ IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Obstacle,HYDROData_ArtificialObject) HYDROData_Obstacle::HYDROData_Obstacle() -: HYDROData_ArtificialObject() +: HYDROData_ArtificialObject( Geom_3d ) { } diff --git a/src/HYDROData/HYDROData_Polyline3D.cxx b/src/HYDROData/HYDROData_Polyline3D.cxx index 50822459..f2cb00e4 100644 --- a/src/HYDROData/HYDROData_Polyline3D.cxx +++ b/src/HYDROData/HYDROData_Polyline3D.cxx @@ -58,7 +58,7 @@ IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Polyline3D,HYDROData_Object) HYDROData_Polyline3D::HYDROData_Polyline3D() -: HYDROData_Object() +: HYDROData_Object( Geom_3d ) { } @@ -249,7 +249,7 @@ bool HYDROData_Polyline3D::SetPolylineXY( const Handle(HYDROData_PolylineXY)& th updateChildProfilePoints(); // Indicate model of the need to update the polyline presentation - SetToUpdate( true ); + Changed( Geom_2d ); return true; } @@ -269,7 +269,7 @@ void HYDROData_Polyline3D::RemovePolylineXY() ClearReferenceObjects( DataTag_PolylineXY ); // Indicate model of the need to update the polyline presentation - SetToUpdate( true ); + Changed( Geom_2d ); } bool HYDROData_Polyline3D::SetProfileUZ( const Handle(HYDROData_ProfileUZ)& theProfile ) @@ -287,7 +287,7 @@ bool HYDROData_Polyline3D::SetProfileUZ( const Handle(HYDROData_ProfileUZ)& theP RemoveAltitudeObject(); // Indicate model of the need to update the polyline presentation - SetToUpdate( true ); + Changed( Geom_Z ); return true; } @@ -307,7 +307,7 @@ void HYDROData_Polyline3D::RemoveProfileUZ() ClearReferenceObjects( DataTag_ProfileUZ ); // Indicate model of the need to update the polyline presentation - SetToUpdate( true ); + Changed( Geom_Z ); } bool HYDROData_Polyline3D::SetAltitudeObject( diff --git a/src/HYDROData/HYDROData_PolylineXY.cxx b/src/HYDROData/HYDROData_PolylineXY.cxx index 839e949a..8c97c15d 100755 --- a/src/HYDROData/HYDROData_PolylineXY.cxx +++ b/src/HYDROData/HYDROData_PolylineXY.cxx @@ -484,7 +484,7 @@ void HYDROData_PolylineXY::Update() if ( !IsEditable() ) { // If polyline is not editable we no need to update it wire - SetToUpdate( false ); + ClearChanged(); return; } @@ -710,7 +710,7 @@ void HYDROData_PolylineXY::AddSection( const TCollection_AsciiString& theSectNam aTypesList->Append( theSectionType ); aClosuresList->Append( theIsClosed ); - SetToUpdate( true ); + Changed( Geom_2d ); } TCollection_AsciiString HYDROData_PolylineXY::GetSectionName( const int theSectionIndex ) const @@ -754,8 +754,6 @@ void HYDROData_PolylineXY::SetSectionName( const int theSec TDataStd_ListIteratorOfListOfExtendedString aNamesIter( anOldNamesList ); for ( int i = 0; aNamesIter.More(); aNamesIter.Next(), ++i ) aNamesList->Append( i == theSectionIndex ? aNewSectName : aNamesIter.Value() ); - - SetToUpdate( true ); } HYDROData_PolylineXY::SectionType HYDROData_PolylineXY::GetSectionType( const int theSectionIndex ) const @@ -793,7 +791,7 @@ void HYDROData_PolylineXY::SetSectionType( const int theSectionIndex, for ( int i = 0; aTypesIter.More(); aTypesIter.Next(), ++i ) aTypesList->Append( i == theSectionIndex ? theSectionType : aTypesIter.Value() ); - SetToUpdate( true ); + Changed( Geom_2d ); } bool HYDROData_PolylineXY::IsClosedSection( const int theSectionIndex ) const @@ -831,7 +829,7 @@ void HYDROData_PolylineXY::SetSectionClosed( const int theSectionIndex, for ( int i = 0; aClosuresIter.More(); aClosuresIter.Next(), ++i ) aClosuresList->Append( i == theSectionIndex ? theIsClosed : (bool)aClosuresIter.Value() ); - SetToUpdate( true ); + Changed( Geom_2d ); } void HYDROData_PolylineXY::GetSections( NCollection_Sequence& theSectNames, @@ -913,14 +911,14 @@ void HYDROData_PolylineXY::RemoveSection( const int theSectionIndex ) removePointsLists( theSectionIndex ); } - SetToUpdate( true ); + Changed( Geom_2d ); } void HYDROData_PolylineXY::RemoveSections() { removeSectionsLists(); removePointsLists(); - SetToUpdate( true ); + Changed( Geom_2d ); } void HYDROData_PolylineXY::AddPoint( const int theSectionIndex, @@ -966,7 +964,7 @@ void HYDROData_PolylineXY::AddPoint( const int theSectionIndex, } } - SetToUpdate( true ); + Changed( Geom_2d ); } void HYDROData_PolylineXY::SetPoint( const int theSectionIndex, @@ -1017,7 +1015,7 @@ void HYDROData_PolylineXY::SetPoint( const int theSectionIndex, } } - SetToUpdate( true ); + Changed( Geom_2d ); } void HYDROData_PolylineXY::SetPoints( const int theSectionIndex, @@ -1073,7 +1071,7 @@ void HYDROData_PolylineXY::RemovePoint( const int theSectionIndex, } } - SetToUpdate( true ); + Changed( Geom_2d ); } HYDROData_PolylineXY::PointsList HYDROData_PolylineXY::GetPoints( const int theSectionIndex, bool IsConvertToGlobal ) const @@ -1156,7 +1154,7 @@ void HYDROData_PolylineXY::UpdateLocalCS( double theDx, double theDy ) } SetPoints( i, aPoints ); } - SetToUpdate( true ); + Changed( Geom_2d ); } void HYDROData_PolylineXY::Transform( const QTransform& theTrsf ) diff --git a/src/HYDROData/HYDROData_Profile.cxx b/src/HYDROData/HYDROData_Profile.cxx index 2649e2b0..9c4eda1d 100755 --- a/src/HYDROData/HYDROData_Profile.cxx +++ b/src/HYDROData/HYDROData_Profile.cxx @@ -56,7 +56,7 @@ IMPLEMENT_STANDARD_HANDLE(HYDROData_Profile, HYDROData_Object) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Profile, HYDROData_Object) HYDROData_Profile::HYDROData_Profile() -: HYDROData_Object() +: HYDROData_Object( Geom_3d ) { } @@ -239,7 +239,7 @@ void HYDROData_Profile::SetLeftPoint( const gp_XY& theGPoint, bool IsConvertFrom anArray->SetValue( 0, aLPoint.X() ); anArray->SetValue( 1, aLPoint.Y() ); - SetToUpdate( true ); + Changed( Geom_3d ); } bool HYDROData_Profile::GetLeftPoint( gp_XY& thePoint, bool IsConvertToGlobal, @@ -291,7 +291,7 @@ void HYDROData_Profile::SetRightPoint( const gp_XY& theGPoint, bool IsConvertFro anArray->SetValue( 0, aLPoint.X() ); anArray->SetValue( 1, aLPoint.Y() ); - SetToUpdate( true ); + Changed( Geom_3d ); } bool HYDROData_Profile::GetRightPoint( gp_XY& thePoint, bool IsConvertToGlobal, @@ -336,7 +336,7 @@ void HYDROData_Profile::Invalidate() if ( !aLastLabel.IsNull() ) aLastLabel.ForgetAllAttributes(); - SetToUpdate( true ); + Changed( Geom_3d ); } Handle(HYDROData_ProfileUZ) HYDROData_Profile::GetProfileUZ( const bool theIsCreate ) const @@ -369,7 +369,7 @@ void HYDROData_Profile::RemovePoints() if ( !aProfileUZ.IsNull() ) { aProfileUZ->RemoveSections(); - SetToUpdate( true ); + Changed( Geom_3d ); } } @@ -384,7 +384,7 @@ void HYDROData_Profile::SetParametricPoints( const HYDROData_ProfileUZ::PointsLi aProfileUZ->AddPoint( 0, aPoint ); } - SetToUpdate( true ); + Changed( Geom_3d ); } HYDROData_ProfileUZ::PointsList HYDROData_Profile::GetParametricPoints() const diff --git a/src/HYDROData/HYDROData_Region.cxx b/src/HYDROData/HYDROData_Region.cxx index 20a86e42..582357e8 100644 --- a/src/HYDROData/HYDROData_Region.cxx +++ b/src/HYDROData/HYDROData_Region.cxx @@ -52,7 +52,7 @@ IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Region, HYDROData_Entity) HYDROData_Region::HYDROData_Region() - : HYDROData_Entity() + : HYDROData_Entity( Geom_2d ) { } @@ -107,7 +107,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() ); diff --git a/src/HYDROData/HYDROData_River.cxx b/src/HYDROData/HYDROData_River.cxx index 2bb5cef7..88f7c84c 100644 --- a/src/HYDROData/HYDROData_River.cxx +++ b/src/HYDROData/HYDROData_River.cxx @@ -29,7 +29,7 @@ IMPLEMENT_STANDARD_RTTIEXT(HYDROData_River,HYDROData_NaturalObject) HYDROData_River::HYDROData_River() -: HYDROData_NaturalObject() +: HYDROData_NaturalObject( Geom_3d ) { } diff --git a/src/HYDROData/HYDROData_ShapesGroup.cxx b/src/HYDROData/HYDROData_ShapesGroup.cxx index 35015221..12807de7 100644 --- a/src/HYDROData/HYDROData_ShapesGroup.cxx +++ b/src/HYDROData/HYDROData_ShapesGroup.cxx @@ -137,7 +137,7 @@ void HYDROData_ShapesGroup::GroupDefinition::Dump( std::ostream& theSt HYDROData_ShapesGroup::HYDROData_ShapesGroup() -: HYDROData_Entity() +: HYDROData_Entity( Geom_Groups ) { } diff --git a/src/HYDROData/HYDROData_Stream.cxx b/src/HYDROData/HYDROData_Stream.cxx index 42a62b57..a0f663f8 100644 --- a/src/HYDROData/HYDROData_Stream.cxx +++ b/src/HYDROData/HYDROData_Stream.cxx @@ -95,7 +95,7 @@ IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Stream,HYDROData_NaturalObject) HYDROData_Stream::HYDROData_Stream() -: HYDROData_NaturalObject() +: HYDROData_NaturalObject( Geom_3d ) { } @@ -303,49 +303,28 @@ bool HYDROData_Stream::IsValidAsAxis( const Handle(HYDROData_PolylineXY)& theHyd return true; } -TopoDS_Shape getShapeFromGroup( const HYDROData_SequenceOfObjects& theGroups, - const int theGroupId ) -{ - TopoDS_Shape aResShape; - if ( theGroups.Length() != 4 ) - return aResShape; - - Handle(HYDROData_ShapesGroup) aGroup = - Handle(HYDROData_ShapesGroup)::DownCast( theGroups.Value( theGroupId ) ); - if ( aGroup.IsNull() ) - return aResShape; - - TopTools_SequenceOfShape aGroupShapes; - aGroup->GetShapes( aGroupShapes ); - - if ( !aGroupShapes.IsEmpty() ) - aResShape = aGroupShapes.First(); - - return aResShape; -} - TopoDS_Shape HYDROData_Stream::GetLeftShape() const { HYDROData_SequenceOfObjects aGroups = GetGroups(); - return getShapeFromGroup( aGroups, 1 ); + return HYDROData_Tool::getFirstShapeFromGroup( aGroups, 1); } TopoDS_Shape HYDROData_Stream::GetRightShape() const { HYDROData_SequenceOfObjects aGroups = GetGroups(); - return getShapeFromGroup( aGroups, 2 ); + return HYDROData_Tool::getFirstShapeFromGroup( aGroups, 2); } TopoDS_Shape HYDROData_Stream::GetInletShape() const { HYDROData_SequenceOfObjects aGroups = GetGroups(); - return getShapeFromGroup( aGroups, 3 ); + return HYDROData_Tool::getFirstShapeFromGroup( aGroups, 3); } TopoDS_Shape HYDROData_Stream::GetOutletShape() const { HYDROData_SequenceOfObjects aGroups = GetGroups(); - return getShapeFromGroup( aGroups, 4 ); + return HYDROData_Tool::getFirstShapeFromGroup( aGroups, 4); } QColor HYDROData_Stream::getDefaultFillingColor() const @@ -373,7 +352,7 @@ bool HYDROData_Stream::SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& the updateProfilesOrder(); // Indicate model of the need to update the stream presentation - SetToUpdate( true ); + Changed( Geom_3d ); return true; } @@ -396,7 +375,7 @@ void HYDROData_Stream::RemoveHydraulicAxis() RemoveProfiles(); // Indicate model of the need to update the stream presentation - SetToUpdate( true ); + Changed( Geom_3d ); } bool HYDROData_Stream::HasIntersection( const Handle(HYDROData_Profile)& theProfile, @@ -530,7 +509,7 @@ bool HYDROData_Stream::AddProfile( const Handle(HYDROData_Profile)& theProfile ) insertProfileInToOrder( theProfile, aProfileIndex ); // Indicate model of the need to update the stream presentation - SetToUpdate( true ); + Changed( Geom_3d ); return true; } @@ -575,7 +554,7 @@ bool HYDROData_Stream::SetProfiles( const HYDROData_SequenceOfObjects& theProfil SetReferenceObjects( theProfiles, DataTag_Profile ); if ( anIsToUpdate ) - SetToUpdate( true ); + Changed( Geom_3d ); } return true; @@ -618,22 +597,20 @@ bool HYDROData_Stream::RemoveProfile( const Handle(HYDROData_Profile)& theProfil removeParameter( aProfileIndex ); // Indicate model of the need to update the stream presentation - SetToUpdate( true ); + Changed( Geom_3d ); return true; } void HYDROData_Stream::RemoveProfiles() { - bool anIsToUpdate = IsMustBeUpdated() || NbReferenceObjects( DataTag_Profile ) > 0; - ClearReferenceObjects( DataTag_Profile ); // Remove the parameters array removeParametersArray(); // Indicate model of the need to update the stream presentation - SetToUpdate( anIsToUpdate ); + Changed( Geom_3d ); } void HYDROData_Stream::insertProfileInToOrder( const Handle(HYDROData_Profile)& theProfile, @@ -1028,7 +1005,8 @@ bool HYDROData_Stream::Interpolate( HYDROData_IProfilesInterpolator* theInterpol return isOK; } -void HYDROData_Stream::CopyTo( const Handle(HYDROData_Entity)& theDestination ) const +void HYDROData_Stream::CopyTo( const Handle(HYDROData_Entity)& theDestination, + bool isGenerateNewName ) const { // Get the document Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); @@ -1037,7 +1015,7 @@ void HYDROData_Stream::CopyTo( const Handle(HYDROData_Entity)& theDestination ) } // Call base method - HYDROData_Entity::CopyTo( theDestination ); + HYDROData_Entity::CopyTo( theDestination, isGenerateNewName ); Handle(HYDROData_Stream) aStreamCopy = Handle(HYDROData_Stream)::DownCast( theDestination ); diff --git a/src/HYDROData/HYDROData_Stream.h b/src/HYDROData/HYDROData_Stream.h index 6ebf6427..fd4ffca5 100644 --- a/src/HYDROData/HYDROData_Stream.h +++ b/src/HYDROData/HYDROData_Stream.h @@ -136,7 +136,8 @@ public: /** * */ - HYDRODATA_EXPORT virtual void CopyTo( const Handle(HYDROData_Entity)& theDestination ) const; + HYDRODATA_EXPORT virtual void CopyTo( const Handle(HYDROData_Entity)& theDestination, + bool isGenerateNewName ) const; /** diff --git a/src/HYDROData/HYDROData_StreamAltitude.cxx b/src/HYDROData/HYDROData_StreamAltitude.cxx index 893be442..96b33ad8 100644 --- a/src/HYDROData/HYDROData_StreamAltitude.cxx +++ b/src/HYDROData/HYDROData_StreamAltitude.cxx @@ -18,6 +18,7 @@ #include "HYDROData_StreamAltitude.h" +#include "HYDROData_Channel.h" #include "HYDROData_Document.h" #include "HYDROData_Profile.h" #include "HYDROData_Stream.h" @@ -37,6 +38,7 @@ #include +#include #include #include @@ -44,6 +46,7 @@ #include #include +#include #include @@ -69,150 +72,169 @@ HYDROData_StreamAltitude::~HYDROData_StreamAltitude() { } -Standard_Real getAltitudeFromProfile( const Handle(HYDROData_Profile)& theProfile, - const Standard_Real& theLeftDist, - const Standard_Real& theRightDist ) +bool IsPointBetweenEdges( const gp_Pnt& aFirstPnt1, const gp_Pnt& aLastPnt1, + const gp_Pnt& aFirstPnt2, const gp_Pnt& aLastPnt2, + const gp_Pnt& thePoint) { + BRepBuilderAPI_MakeEdge aLeftMakeEdge( aFirstPnt1, aLastPnt1 ); + BRepBuilderAPI_MakeEdge aBotMakeEdge( aLastPnt1, aLastPnt2 ); + BRepBuilderAPI_MakeEdge aRightMakeEdge( aLastPnt2, aFirstPnt2 ); + BRepBuilderAPI_MakeEdge aTopMakeEdge( aFirstPnt2, aFirstPnt1 ); + + BRepBuilderAPI_MakeWire aMakeWire( aLeftMakeEdge.Edge(), aBotMakeEdge.Edge(), + aRightMakeEdge.Edge(), aTopMakeEdge.Edge() ); + + BRepBuilderAPI_MakeFace aMakeFace( aMakeWire.Wire() ); + + TopoDS_Face aFace = aMakeFace.Face(); +#ifdef DEB_CLASS2D + TopoDS_Compound aCmp; + BRep_Builder aBB; + aBB.MakeCompound(aCmp); + aBB.Add(aCmp, aFace); + BRepBuilderAPI_MakeVertex aMk(thePoint); + aBB.Add(aCmp, aMk.Vertex()); + BRepTools::Write(aCmp, "ProfileFace.brep"); +#endif + + gp_XY anXY( thePoint.X(), thePoint.Y() ); + TopAbs_State aPointState = HYDROData_Tool::ComputePointState(anXY, aFace); + +#ifdef DEB_CLASS2D + cout << "Point status is = " << aPointState <GetLeftPoint( aFirstPoint, false ) || - !theProfile->GetRightPoint( aLastPoint, false ) ) - return aResAlt; - - gp_Pnt aPnt1( aFirstPoint.X(), aFirstPoint.Y(), 0 ); - gp_Pnt aPnt2( aLastPoint.X(), aLastPoint.Y(), 0 ); - + TopoDS_Vertex aFirstVertex, aLastVertex; + TopExp::Vertices( theWire, aFirstVertex, aLastVertex ); + + gp_Pnt aPnt1( BRep_Tool::Pnt( aFirstVertex ) ); + aPnt1.SetZ( 0 ); + gp_Pnt aPnt2( BRep_Tool::Pnt( aLastVertex ) ); + aPnt2.SetZ( 0 ); + Standard_Real aProfileDist = aPnt1.Distance( aPnt2 ); Standard_Real aCoeff = aProfileDist / ( theLeftDist + theRightDist ); gp_Pnt anIntPoint( aPnt1.XYZ() + ( aCoeff * theLeftDist ) * gp_Dir( gp_Vec( aPnt1, aPnt2 ) ).XYZ() ); - gp_Lin aPointLine( anIntPoint, gp::DZ() ); - - gp_Pnt aPrevPoint; - gp_Lin aPrevNormal; - HYDROData_Profile::ProfilePoints aProfilePoints = theProfile->GetProfilePoints( false ); - for ( int i = 1, n = aProfilePoints.Length(); i <= n; ++i ) - { - gp_Pnt aProfPoint( aProfilePoints.Value( i ) ); - - Standard_Real aDist = aPointLine.Distance( aProfPoint ); - if ( aDist <= gp::Resolution() ) - { - // We found the intersected point - aResAlt = aProfPoint.Z(); - break; - } - - gp_Lin aNormal = aPointLine.Normal( aProfPoint ); - if ( i == 1 ) - { - aPrevNormal = aNormal; - aPrevPoint = aProfPoint; - continue; - } - - if ( aPrevNormal.Direction().Dot( aNormal.Direction() ) < 0 ) - { - // We found the intersected edge - gp_Lin anEdgeLine( aPrevPoint, gp_Dir( gp_Vec( aPrevPoint, aProfPoint ) ) ); - - Extrema_ExtElC anExtrema( aPointLine, anEdgeLine, Precision::Angular() ); - if ( !anExtrema.IsParallel() ) - { - Extrema_POnCurv aFirstPnt, aSecPnt; - anExtrema.Points( 1, aFirstPnt, aSecPnt ); - - const gp_Pnt& anIntPnt = aSecPnt.Value(); - aResAlt = anIntPnt.Z(); - - break; - } - } - - aPrevNormal = aNormal; - aPrevPoint = aProfPoint; - } - - return aResAlt; + return HYDROData_Tool::GetAltitudeForWire( theWire, + gp_XY(anIntPoint.X(), anIntPoint.Y()), + 1E-2, + 1E-2, + HYDROData_IAltitudeObject::GetInvalidAltitude() ); } -bool HYDROData_StreamAltitude::getBoundaryProfilesForPoint( - const gp_XY& thePoint, - Handle(HYDROData_Profile)& theLeftProfile, - Handle(HYDROData_Profile)& theRightProfile ) const +bool HYDROData_StreamAltitude::getBoundaryWiresForPoint( + const gp_XY& thePoint, + TopoDS_Wire& theLeftWire, + TopoDS_Wire& theRightWire ) const { - Handle(HYDROData_Stream) aStream = - Handle(HYDROData_Stream)::DownCast( GetFatherObject() ); - if ( aStream.IsNull() ) - return false; + gp_Pnt aTestPnt( thePoint.X(), thePoint.Y(), 0 ); - HYDROData_SequenceOfObjects aStreamProfiles = aStream->GetProfiles(); - if ( aStreamProfiles.Length() < 2 ) + Handle(HYDROData_Object) anObject = + Handle(HYDROData_Object)::DownCast( GetFatherObject() ); + if ( anObject.IsNull() ) { return false; + } - Handle(HYDROData_Profile) aPrevProfile; - gp_Pnt aPrevPnt1, aPrevPnt2; - for ( int i = 1, n = aStreamProfiles.Length(); i <= n; ++i ) - { - Handle(HYDROData_Profile) aProfile = - Handle(HYDROData_Profile)::DownCast( aStreamProfiles.Value( i ) ); - if ( aProfile.IsNull() ) - continue; - - gp_XY aFirstPoint, aLastPoint; - if ( !aProfile->GetLeftPoint( aFirstPoint, false ) || - !aProfile->GetRightPoint( aLastPoint, false ) ) - continue; + if ( anObject->GetKind() == KIND_STREAM ) { + Handle(HYDROData_Stream) aStream = Handle(HYDROData_Stream)::DownCast( anObject ); + if ( aStream.IsNull() ) + return false; - gp_Pnt aPnt1( aFirstPoint.X(), aFirstPoint.Y(), 0 ); - gp_Pnt aPnt2( aLastPoint.X(), aLastPoint.Y(), 0 ); + HYDROData_SequenceOfObjects aStreamProfiles = aStream->GetProfiles(); + if ( aStreamProfiles.Length() < 2 ) + return false; - if ( !aPrevProfile.IsNull() ) + Handle(HYDROData_Profile) aPrevProfile; + gp_Pnt aPrevPnt1, aPrevPnt2; + for ( int i = 1, n = aStreamProfiles.Length(); i <= n; ++i ) { - BRepBuilderAPI_MakeEdge aLeftMakeEdge( aPrevPnt1, aPrevPnt2 ); - BRepBuilderAPI_MakeEdge aBotMakeEdge( aPrevPnt2, aPnt2 ); - BRepBuilderAPI_MakeEdge aRightMakeEdge( aPnt2, aPnt1 ); - BRepBuilderAPI_MakeEdge aTopMakeEdge( aPnt1, aPrevPnt1 ); - - BRepBuilderAPI_MakeWire aMakeWire( aLeftMakeEdge.Edge(), aBotMakeEdge.Edge(), - aRightMakeEdge.Edge(), aTopMakeEdge.Edge() ); - - BRepBuilderAPI_MakeFace aMakeFace( aMakeWire.Wire() ); - - TopoDS_Face aProfilesFace = aMakeFace.Face(); -#ifdef DEB_CLASS2D - TopoDS_Compound aCmp; - BRep_Builder aBB; - aBB.MakeCompound(aCmp); - aBB.Add(aCmp, aProfilesFace); - gp_Pnt aPnt (thePoint.X(), thePoint.Y(), 0.); - BRepBuilderAPI_MakeVertex aMk(aPnt); - aBB.Add(aCmp, aMk.Vertex()); - BRepTools::Write(aCmp, "ProfileFace.brep"); -#endif - - TopAbs_State aPointState = HYDROData_Tool::ComputePointState(thePoint, aProfilesFace); + Handle(HYDROData_Profile) aProfile = + Handle(HYDROData_Profile)::DownCast( aStreamProfiles.Value( i ) ); + if ( aProfile.IsNull() ) + continue; + + gp_XY aFirstPoint, aLastPoint; + if ( !aProfile->GetLeftPoint( aFirstPoint, false ) || + !aProfile->GetRightPoint( aLastPoint, false ) ) + continue; + + gp_Pnt aPnt1( aFirstPoint.X(), aFirstPoint.Y(), 0 ); + gp_Pnt aPnt2( aLastPoint.X(), aLastPoint.Y(), 0 ); + + if ( !aPrevProfile.IsNull() ) + { + if ( IsPointBetweenEdges( aPrevPnt1, aPrevPnt2, aPnt1, aPnt2, aTestPnt ) ) + { + theLeftWire = TopoDS::Wire( aPrevProfile->GetShape3D() ); + theRightWire = TopoDS::Wire( aProfile->GetShape3D() ); + break; + } + } -#ifdef DEB_CLASS2D - cout << "Point status is = " << aPointState <GetKind() == KIND_CHANNEL ) { + Handle(HYDROData_Channel) aChannel = Handle(HYDROData_Channel)::DownCast( anObject ); + if ( aChannel.IsNull() ) + return false; + + TopTools_ListOfShape aWiresList; + TopExp_Explorer anExp( aChannel->GetShape3D(), TopAbs_WIRE ); + for ( ; anExp.More(); anExp.Next() ) { + if(!anExp.Current().IsNull()) { + const TopoDS_Wire& aWire = TopoDS::Wire( anExp.Current() ); + aWiresList.Append( aWire ); } } - aPrevProfile = aProfile; - aPrevPnt1 = aPnt1; - aPrevPnt2 = aPnt2; + if ( aWiresList.Extent() < 2 ) + return false; + + TopoDS_Wire aPrevWire; + gp_Pnt aPrevPnt1, aPrevPnt2; + + TopTools_ListIteratorOfListOfShape anIt( aWiresList ); + for ( ; anIt.More(); anIt.Next() ) { + TopoDS_Wire& aWire = TopoDS::Wire( anIt.Value() ); + if ( aWire.IsNull() ) + continue; + + TopoDS_Vertex aFirstVertex, aLastVertex; + TopExp::Vertices( aWire, aFirstVertex, aLastVertex ); + + gp_Pnt aPnt1( BRep_Tool::Pnt( aFirstVertex ) ); + aPnt1.SetZ( 0 ); + gp_Pnt aPnt2( BRep_Tool::Pnt( aLastVertex ) ); + aPnt2.SetZ( 0 ); + + if ( !aPrevWire.IsNull() ) { + if ( IsPointBetweenEdges( aPrevPnt1, aPrevPnt2, aPnt1, aPnt2, aTestPnt ) ) { + theLeftWire = aPrevWire; + theRightWire = aWire; + break; + } + } + + aPrevWire = aWire; + aPrevPnt1 = aPnt1; + aPrevPnt2 = aPnt2; + } } - return !theLeftProfile.IsNull() && !theRightProfile.IsNull(); + return !theLeftWire.IsNull() && !theRightWire.IsNull(); } double HYDROData_StreamAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) const @@ -220,40 +242,39 @@ double HYDROData_StreamAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) co DEBTRACE("GetAltitudeForPoint p(" << thePoint.X() << ", " << thePoint.Y() << ")"); double aResAltitude = GetInvalidAltitude(); - Handle(HYDROData_Stream) aStream = - Handle(HYDROData_Stream)::DownCast( GetFatherObject() ); - if ( aStream.IsNull() ) + Handle(HYDROData_Object) anObject = + Handle(HYDROData_Object)::DownCast( GetFatherObject() ); + if ( anObject.IsNull() ) { - DEBTRACE("aStream.IsNull()"); + DEBTRACE("aStream.IsNull()"); return aResAltitude; } - - TopoDS_Shape aStreamShape = aStream->GetTopShape(); - if ( aStreamShape.IsNull() ) + TopoDS_Shape aTopShape = anObject->GetTopShape(); + if ( aTopShape.IsNull() ) { - DEBTRACE("aStreamShape.IsNull()"); + DEBTRACE("aTopShape.IsNull()"); return aResAltitude; } - TopExp_Explorer aStreamFaceExp( aStreamShape, TopAbs_FACE ); - if ( !aStreamFaceExp.More() ) + TopExp_Explorer aFaceExp( aTopShape, TopAbs_FACE ); + if ( !aFaceExp.More() ) { - DEBTRACE("!aStreamFaceExp.More()"); + DEBTRACE("!aFaceExp.More()"); return aResAltitude; } // Get only face because of 2d profile wires is in compound - TopoDS_Face aStreamFace = TopoDS::Face( aStreamFaceExp.Current() ); + TopoDS_Face aFace = TopoDS::Face( aFaceExp.Current() ); - // Check if point is inside of stream presentation - TopAbs_State aPointState = HYDROData_Tool::ComputePointState(thePoint, aStreamFace); + // Check if point is inside of stream/channel presentation + TopAbs_State aPointState = HYDROData_Tool::ComputePointState(thePoint, aFace); #ifdef DEB_CLASS2D cout << "Point status is = " << aPointState <GetKind() == KIND_STREAM ) { + Handle(HYDROData_Stream) aStream = + Handle(HYDROData_Stream)::DownCast( GetFatherObject() ); + if ( !aStream.IsNull() ) { + aLeftEdge = TopoDS::Edge( aStream->GetLeftShape() ); + aRightEdge = TopoDS::Edge( aStream->GetRightShape() ); + } + } else if ( anObject->GetKind() == KIND_CHANNEL ) { + Handle(HYDROData_Channel) aChannel = + Handle(HYDROData_Channel)::DownCast( GetFatherObject() ); + if ( !aChannel.IsNull() ) { + aLeftEdge = TopoDS::Edge( aChannel->GetLeftShape() ); + aRightEdge = TopoDS::Edge( aChannel->GetRightShape() ); + } + } + // Find the two profiles between which the point is lies - Handle(HYDROData_Profile) aLeftProfile, aRightProfile; - if ( !getBoundaryProfilesForPoint( thePoint, aLeftProfile, aRightProfile ) ) + TopoDS_Wire aLeftWire, aRightWire; + if ( !getBoundaryWiresForPoint( thePoint, aLeftWire, aRightWire ) ) { - DEBTRACE("!getBoundaryProfilesForPoint( thePoint, aLeftProfile, aRightProfile )"); - return aResAltitude; + DEBTRACE("!getBoundaryProfilesForPoint( thePoint, aLeftProfile, aRightProfile )"); + return aResAltitude; } // Find the projections of point to borders of stream gp_XYZ aPointToTest( thePoint.X(), thePoint.Y(), 0.0 ); - - TopoDS_Edge aStreamLeftEdge = TopoDS::Edge( aStream->GetLeftShape() ); - TopoDS_Edge aStreamRightEdge = TopoDS::Edge( aStream->GetRightShape() ); - + Standard_Real aFirst = 0.0, aLast = 0.0; - Handle(Geom_Curve) anEdgeLeftCurve = BRep_Tool::Curve( aStreamLeftEdge, aFirst, aLast ); - Handle(Geom_Curve) anEdgeRightCurve = BRep_Tool::Curve( aStreamRightEdge, aFirst, aLast ); + Handle(Geom_Curve) anEdgeLeftCurve = BRep_Tool::Curve( aLeftEdge, aFirst, aLast ); + Handle(Geom_Curve) anEdgeRightCurve = BRep_Tool::Curve( aRightEdge, aFirst, aLast ); GeomAPI_ProjectPointOnCurve aLeftProject( aPointToTest, anEdgeLeftCurve ); GeomAPI_ProjectPointOnCurve aRightProject( aPointToTest, anEdgeRightCurve ); + int aNbPoints1 = aRightProject.NbPoints(); + int aNbPoints2 = aLeftProject.NbPoints(); + if ( aNbPoints1 < 1 || aNbPoints2 < 1) + return aResAltitude; Standard_Real aLeftDist = aLeftProject.LowerDistance(); Standard_Real aRightDist = aRightProject.LowerDistance(); // Find the altitude in profiles - Standard_Real aLeftAlt = getAltitudeFromProfile( aLeftProfile, aLeftDist, aRightDist ); - Standard_Real aRightAlt = getAltitudeFromProfile( aRightProfile, aLeftDist, aRightDist ); + Standard_Real aLeftAlt, aRightAlt; + gp_Pnt aLeftProfileP1, aLeftProfileP2, aRightProfileP1, aRightProfileP2; + aLeftAlt = getAltitudeFromWire( aLeftWire, aLeftDist, aRightDist ); + aRightAlt = getAltitudeFromWire( aRightWire, aLeftDist, aRightDist ); + + TopoDS_Vertex aFirstVertex, aLastVertex; + TopExp::Vertices( aLeftWire, aFirstVertex, aLastVertex ); + aLeftProfileP1 = BRep_Tool::Pnt( aFirstVertex ); + aLeftProfileP2 = BRep_Tool::Pnt( aLastVertex ); + + TopExp::Vertices( aRightWire, aFirstVertex, aLastVertex ); + aRightProfileP1 = BRep_Tool::Pnt( aFirstVertex ); + aRightProfileP2 = BRep_Tool::Pnt( aLastVertex ); // Interpolate altitudes // Left profile line ( the segment between the firts and the last profile point ) - HYDROData_Profile::ProfilePoints aLeftProfilePoints = aLeftProfile->GetProfilePoints( false ); - gp_Pnt aLeftProfileP1( aLeftProfilePoints.First() ); aLeftProfileP1.SetZ( 0 ); - gp_Pnt aLeftProfileP2( aLeftProfilePoints.Last() ); aLeftProfileP2.SetZ( 0 ); gp_Vec aLeftProfileVec( aLeftProfileP1, aLeftProfileP2 ); Handle(Geom_Line) aLeftProfileLine = new Geom_Line( gp_Ax1( aLeftProfileP1, aLeftProfileVec ) ); // Right profile line - HYDROData_Profile::ProfilePoints aRightProfilePoints = aRightProfile->GetProfilePoints( false ); - gp_Pnt aRightProfileP1( aRightProfilePoints.First() ); aRightProfileP1.SetZ( 0 ); - gp_Pnt aRightProfileP2( aRightProfilePoints.Last() ); aRightProfileP2.SetZ( 0 ); gp_Vec aRightProfileVec( aRightProfileP1, aRightProfileP2 ); Handle(Geom_Line) aRightProfileLine = new Geom_Line( gp_Ax1( aRightProfileP1, aRightProfileVec ) ); diff --git a/src/HYDROData/HYDROData_StreamAltitude.h b/src/HYDROData/HYDROData_StreamAltitude.h index 5cb6cc21..02cbc308 100644 --- a/src/HYDROData/HYDROData_StreamAltitude.h +++ b/src/HYDROData/HYDROData_StreamAltitude.h @@ -22,10 +22,10 @@ #include "HYDROData_IAltitudeObject.h" -class Handle(HYDROData_Profile); DEFINE_STANDARD_HANDLE(HYDROData_StreamAltitude, HYDROData_IAltitudeObject) +class TopoDS_Wire; /**\class HYDROData_StreamAltitude * \brief Class that stores/retreives information about the stream altitude. @@ -65,9 +65,9 @@ public: protected: - bool getBoundaryProfilesForPoint( const gp_XY& thePoint, - Handle(HYDROData_Profile)& theLeftProfile, - Handle(HYDROData_Profile)& theRightProfile ) const; + bool getBoundaryWiresForPoint( const gp_XY& thePoint, + TopoDS_Wire& theLeftWire, + TopoDS_Wire& theRightWire ) const; protected: diff --git a/src/HYDROData/HYDROData_StricklerTable.cxx b/src/HYDROData/HYDROData_StricklerTable.cxx index d3ef0b86..5d7623d8 100644 --- a/src/HYDROData/HYDROData_StricklerTable.cxx +++ b/src/HYDROData/HYDROData_StricklerTable.cxx @@ -32,7 +32,8 @@ IMPLEMENT_STANDARD_HANDLE( HYDROData_StricklerTable, HYDROData_Entity ) IMPLEMENT_STANDARD_RTTIEXT( HYDROData_StricklerTable, HYDROData_Entity ) - HYDROData_StricklerTable::HYDROData_StricklerTable() +HYDROData_StricklerTable::HYDROData_StricklerTable() +: HYDROData_Entity( Geom_No ) { } diff --git a/src/HYDROData/HYDROData_Tool.cxx b/src/HYDROData/HYDROData_Tool.cxx index b9b0dcdb..dee9901e 100644 --- a/src/HYDROData/HYDROData_Tool.cxx +++ b/src/HYDROData/HYDROData_Tool.cxx @@ -22,6 +22,7 @@ #include "HYDROData_Image.h" #include "HYDROData_Iterator.h" #include "HYDROData_NaturalObject.h" +#include "HYDROData_ShapesGroup.h" #include #include @@ -35,6 +36,10 @@ #include #include #include +#include +#include +#include +#include static int aMaxNameId = std::numeric_limits::max(); @@ -53,38 +58,6 @@ void HYDROData_Tool::WriteStringsToFile( QFile& theFile, anOutStream << aWriteStr << theSep << theSep; } -void HYDROData_Tool::SetMustBeUpdatedObjects( - const Handle(HYDROData_Document)& theDoc ) -{ - bool anIsChanged = true; - - // iterate until there is no changes because objects on all level of dependency must be updated - while ( anIsChanged ) - { - anIsChanged = false; - - HYDROData_Iterator anIter( theDoc ); - for ( ; anIter.More(); anIter.Next() ) - { - Handle(HYDROData_Entity) anObject = anIter.Current(); - if ( anObject.IsNull() || anObject->IsMustBeUpdated() ) - continue; - - HYDROData_SequenceOfObjects aRefSeq = anObject->GetAllReferenceObjects(); - for ( int i = 1, n = aRefSeq.Length(); i <= n; ++i ) - { - Handle(HYDROData_Entity) aRefObject = aRefSeq.Value( i ); - if ( aRefObject.IsNull() || !aRefObject->IsMustBeUpdated() ) - continue; - - anObject->SetToUpdate( true ); - anIsChanged = true; - break; - } - } - } -} - QString HYDROData_Tool::GenerateObjectName( const Handle(HYDROData_Document)& theDoc, const QString& thePrefix, const QStringList& theUsedNames, @@ -194,4 +167,89 @@ TopAbs_State HYDROData_Tool::ComputePointState( const gp_XY& theXY, const TopoDS BRepTopAdaptor_FClass2d aClassifier( theFace, toluv ); aState = aClassifier.Perform( gp_Pnt2d(aU1, aV1), Standard_False ); return aState; +} + +double HYDROData_Tool::GetAltitudeForEdge( const TopoDS_Edge& theEdge, + const gp_XY& thePoint, + double theParameterTolerance, + double theSquareDistanceTolerance, + double theInvalidAltitude ) +{ + double aFirst, aLast; + Handle(Geom_Curve) aCurve = BRep_Tool::Curve( theEdge, aFirst, aLast ); + if( aCurve.IsNull() ) + return theInvalidAltitude; + + gp_Pnt aFirstPnt, aLastPnt; + + aCurve->D0( aFirst, aFirstPnt ); + aCurve->D0( aLast, aLastPnt ); + + gp_Pnt2d aFirstPnt2d( aFirstPnt.X(), aFirstPnt.Y() ); + gp_Pnt2d aLastPnt2d( aLastPnt.X(), aLastPnt.Y() ); + + double aFirstDist = 0; + double aLastDist = aFirstPnt2d.SquareDistance( aLastPnt2d ); + double aNecDist = aFirstPnt2d.SquareDistance( thePoint ); + + while( fabs( aLast - aFirst ) > theParameterTolerance ) + { + double aMid = ( aFirst + aLast ) / 2; + gp_Pnt aMidPnt; + aCurve->D0( aMid, aMidPnt ); + double aDist = aFirstPnt2d.SquareDistance( gp_Pnt2d( aMidPnt.X(), aMidPnt.Y() ) ); + + if( aDist < aNecDist ) + aFirst = aMid; + else + aLast = aMid; + } + + double aMid = ( aFirst + aLast ) / 2; + gp_Pnt aMidPnt; + aCurve->D0( aMid, aMidPnt ); + + gp_Pnt2d aMidPnt2d( aMidPnt.X(), aMidPnt.Y() ); + if( aMidPnt2d.SquareDistance( thePoint ) < theSquareDistanceTolerance ) + return aMidPnt.Z(); + else + return theInvalidAltitude; +} + +double HYDROData_Tool::GetAltitudeForWire( const TopoDS_Wire& theWire, + const gp_XY& thePoint, + double theParameterTolerance, + double theSquareDistanceTolerance, + double theInvalidAltitude ) +{ + TopExp_Explorer anExp( theWire, TopAbs_EDGE ); + for( ; anExp.More(); anExp.Next() ) + { + double anAltitude = GetAltitudeForEdge( TopoDS::Edge( anExp.Current() ), thePoint, + theParameterTolerance, theSquareDistanceTolerance, theInvalidAltitude ); + if( anAltitude != theInvalidAltitude ) + return anAltitude; + } + return theInvalidAltitude; +} + +TopoDS_Shape HYDROData_Tool::getFirstShapeFromGroup( const HYDROData_SequenceOfObjects& theGroups, + const int theGroupId ) +{ + TopoDS_Shape aResShape; + if ( theGroupId < 1 || theGroupId > theGroups.Length() ) + return aResShape; + + Handle(HYDROData_ShapesGroup) aGroup = + Handle(HYDROData_ShapesGroup)::DownCast( theGroups.Value( theGroupId ) ); + if ( aGroup.IsNull() ) + return aResShape; + + TopTools_SequenceOfShape aGroupShapes; + aGroup->GetShapes( aGroupShapes ); + + if ( !aGroupShapes.IsEmpty() ) + aResShape = aGroupShapes.First(); + + return aResShape; } \ No newline at end of file diff --git a/src/HYDROData/HYDROData_Tool.h b/src/HYDROData/HYDROData_Tool.h index 83b1c042..0642d4fd 100644 --- a/src/HYDROData/HYDROData_Tool.h +++ b/src/HYDROData/HYDROData_Tool.h @@ -35,6 +35,8 @@ class QFile; class TopoDS_Shape; class TopTools_SequenceOfShape; class Handle(HYDROData_Document); +class TopoDS_Edge; +class TopoDS_Wire; class HYDRODATA_EXPORT HYDROData_Tool { @@ -44,12 +46,6 @@ public: const QStringList& theStrings, const QString& theSep = "\n" ); - /** - * Enables "MustBeUpdated" flag for objects that are depended on "MustBeUpdated" objects. - * \param theDoc document where this operation is performed - */ - static void SetMustBeUpdatedObjects( const Handle(HYDROData_Document)& theDoc ); - /** * \brief Generate name for new object. * \param theDoc document @@ -95,6 +91,25 @@ public: static TopAbs_State ComputePointState( const gp_XY& thePnt2d, const TopoDS_Face& theFace ); + + static double GetAltitudeForEdge( const TopoDS_Edge& theEdge, + const gp_XY& thePoint, + double theParameterTolerance, + double theSquareDistanceTolerance, + double theInvalidAltitude ); + static double GetAltitudeForWire( const TopoDS_Wire& theWire, + const gp_XY& thePoint, + double theParameterTolerance, + double theSquareDistanceTolerance, + double theInvalidAltitude ); + + /** + * \brief Returns the first shape from the group. + * \param theGroups the list of groups + * \param theGroupId the group id + */ + static TopoDS_Shape getFirstShapeFromGroup( const HYDROData_SequenceOfObjects& theGroups, + const int theGroupId ); }; inline bool ValuesEquals( const double& theFirst, const double& theSecond ) diff --git a/src/HYDROData/HYDROData_VisualState.cxx b/src/HYDROData/HYDROData_VisualState.cxx index e2867ea8..e7d8ff79 100644 --- a/src/HYDROData/HYDROData_VisualState.cxx +++ b/src/HYDROData/HYDROData_VisualState.cxx @@ -24,7 +24,7 @@ IMPLEMENT_STANDARD_HANDLE(HYDROData_VisualState, HYDROData_Entity) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_VisualState, HYDROData_Entity) HYDROData_VisualState::HYDROData_VisualState() -: HYDROData_Entity() +: HYDROData_Entity( Geom_No ) { } diff --git a/src/HYDROData/HYDROData_Zone.cxx b/src/HYDROData/HYDROData_Zone.cxx index 97e1da6c..c0a5a884 100644 --- a/src/HYDROData/HYDROData_Zone.cxx +++ b/src/HYDROData/HYDROData_Zone.cxx @@ -41,7 +41,7 @@ IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Zone, HYDROData_Entity) HYDROData_Zone::HYDROData_Zone() -: HYDROData_Entity() +: HYDROData_Entity( Geom_2d ) { myInterpolator = NULL; } diff --git a/src/HYDROData/test_HYDROData_Bathymetry.cxx b/src/HYDROData/test_HYDROData_Bathymetry.cxx index dbc229fd..e3b2509a 100755 --- a/src/HYDROData/test_HYDROData_Bathymetry.cxx +++ b/src/HYDROData/test_HYDROData_Bathymetry.cxx @@ -185,7 +185,7 @@ void test_HYDROData_Bathymetry::testCopy() Handle(HYDROData_Bathymetry) aBathymetry2 = Handle(HYDROData_Bathymetry)::DownCast( aDoc->CreateObject( KIND_BATHYMETRY ) ); - aBathymetry1->CopyTo( aBathymetry2 ); + aBathymetry1->CopyTo( aBathymetry2, true ); if ( anIsFileCreated ) { diff --git a/src/HYDROData/test_HYDROData_Entity.cxx b/src/HYDROData/test_HYDROData_Entity.cxx index a6850801..e55530bb 100644 --- a/src/HYDROData/test_HYDROData_Entity.cxx +++ b/src/HYDROData/test_HYDROData_Entity.cxx @@ -57,7 +57,7 @@ void test_HYDROData_Entity::testCopy() Handle(HYDROData_Entity) aCopy = aDoc->CreateObject(KIND_IMAGE); // object for copy CPPUNIT_ASSERT(aCopy->GetName().isEmpty()); - anObj->CopyTo(aCopy); + anObj->CopyTo(aCopy, true); // check the copied object has same name as original CPPUNIT_ASSERT_EQUAL(aName.toStdString(), aCopy->GetName().toStdString()); diff --git a/src/HYDROData/test_HYDROData_Image.cxx b/src/HYDROData/test_HYDROData_Image.cxx index 689c7a64..ddeeeb87 100644 --- a/src/HYDROData/test_HYDROData_Image.cxx +++ b/src/HYDROData/test_HYDROData_Image.cxx @@ -154,7 +154,7 @@ void test_HYDROData_Image::testCopy() // copy image to the new one Handle(HYDROData_Image) anImage3 = Handle(HYDROData_Image)::DownCast(aDoc->CreateObject(KIND_IMAGE)); - anImage1->CopyTo(anImage3); + anImage1->CopyTo(anImage3, true); // check all fields are correctly copied CPPUNIT_ASSERT(anImage1->Image() == anImage3->Image()); diff --git a/src/HYDROData/test_HYDROData_PolylineXY.cxx b/src/HYDROData/test_HYDROData_PolylineXY.cxx index 6c019831..99b61069 100644 --- a/src/HYDROData/test_HYDROData_PolylineXY.cxx +++ b/src/HYDROData/test_HYDROData_PolylineXY.cxx @@ -66,7 +66,7 @@ void test_HYDROData_PolylineXY::testCopy() Handle(HYDROData_PolylineXY) aPolyline2 = Handle(HYDROData_PolylineXY)::DownCast(aDoc->CreateObject(KIND_POLYLINEXY)); - aPolyline1->CopyTo(aPolyline2); + aPolyline1->CopyTo(aPolyline2, true); aDoc->Close(); diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index edce573b..169d5c26 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -632,7 +632,7 @@ void HYDROGUI_CalculationOp::onRemoveObjects() bool HYDROGUI_CalculationOp::confirmRegionsChange() const { // Check if the case is already modified or not - bool isConfirmed = myEditedObject->IsMustBeUpdated(); + bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ); if ( !isConfirmed ) { // If not modified check if the case has already defined regions with zones @@ -657,7 +657,7 @@ bool HYDROGUI_CalculationOp::confirmRegionsChange() const bool HYDROGUI_CalculationOp::confirmOrderChange() const { // Check if the case is already modified or not - bool isConfirmed = myEditedObject->IsMustBeUpdated(); + bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ); if ( !isConfirmed ) { // If not modified check if the case has already defined regions with zones @@ -682,7 +682,7 @@ bool HYDROGUI_CalculationOp::confirmOrderChange() const bool HYDROGUI_CalculationOp::confirmRuleChange() const { // Check if the case is already modified or not - bool isConfirmed = myEditedObject->IsMustBeUpdated(); + bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ); if ( !isConfirmed ) { // If not modified check if the case has already defined regions with zones @@ -707,7 +707,7 @@ bool HYDROGUI_CalculationOp::confirmRuleChange() const bool HYDROGUI_CalculationOp::confirmModeChange() const { // Check if the case is already modified or not - bool isConfirmed = myEditedObject->IsMustBeUpdated(); + bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ); if ( !isConfirmed ) { // If not modified check if the case has already defined regions with zones @@ -761,7 +761,7 @@ bool HYDROGUI_CalculationOp::confirmContinueWithWarning( const HYDROData_Warning bool HYDROGUI_CalculationOp::confirmLandCoverRegionsChange() const { // Check if the case is already modified or not - bool isConfirmed = myEditedObject->IsMustBeUpdated(); + bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_No ); if ( !isConfirmed ) { // If not modified check if the case has already defined regions with land cover zones @@ -786,7 +786,7 @@ bool HYDROGUI_CalculationOp::confirmLandCoverRegionsChange() const bool HYDROGUI_CalculationOp::confirmLandCoverModeChange() const { // Check if the case is already modified or not - bool isConfirmed = myEditedObject->IsMustBeUpdated(); + bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_No ); if ( !isConfirmed ) { // If not modified check if the case has already defined regions with land cover zones @@ -811,7 +811,7 @@ bool HYDROGUI_CalculationOp::confirmLandCoverModeChange() const bool HYDROGUI_CalculationOp::confirmLandCoverOrderChange() const { // Check if the case is already modified or not - bool isConfirmed = myEditedObject->IsMustBeUpdated(); + bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_No ); if ( !isConfirmed ) { // If not modified check if the case has already defined regions with land cover zones @@ -836,7 +836,7 @@ bool HYDROGUI_CalculationOp::confirmLandCoverOrderChange() const bool HYDROGUI_CalculationOp::confirmLandCoverRuleChange() const { // Check if the case is already modified or not - bool isConfirmed = myEditedObject->IsMustBeUpdated(); + bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_No ); if ( !isConfirmed ) { // If not modified check if the case has already defined regions with land cover zones @@ -987,10 +987,10 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) } } aPanel->setStricklerTableNames( aList, anEntryList ); - bool anUpdateState = myEditedObject->IsMustBeUpdated(); + //@ASL: bool anUpdateState = myEditedObject->IsMustBeUpdated(); if ( !aList.isEmpty() ) aPanel->setStricklerTable( aList.at( 0 ), false ); - myEditedObject->SetToUpdate( anUpdateState ); + //@ASL: myEditedObject->SetToUpdate( anUpdateState ); // Fill in list widget with all available land covers aSeq = HYDROGUI_Tool::GetLandCovers( module() ); @@ -1060,7 +1060,7 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) if ( aMode == HYDROData_CalculationCase::AUTOMATIC ) { // Set objects in the specified order - if( myEditedObject->IsMustBeUpdated() ) + if( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ) { myEditedObject->RemoveGeometryObjects(); foreach ( const QString& aName, aPanel->getAllGeomObjects() ) @@ -1093,7 +1093,7 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) if ( aMode == HYDROData_CalculationCase::AUTOMATIC ) { // Set objects in the specified order - if( myEditedObject->IsMustBeUpdated() ) + if( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ) { myEditedObject->RemoveLandCovers(); foreach ( const QString& aName, aPanel->getAllLandCovers() ) @@ -1119,7 +1119,7 @@ void HYDROGUI_CalculationOp::onNext( const int theIndex ) } aPanel->setEditLandCoverZonesEnabled( aMode == HYDROData_CalculationCase::MANUAL ); - if ( myEditedObject->IsMustBeUpdated() ) + if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) ) { myShowZones = true; myEditedObject->Update(); @@ -1577,7 +1577,7 @@ void HYDROGUI_CalculationOp::setAvailableGroups() aGroupsNames.append( aGroup->GetName() ); } } - if( myEditedObject->IsMustBeUpdated() ) { + 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 ) ); @@ -1590,7 +1590,7 @@ void HYDROGUI_CalculationOp::setAvailableGroups() aPanel->setAvailableGroups( aGroupsNames ); aPanel->includeGroups( aList ); - bool isUpdated = myEditedObject->IsMustBeUpdated(); + //@ASL: bool isUpdated = myEditedObject->IsMustBeUpdated(); } void HYDROGUI_CalculationOp::onAddGroups() @@ -1747,7 +1747,7 @@ void HYDROGUI_CalculationOp::onOrderChanged( bool& isConfirmed ) isConfirmed = confirmOrderChange(); if( isConfirmed ) - myEditedObject->SetToUpdate( true ); + myEditedObject->Changed( HYDROData_Entity::Geom_2d ); } void HYDROGUI_CalculationOp::onOrderLandCoverChanged( bool& isConfirmed ) @@ -1759,7 +1759,7 @@ void HYDROGUI_CalculationOp::onOrderLandCoverChanged( bool& isConfirmed ) isConfirmed = confirmLandCoverOrderChange(); if( isConfirmed ) - myEditedObject->SetToUpdate( true ); + myEditedObject->Changed( HYDROData_Entity::Geom_No ); } void HYDROGUI_CalculationOp::onRuleChanged( bool& isConfirmed ) @@ -1771,7 +1771,7 @@ void HYDROGUI_CalculationOp::onRuleChanged( bool& isConfirmed ) isConfirmed = confirmRuleChange(); if( isConfirmed ) - myEditedObject->SetToUpdate( true ); + myEditedObject->Changed( HYDROData_Entity::Geom_2d ); } void HYDROGUI_CalculationOp::onRuleLandCoverChanged( bool& isConfirmed ) @@ -1783,7 +1783,7 @@ void HYDROGUI_CalculationOp::onRuleLandCoverChanged( bool& isConfirmed ) isConfirmed = confirmLandCoverRuleChange(); if( isConfirmed ) - myEditedObject->SetToUpdate( true ); + myEditedObject->Changed( HYDROData_Entity::Geom_No ); } void HYDROGUI_CalculationOp::onRegenerateColors() diff --git a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx index f00d5804..1141a006 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx @@ -211,7 +211,7 @@ bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags, myEditedObject->SetProfile( aProfile ); } - if ( myEditedObject->IsMustBeUpdated() ) + if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ) myEditedObject->Update(); erasePreview(); diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 88bb35b2..1478a747 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -679,7 +679,7 @@ bool HYDROGUI_DataModel::paste() Handle(HYDROData_Entity) aClone = getDocument()->CreateObject( aKind ); if( !aClone.IsNull() ) { - anObject->CopyTo( aClone ); + anObject->CopyTo( aClone, true ); anIsChanged = true; // remove Z layer diff --git a/src/HYDROGUI/HYDROGUI_DataObject.cxx b/src/HYDROGUI/HYDROGUI_DataObject.cxx index e0183809..8ec9658d 100644 --- a/src/HYDROGUI/HYDROGUI_DataObject.cxx +++ b/src/HYDROGUI/HYDROGUI_DataObject.cxx @@ -74,7 +74,7 @@ QFont HYDROGUI_DataObject::font( const int theId ) const if( theId == NameId ) { Handle(HYDROData_Entity) aDataObject = modelObject(); - if( !aDataObject.IsNull() && aDataObject->IsMustBeUpdated() ) + if( !aDataObject.IsNull() && aDataObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) ) { aFont.setItalic( true ); aFont.setBold( true ); @@ -108,7 +108,7 @@ QColor HYDROGUI_DataObject::color( const ColorRole theRole, const int theId ) co if ( !aColor.isValid() ) { Handle(HYDROData_Entity) aDataObject = modelObject(); - if( !aDataObject.IsNull() && aDataObject->IsMustBeUpdated() ) + if( !aDataObject.IsNull() && aDataObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) ) { switch ( theRole ) { @@ -148,7 +148,7 @@ QPixmap HYDROGUI_DataObject::icon( const int theId ) const } else { - QString aNeedUpdate( aDataObject->IsMustBeUpdated() ? "M_" : "" ); + QString aNeedUpdate( aDataObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) ? "M_" : "" ); int anObjectKind = (int)aDataObject->GetKind(); if ( anObjectKind == KIND_DUMMY_3D ) diff --git a/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx b/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx index 17ac4487..32d45fd4 100644 --- a/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx +++ b/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx @@ -372,7 +372,7 @@ bool HYDROGUI_LandCoverOp::confirmPolylinesChange() const return true; // Check if the land cover object is already modified or not - bool isConfirmed = myEditedObject->IsMustBeUpdated(); + bool isConfirmed = myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ); if ( !isConfirmed ) { // If not modified check if the land cover has already defined polylines diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 60609a97..81ad9fa0 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -399,7 +399,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, anIsVisibleInSelection |= aVisibility; anIsHiddenInSelection |= !aVisibility; - if ( anObject->CanBeUpdated() && anObject->IsMustBeUpdated() ) + if ( anObject->CanBeUpdated() && anObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) ) { anIsMustObjectBeUpdated = true; } diff --git a/src/HYDROGUI/HYDROGUI_Polyline.cxx b/src/HYDROGUI/HYDROGUI_Polyline.cxx index 7d312cb5..91e0a06a 100644 --- a/src/HYDROGUI/HYDROGUI_Polyline.cxx +++ b/src/HYDROGUI/HYDROGUI_Polyline.cxx @@ -39,6 +39,10 @@ #include #include #include +#include +#include +#include +#include IMPLEMENT_STANDARD_HANDLE (HYDROGUI_Polyline, AIS_Shape) IMPLEMENT_STANDARD_RTTIEXT(HYDROGUI_Polyline, AIS_Shape) @@ -53,11 +57,43 @@ HYDROGUI_Polyline::~HYDROGUI_Polyline() { } +Handle( Graphic3d_ArrayOfPolylines ) BuildEdgePresentation( const TopoDS_Edge& theEdge, double theDeviation ) +{ + BRepAdaptor_Curve aCurveAdaptor( theEdge ); + GCPnts_QuasiUniformDeflection aPnts( aCurveAdaptor, theDeviation ); + + Handle( Graphic3d_ArrayOfPolylines ) anArray; + if( !aPnts.IsDone() ) + return anArray; + + int n = aPnts.NbPoints(); + anArray = new Graphic3d_ArrayOfPolylines( n ); + for( int i=1; i<=n; i++ ) + anArray->AddVertex( aPnts.Value( i ) ); + + return anArray; +} + void HYDROGUI_Polyline::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPrs, const Standard_Integer aMode) { - AIS_Shape::Compute(aPresentationManager, aPrs, aMode); + //AIS_Shape::Compute(aPresentationManager, aPrs, aMode); + + aPrs->Clear(); + Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup( aPrs ); + Handle(Graphic3d_AspectLine3d) anAspect = Attributes()->FaceBoundaryAspect()->Aspect(); + aGroup->SetGroupPrimitivesAspect( anAspect ); + + TopExp_Explorer Exp1 ( myshape, TopAbs_EDGE ); + for ( ; Exp1.More(); Exp1.Next() ) + { + TopoDS_Edge anEdge = TopoDS::Edge( Exp1.Current() ); + Handle( Graphic3d_ArrayOfPolylines ) anArray = BuildEdgePresentation( anEdge, 0.1 ); + if( !anArray.IsNull() ) + aGroup->AddPrimitiveArray ( anArray ); + } + TopExp_Explorer Exp ( myshape, TopAbs_EDGE ); for ( ; Exp.More(); Exp.Next() ) { diff --git a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx index 759795a5..d7995dd1 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx @@ -232,7 +232,7 @@ bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags, } // At first we update the child u,z profile object - aProfileUZ->SetToUpdate( true ); + aProfileUZ->Changed( HYDROData_Entity::Geom_2d ); aProfileUZ->Update(); // And now we update our edited object diff --git a/src/HYDROGUI/HYDROGUI_StreamOp.cxx b/src/HYDROGUI/HYDROGUI_StreamOp.cxx index 6162acb8..4123e5be 100755 --- a/src/HYDROGUI/HYDROGUI_StreamOp.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamOp.cxx @@ -245,7 +245,7 @@ bool HYDROGUI_StreamOp::processApply( int& theUpdateFlags, myEditedObject->SetHydraulicAxis( aHydAxis ); myEditedObject->SetProfiles( aRefProfiles, false ); - if ( myEditedObject->IsMustBeUpdated() ) + if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ) myEditedObject->Update(); if ( !myIsEdit ) diff --git a/src/HYDROGUI/HYDROGUI_UpdateObjectOp.cxx b/src/HYDROGUI/HYDROGUI_UpdateObjectOp.cxx index d7925e36..08a1de81 100644 --- a/src/HYDROGUI/HYDROGUI_UpdateObjectOp.cxx +++ b/src/HYDROGUI/HYDROGUI_UpdateObjectOp.cxx @@ -73,7 +73,7 @@ void HYDROGUI_UpdateObjectOp::updateObject( const Handle(HYDROData_Entity)& theO updateObject( anObject, theMapOfTreated ); } - if ( !myIsForced && !theObject->IsMustBeUpdated() ) + if ( !myIsForced && !theObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) ) return; theObject->Update(); diff --git a/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx b/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx index 43a017d3..8be7fa37 100644 --- a/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx @@ -72,7 +72,7 @@ HYDROGUI_ViewerDlg::HYDROGUI_ViewerDlg( HYDROGUI_Module* theModule, const QStrin myViewManager->setViewModel( aViewer );// custom view model, which extends SALOME_View interface - aViewer->enableMultiselection( false ); + //aViewer->enableMultiselection( false ); SUIT_ViewWindow* aViewWin = myViewManager->createViewWindow(); aViewer->setStaticTrihedronDisplayed( false ); diff --git a/src/HYDROPy/HYDROData_Entity.sip b/src/HYDROPy/HYDROData_Entity.sip index 9dc1676e..ee4e4841 100644 --- a/src/HYDROPy/HYDROData_Entity.sip +++ b/src/HYDROPy/HYDROData_Entity.sip @@ -154,6 +154,16 @@ class HYDROData_Entity %End public: + enum Geometry + { + Geom_No = 1, + Geom_2d = 2, + Geom_Z = 4, + Geom_Groups = 8, + + Geom_3d = 6, + Geom_2d_and_groups = 10, + }; /** * Returns the kind of this object. Must be redefined in all objects of known type. @@ -186,19 +196,6 @@ public: */ virtual QVariant GetDataVariant(); - - /** - * Sets the "MustBeUpdated" flag: if object is depended on updated features. - * \param theFlag is true for objects that must be updated, false for up-to-date - */ - virtual void SetToUpdate( bool theFlag ); - - /** - * Returns the "MustBeUpdated" flag: is object data must be updated or not - * \returns false if object is up to date - */ - virtual bool IsMustBeUpdated() const; - /** * Returns flag indicating that object is updateble or not. */ @@ -216,24 +213,6 @@ public: */ virtual void Remove(); - - /** - * Copies all properties of this to the destinated object. - * Objects must be the same type. - * \param theDestination initialized object (from any document) - target of copying - */ - void CopyTo( HYDROData_Entity theDestination ) const [void ( const Handle_HYDROData_Entity& )]; - %MethodCode - Handle(HYDROData_Entity) aCopyTo = createHandle( a0 ); - if ( !aCopyTo.IsNull() ) - { - Py_BEGIN_ALLOW_THREADS - sipSelfWasArg ? sipCpp->HYDROData_Entity::CopyTo( aCopyTo ): - sipCpp->CopyTo( aCopyTo ); - Py_END_ALLOW_THREADS - } - %End - /** * Returns father object. For object created under root document label * this method always return NULL object. @@ -279,7 +258,7 @@ protected: * Creates new object in the internal data structure. Use higher level objects * to create objects with real content. */ - HYDROData_Entity(); + HYDROData_Entity( Geometry ); /** * Destructs properties of the object and object itself, removes it from the document. -- 2.39.2