]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #568: Land Cover: a draft of data model and implementation of dialog box and...
authormkr <mkr@opencascade.com>
Mon, 8 Jun 2015 09:13:47 +0000 (12:13 +0300)
committermkr <mkr@opencascade.com>
Mon, 8 Jun 2015 09:13:47 +0000 (12:13 +0300)
29 files changed:
src/HYDROData/CMakeLists.txt
src/HYDROData/HYDROData_Entity.cxx
src/HYDROData/HYDROData_Entity.h
src/HYDROData/HYDROData_Iterator.cxx
src/HYDROData/HYDROData_LandCover.cxx [new file with mode: 0644]
src/HYDROData/HYDROData_LandCover.h [new file with mode: 0644]
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_BasicZoneDlg.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_BasicZoneDlg.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_DataModel.cxx
src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.cxx
src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.h
src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx
src/HYDROGUI/HYDROGUI_LandCoverDlg.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_LandCoverDlg.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_LandCoverOp.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_LandCoverOp.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/icon_create_land_cover.png [new file with mode: 0644]
src/HYDROGUI/resources/icon_edit_land_cover.png [new file with mode: 0644]
src/HYDROGUI/resources/icon_edit_strickler_table.png
src/HYDROGUI/resources/icon_export_strickler_table.png
src/HYDROGUI/resources/icon_import_strickler_table.png
src/HYDROGUI/resources/icon_land_cover.png [new file with mode: 0644]
src/HYDROGUI/resources/icon_strickler_table.png

index 5447d2801589b5558e0dce2a35c02ce5acd83dd6..178f32004ceb25731236acef11c21de40b51dba2 100644 (file)
@@ -42,6 +42,7 @@ set(PROJECT_HEADERS
     HYDROData_Stream.h
     HYDROData_StreamAltitude.h
     HYDROData_StricklerTable.h
+       HYDROData_LandCover.h
     HYDROData_Tool.h
     HYDROData_Transform.h
     HYDROData_VisualState.h
@@ -94,6 +95,7 @@ set(PROJECT_SOURCES
     HYDROData_Stream.cxx
     HYDROData_StreamAltitude.cxx
     HYDROData_StricklerTable.cxx
+       HYDROData_LandCover.cxx
     HYDROData_Tool.cxx
     HYDROData_Transform.cxx
     HYDROData_VisualState.cxx
index f51b26441a7af17c3154fc787fb2422d15a7fda4..bd47a0901b01a77cefa535af91340f540d39da8c 100644 (file)
@@ -599,7 +599,8 @@ QString HYDROData_Entity::getPyTypeID() const
     case KIND_SPLITTED_GROUP:    return "KIND_SPLITTED_GROUP";
     case KIND_STREAM_ALTITUDE:   return "KIND_STREAM_ALTITUDE";
     case KIND_OBSTACLE_ALTITUDE: return "KIND_OBSTACLE_ALTITUDE";
-       case KIND_STRICKLER_TABLE:   return "KIND_STRICKLER_TABLE";
+    case KIND_STRICKLER_TABLE:   return "KIND_STRICKLER_TABLE";
+    case KIND_LAND_COVER:        return "KIND_LAND_COVER";
     default:                     return "KIND_UNKNOWN"; ///! Unrecognized object
   }
 }
index fd8640636908aebc1c39c040225e6c84734425d5..8e4937291bcf518b08e967f2bba8e24f7cf72ca9 100644 (file)
@@ -64,7 +64,8 @@ const ObjectKind KIND_SPLITTED_GROUP    = 23;
 const ObjectKind KIND_STREAM_ALTITUDE   = 24;
 const ObjectKind KIND_OBSTACLE_ALTITUDE = 25;
 const ObjectKind KIND_STRICKLER_TABLE   = 26;
-const ObjectKind KIND_LAST              = KIND_STRICKLER_TABLE;
+const ObjectKind KIND_LAND_COVER        = 27;
+const ObjectKind KIND_LAST              = KIND_LAND_COVER;
 
 DEFINE_STANDARD_HANDLE(HYDROData_Entity, MMgt_TShared)
 
index 18b3dffdf2fbbf0ba350cfe449e5eb0d65be053b..a52f932836fc2536b5be1dc6cba83c9ea9cc86c2 100644 (file)
@@ -42,6 +42,7 @@
 #include "HYDROData_StreamAltitude.h"
 #include "HYDROData_Zone.h"
 #include "HYDROData_StricklerTable.h"
+#include "HYDROData_LandCover.h"
 
 #include <TDataStd_Name.hxx>
 #include <TDataStd_NamedData.hxx>
@@ -150,7 +151,8 @@ Handle(HYDROData_Entity) HYDROData_Iterator::Object( const TDF_Label& theLabel )
     case KIND_SPLITTED_GROUP:     aResult = new HYDROData_SplittedShapesGroup();  break;
     case KIND_STREAM_ALTITUDE:    aResult = new HYDROData_StreamAltitude();       break;
     case KIND_OBSTACLE_ALTITUDE:  aResult = new HYDROData_ObstacleAltitude();     break;
-       case KIND_STRICKLER_TABLE:    aResult = new HYDROData_StricklerTable();       break;
+    case KIND_STRICKLER_TABLE:    aResult = new HYDROData_StricklerTable();       break;
+    case KIND_LAND_COVER:         aResult = new HYDROData_LandCover();            break;
     default:                                                                      break;
   }
 
