From 1c6465288cda49e75392724ddc01aba7cfe4ef68 Mon Sep 17 00:00:00 2001 From: adv Date: Thu, 5 Dec 2013 11:52:32 +0000 Subject: [PATCH] Update mechanism is corrected (Bug #182). --- src/HYDROData/HYDROData_Bathymetry.cxx | 16 ++- src/HYDROData/HYDROData_CalculationCase.cxx | 7 +- src/HYDROData/HYDROData_CalculationCase.h | 12 +- src/HYDROData/HYDROData_Entity.cxx | 14 ++- src/HYDROData/HYDROData_Image.cxx | 107 +++++++++--------- src/HYDROData/HYDROData_ImmersibleZone.cxx | 15 +++ src/HYDROData/HYDROData_ImmersibleZone.h | 10 ++ src/HYDROData/HYDROData_Object.cxx | 8 +- src/HYDROData/HYDROData_PolylineXY.cxx | 19 ++++ src/HYDROData/HYDROData_Profile.cxx | 13 +++ src/HYDROData/HYDROData_Tool.cxx | 35 +++--- src/HYDROData/HYDROData_Tool.h | 4 +- src/HYDROGUI/CMakeLists.txt | 4 +- src/HYDROGUI/HYDROGUI_CalculationOp.cxx | 2 +- src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx | 1 + src/HYDROGUI/HYDROGUI_ImportImageOp.cxx | 3 +- src/HYDROGUI/HYDROGUI_Module.cxx | 15 +-- src/HYDROGUI/HYDROGUI_Operations.cxx | 9 +- src/HYDROGUI/HYDROGUI_Operations.h | 3 +- src/HYDROGUI/HYDROGUI_ProfileOp.cxx | 2 + ...mageOp.cxx => HYDROGUI_UpdateObjectOp.cxx} | 38 +++++-- ...ateImageOp.h => HYDROGUI_UpdateObjectOp.h} | 18 ++- src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 12 +- 23 files changed, 236 insertions(+), 131 deletions(-) rename src/HYDROGUI/{HYDROGUI_UpdateImageOp.cxx => HYDROGUI_UpdateObjectOp.cxx} (60%) rename src/HYDROGUI/{HYDROGUI_UpdateImageOp.h => HYDROGUI_UpdateObjectOp.h} (69%) diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx index 3d5e9ca5..2cacf6f0 100644 --- a/src/HYDROData/HYDROData_Bathymetry.cxx +++ b/src/HYDROData/HYDROData_Bathymetry.cxx @@ -86,14 +86,20 @@ void HYDROData_Bathymetry::SetAltitudePoints( const AltitudePoints& thePoints ) aCoordsArray->SetValue( i * 3 + 1, aPoint.Y() ); aCoordsArray->SetValue( i * 3 + 2, aPoint.Z() ); } + + SetToUpdate( true ); } HYDROData_Bathymetry::AltitudePoints HYDROData_Bathymetry::GetAltitudePoints() const { AltitudePoints aPoints; + TDF_Label aLabel = myLab.FindChild( DataTag_AltitudePoints, false ); + if ( aLabel.IsNull() ) + return aPoints; + Handle(TDataStd_RealArray) aCoordsArray; - if ( !myLab.FindChild( DataTag_AltitudePoints ).FindAttribute( TDataStd_RealArray::GetID(), aCoordsArray ) ) + if ( !aLabel.FindAttribute( TDataStd_RealArray::GetID(), aCoordsArray ) ) return aPoints; for ( int i = aCoordsArray->Lower(), n = aCoordsArray->Upper(); i <= n; ) @@ -114,8 +120,12 @@ HYDROData_Bathymetry::AltitudePoints HYDROData_Bathymetry::GetAltitudePoints() c void HYDROData_Bathymetry::RemoveAltitudePoints() { - TDF_Label aLab = myLab.FindChild( DataTag_AltitudePoints ); - aLab.ForgetAllAttributes(); + TDF_Label aLabel = myLab.FindChild( DataTag_AltitudePoints, false ); + if ( !aLabel.IsNull() ) + { + aLabel.ForgetAllAttributes(); + SetToUpdate( true ); + } } void interpolateAltitudeForPoints( const gp_XY& thePoint, diff --git a/src/HYDROData/HYDROData_CalculationCase.cxx b/src/HYDROData/HYDROData_CalculationCase.cxx index e3c40801..c1b32445 100644 --- a/src/HYDROData/HYDROData_CalculationCase.cxx +++ b/src/HYDROData/HYDROData_CalculationCase.cxx @@ -139,8 +139,10 @@ HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetAllReferenceObjects() return aResSeq; } -void HYDROData_CalculationCase::SplitGeometryObjects() +void HYDROData_CalculationCase::Update() { + HYDROData_Entity::Update(); + // At first we remove previously created regions RemoveRegions(); @@ -194,9 +196,6 @@ void HYDROData_CalculationCase::SplitGeometryObjects() aRegionZone->AddGeometryObject( aRefObject ); } } - - // The splitted data is up to date - SetToUpdate( false ); } bool HYDROData_CalculationCase::AddGeometryObject( const Handle(HYDROData_Object)& theObject ) diff --git a/src/HYDROData/HYDROData_CalculationCase.h b/src/HYDROData/HYDROData_CalculationCase.h index 83d75bbe..f6787a27 100644 --- a/src/HYDROData/HYDROData_CalculationCase.h +++ b/src/HYDROData/HYDROData_CalculationCase.h @@ -56,6 +56,12 @@ public: */ HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const; + /** + * Update the calcualtion case object. + * Call this method whenever you made changes for object data. + */ + HYDRODATA_EXPORT virtual void Update(); + /** * Returns the list of all reference objects of this object. */ @@ -64,12 +70,6 @@ public: public: // Public methods to work with Calculation - /** - * Split reference geometry objects to non-intersected regions. - */ - HYDRODATA_EXPORT virtual void SplitGeometryObjects(); - - /** * Add new one reference geometry object for calculation case. */ diff --git a/src/HYDROData/HYDROData_Entity.cxx b/src/HYDROData/HYDROData_Entity.cxx index 015cb0f7..126f6dff 100644 --- a/src/HYDROData/HYDROData_Entity.cxx +++ b/src/HYDROData/HYDROData_Entity.cxx @@ -2,6 +2,7 @@ #include "HYDROData_Entity.h" #include "HYDROData_Iterator.h" +#include "HYDROData_Tool.h" #include #include @@ -55,6 +56,7 @@ QStringList HYDROData_Entity::DumpToPython( MapOfTreatedObjects& theTreatedObjec void HYDROData_Entity::Update() { + SetToUpdate( false ); } QVariant HYDROData_Entity::GetDataVariant() @@ -62,11 +64,21 @@ QVariant HYDROData_Entity::GetDataVariant() return QVariant(); } -void HYDROData_Entity::SetToUpdate(bool theFlag) +void HYDROData_Entity::SetToUpdate( bool theFlag ) { + if ( IsMustBeUpdated() == theFlag ) + return; + if ( theFlag ) { TDataStd_UAttribute::Set( myLab, GUID_MUST_BE_UPDATED ); + + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); + if ( !aDocument.IsNull() ) + { + // Change the states of this and all depended objects + HYDROData_Tool::SetMustBeUpdatedObjects( aDocument ); + } } else { diff --git a/src/HYDROData/HYDROData_Image.cxx b/src/HYDROData/HYDROData_Image.cxx index e589ae9c..c8fb2713 100644 --- a/src/HYDROData/HYDROData_Image.cxx +++ b/src/HYDROData/HYDROData_Image.cxx @@ -3,7 +3,6 @@ #include "HYDROData_Document.h" #include "HYDROData_Lambert93.h" -#include "HYDROData_Tool.h" #include "HYDROData_OperationsFactory.h" #include @@ -152,12 +151,21 @@ QStringList HYDROData_Image::DumpToPython( MapOfTreatedObjects& theTreatedObject void HYDROData_Image::Update() { + bool anIsToUpdate = IsMustBeUpdated(); + + HYDROData_Entity::Update(); + + if ( !anIsToUpdate ) + return; + HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory(); ImageComposer_Operator* anOp = aFactory->Operator( OperatorName() ); if ( anOp ) // Update image if there is an operation { // Fill by arguments and process the operation + anOp->setBinArgs( Args() ); + QVariant anObj1, anObj2; int aNbReferences = NbReferences(); @@ -193,15 +201,6 @@ void HYDROData_Image::Update() { UpdateTrsf(); } - - Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); - if ( !aDocument.IsNull() ) - { - // Change the states of this and all depended images - SetToUpdate( true ); - HYDROData_Tool::SetMustBeUpdatedImages( aDocument ); - SetToUpdate( false ); - } } QVariant HYDROData_Image::GetDataVariant() @@ -233,27 +232,32 @@ HYDROData_SequenceOfObjects HYDROData_Image::GetAllReferenceObjects() const void HYDROData_Image::SetImage(const QImage& theImage) { - if (theImage.isNull()) { + if ( theImage.isNull() ) + { // for empty image remove all previously stored attributes myLab.ForgetAttribute(TDataStd_IntegerArray::GetID()); myLab.ForgetAttribute(TDataStd_ByteArray::GetID()); - return; } - // store width, height, bytes per line and format in integer array - Handle(TDataStd_IntegerArray) aParams; - if (!myLab.FindAttribute(TDataStd_IntegerArray::GetID(), aParams)) { - aParams = TDataStd_IntegerArray::Set(myLab, 1, 4); + else + { + // store width, height, bytes per line and format in integer array + Handle(TDataStd_IntegerArray) aParams; + if (!myLab.FindAttribute(TDataStd_IntegerArray::GetID(), aParams)) { + aParams = TDataStd_IntegerArray::Set(myLab, 1, 4); + } + aParams->SetValue(1, theImage.width()); + aParams->SetValue(2, theImage.height()); + aParams->SetValue(3, theImage.bytesPerLine()); + aParams->SetValue(4, (int)(theImage.format())); + // store data of image in byte array + const char* aData = (const char*)(theImage.bits()); + SaveByteArray(0, aData, theImage.byteCount()); } - aParams->SetValue(1, theImage.width()); - aParams->SetValue(2, theImage.height()); - aParams->SetValue(3, theImage.bytesPerLine()); - aParams->SetValue(4, (int)(theImage.format())); - // store data of image in byte array - const char* aData = (const char*)(theImage.bits()); - SaveByteArray(0, aData, theImage.byteCount()); + + SetToUpdate( true ); } -bool HYDROData_Image::LoadImage(const QString& theFilePath) +bool HYDROData_Image::LoadImage( const QString& theFilePath ) { QImage anImage( theFilePath ); SetImage( anImage ); @@ -274,10 +278,12 @@ QImage HYDROData_Image::Image() return aResult; } -void HYDROData_Image::SetFilePath(const QString& theFilePath) +void HYDROData_Image::SetFilePath( const QString& theFilePath ) { TCollection_AsciiString anAsciiStr( theFilePath.toStdString().c_str() ); TDataStd_AsciiString::Set( myLab.FindChild( DataTag_FilePath ), anAsciiStr ); + + SetToUpdate( true ); } QString HYDROData_Image::GetFilePath() const @@ -312,6 +318,8 @@ void HYDROData_Image::SetTrsf(const QTransform& theTrsf) anArray->SetValue(7, theTrsf.m31()); anArray->SetValue(8, theTrsf.m32()); anArray->SetValue(9, theTrsf.m33()); + + SetToUpdate( true ); } QTransform HYDROData_Image::Trsf() const @@ -451,13 +459,14 @@ void HYDROData_Image::RemoveAllReferences() SetIsSelfSplitted( false ); } - SetToUpdate( false ); - bool anIsByTwoPoints = IsByTwoPoints(); QImage anImage = Image(); if ( anImage.isNull() ) + { + SetToUpdate( false ); return; + } // Set local points to default position QPoint aLocalPointA = QPoint( 0, 0 ); @@ -475,6 +484,8 @@ void HYDROData_Image::RemoveAllReferences() QPointF( aTransform.map( aLocalPointC ) ); SetGlobalPoints( ManualCartesian, aTrsfPointA, aTrsfPointB, aTrsfPointC ); + + SetToUpdate( false ); } void HYDROData_Image::SetLocalPoints( const QPoint& thePointA, @@ -497,6 +508,8 @@ void HYDROData_Image::SetLocalPoints( const QPoint& thePointA, if ( theIsUpdate ) UpdateTrsf(); + + SetToUpdate( true ); } bool HYDROData_Image::GetLocalPoints( QPoint& thePointA, @@ -551,31 +564,7 @@ void HYDROData_Image::SetGlobalPoints( const TransformationMode& theMode, if ( theIsUpdate ) UpdateTrsf(); - /* - if( anIsRefImage ) - { - aCPointA = QPointF( aTransform.map( aPointA ) ); - aCPointB = QPointF( aTransform.map( aPointB ) ); - aCPointC = QPointF( aTransform.map( aPointC ) ); - - // compute Lambert93 points - xca = aCPointA.x(); - yca = aCPointA.y(); - xcb = aCPointB.x(); - ycb = aCPointB.y(); - xcc = aCPointC.x(); - ycc = aCPointC.y(); - - double xla = 0, yla = 0, xlb = 0, ylb = 0, xlc = 0, ylc = 0; - HYDROData_Lambert93::toGeo( xca, yca, yla, xla ); - HYDROData_Lambert93::toGeo( xcb, ycb, ylb, xlb ); - HYDROData_Lambert93::toGeo( xcc, ycc, ylc, xlc ); - - aLPointA = QPointF( xla * 3600.0, yla * 3600.0 ); // convert degrees to seconds - aLPointB = QPointF( xlb * 3600.0, ylb * 3600.0 ); // convert degrees to seconds - aLPointC = QPointF( xlc * 3600.0, ylc * 3600.0 ); // convert degrees to seconds - } - */ + SetToUpdate( true ); } bool HYDROData_Image::GetGlobalPoints( TransformationMode& theMode, @@ -653,6 +642,7 @@ bool HYDROData_Image::HasReferencePoints() const void HYDROData_Image::SetTrsfMode( const TransformationMode& theMode ) { TDataStd_Integer::Set( myLab.FindChild( DataTag_TrsfMode ), (int)theMode ); + SetToUpdate( true ); } HYDROData_Image::TransformationMode HYDROData_Image::GetTrsfMode() const @@ -673,6 +663,7 @@ HYDROData_Image::TransformationMode HYDROData_Image::GetTrsfMode() const void HYDROData_Image::SetTrsfReferenceImage( const Handle(HYDROData_Image)& theRefImage ) { SetReferenceObject( theRefImage, DataTag_TrsfImage ); + SetToUpdate( true ); } Handle(HYDROData_Image) HYDROData_Image::GetTrsfReferenceImage() const @@ -682,12 +673,14 @@ Handle(HYDROData_Image) HYDROData_Image::GetTrsfReferenceImage() const void HYDROData_Image::RemoveTrsfReferenceImage() { - return RemoveReferenceObject( DataTag_TrsfImage ); + RemoveReferenceObject( DataTag_TrsfImage ); + SetToUpdate( true ); } void HYDROData_Image::AppendReference( const Handle(HYDROData_Entity)& theReferenced ) { AddReferenceObject( theReferenced, 0 ); + SetToUpdate( true ); } int HYDROData_Image::NbReferences() const @@ -704,22 +697,26 @@ void HYDROData_Image::ChangeReference( const int theIndex, Handle(HYDROData_Entity) theReferenced) { SetReferenceObject( theReferenced, 0, theIndex ); + SetToUpdate( true ); } void HYDROData_Image::RemoveReference(const int theIndex) { RemoveReferenceObject( 0, theIndex ); + SetToUpdate( true ); } void HYDROData_Image::ClearReferences() { ClearReferenceObjects( 0 ); + SetToUpdate( true ); } void HYDROData_Image::SetOperatorName( const QString theOpName ) { TCollection_AsciiString anAsciiStr( theOpName.toStdString().c_str() ); TDataStd_AsciiString::Set( myLab.FindChild( DataTag_Operator ), anAsciiStr ); + SetToUpdate( true ); } QString HYDROData_Image::OperatorName() const @@ -740,6 +737,7 @@ QString HYDROData_Image::OperatorName() const void HYDROData_Image::SetArgs(const QByteArray& theArgs) { SaveByteArray(DataTag_Operator, theArgs.constData(), theArgs.length()); + SetToUpdate( true ); } QByteArray HYDROData_Image::Args() const @@ -758,6 +756,7 @@ void HYDROData_Image::SetIsSelfSplitted(bool theFlag) } else { myLab.ForgetAttribute(GUID_SELF_SPLITTED); } + SetToUpdate( true ); } bool HYDROData_Image::IsSelfSplitted() const @@ -770,7 +769,7 @@ QPointF HYDROData_Image::generateThirdPoint( const QPointF& thePointA, const bool& theIsLocal ) const { // Rotate vector to 90 degrees : clockwise - for local - // anticlockwise - for global + // counterclockwise - for global const double aTheta = theIsLocal ? -M_PI_2 : M_PI_2; QPointF aResPoint; diff --git a/src/HYDROData/HYDROData_ImmersibleZone.cxx b/src/HYDROData/HYDROData_ImmersibleZone.cxx index cf4375de..38b83a61 100644 --- a/src/HYDROData/HYDROData_ImmersibleZone.cxx +++ b/src/HYDROData/HYDROData_ImmersibleZone.cxx @@ -87,6 +87,19 @@ HYDROData_SequenceOfObjects HYDROData_ImmersibleZone::GetAllReferenceObjects() c } TopoDS_Shape HYDROData_ImmersibleZone::GetTopShape() const +{ + return getTopShape(); +} + +void HYDROData_ImmersibleZone::Update() +{ + HYDROData_NaturalObject::Update(); + + TopoDS_Shape aResShape = generateTopShape(); + SetTopShape( aResShape ); +} + +TopoDS_Shape HYDROData_ImmersibleZone::generateTopShape() const { TopoDS_Shape aResShape = TopoDS_Face(); @@ -176,6 +189,7 @@ QColor HYDROData_ImmersibleZone::DefaultBorderColor() void HYDROData_ImmersibleZone::SetPolyline( const Handle(HYDROData_PolylineXY)& thePolyline ) { SetReferenceObject( thePolyline, DataTag_Polyline ); + SetToUpdate( true ); } Handle(HYDROData_PolylineXY) HYDROData_ImmersibleZone::GetPolyline() const @@ -187,6 +201,7 @@ Handle(HYDROData_PolylineXY) HYDROData_ImmersibleZone::GetPolyline() const void HYDROData_ImmersibleZone::RemovePolyline() { ClearReferenceObjects( DataTag_Polyline ); + SetToUpdate( true ); } diff --git a/src/HYDROData/HYDROData_ImmersibleZone.h b/src/HYDROData/HYDROData_ImmersibleZone.h index f7111a37..d8ea781c 100644 --- a/src/HYDROData/HYDROData_ImmersibleZone.h +++ b/src/HYDROData/HYDROData_ImmersibleZone.h @@ -42,6 +42,12 @@ public: */ HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const; + /** + * Update the immersible zone object. + * Call this method whenever you made changes for object data. + */ + HYDRODATA_EXPORT virtual void Update(); + /** * Returns the top shape of the object. */ @@ -77,6 +83,10 @@ public: */ HYDRODATA_EXPORT virtual void RemovePolyline(); +private: + + TopoDS_Shape generateTopShape() const; + protected: friend class HYDROData_Iterator; diff --git a/src/HYDROData/HYDROData_Object.cxx b/src/HYDROData/HYDROData_Object.cxx index e8477db6..3efd5c7b 100644 --- a/src/HYDROData/HYDROData_Object.cxx +++ b/src/HYDROData/HYDROData_Object.cxx @@ -47,14 +47,15 @@ void HYDROData_Object::SetShape3D( const TopoDS_Shape& theShape ) void HYDROData_Object::Update() { + HYDROData_Entity::Update(); removeTopShape(); removeShape3D(); - SetToUpdate( false ); } void HYDROData_Object::SetBathymetry( const Handle(HYDROData_Bathymetry)& theBathymetry ) { SetReferenceObject( theBathymetry, DataTag_Bathymetry ); + SetToUpdate( true ); } Handle(HYDROData_Bathymetry) HYDROData_Object::GetBathymetry() const @@ -66,6 +67,7 @@ Handle(HYDROData_Bathymetry) HYDROData_Object::GetBathymetry() const void HYDROData_Object::RemoveBathymetry() { ClearReferenceObjects( DataTag_Bathymetry ); + SetToUpdate( true ); } TopoDS_Shape HYDROData_Object::getTopShape() const @@ -110,7 +112,7 @@ void HYDROData_Object::removeShape3D() void HYDROData_Object::SetFillingColor( const QColor& theColor ) { - return SetColor( theColor, DataTag_FillingColor ); + SetColor( theColor, DataTag_FillingColor ); } QColor HYDROData_Object::GetFillingColor() const @@ -120,7 +122,7 @@ QColor HYDROData_Object::GetFillingColor() const void HYDROData_Object::SetBorderColor( const QColor& theColor ) { - return SetColor( theColor, DataTag_BorderColor ); + SetColor( theColor, DataTag_BorderColor ); } QColor HYDROData_Object::GetBorderColor() const diff --git a/src/HYDROData/HYDROData_PolylineXY.cxx b/src/HYDROData/HYDROData_PolylineXY.cxx index b20f1bd8..a8cb4c0f 100755 --- a/src/HYDROData/HYDROData_PolylineXY.cxx +++ b/src/HYDROData/HYDROData_PolylineXY.cxx @@ -190,6 +190,8 @@ void HYDROData_PolylineXY::BuildPainterPath( QPainterPath& void HYDROData_PolylineXY::Update() { + HYDROData_IPolyline::Update(); + NCollection_Sequence aSectNames; NCollection_Sequence aSectTypes; NCollection_Sequence aSectClosures; @@ -379,6 +381,8 @@ void HYDROData_PolylineXY::AddSection( const TCollection_AsciiString& theSectNam aNamesList->Append( aSectName ); aTypesList->Append( theSectionType ); aClosuresList->Append( theIsClosed ); + + SetToUpdate( true ); } TCollection_AsciiString HYDROData_PolylineXY::GetSectionName( const int theSectionIndex ) const @@ -422,6 +426,8 @@ 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 @@ -458,6 +464,8 @@ void HYDROData_PolylineXY::SetSectionType( const int theSectionIndex, TColStd_ListIteratorOfListOfInteger aTypesIter( anOldTypesList ); for ( int i = 0; aTypesIter.More(); aTypesIter.Next(), ++i ) aTypesList->Append( i == theSectionIndex ? theSectionType : aTypesIter.Value() ); + + SetToUpdate( true ); } bool HYDROData_PolylineXY::IsClosedSection( const int theSectionIndex ) const @@ -494,6 +502,8 @@ void HYDROData_PolylineXY::SetSectionClosed( const int theSectionIndex, TDataStd_ListIteratorOfListOfByte aClosuresIter( anOldClosuresList ); for ( int i = 0; aClosuresIter.More(); aClosuresIter.Next(), ++i ) aClosuresList->Append( i == theSectionIndex ? theIsClosed : (bool)aClosuresIter.Value() ); + + SetToUpdate( true ); } void HYDROData_PolylineXY::GetSections( NCollection_Sequence& theSectNames, @@ -574,12 +584,15 @@ void HYDROData_PolylineXY::RemoveSection( const int theSectionIndex ) // Remove points that belongs to removed section removePointsLists( theSectionIndex ); } + + SetToUpdate( true ); } void HYDROData_PolylineXY::RemoveSections() { removeSectionsLists(); removePointsLists(); + SetToUpdate( true ); } void HYDROData_PolylineXY::AddPoint( const int theSectionIndex, @@ -624,6 +637,8 @@ void HYDROData_PolylineXY::AddPoint( const int theSectionIndex, aListY->Append( aCoordY ); } } + + SetToUpdate( true ); } void HYDROData_PolylineXY::SetPoint( const int theSectionIndex, @@ -673,6 +688,8 @@ void HYDROData_PolylineXY::SetPoint( const int theSectionIndex, aListY->Append( aCoordY ); } } + + SetToUpdate( true ); } void HYDROData_PolylineXY::RemovePoint( const int theSectionIndex, @@ -710,6 +727,8 @@ void HYDROData_PolylineXY::RemovePoint( const int theSectionIndex, aListY->Append( anIterY.Value() ); } } + + SetToUpdate( true ); } HYDROData_PolylineXY::PointsList HYDROData_PolylineXY::GetPoints( const int theSectionIndex ) const diff --git a/src/HYDROData/HYDROData_Profile.cxx b/src/HYDROData/HYDROData_Profile.cxx index b32809b3..85f5fd72 100755 --- a/src/HYDROData/HYDROData_Profile.cxx +++ b/src/HYDROData/HYDROData_Profile.cxx @@ -64,6 +64,8 @@ TopoDS_Shape HYDROData_Profile::GetShape3D() const void HYDROData_Profile::Update() { + HYDROData_Object::Update(); + BRepBuilderAPI_MakeWire aMakeWire; ProfilePoints aProfilePoints = GetProfilePoints(); @@ -129,6 +131,8 @@ void HYDROData_Profile::SetFirstPoint( const gp_XY& thePoint ) anArray->SetValue( 0, thePoint.X() ); anArray->SetValue( 1, thePoint.Y() ); + + SetToUpdate( true ); } bool HYDROData_Profile::GetFirstPoint( gp_XY& thePoint ) const @@ -157,6 +161,8 @@ void HYDROData_Profile::SetLastPoint( const gp_XY& thePoint ) anArray->SetValue( 0, thePoint.X() ); anArray->SetValue( 1, thePoint.Y() ); + + SetToUpdate( true ); } bool HYDROData_Profile::GetLastPoint( gp_XY& thePoint ) const @@ -184,6 +190,8 @@ void HYDROData_Profile::Invalidate() TDF_Label aLastLabel = myLab.FindChild( DataTag_LastPoint, false ); if ( !aLastLabel.IsNull() ) aLastLabel.ForgetAllAttributes(); + + SetToUpdate( true ); } Handle(HYDROData_ProfileUZ) HYDROData_Profile::GetProfileUZ( const bool theIsCreate ) const @@ -214,7 +222,10 @@ void HYDROData_Profile::RemovePoints() { Handle(HYDROData_ProfileUZ) aProfileUZ = GetProfileUZ( false ); if ( !aProfileUZ.IsNull() ) + { aProfileUZ->RemoveSections(); + SetToUpdate( true ); + } } void HYDROData_Profile::SetParametricPoints( const HYDROData_ProfileUZ::PointsList& thePoints ) @@ -227,6 +238,8 @@ void HYDROData_Profile::SetParametricPoints( const HYDROData_ProfileUZ::PointsLi const HYDROData_ProfileUZ::Point& aPoint = thePoints.Value( i ); aProfileUZ->AddPoint( 0, aPoint ); } + + SetToUpdate( true ); } HYDROData_ProfileUZ::PointsList HYDROData_Profile::GetParametricPoints() const diff --git a/src/HYDROData/HYDROData_Tool.cxx b/src/HYDROData/HYDROData_Tool.cxx index fee6e110..68e759d7 100644 --- a/src/HYDROData/HYDROData_Tool.cxx +++ b/src/HYDROData/HYDROData_Tool.cxx @@ -25,42 +25,33 @@ void HYDROData_Tool::WriteStringsToFile( QFile& theFile, anOutStream << aWriteStr << theSep << theSep; } -void HYDROData_Tool::SetMustBeUpdatedImages( +void HYDROData_Tool::SetMustBeUpdatedObjects( const Handle(HYDROData_Document)& theDoc ) { bool anIsChanged = true; - // iterate until there is no changes because images on all level of dependency must be updated + // iterate until there is no changes because objects on all level of dependency must be updated while ( anIsChanged ) { anIsChanged = false; - HYDROData_Iterator anIter( theDoc, KIND_IMAGE ); + HYDROData_Iterator anIter( theDoc ); for ( ; anIter.More(); anIter.Next() ) { - Handle(HYDROData_Image) anImage = - Handle(HYDROData_Image)::DownCast( anIter.Current() ); - if ( anImage.IsNull() || anImage->IsMustBeUpdated() ) + Handle(HYDROData_Entity) anObject = anIter.Current(); + if ( anObject.IsNull() || anObject->IsMustBeUpdated() ) continue; - Handle(HYDROData_Image) aTrsfRefImage = anImage->GetTrsfReferenceImage(); - if ( !aTrsfRefImage.IsNull() && aTrsfRefImage->IsMustBeUpdated() ) + HYDROData_SequenceOfObjects aRefSeq = anObject->GetAllReferenceObjects(); + for ( int i = 1, n = aRefSeq.Length(); i <= n; ++i ) { - anImage->SetToUpdate( true ); - anIsChanged = true; - continue; - } + Handle(HYDROData_Entity) aRefObject = aRefSeq.Value( i ); + if ( aRefObject.IsNull() || !aRefObject->IsMustBeUpdated() ) + continue; - for ( int i = 0, aNBRefs = anImage->NbReferences(); i < aNBRefs; ++i ) - { - Handle(HYDROData_Image) aRefImage = - Handle(HYDROData_Image)::DownCast( anImage->Reference( i ) ); - if ( !aRefImage.IsNull() && aRefImage->IsMustBeUpdated() ) - { - // image references to updated => also must be updated - anImage->SetToUpdate( true ); - anIsChanged = true; - } + anObject->SetToUpdate( true ); + anIsChanged = true; + break; } } } diff --git a/src/HYDROData/HYDROData_Tool.h b/src/HYDROData/HYDROData_Tool.h index a1fc8337..cb1506e0 100644 --- a/src/HYDROData/HYDROData_Tool.h +++ b/src/HYDROData/HYDROData_Tool.h @@ -22,10 +22,10 @@ public: const QString& theSep = "\n" ); /** - * Enables "MustBeUpdated" flag for Images that are depended on "MustBeUpdated" images. + * Enables "MustBeUpdated" flag for objects that are depended on "MustBeUpdated" objects. * \param theDoc document where this operation is performed */ - static void SetMustBeUpdatedImages( const Handle(HYDROData_Document)& theDoc ); + static void SetMustBeUpdatedObjects( const Handle(HYDROData_Document)& theDoc ); /** * \brief Generate name for new object. diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index a7f6b516..2ac374ba 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -57,7 +57,7 @@ set(PROJECT_HEADERS HYDROGUI_TwoImagesDlg.h HYDROGUI_TwoImagesOp.h HYDROGUI_UpdateFlags.h - HYDROGUI_UpdateImageOp.h + HYDROGUI_UpdateObjectOp.h HYDROGUI_VisualStateOp.h HYDROGUI_VTKPrs.h HYDROGUI_VTKPrsBathymetry.h @@ -133,7 +133,7 @@ set(PROJECT_SOURCES HYDROGUI_Tool.cxx HYDROGUI_TwoImagesDlg.cxx HYDROGUI_TwoImagesOp.cxx - HYDROGUI_UpdateImageOp.cxx + HYDROGUI_UpdateObjectOp.cxx HYDROGUI_VisualStateOp.cxx HYDROGUI_VTKPrs.cxx HYDROGUI_VTKPrsBathymetry.cxx diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index 0323f921..ad69b40c 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -556,7 +556,7 @@ void HYDROGUI_CalculationOp::onSplitZones() if ( myEditedObject->IsMustBeUpdated() ) { myShowZones = true; - myEditedObject->SplitGeometryObjects(); + myEditedObject->Update(); aPanel->setEditedObject( myEditedObject ); diff --git a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx index 92bcc38c..3e9fd482 100644 --- a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx @@ -221,6 +221,7 @@ bool HYDROGUI_ImmersibleZoneOp::processApply( int& theUpdateFlags, aZoneObj->SetPolyline( aZonePolyline ); aZoneObj->SetBathymetry( aZoneBathymetry ); + aZoneObj->Update(); closePreview(); diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx index 3c3f64f0..b3232d5f 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx @@ -466,8 +466,7 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags, if( !myIsEdit ) module()->setObjectVisible( HYDROGUI_Tool::GetActiveGraphicsViewId( module() ), anImageObj, true ); - if( myIsEdit ) - anImageObj->Update(); + anImageObj->Update(); theUpdateFlags = UF_Model | UF_Viewer | UF_GV_Forced | UF_OCCViewer | UF_OCC_Forced; return true; diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 3433e99a..19d2e207 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -253,7 +253,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, bool anIsFusedImage = false; bool anIsCutImage = false; bool anIsSplittedImage = false; - bool anIsMustBeUpdatedImage = false; + bool anIsMustobjectBeUpdated = false; bool anIsPolyline = false; bool anIsPolyline3D = false; bool anIsProfile = false; @@ -290,6 +290,11 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, anIsVisibleInSelection |= aVisibility; anIsHiddenInSelection |= !aVisibility; + if ( anObject->IsMustBeUpdated() ) + { + anIsMustobjectBeUpdated = true; + } + ObjectKind anObjectKind = anObject->GetKind(); if( anObjectKind == KIND_IMAGE ) { @@ -312,10 +317,6 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, anIsSplittedImage = true; } } - if ( anImage->IsMustBeUpdated() ) - { - anIsMustBeUpdatedImage = true; - } } } else if( anObjectKind == KIND_POLYLINEXY ) @@ -410,9 +411,9 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, if( anIsSelectedDataObjects ) { - if ( anIsMustBeUpdatedImage ) + if ( anIsMustobjectBeUpdated ) { - theMenu->addAction( action( UpdateImageId ) ); + theMenu->addAction( action( UpdateObjectId ) ); theMenu->addSeparator(); } diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index 96f78286..85601129 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -41,7 +41,7 @@ #include "HYDROGUI_StreamOp.h" #include "HYDROGUI_TwoImagesOp.h" #include "HYDROGUI_UpdateFlags.h" -#include "HYDROGUI_UpdateImageOp.h" +#include "HYDROGUI_UpdateObjectOp.h" #include "HYDROGUI_VisualStateOp.h" #include "HYDROGUI_ImmersibleZoneOp.h" #include "HYDROGUI_ImportGeomObjectOp.h" @@ -102,11 +102,12 @@ void HYDROGUI_Module::createActions() createAction( CopyId, "COPY", "", Qt::CTRL + Qt::Key_C ); createAction( PasteId, "PASTE", "", Qt::CTRL + Qt::Key_V ); + createAction( UpdateObjectId, "UPDATE_OBJECT" ); + createAction( ImportImageId, "IMPORT_IMAGE", "", Qt::CTRL + Qt::Key_I ); createAction( EditImportedImageId, "EDIT_IMPORTED_IMAGE" ); createAction( ObserveImageId, "OBSERVE_IMAGE" ); createAction( ExportImageId, "EXPORT_IMAGE" ); - createAction( UpdateImageId, "UPDATE_IMAGE" ); createAction( RemoveImageRefsId, "REMOVE_IMAGE_REFERENCE" ); createAction( CreatePolylineId, "CREATE_POLYLINE" ); @@ -347,8 +348,8 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const case ExportImageId: anOp = new HYDROGUI_ExportImageOp( aModule ); break; - case UpdateImageId: - anOp = new HYDROGUI_UpdateImageOp( aModule ); + case UpdateObjectId: + anOp = new HYDROGUI_UpdateObjectOp( aModule ); break; case RemoveImageRefsId: anOp = new HYDROGUI_RemoveImageRefsOp( aModule ); diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index d892d67f..3344f3c9 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -36,11 +36,12 @@ enum OperationId CopyId, PasteId, + UpdateObjectId, + ImportImageId, EditImportedImageId, ObserveImageId, ExportImageId, - UpdateImageId, RemoveImageRefsId, CreatePolylineId, diff --git a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx index 386e914a..a9a9cf2c 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx @@ -200,6 +200,8 @@ bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags, } aProfileObj->SetParametricPoints( aProfileParamPoints ); + aProfileObj->Update(); + theUpdateFlags = UF_Model; return true; } diff --git a/src/HYDROGUI/HYDROGUI_UpdateImageOp.cxx b/src/HYDROGUI/HYDROGUI_UpdateObjectOp.cxx similarity index 60% rename from src/HYDROGUI/HYDROGUI_UpdateImageOp.cxx rename to src/HYDROGUI/HYDROGUI_UpdateObjectOp.cxx index 34256182..ec2285e5 100644 --- a/src/HYDROGUI/HYDROGUI_UpdateImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_UpdateObjectOp.cxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include "HYDROGUI_UpdateImageOp.h" +#include "HYDROGUI_UpdateObjectOp.h" #include "HYDROGUI_Module.h" #include "HYDROGUI_Tool.h" @@ -29,29 +29,29 @@ #include #include -HYDROGUI_UpdateImageOp::HYDROGUI_UpdateImageOp( HYDROGUI_Module* theModule ) +HYDROGUI_UpdateObjectOp::HYDROGUI_UpdateObjectOp( HYDROGUI_Module* theModule ) : HYDROGUI_Operation( theModule ) { setName( tr( "UPDATE_IMAGE" ) ); } -HYDROGUI_UpdateImageOp::~HYDROGUI_UpdateImageOp() +HYDROGUI_UpdateObjectOp::~HYDROGUI_UpdateObjectOp() { } -void HYDROGUI_UpdateImageOp::startOperation() +void HYDROGUI_UpdateObjectOp::startOperation() { HYDROGUI_Operation::startOperation(); startDocOperation(); + NCollection_Map aMapOfTreated; + HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( module() ); for( int anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ ) { - Handle(HYDROData_Image) anImage = - Handle(HYDROData_Image)::DownCast( aSeq.Value( anIndex ) ); - if( !anImage.IsNull() && anImage->IsMustBeUpdated() ) - anImage->Update(); + Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex ); + updateObject( anObject, aMapOfTreated ); } commitDocOperation(); @@ -59,3 +59,25 @@ void HYDROGUI_UpdateImageOp::startOperation() module()->update( UF_Model | UF_Viewer | UF_GV_Forced | UF_OCCViewer | UF_OCC_Forced ); commit(); } + +void HYDROGUI_UpdateObjectOp::updateObject( const Handle(HYDROData_Entity)& theObject, + NCollection_Map& theMapOfTreated ) const +{ + if( theObject.IsNull() || theMapOfTreated.Contains( theObject ) ) + return; + + theMapOfTreated.Add( theObject ); + + HYDROData_SequenceOfObjects aRefSeq = theObject->GetAllReferenceObjects(); + for ( int i = 1, n = aRefSeq.Length(); i <= n; ++i ) + { + Handle(HYDROData_Entity) anObject = aRefSeq.Value( i ); + updateObject( anObject, theMapOfTreated ); + } + + if ( !theObject->IsMustBeUpdated() ) + return; + + theObject->Update(); +} + diff --git a/src/HYDROGUI/HYDROGUI_UpdateImageOp.h b/src/HYDROGUI/HYDROGUI_UpdateObjectOp.h similarity index 69% rename from src/HYDROGUI/HYDROGUI_UpdateImageOp.h rename to src/HYDROGUI/HYDROGUI_UpdateObjectOp.h index fa011434..735b01bf 100644 --- a/src/HYDROGUI/HYDROGUI_UpdateImageOp.h +++ b/src/HYDROGUI/HYDROGUI_UpdateObjectOp.h @@ -20,21 +20,29 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef HYDROGUI_UPDATEIMAGEOP_H -#define HYDROGUI_UPDATEIMAGEOP_H +#ifndef HYDROGUI_UpdateObjectOp_H +#define HYDROGUI_UpdateObjectOp_H #include "HYDROGUI_Operation.h" -class HYDROGUI_UpdateImageOp : public HYDROGUI_Operation +#include + +class Handle_HYDROData_Entity; + +class HYDROGUI_UpdateObjectOp : public HYDROGUI_Operation { Q_OBJECT public: - HYDROGUI_UpdateImageOp( HYDROGUI_Module* theModule ); - virtual ~HYDROGUI_UpdateImageOp(); + HYDROGUI_UpdateObjectOp( HYDROGUI_Module* theModule ); + virtual ~HYDROGUI_UpdateObjectOp(); protected: + virtual void startOperation(); + + virtual void updateObject( const Handle_HYDROData_Entity& theObject, + NCollection_Map& theMapOfTreated ) const; }; #endif diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 4fece1fa..751d79b5 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -657,8 +657,8 @@ file cannot be correctly imported for a Bathymetry definition. Undo - DSK_UPDATE_IMAGE - Update image + DSK_UPDATE_OBJECT + Update DSK_IMPORT_OBSTACLE_FROM_FILE @@ -869,8 +869,8 @@ file cannot be correctly imported for a Bathymetry definition. Undo - MEN_UPDATE_IMAGE - Update image + MEN_UPDATE_OBJECT + Update MEN_IMPORT_OBSTACLE_FROM_FILE @@ -1057,8 +1057,8 @@ file cannot be correctly imported for a Bathymetry definition. Undo - STB_UPDATE_IMAGE - Update image + STB_UPDATE_OBJECT + Update STB_IMPORT_OBSTACLE_FROM_FILE -- 2.39.2