From e7e76450be3fadf6ad263f78e10ceb8cd1f70deb Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Thu, 14 Nov 2019 16:11:16 +0100 Subject: [PATCH] Lot 2: change bathy associated to natural object propagated to all cases without need of update (but new exec of interpolation Z script requested) --- src/HYDROData/HYDROData_Object.cxx | 46 ++++++++++++++++-- src/HYDROData/HYDROData_Region.cxx | 4 +- src/HYDROData/HYDROData_Zone.cxx | 3 +- src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx | 56 +++++++++++++++++++++- src/HYDROGUI/HYDROGUI_Zone.cxx | 5 ++ 5 files changed, 106 insertions(+), 8 deletions(-) diff --git a/src/HYDROData/HYDROData_Object.cxx b/src/HYDROData/HYDROData_Object.cxx index 9d311e76..0fcae54f 100644 --- a/src/HYDROData/HYDROData_Object.cxx +++ b/src/HYDROData/HYDROData_Object.cxx @@ -45,6 +45,7 @@ HYDROData_Object::~HYDROData_Object() void HYDROData_Object::SetName( const QString& theName ) { + //DEBTRACE("SetName"); QString anOldObjName = GetName(); if ( anOldObjName != theName ) { @@ -74,6 +75,7 @@ void HYDROData_Object::SetName( const QString& theName ) void HYDROData_Object::Update() { + DEBTRACE("Update"); if( IsMustBeUpdated( Geom_2d ) ) { RemoveTopShape(); @@ -88,6 +90,7 @@ void HYDROData_Object::Update() HYDROData_SequenceOfObjects HYDROData_Object::GetAllReferenceObjects() const { + //DEBTRACE("GetAllReferenceObjects"); HYDROData_SequenceOfObjects aResSeq = HYDROData_Entity::GetAllReferenceObjects(); Handle(HYDROData_IAltitudeObject) aRefAltitude = GetAltitudeObject(); @@ -99,6 +102,7 @@ HYDROData_SequenceOfObjects HYDROData_Object::GetAllReferenceObjects() const void HYDROData_Object::Changed( Geometry theChangedGeometry ) { + DEBTRACE("Changed"); HYDROData_Entity::Changed( theChangedGeometry ); Handle(HYDROData_DummyObject3D) anObject3D = GetObject3D(); @@ -108,16 +112,19 @@ void HYDROData_Object::Changed( Geometry theChangedGeometry ) void HYDROData_Object::SetTopShape( const TopoDS_Shape& theShape ) { + DEBTRACE("SetTopShape"); HYDROData_Entity::SetShape( DataTag_TopShape, theShape ); } TopoDS_Shape HYDROData_Object::GetTopShape() const { + //DEBTRACE("GetTopShape"); return HYDROData_Entity::GetShape( DataTag_TopShape ); } void HYDROData_Object::SetShape3D( const TopoDS_Shape& theShape ) { + DEBTRACE("SetShape3D"); HYDROData_Entity::SetShape( DataTag_Shape3D, theShape ); // Check the object 3D existance checkAndSetObject3D(); @@ -125,11 +132,13 @@ void HYDROData_Object::SetShape3D( const TopoDS_Shape& theShape ) TopoDS_Shape HYDROData_Object::GetShape3D() const { + //DEBTRACE("GetShape3D"); return HYDROData_Entity::GetShape( DataTag_Shape3D ); } Handle(HYDROData_DummyObject3D) HYDROData_Object::GetObject3D() const { + //DEBTRACE("GetObject3D"); Handle(HYDROData_DummyObject3D) anObject; TDF_Label aLabel = myLab.FindChild( DataTag_Object3D, false ); @@ -148,6 +157,7 @@ Handle(HYDROData_DummyObject3D) HYDROData_Object::GetObject3D() const void HYDROData_Object::checkAndSetObject3D() { + DEBTRACE("checkAndSetObject3D"); TDF_Label aLabel = myLab.FindChild( DataTag_Object3D, false ); if ( !aLabel.IsNull() ) return; @@ -158,11 +168,13 @@ void HYDROData_Object::checkAndSetObject3D() HYDROData_SequenceOfObjects HYDROData_Object::GetGroups() const { + //DEBTRACE("GetGroups"); return GetReferenceObjects( DataTag_EdgesGroup ); } Handle(HYDROData_ShapesGroup) HYDROData_Object::GetGroup( const int theGroupId ) const { + //DEBTRACE("GetGroup"); Handle(HYDROData_ShapesGroup) aResGroup; HYDROData_SequenceOfObjects aGroups = GetGroups(); @@ -176,6 +188,7 @@ Handle(HYDROData_ShapesGroup) HYDROData_Object::GetGroup( const int theGroupId ) int HYDROData_Object::GetGroupId( const Handle(HYDROData_ShapesGroup)& theGroup ) const { + //DEBTRACE("GetGroupId"); int aRes = -1; HYDROData_SequenceOfObjects aGroups = GetGroups(); @@ -196,10 +209,14 @@ int HYDROData_Object::GetGroupId( const Handle(HYDROData_ShapesGroup)& theGroup bool HYDROData_Object::SetAltitudeObject( const Handle(HYDROData_IAltitudeObject)& theAltitude ) { + DEBTRACE("SetAltitudeObject"); if ( theAltitude.IsNull() ) return false; Handle(HYDROData_IAltitudeObject) aPrevAltitude = GetAltitudeObject(); + if (!aPrevAltitude.IsNull()) + DEBTRACE("aPrevAltitude: " << aPrevAltitude->GetName()) + DEBTRACE("theAltitude: " << theAltitude->GetName()) if ( IsEqual( aPrevAltitude, theAltitude ) ) return true; @@ -214,16 +231,18 @@ bool HYDROData_Object::SetAltitudeObject( Handle(HYDROData_IAltitudeObject) HYDROData_Object::GetAltitudeObject() const { + //DEBTRACE("GetAltitudeObject"); return Handle(HYDROData_IAltitudeObject)::DownCast( GetReferenceObject( DataTag_AltitudeObject ) ); } void HYDROData_Object::RemoveAltitudeObject() { + DEBTRACE("RemoveAltitudeObject"); Handle(HYDROData_IAltitudeObject) aPrevAltitude = GetAltitudeObject(); if ( aPrevAltitude.IsNull() ) return; - + DEBTRACE("aPrevAltitude: " << aPrevAltitude->GetName()) ClearReferenceObjects( DataTag_AltitudeObject ); // #636: In the case of the altitude object change the geometry of the main object is not changed, @@ -233,36 +252,43 @@ void HYDROData_Object::RemoveAltitudeObject() void HYDROData_Object::SetFillingColor( const QColor& theColor ) { + //DEBTRACE("SetFillingColor"); SetColor( theColor, DataTag_FillingColor ); } QColor HYDROData_Object::GetFillingColor() const { + //DEBTRACE("GetFillingColor"); return GetColor( DefaultFillingColor(), DataTag_FillingColor ); } void HYDROData_Object::SetBorderColor( const QColor& theColor ) { + //DEBTRACE("SetBorderColor"); SetColor( theColor, DataTag_BorderColor ); } QColor HYDROData_Object::GetBorderColor() const { + //DEBTRACE("GetBorderColor"); return GetColor( DefaultBorderColor(), DataTag_BorderColor ); } QColor HYDROData_Object::DefaultFillingColor() const { + //DEBTRACE("DefaultFillingColor"); return QColor( Qt::yellow ); } QColor HYDROData_Object::DefaultBorderColor() const { + //DEBTRACE("DefaultBorderColor"); return QColor( Qt::transparent ); } QStringList HYDROData_Object::dumpObjectCreation( MapOfTreatedObjects& theTreatedObjects ) const { + DEBTRACE("dumpObjectCreation"); QStringList aResList = HYDROData_Entity::dumpObjectCreation( theTreatedObjects ); if ( aResList.isEmpty() ) return aResList; //Object was not created @@ -291,6 +317,7 @@ ObjectKind HYDROData_Object::getAltitudeObjectType() const Handle(HYDROData_IAltitudeObject) HYDROData_Object::getChildAltitudeObject() const { + //DEBTRACE("getChildAltitudeObject"); Handle(HYDROData_IAltitudeObject) anObject; TDF_Label aLabel = myLab.FindChild( DataTag_ChildAltitudeObject, false ); @@ -309,14 +336,20 @@ Handle(HYDROData_IAltitudeObject) HYDROData_Object::getChildAltitudeObject() con void HYDROData_Object::checkAndSetAltitudeObject() { + DEBTRACE("checkAndSetAltitudeObject"); Handle(HYDROData_Document) aDocument = HYDROData_Document::Document(); ObjectKind anAltitudeObjectType = getAltitudeObjectType(); - //DEBTRACE("HYDROData_Object::checkAndSetAltitudeObject anAltitudeObjectType="<< anAltitudeObjectType); + DEBTRACE("HYDROData_Object::checkAndSetAltitudeObject anAltitudeObjectType="<< anAltitudeObjectType); if ( anAltitudeObjectType == KIND_UNKNOWN ) + { + DEBTRACE("anAltitudeObjectType == KIND_UNKNOWN"); return; // No need to create altitude object + } Handle(HYDROData_IAltitudeObject) altObject = GetAltitudeObject(); + if( !altObject.IsNull() ) + DEBTRACE(altObject->GetName()); if( !altObject.IsNull() && altObject->GetKind()==anAltitudeObjectType ) return; @@ -327,7 +360,7 @@ void HYDROData_Object::checkAndSetAltitudeObject() HYDROData_Iterator::CreateObject( aChildLabel, anAltitudeObjectType ) ); QString anAltitudePref = GetName() + "_Altitude"; - //DEBTRACE("anAltitudePref " << anAltitudePref.toStdString()); + DEBTRACE("anAltitudePref " << anAltitudePref.toStdString()); QString anAltitudeName = HYDROData_Tool::GenerateObjectName( aDocument, anAltitudePref ); anAltitudeObject->SetName( anAltitudeName ); @@ -336,6 +369,7 @@ void HYDROData_Object::checkAndSetAltitudeObject() Handle(HYDROData_ShapesGroup) HYDROData_Object::createGroupObject() { + DEBTRACE("createGroupObject"); TDF_Label aNewLab = myLab.FindChild( DataTag_EdgesGroup ).NewChild(); Handle(HYDROData_ShapesGroup) aNewGroup = @@ -347,6 +381,7 @@ Handle(HYDROData_ShapesGroup) HYDROData_Object::createGroupObject() void HYDROData_Object::RemoveGroupObjects() { + DEBTRACE("RemoveGroupObjects"); TDF_Label aLabel = myLab.FindChild( DataTag_EdgesGroup, false ); if ( !aLabel.IsNull() ) aLabel.ForgetAllAttributes(); @@ -354,16 +389,19 @@ void HYDROData_Object::RemoveGroupObjects() void HYDROData_Object::RemoveTopShape() { + DEBTRACE("RemoveTopShape"); HYDROData_Entity::SetShape( DataTag_TopShape, TopoDS_Shape() ); } void HYDROData_Object::RemoveShape3D() { + DEBTRACE("RemoveShape3D"); HYDROData_Entity::SetShape( DataTag_Shape3D, TopoDS_Shape() ); } bool HYDROData_Object::IsSubmersible() const { + //DEBTRACE("IsSubmersible"); Handle(TDataStd_Integer) aSubMersibleAttr; bool isSubmersible = true; //default @@ -377,6 +415,7 @@ bool HYDROData_Object::IsSubmersible() const void HYDROData_Object::SetIsSubmersible( bool isSubmersible ) const { + DEBTRACE("SetIsSubmersible"); Handle(TDataStd_Integer) anAttr = TDataStd_Integer::Set( myLab, isSubmersible ? 1 : 0 ); anAttr->SetID(TDataStd_Integer::GetID()); } @@ -384,6 +423,7 @@ void HYDROData_Object::SetIsSubmersible( bool isSubmersible ) const void HYDROData_Object::GetBoundaries( QList& theBoundShapes, QStringList& theBoundNames ) const { + DEBTRACE("GetBoundaries"); HYDROData_SequenceOfObjects aGroups = GetGroups(); HYDROData_SequenceOfObjects::Iterator anIter( aGroups ); for ( ; anIter.More(); anIter.Next() ) diff --git a/src/HYDROData/HYDROData_Region.cxx b/src/HYDROData/HYDROData_Region.cxx index c3876616..15bb8160 100644 --- a/src/HYDROData/HYDROData_Region.cxx +++ b/src/HYDROData/HYDROData_Region.cxx @@ -51,7 +51,7 @@ #include "gp_Pln.hxx" #include "BRepTools_ReShape.hxx" -//#define _DEVDEBUG_ +#define _DEVDEBUG_ #include "HYDRO_trace.hxx" //#define DEB_GET_REGION_SHAPE @@ -188,7 +188,7 @@ Handle(HYDROData_Zone) HYDROData_Region::addNewZone( const Handle(HYDROData_Docu Handle(HYDROData_Entity) aRefObject = theDoc->FindObjectByName( anObjName ); if ( aRefObject.IsNull() ) continue; - + DEBTRACE("aRefObject name: " << aRefObject->GetName()); aNewZone->AddObject( aRefObject ); } diff --git a/src/HYDROData/HYDROData_Zone.cxx b/src/HYDROData/HYDROData_Zone.cxx index 3b296621..9edf3051 100644 --- a/src/HYDROData/HYDROData_Zone.cxx +++ b/src/HYDROData/HYDROData_Zone.cxx @@ -141,7 +141,8 @@ HYDROData_Zone::MergeType HYDROData_Zone::GetMergeType() const void HYDROData_Zone::SetMergeObject( const Handle(HYDROData_Entity)& theObject ) { - //DEBTRACE("HYDROData_Zone::SetMergeObject"); + + DEBTRACE("HYDROData_Zone::SetMergeObject " << theObject->GetName().toStdString()); SetReferenceObject( theObject, DataTag_MergeObject ); } diff --git a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx index bf8ff273..d34c908e 100644 --- a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx @@ -45,6 +45,8 @@ #include #include +#define _DEVDEBUG_ +#include "HYDRO_trace.hxx" HYDROGUI_ImmersibleZoneOp::HYDROGUI_ImmersibleZoneOp( HYDROGUI_Module* theModule, const bool theIsEdit ) @@ -188,8 +190,25 @@ bool HYDROGUI_ImmersibleZoneOp::processApply( int& theUpdateFlags, aZoneObj->SetBorderColor( aZoneObj->DefaultBorderColor() ); } - aZoneObj->SetPolyline( aZonePolyline ); - aZoneObj->SetAltitudeObject( aZoneBathymetry ); + bool isPolylineChanged = true; + if (aZonePolyline && aZoneObj->GetPolyline() && (aZoneObj->GetPolyline()->GetName() == aZonePolyline->GetName())) + { + isPolylineChanged =false; + DEBTRACE("polyline unchanged"); + } + else + { + if (aZonePolyline) DEBTRACE(aZonePolyline->GetName().toStdString()); + if (aZoneObj->GetPolyline()) DEBTRACE(aZoneObj->GetPolyline()->GetName().toStdString()); + aZoneObj->SetPolyline( aZonePolyline ); + } + bool isBathymetryChanged = true; + if (aZoneBathymetry && aZoneObj->GetAltitudeObject() && IsEqual(aZoneObj->GetAltitudeObject(), aZoneBathymetry)) + { + isBathymetryChanged = false; + DEBTRACE("bathymetry unchanged"); + } + else aZoneObj->SetAltitudeObject( aZoneBathymetry ); aZoneObj->Update(); closePreview(); @@ -205,6 +224,39 @@ bool HYDROGUI_ImmersibleZoneOp::processApply( int& theUpdateFlags, theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer; + if (isBathymetryChanged) + { + DEBTRACE("bathymetry changed on " << anObjectName.toStdString()); + // Find immersibles objects referenced by all calculation case zones and check if they correspond to the one modified + HYDROData_SequenceOfObjects zoneList = doc()->CollectAllObjects(); + for (int i=1; i<=zoneList.Size(); i++ ) + { + //DEBTRACE(" --- entity: " << zoneList(i)->GetName().toStdString() << " " << zoneList(i)->GetKind()); + Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( zoneList(i) ); + if (aZone.IsNull()) + continue; + DEBTRACE(" zone tested: " << aZone->GetName().toStdString()); + HYDROData_SequenceOfObjects aSeq = aZone->GetObjects(); + HYDROData_SequenceOfObjects::Iterator anIter( aSeq ); + for ( ; anIter.More(); anIter.Next() ) + { + Handle(HYDROData_Entity) aMergeObject; + Handle(HYDROData_Object) aRefGeomObj = Handle(HYDROData_Object)::DownCast( anIter.Value() ); + if ( !aRefGeomObj.IsNull() ) + { + DEBTRACE(" aRefGeomObj " << aRefGeomObj->GetName().toStdString()); + if (aRefGeomObj->GetName() == anObjectName) + { + DEBTRACE(" BINGO! modify altitude object in zone"); + aMergeObject = aRefGeomObj->GetAltitudeObject(); + aZone->SetMergeObject( aMergeObject ); + break; + } + } + } + + } + } return true; } diff --git a/src/HYDROGUI/HYDROGUI_Zone.cxx b/src/HYDROGUI/HYDROGUI_Zone.cxx index 6da859d9..9be83f89 100644 --- a/src/HYDROGUI/HYDROGUI_Zone.cxx +++ b/src/HYDROGUI/HYDROGUI_Zone.cxx @@ -25,6 +25,9 @@ #include #include +#define _DEVDEBUG_ +#include "HYDRO_trace.hxx" + HYDROGUI_Zone::HYDROGUI_Zone( SUIT_DataObject* theParent, Handle(HYDROData_Zone) theData, const QString& theParentEntry, @@ -242,6 +245,7 @@ HYDROData_Zone::MergeType HYDROGUI_Zone::getMergeType() const void HYDROGUI_Zone::setMergeType( int theMergeType, QString theMergeObjectName ) { + DEBTRACE("HYDROGUI_Zone::setMergeType " << theMergeType << " " << theMergeObjectName.toStdString()); Handle(HYDROData_Zone) aZone = Handle(HYDROData_Zone)::DownCast( modelObject() ); if ( !aZone.IsNull() ) { @@ -262,6 +266,7 @@ void HYDROGUI_Zone::setMergeType( int theMergeType, QString theMergeObjectName ) if ( !aRefGeomObj.IsNull() ) { // Get altitude object + DEBTRACE("aRefGeomObj " << aRefGeomObj->GetName().toStdString()); aMergeObject = aRefGeomObj->GetAltitudeObject(); } -- 2.39.2