diff --git a/src/HYDROData/HYDROData_LandCover.cxx b/src/HYDROData/HYDROData_LandCover.cxx
new file mode 100644 (file)
index 0000000..a671192
--- /dev/null
@@ -0,0 +1,36 @@
+// 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 "HYDROData_LandCover.h"
+
+IMPLEMENT_STANDARD_HANDLE( HYDROData_LandCover, HYDROData_Entity )
+IMPLEMENT_STANDARD_RTTIEXT( HYDROData_LandCover, HYDROData_Entity )
+
+HYDROData_LandCover::HYDROData_LandCover()
+{
+}
+
+
+HYDROData_LandCover::~HYDROData_LandCover()
+{
+}
+
+const ObjectKind HYDROData_LandCover::GetKind() const
+{
+  return KIND_LAND_COVER;
+}
diff --git a/src/HYDROData/HYDROData_LandCover.h b/src/HYDROData/HYDROData_LandCover.h
new file mode 100644 (file)
index 0000000..246208e
--- /dev/null
@@ -0,0 +1,45 @@
+// 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 HYDROData_LANDCOVER_HeaderFile
+#define HYDROData_LANDCOVER_HeaderFile
+
+#include <HYDROData_Entity.h>
+
+DEFINE_STANDARD_HANDLE( HYDROData_LandCover, HYDROData_Entity )
+
+class HYDROData_LandCover : public HYDROData_Entity
+{
+protected:
+  friend class HYDROData_Iterator;
+
+  enum DataTag
+  {
+    DataTag_Table = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
+  };
+
+  HYDRODATA_EXPORT HYDROData_LandCover();
+  HYDRODATA_EXPORT ~HYDROData_LandCover();
+
+public:
+  DEFINE_STANDARD_RTTI( HYDROData_LandCover );
+
+  HYDRODATA_EXPORT virtual const ObjectKind GetKind() const;
+};
+
+#endif
index eeca42fc8ee51801686f004f4d28703c403e27e3..b06c690810cd993cafb0e351ca1c516878954205 100644 (file)
@@ -27,6 +27,7 @@ set(PROJECT_HEADERS
     HYDROGUI_ExportImageOp.h
     HYDROGUI_GVSelector.h
     HYDROGUI_ImagePrs.h
+       HYDROGUI_BasicZoneDlg.h
     HYDROGUI_ImmersibleZoneDlg.h
     HYDROGUI_ImmersibleZoneOp.h
     HYDROGUI_ImportBathymetryDlg.h
@@ -74,6 +75,8 @@ set(PROJECT_HEADERS
     HYDROGUI_LineEditDoubleValidator.h
     HYDROGUI_StricklerTableDlg.h
     HYDROGUI_StricklerTableOp.h
+       HYDROGUI_LandCoverDlg.h
+       HYDROGUI_LandCoverOp.h
     HYDROGUI_SubmersibleOp.h
     HYDROGUI_Tool.h
     HYDROGUI_TwoImagesDlg.h
@@ -144,6 +147,7 @@ set(PROJECT_SOURCES
     HYDROGUI_ExportImageOp.cxx
     HYDROGUI_GVSelector.cxx
     HYDROGUI_ImagePrs.cxx
+       HYDROGUI_BasicZoneDlg.cxx
     HYDROGUI_ImmersibleZoneDlg.cxx
     HYDROGUI_ImmersibleZoneOp.cxx
     HYDROGUI_ImportBathymetryDlg.cxx
@@ -191,6 +195,8 @@ set(PROJECT_SOURCES
     HYDROGUI_LineEditDoubleValidator.cxx
     HYDROGUI_StricklerTableDlg.cxx
     HYDROGUI_StricklerTableOp.cxx
+       HYDROGUI_LandCoverDlg.cxx
+       HYDROGUI_LandCoverOp.cxx
     HYDROGUI_SubmersibleOp.cxx
     HYDROGUI_Tool.cxx
     HYDROGUI_TwoImagesDlg.cxx
diff --git a/src/HYDROGUI/HYDROGUI_BasicZoneDlg.cxx b/src/HYDROGUI/HYDROGUI_BasicZoneDlg.cxx
new file mode 100644 (file)
index 0000000..31af61f
--- /dev/null
@@ -0,0 +1,106 @@
+// 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_BasicZoneDlg.h"
+
+#include <QComboBox>
+#include <QGroupBox>
+#include <QLabel>
+#include <QLayout>
+#include <QLineEdit>
+
+HYDROGUI_BasicZoneDlg::HYDROGUI_BasicZoneDlg( HYDROGUI_Module* theModule, const QString& theTitle,
+                                              const QString& theLabel1, const QString& theLabel2,
+                                              const QString& theLabel3, const QString& theLabel4 )
+: HYDROGUI_InputPanel( theModule, theTitle )
+{
+  // Zone name
+  myObjectNameGroup = new QGroupBox( theLabel1, mainFrame() );
+
+  myObjectName = new QLineEdit( myObjectNameGroup );
+
+  QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
+  aNameLayout->setMargin( 5 );
+  aNameLayout->setSpacing( 5 );
+  aNameLayout->addWidget( new QLabel( theLabel2, myObjectNameGroup ) );
+  aNameLayout->addWidget( myObjectName );
+
+  // Main parameters: group-box and frame
+  myParamGroup = new QGroupBox( theLabel3, mainFrame() );
+
+  myPolylineFrame = new QFrame( myParamGroup );
+
+  // Additional parameter defined with help of combo-box control
+  myAdditionalParamsGroup = new QGroupBox( theLabel4, mainFrame() );
+
+  myAdditionalParams = new QComboBox( myPolylineFrame );
+  myAdditionalParams->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+  QBoxLayout* aBathLayout = new QHBoxLayout( myAdditionalParamsGroup );
+  aBathLayout->setMargin( 5 );
+  aBathLayout->setSpacing( 5 );
+  aBathLayout->addWidget( myAdditionalParams );
+
+  // Common
+  addWidget( myObjectNameGroup );
+  addWidget( myParamGroup );
+  addWidget( myAdditionalParamsGroup );
+
+  addStretch();  
+}
+
+HYDROGUI_BasicZoneDlg::~HYDROGUI_BasicZoneDlg()
+{
+}
+
+void HYDROGUI_BasicZoneDlg::reset()
+{
+  myObjectName->clear();
+  myAdditionalParams->clear();  
+}
+
+void HYDROGUI_BasicZoneDlg::setObjectName( const QString& theName )
+{
+  myObjectName->setText( theName );
+}
+
+QString HYDROGUI_BasicZoneDlg::getObjectName() const
+{
+  return myObjectName->text();
+}
+
+void HYDROGUI_BasicZoneDlg::setAdditionalParams( const QStringList& thePrams )
+{
+  bool isBlocked = blockSignals( true );
+
+  myAdditionalParams->clear();
+  myAdditionalParams->addItems( thePrams );
+
+  blockSignals( isBlocked );
+}
+
+void HYDROGUI_BasicZoneDlg::setSelectedAdditionalParamName( const QString& theParam )
+{
+  int aNewIdx = myAdditionalParams->findText( theParam );
+  myAdditionalParams->setCurrentIndex( aNewIdx );
+}
+
+QString HYDROGUI_BasicZoneDlg::getSelectedAdditionalParamName() const
+{
+  return myAdditionalParams->currentText();
+}
diff --git a/src/HYDROGUI/HYDROGUI_BasicZoneDlg.h b/src/HYDROGUI/HYDROGUI_BasicZoneDlg.h
new file mode 100644 (file)
index 0000000..b89e1ca
--- /dev/null
@@ -0,0 +1,59 @@
+// 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_BASICZONEDLG_H
+#define HYDROGUI_BASICZONEDLG_H
+
+#include "HYDROGUI_InputPanel.h"
+
+class QComboBox;
+class QGroupBox;
+class QLineEdit;
+class QFrame;
+
+class HYDROGUI_BasicZoneDlg : public HYDROGUI_InputPanel
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_BasicZoneDlg( HYDROGUI_Module* theModule, const QString& theTitle,
+                         const QString& theLabel1, const QString& theLabel2,
+                         const QString& theLabel3, const QString& theLabel4 );
+  virtual ~HYDROGUI_BasicZoneDlg();
+
+  virtual void           reset();
+
+  void                   setObjectName( const QString& theName );
+  QString                getObjectName() const;
+
+  void                   setAdditionalParams( const QStringList& thePrams );
+  void                   setSelectedAdditionalParamName( const QString& theParam );
+  QString                getSelectedAdditionalParamName() const;
+
+protected:
+  QGroupBox*             myObjectNameGroup;
+  QLineEdit*             myObjectName;
+
+  QGroupBox*             myParamGroup;
+  QFrame*                myPolylineFrame;
+
+  QGroupBox*             myAdditionalParamsGroup;
+  QComboBox*             myAdditionalParams; // bathymetries or strickler types
+};
+
+#endif
index c3df102e51541658c744473e3c7b9c72eb063af8..b6537bfed6dc4f6023aa1062d4b6683cb930ae64 100644 (file)
@@ -44,6 +44,7 @@
 #include <HYDROData_River.h>
 #include <HYDROData_Stream.h>
 #include <HYDROData_StricklerTable.h>
+#include <HYDROData_LandCover.h>
 
 #include <CAM_Module.h>
 #include <CAM_Study.h>
@@ -271,6 +272,9 @@ void HYDROGUI_DataModel::update( const int theStudyId )
   // STRICKLER TABLES
   LightApp_DataObject* aStricklerTablesRootObj = createObject( aNewRootObj, tr( partitionName( KIND_STRICKLER_TABLE ).toAscii() ) );
 
+  // LAND COVERS
+  LightApp_DataObject* aLandCoversRootObj = createObject( aNewRootObj, tr( partitionName( KIND_LAND_COVER ).toAscii() ) );
+
   // CALCULATION CASES
   LightApp_DataObject* aCalculRootObj = createObject( aNewRootObj, tr( partitionName( KIND_CALCULATION ).toAscii() ) );
 
@@ -375,14 +379,24 @@ void HYDROGUI_DataModel::update( const int theStudyId )
 
           break;
         }
-               case KIND_STRICKLER_TABLE:
+        case KIND_STRICKLER_TABLE:
         {
-          Handle(HYDROData_StricklerTable) anStricklerTableObj =
+          Handle(HYDROData_StricklerTable) aStricklerTableObj =
             Handle(HYDROData_StricklerTable)::DownCast( anObj );
-          if( !anStricklerTableObj.IsNull() ) {
-            obj = createObject( aStricklerTablesRootObj, anStricklerTableObj );
+          if( !aStricklerTableObj.IsNull() ) {
+            obj = createObject( aStricklerTablesRootObj, aStricklerTableObj );
+          }
+          aNoStricklerTableObj++;
+
+          break;
+        }
+        case KIND_LAND_COVER:
+        {
+          Handle(HYDROData_LandCover) aLandCoverObj =
+            Handle(HYDROData_LandCover)::DownCast( anObj );
+          if( !aLandCoverObj.IsNull() ) {
+            obj = createObject( aLandCoversRootObj, aLandCoverObj );
           }
-                 aNoStricklerTableObj++;
 
           break;
         }
@@ -682,6 +696,7 @@ QString HYDROGUI_DataModel::partitionName( const ObjectKind theObjectKind )
     case KIND_ARTIFICIAL_OBJECT: return "ARTIFICIAL_OBJECTS";
     case KIND_NATURAL_OBJECT:    return "NATURAL_OBJECTS";
     case KIND_STRICKLER_TABLE:   return "STRICKLER_TABLES";
+    case KIND_LAND_COVER:        return "LAND_COVERS";
     default: break;
   }
   return QString();
@@ -779,25 +794,25 @@ void HYDROGUI_DataModel::createDefaultStricklerTable( const Handle(HYDROData_Doc
                                                       LightApp_DataObject*              theParent )
 {
   // Create default Strickler table object
-  Handle(HYDROData_StricklerTable) anStricklerTableObj =
+  Handle(HYDROData_StricklerTable) aStricklerTableObj =
     Handle(HYDROData_StricklerTable)::DownCast( theDocument->CreateObject(KIND_STRICKLER_TABLE) );     
-  if ( !anStricklerTableObj.IsNull() )
+  if ( !aStricklerTableObj.IsNull() )
   {
-    anStricklerTableObj->Import( HYDROGUI_Tool::ToAsciiString( tr( "DEFAULT_STRICKLER_TABLE_FILE" ) ) );
-       // Set name
+    aStricklerTableObj->Import( HYDROGUI_Tool::ToAsciiString( tr( "DEFAULT_STRICKLER_TABLE_FILE" ) ) );
+    // Set name
     QString aStricklerTableName;
-    if ( anStricklerTableObj->GetName().isEmpty() )
+    if ( aStricklerTableObj->GetName().isEmpty() )
     {
       HYDROGUI_Module* aModule = dynamic_cast<HYDROGUI_Module*>( module() );
       if ( aModule )
         aStricklerTableName = HYDROGUI_Tool::GenerateObjectName( aModule, tr( "DEFAULT_STRICKLER_TABLE_NAME" ) );
     }
-    if ( anStricklerTableObj->GetName() != aStricklerTableName )
-      anStricklerTableObj->SetName( aStricklerTableName );
+    if ( aStricklerTableObj->GetName() != aStricklerTableName )
+      aStricklerTableObj->SetName( aStricklerTableName );
 
-    anStricklerTableObj->Update();
+    aStricklerTableObj->Update();
 
-    LightApp_DataObject* obj = createObject( theParent, anStricklerTableObj );
+    LightApp_DataObject* obj = createObject( theParent, aStricklerTableObj );
   }
 }
 
index 000c49078e2b5212e10d44958622eff0ef48a5b9..85130b2a2098a8e8ed946788a525b3aabf8890fb 100644 (file)
 #include <QGroupBox>
 #include <QLabel>
 #include <QLayout>
-#include <QLineEdit>
 
 HYDROGUI_ImmersibleZoneDlg::HYDROGUI_ImmersibleZoneDlg( HYDROGUI_Module* theModule, const QString& theTitle )
-: HYDROGUI_InputPanel( theModule, theTitle )
+: HYDROGUI_BasicZoneDlg( theModule, theTitle,
+                         tr( "ZONE_NAME" ), tr( "NAME" ),
+                         tr( "ZONE_PARAMETERS" ), tr( "ZONE_BATHYMETRY" ) )
 {
-  // Zone name
-  myObjectNameGroup = new QGroupBox( tr( "ZONE_NAME" ), mainFrame() );
-
-  myObjectName = new QLineEdit( myObjectNameGroup );
-
-  QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
-  aNameLayout->setMargin( 5 );
-  aNameLayout->setSpacing( 5 );
-  aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
-  aNameLayout->addWidget( myObjectName );
-
-
-  QGroupBox* aParamGroup = new QGroupBox( tr( "ZONE_PARAMETERS" ), mainFrame() );
-
-  QFrame* aPolylineFrame = new QFrame( aParamGroup );
-
-  myPolylines = new QComboBox( aPolylineFrame );
+  myPolylines = new QComboBox( myPolylineFrame );
   myPolylines->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
 
-  QBoxLayout* aPolyLayout = new QHBoxLayout( aPolylineFrame );
+  QBoxLayout* aPolyLayout = new QHBoxLayout( myPolylineFrame );
   aPolyLayout->setMargin( 0 );
   aPolyLayout->setSpacing( 5 );
-  aPolyLayout->addWidget( new QLabel( tr( "ZONE_POLYLINE" ), aPolylineFrame ) );
+  aPolyLayout->addWidget( new QLabel( tr( "ZONE_POLYLINE" ), myPolylineFrame ) );
   aPolyLayout->addWidget( myPolylines );
   
-  QBoxLayout* aParamLayout = new QVBoxLayout( aParamGroup );
+  QBoxLayout* aParamLayout = new QVBoxLayout( myParamGroup );
   aParamLayout->setMargin( 5 );
   aParamLayout->setSpacing( 5 );
-  aParamLayout->addWidget( aPolylineFrame );
-
-  QGroupBox* aBathGroup = new QGroupBox( tr( "ZONE_BATHYMETRY" ), mainFrame() );
-
-  myBathymetries = new QComboBox( aPolylineFrame );
-  myBathymetries->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
-
-  QBoxLayout* aBathLayout = new QHBoxLayout( aBathGroup );
-  aBathLayout->setMargin( 5 );
-  aBathLayout->setSpacing( 5 );
-  aBathLayout->addWidget( myBathymetries );
-
-
-  // Common
-  addWidget( myObjectNameGroup );
-  addWidget( aParamGroup );
-  addWidget( aBathGroup );
-
-  addStretch();
-
+  aParamLayout->addWidget( myPolylineFrame );
 
   // Connect signals and slots
   connect( myPolylines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onZoneDefChanged() ) );
@@ -90,26 +56,15 @@ void HYDROGUI_ImmersibleZoneDlg::reset()
 {
   bool isBlocked = blockSignals( true );
 
-  myObjectName->clear();
+  HYDROGUI_BasicZoneDlg::reset(); 
 
   myPolylines->clear();
-  myBathymetries->clear();
-
+  
   blockSignals( isBlocked );
 
   onZoneDefChanged();
 }
 
-void HYDROGUI_ImmersibleZoneDlg::setObjectName( const QString& theName )
-{
-  myObjectName->setText( theName );
-}
-
-QString HYDROGUI_ImmersibleZoneDlg::getObjectName() const
-{
-  return myObjectName->text();
-}
-
 void HYDROGUI_ImmersibleZoneDlg::setPolylineNames( const QStringList& thePolylines )
 {
   bool isBlocked = blockSignals( true );
@@ -138,27 +93,6 @@ QString HYDROGUI_ImmersibleZoneDlg::getPolylineName() const
   return myPolylines->currentText();
 }
 
-void HYDROGUI_ImmersibleZoneDlg::setBathymetryNames( const QStringList& theBathymetries )
-{
-  bool isBlocked = blockSignals( true );
-
-  myBathymetries->clear();
-  myBathymetries->addItems( theBathymetries );
-
-  blockSignals( isBlocked );
-}
-
-void HYDROGUI_ImmersibleZoneDlg::setBathymetryName( const QString& theName )
-{
-  int aNewIdx = myBathymetries->findText( theName );
-  myBathymetries->setCurrentIndex( aNewIdx );
-}
-
-QString HYDROGUI_ImmersibleZoneDlg::getBathymetryName() const
-{
-  return myBathymetries->currentText();
-}
-
 void HYDROGUI_ImmersibleZoneDlg::onZoneDefChanged()
 {
   if ( signalsBlocked() )
index ea64b763c291883e2630346937119e5078365a99..a7190f2cca93b06153d9a7d40f64416a44df1f9a 100644 (file)
 #ifndef HYDROGUI_ImmersibleZoneDlg_H
 #define HYDROGUI_ImmersibleZoneDlg_H
 
-#include "HYDROGUI_InputPanel.h"
+#include "HYDROGUI_BasicZoneDlg.h"
 
 class QComboBox;
-class QGroupBox;
-class QLineEdit;
 
-class HYDROGUI_ImmersibleZoneDlg : public HYDROGUI_InputPanel
+class HYDROGUI_ImmersibleZoneDlg : public HYDROGUI_BasicZoneDlg
 {
   Q_OBJECT
 
@@ -33,19 +31,12 @@ public:
   HYDROGUI_ImmersibleZoneDlg( HYDROGUI_Module* theModule, const QString& theTitle );
   virtual ~HYDROGUI_ImmersibleZoneDlg();
 
-  void                       reset();
-
-  void                       setObjectName( const QString& theName );
-  QString                    getObjectName() const;
+  virtual void               reset();
 
   void                       setPolylineNames( const QStringList& thePolylines );
   void                       setPolylineName( const QString& thePolyline );
   QString                    getPolylineName() const;
 
-  void                       setBathymetryNames( const QStringList& theBathymetries );
-  void                       setBathymetryName( const QString& theBathymetry );
-  QString                    getBathymetryName() const;
-
 signals:
   void                       CreatePreview( const QString& thePolylineName );
 
@@ -53,12 +44,7 @@ private slots:
   void                       onZoneDefChanged();
 
 private:
-
-  QGroupBox*                 myObjectNameGroup;
-  QLineEdit*                 myObjectName;
-
   QComboBox*                 myPolylines;
-  QComboBox*                 myBathymetries;
 };
 
 #endif
index dc674b74fc76634fbba524b1675c4aa6492807c2..678d8059680af73ba72bbc589df2d754c376232b 100644 (file)
@@ -96,12 +96,12 @@ void HYDROGUI_ImmersibleZoneOp::startOperation()
 
   aPanel->setObjectName( anObjectName );
   aPanel->setPolylineNames( HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_POLYLINEXY ) );
-  aPanel->setBathymetryNames( HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_BATHYMETRY ) );
+  aPanel->setAdditionalParams( HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_BATHYMETRY ) );
 
   aPanel->blockSignals( false );
 
   aPanel->setPolylineName( aSelectedPolyline );
-  aPanel->setBathymetryName( aSelectedBathymetry );
+  aPanel->setSelectedAdditionalParamName( aSelectedBathymetry );
 }
 
 void HYDROGUI_ImmersibleZoneOp::abortOperation()
