#include <HYDROData_Tool.h>
#include <TDataStd_Integer.hxx>
+#include <TDataXtd_Position.hxx>
#include <TDF_Delta.hxx>
+#include <gp_Pnt2d.hxx>
+#include <gp_Pnt.hxx>
+
#include <QFile>
#include <QStringList>
#include <QTextStream>
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;
{
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 );
+}
#include <TDocStd_Document.hxx>
class QFile;
+class gp_Pnt2d;
/**
* Errors that could appear on document open/save actions.
//! Removes the order of objects presentation.
HYDRODATA_EXPORT void RemoveObjectsLayerOrder();
+ HYDRODATA_EXPORT gp_Pnt2d GetLocalCS() const;
+ HYDRODATA_EXPORT void SetLocalCS( const gp_Pnt2d& );
public:
//! 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
HYDROGUI_ImportImageDlg.h
HYDROGUI_ImportImageOp.h
HYDROGUI_InputPanel.h
+ HYDROGUI_LocalCSDlg.h
+ HYDROGUI_LocalCSOp.h
HYDROGUI_Module.h
HYDROGUI_NameValidator.h
HYDROGUI_ObjSelector.h
HYDROGUI_ImportImageDlg.cxx
HYDROGUI_ImportImageOp.cxx
HYDROGUI_InputPanel.cxx
+ HYDROGUI_LocalCSDlg.cxx
+ HYDROGUI_LocalCSOp.cxx
HYDROGUI_Module.cxx
HYDROGUI_NameValidator.cxx
HYDROGUI_ObjSelector.cxx
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<LightApp_Study*>( getApp()->activeStudy() );
+ if( aStudy )
+ isRoot = aStudy->isComponent( anEntry );
+ }
// Check the selected GEOM objects (take into account the Object Browser only)
if ( anIsObjectBrowser ) {
theMenu->addSeparator();
theMenu->addAction( action( CopyViewerPositionId ) );
}
+
+ if( isRoot )
+ theMenu->addAction( action( EditLocalCSId ) );
}
void HYDROGUI_Module::update( const int flags )
#include "HYDROGUI_BathymetryBoundsOp.h"
#include "HYDROGUI_Tool.h"
#include "HYDROGUI_ZLevelsOp.h"
+#include "HYDROGUI_LocalCSOp.h"
#include <HYDROData_Document.h>
#include <HYDROData_Obstacle.h>
createAction( SetColorId, "COLOR" );
createAction( SetZLevelId, "ZLEVEL" );
+ createAction( EditLocalCSId, "EDIT_LOCAL_CS" );
createAction( ShowId, "SHOW" );
createAction( ShowOnlyId, "SHOW_ONLY" );
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 );
case SetZLevelId:
anOp = new HYDROGUI_ZLevelsOp( aModule );
break;
+ case EditLocalCSId:
+ anOp = new HYDROGUI_LocalCSOp( aModule );
+ break;
case ShowId:
case ShowOnlyId:
case ShowAllId:
SetColorId,
SetZLevelId,
+ EditLocalCSId,
};
<source>DSK_ZLEVEL</source>
<translation>Change layer order</translation>
</message>
+ <message>
+ <source>DSK_EDIT_LOCAL_CS</source>
+ <translation>Change local CS</translation>
+ </message>
<message>
<source>MEN_CREATE_CALCULATION</source>
<translation>Create calculation case</translation>
<source>MEN_ZLEVEL</source>
<translation>Change layer order</translation>
</message>
+ <message>
+ <source>MEN_EDIT_LOCAL_CS</source>
+ <translation>Change local CS</translation>
+ </message>
<message>
<source>STB_CREATE_CALCULATION</source>
<translation>Create calculation case</translation>
<source>STB_ZLEVEL</source>
<translation>Change layer order</translation>
</message>
+ <message>
+ <source>STB_EDIT_LOCAL_CS</source>
+ <translation>Change local CS</translation>
+ </message>
</context>
<context>
</message>
</context>
+ <context>
+ <name>HYDROGUI_LocalCSOp</name>
+ <message>
+ <source>EDIT_LOCAL_CS</source>
+ <translation>Local CS transformation</translation>
+ </message>
+ </context>
+
<context>
<name>HYDROGUI_ImportGeomObjectOp</name>
<message>