]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #562: add default Strickler coefficient into HYDRO module preferencies, implemen...
authormkr <mkr@opencascade.com>
Thu, 4 Jun 2015 12:23:09 +0000 (15:23 +0300)
committermkr <mkr@opencascade.com>
Thu, 4 Jun 2015 12:23:09 +0000 (15:23 +0300)
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_DataModel.cxx
src/HYDROGUI/HYDROGUI_DuplicateOp.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_DuplicateOp.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_Operations.h
src/HYDROGUI/resources/HYDROGUI_images.ts
src/HYDROGUI/resources/HYDROGUI_msg_en.ts
src/HYDROGUI/resources/LightApp.xml

index 62035c763c82937550b068979db04b3e660eac33..eeca42fc8ee51801686f004f4d28703c403e27e3 100644 (file)
@@ -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
index 366f9c789b98fb52a0ec099edb072a925363bee0..c3df102e51541658c744473e3c7b9c72eb063af8 100644 (file)
@@ -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 (file)
index 0000000..49797ab
--- /dev/null
@@ -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 (file)
index 0000000..fe3a4f7
--- /dev/null
@@ -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
index 2fadc91100629997bd96d46f12c3e9e606e4539f..0403a311edc6133b8154e264d6202a5c9a4e9da7 100644 (file)
@@ -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
index abdbc312404bc11dd2d0b9e83ea78c12ef44307c..3b4fedb19406940175ab96edc1367cdb1c469b08 100644 (file)
@@ -58,6 +58,7 @@
 #include "HYDROGUI_ProfileInterpolateOp.h"
 #include "HYDROGUI_SubmersibleOp.h"
 #include "HYDROGUI_StricklerTableOp.h"
+#include "HYDROGUI_DuplicateOp.h"
 
 #include <HYDROData_Document.h>
 #include <HYDROData_Obstacle.h>
@@ -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 );
index 0bbde201fbcd5ef9a3d0e068778de286e4279175..504a9ef89ff88ac2e6f8b041fb6c372e107cf8e7 100644 (file)
@@ -113,7 +113,8 @@ enum OperationId
 
   ImportStricklerTableFromFileId,
   ExportStricklerTableFromFileId,
-  EditStricklerTableId
+  EditStricklerTableId,
+  DuplicateStricklerTableId
 
 };
 
index 7eed358d8cd8ca9c504f35f4eabca5a667bed68f..9da19b5ce549c0cb688e7def2232447b9f8451c1 100644 (file)
       <source>EDIT_STRICKLER_TABLE_ICO</source>
       <translation>icon_edit_strickler_table.png</translation>
     </message>
+    <message>
+      <source>DUPLICATE_STRICKLER_TABLE_ICO</source>
+      <translation>icon_edit_strickler_table.png</translation>
+    </message>
 
     <message>
       <source>IMPORT_OBSTACLE_FROM_FILE_ICO</source>
index 5022b7eef227f5eb5e292b1e832c3f4b6eed35f7..e07fd2289f79935d7ee0102da7014917c818c8d1 100644 (file)
@@ -253,6 +253,14 @@ All supported formats (*.brep *.iges *.igs *.step *.stp)</translation>
       <source>PREF_VIEWER_AUTO_FITALL</source>
       <translation>Make automatic fit all after show object operation</translation>
     </message>
+    <message>
+      <source>PREF_GROUP_STRICKLER_TABLE</source>
+      <translation>Strickler table</translation>
+    </message>
+    <message>
+      <source>PREF_DEFAULT_STRICKLER_COEFFICIENT</source>
+      <translation>Default Strickler coefficient</translation>
+    </message>
     <message>
       <source>STRICKLER_TABLE_FILTER</source>
       <translation>Strickler table files (*.txt);;All files (*.* *)</translation>
@@ -399,6 +407,14 @@ All supported formats (*.brep *.iges *.igs *.step *.stp)</translation>
     </message>
   </context>
 
+  <context>
+    <name>HYDROGUI_DuplicateOp</name>
+    <message>
+      <source>DUPLICATE</source>
+      <translation>Duplicate</translation>
+    </message>
+  </context>
+
   <context>
     <name>HYDROGUI_CopyPastePositionOp</name>
     <message>
@@ -766,6 +782,10 @@ Would you like to remove all references from the image?</translation>
       <source>DSK_EDIT_STRICKLER_TABLE</source>
       <translation>Edit Strickler table</translation>
     </message>
+    <message>
+      <source>DSK_DUPLICATE_STRICKLER_TABLE</source>
+      <translation>Duplicate Strickler table</translation>
+    </message>
     <message>
       <source>DSK_COPY</source>
       <translation>Copy</translation>
@@ -1014,6 +1034,10 @@ Would you like to remove all references from the image?</translation>
       <source>MEN_EDIT_STRICKLER_TABLE</source>
       <translation>Edit Strickler table</translation>
     </message>
+    <message>
+      <source>MEN_DUPLICATE_STRICKLER_TABLE</source>
+      <translation>Duplicate Strickler table</translation>
+    </message>
     <message>
       <source>MEN_CUT_IMAGES</source>
       <translation>Cut images</translation>
@@ -1286,6 +1310,10 @@ Would you like to remove all references from the image?</translation>
       <source>STB_EDIT_STRICKLER_TABLE</source>
       <translation>Edit Strickler table</translation>
     </message>
+    <message>
+      <source>STB_DUPLICATE_STRICKLER_TABLE</source>
+      <translation>Duplicate Strickler table</translation>
+    </message>
     <message>
       <source>STB_COPY</source>
       <translation>Copy</translation>
index dbd155861b4c3eaaad2404ebf648a5337d6ee39b..c7dc8b352a50d06294ed7efdb7edf2e7ad9973e3 100644 (file)
@@ -44,5 +44,6 @@
   </section>
   <section name="preferences" >
     <parameter name="type_of_cursor" value="2"/>
+    <parameter name="default_strickler_coefficient" value="0.00"/>
   </section>
 </document>