@@ -162,7 +162,7 @@ bool HYDROGUI_ImmersibleZoneOp::processApply( int& theUpdateFlags,
       HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINEXY ) );
   }
 
-  QString aBathymetryName = aPanel->getBathymetryName();
+  QString aBathymetryName = aPanel->getSelectedAdditionalParamName();
   if ( !aBathymetryName.isEmpty() )
   {
     aZoneBathymetry = Handle(HYDROData_Bathymetry)::DownCast(
diff --git a/src/HYDROGUI/HYDROGUI_LandCoverDlg.cxx b/src/HYDROGUI/HYDROGUI_LandCoverDlg.cxx
new file mode 100644 (file)
index 0000000..fabcc56
--- /dev/null
@@ -0,0 +1,125 @@
+// 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_LandCoverDlg.h"
+
+#include <QGroupBox>
+#include <QLabel>
+#include <QLayout>
+#include <QListWidget>
+
+HYDROGUI_LandCoverDlg::HYDROGUI_LandCoverDlg( HYDROGUI_Module* theModule, const QString& theTitle )
+: HYDROGUI_BasicZoneDlg( theModule, theTitle,
+                         tr( "LAND_COVER_NAME" ), tr( "NAME" ),
+                         tr( "LAND_COVER_PARAMETERS" ), tr( "LAND_COVER_STRICKLER_TYPE" ) )
+{
+  myPolylines = new QListWidget( myPolylineFrame );
+  myPolylines->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
+  myPolylines->setSelectionMode( QAbstractItemView::ExtendedSelection );
+
+  QBoxLayout* aPolyLayout = new QVBoxLayout( myPolylineFrame );
+  aPolyLayout->setMargin( 0 );
+  aPolyLayout->setSpacing( 5 );
+  aPolyLayout->addWidget( new QLabel( tr( "LAND_COVER_POLYLINES" ), myPolylineFrame ) );
+  aPolyLayout->addWidget( myPolylines );
+  
+  QBoxLayout* aParamLayout = new QVBoxLayout( myParamGroup );
+  aParamLayout->setMargin( 5 );
+  aParamLayout->setSpacing( 5 );
+  aParamLayout->addWidget( myPolylineFrame );
+
+  // Connect signals and slots
+  connect( myPolylines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onZoneDefChanged() ) );
+}
+
+HYDROGUI_LandCoverDlg::~HYDROGUI_LandCoverDlg()
+{
+}
+
+void HYDROGUI_LandCoverDlg::reset()
+{
+  bool isBlocked = blockSignals( true );
+
+  HYDROGUI_BasicZoneDlg::reset();
+
+  myPolylines->clear();
+  
+  blockSignals( isBlocked );
+
+  onZoneDefChanged();
+}
+
+void HYDROGUI_LandCoverDlg::setPolylineNames( const QStringList& thePolylines )
+{
+  bool isBlocked = blockSignals( true );
+
+  myPolylines->clear();
+  myPolylines->addItems( thePolylines );
+
+  blockSignals( isBlocked );
+}
+
+void HYDROGUI_LandCoverDlg::setSelectedPolylineNames( const QStringList& theSelectedPolylines )
+{
+  bool anUpdateNeeded = false;
+  for (int i =0; i< myPolylines->count(); i++)
+  {
+    QListWidgetItem* anItem = myPolylines->item( i );
+    if ( anItem )
+    {
+      bool aIsSelected = anItem->isSelected();
+      if ( theSelectedPolylines.contains( anItem->text() ) )
+      {
+        if ( !aIsSelected )
+        {
+          anUpdateNeeded = true;
+          anItem->setSelected( true );
+        }
+      }
+      else if ( aIsSelected )
+      {
+        anUpdateNeeded = true;
+        anItem->setSelected( false );
+      }
+    }
+  }
+
+  if ( anUpdateNeeded )
+    onZoneDefChanged();
+}
+
+QStringList HYDROGUI_LandCoverDlg::getSelectedPolylineNames() const
+{
+  QStringList aSelectedPolylines;
+
+  QList<QListWidgetItem*> aSelectedItems = myPolylines->selectedItems();
+  QList<QListWidgetItem*>::const_iterator anIt = aSelectedItems.begin(), aLast = aSelectedItems.end();
+  for( ; anIt!=aLast; anIt++ )
+    aSelectedPolylines.append( (*anIt)->text() );
+
+  return aSelectedPolylines;
+}
+
+void HYDROGUI_LandCoverDlg::onZoneDefChanged()
+{
+  if ( signalsBlocked() )
+    return;
+
+  QStringList aPolylineNames = getSelectedPolylineNames();
+  emit CreatePreview( aPolylineNames );
+}
diff --git a/src/HYDROGUI/HYDROGUI_LandCoverDlg.h b/src/HYDROGUI/HYDROGUI_LandCoverDlg.h
new file mode 100644 (file)
index 0000000..bb529fa
--- /dev/null
@@ -0,0 +1,50 @@
+// 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_LANDCOVERDLG_H
+#define HYDROGUI_LANDCOVERDLG_H
+
+#include "HYDROGUI_BasicZoneDlg.h"
+
+class QListWidget;
+
+class HYDROGUI_LandCoverDlg : public HYDROGUI_BasicZoneDlg
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_LandCoverDlg( HYDROGUI_Module* theModule, const QString& theTitle );
+  virtual ~HYDROGUI_LandCoverDlg();
+
+  virtual void               reset();
+
+  void                       setPolylineNames( const QStringList& thePolylines );
+  void                       setSelectedPolylineNames( const QStringList& theSelectedPolylines );
+  QStringList                getSelectedPolylineNames() const;
+
+signals:
+  void                       CreatePreview( const QStringList& thePolylineNames );
+
+private slots:
+  void                       onZoneDefChanged();
+
+private:
+  QListWidget*               myPolylines;
+};
+
+#endif
diff --git a/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx b/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx
new file mode 100644 (file)
index 0000000..d8b4fdc
--- /dev/null
@@ -0,0 +1,321 @@
+// 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_LandCoverOp.h"
+
+#include "HYDROGUI_LandCoverDlg.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Shape.h"
+#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_UpdateFlags.h"
+#include "HYDROGUI_DataObject.h"
+
+#include <HYDROData_PolylineXY.h>
+#include <HYDROData_Document.h>
+#include <HYDROData_Iterator.h>
+#include <HYDROData_StricklerTable.h>
+
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewModel.h>
+
+#include <LightApp_Application.h>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Wire.hxx>
+
+#include <QApplication>
+
+HYDROGUI_LandCoverOp::HYDROGUI_LandCoverOp( HYDROGUI_Module* theModule,
+                                            const bool theIsEdit )
+: HYDROGUI_Operation( theModule ),
+  myIsEdit( theIsEdit ),
+  myPreviewPrs( 0 )
+{
+  setName( theIsEdit ? tr( "EDIT_LAND_COVER" ) : tr( "CREATE_LAND_COVER" ) );
+}
+
+HYDROGUI_LandCoverOp::~HYDROGUI_LandCoverOp()
+{
+  closePreview();
+}
+
+void HYDROGUI_LandCoverOp::startOperation()
+{
+  HYDROGUI_Operation::startOperation();
+
+  HYDROGUI_LandCoverDlg* aPanel = ::qobject_cast<HYDROGUI_LandCoverDlg*>( inputPanel() );
+  if ( !aPanel )
+    return;
+
+  aPanel->blockSignals( true );
+
+  aPanel->reset();
+
+  QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_LAND_COVER_NAME" ) );
+
+  QStringList aSelectedPolylines;
+  QString     aSelectedStricklerType;
+
+  if ( myIsEdit )
+  {
+    if ( isApplyAndClose() )
+      myEditedObject = Handle(HYDROData_LandCover)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+    if ( !myEditedObject.IsNull() )
+    {
+      anObjectName = myEditedObject->GetName();
+
+      // TODO: Temporary commented until getPolylinesCount, GetPolyline and GetStricklerType data model methods will be implemented
+      /*
+      int nNoPolylines = myEditedObject->getPolylinesCount();
+      for (int i=0; i<nNoPolylines; i++)
+      {
+        Handle(HYDROData_PolylineXY) aRefPolyline = myEditedObject->GetPolyline(i);
+        if ( !aRefPolyline.IsNull() )
+          aSelectedPolylines.append( aRefPolyline->GetName() );
+      }
+
+      aSelectedStricklerType = myEditedObject->GetStricklerType();
+      */
+
+      // The code below is a sample of data filling Land cover object
+      aSelectedPolylines.append( "Lake_1" );
+      aSelectedPolylines.append( "Polyline_1" );
+      aSelectedStricklerType = "Canaux naturels";
+    }
+  }
+
+  aPanel->setObjectName( anObjectName );
+  aPanel->setPolylineNames( HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_POLYLINEXY ) );
+  // Construct a list of unique names of all Strickler types defined within the data model
+  QStringList aStricklerTypes;
+  HYDROData_Iterator anIterator( doc(), KIND_STRICKLER_TABLE );
+  for( ; anIterator.More(); anIterator.Next() )
+  {
+    Handle(HYDROData_StricklerTable) aStricklerTableObj =
+      Handle(HYDROData_StricklerTable)::DownCast( anIterator.Current() );      
+    if ( !aStricklerTableObj.IsNull() )
+    {
+      // TODO: implement GetTypes method in data model
+      //QStringList aTypes = aStricklerTableObj->GetTypes();
+      // The code below is a sample of data filling list of Strickler types
+      QStringList aTypes;
+      aTypes.append("Zones de champs, prairies, sans cultures");
+      aTypes.append("Canaux naturels");
+      aTypes.append("Zones à faible urbanization (bourg)");
+      QStringList::const_iterator anIt = aTypes.begin(), aLast = aTypes.end();
+      for( ; anIt!=aLast; anIt++ )
+      {
+        QString aType = *anIt;
+        if ( !aType.isEmpty() && !aStricklerTypes.contains( aType ))
+          aStricklerTypes.append( aType );
+      }
+    }
+  }
+  aStricklerTypes.sort();
+  aPanel->setAdditionalParams( aStricklerTypes );
+
+  aPanel->blockSignals( false );
+
+  aPanel->setSelectedPolylineNames( aSelectedPolylines );
+  aPanel->setSelectedAdditionalParamName( aSelectedStricklerType );
+}
+
+void HYDROGUI_LandCoverOp::abortOperation()
+{
+  closePreview();
+
+  HYDROGUI_Operation::abortOperation();
+}
+
+void HYDROGUI_LandCoverOp::commitOperation()
+{
+  closePreview();
+
+  HYDROGUI_Operation::commitOperation();
+}
+
+HYDROGUI_InputPanel* HYDROGUI_LandCoverOp::createInputPanel() const
+{
+  HYDROGUI_LandCoverDlg* aPanel = new HYDROGUI_LandCoverDlg( module(), getName() );
+  connect( aPanel, SIGNAL( CreatePreview( const QStringList& ) ),
+           this,   SLOT( onCreatePreview( const QStringList& ) ) );
+  return aPanel;
+}
+
+bool HYDROGUI_LandCoverOp::processApply( int& theUpdateFlags,
+                                         QString& theErrorMsg,
+                                         QStringList& theBrowseObjectsEntries )
+{
+  HYDROGUI_LandCoverDlg* aPanel = ::qobject_cast<HYDROGUI_LandCoverDlg*>( inputPanel() );
+  if ( !aPanel )
+    return false;
+
+  QString anObjectName = aPanel->getObjectName().simplified();
+  if ( anObjectName.isEmpty() )
+  {
+    theErrorMsg = tr( "INCORRECT_OBJECT_NAME" );
+    return false;
+  }
+
+  if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anObjectName ) )
+  {
+    // check that there are no other objects with the same name in the document
+    Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName );
+    if( !anObject.IsNull() )
+    {
+      theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName );
+      return false;
+    }
+  }
+
+  QList<Handle(HYDROData_PolylineXY)> aZonePolylines;
+  QString aStricklerType;
+
+  QStringList aSelectedPolylineNames = aPanel->getSelectedPolylineNames();
+  QStringList::const_iterator anIt = aSelectedPolylineNames.begin(), aLast = aSelectedPolylineNames.end();
+  for( ; anIt!=aLast; anIt++ )
+  {
+    QString aPolylineName = *anIt;
+    if ( !aPolylineName.isEmpty() )
+    {
+      aZonePolylines.append( Handle(HYDROData_PolylineXY)::DownCast(
+        HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINEXY ) ) );
+    }
+  }
+
+  QString aSelectedStricklerType = aPanel->getSelectedAdditionalParamName();
+  
+  // TODO: Generate TopoDS_Shape based on the set of polylines, implement generateTopShape data model method
+  /*
+  if ( HYDROData_LandCover::generateTopShape( aZonePolylines ).IsNull() )
+  {
+    theErrorMsg = tr( "ZONE_OBJECT_CANNOT_BE_CREATED" );
+    return false;
+  }
+  */
+
+  Handle(HYDROData_LandCover) aZoneObj = myIsEdit ? myEditedObject :
+    Handle(HYDROData_LandCover)::DownCast( doc()->CreateObject( KIND_LAND_COVER ) );
+
+  aZoneObj->SetName( anObjectName );
+
+  // TODO: Temporary commented until SetFillingColor, DefaultFillingColor,
+  // SetBorderColor and DefaultBorderColor data model methods will be implemented
+  /*
+  if ( !myIsEdit )
+  {    
+    aZoneObj->SetFillingColor( HYDROData_LandCover::DefaultFillingColor() );
+    aZoneObj->SetBorderColor( HYDROData_LandCover::DefaultBorderColor() );
+  }
+  */
+
+  // TODO: Temporary commented until SetPolylines and SetStricklerType data model methods will be implemented
+  //aZoneObj->SetPolylines( aZonePolylines );
+  //aZoneObj->SetStricklerType( aSelectedStricklerType );
+  aZoneObj->Update();
+
+  closePreview();
+
+  if( !myIsEdit )
+  {
+    module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aZoneObj, true );
+    QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aZoneObj );
+    theBrowseObjectsEntries.append( anEntry );
+  }
+
+  module()->setIsToUpdate( aZoneObj );
+
+  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
+
+  return true;
+}
+
+void HYDROGUI_LandCoverOp::onCreatePreview( const QStringList& thePolylineNames )
+{
+  HYDROGUI_LandCoverDlg* aPanel = ::qobject_cast<HYDROGUI_LandCoverDlg*>( inputPanel() );
+  if ( !aPanel )
+    return;
+
+  QApplication::setOverrideCursor( Qt::WaitCursor );  
+
+  QList<Handle(HYDROData_PolylineXY)> aZonePolylines;
+  QStringList::const_iterator anIt = thePolylineNames.begin(), aLast = thePolylineNames.end();
+  for( ; anIt!=aLast; anIt++ )
+  {
+    QString aPolylineName = *anIt;
+    Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast(
+      HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINEXY ) );
+    if ( !aPolyline.IsNull() )
+      aZonePolylines.append( aPolyline );
+  }
+
+  // TODO: Generate TopoDS_Shape based on the set of polylines, implement generateTopShape data model method  
+  TopoDS_Shape aZoneShape;/* = HYDROData_LandCover::generateTopShape( aZonePolylines );
+  if( aZoneShape.IsNull() )
+    printErrorMessage( tr( "ZONE_OBJECT_CANNOT_BE_CREATED" ) );
+  */
+
+  LightApp_Application* anApp = module()->getApp();
+  if ( !getPreviewManager() )
+    setPreviewManager( ::qobject_cast<OCCViewer_ViewManager*>( 
+                       anApp->getViewManager( OCCViewer_Viewer::Type(), true ) ) );
+  OCCViewer_ViewManager* aViewManager = getPreviewManager();
+  if ( aViewManager && !myPreviewPrs )
+  {
+    if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() )
+    {
+      Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
+      if ( !aCtx.IsNull() )
+        myPreviewPrs = new HYDROGUI_Shape( aCtx, NULL, getPreviewZLayer() );
+    }
+  }
+
+  if ( aViewManager && myPreviewPrs )
+  {
+    // TODO: Temporary commented until GetFillingColor, DefaultFillingColor,
+    // GetBorderColor and DefaultBorderColor data model methods will be implemented
+    /*
+    QColor aFillingColor = HYDROData_LandCover::DefaultFillingColor();
+    QColor aBorderColor = HYDROData_LandCover::DefaultBorderColor();
+    if ( !myEditedObject.IsNull() ) {
+      aFillingColor = myEditedObject->GetFillingColor();
+      aBorderColor = myEditedObject->GetBorderColor();
+    }
+
+    myPreviewPrs->setFillingColor( aFillingColor, false, false );
+    myPreviewPrs->setBorderColor( aBorderColor, false, false );
+    */
+
+    TopoDS_Face aFace;
+    if( !aZoneShape.IsNull() )
+      aFace = TopoDS::Face( aZoneShape );
+    myPreviewPrs->setFace( aFace, true, true, "" );
+  }
+
+  QApplication::restoreOverrideCursor();
+}
+
+void HYDROGUI_LandCoverOp::closePreview()
+{
+  if( myPreviewPrs )
+  {
+    delete myPreviewPrs;
+    myPreviewPrs = 0;
+  }
+}
diff --git a/src/HYDROGUI/HYDROGUI_LandCoverOp.h b/src/HYDROGUI/HYDROGUI_LandCoverOp.h
new file mode 100644 (file)
index 0000000..a50feb0
--- /dev/null
@@ -0,0 +1,61 @@
+// 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_LANDCOVEROP_H
+#define HYDROGUI_LANDCOVEROP_H
+
+#include "HYDROGUI_Operation.h"
+
+#include <HYDROData_LandCover.h>
+
+class HYDROGUI_Shape;
+
+class HYDROGUI_LandCoverOp : public HYDROGUI_Operation
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_LandCoverOp( HYDROGUI_Module* theModule, const bool theIsEdit );
+  virtual ~HYDROGUI_LandCoverOp();
+
+protected:
+  virtual void                 startOperation();
+  virtual void                 abortOperation();
+  virtual void                 commitOperation();
+
+  virtual HYDROGUI_InputPanel* createInputPanel() const;
+
+  virtual bool                 processApply( int& theUpdateFlags, QString& theErrorMsg,
+                                             QStringList& theBrowseObjectsEntries );
+
+  virtual HYDROGUI_Shape*      getPreviewShape() const { return myPreviewPrs; };
+
+protected slots:
+  void                         onCreatePreview( const QStringList& thePolylineNames );
+
+private:
+  void                         closePreview();
+
+private:
+  bool                         myIsEdit;
+  Handle(HYDROData_LandCover)  myEditedObject;
+
+  HYDROGUI_Shape*              myPreviewPrs;
+};
+
+#endif
index 0403a311edc6133b8154e264d6202a5c9a4e9da7..3d5dc177b24e0ea104e9ad3e3db34593e223479e 100644 (file)
@@ -337,6 +337,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
   bool anIsZone = false;
   bool anIsObstacle = false;
   bool anIsStricklerTable = false;
