From: Paul RASCLE Date: Wed, 20 Aug 2014 17:58:47 +0000 (+0000) Subject: merge trunk on BR_quadtree 20140820 X-Git-Tag: BR_quadtree_20140917 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Ftags%2FBR_quadtree_20140917;p=modules%2Fhydro.git merge trunk on BR_quadtree 20140820 --- diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx index 4624bb8a..202ffe33 100644 --- a/src/HYDROData/HYDROData_Bathymetry.cxx +++ b/src/HYDROData/HYDROData_Bathymetry.cxx @@ -468,9 +468,19 @@ bool HYDROData_Bathymetry::ImportFromFile( const TCollection_AsciiString& theFil // Try to import the file if ( aFileSuf == "xyz" ) aRes = importFromXYZFile( aFile, aPoints ); - + // Close the file aFile.close(); + + + // Convert from global to local CS + Handle_HYDROData_Document aDoc = HYDROData_Document::Document( myLab ); + AltitudePoints::Iterator anIter( aPoints ); + for ( ; anIter.More(); anIter.Next() ) + { + AltitudePoint& aPoint = anIter.ChangeValue(); + aDoc->Transform( aPoint, true ); + } if ( aRes ) { @@ -546,14 +556,14 @@ bool HYDROData_Bathymetry::importFromXYZFile( QFile& theFile, } -bool HYDROData_Bathymetry::CreateBoundaryPolyline() const +Handle_HYDROData_PolylineXY HYDROData_Bathymetry::CreateBoundaryPolyline() const { Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); Handle_HYDROData_PolylineXY aResult = Handle_HYDROData_PolylineXY::DownCast( aDocument->CreateObject( KIND_POLYLINEXY ) ); if( aResult.IsNull() ) - return false; + return aResult; //search free name QString aPolylinePref = GetName() + "_Boundary"; @@ -588,5 +598,19 @@ bool HYDROData_Bathymetry::CreateBoundaryPolyline() const aResult->AddPoint( 0, HYDROData_IPolyline::Point( Xmax, Ymin ) ); aResult->Update(); - return true; + 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 95af7420..622fc82e 100644 --- a/src/HYDROData/HYDROData_Bathymetry.h +++ b/src/HYDROData/HYDROData_Bathymetry.h @@ -7,6 +7,7 @@ class QFile; class gp_XYZ; +class Handle_HYDROData_PolylineXY; DEFINE_STANDARD_HANDLE(HYDROData_Bathymetry, HYDROData_IAltitudeObject) @@ -114,7 +115,9 @@ public: */ HYDRODATA_EXPORT virtual bool ImportFromFile( const TCollection_AsciiString& theFileName ); - HYDRODATA_EXPORT bool CreateBoundaryPolyline() const; + 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 eea22c6d..86d16b08 100644 --- a/src/HYDROData/HYDROData_Document.cxx +++ b/src/HYDROData/HYDROData_Document.cxx @@ -5,9 +5,12 @@ #include #include +#include #include +#include + #include #include #include @@ -23,6 +26,8 @@ static const int TAG_PROPS = 1; // general properties tag static const int TAG_PROPS_NEW_ID = 1; // general properties: tag for storage of the new object ID static const int TAG_OBJECTS = 2; // tag of the objects sub-tree static const int TAG_HISTORY = 3; // tag of the history sub-tree (Root for History) +static const int TAG_LOCAL_CS = 4; // tag of local coordinate system information +static const gp_Pnt2d DEFAULT_LOCAL_CS( 0, 0 ); using namespace std; @@ -197,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 ); @@ -632,12 +642,16 @@ HYDROData_Document::HYDROData_Document() myDoc->SetUndoLimit(UNDO_LIMIT); NewID(); // needed to have at least one attribute in initial document to avoid errors myTransactionsAfterSave = 0; + myLX = -1; + myLY = -1; } HYDROData_Document::HYDROData_Document(const Handle(TDocStd_Document)& theDoc) { myDoc = theDoc; myTransactionsAfterSave = 0; + myLX = -1; + myLY = -1; } HYDROData_Document::~HYDROData_Document() @@ -661,3 +675,106 @@ TDF_Label HYDROData_Document::LabelOfObjects() { return myDoc->Main().FindChild(TAG_OBJECTS); } + +TDF_Label HYDROData_Document::LabelOfLocalCS() const +{ + return myDoc->Main().FindChild(TAG_LOCAL_CS); +} + +void HYDROData_Document::GetLocalCS( double& theLX, double& theLY ) const +{ + TDF_Label aLocalCSLab = LabelOfLocalCS(); + + Handle( TDataXtd_Position ) aLocalCS; + if( aLocalCSLab.FindAttribute( TDataXtd_Position::GetID(), aLocalCS ) ) + { + gp_Pnt aLocalCS3d = aLocalCS->GetPosition(); + theLX = aLocalCS3d.X(); + theLY = aLocalCS3d.Y(); + } + else + { + theLX = DEFAULT_LOCAL_CS.X(); + theLY = DEFAULT_LOCAL_CS.Y(); + } +} + +void HYDROData_Document::SetLocalCS( double theLX, double theLY ) +{ + 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( theLX, theLY, 0 ); + aLocalCS->SetPosition( aLocalCS3d ); + + // 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 +{ + UpdateLCSFields(); + if( IsToLocalCS ) + { + X -= myLX; + Y -= myLY; + } + else + { + X += myLX; + Y += myLY; + } +} + +void HYDROData_Document::Transform( gp_Pnt& thePnt, bool IsToLocalCS ) const +{ + double X = thePnt.X(); + double Y = thePnt.Y(); + double Z = thePnt.Z(); + Transform( X, Y, IsToLocalCS ); + thePnt = gp_Pnt( X, Y, Z ); +} + +void HYDROData_Document::Transform( gp_XYZ& thePnt, bool IsToLocalCS ) const +{ + double X = thePnt.X(); + double Y = thePnt.Y(); + double Z = thePnt.Z(); + Transform( X, Y, IsToLocalCS ); + thePnt = gp_XYZ( X, Y, Z ); +} + +void HYDROData_Document::Transform( gp_XY& thePnt, bool IsToLocalCS ) const +{ + double X = thePnt.X(); + double Y = thePnt.Y(); + Transform( X, Y, IsToLocalCS ); + thePnt = gp_XY( X, Y ); +} diff --git a/src/HYDROData/HYDROData_Document.h b/src/HYDROData/HYDROData_Document.h index ffdaf981..7efc1d63 100644 --- a/src/HYDROData/HYDROData_Document.h +++ b/src/HYDROData/HYDROData_Document.h @@ -7,6 +7,10 @@ #include class QFile; +class gp_Pnt2d; +class gp_Pnt; +class gp_XYZ; +class gp_XY; /** * Errors that could appear on document open/save actions. @@ -123,6 +127,12 @@ public: //! Removes the order of objects presentation. HYDRODATA_EXPORT void RemoveObjectsLayerOrder(); + 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; + HYDRODATA_EXPORT void Transform( gp_XY& thePnt, bool IsToLocalCS ) const; public: @@ -194,6 +204,8 @@ protected: //! Returns the label where the objects are located (used by Iterator) HYDRODATA_EXPORT TDF_Label LabelOfObjects(); + HYDRODATA_EXPORT TDF_Label LabelOfLocalCS() const; + private: // Dump header Python part in to file \c theFile @@ -205,10 +217,12 @@ 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 int myTransactionsAfterSave; ///< number of transactions after the last "save" call, used for "IsModified" method + double myLX, myLY; }; #endif 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 76dfad84..494461f2 100755 --- a/src/HYDROData/HYDROData_Profile.cxx +++ b/src/HYDROData/HYDROData_Profile.cxx @@ -60,7 +60,7 @@ QStringList HYDROData_Profile::DumpToPython( MapOfTreatedObjects& theTreatedObje QString aGap = QString().fill( ' ', aPntsListName.length() + 5 ); if ( anIsValidProfile ) { - HYDROData_Profile::ProfilePoints aPointsList = GetProfilePoints(); + HYDROData_Profile::ProfilePoints aPointsList = GetProfilePoints( true ); for ( int k = 1, aNbPoints = aPointsList.Size(); k <= aNbPoints; ++k ) { const ProfilePoint& aPoint = aPointsList.Value( k ); @@ -122,7 +122,7 @@ TopoDS_Shape HYDROData_Profile::GetTopShape() const TopoDS_Wire aWire; gp_XY aFirstPoint, aLastPoint; - if ( !GetLeftPoint( aFirstPoint ) || !GetRightPoint( aLastPoint ) ) + if ( !GetLeftPoint( aFirstPoint, false ) || !GetRightPoint( aLastPoint, false ) ) return aWire; gp_Pnt aPnt1( aFirstPoint.X(), aFirstPoint.Y(), 0 ); @@ -150,7 +150,7 @@ void HYDROData_Profile::Update() Handle(HYDROData_ProfileUZ) aProfile = GetProfileUZ( false ); if ( !aProfile.IsNull() ) { - ProfilePoints aProfilePoints = GetProfilePoints(); + ProfilePoints aProfilePoints = GetProfilePoints( false ); HYDROData_IPolyline::SectionType aSectionType = aProfile->GetSectionType( 0 ); aWire = HYDROData_PolylineXY::BuildWire( aSectionType, false, aProfilePoints ); @@ -181,33 +181,41 @@ QColor HYDROData_Profile::getDefaultBorderColor() const bool HYDROData_Profile::IsValid() const { gp_XY aFirstPoint, aLastPoint; - if ( !GetLeftPoint( aFirstPoint ) || !GetRightPoint( aLastPoint ) ) + if ( !GetLeftPoint( aFirstPoint, false ) || !GetRightPoint( aLastPoint, false ) ) return false; int aNbPoints = NbPoints(); return aNbPoints > 1; } -void HYDROData_Profile::SetLeftPoint( const gp_XY& thePoint ) +void HYDROData_Profile::SetLeftPoint( const gp_XY& theGPoint, bool IsConvertFromGlobal ) { TDF_Label aLabel = myLab.FindChild( DataTag_FirstPoint ); + if ( aLabel.IsNull() ) + return; + + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( Label() ); + gp_XY aLPoint = theGPoint; + if( IsConvertFromGlobal ) + aDoc->Transform( aLPoint, true ); Handle(TDataStd_RealArray) anArray; if ( !aLabel.FindAttribute( TDataStd_RealArray::GetID(), anArray ) ) anArray = TDataStd_RealArray::Set( aLabel, 0, 1 ); - anArray->SetValue( 0, thePoint.X() ); - anArray->SetValue( 1, thePoint.Y() ); + anArray->SetValue( 0, aLPoint.X() ); + anArray->SetValue( 1, aLPoint.Y() ); SetToUpdate( true ); } -bool HYDROData_Profile::GetLeftPoint( gp_XY& thePoint ) const +bool HYDROData_Profile::GetLeftPoint( gp_XY& thePoint, bool IsConvertToGlobal ) const { TDF_Label aLabel = myLab.FindChild( DataTag_FirstPoint, false ); if ( aLabel.IsNull() ) return false; + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( myLab ); Handle(TDataStd_RealArray) anArray; if ( !aLabel.FindAttribute( TDataStd_RealArray::GetID(), anArray ) ) return false; @@ -215,29 +223,38 @@ bool HYDROData_Profile::GetLeftPoint( gp_XY& thePoint ) const thePoint.SetX( anArray->Value( 0 ) ); thePoint.SetY( anArray->Value( 1 ) ); + if( IsConvertToGlobal ) + aDoc->Transform( thePoint, false ); + return true; } -void HYDROData_Profile::SetRightPoint( const gp_XY& thePoint ) +void HYDROData_Profile::SetRightPoint( const gp_XY& theGPoint, bool IsConvertFromGlobal ) { TDF_Label aLabel = myLab.FindChild( DataTag_LastPoint ); + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( Label() ); + gp_XY aLPoint = theGPoint; + if( IsConvertFromGlobal ) + aDoc->Transform( aLPoint, true ); + Handle(TDataStd_RealArray) anArray; if ( !aLabel.FindAttribute( TDataStd_RealArray::GetID(), anArray ) ) anArray = TDataStd_RealArray::Set( aLabel, 0, 1 ); - anArray->SetValue( 0, thePoint.X() ); - anArray->SetValue( 1, thePoint.Y() ); + anArray->SetValue( 0, aLPoint.X() ); + anArray->SetValue( 1, aLPoint.Y() ); SetToUpdate( true ); } -bool HYDROData_Profile::GetRightPoint( gp_XY& thePoint ) const +bool HYDROData_Profile::GetRightPoint( gp_XY& thePoint, bool IsConvertToGlobal ) const { TDF_Label aLabel = myLab.FindChild( DataTag_LastPoint, false ); if ( aLabel.IsNull() ) return false; + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( myLab ); Handle(TDataStd_RealArray) anArray; if ( !aLabel.FindAttribute( TDataStd_RealArray::GetID(), anArray ) ) return false; @@ -245,6 +262,9 @@ bool HYDROData_Profile::GetRightPoint( gp_XY& thePoint ) const thePoint.SetX( anArray->Value( 0 ) ); thePoint.SetY( anArray->Value( 1 ) ); + if( IsConvertToGlobal ) + aDoc->Transform( thePoint, false ); + return true; } @@ -315,7 +335,7 @@ HYDROData_ProfileUZ::PointsList HYDROData_Profile::GetParametricPoints() const return aProfileUZ.IsNull() ? HYDROData_ProfileUZ::PointsList() : aProfileUZ->GetPoints(); } -void HYDROData_Profile::SetProfilePoints( const ProfilePoints& thePoints ) +void HYDROData_Profile::SetProfilePoints( const ProfilePoints& thePoints, bool IsConvertFromGlobal ) { RemovePoints(); if ( thePoints.Length() < 2 ) @@ -323,10 +343,14 @@ void HYDROData_Profile::SetProfilePoints( const ProfilePoints& thePoints ) gp_XY aFirstPoint, aLastPoint; + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( Label() ); Handle(HYDROData_ProfileUZ) aProfileUZ = GetProfileUZ(); for ( int i = 1, n = thePoints.Length(); i <= n ; ++i ) { - const ProfilePoint& aPoint = thePoints.Value( i ); + ProfilePoint aPoint = thePoints.Value( i ); + if( IsConvertFromGlobal ) + aDoc->Transform( aPoint, true ); + gp_XY aPointXY( aPoint.X(), aPoint.Y() ); if ( i == 1 ) @@ -340,16 +364,17 @@ void HYDROData_Profile::SetProfilePoints( const ProfilePoints& thePoints ) aProfileUZ->AddPoint( 0, aParPoint ); } - SetLeftPoint( aFirstPoint ); - SetRightPoint( aLastPoint ); + SetLeftPoint( aFirstPoint, false );//already converted to local CS + SetRightPoint( aLastPoint, false ); } -HYDROData_Profile::ProfilePoints HYDROData_Profile::GetProfilePoints() const +HYDROData_Profile::ProfilePoints HYDROData_Profile::GetProfilePoints( bool IsConvertToGlobal ) const { ProfilePoints aResPoints; gp_XY aFirstPoint, aLastPoint; - if ( !GetLeftPoint( aFirstPoint ) || !GetRightPoint( aLastPoint ) ) + if ( !GetLeftPoint( aFirstPoint, IsConvertToGlobal ) || + !GetRightPoint( aLastPoint, IsConvertToGlobal ) ) return aResPoints; HYDROData_ProfileUZ::PointsList aParametricPoints = GetParametricPoints(); @@ -594,7 +619,7 @@ bool HYDROData_Profile::ImportFromFile( OSD_File& theFile, } else if ( anIsGeoref ) { - SetProfilePoints( aPointsXYZ ); + SetProfilePoints( aPointsXYZ, true ); } Update(); @@ -603,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 3c56846f..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. */ @@ -99,27 +101,27 @@ public: * Set first(left) point for profile. * \param thePoint the point */ - HYDRODATA_EXPORT void SetLeftPoint( const gp_XY& thePoint ); + HYDRODATA_EXPORT void SetLeftPoint( const gp_XY& thePoint, bool IsConvertFromGlobal = false ); /** * Returns first(left) point of profile. * \param thePoint[out] profile first point * \return true if point has been set */ - HYDRODATA_EXPORT bool GetLeftPoint( gp_XY& thePoint ) const; + HYDRODATA_EXPORT bool GetLeftPoint( gp_XY& thePoint, bool IsConvertToGlobal = false ) const; /** * Set last(right) point for profile. * \param thePoint the point */ - HYDRODATA_EXPORT void SetRightPoint( const gp_XY& thePoint ); + HYDRODATA_EXPORT void SetRightPoint( const gp_XY& thePoint, bool IsConvertFromGlobal = false ); /** * Returns last(right) point of profile. * \param thePoint[out] profile last point * \return true if point has been set */ - HYDRODATA_EXPORT bool GetRightPoint( gp_XY& thePoint ) const; + HYDRODATA_EXPORT bool GetRightPoint( gp_XY& thePoint, bool IsConvertToGlobal = false ) const; /** @@ -159,15 +161,14 @@ public: * First and last points will be automatically updated. * \param thePoints the list with new profile points */ - HYDRODATA_EXPORT void SetProfilePoints( const ProfilePoints& thePoints ); + HYDRODATA_EXPORT void SetProfilePoints( const ProfilePoints& thePoints, bool IsConvertFromGlobal = true ); /** * Returns profile points. * Empty sequence is returned if first or last point was not set. * \return profile points list */ - HYDRODATA_EXPORT ProfilePoints GetProfilePoints() const; - + HYDRODATA_EXPORT ProfilePoints GetProfilePoints( bool IsConvertToGlobal = false ) const; public: // Public methods to work with files. 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_Stream.cxx b/src/HYDROData/HYDROData_Stream.cxx index 128239ea..b4d48d61 100644 --- a/src/HYDROData/HYDROData_Stream.cxx +++ b/src/HYDROData/HYDROData_Stream.cxx @@ -152,8 +152,8 @@ bool HYDROData_Stream::IsHas2dPrs() const } bool HYDROData_Stream::CreatePresentations( const Handle(HYDROData_PolylineXY)& theHydAxis, - const HYDROData_SequenceOfObjects& theProfiles, - PrsDefinition& thePrs ) + const HYDROData_SequenceOfObjects& theProfiles, + PrsDefinition& thePrs ) { if ( theHydAxis.IsNull() || theProfiles.Length() < 2 ) return false; @@ -175,7 +175,7 @@ bool HYDROData_Stream::CreatePresentations( const Handle(HYDROData_PolylineXY)& const TopoDS_Shape& aProf3d = aProfile->GetShape3D(); gp_XY aPnt1, aPnt2; - if ( !aProfile->GetLeftPoint( aPnt1 ) || !aProfile->GetRightPoint( aPnt2 ) ) + if ( !aProfile->GetLeftPoint( aPnt1, false ) || !aProfile->GetRightPoint( aPnt2, false ) ) continue; anArrOfProfiles.SetValue(i,aProfile->GetShape3D());//aProfile->GetTopShape(); diff --git a/src/HYDROData/HYDROData_StreamAltitude.cxx b/src/HYDROData/HYDROData_StreamAltitude.cxx index 11cd35e4..8c1f9f69 100644 --- a/src/HYDROData/HYDROData_StreamAltitude.cxx +++ b/src/HYDROData/HYDROData_StreamAltitude.cxx @@ -56,8 +56,8 @@ Standard_Real getAltitudeFromProfile( const Handle(HYDROData_Profile)& theProfil Standard_Real aResAlt = 0.0; gp_XY aFirstPoint, aLastPoint; - if ( !theProfile->GetLeftPoint( aFirstPoint ) || - !theProfile->GetRightPoint( aLastPoint ) ) + if ( !theProfile->GetLeftPoint( aFirstPoint, false ) || + !theProfile->GetRightPoint( aLastPoint, false ) ) return aResAlt; gp_Pnt aPnt1( aFirstPoint.X(), aFirstPoint.Y(), 0 ); @@ -73,7 +73,7 @@ Standard_Real getAltitudeFromProfile( const Handle(HYDROData_Profile)& theProfil gp_Pnt aPrevPoint; gp_Lin aPrevNormal; - HYDROData_Profile::ProfilePoints aProfilePoints = theProfile->GetProfilePoints(); + HYDROData_Profile::ProfilePoints aProfilePoints = theProfile->GetProfilePoints( false ); for ( int i = 1, n = aProfilePoints.Length(); i <= n; ++i ) { gp_Pnt aProfPoint( aProfilePoints.Value( i ) ); @@ -143,7 +143,8 @@ bool HYDROData_StreamAltitude::getBoundaryProfilesForPoint( continue; gp_XY aFirstPoint, aLastPoint; - if ( !aProfile->GetLeftPoint( aFirstPoint ) || !aProfile->GetRightPoint( aLastPoint ) ) + if ( !aProfile->GetLeftPoint( aFirstPoint, false ) || + !aProfile->GetRightPoint( aLastPoint, false ) ) continue; gp_Pnt aPnt1( aFirstPoint.X(), aFirstPoint.Y(), 0 ); @@ -258,7 +259,7 @@ double HYDROData_StreamAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) co // Interpolate altitudes // Left profile line ( the segment between the firts and the last profile point ) - HYDROData_Profile::ProfilePoints aLeftProfilePoints = aLeftProfile->GetProfilePoints(); + HYDROData_Profile::ProfilePoints aLeftProfilePoints = aLeftProfile->GetProfilePoints( false ); gp_Pnt aLeftProfileP1( aLeftProfilePoints.First() ); aLeftProfileP1.SetZ( 0 ); gp_Pnt aLeftProfileP2( aLeftProfilePoints.Last() ); @@ -266,7 +267,7 @@ double HYDROData_StreamAltitude::GetAltitudeForPoint( const gp_XY& thePoint ) co 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(); + HYDROData_Profile::ProfilePoints aRightProfilePoints = aRightProfile->GetProfilePoints( false ); gp_Pnt aRightProfileP1( aRightProfilePoints.First() ); aRightProfileP1.SetZ( 0 ); gp_Pnt aRightProfileP2( aRightProfilePoints.Last() ); 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/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 79549b29..26bb74a6 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -14,6 +14,7 @@ set(PROJECT_HEADERS HYDROGUI_CopyPastePositionOp.h HYDROGUI_DataBrowser.h HYDROGUI_DataModel.h + HYDROGUI_DataModelSync.h HYDROGUI_DataObject.h HYDROGUI_DeleteDlg.h HYDROGUI_DeleteOp.h @@ -29,6 +30,8 @@ set(PROJECT_HEADERS HYDROGUI_ImportImageDlg.h HYDROGUI_ImportImageOp.h HYDROGUI_InputPanel.h + HYDROGUI_LocalCSDlg.h + HYDROGUI_LocalCSOp.h HYDROGUI_Module.h HYDROGUI_NameValidator.h HYDROGUI_ObjSelector.h @@ -108,6 +111,7 @@ set(PROJECT_SOURCES HYDROGUI_CopyPastePositionOp.cxx HYDROGUI_DataBrowser.cxx HYDROGUI_DataModel.cxx + HYDROGUI_DataModelSync.cxx HYDROGUI_DataObject.cxx HYDROGUI_DeleteDlg.cxx HYDROGUI_DeleteOp.cxx @@ -123,6 +127,8 @@ set(PROJECT_SOURCES HYDROGUI_ImportImageDlg.cxx HYDROGUI_ImportImageOp.cxx HYDROGUI_InputPanel.cxx + HYDROGUI_LocalCSDlg.cxx + HYDROGUI_LocalCSOp.cxx HYDROGUI_Module.cxx HYDROGUI_NameValidator.cxx HYDROGUI_ObjSelector.cxx diff --git a/src/HYDROGUI/HYDROGUI_BathymetryBoundsOp.cxx b/src/HYDROGUI/HYDROGUI_BathymetryBoundsOp.cxx index cf042190..1dd589b7 100644 --- a/src/HYDROGUI/HYDROGUI_BathymetryBoundsOp.cxx +++ b/src/HYDROGUI/HYDROGUI_BathymetryBoundsOp.cxx @@ -24,6 +24,8 @@ #include #include #include +#include +#include HYDROGUI_BathymetryBoundsOp::HYDROGUI_BathymetryBoundsOp( HYDROGUI_Module* theModule ) : HYDROGUI_Operation( theModule ) @@ -50,13 +52,18 @@ void HYDROGUI_BathymetryBoundsOp::startOperation() onApply(); } -bool HYDROGUI_BathymetryBoundsOp::processApply( int& theUpdateFlags, QString& theErrorMsg ) +bool HYDROGUI_BathymetryBoundsOp::processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) { - bool isOK = myBath->CreateBoundaryPolyline(); + Handle_HYDROData_PolylineXY aPolyline = myBath->CreateBoundaryPolyline(); + bool isOK = !aPolyline.IsNull(); theUpdateFlags = 0; if( isOK ) { module()->setIsToUpdate( myBath ); theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer; + + QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aPolyline ); + theBrowseObjectsEntries.append( anEntry ); } else theErrorMsg = tr( "CANNOT_CREATE_BOUNDARY_POLYLINE" ); diff --git a/src/HYDROGUI/HYDROGUI_BathymetryBoundsOp.h b/src/HYDROGUI/HYDROGUI_BathymetryBoundsOp.h index 00b92d56..7586c17d 100644 --- a/src/HYDROGUI/HYDROGUI_BathymetryBoundsOp.h +++ b/src/HYDROGUI/HYDROGUI_BathymetryBoundsOp.h @@ -37,7 +37,8 @@ public: protected: virtual void startOperation(); virtual HYDROGUI_InputPanel* createInputPanel() const; - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); private: Handle(HYDROData_Bathymetry) myBath; diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx index 71f47ea7..954e789f 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.cxx @@ -498,13 +498,20 @@ bool HYDROGUI_CalculationOp::confirmRegionsChange() const } bool HYDROGUI_CalculationOp::processApply( int& theUpdateFlags, - QString& theErrorMsg ) + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) { HYDROGUI_CalculationDlg* aPanel = ::qobject_cast( inputPanel() ); if ( !aPanel ) return false; + if( !myIsEdit ) + { + QString anEntry = HYDROGUI_DataObject::dataObjectEntry( myEditedObject ); + theBrowseObjectsEntries.append( anEntry ); + } + theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init; return true; @@ -516,12 +523,13 @@ void HYDROGUI_CalculationOp::onApply() int anUpdateFlags = 0; QString anErrorMsg; + QStringList aBrowseObjectsEntries; bool aResult = false; try { - aResult = processApply( anUpdateFlags, anErrorMsg ); + aResult = processApply( anUpdateFlags, anErrorMsg, aBrowseObjectsEntries ); } catch ( Standard_Failure ) { @@ -540,6 +548,7 @@ void HYDROGUI_CalculationOp::onApply() { module()->update( anUpdateFlags ); commit(); + browseObjects( aBrowseObjectsEntries ); } else { diff --git a/src/HYDROGUI/HYDROGUI_CalculationOp.h b/src/HYDROGUI/HYDROGUI_CalculationOp.h index 829c01bb..81c19c61 100644 --- a/src/HYDROGUI/HYDROGUI_CalculationOp.h +++ b/src/HYDROGUI/HYDROGUI_CalculationOp.h @@ -52,7 +52,8 @@ protected: virtual HYDROGUI_InputPanel* createInputPanel() const; virtual void onApply(); - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); void setAvailableGroups(); diff --git a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx index 0a622785..e820deb6 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx @@ -23,6 +23,7 @@ #include "HYDROGUI_ChannelOp.h" #include "HYDROGUI_DataModel.h" +#include #include "HYDROGUI_ChannelDlg.h" #include "HYDROGUI_Module.h" #include "HYDROGUI_Shape.h" @@ -143,7 +144,8 @@ HYDROGUI_InputPanel* HYDROGUI_ChannelOp::createInputPanel() const } bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags, - QString& theErrorMsg ) + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) { HYDROGUI_ChannelDlg* aPanel = ::qobject_cast( inputPanel() ); if ( !aPanel ) @@ -203,7 +205,11 @@ bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags, erasePreview(); if( !myIsEdit ) + { module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), myEditedObject, true ); + QString anEntry = HYDROGUI_DataObject::dataObjectEntry( myEditedObject ); + theBrowseObjectsEntries.append( anEntry ); + } module()->setIsToUpdate( myEditedObject ); diff --git a/src/HYDROGUI/HYDROGUI_ChannelOp.h b/src/HYDROGUI/HYDROGUI_ChannelOp.h index 798d7a89..bb1c5acb 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelOp.h +++ b/src/HYDROGUI/HYDROGUI_ChannelOp.h @@ -46,7 +46,8 @@ protected: virtual HYDROGUI_InputPanel* createInputPanel() const; - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); protected slots: virtual void onCreatePreview(); diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 654451d8..6f1adada 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -47,8 +48,6 @@ #include #include -#include -#include #include #include @@ -56,11 +55,11 @@ #include #include -#include #include #include #include #include +#include #include @@ -77,6 +76,9 @@ static HYDROData_SequenceOfObjects myCopyingObjects; +const int ENTRY_COLUMN = 2; + + HYDROGUI_DataModel::HYDROGUI_DataModel( CAM_Module* theModule ) : LightApp_DataModel( theModule ) { @@ -95,17 +97,19 @@ bool HYDROGUI_DataModel::open( const QString& theURL, const int aStudyId = theStudy->id(); Data_DocError res = DocError_UnknownProblem; - if( theFileList.count() == 2 ) + if( theFileList.count() >= 2 ) { QString aTmpDir = theFileList[0]; - QString aFileName = theFileList[1]; + QString aDataFileName = theFileList[1]; + QString aStatesFileName = theFileList.count() == 3 ? theFileList[2] : ""; myStudyURL = theURL; - QString aFullPath = SUIT_Tools::addSlash( aTmpDir ) + aFileName; + QString aDataFullPath = SUIT_Tools::addSlash( aTmpDir ) + aDataFileName; + QString aStatesFullPath = aStatesFileName.isEmpty() ? "" : SUIT_Tools::addSlash( aTmpDir ) + aStatesFileName; try { - res = HYDROData_Document::Load( (char*)aFullPath.toLatin1().constData(), aStudyId ); + res = HYDROData_Document::Load( (char*)aDataFullPath.toLatin1().constData(), aStudyId ); } catch(...) { @@ -116,6 +120,16 @@ bool HYDROGUI_DataModel::open( const QString& theURL, module()->application()->putInfo( tr( "LOAD_ERROR" ) ); return false; } + + if( !aStatesFullPath.isEmpty() ) + { + QFile aFile( aStatesFullPath ); + if( aFile.open( QFile::ReadOnly ) ) + { + myStates = aFile.readAll(); + aFile.close(); + } + } } // if the document open was successful, the data model update happens @@ -134,27 +148,41 @@ bool HYDROGUI_DataModel::save( QStringList& theFileList ) LightApp_DataModel::save( theFileList ); QString aTmpDir; - QString aFileName; SUIT_ResourceMgr* resMgr = module()->application()->resourceMgr(); bool isMultiFile = false; if( resMgr ) isMultiFile = resMgr->booleanValue( "Study", "multi_file", false ); - // save data to temporary files + // save module data to temporary files LightApp_Study* aStudy = dynamic_cast( module()->application()->activeStudy() ); aTmpDir = aStudy->GetTmpDir( myStudyURL.toLatin1().constData(), isMultiFile ).c_str(); - aFileName = SUIT_Tools::file( myStudyURL, false ) + "_HYDRO.cbf"; - - QString aFullPath = aTmpDir + aFileName; - Data_DocError res = getDocument()->Save( (char*)aFullPath.toLatin1().constData() ); + + // save OCAF data to a temporary file + QString aDataFileName = SUIT_Tools::file( myStudyURL, false ) + "_HYDRO.cbf"; + QString aDataFullPath = aTmpDir + aDataFileName; + Data_DocError res = getDocument()->Save( (char*)aDataFullPath.toLatin1().constData() ); if( res != DocError_OK ) { module()->application()->putInfo( tr( "SAVE_ERROR" ) ); return false; } + // save tree state data to a temporary file + LightApp_Application* anApp = dynamic_cast( module()->application() ); + QByteArray aStatesData = anApp->objectBrowser()->getOpenStates( ENTRY_COLUMN ); + QString aStatesFileName = SUIT_Tools::file( myStudyURL, false ) + "_HYDRO_tree_states.txt"; + QString aStatesFullPath = aTmpDir + aStatesFileName; + QFile aFile( aStatesFullPath ); + if( aFile.open( QFile::WriteOnly ) ) + { + aFile.write( aStatesData ); + aFile.close(); + } + + // add temporary files to the list theFileList.append( aTmpDir ); - theFileList.append( aFileName ); + theFileList.append( aDataFileName ); + theFileList.append( aStatesFileName ); return true; } @@ -219,19 +247,8 @@ void HYDROGUI_DataModel::update( const int theStudyId ) if( !aStudyRoot ) return; - // create root object if not exist - CAM_DataObject* aRootObj = root(); - if( !aRootObj ) - aRootObj = createRootModuleObject( aStudyRoot ); - - if( !aRootObj ) - return; - - DataObjectList aList; - aRootObj->children( aList ); - QListIterator anIter( aList ); - while( anIter.hasNext() ) - removeChild( aRootObj, anIter.next() ); + // create a new root object + CAM_DataObject* aNewRootObj = new CAM_DataObject(); Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theStudyId ); if( aDocument.IsNull() ) @@ -240,34 +257,34 @@ void HYDROGUI_DataModel::update( const int theStudyId ) // Create root objects: // IMAGES - LightApp_DataObject* anImageRootObj = createObject( aRootObj, tr( partitionName( KIND_IMAGE ).toAscii() ) ); + LightApp_DataObject* anImageRootObj = createObject( aNewRootObj, tr( partitionName( KIND_IMAGE ).toAscii() ) ); // BATHYMETRY - LightApp_DataObject* aBathymetryRootObj = createObject( aRootObj, tr( partitionName( KIND_BATHYMETRY ).toAscii() ) ); + LightApp_DataObject* aBathymetryRootObj = createObject( aNewRootObj, tr( partitionName( KIND_BATHYMETRY ).toAscii() ) ); // ARTIFICIAL OBJECTS - LightApp_DataObject* anArtificialObjectsRootObj = createObject( aRootObj, tr( partitionName( KIND_ARTIFICIAL_OBJECT ).toAscii() ) ); + LightApp_DataObject* anArtificialObjectsRootObj = createObject( aNewRootObj, tr( partitionName( KIND_ARTIFICIAL_OBJECT ).toAscii() ) ); // NATURAL OBJECTS - LightApp_DataObject* aNaturalObjectsRootObj = createObject( aRootObj, tr( partitionName( KIND_NATURAL_OBJECT ).toAscii() ) ); + LightApp_DataObject* aNaturalObjectsRootObj = createObject( aNewRootObj, tr( partitionName( KIND_NATURAL_OBJECT ).toAscii() ) ); // OBSTACLES - LightApp_DataObject* anObstaclesRootObj = createObject( aRootObj, tr( partitionName( KIND_OBSTACLE ).toAscii() ) ); + LightApp_DataObject* anObstaclesRootObj = createObject( aNewRootObj, tr( partitionName( KIND_OBSTACLE ).toAscii() ) ); // CALCULATION CASES - LightApp_DataObject* aCalculRootObj = createObject( aRootObj, tr( partitionName( KIND_CALCULATION ).toAscii() ) ); + LightApp_DataObject* aCalculRootObj = createObject( aNewRootObj, tr( partitionName( KIND_CALCULATION ).toAscii() ) ); // POLYLINES - LightApp_DataObject* aPolylineRootObj = createObject( aRootObj, tr( partitionName( KIND_POLYLINEXY ).toAscii() ) ); + LightApp_DataObject* aPolylineRootObj = createObject( aNewRootObj, tr( partitionName( KIND_POLYLINEXY ).toAscii() ) ); // POLYLINES - LightApp_DataObject* aPolyline3DRootObj = createObject( aRootObj, tr( partitionName( KIND_POLYLINE ).toAscii() ) ); + LightApp_DataObject* aPolyline3DRootObj = createObject( aNewRootObj, tr( partitionName( KIND_POLYLINE ).toAscii() ) ); // PROFILES - LightApp_DataObject* aProfileRootObj = createObject( aRootObj, tr( partitionName( KIND_PROFILE ).toAscii() ) ); + LightApp_DataObject* aProfileRootObj = createObject( aNewRootObj, tr( partitionName( KIND_PROFILE ).toAscii() ) ); // VISUAL STATES - LightApp_DataObject* aVisualStateRootObj = createObject( aRootObj, tr( partitionName( KIND_VISUAL_STATE ).toAscii() ) ); + LightApp_DataObject* aVisualStateRootObj = createObject( aNewRootObj, tr( partitionName( KIND_VISUAL_STATE ).toAscii() ) ); HYDROData_Iterator anIterator( aDocument, KIND_UNKNOWN ); for( ; anIterator.More(); anIterator.Next() ) { @@ -410,10 +427,27 @@ void HYDROGUI_DataModel::update( const int theStudyId ) } } - if( SUIT_DataBrowser* anObjectBrowser = anApp->objectBrowser() ) + //if( SUIT_DataBrowser* anObjectBrowser = anApp->objectBrowser() ) + //{ + // anObjectBrowser->setAutoOpenLevel( 3 ); + // anObjectBrowser->openLevels(); + //} + + HYDROGUI_DataModelSync aSync( aNewRootObj ); + SUIT_DataObject* aRoot = root(); + bool isNewDoc = aRoot==0; + if( isNewDoc ) + aRoot = createRootModuleObject( aStudyRoot ); + ::synchronize < suitPtr, suitPtr, HYDROGUI_DataModelSync > + ( aNewRootObj, aRoot, aSync ); + + + if( !myStates.isEmpty() ) { - anObjectBrowser->setAutoOpenLevel( 3 ); - anObjectBrowser->openLevels(); + LightApp_Application* anApp = dynamic_cast( module()->application() ); + anApp->objectBrowser()->updateTree(); + anApp->objectBrowser()->setOpenStates( myStates, ENTRY_COLUMN ); + myStates.clear(); } } diff --git a/src/HYDROGUI/HYDROGUI_DataModel.h b/src/HYDROGUI/HYDROGUI_DataModel.h index 019350e1..dde52d05 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.h +++ b/src/HYDROGUI/HYDROGUI_DataModel.h @@ -363,6 +363,7 @@ protected: protected: QString myStudyURL; ///< the saved/opened document URL + QByteArray myStates; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_DataModelSync.cxx b/src/HYDROGUI/HYDROGUI_DataModelSync.cxx new file mode 100644 index 00000000..5f148e9a --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_DataModelSync.cxx @@ -0,0 +1,93 @@ + +#include +#include +#include + +HYDROGUI_DataModelSync::HYDROGUI_DataModelSync( SUIT_DataObject* theRoot ) + : myRoot( theRoot ) +{ +} + +HYDROGUI_DataModelSync::~HYDROGUI_DataModelSync() +{ +} + +void HYDROGUI_DataModelSync::deleteItemWithChildren( const suitPtr& theSuitPtr ) const +{ + if( !theSuitPtr ) + return; + + theSuitPtr->setAutoDeleteChildren( true ); + theSuitPtr->deleteLater(); +} + +suitPtr HYDROGUI_DataModelSync::nullSrc() const +{ + return 0; +} + +suitPtr HYDROGUI_DataModelSync::nullTrg() const +{ + return 0; +} + +QList HYDROGUI_DataModelSync::children( const suitPtr& theSuitPtr ) const +{ + QList aChildren; + if( theSuitPtr ) + { + DataObjectList anObjList; + theSuitPtr->children( anObjList ); + foreach( SUIT_DataObject* anObj, anObjList ) + aChildren.append( anObj ); + } + return aChildren; +} + +suitPtr HYDROGUI_DataModelSync::parent( const suitPtr& theSuitPtr ) const +{ + return theSuitPtr ? theSuitPtr->parent() : 0; +} + +void HYDROGUI_DataModelSync::updateItem( const suitPtr& theSrcPtr, const suitPtr& theTrgPtr ) const +{ + HYDROGUI_DataObject* aDataObj = dynamic_cast( theTrgPtr ); + if( aDataObj ) + aDataObj->updateBy( theSrcPtr ); + + HYDROGUI_NamedObject* aNamedObj = dynamic_cast( theTrgPtr ); + if( aNamedObj ) + aNamedObj->updateBy( theSrcPtr ); +} + +bool HYDROGUI_DataModelSync::isEqual( const suitPtr& theSrcPtr, const suitPtr& theTrgPtr ) const +{ + if( theSrcPtr==myRoot ) + return true; + + if( theSrcPtr==0 ) + return theTrgPtr==0; + + if( theTrgPtr==0 ) + return theSrcPtr==0; + + QString aSrcClass = typeid( *theSrcPtr ).name(); + QString aTrgClass = typeid( *theTrgPtr ).name(); + return aSrcClass==aTrgClass; +} + +suitPtr HYDROGUI_DataModelSync::createItem( const suitPtr& theSrcPtr, + const suitPtr& theParent, + const suitPtr& theAfter ) const +{ + if( theParent ) + { + int aPos = theParent->childPos( theAfter ); + if( aPos>=0 ) + theParent->insertChild( theSrcPtr, aPos+1 ); + else + theParent->appendChild( theSrcPtr ); + } + return theSrcPtr; +} + diff --git a/src/HYDROGUI/HYDROGUI_DataModelSync.h b/src/HYDROGUI/HYDROGUI_DataModelSync.h new file mode 100644 index 00000000..91920682 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_DataModelSync.h @@ -0,0 +1,30 @@ + +#ifndef HYDROGUI_DATA_MODEL_SYNC_HEADER +#define HYDROGUI_DATA_MODEL_SYNC_HEADER + +#include + +class SUIT_DataObject; + +typedef SUIT_DataObject* suitPtr; + +class HYDROGUI_DataModelSync +{ +public: + HYDROGUI_DataModelSync( SUIT_DataObject* theRoot ); + ~HYDROGUI_DataModelSync(); + + void deleteItemWithChildren( const suitPtr& ) const; + suitPtr nullSrc() const; + suitPtr nullTrg() const; + QList children( const suitPtr& ) const; + suitPtr parent( const suitPtr& ) const; + void updateItem( const suitPtr&, const suitPtr& ) const; + bool isEqual( const suitPtr&, const suitPtr& ) const; + suitPtr createItem( const suitPtr&, const suitPtr&, const suitPtr& ) const; + +private: + SUIT_DataObject* myRoot; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_DataObject.cxx b/src/HYDROGUI/HYDROGUI_DataObject.cxx index a259a866..9701970a 100644 --- a/src/HYDROGUI/HYDROGUI_DataObject.cxx +++ b/src/HYDROGUI/HYDROGUI_DataObject.cxx @@ -220,6 +220,23 @@ bool HYDROGUI_DataObject::renameAllowed( const int theColumnId ) const return aRes; } +void HYDROGUI_DataObject::updateBy( SUIT_DataObject* theObj ) +{ + HYDROGUI_DataObject* aDataObj = dynamic_cast( theObj ); + if( !aDataObj ) + return; + + myData = aDataObj->myData; + myParentEntry = aDataObj->myParentEntry; + myIsValid = aDataObj->myIsValid; + myIsInOperation = aDataObj->myIsInOperation; + myIcon = aDataObj->myIcon; + setModified( true ); +} + + + + HYDROGUI_NamedObject::HYDROGUI_NamedObject( SUIT_DataObject* theParent, @@ -270,6 +287,24 @@ QFont HYDROGUI_NamedObject::font( const int theId ) const return aFont; } +void HYDROGUI_NamedObject::updateBy( SUIT_DataObject* theObj ) +{ + HYDROGUI_NamedObject* aNamedObj = dynamic_cast( theObj ); + if( !aNamedObj ) + return; + + myName = aNamedObj->myName; + myParentEntry = aNamedObj->myParentEntry; + myIcon = aNamedObj->myIcon; + myIsInOperation = aNamedObj->myIsInOperation; + setModified( true ); +} + + + + + + HYDROGUI_DropTargetObject::HYDROGUI_DropTargetObject( SUIT_DataObject* theParent, const QString& theName, const QString& theParentEntry, diff --git a/src/HYDROGUI/HYDROGUI_DataObject.h b/src/HYDROGUI/HYDROGUI_DataObject.h index 6ffeaa1e..b35d60c0 100644 --- a/src/HYDROGUI/HYDROGUI_DataObject.h +++ b/src/HYDROGUI/HYDROGUI_DataObject.h @@ -141,6 +141,8 @@ public: */ bool isInOperation() const { return myIsInOperation; } + void updateBy( SUIT_DataObject* ); + protected: Handle(HYDROData_Entity) myData; ///< object from data model QString myParentEntry; @@ -199,6 +201,8 @@ public: */ bool isInOperation() const { return myIsInOperation; } + void updateBy( SUIT_DataObject* ); + private: QString myName; ///< name in the OB QString myParentEntry; diff --git a/src/HYDROGUI/HYDROGUI_DigueOp.cxx b/src/HYDROGUI/HYDROGUI_DigueOp.cxx index f16708f3..60c8119f 100644 --- a/src/HYDROGUI/HYDROGUI_DigueOp.cxx +++ b/src/HYDROGUI/HYDROGUI_DigueOp.cxx @@ -54,9 +54,10 @@ void HYDROGUI_DigueOp::startOperation() } bool HYDROGUI_DigueOp::processApply( int& theUpdateFlags, - QString& theErrorMsg ) + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) { - if ( !HYDROGUI_ChannelOp::processApply( theUpdateFlags, theErrorMsg ) ) + if ( !HYDROGUI_ChannelOp::processApply( theUpdateFlags, theErrorMsg, theBrowseObjectsEntries ) ) return false; if ( !myIsEdit ) diff --git a/src/HYDROGUI/HYDROGUI_DigueOp.h b/src/HYDROGUI/HYDROGUI_DigueOp.h index 782626a7..f5c43455 100644 --- a/src/HYDROGUI/HYDROGUI_DigueOp.h +++ b/src/HYDROGUI/HYDROGUI_DigueOp.h @@ -37,7 +37,8 @@ protected: virtual void startOperation(); - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); virtual HYDROGUI_InputPanel* createInputPanel() const; diff --git a/src/HYDROGUI/HYDROGUI_ExportCalculationOp.cxx b/src/HYDROGUI/HYDROGUI_ExportCalculationOp.cxx index 8e3f8522..d91522bb 100644 --- a/src/HYDROGUI/HYDROGUI_ExportCalculationOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ExportCalculationOp.cxx @@ -68,7 +68,8 @@ void HYDROGUI_ExportCalculationOp::commitOperation() } bool HYDROGUI_ExportCalculationOp::processApply( int& theUpdateFlags, - QString& theErrorMsg ) + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) { // Get the selected calculation case Handle(HYDROData_CalculationCase) aCalculation = @@ -107,9 +108,10 @@ void HYDROGUI_ExportCalculationOp::onApply() QString anErrorMsg; bool aResult = false; - + QStringList aBrowseObjectsEntries; + try { - aResult = processApply( anUpdateFlags, anErrorMsg ); + aResult = processApply( anUpdateFlags, anErrorMsg, aBrowseObjectsEntries ); } catch ( Standard_Failure ) { @@ -127,6 +129,7 @@ void HYDROGUI_ExportCalculationOp::onApply() if ( aResult ) { module()->update( anUpdateFlags ); commit(); + browseObjects( aBrowseObjectsEntries ); // Show message box SUIT_MessageBox::information( module()->getApp()->desktop(), diff --git a/src/HYDROGUI/HYDROGUI_ExportCalculationOp.h b/src/HYDROGUI/HYDROGUI_ExportCalculationOp.h index 1b42f3ff..7cbe6b29 100644 --- a/src/HYDROGUI/HYDROGUI_ExportCalculationOp.h +++ b/src/HYDROGUI/HYDROGUI_ExportCalculationOp.h @@ -38,7 +38,8 @@ protected: virtual void abortOperation(); virtual void commitOperation(); - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); virtual void onApply(); }; diff --git a/src/HYDROGUI/HYDROGUI_GeoreferencementOp.cxx b/src/HYDROGUI/HYDROGUI_GeoreferencementOp.cxx index d7b389e6..9c7ef5c2 100644 --- a/src/HYDROGUI/HYDROGUI_GeoreferencementOp.cxx +++ b/src/HYDROGUI/HYDROGUI_GeoreferencementOp.cxx @@ -115,7 +115,8 @@ HYDROGUI_InputPanel* HYDROGUI_GeoreferencementOp::createInputPanel() const } bool HYDROGUI_GeoreferencementOp::processApply( int& theUpdateFlags, - QString& theErrorMsg ) + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) { theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init; @@ -249,8 +250,8 @@ bool HYDROGUI_GeoreferencementOp::store( QString& theErrorMsg ) if ( !aProfile->IsValid() ) // Show the profile after it became valid aModule->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( aModule ), aProfile, true ); - aProfile->SetLeftPoint( gp_XY( aGeoData.Xg, aGeoData.Yg ) ); - aProfile->SetRightPoint( gp_XY( aGeoData.Xd, aGeoData.Yd ) ); + aProfile->SetLeftPoint( gp_XY( aGeoData.Xg, aGeoData.Yg ), false ); + aProfile->SetRightPoint( gp_XY( aGeoData.Xd, aGeoData.Yd ), false ); } else { aProfile->Invalidate(); aModule->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( aModule ), aProfile, false ); @@ -299,7 +300,8 @@ void HYDROGUI_GeoreferencementOp::setPanelData( HYDROGUI_GeoreferencementDlg::ProfileGeoData aGeoData( aProfile->GetName() ); gp_XY aFirstPoint, aLastPoint; - if ( aProfile->GetLeftPoint( aFirstPoint ) && aProfile->GetRightPoint( aLastPoint ) ) { + if ( aProfile->GetLeftPoint( aFirstPoint, false ) && + aProfile->GetRightPoint( aLastPoint, false ) ) { aGeoData = HYDROGUI_GeoreferencementDlg::ProfileGeoData( aGeoData.Name, aFirstPoint.X(), aFirstPoint.Y(), diff --git a/src/HYDROGUI/HYDROGUI_GeoreferencementOp.h b/src/HYDROGUI/HYDROGUI_GeoreferencementOp.h index 6fa244c0..753df02c 100644 --- a/src/HYDROGUI/HYDROGUI_GeoreferencementOp.h +++ b/src/HYDROGUI/HYDROGUI_GeoreferencementOp.h @@ -47,7 +47,8 @@ protected: virtual HYDROGUI_InputPanel* createInputPanel() const; - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); protected slots: void onModeActivated( const int theActualMode ); diff --git a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx index 405f5f89..b6c0fd02 100644 --- a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx @@ -28,6 +28,7 @@ #include "HYDROGUI_Shape.h" #include "HYDROGUI_Tool.h" #include "HYDROGUI_UpdateFlags.h" +#include "HYDROGUI_DataObject.h" #include #include @@ -128,7 +129,8 @@ HYDROGUI_InputPanel* HYDROGUI_ImmersibleZoneOp::createInputPanel() const } bool HYDROGUI_ImmersibleZoneOp::processApply( int& theUpdateFlags, - QString& theErrorMsg ) + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) { HYDROGUI_ImmersibleZoneDlg* aPanel = ::qobject_cast( inputPanel() ); if ( !aPanel ) @@ -194,7 +196,11 @@ bool HYDROGUI_ImmersibleZoneOp::processApply( int& theUpdateFlags, closePreview(); if( !myIsEdit ) + { module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aZoneObj, true ); + QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aZoneObj ); + theBrowseObjectsEntries.append( anEntry ); + } module()->setIsToUpdate( aZoneObj ); diff --git a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.h b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.h index 20cddaca..d69d2a26 100644 --- a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.h +++ b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.h @@ -44,7 +44,8 @@ protected: virtual HYDROGUI_InputPanel* createInputPanel() const; - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); virtual HYDROGUI_Shape* getPreviewShape() const { return myPreviewPrs; }; diff --git a/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx b/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx index 60ae9a44..4e828055 100644 --- a/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx @@ -23,6 +23,7 @@ #include "HYDROGUI_ImportBathymetryOp.h" #include "HYDROGUI_DataModel.h" +#include "HYDROGUI_DataObject.h" #include "HYDROGUI_ImportBathymetryDlg.h" #include "HYDROGUI_Module.h" #include "HYDROGUI_Tool.h" @@ -96,7 +97,8 @@ HYDROGUI_InputPanel* HYDROGUI_ImportBathymetryOp::createInputPanel() const } bool HYDROGUI_ImportBathymetryOp::processApply( int& theUpdateFlags, - QString& theErrorMsg ) + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) { HYDROGUI_ImportBathymetryDlg* aPanel = ::qobject_cast( inputPanel() ); @@ -196,6 +198,13 @@ bool HYDROGUI_ImportBathymetryOp::processApply( int& theUpdateFlags, } theUpdateFlags = UF_Model | UF_VTKViewer | UF_VTK_Init | UF_VTK_Forced; + + if( !myIsEdit ) + { + QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aBathymetryObj ); + theBrowseObjectsEntries.append( anEntry ); + } + return true; } diff --git a/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.h b/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.h index cdf6a39b..5713e31d 100644 --- a/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.h +++ b/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.h @@ -43,7 +43,8 @@ protected: virtual HYDROGUI_InputPanel* createInputPanel() const; - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); protected slots: diff --git a/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx b/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx index 7832f3b3..e8cb3e03 100644 --- a/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx @@ -23,7 +23,7 @@ #include "HYDROGUI_ImportGeomObjectOp.h" #include "HYDROGUI_GeomObjectDlg.h" - +#include "HYDROGUI_DataObject.h" #include "HYDROGUI_DataModel.h" #include "HYDROGUI_Module.h" #include "HYDROGUI_Tool.h" @@ -145,7 +145,8 @@ void HYDROGUI_ImportGeomObjectOp::commitOperation() } bool HYDROGUI_ImportGeomObjectOp::processApply( int& theUpdateFlags, - QString& theErrorMsg ) + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) { // Get active SalomeApp_Study SalomeApp_Study* aStudy = @@ -264,6 +265,8 @@ bool HYDROGUI_ImportGeomObjectOp::processApply( int& theUpdateFlags, if ( anIsOk ) { anObject->Update(); module()->setIsToUpdate( anObject ); + QString aHydroObjEntry = HYDROGUI_DataObject::dataObjectEntry( anObject ); + theBrowseObjectsEntries.append( aHydroObjEntry ); theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer; } } diff --git a/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.h b/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.h index b8830f9f..75d70128 100644 --- a/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.h +++ b/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.h @@ -58,7 +58,8 @@ protected: virtual HYDROGUI_InputPanel* createInputPanel() const; - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); protected slots: void onExternalOperationFinished( const QString&, const QString&, diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx index 58ca39f3..72f2ac2d 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx @@ -23,6 +23,7 @@ #include "HYDROGUI_ImportImageOp.h" #include "HYDROGUI_DataModel.h" +#include #include "HYDROGUI_ImportImageDlg.h" #include "HYDROGUI_Module.h" #include "HYDROGUI_PrsImage.h" @@ -344,7 +345,8 @@ bool HYDROGUI_ImportImageOp::checkPoints( const QPointF& thePointA, } bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags, - QString& theErrorMsg ) + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) { HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel(); @@ -446,7 +448,11 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags, if( myIsEdit ) anImageObj = myEditedObject; else + { anImageObj = Handle(HYDROData_Image)::DownCast( doc()->CreateObject( KIND_IMAGE ) ); + QString anEntry = HYDROGUI_DataObject::dataObjectEntry( anImageObj ); + theBrowseObjectsEntries.append( anEntry ); + } if( anImageObj.IsNull() ) return false; diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.h b/src/HYDROGUI/HYDROGUI_ImportImageOp.h index 0acdd0bc..7a2c399c 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.h +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.h @@ -49,7 +49,8 @@ protected: virtual HYDROGUI_InputPanel* createInputPanel() const; - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); bool isReferenceCorrect() const; protected slots: diff --git a/src/HYDROGUI/HYDROGUI_ImportObstacleFromFileOp.cxx b/src/HYDROGUI/HYDROGUI_ImportObstacleFromFileOp.cxx index 301e826d..432ef681 100644 --- a/src/HYDROGUI/HYDROGUI_ImportObstacleFromFileOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportObstacleFromFileOp.cxx @@ -23,7 +23,7 @@ #include "HYDROGUI_ImportObstacleFromFileOp.h" #include "HYDROGUI_GeomObjectDlg.h" - +#include #include "HYDROGUI_DataModel.h" #include "HYDROGUI_Module.h" #include "HYDROGUI_Tool.h" @@ -98,7 +98,8 @@ void HYDROGUI_ImportObstacleFromFileOp::commitOperation() } bool HYDROGUI_ImportObstacleFromFileOp::processApply( int& theUpdateFlags, - QString& theErrorMsg ) + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) { QString aFileName; QString anObstacleName; @@ -176,6 +177,10 @@ bool HYDROGUI_ImportObstacleFromFileOp::processApply( int& theUpdateFlags, anIsOk = true; module()->setIsToUpdate( anObstacle ); theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer; + QString anEntry = HYDROGUI_DataObject::dataObjectEntry( anObstacle ); + theBrowseObjectsEntries.append( anEntry ); + + } else { theErrorMsg = tr( "BAD_IMPORTED_OBSTACLE_FILE" ).arg( aFileName ); } diff --git a/src/HYDROGUI/HYDROGUI_ImportObstacleFromFileOp.h b/src/HYDROGUI/HYDROGUI_ImportObstacleFromFileOp.h index e2647293..b32d0dd0 100644 --- a/src/HYDROGUI/HYDROGUI_ImportObstacleFromFileOp.h +++ b/src/HYDROGUI/HYDROGUI_ImportObstacleFromFileOp.h @@ -42,7 +42,8 @@ protected: virtual HYDROGUI_InputPanel* createInputPanel() const; - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); private: SUIT_FileDlg* myFileDlg; diff --git a/src/HYDROGUI/HYDROGUI_ImportProfilesOp.cxx b/src/HYDROGUI/HYDROGUI_ImportProfilesOp.cxx index 2e05ab91..9d637fc3 100644 --- a/src/HYDROGUI/HYDROGUI_ImportProfilesOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportProfilesOp.cxx @@ -81,6 +81,8 @@ void HYDROGUI_ImportProfilesOp::onApply() } QApplication::setOverrideCursor( Qt::WaitCursor ); + QStringList aBrowseObjectsEntries; + //TODO: to implement the addition of imported profiles' entries to the list startDocOperation(); @@ -141,6 +143,7 @@ void HYDROGUI_ImportProfilesOp::onApply() commit(); module()->update( UF_Model | UF_VTKViewer | UF_VTK_Forced | UF_VTK_Init ); + browseObjects( aBrowseObjectsEntries ); } QApplication::restoreOverrideCursor(); diff --git a/src/HYDROGUI/HYDROGUI_LocalCSDlg.cxx b/src/HYDROGUI/HYDROGUI_LocalCSDlg.cxx new file mode 100644 index 00000000..2b0168b3 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_LocalCSDlg.cxx @@ -0,0 +1,73 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include +#include +#include +#include + +const double RANGE = 1E+10; +const double STEP = 1.00; +const double PREC = 2; + +HYDROGUI_LocalCSDlg::HYDROGUI_LocalCSDlg( HYDROGUI_Module* theModule, const QString& theTitle ) +: HYDROGUI_InputPanel( theModule, theTitle ) +{ + QFrame* aFrame = new QFrame( mainFrame() ); + addWidget( aFrame, 1 ); + + QGridLayout* aLayout = new QGridLayout( aFrame ); + + myLX = new QtxDoubleSpinBox( 0, RANGE, STEP, PREC, PREC, aFrame ); + myLX->setValue( 0.0 ); + myLY = new QtxDoubleSpinBox( 0, RANGE, STEP, PREC, PREC, aFrame ); + myLY->setValue( 0.0 ); + + aLayout->addWidget( new QLabel( tr( "LX" ), aFrame ), 0, 0 ); + aLayout->addWidget( myLX, 0, 1 ); + aLayout->addWidget( new QLabel( tr( "LY" ), aFrame ), 1, 0 ); + aLayout->addWidget( myLY, 1, 1 ); + aLayout->setColumnStretch( 0, 0 ); + aLayout->setColumnStretch( 1, 1 ); + aLayout->setRowStretch( 2, 1 ); +} + +HYDROGUI_LocalCSDlg::~HYDROGUI_LocalCSDlg() +{ +} + +double HYDROGUI_LocalCSDlg::GetLocalX() const +{ + return myLX->value(); +} + +double HYDROGUI_LocalCSDlg::GetLocalY() const +{ + return myLY->value(); +} + +void HYDROGUI_LocalCSDlg::SetLocalCS( double theLX, double theLY ) +{ + myLX->setValue( theLX ); + myLY->setValue( theLY ); +} + diff --git a/src/HYDROGUI/HYDROGUI_LocalCSDlg.h b/src/HYDROGUI/HYDROGUI_LocalCSDlg.h new file mode 100644 index 00000000..f0fd13c2 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_LocalCSDlg.h @@ -0,0 +1,47 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HYDROGUI_LocalCSDlg_H +#define HYDROGUI_LocalCSDlg_H + +#include "HYDROGUI_InputPanel.h" + +class QtxDoubleSpinBox; + +class HYDROGUI_LocalCSDlg : public HYDROGUI_InputPanel +{ + Q_OBJECT + +public: + HYDROGUI_LocalCSDlg( HYDROGUI_Module* theModule, const QString& theTitle ); + virtual ~HYDROGUI_LocalCSDlg(); + + double GetLocalX() const; + double GetLocalY() const; + void SetLocalCS( double theLX, double theLY ); + +private: + QtxDoubleSpinBox* myLX; + QtxDoubleSpinBox* myLY; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_LocalCSOp.cxx b/src/HYDROGUI/HYDROGUI_LocalCSOp.cxx new file mode 100644 index 00000000..228a9fab --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_LocalCSOp.cxx @@ -0,0 +1,72 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include +#include +#include +#include +#include + +HYDROGUI_LocalCSOp::HYDROGUI_LocalCSOp( HYDROGUI_Module* theModule ) +: HYDROGUI_Operation( theModule ) +{ + setName( tr( "EDIT_LOCAL_CS" ) ); +} + +HYDROGUI_LocalCSOp::~HYDROGUI_LocalCSOp() +{ +} + +void HYDROGUI_LocalCSOp::startOperation() +{ + HYDROGUI_Operation::startOperation(); + + HYDROGUI_LocalCSDlg* aPanel = ::qobject_cast( inputPanel() ); + if ( !aPanel ) + return; + + double aLX, aLY; + doc()->GetLocalCS( aLX, aLY ); + aPanel->SetLocalCS( aLX, aLY ); +} + +HYDROGUI_InputPanel* HYDROGUI_LocalCSOp::createInputPanel() const +{ + return new HYDROGUI_LocalCSDlg( module(), getName() ); +} + +bool HYDROGUI_LocalCSOp::processApply( int& theUpdateFlags, + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) +{ + HYDROGUI_LocalCSDlg* aPanel = ::qobject_cast( inputPanel() ); + if ( !aPanel ) + return false; + + double aLX = aPanel->GetLocalX(); + double aLY = aPanel->GetLocalY(); + doc()->SetLocalCS( aLX, aLY ); + + theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer; + + return true; +} diff --git a/src/HYDROGUI/HYDROGUI_LocalCSOp.h b/src/HYDROGUI/HYDROGUI_LocalCSOp.h new file mode 100644 index 00000000..6ec1be1c --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_LocalCSOp.h @@ -0,0 +1,45 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HYDROGUI_LocalCSOp_H +#define HYDROGUI_LocalCSOp_H + +#include "HYDROGUI_Operation.h" + +class HYDROGUI_LocalCSOp : public HYDROGUI_Operation +{ + Q_OBJECT + +public: + HYDROGUI_LocalCSOp( HYDROGUI_Module* theModule ); + virtual ~HYDROGUI_LocalCSOp(); + +protected: + virtual void startOperation(); + + virtual HYDROGUI_InputPanel* createInputPanel() const; + + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 5e03c129..4aef231e 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -332,6 +332,18 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, bool anIsDummyObject3D = false; bool anIsGroup = false; bool anIsObjectCanBeColored = false; + bool isRoot = false; + + SUIT_SelectionMgr* aSelectionMgr = getApp()->selectionMgr(); + SUIT_DataOwnerPtrList anOwners; + aSelectionMgr->selected( anOwners ); + if( anIsObjectBrowser && anOwners.size()==1 ) + { + QString anEntry = anOwners[0]->keyString(); + LightApp_Study* aStudy = dynamic_cast( getApp()->activeStudy() ); + if( aStudy ) + isRoot = aStudy->isComponent( anEntry ); + } // Check the selected GEOM objects (take into account the Object Browser only) if ( anIsObjectBrowser ) { @@ -668,6 +680,9 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, theMenu->addSeparator(); theMenu->addAction( action( CopyViewerPositionId ) ); } + + if( isRoot ) + theMenu->addAction( action( EditLocalCSId ) ); } void HYDROGUI_Module::update( const int flags ) @@ -1486,21 +1501,31 @@ void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList ) void HYDROGUI_Module::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* ) { - double aX, aY, aZ; + double X, Y, Z; bool doShow = false; HYDROGUI_Displayer* aDisplayer = getDisplayer(); if ( aDisplayer ) aDisplayer->SaveCursorViewPosition( theViewWindow ); - doShow = aDisplayer->GetCursorViewCoordinates( theViewWindow, aX, aY, aZ ); + doShow = aDisplayer->GetCursorViewCoordinates( theViewWindow, X, Y, Z ); if ( doShow ) { // Show the coordinates in the status bar SUIT_Desktop* aDesktop = getApp()->desktop(); - if ( aDesktop && aDesktop->statusBar() ) { - QString aXStr = HYDROGUI_Tool::GetCoordinateString( aX ); - QString anYStr = HYDROGUI_Tool::GetCoordinateString( aY ); - aDesktop->statusBar()->showMessage( tr("COORDINATES_INFO").arg( aXStr ).arg( anYStr ) ); + if ( aDesktop && aDesktop->statusBar() ) + { + gp_Pnt aWPnt( X, Y, Z ); + int aStudyId = application()->activeStudy()->id(); + HYDROData_Document::Document( aStudyId )->Transform( aWPnt, false ); + double WX = aWPnt.X(), WY = aWPnt.Y(); + + QString aXStr = HYDROGUI_Tool::GetCoordinateString( X ); + QString anYStr = HYDROGUI_Tool::GetCoordinateString( Y ); + QString aWXStr = HYDROGUI_Tool::GetCoordinateString( WX ); + QString aWYStr = HYDROGUI_Tool::GetCoordinateString( WY ); + QString aMsg = tr( "COORDINATES_INFO" ); + aMsg = aMsg.arg( aXStr ).arg( anYStr ).arg( aWXStr ).arg( aWYStr ); + aDesktop->statusBar()->showMessage( aMsg ); } } } diff --git a/src/HYDROGUI/HYDROGUI_Operation.cxx b/src/HYDROGUI/HYDROGUI_Operation.cxx index 6c9d4ed9..442b6e7d 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.cxx +++ b/src/HYDROGUI/HYDROGUI_Operation.cxx @@ -233,7 +233,8 @@ void HYDROGUI_Operation::closeInputPanel() } bool HYDROGUI_Operation::processApply( int& theUpdateFlags, - QString& theErrorMsg ) + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) { return false; } @@ -290,10 +291,11 @@ void HYDROGUI_Operation::onApply() QString anErrorMsg; bool aResult = false; - + QStringList aBrowseObjectsEntries; + try { - aResult = processApply( anUpdateFlags, anErrorMsg ); + aResult = processApply( anUpdateFlags, anErrorMsg, aBrowseObjectsEntries ); } catch ( Standard_Failure ) { @@ -313,6 +315,7 @@ void HYDROGUI_Operation::onApply() module()->update( anUpdateFlags ); commitDocOperation(); commit(); + browseObjects( aBrowseObjectsEntries ); } else { @@ -377,4 +380,9 @@ QString HYDROGUI_Operation::getHelpContext() const return QString(); } - +void HYDROGUI_Operation::browseObjects( const QStringList& theBrowseObjectsEntries ) +{ + bool isApplyAndClose = true; + bool isOptimizedBrowse = true; + module()->getApp()->browseObjects( theBrowseObjectsEntries, isApplyAndClose, isOptimizedBrowse ); +} diff --git a/src/HYDROGUI/HYDROGUI_Operation.h b/src/HYDROGUI/HYDROGUI_Operation.h index 05879abf..44a77d87 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.h +++ b/src/HYDROGUI/HYDROGUI_Operation.h @@ -71,7 +71,8 @@ protected: virtual HYDROGUI_InputPanel* createInputPanel() const; virtual void closeInputPanel(); - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); virtual void processCancel(); void startDocOperation(); @@ -85,6 +86,8 @@ protected: void printErrorMessage( const QString& theErrorMsg ); void setPrintErrorMessage( const bool theIsPrint ); + void browseObjects( const QStringList& theBrowseObjectsEntries ); + protected slots: virtual void onApply(); diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index a2d1f3f6..8c0eb523 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -56,6 +56,7 @@ #include "HYDROGUI_BathymetryBoundsOp.h" #include "HYDROGUI_Tool.h" #include "HYDROGUI_ZLevelsOp.h" +#include "HYDROGUI_LocalCSOp.h" #include #include @@ -172,6 +173,7 @@ void HYDROGUI_Module::createActions() createAction( SetColorId, "COLOR" ); createAction( SetZLevelId, "ZLEVEL" ); + createAction( EditLocalCSId, "EDIT_LOCAL_CS" ); createAction( ShowId, "SHOW" ); createAction( ShowOnlyId, "SHOW_ONLY" ); @@ -200,6 +202,7 @@ void HYDROGUI_Module::createMenus() createMenu( ImportBathymetryId, aHydroId, -1, -1 ); createMenu( CreatePolylineId, aHydroId, -1, -1 ); createMenu( CreatePolyline3DId, aHydroId, -1, -1 ); + createMenu( EditLocalCSId, aHydroId, -1, -1 ); int aNewProfileId = createMenu( tr( "MEN_DESK_PROFILE" ), aHydroId, -1 ); createMenu( CreateProfileId, aNewProfileId, -1, -1 ); @@ -499,6 +502,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const case SetZLevelId: anOp = new HYDROGUI_ZLevelsOp( aModule ); break; + case EditLocalCSId: + anOp = new HYDROGUI_LocalCSOp( aModule ); + break; case ShowId: case ShowOnlyId: case ShowAllId: diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index a03a34d8..d307d7a7 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -105,6 +105,7 @@ enum OperationId SetColorId, SetZLevelId, + EditLocalCSId, }; diff --git a/src/HYDROGUI/HYDROGUI_Poly3DOp.cxx b/src/HYDROGUI/HYDROGUI_Poly3DOp.cxx index 8259381a..5c8ff2f2 100644 --- a/src/HYDROGUI/HYDROGUI_Poly3DOp.cxx +++ b/src/HYDROGUI/HYDROGUI_Poly3DOp.cxx @@ -23,6 +23,7 @@ #include "HYDROGUI_Poly3DOp.h" #include "HYDROGUI_Module.h" +#include #include "HYDROGUI_Tool.h" #include "HYDROGUI_Poly3DDlg.h" #include "HYDROGUI_UpdateFlags.h" @@ -108,7 +109,8 @@ void HYDROGUI_Poly3DOp::startOperation() } bool HYDROGUI_Poly3DOp::processApply( int& theUpdateFlags, - QString& theErrorMsg ) + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) { HYDROGUI_Poly3DDlg* aPanel = dynamic_cast( inputPanel() ); @@ -149,6 +151,8 @@ bool HYDROGUI_Poly3DOp::processApply( int& theUpdateFlags, else { aResult = Handle(HYDROData_Polyline3D)::DownCast( doc()->CreateObject( KIND_POLYLINE ) ); + QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aResult ); + theBrowseObjectsEntries.append( anEntry ); } if( aResult.IsNull() ) diff --git a/src/HYDROGUI/HYDROGUI_Poly3DOp.h b/src/HYDROGUI/HYDROGUI_Poly3DOp.h index 572e179a..d8fd16d5 100644 --- a/src/HYDROGUI/HYDROGUI_Poly3DOp.h +++ b/src/HYDROGUI/HYDROGUI_Poly3DOp.h @@ -40,7 +40,8 @@ protected: virtual HYDROGUI_InputPanel* createInputPanel() const; - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); private: bool myIsEdit; diff --git a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx index 47b25a12..a97508ef 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx +++ b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx @@ -23,6 +23,7 @@ #include "HYDROGUI_PolylineOp.h" #include "HYDROGUI_Module.h" +#include "HYDROGUI_DataObject.h" #include "HYDROGUI_PolylineDlg.h" #include "HYDROGUI_Tool.h" #include "HYDROGUI_UpdateFlags.h" @@ -211,7 +212,8 @@ HYDROGUI_InputPanel* HYDROGUI_PolylineOp::createInputPanel() const } bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags, - QString& theErrorMsg ) + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) { HYDROGUI_PolylineDlg* aPanel = ::qobject_cast( inputPanel() ); if ( !aPanel ) @@ -321,6 +323,8 @@ bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags, if( !myIsEdit ) { module()->setObjectVisible( anActiveViewId, aPolylineObj, true ); + QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aPolylineObj ); + theBrowseObjectsEntries.append( anEntry ); } return true; diff --git a/src/HYDROGUI/HYDROGUI_PolylineOp.h b/src/HYDROGUI/HYDROGUI_PolylineOp.h index d79d582d..25b2f8dc 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineOp.h +++ b/src/HYDROGUI/HYDROGUI_PolylineOp.h @@ -49,7 +49,8 @@ protected: virtual HYDROGUI_InputPanel* createInputPanel() const; - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); protected slots: void onEditorSelectionChanged(); diff --git a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx index 53700cc0..609bdafd 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx @@ -24,7 +24,7 @@ #include "HYDROGUI_ProfileDlg.h" #include "HYDROGUI_Tool.h" #include "HYDROGUI_UpdateFlags.h" - +#include #include "HYDROData_Document.h" #include "HYDROData_Profile.h" #include "CurveCreator_Profile.hxx" @@ -155,7 +155,8 @@ HYDROGUI_InputPanel* HYDROGUI_ProfileOp::createInputPanel() const } bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags, - QString& theErrorMsg ) + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) { HYDROGUI_ProfileDlg* aPanel = ::qobject_cast( inputPanel() ); if ( !aPanel ) @@ -239,6 +240,11 @@ bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags, theUpdateFlags = UF_Model; if ( myIsEdit ) theUpdateFlags |= UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer; + else + { + QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aProfileObj ); + theBrowseObjectsEntries.append( anEntry ); + } return true; } diff --git a/src/HYDROGUI/HYDROGUI_ProfileOp.h b/src/HYDROGUI/HYDROGUI_ProfileOp.h index dd5e2370..d93311a1 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileOp.h +++ b/src/HYDROGUI/HYDROGUI_ProfileOp.h @@ -47,7 +47,8 @@ protected: virtual HYDROGUI_InputPanel* createInputPanel() const; - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); private: void displayPreview(); diff --git a/src/HYDROGUI/HYDROGUI_SetColorOp.cxx b/src/HYDROGUI/HYDROGUI_SetColorOp.cxx index fa24977f..464434b6 100644 --- a/src/HYDROGUI/HYDROGUI_SetColorOp.cxx +++ b/src/HYDROGUI/HYDROGUI_SetColorOp.cxx @@ -118,7 +118,8 @@ void HYDROGUI_SetColorOp::startOperation() } bool HYDROGUI_SetColorOp::processApply( int& theUpdateFlags, - QString& theErrorMsg ) + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) { if ( !myColorDlg || myEditedObject.IsNull() ) return false; diff --git a/src/HYDROGUI/HYDROGUI_SetColorOp.h b/src/HYDROGUI/HYDROGUI_SetColorOp.h index 9fce5bd1..08729bd3 100644 --- a/src/HYDROGUI/HYDROGUI_SetColorOp.h +++ b/src/HYDROGUI/HYDROGUI_SetColorOp.h @@ -43,7 +43,8 @@ public: protected: virtual void startOperation(); - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); private: HYDROGUI_ColorDlg* myColorDlg; diff --git a/src/HYDROGUI/HYDROGUI_Shape.cxx b/src/HYDROGUI/HYDROGUI_Shape.cxx index d855380c..550deb93 100644 --- a/src/HYDROGUI/HYDROGUI_Shape.cxx +++ b/src/HYDROGUI/HYDROGUI_Shape.cxx @@ -307,6 +307,12 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer ) gp_Pnt aPnt3( aRect.bottomRight().x(), aRect.bottomRight().y(), 0 ); gp_Pnt aPnt4( aRect.bottomLeft().x(), aRect.bottomLeft().y(), 0 ); + Handle_HYDROData_Document aDoc = HYDROData_Document::Document( anImageObj->Label() ); + aDoc->Transform( aPnt1, true ); + aDoc->Transform( aPnt2, true ); + aDoc->Transform( aPnt3, true ); + aDoc->Transform( aPnt4, true ); + TopoDS_Edge anEdge1 = BRepBuilderAPI_MakeEdge( aPnt1, aPnt2 ).Edge(); TopoDS_Edge anEdge2 = BRepBuilderAPI_MakeEdge( aPnt2, aPnt3 ).Edge(); TopoDS_Edge anEdge3 = BRepBuilderAPI_MakeEdge( aPnt3, aPnt4 ).Edge(); diff --git a/src/HYDROGUI/HYDROGUI_StreamOp.cxx b/src/HYDROGUI/HYDROGUI_StreamOp.cxx index cabf8c67..ca39e32e 100755 --- a/src/HYDROGUI/HYDROGUI_StreamOp.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamOp.cxx @@ -23,6 +23,7 @@ #include "HYDROGUI_StreamOp.h" #include "HYDROGUI_Module.h" +#include #include "HYDROGUI_Shape.h" #include "HYDROGUI_StreamDlg.h" #include "HYDROGUI_Tool.h" @@ -184,7 +185,8 @@ HYDROGUI_InputPanel* HYDROGUI_StreamOp::createInputPanel() const } bool HYDROGUI_StreamOp::processApply( int& theUpdateFlags, - QString& theErrorMsg ) + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) { HYDROGUI_StreamDlg* aPanel = ::qobject_cast( inputPanel() ); if ( !aPanel ) @@ -260,6 +262,8 @@ bool HYDROGUI_StreamOp::processApply( int& theUpdateFlags, // Show the object in case of creation mode of the operation if( !myIsEdit ) { module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), myEditedObject, true ); + QString anEntry = HYDROGUI_DataObject::dataObjectEntry( myEditedObject ); + theBrowseObjectsEntries.append( anEntry ); } module()->setIsToUpdate( myEditedObject ); diff --git a/src/HYDROGUI/HYDROGUI_StreamOp.h b/src/HYDROGUI/HYDROGUI_StreamOp.h index 1173b679..300e269e 100755 --- a/src/HYDROGUI/HYDROGUI_StreamOp.h +++ b/src/HYDROGUI/HYDROGUI_StreamOp.h @@ -46,7 +46,8 @@ protected: virtual HYDROGUI_InputPanel* createInputPanel() const; - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); virtual bool isToAbortOnApply() const { return false; } 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/HYDROGUI/HYDROGUI_TranslateObstacleOp.cxx b/src/HYDROGUI/HYDROGUI_TranslateObstacleOp.cxx index 7275fe0a..27be271f 100644 --- a/src/HYDROGUI/HYDROGUI_TranslateObstacleOp.cxx +++ b/src/HYDROGUI/HYDROGUI_TranslateObstacleOp.cxx @@ -101,7 +101,8 @@ HYDROGUI_InputPanel* HYDROGUI_TranslateObstacleOp::createInputPanel() const } bool HYDROGUI_TranslateObstacleOp::processApply( int& theUpdateFlags, - QString& theErrorMsg ) + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) { HYDROGUI_TranslateObstacleDlg* aPanel = ::qobject_cast( inputPanel() ); if ( !aPanel || myEditedObject.IsNull() ) { diff --git a/src/HYDROGUI/HYDROGUI_TranslateObstacleOp.h b/src/HYDROGUI/HYDROGUI_TranslateObstacleOp.h index d2fa5e68..c005d78f 100644 --- a/src/HYDROGUI/HYDROGUI_TranslateObstacleOp.h +++ b/src/HYDROGUI/HYDROGUI_TranslateObstacleOp.h @@ -46,7 +46,8 @@ protected: virtual HYDROGUI_InputPanel* createInputPanel() const; - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); virtual HYDROGUI_Shape* getPreviewShape() const { return myPreviewPrs; }; diff --git a/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx b/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx index f57f39c0..990673a6 100644 --- a/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx +++ b/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx @@ -26,6 +26,7 @@ #include "HYDROGUI_Tool.h" #include "HYDROGUI_TwoImagesDlg.h" #include "HYDROGUI_UpdateFlags.h" +#include #include #include @@ -151,7 +152,8 @@ void HYDROGUI_TwoImagesOp::onAlreadySelected( const QString& theName ) } bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags, - QString& theErrorMsg ) + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) { HYDROGUI_TwoImagesDlg* aPanel = dynamic_cast( inputPanel() ); @@ -208,6 +210,8 @@ bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags, anOperator = aFactory->Operator( anOperatorName ); aResult = aFactory->CreateImage( doc(), anOperator ); + QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aResult ); + theBrowseObjectsEntries.append( anEntry ); } if( aResult.IsNull() || !anOperator ) diff --git a/src/HYDROGUI/HYDROGUI_TwoImagesOp.h b/src/HYDROGUI/HYDROGUI_TwoImagesOp.h index 095d47f1..274224a1 100644 --- a/src/HYDROGUI/HYDROGUI_TwoImagesOp.h +++ b/src/HYDROGUI/HYDROGUI_TwoImagesOp.h @@ -43,7 +43,8 @@ protected: virtual HYDROGUI_InputPanel* createInputPanel() const; - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); protected slots: /** Show warning if the name has already been selected diff --git a/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx b/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx index 1b9fba2d..3f7c1eaf 100644 --- a/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx @@ -95,7 +95,8 @@ void HYDROGUI_ZLevelsOp::startOperation() /** */ bool HYDROGUI_ZLevelsOp::processApply( int& theUpdateFlags, - QString& theErrorMsg ) + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) { bool aRes = false; diff --git a/src/HYDROGUI/HYDROGUI_ZLevelsOp.h b/src/HYDROGUI/HYDROGUI_ZLevelsOp.h index 7bb84ebc..7d43033b 100644 --- a/src/HYDROGUI/HYDROGUI_ZLevelsOp.h +++ b/src/HYDROGUI/HYDROGUI_ZLevelsOp.h @@ -43,7 +43,8 @@ public: protected: virtual void startOperation(); - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); virtual void processCancel(); private: diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 4dbe13fb..574b4dda 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -195,7 +195,7 @@ All supported formats (*.brep *.iges *.igs *.step *.stp) COORDINATES_INFO - X: %1, Y: %2 + Local CS: (%1, %2); Global CS: (%3, %4) POLYLINE3D_POLYLINE @@ -830,6 +830,10 @@ Would you like to remove all references from the image? DSK_ZLEVEL Change layer order + + DSK_EDIT_LOCAL_CS + Change local CS + MEN_CREATE_CALCULATION Create calculation case @@ -1078,6 +1082,10 @@ Would you like to remove all references from the image? MEN_ZLEVEL Change layer order + + MEN_EDIT_LOCAL_CS + Change local CS + STB_CREATE_CALCULATION Create calculation case @@ -1298,6 +1306,10 @@ Would you like to remove all references from the image? STB_ZLEVEL Change layer order + + STB_EDIT_LOCAL_CS + Change local CS + @@ -1620,6 +1632,14 @@ Would you like to remove all references from the image? + + HYDROGUI_LocalCSOp + + EDIT_LOCAL_CS + Local CS transformation + + + HYDROGUI_ImportGeomObjectOp 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.