From b1de05ae46af77d0b2692808e99af6404bd88a42 Mon Sep 17 00:00:00 2001 From: mkr Date: Thu, 4 Jun 2015 15:23:09 +0300 Subject: [PATCH] refs #562: add default Strickler coefficient into HYDRO module preferencies, implement duplicate operation for Strickler table objects. --- src/HYDROGUI/CMakeLists.txt | 2 + src/HYDROGUI/HYDROGUI_DataModel.cxx | 2 +- src/HYDROGUI/HYDROGUI_DuplicateOp.cxx | 72 +++++++++++++++++++++++ src/HYDROGUI/HYDROGUI_DuplicateOp.h | 37 ++++++++++++ src/HYDROGUI/HYDROGUI_Module.cxx | 11 +++- src/HYDROGUI/HYDROGUI_Operations.cxx | 5 ++ src/HYDROGUI/HYDROGUI_Operations.h | 3 +- src/HYDROGUI/resources/HYDROGUI_images.ts | 4 ++ src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 28 +++++++++ src/HYDROGUI/resources/LightApp.xml | 1 + 10 files changed, 162 insertions(+), 3 deletions(-) create mode 100644 src/HYDROGUI/HYDROGUI_DuplicateOp.cxx create mode 100644 src/HYDROGUI/HYDROGUI_DuplicateOp.h diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 62035c76..eeca42fc 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -23,6 +23,7 @@ set(PROJECT_HEADERS HYDROGUI_DigueDlg.h HYDROGUI_DigueOp.h HYDROGUI_Displayer.h + HYDROGUI_DuplicateOp.h HYDROGUI_ExportImageOp.h HYDROGUI_GVSelector.h HYDROGUI_ImagePrs.h @@ -139,6 +140,7 @@ set(PROJECT_SOURCES HYDROGUI_DigueDlg.cxx HYDROGUI_DigueOp.cxx HYDROGUI_Displayer.cxx + HYDROGUI_DuplicateOp.cxx HYDROGUI_ExportImageOp.cxx HYDROGUI_GVSelector.cxx HYDROGUI_ImagePrs.cxx diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index 366f9c78..c3df102e 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -681,7 +681,7 @@ QString HYDROGUI_DataModel::partitionName( const ObjectKind theObjectKind ) case KIND_OBSTACLE: return "OBSTACLES"; case KIND_ARTIFICIAL_OBJECT: return "ARTIFICIAL_OBJECTS"; case KIND_NATURAL_OBJECT: return "NATURAL_OBJECTS"; - case KIND_STRICKLER_TABLE: return "STRICKLER_TABLES"; + case KIND_STRICKLER_TABLE: return "STRICKLER_TABLES"; default: break; } return QString(); diff --git a/src/HYDROGUI/HYDROGUI_DuplicateOp.cxx b/src/HYDROGUI/HYDROGUI_DuplicateOp.cxx new file mode 100644 index 00000000..49797ab2 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_DuplicateOp.cxx @@ -0,0 +1,72 @@ +// Copyright (C) 2014-2015 EDF-R&D +// 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, or (at your option) any later version. +// +// 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_DuplicateOp.h" + +#include "HYDROGUI_DataModel.h" +#include "HYDROGUI_Module.h" +#include "HYDROGUI_UpdateFlags.h" + +HYDROGUI_DuplicateOp::HYDROGUI_DuplicateOp( HYDROGUI_Module* theModule ) +: HYDROGUI_Operation( theModule ) +{ + setName( tr( "DUPLICATE" ) ); +} + + +HYDROGUI_DuplicateOp::~HYDROGUI_DuplicateOp() +{ +} + +void HYDROGUI_DuplicateOp::startOperation() +{ + HYDROGUI_Operation::startOperation(); + + HYDROGUI_DataModel* aModel = module()->getDataModel(); + + bool anIsOk = false; + int aFlags = 0; + + // Copy object + anIsOk = aModel->copy(); + aFlags = UF_Controls; + if( !anIsOk ) + { + abort(); + return; + } + + // Paste object + startDocOperation(); + + anIsOk = aModel->paste(); + aFlags = UF_Controls | UF_Model; + + if( anIsOk ) + commitDocOperation(); + else + abortDocOperation(); + + if( anIsOk ) + { + module()->update( aFlags ); + commit(); + } + else + abort(); +} diff --git a/src/HYDROGUI/HYDROGUI_DuplicateOp.h b/src/HYDROGUI/HYDROGUI_DuplicateOp.h new file mode 100644 index 00000000..fe3a4f7d --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_DuplicateOp.h @@ -0,0 +1,37 @@ +// Copyright (C) 2014-2015 EDF-R&D +// 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, or (at your option) any later version. +// +// 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_DUPLICATEOP_H +#define HYDROGUI_DUPLICATEOP_H + +#include "HYDROGUI_Operation.h" + +class HYDROGUI_DuplicateOp : public HYDROGUI_Operation +{ + Q_OBJECT + +public: + HYDROGUI_DuplicateOp( HYDROGUI_Module* theModule ); + virtual ~HYDROGUI_DuplicateOp(); + +protected: + virtual void startOperation(); +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 2fadc911..0403a311 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -642,7 +642,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, else if( anIsStricklerTable ) { theMenu->addAction( action( EditStricklerTableId ) ); - theMenu->addAction( action( ExportStricklerTableFromFileId ) ); + theMenu->addAction( action( ExportStricklerTableFromFileId ) ); + theMenu->addAction( action( DuplicateStricklerTableId ) ); theMenu->addSeparator(); } else if( anIsVisualState && anIsObjectBrowser ) @@ -761,6 +762,14 @@ void HYDROGUI_Module::createPreferences() int viewerGroup = addPreference( tr( "PREF_GROUP_VIEWER" ), genTab ); addPreference( tr( "PREF_VIEWER_AUTO_FITALL" ), viewerGroup, LightApp_Preferences::Bool, "HYDRO", "auto_fit_all" ); + + int StricklerTableGroup = addPreference( tr( "PREF_GROUP_STRICKLER_TABLE" ), genTab ); + int defaultStricklerCoef = addPreference( tr( "PREF_DEFAULT_STRICKLER_COEFFICIENT" ), StricklerTableGroup, + LightApp_Preferences::DblSpin, "HYDRO", "default_strickler_coefficient" ); + setPreferenceProperty( defaultStricklerCoef, "precision", 2 ); + setPreferenceProperty( defaultStricklerCoef, "min", 0.00 ); + setPreferenceProperty( defaultStricklerCoef, "max", 1000000.00 ); + setPreferenceProperty( defaultStricklerCoef, "step", 0.01 ); } QCursor HYDROGUI_Module::getPrefEditCursor() const diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index abdbc312..3b4fedb1 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -58,6 +58,7 @@ #include "HYDROGUI_ProfileInterpolateOp.h" #include "HYDROGUI_SubmersibleOp.h" #include "HYDROGUI_StricklerTableOp.h" +#include "HYDROGUI_DuplicateOp.h" #include #include @@ -152,6 +153,7 @@ void HYDROGUI_Module::createActions() createAction( ImportStricklerTableFromFileId, "IMPORT_STRICKLER_TABLE", "IMPORT_STRICKLER_TABLE_ICO" ); createAction( ExportStricklerTableFromFileId, "EXPORT_STRICKLER_TABLE", "EXPORT_STRICKLER_TABLE_ICO" ); createAction( EditStricklerTableId, "EDIT_STRICKLER_TABLE", "EDIT_STRICKLER_TABLE_ICO" ); + createAction( DuplicateStricklerTableId, "DUPLICATE_STRICKLER_TABLE", "DUPLICATE_STRICKLER_TABLE_ICO" ); createAction( ImportObstacleFromFileId, "IMPORT_OBSTACLE_FROM_FILE", "IMPORT_OBSTACLE_FROM_FILE_ICO" ); createAction( ImportGeomObjectAsObstacleId, "IMPORT_GEOM_OBJECT_AS_OBSTACLE", "IMPORT_GEOM_OBJECT_ICO" ); @@ -481,6 +483,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const case EditStricklerTableId: anOp = new HYDROGUI_StricklerTableOp( aModule, theId == EditStricklerTableId ); break; + case DuplicateStricklerTableId: + anOp = new HYDROGUI_DuplicateOp( aModule ); + 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 0bbde201..504a9ef8 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -113,7 +113,8 @@ enum OperationId ImportStricklerTableFromFileId, ExportStricklerTableFromFileId, - EditStricklerTableId + EditStricklerTableId, + DuplicateStricklerTableId }; diff --git a/src/HYDROGUI/resources/HYDROGUI_images.ts b/src/HYDROGUI/resources/HYDROGUI_images.ts index 7eed358d..9da19b5c 100644 --- a/src/HYDROGUI/resources/HYDROGUI_images.ts +++ b/src/HYDROGUI/resources/HYDROGUI_images.ts @@ -354,6 +354,10 @@ EDIT_STRICKLER_TABLE_ICO icon_edit_strickler_table.png + + DUPLICATE_STRICKLER_TABLE_ICO + icon_edit_strickler_table.png + IMPORT_OBSTACLE_FROM_FILE_ICO diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 5022b7ee..e07fd228 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -253,6 +253,14 @@ All supported formats (*.brep *.iges *.igs *.step *.stp) PREF_VIEWER_AUTO_FITALL Make automatic fit all after show object operation + + PREF_GROUP_STRICKLER_TABLE + Strickler table + + + PREF_DEFAULT_STRICKLER_COEFFICIENT + Default Strickler coefficient + STRICKLER_TABLE_FILTER Strickler table files (*.txt);;All files (*.* *) @@ -399,6 +407,14 @@ All supported formats (*.brep *.iges *.igs *.step *.stp) + + HYDROGUI_DuplicateOp + + DUPLICATE + Duplicate + + + HYDROGUI_CopyPastePositionOp @@ -766,6 +782,10 @@ Would you like to remove all references from the image? DSK_EDIT_STRICKLER_TABLE Edit Strickler table + + DSK_DUPLICATE_STRICKLER_TABLE + Duplicate Strickler table + DSK_COPY Copy @@ -1014,6 +1034,10 @@ Would you like to remove all references from the image? MEN_EDIT_STRICKLER_TABLE Edit Strickler table + + MEN_DUPLICATE_STRICKLER_TABLE + Duplicate Strickler table + MEN_CUT_IMAGES Cut images @@ -1286,6 +1310,10 @@ Would you like to remove all references from the image? STB_EDIT_STRICKLER_TABLE Edit Strickler table + + STB_DUPLICATE_STRICKLER_TABLE + Duplicate Strickler table + STB_COPY Copy diff --git a/src/HYDROGUI/resources/LightApp.xml b/src/HYDROGUI/resources/LightApp.xml index dbd15586..c7dc8b35 100644 --- a/src/HYDROGUI/resources/LightApp.xml +++ b/src/HYDROGUI/resources/LightApp.xml @@ -44,5 +44,6 @@
+
-- 2.39.2