+  bool anIsLandCover = false;
   bool anIsStream = false;
   bool anIsChannel = false;
   bool anIsDigue = false;
@@ -457,6 +458,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         anIsObstacle = true;
       else if( anObjectKind == KIND_STRICKLER_TABLE )
         anIsStricklerTable = true;
+      else if( anObjectKind == KIND_LAND_COVER )
+        anIsLandCover = true;
       else if( anObjectKind == KIND_STREAM )
       {
         anIsStream = true;
@@ -513,6 +516,9 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         case KIND_STRICKLER_TABLE:
           theMenu->addAction( action( ImportStricklerTableFromFileId ) );          
           break;
+        case KIND_LAND_COVER:
+          theMenu->addAction( action( CreateLandCoverId ) );          
+          break;
         case KIND_CALCULATION:
           theMenu->addAction( action( CreateCalculationId ) );
           break;
@@ -646,6 +652,11 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         theMenu->addAction( action( DuplicateStricklerTableId ) );
         theMenu->addSeparator();
       }
+      else if( anIsLandCover )
+      {
+        theMenu->addAction( action( EditLandCoverId ) );
+        theMenu->addSeparator();
+      }      
       else if( anIsVisualState && anIsObjectBrowser )
       {
         theMenu->addAction( action( SaveVisualStateId ) );
index 3b4fedb19406940175ab96edc1367cdb1c469b08..6c291ed7ed8a1fd0d64e046686fea5a3410895f3 100644 (file)
@@ -59,6 +59,7 @@
 #include "HYDROGUI_SubmersibleOp.h"
 #include "HYDROGUI_StricklerTableOp.h"
 #include "HYDROGUI_DuplicateOp.h"
+#include "HYDROGUI_LandCoverOp.h"
 
 #include <HYDROData_Document.h>
 #include <HYDROData_Obstacle.h>
@@ -155,6 +156,9 @@ void HYDROGUI_Module::createActions()
   createAction( EditStricklerTableId, "EDIT_STRICKLER_TABLE", "EDIT_STRICKLER_TABLE_ICO" );
   createAction( DuplicateStricklerTableId, "DUPLICATE_STRICKLER_TABLE", "DUPLICATE_STRICKLER_TABLE_ICO" );
 
+  createAction( CreateLandCoverId, "CREATE_LAND_COVER", "CREATE_LAND_COVER_ICO" );
+  createAction( EditLandCoverId, "EDIT_LAND_COVER", "EDIT_LAND_COVER_ICO" );
+
   createAction( ImportObstacleFromFileId, "IMPORT_OBSTACLE_FROM_FILE", "IMPORT_OBSTACLE_FROM_FILE_ICO" );
   createAction( ImportGeomObjectAsObstacleId, "IMPORT_GEOM_OBJECT_AS_OBSTACLE", "IMPORT_GEOM_OBJECT_ICO" );
   createAction( ImportGeomObjectAsPolylineId, "IMPORT_GEOM_OBJECT_AS_POLYLINE", "IMPORT_GEOM_OBJECT_ICO" );
@@ -222,6 +226,7 @@ void HYDROGUI_Module::createMenus()
   createMenu( CreateImmersibleZoneId, aHydroId, -1, -1 );
   createMenu( CreateChannelId, aHydroId, -1, -1 );
   createMenu( CreateDigueId, aHydroId, -1, -1 );  
+  createMenu( CreateLandCoverId, aHydroId, -1, -1 );  
 
   int aNewProfileId = createMenu( tr( "MEN_DESK_PROFILE" ), aHydroId, -1 );
   createMenu( CreateProfileId, aNewProfileId, -1, -1 );
@@ -284,7 +289,10 @@ void HYDROGUI_Module::createToolbars()
   createTool( CreateCylinderId, aToolBar );
 
   createTool( separator(), aToolBar );
-  createTool( ImportStricklerTableFromFileId, aToolBar );  
+  createTool( ImportStricklerTableFromFileId, aToolBar );
+
+  createTool( separator(), aToolBar );
+  createTool( CreateLandCoverId, aToolBar );
 
   createTool( separator(), aToolBar );
   createTool( CreateCalculationId, aToolBar );
@@ -483,6 +491,10 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case EditStricklerTableId:
     anOp = new HYDROGUI_StricklerTableOp( aModule, theId == EditStricklerTableId );
     break;
+  case CreateLandCoverId:
+  case EditLandCoverId:
+    anOp = new HYDROGUI_LandCoverOp( aModule, theId == EditLandCoverId );
+    break;
   case DuplicateStricklerTableId:
     anOp = new HYDROGUI_DuplicateOp( aModule );
     break;
index 504a9ef89ff88ac2e6f8b041fb6c372e107cf8e7..e9d10c02a64d6113ea30002b101de3dde8bfdd95 100644 (file)
@@ -114,8 +114,10 @@ enum OperationId
   ImportStricklerTableFromFileId,
   ExportStricklerTableFromFileId,
   EditStricklerTableId,
-  DuplicateStricklerTableId
+  DuplicateStricklerTableId,
 
+  CreateLandCoverId,
+  EditLandCoverId
 };
 
 #endif
