From 2a8f1dac890bd9eb0b401687408e2545c3f46f17 Mon Sep 17 00:00:00 2001 From: asl Date: Mon, 11 Aug 2014 07:37:52 +0000 Subject: [PATCH] refs #369: support of local CS --- src/HYDROData/HYDROData_Document.cxx | 37 +++++++++++++++++++++++ src/HYDROData/HYDROData_Document.h | 5 +++ src/HYDROGUI/CMakeLists.txt | 4 +++ src/HYDROGUI/HYDROGUI_Module.cxx | 15 +++++++++ src/HYDROGUI/HYDROGUI_Operations.cxx | 6 ++++ src/HYDROGUI/HYDROGUI_Operations.h | 1 + src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 20 ++++++++++++ 7 files changed, 88 insertions(+) diff --git a/src/HYDROData/HYDROData_Document.cxx b/src/HYDROData/HYDROData_Document.cxx index eea22c6d..788b5527 100644 --- a/src/HYDROData/HYDROData_Document.cxx +++ b/src/HYDROData/HYDROData_Document.cxx @@ -5,9 +5,13 @@ #include #include +#include #include +#include +#include + #include #include #include @@ -23,6 +27,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; @@ -661,3 +667,34 @@ TDF_Label HYDROData_Document::LabelOfObjects() { return myDoc->Main().FindChild(TAG_OBJECTS); } + +TDF_Label HYDROData_Document::LabelOfLocalCS() const +{ + return myDoc->Main().FindChild(TAG_LOCAL_CS); +} + +gp_Pnt2d HYDROData_Document::GetLocalCS() const +{ + TDF_Label aLocalCSLab = LabelOfLocalCS(); + + Handle( TDataXtd_Position ) aLocalCS; + if( aLocalCSLab.FindAttribute( TDataXtd_Position::GetID(), aLocalCS ) ) + { + gp_Pnt aLocalCS3d = aLocalCS->GetPosition(); + return gp_Pnt2d( aLocalCS3d.X(), aLocalCS3d.Y() ); + } + else + return DEFAULT_LOCAL_CS; +} + +void HYDROData_Document::SetLocalCS( const gp_Pnt2d& theLocalCS ) +{ + 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 ); + aLocalCS->SetPosition( aLocalCS3d ); +} diff --git a/src/HYDROData/HYDROData_Document.h b/src/HYDROData/HYDROData_Document.h index ffdaf981..2ed1acd7 100644 --- a/src/HYDROData/HYDROData_Document.h +++ b/src/HYDROData/HYDROData_Document.h @@ -7,6 +7,7 @@ #include class QFile; +class gp_Pnt2d; /** * Errors that could appear on document open/save actions. @@ -123,6 +124,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& ); public: @@ -194,6 +197,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 diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 212a5153..26bb74a6 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -30,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 @@ -125,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_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 5e03c129..aaa13984 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 ) 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/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 4dbe13fb..781e984b 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -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 -- 2.39.2