From 95fae05fbf436c6efd6dcebe37dc8315e9f3147b Mon Sep 17 00:00:00 2001 From: asl Date: Thu, 14 Aug 2014 07:15:08 +0000 Subject: [PATCH] debug of local CS --- src/HYDROData/HYDROData_Bathymetry.cxx | 14 ++++++ src/HYDROData/HYDROData_Bathymetry.h | 2 + src/HYDROData/HYDROData_Confluence.cxx | 5 +++ src/HYDROData/HYDROData_Confluence.h | 2 + src/HYDROData/HYDROData_Document.cxx | 59 ++++++++++++++++++------- src/HYDROData/HYDROData_Document.h | 5 ++- src/HYDROData/HYDROData_DummyObject3D.h | 1 - src/HYDROData/HYDROData_Entity.cxx | 5 +++ src/HYDROData/HYDROData_Entity.h | 1 + src/HYDROData/HYDROData_Obstacle.cxx | 5 +++ src/HYDROData/HYDROData_Obstacle.h | 2 + src/HYDROData/HYDROData_PolylineXY.cxx | 22 +++++++++ src/HYDROData/HYDROData_PolylineXY.h | 2 + src/HYDROData/HYDROData_Profile.cxx | 13 ++++++ src/HYDROData/HYDROData_Profile.h | 2 + src/HYDROData/HYDROData_River.cxx | 5 +++ src/HYDROData/HYDROData_River.h | 2 + src/HYDROData/HYDROData_Zone.h | 1 - src/HYDROGUI/HYDROGUI_DataObject.cxx | 2 + src/HYDROGUI/HYDROGUI_Tool.cxx | 7 ++- src/HYDROPy/HYDROData_Document.sip | 2 + 21 files changed, 137 insertions(+), 22 deletions(-) diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx index e6968d61..58d3a11c 100644 --- a/src/HYDROData/HYDROData_Bathymetry.cxx +++ b/src/HYDROData/HYDROData_Bathymetry.cxx @@ -520,3 +520,17 @@ Handle_HYDROData_PolylineXY HYDROData_Bathymetry::CreateBoundaryPolyline() const return aResult; } + +void HYDROData_Bathymetry::UpdateLocalCS( double theDx, double theDy ) +{ + gp_XYZ aDelta( theDx, theDy, 0 ); + AltitudePoints aPoints = GetAltitudePoints(); + AltitudePoints::Iterator anIter( aPoints ); + for ( int i = 0 ; anIter.More(); ++i, anIter.Next() ) + { + AltitudePoint& aPoint = anIter.ChangeValue(); + aPoint += aDelta; + } + SetAltitudePoints( aPoints ); +} + diff --git a/src/HYDROData/HYDROData_Bathymetry.h b/src/HYDROData/HYDROData_Bathymetry.h index 72ef4139..cd8c306b 100644 --- a/src/HYDROData/HYDROData_Bathymetry.h +++ b/src/HYDROData/HYDROData_Bathymetry.h @@ -115,6 +115,8 @@ public: HYDRODATA_EXPORT Handle_HYDROData_PolylineXY CreateBoundaryPolyline() const; + HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy ); + private: /** diff --git a/src/HYDROData/HYDROData_Confluence.cxx b/src/HYDROData/HYDROData_Confluence.cxx index 64883f88..bf7ee295 100644 --- a/src/HYDROData/HYDROData_Confluence.cxx +++ b/src/HYDROData/HYDROData_Confluence.cxx @@ -46,5 +46,10 @@ TopoDS_Shape HYDROData_Confluence::GetShape3D() const return getShape3D(); } +void HYDROData_Confluence::UpdateLocalCS( double theDx, double theDy ) +{ + //TODO +} + diff --git a/src/HYDROData/HYDROData_Confluence.h b/src/HYDROData/HYDROData_Confluence.h index 224b19e6..f8f68af7 100644 --- a/src/HYDROData/HYDROData_Confluence.h +++ b/src/HYDROData/HYDROData_Confluence.h @@ -44,6 +44,8 @@ public: */ HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const; + HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy ); + protected: friend class HYDROData_Iterator; diff --git a/src/HYDROData/HYDROData_Document.cxx b/src/HYDROData/HYDROData_Document.cxx index 58e4f0e7..86d16b08 100644 --- a/src/HYDROData/HYDROData_Document.cxx +++ b/src/HYDROData/HYDROData_Document.cxx @@ -9,7 +9,6 @@ #include -#include #include #include @@ -203,6 +202,11 @@ bool HYDROData_Document::DumpToPython( const QString& theFileName, bool aRes = true; + // Dump the local CS data to Python + UpdateLCSFields(); + QString aLCS = QString( "%1.SetLocalCS( %2, %3 )" ).arg( GetDocPyName() ).arg( myLX ).arg( myLY ); + HYDROData_Tool::WriteStringsToFile( aFile, QStringList() << aLCS ); + // Dump all model objects to Python script aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_IMAGE ); aRes = aRes && dumpPartitionToPython( aFile, theIsMultiFile, aTreatedObjects, KIND_POLYLINEXY ); @@ -677,7 +681,7 @@ TDF_Label HYDROData_Document::LabelOfLocalCS() const return myDoc->Main().FindChild(TAG_LOCAL_CS); } -gp_Pnt2d HYDROData_Document::GetLocalCS() const +void HYDROData_Document::GetLocalCS( double& theLX, double& theLY ) const { TDF_Label aLocalCSLab = LabelOfLocalCS(); @@ -685,35 +689,58 @@ gp_Pnt2d HYDROData_Document::GetLocalCS() const if( aLocalCSLab.FindAttribute( TDataXtd_Position::GetID(), aLocalCS ) ) { gp_Pnt aLocalCS3d = aLocalCS->GetPosition(); - return gp_Pnt2d( aLocalCS3d.X(), aLocalCS3d.Y() ); + theLX = aLocalCS3d.X(); + theLY = aLocalCS3d.Y(); } else - return DEFAULT_LOCAL_CS; + { + theLX = DEFAULT_LOCAL_CS.X(); + theLY = DEFAULT_LOCAL_CS.Y(); + } } -void HYDROData_Document::SetLocalCS( const gp_Pnt2d& theLocalCS ) +void HYDROData_Document::SetLocalCS( double theLX, double theLY ) { - TDF_Label aLocalCSLab = LabelOfLocalCS(); + UpdateLCSFields(); + // update the local CS data in attribute + TDF_Label aLocalCSLab = LabelOfLocalCS(); Handle( TDataXtd_Position ) aLocalCS; if( !aLocalCSLab.FindAttribute( TDataXtd_Position::GetID(), aLocalCS ) ) aLocalCS = TDataXtd_Position::Set( aLocalCSLab ); - gp_Pnt aLocalCS3d( theLocalCS.X(), theLocalCS.Y(), 0 ); + gp_Pnt aLocalCS3d( theLX, theLY, 0 ); aLocalCS->SetPosition( aLocalCS3d ); - myLX = theLocalCS.X(); - myLY = theLocalCS.Y(); + + // calculate delta for coordinates + double aDX = myLX - theLX; + double aDY = myLY - theLY; + + // update the local CS data in internal fields + myLX = theLX; + myLY = theLY; + + //update all objects in the document + HYDROData_Iterator anIterator( this, KIND_UNKNOWN ); + for( ; anIterator.More(); anIterator.Next() ) + anIterator.Current()->UpdateLocalCS( aDX, aDY ); +} + +void HYDROData_Document::UpdateLCSFields() const +{ + if( myLX >= 0 && myLY >= 0 ) + return; + + double aLX, aLY; + GetLocalCS( aLX, aLY ); + HYDROData_Document* aThat = const_cast( this ); + aThat->myLX = aLX; + aThat->myLY = aLY; } void HYDROData_Document::Transform( double& X, double& Y, bool IsToLocalCS ) const { - if( myLX < 0 || myLY < 0 ) - { - gp_Pnt2d aLCS = GetLocalCS(); - HYDROData_Document* aThat = const_cast( this ); - aThat->myLX = aLCS.X(); - aThat->myLY = aLCS.Y(); - } + UpdateLCSFields(); if( IsToLocalCS ) { X -= myLX; diff --git a/src/HYDROData/HYDROData_Document.h b/src/HYDROData/HYDROData_Document.h index 43eba79a..7efc1d63 100644 --- a/src/HYDROData/HYDROData_Document.h +++ b/src/HYDROData/HYDROData_Document.h @@ -127,8 +127,8 @@ public: //! Removes the order of objects presentation. HYDRODATA_EXPORT void RemoveObjectsLayerOrder(); - HYDRODATA_EXPORT gp_Pnt2d GetLocalCS() const; - HYDRODATA_EXPORT void SetLocalCS( const gp_Pnt2d& ); + HYDRODATA_EXPORT void GetLocalCS( double&, double& ) const; + HYDRODATA_EXPORT void SetLocalCS( double, double ); HYDRODATA_EXPORT void Transform( double& X, double& Y, bool IsToLocalCS ) const; HYDRODATA_EXPORT void Transform( gp_Pnt& thePnt, bool IsToLocalCS ) const; HYDRODATA_EXPORT void Transform( gp_XYZ& thePnt, bool IsToLocalCS ) const; @@ -217,6 +217,7 @@ private: const bool theIsMultiFile, MapOfTreatedObjects& theDumpedObjects, const ObjectKind& theObjectKind ) const; + void UpdateLCSFields() const; private: Handle(TDocStd_Document) myDoc; ///< OCAF document instance corresponding for keeping all persistent data diff --git a/src/HYDROData/HYDROData_DummyObject3D.h b/src/HYDROData/HYDROData_DummyObject3D.h index e1222fa6..dcc0795b 100644 --- a/src/HYDROData/HYDROData_DummyObject3D.h +++ b/src/HYDROData/HYDROData_DummyObject3D.h @@ -71,7 +71,6 @@ public: */ HYDRODATA_EXPORT virtual QColor GetBorderColor() const; - protected: friend class HYDROData_Iterator; diff --git a/src/HYDROData/HYDROData_Entity.cxx b/src/HYDROData/HYDROData_Entity.cxx index 4c1ed735..fc5fe6c2 100644 --- a/src/HYDROData/HYDROData_Entity.cxx +++ b/src/HYDROData/HYDROData_Entity.cxx @@ -65,6 +65,11 @@ void HYDROData_Entity::Update() SetToUpdate( false ); } +void HYDROData_Entity::UpdateLocalCS( double theDx, double theDy ) +{ + //On the base level no actions are necessary +} + bool HYDROData_Entity::IsHas2dPrs() const { return false; diff --git a/src/HYDROData/HYDROData_Entity.h b/src/HYDROData/HYDROData_Entity.h index b46a6e43..d639c4a7 100644 --- a/src/HYDROData/HYDROData_Entity.h +++ b/src/HYDROData/HYDROData_Entity.h @@ -114,6 +114,7 @@ public: */ HYDRODATA_EXPORT virtual void Update(); + HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy ); /** * Checks that object has 2D presentation. Base implementation returns false. diff --git a/src/HYDROData/HYDROData_Obstacle.cxx b/src/HYDROData/HYDROData_Obstacle.cxx index 4dfae867..b7c8eb54 100644 --- a/src/HYDROData/HYDROData_Obstacle.cxx +++ b/src/HYDROData/HYDROData_Obstacle.cxx @@ -482,3 +482,8 @@ bool HYDROData_Obstacle::getTranslation( double& theDx, double& theDy, double& t return true; } +void HYDROData_Obstacle::UpdateLocalCS( double theDx, double theDy ) +{ + Translate( theDx, theDy, 0 ); +} + diff --git a/src/HYDROData/HYDROData_Obstacle.h b/src/HYDROData/HYDROData_Obstacle.h index a0ba13ad..3641ba9d 100644 --- a/src/HYDROData/HYDROData_Obstacle.h +++ b/src/HYDROData/HYDROData_Obstacle.h @@ -43,6 +43,8 @@ public: */ HYDRODATA_EXPORT virtual void Update(); + HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy ); + /** * Checks that object has 2D presentation. Reimlemented to retun true. */ diff --git a/src/HYDROData/HYDROData_PolylineXY.cxx b/src/HYDROData/HYDROData_PolylineXY.cxx index be2495cd..72423bb3 100755 --- a/src/HYDROData/HYDROData_PolylineXY.cxx +++ b/src/HYDROData/HYDROData_PolylineXY.cxx @@ -1102,4 +1102,26 @@ QPainterPath HYDROData_PolylineXY::GetPainterPath() const return aPath; } +void HYDROData_PolylineXY::UpdateLocalCS( double theDx, double theDy ) +{ + NCollection_Sequence aSectNames; + NCollection_Sequence aSectTypes; + NCollection_Sequence aSectClosures; + GetSections( aSectNames, aSectTypes, aSectClosures ); + + gp_XY aDelta( theDx, theDy ); + for ( int i = 0, aNbSects = aSectNames.Size(); i < aNbSects; i++ ) + { + PointsList aPoints = GetPoints( i ); + for( int j = 1, n = aPoints.Size(); j <= n; ++j ) + { + Point& aPoint = aPoints.ChangeValue( j ); + aPoint += aDelta; + } + SetPoints( i, aPoints ); + } + SetToUpdate( true ); +} + + diff --git a/src/HYDROData/HYDROData_PolylineXY.h b/src/HYDROData/HYDROData_PolylineXY.h index 86ae8e54..1643aeab 100644 --- a/src/HYDROData/HYDROData_PolylineXY.h +++ b/src/HYDROData/HYDROData_PolylineXY.h @@ -46,6 +46,8 @@ public: */ HYDRODATA_EXPORT virtual void Update(); + HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy ); + /** * Checks that object has 2D presentation. Reimlemented to retun true. */ diff --git a/src/HYDROData/HYDROData_Profile.cxx b/src/HYDROData/HYDROData_Profile.cxx index 0d4b5f45..494461f2 100755 --- a/src/HYDROData/HYDROData_Profile.cxx +++ b/src/HYDROData/HYDROData_Profile.cxx @@ -628,5 +628,18 @@ bool HYDROData_Profile::ImportFromFile( OSD_File& theFile, return aRes; } +void HYDROData_Profile::UpdateLocalCS( double theDx, double theDy ) +{ + gp_XY aDelta( theDx, theDy ); + gp_XY aPnt; + + GetLeftPoint( aPnt, false ); + aPnt += aDelta; + SetLeftPoint( aPnt, false ); + + GetRightPoint( aPnt, false ); + aPnt += aDelta; + SetRightPoint( aPnt, false ); +} diff --git a/src/HYDROData/HYDROData_Profile.h b/src/HYDROData/HYDROData_Profile.h index ae708f75..45b916a8 100644 --- a/src/HYDROData/HYDROData_Profile.h +++ b/src/HYDROData/HYDROData_Profile.h @@ -65,6 +65,8 @@ public: */ HYDRODATA_EXPORT virtual void Update(); + HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy ); + /** * Returns default filling color for new profile. */ diff --git a/src/HYDROData/HYDROData_River.cxx b/src/HYDROData/HYDROData_River.cxx index 012167d2..b5958347 100644 --- a/src/HYDROData/HYDROData_River.cxx +++ b/src/HYDROData/HYDROData_River.cxx @@ -57,5 +57,10 @@ TopoDS_Shape HYDROData_River::GetShape3D() const return getShape3D(); } +void HYDROData_River::UpdateLocalCS( double theDx, double theDy ) +{ + //TODO +} + diff --git a/src/HYDROData/HYDROData_River.h b/src/HYDROData/HYDROData_River.h index 9503d5b0..5ac5f963 100644 --- a/src/HYDROData/HYDROData_River.h +++ b/src/HYDROData/HYDROData_River.h @@ -40,6 +40,8 @@ public: */ HYDRODATA_EXPORT virtual void Update(); + HYDRODATA_EXPORT virtual void UpdateLocalCS( double theDx, double theDy ); + /** * Checks that object has 2D presentation. Reimlemented to retun true. */ diff --git a/src/HYDROData/HYDROData_Zone.h b/src/HYDROData/HYDROData_Zone.h index f1e3ba96..2bdcac74 100644 --- a/src/HYDROData/HYDROData_Zone.h +++ b/src/HYDROData/HYDROData_Zone.h @@ -149,7 +149,6 @@ public: */ HYDRODATA_EXPORT virtual void RemoveGeometryObjects(); - protected: friend class HYDROData_Region; diff --git a/src/HYDROGUI/HYDROGUI_DataObject.cxx b/src/HYDROGUI/HYDROGUI_DataObject.cxx index cde78b0d..9701970a 100644 --- a/src/HYDROGUI/HYDROGUI_DataObject.cxx +++ b/src/HYDROGUI/HYDROGUI_DataObject.cxx @@ -231,6 +231,7 @@ void HYDROGUI_DataObject::updateBy( SUIT_DataObject* theObj ) myIsValid = aDataObj->myIsValid; myIsInOperation = aDataObj->myIsInOperation; myIcon = aDataObj->myIcon; + setModified( true ); } @@ -296,6 +297,7 @@ void HYDROGUI_NamedObject::updateBy( SUIT_DataObject* theObj ) myParentEntry = aNamedObj->myParentEntry; myIcon = aNamedObj->myIcon; myIsInOperation = aNamedObj->myIsInOperation; + setModified( true ); } diff --git a/src/HYDROGUI/HYDROGUI_Tool.cxx b/src/HYDROGUI/HYDROGUI_Tool.cxx index 5c45c8ba..5252cb2f 100644 --- a/src/HYDROGUI/HYDROGUI_Tool.cxx +++ b/src/HYDROGUI/HYDROGUI_Tool.cxx @@ -709,5 +709,8 @@ QStringList HYDROGUI_Tool::FindExistingObjectsNames( const Handle(HYDROData_Docu QString HYDROGUI_Tool::GetCoordinateString( const double theNumber ) { - return QString::number( theNumber, 'f', 2 ); -} \ No newline at end of file + //return QString::number( theNumber, 'f', 2 ); + static QLocale aLocale( QLocale::English, QLocale::France ); + return aLocale.toString( theNumber, 'f', 2 ); +} + diff --git a/src/HYDROPy/HYDROData_Document.sip b/src/HYDROPy/HYDROData_Document.sip index 56c7e5fd..c2a71f94 100644 --- a/src/HYDROPy/HYDROData_Document.sip +++ b/src/HYDROPy/HYDROData_Document.sip @@ -298,6 +298,8 @@ public: HYDROData_SequenceOfObjects FindObjectsByNames( const QStringList& theNames, const ObjectKind theKind = KIND_UNKNOWN ); + void SetLocalCS( double, double ); + protected: //! Creates new document: private because "Document" method must be used instead of direct creation. -- 2.39.2