index 9da19b5ce549c0cb688e7def2232447b9f8451c1..5a5540f355a81830853639592f6a02b4df74d026 100644 (file)
       <source>HYDRO_TYPE26_ICO</source>
       <translation>icon_strickler_table.png</translation>
     </message>
+    <message>
+      <source>HYDRO_TYPE27_ICO</source>
+      <translation>icon_land_cover.png</translation>
+    </message>  
 
     <!-- Icons for need to update objects -->
     <message>
       <translation>icon_edit_strickler_table.png</translation>
     </message>
 
+    <message>
+      <source>CREATE_LAND_COVER_ICO</source>
+      <translation>icon_create_land_cover.png</translation>
+    </message>
+    <message>
+      <source>EDIT_LAND_COVER_ICO</source>
+      <translation>icon_edit_land_cover.png</translation>
+    </message>
+
     <message>
       <source>IMPORT_OBSTACLE_FROM_FILE_ICO</source>
       <translation>icon_import_obstacle.png</translation>
index e07fd2289f79935d7ee0102da7014917c818c8d1..3c926868e78189d9678d01eaa58cf4408e818837 100644 (file)
       <source>DEFAULT_STRICKLER_TABLE_NAME</source>
       <translation>Strickler table</translation>
     </message>
+    <message>
+      <source>DEFAULT_LAND_COVER_NAME</source>
+      <translation>Land cover</translation>
+    </message>
     <message>
       <source>IMAGES</source>
       <translation>IMAGES</translation>
       <source>STRICKLER_TABLES</source>
       <translation>STRICKLER TABLES</translation>
     </message>
