From 3f67da828864f8d27b0aea2828bc8f5c5aaa9808 Mon Sep 17 00:00:00 2001 From: adv Date: Fri, 6 Dec 2013 11:12:11 +0000 Subject: [PATCH] Create\Edit digue object implementation (Feature #192). --- src/HYDROData/HYDROData_Digue.cxx | 18 ++----- src/HYDROData/HYDROData_Digue.h | 18 ++----- src/HYDROGUI/CMakeLists.txt | 4 ++ src/HYDROGUI/HYDROGUI_ChannelDlg.h | 2 +- src/HYDROGUI/HYDROGUI_ChannelOp.cxx | 12 +++-- src/HYDROGUI/HYDROGUI_ChannelOp.h | 9 ++-- src/HYDROGUI/HYDROGUI_DigueDlg.cxx | 37 +++++++++++++ src/HYDROGUI/HYDROGUI_DigueDlg.h | 40 ++++++++++++++ src/HYDROGUI/HYDROGUI_DigueOp.cxx | 66 +++++++++++++++++++++++ src/HYDROGUI/HYDROGUI_DigueOp.h | 48 +++++++++++++++++ src/HYDROGUI/HYDROGUI_Module.cxx | 11 +++- src/HYDROGUI/HYDROGUI_Operations.cxx | 9 ++++ src/HYDROGUI/HYDROGUI_Operations.h | 3 ++ src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 48 +++++++++++++++++ 14 files changed, 286 insertions(+), 39 deletions(-) create mode 100644 src/HYDROGUI/HYDROGUI_DigueDlg.cxx create mode 100644 src/HYDROGUI/HYDROGUI_DigueDlg.h create mode 100644 src/HYDROGUI/HYDROGUI_DigueOp.cxx create mode 100644 src/HYDROGUI/HYDROGUI_DigueOp.h diff --git a/src/HYDROData/HYDROData_Digue.cxx b/src/HYDROData/HYDROData_Digue.cxx index 89c92a86..077d7e8b 100644 --- a/src/HYDROData/HYDROData_Digue.cxx +++ b/src/HYDROData/HYDROData_Digue.cxx @@ -9,12 +9,12 @@ #define PYTHON_DIGUE_ID "KIND_DIGUE" -IMPLEMENT_STANDARD_HANDLE(HYDROData_Digue,HYDROData_ArtificialObject) -IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Digue,HYDROData_ArtificialObject) +IMPLEMENT_STANDARD_HANDLE(HYDROData_Digue,HYDROData_Channel) +IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Digue,HYDROData_Channel) HYDROData_Digue::HYDROData_Digue() -: HYDROData_ArtificialObject() +: HYDROData_Channel() { } @@ -44,17 +44,5 @@ QStringList HYDROData_Digue::DumpToPython( MapOfTreatedObjects& theTreatedObject return aResList; } -TopoDS_Shape HYDROData_Digue::GetTopShape() const -{ - // TODO - return getTopShape(); -} - -TopoDS_Shape HYDROData_Digue::GetShape3D() const -{ - // TODO - return getShape3D(); -} - diff --git a/src/HYDROData/HYDROData_Digue.h b/src/HYDROData/HYDROData_Digue.h index 0b893d66..c4145d22 100644 --- a/src/HYDROData/HYDROData_Digue.h +++ b/src/HYDROData/HYDROData_Digue.h @@ -2,15 +2,15 @@ #ifndef HYDROData_Digue_HeaderFile #define HYDROData_Digue_HeaderFile -#include "HYDROData_ArtificialObject.h" +#include "HYDROData_Channel.h" -DEFINE_STANDARD_HANDLE(HYDROData_Digue, HYDROData_ArtificialObject) +DEFINE_STANDARD_HANDLE(HYDROData_Digue, HYDROData_Channel) /**\class HYDROData_Digue * \brief * */ -class HYDROData_Digue : public HYDROData_ArtificialObject +class HYDROData_Digue : public HYDROData_Channel { protected: /** @@ -18,7 +18,7 @@ protected: */ enum DataTag { - DataTag_First = HYDROData_ArtificialObject::DataTag_First + 100, ///< first tag, to reserve + DataTag_First = HYDROData_Channel::DataTag_First + 100, ///< first tag, to reserve }; public: @@ -34,16 +34,6 @@ public: */ HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const; - /** - * Returns the top shape of the object. - */ - HYDRODATA_EXPORT virtual TopoDS_Shape GetTopShape() const; - - /** - * Returns the 3d shape of the object. - */ - HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const; - protected: friend class HYDROData_Iterator; diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 2ac374ba..39ec2612 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -14,6 +14,8 @@ set(PROJECT_HEADERS HYDROGUI_DataModel.h HYDROGUI_DataObject.h HYDROGUI_DeleteOp.h + HYDROGUI_DigueDlg.h + HYDROGUI_DigueOp.h HYDROGUI_Displayer.h HYDROGUI_ExportImageOp.h HYDROGUI_GVSelector.h @@ -91,6 +93,8 @@ set(PROJECT_SOURCES HYDROGUI_DataModel.cxx HYDROGUI_DataObject.cxx HYDROGUI_DeleteOp.cxx + HYDROGUI_DigueDlg.cxx + HYDROGUI_DigueOp.cxx HYDROGUI_Displayer.cxx HYDROGUI_ExportImageOp.cxx HYDROGUI_GVSelector.cxx diff --git a/src/HYDROGUI/HYDROGUI_ChannelDlg.h b/src/HYDROGUI/HYDROGUI_ChannelDlg.h index 3e947208..40ecf6d7 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelDlg.h +++ b/src/HYDROGUI/HYDROGUI_ChannelDlg.h @@ -56,7 +56,7 @@ signals: private slots: void onChannelDefChanged(); -private: +protected: QGroupBox* myObjectNameGroup; QLineEdit* myObjectName; diff --git a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx index 493cee9b..4ccd4df4 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx @@ -68,10 +68,7 @@ void HYDROGUI_ChannelOp::startOperation() aPanel->reset(); - if( myIsEdit ) - myEditedObject = Handle(HYDROData_Channel)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); - else - myEditedObject = Handle(HYDROData_Channel)::DownCast( doc()->CreateObject( KIND_CHANNEL ) ); + myEditedObject = getObjectToEdit(); QString aSelectedGuideLine, aSelectedProfile; @@ -108,6 +105,7 @@ void HYDROGUI_ChannelOp::startOperation() onCreatePreview( true ); } + void HYDROGUI_ChannelOp::abortOperation() { erasePreview(); @@ -175,6 +173,12 @@ bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags, return true; } +Handle(HYDROData_Channel) HYDROGUI_ChannelOp::getObjectToEdit() const +{ + return myIsEdit ? Handle(HYDROData_Channel)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ) : + Handle(HYDROData_Channel)::DownCast( doc()->CreateObject( KIND_CHANNEL ) ); +} + void HYDROGUI_ChannelOp::onCreatePreview( const bool theIsInit ) { HYDROGUI_ChannelDlg* aPanel = ::qobject_cast( inputPanel() ); diff --git a/src/HYDROGUI/HYDROGUI_ChannelOp.h b/src/HYDROGUI/HYDROGUI_ChannelOp.h index f1456eeb..25f47a37 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelOp.h +++ b/src/HYDROGUI/HYDROGUI_ChannelOp.h @@ -49,12 +49,13 @@ protected: virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); protected slots: - void onCreatePreview( const bool theIsInit = false ); + virtual void onCreatePreview( const bool theIsInit = false ); -private: - void erasePreview(); +protected: + virtual void erasePreview(); + virtual Handle(HYDROData_Channel) getObjectToEdit() const; -private: +protected: bool myIsEdit; Handle(HYDROData_Channel) myEditedObject; diff --git a/src/HYDROGUI/HYDROGUI_DigueDlg.cxx b/src/HYDROGUI/HYDROGUI_DigueDlg.cxx new file mode 100644 index 00000000..3a20106c --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_DigueDlg.cxx @@ -0,0 +1,37 @@ +// 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 "HYDROGUI_DigueDlg.h" + +#include + +HYDROGUI_DigueDlg::HYDROGUI_DigueDlg( HYDROGUI_Module* theModule, const QString& theTitle ) +: HYDROGUI_ChannelDlg( theModule, theTitle ) +{ + if ( myObjectNameGroup ) + myObjectNameGroup->setTitle( tr( "DIGUE_NAME" ) ); +} + +HYDROGUI_DigueDlg::~HYDROGUI_DigueDlg() +{ +} + diff --git a/src/HYDROGUI/HYDROGUI_DigueDlg.h b/src/HYDROGUI/HYDROGUI_DigueDlg.h new file mode 100644 index 00000000..d3f9922a --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_DigueDlg.h @@ -0,0 +1,40 @@ +// 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_DigueDlg_H +#define HYDROGUI_DigueDlg_H + +#include "HYDROGUI_ChannelDlg.h" + +class HYDROGUI_DigueDlg : public HYDROGUI_ChannelDlg +{ + Q_OBJECT + +public: + + HYDROGUI_DigueDlg( HYDROGUI_Module* theModule, const QString& theTitle ); + virtual ~HYDROGUI_DigueDlg(); + +private: +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_DigueOp.cxx b/src/HYDROGUI/HYDROGUI_DigueOp.cxx new file mode 100644 index 00000000..d62b1630 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_DigueOp.cxx @@ -0,0 +1,66 @@ +// 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 "HYDROGUI_DigueOp.h" + +#include "HYDROGUI_DigueDlg.h" +#include "HYDROGUI_Tool.h" + +#include +#include + +HYDROGUI_DigueOp::HYDROGUI_DigueOp( HYDROGUI_Module* theModule, + const bool theIsEdit ) +: HYDROGUI_ChannelOp( theModule, theIsEdit ) +{ + setName( theIsEdit ? tr( "EDIT_DIGUE" ) : tr( "CREATE_DIGUE" ) ); +} + +HYDROGUI_DigueOp::~HYDROGUI_DigueOp() +{ +} + +void HYDROGUI_DigueOp::startOperation() +{ + HYDROGUI_ChannelOp::startOperation(); + + HYDROGUI_DigueDlg* aPanel = ::qobject_cast( inputPanel() ); + + if ( !myIsEdit || myEditedObject.IsNull() ) + { + QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_DIGUE_NAME" ) ); + aPanel->setObjectName( anObjectName ); + } +} + +HYDROGUI_InputPanel* HYDROGUI_DigueOp::createInputPanel() const +{ + HYDROGUI_DigueDlg* aPanel = new HYDROGUI_DigueDlg( module(), getName() ); + connect( aPanel, SIGNAL( CreatePreview() ), this, SLOT( onCreatePreview() ) ); + return aPanel; +} + +Handle(HYDROData_Channel) HYDROGUI_DigueOp::getObjectToEdit() const +{ + return myIsEdit ? Handle(HYDROData_Digue)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ) : + Handle(HYDROData_Digue)::DownCast( doc()->CreateObject( KIND_DIGUE ) ); +} diff --git a/src/HYDROGUI/HYDROGUI_DigueOp.h b/src/HYDROGUI/HYDROGUI_DigueOp.h new file mode 100644 index 00000000..87db05f8 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_DigueOp.h @@ -0,0 +1,48 @@ +// 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_DigueOp_H +#define HYDROGUI_DigueOp_H + +#include "HYDROGUI_ChannelOp.h" + +class HYDROGUI_DigueOp : public HYDROGUI_ChannelOp +{ + Q_OBJECT + +public: + HYDROGUI_DigueOp( HYDROGUI_Module* theModule, const bool theIsEdit ); + virtual ~HYDROGUI_DigueOp(); + +protected: + + virtual void startOperation(); + + virtual HYDROGUI_InputPanel* createInputPanel() const; + + virtual Handle(HYDROData_Channel) getObjectToEdit() const; + +private: + +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index ce333bb3..3c7a5e59 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -268,6 +268,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, bool anIsObstacle = false; bool anIsStream = false; bool anIsChannel = false; + bool anIsDigue = false; bool anIsGeomObject = false; // check the selected GEOM objects @@ -352,6 +353,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, anIsStream = true; else if( anObjectKind == KIND_CHANNEL ) anIsChannel = true; + else if( anObjectKind == KIND_DIGUE ) + anIsDigue = true; } anIsGeomObject = HYDROData_Tool::IsGeometryObject( anObject ); @@ -377,6 +380,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, break; case KIND_ARTIFICIAL_OBJECT: theMenu->addAction( action( CreateChannelId ) ); + theMenu->addAction( action( CreateDigueId ) ); break; case KIND_NATURAL_OBJECT: theMenu->addAction( action( CreateImmersibleZoneId ) ); @@ -490,6 +494,11 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, theMenu->addAction( action( EditChannelId ) ); theMenu->addSeparator(); } + else if( anIsDigue ) + { + theMenu->addAction( action( EditDigueId ) ); + theMenu->addSeparator(); + } else if( anIsVisualState && anIsObjectBrowser ) { theMenu->addAction( action( SaveVisualStateId ) ); @@ -514,7 +523,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, if( anIsImage || anIsPolyline || anIsPolyline3D || anIsImmersibleZone || anIsZone || anIsRegion || anIsBathymetry || anIsObstacle || anIsStream || - anIsChannel || anIsValidProfile ) + anIsChannel || anIsDigue || anIsValidProfile ) { if( anIsHiddenInSelection ) theMenu->addAction( action( ShowId ) ); diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index 7bfd0071..1114381a 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -27,6 +27,7 @@ #include "HYDROGUI_ChannelOp.h" #include "HYDROGUI_DataModel.h" #include "HYDROGUI_DeleteOp.h" +#include "HYDROGUI_DigueOp.h" #include "HYDROGUI_ExportImageOp.h" #include "HYDROGUI_ImportImageOp.h" #include "HYDROGUI_ImportBathymetryOp.h" @@ -135,6 +136,9 @@ void HYDROGUI_Module::createActions() createAction( CreateChannelId, "CREATE_CHANNEL", "CREATE_CHANNEL_ICO" ); createAction( EditChannelId, "EDIT_CHANNEL", "EDIT_CHANNEL_ICO" ); + createAction( CreateDigueId, "CREATE_DIGUE" ); + createAction( EditDigueId, "EDIT_DIGUE" ); + createAction( ImportObstacleFromFileId, "IMPORT_OBSTACLE_FROM_FILE", "IMPORT_OBSTACLE_FROM_FILE_ICO" ); createAction( ImportGeomObjectId, "IMPORT_GEOM_OBJECT", "IMPORT_GEOM_OBJECT_ICO" ); createAction( CreateBoxId, "CREATE_BOX", "CREATE_BOX_ICO" ); @@ -193,6 +197,7 @@ void HYDROGUI_Module::createMenus() int anArtificialMenuId = createMenu( tr( "MEN_DESK_ARTIFICIAL" ), aHydroId, -1 ); createMenu( CreateChannelId, anArtificialMenuId, -1, -1 ); + createMenu( CreateDigueId, anArtificialMenuId, -1, -1 ); int aNaturalMenuId = createMenu( tr( "MEN_DESK_NATURAL" ), aHydroId, -1 ); createMenu( CreateImmersibleZoneId, aNaturalMenuId, -1, -1 ); @@ -423,6 +428,10 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const case EditChannelId: anOp = new HYDROGUI_ChannelOp( aModule, theId == EditChannelId ); break; + case CreateDigueId: + case EditDigueId: + anOp = new HYDROGUI_DigueOp( aModule, theId == EditDigueId ); + break; case CreateCalculationId: case EditCalculationId: anOp = new HYDROGUI_CalculationOp( aModule, theId == EditCalculationId ); diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index 3344f3c9..e059fda8 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -68,6 +68,9 @@ enum OperationId CreateChannelId, EditChannelId, + CreateDigueId, + EditDigueId, + CreateCalculationId, EditCalculationId, ExportCalculationId, diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 5c4fc3de..9d8c7006 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -544,6 +544,14 @@ file cannot be correctly imported for a Bathymetry definition. DSK_EDIT_CHANNEL Edit channel + + DSK_CREATE_DIGUE + Create digue + + + DSK_EDIT_DIGUE + Edit digue + DSK_COPY Copy @@ -736,6 +744,14 @@ file cannot be correctly imported for a Bathymetry definition. MEN_EDIT_CHANNEL Edit channel + + MEN_CREATE_DIGUE + Create digue + + + MEN_EDIT_DIGUE + Edit digue + MEN_CUT_IMAGES Cut images @@ -944,6 +960,14 @@ file cannot be correctly imported for a Bathymetry definition. STB_EDIT_CHANNEL Edit channel + + STB_CREATE_DIGUE + Create digue + + + STB_EDIT_DIGUE + Edit digue + STB_COPY Copy @@ -1711,4 +1735,28 @@ Do you want to remove these profiles and continue? + + HYDROGUI_DigueDlg + + DIGUE_NAME + Digue name + + + + + HYDROGUI_DigueOp + + CREATE_DIGUE + Create digue + + + EDIT_DIGUE + Edit digue + + + DEFAULT_DIGUE_NAME + Digue + + + -- 2.39.2