+    <message>
+      <source>LAND_COVERS</source>
+      <translation>LAND COVERS</translation>
+    </message>
     <message>
       <source>ARTIFICIAL_OBJECTS</source>
       <translation>ARTIFICIAL OBJECTS</translation>
@@ -786,6 +794,14 @@ Would you like to remove all references from the image?</translation>
       <source>DSK_DUPLICATE_STRICKLER_TABLE</source>
       <translation>Duplicate Strickler table</translation>
     </message>
+    <message>
+      <source>DSK_CREATE_LAND_COVER</source>
+      <translation>Create land cover</translation>
+    </message>
+    <message>
+      <source>DSK_EDIT_LAND_COVER</source>
+      <translation>Edit land cover</translation>
+    </message>
     <message>
       <source>DSK_COPY</source>
       <translation>Copy</translation>
@@ -1038,6 +1054,14 @@ Would you like to remove all references from the image?</translation>
       <source>MEN_DUPLICATE_STRICKLER_TABLE</source>
       <translation>Duplicate Strickler table</translation>
     </message>
+    <message>
+      <source>MEN_CREATE_LAND_COVER</source>
+      <translation>Create land cover</translation>
+    </message>
+    <message>
+      <source>MEN_EDIT_LAND_COVER</source>
+      <translation>Edit land cover</translation>
+    </message>
     <message>
       <source>MEN_CUT_IMAGES</source>
       <translation>Cut images</translation>
@@ -1314,6 +1338,14 @@ Would you like to remove all references from the image?</translation>
       <source>STB_DUPLICATE_STRICKLER_TABLE</source>
       <translation>Duplicate Strickler table</translation>
     </message>
+    <message>
+      <source>STB_CREATE_LAND_COVER</source>
+      <translation>Create land cover</translation>
+    </message>
+    <message>
+      <source>STB_EDIT_LAND_COVER</source>
+      <translation>Edit land cover</translation>
+    </message>
     <message>
       <source>STB_COPY</source>
       <translation>Copy</translation>
@@ -2355,6 +2387,50 @@ Polyline should consist from one not closed curve.</translation>
     </message>
   </context>
 
+  <context>
+    <name>HYDROGUI_LandCoverDlg</name>
+    <message>
+      <source>DEFAULT_LAND_COVER_NAME</source>
+      <translation>Land cover</translation>
+    </message>
+    <message>
+      <source>LAND_COVER_NAME</source>
+      <translation>Land cover name</translation>
+    </message>
+    <message>
+      <source>NAME</source>
+      <translation>Name</translation>
+    </message>
+    <message>
+      <source>LAND_COVER_PARAMETERS</source>
+      <translation>Parameters</translation>
+    </message>
+    <message>
+      <source>LAND_COVER_POLYLINES</source>
+      <translation>Polylines</translation>
+    </message>
+    <message>
+      <source>LAND_COVER_STRICKLER_TYPE</source>
+      <translation>Strickler type</translation>
+    </message>
+  </context>
+
+  <context>
+    <name>HYDROGUI_LandCoverOp</name>
+    <message>
+      <source>CREATE_LAND_COVER</source>
+      <translation>Create land cover</translation>
+    </message>
+    <message>
+      <source>EDIT_LAND_COVER</source>
+      <translation>Edit land cover</translation>
+    </message>
+    <message>
+      <source>SELECT_STRICKLER_TABLE_FILE</source>
+      <translation>The Strickler table file is not chosen</translation>
+    </message>
+  </context>
+
   <context>
     <name>HYDROGUI_TranslateObstacleDlg</name>
     <message>
diff --git a/src/HYDROGUI/resources/icon_create_land_cover.png b/src/HYDROGUI/resources/icon_create_land_cover.png
new file mode 100644 (file)
index 0000000..63072e3
Binary files /dev/null and b/src/HYDROGUI/resources/icon_create_land_cover.png differ
diff --git a/src/HYDROGUI/resources/icon_edit_land_cover.png b/src/HYDROGUI/resources/icon_edit_land_cover.png
new file mode 100644 (file)
index 0000000..63072e3
Binary files /dev/null and b/src/HYDROGUI/resources/icon_edit_land_cover.png differ
index 21dfce052821e48b7a6e40a0d328e608fbec8a80..9b65769f251f99269a2bfe652660456a841a5f36 100644 (file)
Binary files a/src/HYDROGUI/resources/icon_edit_strickler_table.png and b/src/HYDROGUI/resources/icon_edit_strickler_table.png differ
index 21dfce052821e48b7a6e40a0d328e608fbec8a80..9b65769f251f99269a2bfe652660456a841a5f36 100644 (file)
Binary files a/src/HYDROGUI/resources/icon_export_strickler_table.png and b/src/HYDROGUI/resources/icon_export_strickler_table.png differ
index 21dfce052821e48b7a6e40a0d328e608fbec8a80..9b65769f251f99269a2bfe652660456a841a5f36 100644 (file)
Binary files a/src/HYDROGUI/resources/icon_import_strickler_table.png and b/src/HYDROGUI/resources/icon_import_strickler_table.png differ
diff --git a/src/HYDROGUI/resources/icon_land_cover.png b/src/HYDROGUI/resources/icon_land_cover.png
new file mode 100644 (file)
index 0000000..63072e3
Binary files /dev/null and b/src/HYDROGUI/resources/icon_land_cover.png differ
index 21dfce052821e48b7a6e40a0d328e608fbec8a80..9b65769f251f99269a2bfe652660456a841a5f36 100644 (file)
Binary files a/src/HYDROGUI/resources/icon_strickler_table.png and b/src/HYDROGUI/resources/icon_strickler_table.png differ