]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Merge branch 'BR_LAND_COVER_MAP' of ssh://git.salome-platform.org/modules/hydro into...
authormkr <mkr@opencascade.com>
Fri, 23 Oct 2015 08:22:19 +0000 (11:22 +0300)
committermkr <mkr@opencascade.com>
Fri, 23 Oct 2015 08:22:19 +0000 (11:22 +0300)
12 files changed:
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_LandCoverMapDlg.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_LandCoverMapDlg.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_LandCoverMapOp.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_LandCoverMapOp.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_ShapeLandCoverMap.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ShapeLandCoverMap.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_StricklerTypeComboBox.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_StricklerTypeComboBox.h [new file with mode: 0644]
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 18e7950adbc579667bcd0fe76f780dbe97f0bf66..bbaf85f3fbb34484d5ab388448bd964698467b1b 100644 (file)
@@ -41,6 +41,8 @@ set(PROJECT_HEADERS
     HYDROGUI_ExportSinusXOp.h
     HYDROGUI_ExportSinusXDlg.h
     HYDROGUI_InputPanel.h
+    HYDROGUI_LandCoverMapDlg.h
+    HYDROGUI_LandCoverMapOp.h
     HYDROGUI_LandCoverMapPrs.h
     HYDROGUI_LocalCSDlg.h
     HYDROGUI_LocalCSOp.h
@@ -77,6 +79,7 @@ set(PROJECT_HEADERS
     HYDROGUI_Polyline.h
     HYDROGUI_ShapeBathymetry.h
     HYDROGUI_ShapeImage.h
+    HYDROGUI_ShapeLandCoverMap.h
     HYDROGUI_ShowHideOp.h
     HYDROGUI_SplitPolylinesDlg.h
     HYDROGUI_SplitPolylinesOp.h
@@ -85,6 +88,7 @@ set(PROJECT_HEADERS
     HYDROGUI_LineEditDoubleValidator.h
     HYDROGUI_StricklerTableDlg.h
     HYDROGUI_StricklerTableOp.h
+    HYDROGUI_StricklerTypeComboBox.h
     HYDROGUI_SubmersibleOp.h
     HYDROGUI_Tool.h
     HYDROGUI_TwoImagesDlg.h
@@ -174,6 +178,8 @@ set(PROJECT_SOURCES
     HYDROGUI_ExportSinusXOp.cxx
     HYDROGUI_ExportSinusXDlg.cxx
     HYDROGUI_InputPanel.cxx
+    HYDROGUI_LandCoverMapDlg.cxx
+    HYDROGUI_LandCoverMapOp.cxx
     HYDROGUI_LandCoverMapPrs.cxx
     HYDROGUI_LocalCSDlg.cxx
     HYDROGUI_LocalCSOp.cxx
@@ -210,12 +216,14 @@ set(PROJECT_SOURCES
     HYDROGUI_Polyline.cxx
     HYDROGUI_ShapeBathymetry.cxx
     HYDROGUI_ShapeImage.cxx
+    HYDROGUI_ShapeLandCoverMap.cxx
     HYDROGUI_ShowHideOp.cxx
     HYDROGUI_StreamDlg.cxx
     HYDROGUI_StreamOp.cxx
     HYDROGUI_LineEditDoubleValidator.cxx
     HYDROGUI_StricklerTableDlg.cxx
     HYDROGUI_StricklerTableOp.cxx
+    HYDROGUI_StricklerTypeComboBox.cxx
     HYDROGUI_SplitPolylinesDlg.cxx
     HYDROGUI_SplitPolylinesOp.cxx
     HYDROGUI_SubmersibleOp.cxx
diff --git a/src/HYDROGUI/HYDROGUI_LandCoverMapDlg.cxx b/src/HYDROGUI/HYDROGUI_LandCoverMapDlg.cxx
new file mode 100644 (file)
index 0000000..0c96463
--- /dev/null
@@ -0,0 +1,193 @@
+// 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_LandCoverMapDlg.h"
+
+#include "HYDROGUI_Operations.h"
+#include "HYDROGUI_StricklerTypeComboBox.h"
+
+#include <HYDROData_Object.h>
+#include <HYDROData_PolylineXY.h>
+
+#include <QLineEdit>
+#include <QComboBox>
+#include <QGroupBox>
+#include <QLabel>
+#include <QLayout>
+
+HYDROGUI_LandCoverMapDlg::HYDROGUI_LandCoverMapDlg( HYDROGUI_Module* theModule,
+                                                    const QString& theTitle,
+                                                    const int theOperationId )
+: HYDROGUI_InputPanel( theModule, theTitle ),
+  HYDROGUI_ObjComboBoxFilter(),
+  myOperationId( theOperationId )
+{
+  // Land Cover Map name
+  myObjectNameGroup = new QGroupBox( tr( "LAND_COVER_MAP_NAME" ), mainFrame() );
+
+  myObjectNameCreate = new QLineEdit( myObjectNameGroup );
+  myObjectNameEdit = new QComboBox( myObjectNameGroup );
+  myObjectNameEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+
+  QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup );
+  aNameLayout->setMargin( 5 );
+  aNameLayout->setSpacing( 5 );
+  aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) );
+  aNameLayout->addWidget( myObjectNameCreate );
+  aNameLayout->addWidget( myObjectNameEdit );
+
+  myParamGroup = new QGroupBox( tr( "LAND_COVER_MAP_PARAMETERS" ), mainFrame() );
+  QGridLayout* aParamLayout = new QGridLayout( myParamGroup );
+  aParamLayout->setMargin( 5 );
+  aParamLayout->setSpacing( 10 );
+  
+  // Polyline/Face name
+  myPolylinesFacesLabel = new QLabel( tr( "LAND_COVER_MAP_POLYLINE_FACE" ) );
+  aParamLayout->addWidget( myPolylinesFacesLabel, 0, 0, 1, 1 );
+  aParamLayout->addWidget( myPolylinesFaces = new HYDROGUI_ObjComboBox( theModule, "", KIND_UNKNOWN, myParamGroup ), 0, 1, 1, 1 );
+  myPolylinesFaces->setObjectFilter( this );
+
+  // Strickler type name
+  myStricklerTypesLabel = new QLabel( tr( "LAND_COVER_MAP_STRICKLER_TYPE" ), myParamGroup );
+  myStricklerTypes = new HYDROGUI_StricklerTypeComboBox( theModule, "", myParamGroup );
+  aParamLayout->addWidget( myStricklerTypesLabel, 1, 0, 1, 1 );
+  aParamLayout->addWidget( myStricklerTypes, 1, 1, 1, 1 );
+
+  // Common
+  addWidget( myObjectNameGroup );
+  addWidget( myParamGroup );
+
+  addStretch();
+
+  connect( myPolylinesFaces, SIGNAL( objectSelected( const QString& ) ), this, SLOT( onPolylineFaceChanged( const QString& ) ) );
+
+  updateState( true );
+}
+
+HYDROGUI_LandCoverMapDlg::~HYDROGUI_LandCoverMapDlg()
+{
+}
+
+void HYDROGUI_LandCoverMapDlg::reset()
+{
+  bool isBlocked = blockSignals( true );
+
+  myPolylinesFaces->reset();
+
+  blockSignals( isBlocked );
+
+  updateState();
+}
+
+void HYDROGUI_LandCoverMapDlg::setObjectNames( const QStringList& theNames )
+{
+  bool isBlocked = blockSignals( true );
+
+  myObjectNameEdit->clear();
+  myObjectNameEdit->addItems( theNames );
+
+  blockSignals( isBlocked );
+}
+
+void HYDROGUI_LandCoverMapDlg::setObjectName( const QString& theName )
+{
+  if ( myObjectNameCreate->isVisible() )
+    myObjectNameCreate->setText( theName );
+  else
+    myObjectNameEdit->setCurrentIndex( myObjectNameEdit->findText( theName ) );
+}
+
+QString HYDROGUI_LandCoverMapDlg::getObjectName() const
+{
+  if ( myObjectNameCreate->isVisible() )
+    return myObjectNameCreate->text();
+  return myObjectNameEdit->currentText();
+}
+
+QString HYDROGUI_LandCoverMapDlg::getPolylineFaceName() const
+{
+  return myPolylinesFaces->selectedObject();
+}
+
+void HYDROGUI_LandCoverMapDlg::setPolylineFaceName( const QString& theName )
+{
+  myPolylinesFaces->setSelectedObject( theName );
+}
+
+Handle(HYDROData_Entity) HYDROGUI_LandCoverMapDlg::getPolylineFace() const
+{
+  return myPolylinesFaces->GetObject();
+}
+
+void HYDROGUI_LandCoverMapDlg::setSelectedStricklerTypeName( const QString& theName )
+{
+  myStricklerTypes->setSelectedStricklerTypeName( theName );
+}
+
+QString HYDROGUI_LandCoverMapDlg::getSelectedStricklerTypeName() const
+{
+  return myStricklerTypes->getSelectedStricklerTypeName();
+}
+
+bool HYDROGUI_LandCoverMapDlg::isOk( const Handle(HYDROData_Entity)& theEntity ) const
+{
+  Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast(theEntity);
+  Handle(HYDROData_Object) anObject2d3dPrs = Handle(HYDROData_Object)::DownCast(theEntity);  
+  return ( !anObject2d3dPrs.IsNull() ||
+           ( !aPolylineXY.IsNull() && ( ( myOperationId == CreateLandCoverMapId || myOperationId == AddLandCoverId ) && aPolylineXY->IsClosed() ||
+                                        myOperationId == SplitLandCoverId ) ) );
+}
+
+void HYDROGUI_LandCoverMapDlg::onPolylineFaceChanged( const QString& )
+{
+  updateState();
+  // TODO: select chosen polyline/face in the 3D viewer, if it is not selected yet (i.e. object was chosen not in the viewer, but in combo-box)
+}
+
+void HYDROGUI_LandCoverMapDlg::updateState( bool theInitialConfigure )
+{
+  if ( theInitialConfigure )
+  {
+    myObjectNameCreate->setVisible( myOperationId == CreateLandCoverMapId );
+    myObjectNameEdit->setVisible( myOperationId != CreateLandCoverMapId );
+
+    myParamGroup->setVisible( myOperationId != RemoveLandCoverId );
+
+    bool aShowPolylinesFacesCtrls = ( myOperationId == CreateLandCoverMapId ||
+                                      myOperationId == AddLandCoverId ||
+                                      myOperationId == SplitLandCoverId );
+    myPolylinesFacesLabel->setVisible( aShowPolylinesFacesCtrls );
+    myPolylinesFaces->setVisible( aShowPolylinesFacesCtrls );
+
+    bool aShowStricklerTypesCtrls = ( myOperationId == CreateLandCoverMapId ||
+                                      myOperationId == AddLandCoverId ||
+                                      myOperationId == MergeLandCoverId );
+    myStricklerTypesLabel->setVisible( aShowStricklerTypesCtrls );
+    myStricklerTypes->setVisible( aShowStricklerTypesCtrls );
+  }
+  else
+  {
+    bool anEmptyObjectName = getObjectName().isEmpty();
+
+    bool anEmptyPolylineFaceName = false;
+    if ( myPolylinesFaces->isVisible() )
+      anEmptyPolylineFaceName = getPolylineFaceName().isEmpty();
+
+    setApplyEnabled( !anEmptyObjectName && !anEmptyPolylineFaceName );
+  }
+}
diff --git a/src/HYDROGUI/HYDROGUI_LandCoverMapDlg.h b/src/HYDROGUI/HYDROGUI_LandCoverMapDlg.h
new file mode 100644 (file)
index 0000000..211740c
--- /dev/null
@@ -0,0 +1,76 @@
+// 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
+//
+
+// REMOVED FROM THE PROJECT, BUT KEPT AS A REFERENCE FILE. TO BE DELETED LATER.
+
+#ifndef HYDROGUI_LANDCOVERMAPDLG_H
+#define HYDROGUI_LANDCOVERMAPDLG_H
+
+#include "HYDROGUI_InputPanel.h"
+
+#include "HYDROGUI_ObjComboBox.h"
+
+class HYDROGUI_StricklerTypeComboBox;
+
+class QGroupBox;
+class QLineEdit;
+class QLabel;
+
+class HYDROGUI_LandCoverMapDlg : public HYDROGUI_InputPanel, public HYDROGUI_ObjComboBoxFilter
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_LandCoverMapDlg( HYDROGUI_Module* theModule, const QString& theTitle, const int theOperationId );
+  virtual ~HYDROGUI_LandCoverMapDlg();
+
+  virtual void             reset();
+
+  void                     setObjectNames( const QStringList& theNames );
+  void                     setObjectName( const QString& theName );
+  QString                  getObjectName() const;
+
+  QString                  getPolylineFaceName() const;
+  void                     setPolylineFaceName( const QString& );
+  Handle(HYDROData_Entity) getPolylineFace() const;
+
+  void                     setSelectedStricklerTypeName( const QString& theName );
+  QString                  getSelectedStricklerTypeName() const;
+
+  virtual bool             isOk( const Handle(HYDROData_Entity)& ) const;
+
+private slots:
+  void                     onPolylineFaceChanged( const QString& );
+
+private:
+  void                     updateState( bool theInitialConfigure = false );
+
+private:
+  int                             myOperationId;
+  QGroupBox*                      myObjectNameGroup;  
+  QLineEdit*                      myObjectNameCreate;
+  QComboBox*                      myObjectNameEdit;
+
+  QGroupBox*                      myParamGroup;
+  QLabel*                         myPolylinesFacesLabel;
+  HYDROGUI_ObjComboBox*           myPolylinesFaces;
+  QLabel*                         myStricklerTypesLabel;
+  HYDROGUI_StricklerTypeComboBox* myStricklerTypes;
+};
+
+#endif
diff --git a/src/HYDROGUI/HYDROGUI_LandCoverMapOp.cxx b/src/HYDROGUI/HYDROGUI_LandCoverMapOp.cxx
new file mode 100644 (file)
index 0000000..96655be
--- /dev/null
@@ -0,0 +1,310 @@
+// 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_LandCoverMapOp.h"
+
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_OCCDisplayer.h"
+#include "HYDROGUI_Operations.h"
+#include "HYDROGUI_LandCoverMapDlg.h"
+#include "HYDROGUI_Tool.h"
+#include "HYDROGUI_UpdateFlags.h"
+#include "HYDROGUI_DataObject.h"
+
+#include <HYDROData_Iterator.h>
+#include <HYDROData_StricklerTable.h>
+#include <HYDROData_PolylineXY.h>
+#include <HYDROData_Object.h>
+
+HYDROGUI_LandCoverMapOp::HYDROGUI_LandCoverMapOp( HYDROGUI_Module* theModule, const int theOperationId )
+: HYDROGUI_Operation( theModule ),
+  myOperationId( theOperationId ),
+  myPreviewPrs( 0 )
+{
+  switch( myOperationId )
+  {
+    case CreateLandCoverMapId:
+      setName( tr( "CREATE_LAND_COVER_MAP" ) );
+      break;
+    case AddLandCoverId:
+      setName( tr( "ADD_LAND_COVER" ) );
+      break;
+    case RemoveLandCoverId:
+      setName( tr( "REMOVE_LAND_COVER" ) );
+      break;
+    case SplitLandCoverId:
+      setName( tr( "SPLIT_LAND_COVER" ) );
+      break;
+    case MergeLandCoverId:
+      setName( tr( "MERGE_LAND_COVER" ) );
+      break;
+  }  
+}
+
+HYDROGUI_LandCoverMapOp::~HYDROGUI_LandCoverMapOp()
+{
+  closePreview();
+}
+
+void HYDROGUI_LandCoverMapOp::startOperation()
+{
+  HYDROGUI_Operation::startOperation();
+
+  HYDROGUI_LandCoverMapDlg* aPanel = ::qobject_cast<HYDROGUI_LandCoverMapDlg*>( inputPanel() );
+  if ( !aPanel )
+    return;
+
+  aPanel->blockSignals( true );
+
+  aPanel->reset();
+
+  // Set name of the created/edited land cover map object
+  QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_LAND_COVER_MAP_NAME" ) );
+  if ( myOperationId != CreateLandCoverMapId )
+  {
+    if ( isApplyAndClose() )
+      myEditedObject = Handle(HYDROData_LandCoverMap)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+    if ( !myEditedObject.IsNull() )
+    {
+      anObjectName = myEditedObject->GetName();
+
+      // Construct a list of names of all land cover map objects defined within the data model
+      QStringList aLandCoverMapNames;
+      HYDROData_Iterator anIterator( doc(), KIND_LAND_COVER_MAP );
+      for( ; anIterator.More(); anIterator.Next() )
+      {
+        Handle(HYDROData_LandCoverMap) aLandCoverObj =
+          Handle(HYDROData_LandCoverMap)::DownCast( anIterator.Current() );    
+        if ( !aLandCoverObj.IsNull() )
+          aLandCoverMapNames.append( aLandCoverObj->GetName() );
+      }
+
+      //aLandCoverMapNames.sort();
+      aPanel->setObjectNames( aLandCoverMapNames );
+    }
+  }  
+  aPanel->setObjectName( anObjectName );
+  
+  aPanel->blockSignals( false );
+}
+
+void HYDROGUI_LandCoverMapOp::abortOperation()
+{
+  closePreview();
+
+  HYDROGUI_Operation::abortOperation();
+}
+
+void HYDROGUI_LandCoverMapOp::commitOperation()
+{
+  closePreview();
+
+  HYDROGUI_Operation::commitOperation();
+}
+
+HYDROGUI_InputPanel* HYDROGUI_LandCoverMapOp::createInputPanel() const
+{
+  HYDROGUI_LandCoverMapDlg* aPanel = new HYDROGUI_LandCoverMapDlg( module(), getName(), myOperationId );
+  /*
+  connect( aPanel, SIGNAL( CreatePreview( const QStringList& ) ),
+           this,   SLOT( onCreatePreview( const QStringList& ) ) );
+  connect( aPanel, SIGNAL( addPolylines() ), SLOT( onAddPolylines() ) );
+  connect( aPanel, SIGNAL( removePolylines() ), SLOT( onRemovePolylines() ) );
+  */
+  return aPanel;
+}
+
+bool HYDROGUI_LandCoverMapOp::processApply( int& theUpdateFlags,
+                                            QString& theErrorMsg,
+                                            QStringList& theBrowseObjectsEntries )
+{
+  HYDROGUI_LandCoverMapDlg* aPanel = ::qobject_cast<HYDROGUI_LandCoverMapDlg*>( inputPanel() );
+  if ( !aPanel )
+    return false;
+
+  // Check name of the created/edited object
+  QString anObjectName = aPanel->getObjectName().simplified();
+  if ( anObjectName.isEmpty() )
+  {
+    theErrorMsg = tr( "INCORRECT_OBJECT_NAME" );
+    return false;
+  }
+
+  if ( myOperationId == CreateLandCoverMapId || ( !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;
+    }
+  }
+
+  // Get selected polyline/face
+  Handle(HYDROData_PolylineXY) aPolyline;
+  Handle(HYDROData_Object) aFace;
+  if ( myOperationId == CreateLandCoverMapId || myOperationId == AddLandCoverId || myOperationId == SplitLandCoverId )
+  {
+    Handle(HYDROData_Entity) aPolylineFace = aPanel->getPolylineFace();
+    aPolyline = Handle(HYDROData_PolylineXY)::DownCast( aPolylineFace );
+    aFace = Handle(HYDROData_Object)::DownCast( aPolylineFace );
+    if ( aPolyline.IsNull() && aFace.IsNull() )
+    {
+      theErrorMsg = tr( "POLYLINE_FACE_NOT_DEFINED" );
+      return false;
+    }
+  }
+
+  // Get selected Strickler type
+  QString aSelectedStricklerType;
+  if ( myOperationId == CreateLandCoverMapId || myOperationId == AddLandCoverId || myOperationId == MergeLandCoverId )
+  {
+    aSelectedStricklerType = aPanel->getSelectedStricklerTypeName();
+    if ( aSelectedStricklerType.isEmpty() )
+    {
+      theErrorMsg = tr( "STRICKLER_TYPE_NOT_DEFINED" );
+      return false;
+    }
+  }
+
+  // Create / find the new / edited land cover map object
+  Handle(HYDROData_LandCoverMap) aLandCoverMapObj = myOperationId != CreateLandCoverMapId ? myEditedObject :
+    Handle(HYDROData_LandCoverMap)::DownCast( doc()->CreateObject( KIND_LAND_COVER_MAP ) );
+
+  // Set land cover map name
+  aLandCoverMapObj->SetName( anObjectName );
+  
+  if ( myOperationId == CreateLandCoverMapId || myOperationId == AddLandCoverId )
+  {
+    bool aLandCoverAdded = false;
+    if ( !aPolyline.IsNull() )
+      aLandCoverAdded = aLandCoverMapObj->Add( aPolyline, aSelectedStricklerType );
+    else if ( !aFace.IsNull() )
+      aLandCoverAdded = aLandCoverMapObj->Add( aFace, aSelectedStricklerType );
+    if ( !aLandCoverAdded )
+    {
+      theErrorMsg = tr( "LAND_COVER_NOT_ADDED" );
+      return false;
+    }
+  }
+    
+  /*TCollection_AsciiString anError;
+  if ( HYDROData_LandCover::buildShape( aZonePolylines, anError ).IsNull() )
+  {
+    if ( !anError.IsEmpty() ) {
+      theErrorMsg = HYDROGUI_Tool::ToQString( anError );
+    } else {
+      theErrorMsg = tr( "LAND_COVER_OBJECT_CANNOT_BE_CREATED" );
+    }
+    return false;
+  }*/  
+
+  /*if ( myOperationId == CreateLandCoverMapId )
+  {    
+    aLandCoverMapObj->SetFillingColor( aLandCoverMapObj->DefaultFillingColor() );
+    aLandCoverMapObj->SetBorderColor( aLandCoverMapObj->DefaultBorderColor() );
+  }*/
+
+  //aLandCoverMapObj->SetPolylines( aZonePolylines );
+  //aLandCoverMapObj->SetStricklerType( aSelectedStricklerType );
+  aLandCoverMapObj->Update();
+
+  closePreview();
+
+  module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aLandCoverMapObj, true );
+  if ( myOperationId == CreateLandCoverMapId )
+  {
+    QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aLandCoverMapObj );
+    theBrowseObjectsEntries.append( anEntry );
+  }
+
+  module()->setIsToUpdate( aLandCoverMapObj );
+  module()->getOCCDisplayer()->SetToUpdateColorScale();
+
+  theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
+
+  return true;
+}
+
+void HYDROGUI_LandCoverMapOp::onCreatePreview( const QStringList& thePolylineNames )
+{
+  /*
+  HYDROGUI_LandCoverDlg* aPanel = ::qobject_cast<HYDROGUI_LandCoverDlg*>( inputPanel() );
+  if ( !aPanel )
+    return;
+
+  QApplication::setOverrideCursor( Qt::WaitCursor );  
+
+  HYDROData_SequenceOfObjects 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 );
+  }
+  
+  TCollection_AsciiString anError;
+  TopoDS_Shape aZoneShape = HYDROData_LandCover::buildShape( aZonePolylines, anError );  
+
+  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 )
+  {
+    QColor aFillingColor = Qt::magenta;
+    QColor aBorderColor = Qt::transparent;
+    if ( !myEditedObject.IsNull() ) {
+      aFillingColor = myEditedObject->GetFillingColor();
+      aBorderColor = myEditedObject->GetBorderColor();
+    }
+
+    myPreviewPrs->setFillingColor( aFillingColor, false, false );
+    myPreviewPrs->setBorderColor( aBorderColor, false, false );
+
+    if( !aZoneShape.IsNull() )
+      myPreviewPrs->setShape( aZoneShape );
+  }
+
+  QApplication::restoreOverrideCursor();
+  */
+}
+
+void HYDROGUI_LandCoverMapOp::closePreview()
+{
+  if( myPreviewPrs )
+  {
+    delete myPreviewPrs;
+    myPreviewPrs = 0;
+  }
+}
diff --git a/src/HYDROGUI/HYDROGUI_LandCoverMapOp.h b/src/HYDROGUI/HYDROGUI_LandCoverMapOp.h
new file mode 100644 (file)
index 0000000..092af90
--- /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_LANDCOVERMAPOP_H
+#define HYDROGUI_LANDCOVERMAPOP_H
+
+#include "HYDROGUI_Operation.h"
+
+#include <HYDROData_LandCoverMap.h>
+
+class HYDROGUI_LandCoverMapOp : public HYDROGUI_Operation
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_LandCoverMapOp( HYDROGUI_Module* theModule, const int theOperationId );
+  virtual ~HYDROGUI_LandCoverMapOp();
+    
+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:
+  int                             myOperationId;
+  Handle(HYDROData_LandCoverMap)  myEditedObject;
+
+  HYDROGUI_Shape*                 myPreviewPrs;
+};
+
+#endif
index a8e7370742ea98954840bd991f932ab593ece12f..aa5a6fe75924d97bef3f89c4c341c6815c807feb 100644 (file)
@@ -23,8 +23,7 @@
 #include "HYDROGUI_Tool.h"
 #include <HYDROGUI_ShapeImage.h>
 #include <HYDROGUI_ShapeBathymetry.h>
-// TODO
-//#include <HYDROGUI_ShapeLandCoverMap.h>
+#include <HYDROGUI_ShapeLandCoverMap.h>
 #include "HYDROGUI_Operation.h"
 #include "HYDROGUI_DataObject.h"
 #include "HYDROGUI_ZLayers.h"
@@ -168,9 +167,7 @@ HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const int
     aResShape = new HYDROGUI_ShapeBathymetry( this, theContext, Handle_HYDROData_Bathymetry::DownCast( theObject ) );
   else if( theObject->IsKind( STANDARD_TYPE( HYDROData_LandCoverMap ) ) ) {
     bool isScalarMode = module()->isLandCoversScalarMapModeOn( theViewerId );
-    /* TODO
-    aResShape = new HYDROGUI_ShapeLandCover( this, theContext, Handle_HYDROData_LandCoverMap::DownCast( theObject ), -1, isScalarMode );
-    */
+    aResShape = new HYDROGUI_ShapeLandCoverMap( this, theContext, Handle_HYDROData_LandCoverMap::DownCast( theObject ), -1, isScalarMode );
   }
   else
     aResShape = new HYDROGUI_Shape( theContext, theObject );
@@ -422,7 +419,7 @@ void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer
   int aViewerId = (size_t)theViewer;//TODO: check if viewer id is correct
   bool isLandCoverColoringOn = module()->isLandCoversScalarMapModeOn( aViewerId );
     
-  QList<HYDROGUI_Shape*> aLandCoverShapes = module()->getObjectShapes( aViewerId, KIND_LAND_COVER_MAP );
+  QList<HYDROGUI_Shape*> aLandCoverMapShapes = module()->getObjectShapes( aViewerId, KIND_LAND_COVER_MAP );
   QList<HYDROGUI_Shape*> aBathShapes = module()->getObjectShapes( aViewerId, KIND_BATHYMETRY );
 
   bool isDisplayColorScale = !aBathShapes.empty() || isLandCoverColoringOn;
@@ -503,29 +500,31 @@ void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer
       aView->ColorScaleErase();
   }
 
-  /* TODO
-  foreach( HYDROGUI_Shape* aShape, aLandCoverShapes ) {
-    HYDROGUI_ShapeLandCover* aLandCoverShape = 
-      dynamic_cast<HYDROGUI_ShapeLandCover*>( aShape );
+  foreach( HYDROGUI_Shape* aShape, aLandCoverMapShapes ) {
+    HYDROGUI_ShapeLandCoverMap* aLandCoverMapShape = 
+      dynamic_cast<HYDROGUI_ShapeLandCoverMap*>( aShape );
 
-    if ( !aLandCoverShape || !aLandCoverShape->isVisible() ) {
+    if ( !aLandCoverMapShape || !aLandCoverMapShape->isVisible() ) {
       continue;
     }
     
     QColor aColor;    
-    Handle(HYDROData_LandCover) aLandCover = 
-      Handle(HYDROData_LandCover)::DownCast( aLandCoverShape->getObject() );
+    Handle(HYDROData_LandCoverMap) aLandCoverMap = 
+      Handle(HYDROData_LandCoverMap)::DownCast( aLandCoverMapShape->getObject() );
 
-    if ( aLandCover.IsNull() ) {
+    if ( aLandCoverMap.IsNull() ) {
       continue;
     }
     
     QColor aUndefinedColor( Qt::gray );
-    QColor aColor = isLandCoverColoringOn ? aUndefinedColor : aLandCover->GetFillingColor();
+    aColor = aUndefinedColor;
+    // TODO
+    //QColor aColor = isLandCoverColoringOn ? aUndefinedColor : aLandCoverMap->GetFillingColor();
     
     if ( isLandCoverColoringOn && !aTable.IsNull() ) {
-      QString aStricklerType = 
-        aLandCover->GetStricklerType().toLatin1().constData();
+      QString aStricklerType = "";
+        // TODO
+        //aLandCoverMap->GetStricklerType().toLatin1().constData();
      
       if ( aTable->HasType( aStricklerType ) ) {
         double aStricklerCoeff = aTable->Get( aStricklerType, 0 );
@@ -538,11 +537,10 @@ void HYDROGUI_OCCDisplayer::UpdateColorScale( const OCCViewer_Viewer* theViewer
       }
     }    
     
-    aLandCoverShape->setFillingColor( aColor, true, true );
-    aLandCoverShape->setScalarMapModeEnabled( isLandCoverColoringOn );
-    theViewer->getAISContext()->Redisplay( aLandCoverShape->getAISObject() );
+    aLandCoverMapShape->setFillingColor( aColor, true, true );
+    aLandCoverMapShape->setScalarMapModeEnabled( isLandCoverColoringOn );
+    theViewer->getAISContext()->Redisplay( aLandCoverMapShape->getAISObject() );
   }
-  */
-
+  
   myToUpdateColorScale = false;
 }
index 5641a2c4ff77ae5bd642b73bee912d789f5b7fb9..1715bc479dadba2b148c154d49874cb07ff58526 100644 (file)
@@ -62,8 +62,7 @@
 #include "HYDROGUI_SubmersibleOp.h"
 #include "HYDROGUI_StricklerTableOp.h"
 #include "HYDROGUI_DuplicateOp.h"
-// TODO
-//#include "HYDROGUI_LandCoverMapOp.h"
+#include "HYDROGUI_LandCoverMapOp.h"
 #include "HYDROGUI_PolylineExtractionOp.h"
 #include "HYDROGUI_ExportSinusXOp.h"
 #include "HYDROGUI_MergePolylinesOp.h"
@@ -246,19 +245,18 @@ void HYDROGUI_Module::createMenus()
   int aHydroMenu = 6; // Edit menu id == 5, View menu id == 10
   int aHydroId = createMenu( tr( "MEN_DESK_HYDRO" ), -1, -1, aHydroMenu );
   createMenu( ImportSinusXId, aHydroId, -1, -1 );
-  createMenu( ExportSinusXId, aHydroId, -1, -1 );
-  createMenu( ImportLandCoverMapId, aHydroId, -1, -1 );
+  createMenu( ExportSinusXId, aHydroId, -1, -1 );  
   
   createMenu( ImportBathymetryId, aHydroId, -1, -1 );
   createMenu( ImportStricklerTableFromFileId, aHydroId, -1, -1 );
   createMenu( CreatePolyline3DId, aHydroId, -1, -1 );
   createMenu( CreateImmersibleZoneId, aHydroId, -1, -1 );
   createMenu( CreateChannelId, aHydroId, -1, -1 );
-  createMenu( CreateDigueId, aHydroId, -1, -1 );  
-  createMenu( CreateLandCoverMapId, aHydroId, -1, -1 );  
+  createMenu( CreateDigueId, aHydroId, -1, -1 );
 
   int aNewImageId = createMenu( tr( "MEN_DESK_IMAGE" ), aHydroId, -1 );
   createMenu( ImportImageId, aNewImageId, -1, -1 );
+  createMenu( separator(), aNewImageId );
   createMenu( FuseImagesId, aNewImageId, -1, -1 );
   createMenu( CutImagesId, aNewImageId, -1, -1 );
   createMenu( SplitImageId, aNewImageId, -1, -1 );
@@ -266,24 +264,38 @@ void HYDROGUI_Module::createMenus()
   int aNewPolylineId = createMenu( tr( "MEN_DESK_POLYLINE" ), aHydroId, -1 );
   createMenu( ImportPolylineId, aNewPolylineId, -1, -1 );
   createMenu( CreatePolylineId, aNewPolylineId, -1, -1 );
+  createMenu( separator(), aNewPolylineId );
   createMenu( SplitPolylinesId, aNewPolylineId, -1, -1 );
   createMenu( MergePolylinesId, aNewPolylineId, -1, -1 );
 
   int aNewProfileId = createMenu( tr( "MEN_DESK_PROFILE" ), aHydroId, -1 );
   createMenu( CreateProfileId, aNewProfileId, -1, -1 );
   createMenu( ImportProfilesId, aNewProfileId, -1, -1 );
+  createMenu( separator(), aNewProfileId );
   createMenu( AllGeoreferencementId, aNewProfileId, -1, -1 );
 
   int aStreamMenuId = createMenu( tr( "MEN_DESK_STREAM" ), aHydroId, -1 );
   createMenu( CreateStreamId, aStreamMenuId, -1, -1 );
+  createMenu( separator(), aStreamMenuId );
   createMenu( RiverBottomId, aStreamMenuId, -1, -1 );
   createMenu( ProfileInterpolateId, aStreamMenuId, -1, -1 );
 
   int anObstacleMenuId = createMenu( tr( "MEN_DESK_OBSTACLE" ), aHydroId, -1 );
   createMenu( ImportObstacleFromFileId, anObstacleMenuId, -1, -1 );
+  createMenu( separator(), anObstacleMenuId );
   createMenu( CreateBoxId, anObstacleMenuId, -1, -1 );
   createMenu( CreateCylinderId, anObstacleMenuId, -1, -1 );
 
+  int aLandCoverMapMenuId = createMenu( tr( "MEN_DESK_LAND_COVER_MAP" ), aHydroId, -1 );
+  createMenu( ImportLandCoverMapId, aLandCoverMapMenuId, -1, -1 );
+  createMenu( CreateLandCoverMapId, aLandCoverMapMenuId, -1, -1 );
+  createMenu( separator(), aLandCoverMapMenuId );
+  createMenu( AddLandCoverId, aLandCoverMapMenuId, -1, -1 );
+  createMenu( RemoveLandCoverId, aLandCoverMapMenuId, -1, -1 );
+  createMenu( separator(), aLandCoverMapMenuId );
+  createMenu( SplitLandCoverId, aLandCoverMapMenuId, -1, -1 );
+  createMenu( MergeLandCoverId, aLandCoverMapMenuId, -1, -1 );
+  
   createMenu( CreateCalculationId, aHydroId, -1, -1 );
   createMenu( separator(), aHydroId );
   createMenu( EditLocalCSId, aHydroId, -1, -1 );
@@ -334,6 +346,10 @@ void HYDROGUI_Module::createToolbars()
 
   createTool( separator(), aToolBar );
   createTool( CreateLandCoverMapId, aToolBar );
+  createTool( AddLandCoverId, aToolBar );
+  createTool( RemoveLandCoverId, aToolBar );
+  createTool( SplitLandCoverId, aToolBar );
+  createTool( MergeLandCoverId, aToolBar );
 
   createTool( separator(), aToolBar );
   createTool( CreateCalculationId, aToolBar );
@@ -547,20 +563,11 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
     anOp = new HYDROGUI_StricklerTableOp( aModule, theId );
     break;
   case CreateLandCoverMapId:
-    // TODO
-    //anOp = new HYDROGUI_LandCoverMapOp( aModule, theId == EditLandCoverMapId );
-    break;
   case AddLandCoverId:
-    // TODO
-    break;
   case RemoveLandCoverId:
-    // TODO
-    break;
   case SplitLandCoverId:
-    // TODO
-    break;
   case MergeLandCoverId:
-    // TODO
+    anOp = new HYDROGUI_LandCoverMapOp( aModule, theId );
     break;
   case DuplicateStricklerTableId:
     anOp = new HYDROGUI_DuplicateOp( aModule );
diff --git a/src/HYDROGUI/HYDROGUI_ShapeLandCoverMap.cxx b/src/HYDROGUI/HYDROGUI_ShapeLandCoverMap.cxx
new file mode 100644 (file)
index 0000000..fddf6e7
--- /dev/null
@@ -0,0 +1,104 @@
+// 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_ShapeLandCoverMap.h"
+#include "HYDROGUI_OCCDisplayer.h"
+#include "HYDROGUI_LandCoverMapPrs.h"
+
+#include <HYDROData_LandCoverMap.h>
+
+#include <AIS_InteractiveContext.hxx>
+
+HYDROGUI_ShapeLandCoverMap::HYDROGUI_ShapeLandCoverMap( HYDROGUI_OCCDisplayer* theDisplayer,
+                                                        const Handle(AIS_InteractiveContext)& theContext,
+                                                        const Handle_HYDROData_LandCoverMap&  theLandCoverMap,
+                                                        const int                             theZLayer,
+                                                        const bool                            theIsScalarMode )
+: HYDROGUI_Shape( theContext, theLandCoverMap, theZLayer ),
+  myDisplayer( theDisplayer ),
+  myIsScalarMapMode( theIsScalarMode )
+{
+}
+
+HYDROGUI_ShapeLandCoverMap::~HYDROGUI_ShapeLandCoverMap()
+{
+}
+
+void HYDROGUI_ShapeLandCoverMap::update( bool theIsUpdateViewer, bool isDeactivateSelection )
+{
+  setIsToUpdate( false );
+
+  Handle(HYDROData_LandCoverMap) aLandCoverMapObj =
+    Handle(HYDROData_LandCoverMap)::DownCast( getObject() );
+
+  TopoDS_Shape aLandCoverMapShape = aLandCoverMapObj->GetShape();
+  if ( !aLandCoverMapShape.IsNull() ) {
+    setShape( aLandCoverMapShape, false, false );
+  }
+
+  if ( !myIsScalarMapMode ) {
+    // TODO
+    QColor aFillingColor = Qt::gray;//aLandCoverMapObj->GetFillingColor();
+    QColor aBorderColor = Qt::black;//aLandCoverMapObj->GetBorderColor();
+
+    setFillingColor( aFillingColor, false, false );
+    setBorderColor( aBorderColor, false, false );
+  } else {
+    updateShape( false, false );
+  }
+
+  HYDROGUI_Shape::update( theIsUpdateViewer, isDeactivateSelection );
+}
+
+void HYDROGUI_ShapeLandCoverMap::setScalarMapModeEnabled( const bool theIsToEnable )
+{
+  myIsScalarMapMode = theIsToEnable;
+}
+
+void HYDROGUI_ShapeLandCoverMap::setVisible( const bool theState,
+                                             const bool theIsUpdateViewer )
+{
+  HYDROGUI_Shape::setVisible( theState, theIsUpdateViewer );
+  myDisplayer->SetToUpdateColorScale();
+}
+
+void HYDROGUI_ShapeLandCoverMap::displayShape( const bool theIsUpdateViewer )
+{
+  HYDROGUI_Shape::displayShape( theIsUpdateViewer );
+  myDisplayer->SetToUpdateColorScale();
+}
+
+Handle_AIS_InteractiveObject HYDROGUI_ShapeLandCoverMap::createShape() const
+{
+  Handle(HYDROData_LandCoverMap) aLandCoverMap = Handle(HYDROData_LandCoverMap)::DownCast( getObject() );
+  if ( !aLandCoverMap.IsNull() )
+    return new HYDROGUI_LandCoverMapPrs( aLandCoverMap );
+  return NULL;
+}
+
+void HYDROGUI_ShapeLandCoverMap::display( const bool theIsUpdateViewer )
+{
+  HYDROGUI_Shape::display( theIsUpdateViewer );
+  myDisplayer->SetToUpdateColorScale();
+}
+
+void HYDROGUI_ShapeLandCoverMap::erase( const bool theIsUpdateViewer )
+{
+  HYDROGUI_Shape::erase( theIsUpdateViewer );
+  myDisplayer->SetToUpdateColorScale();
+}
diff --git a/src/HYDROGUI/HYDROGUI_ShapeLandCoverMap.h b/src/HYDROGUI/HYDROGUI_ShapeLandCoverMap.h
new file mode 100644 (file)
index 0000000..025a0fc
--- /dev/null
@@ -0,0 +1,63 @@
+// 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
+//
+
+// REMOVED FROM THE PROJECT, BUT KEPT AS A REFERENCE FILE. TO BE DELETED LATER.
+
+#ifndef HYDROGUI_SHAPE_LANDCOVERMAP_H
+#define HYDROGUI_SHAPE_LANDCOVERMAP_H
+
+#include <HYDROGUI_Shape.h>
+
+class HYDROGUI_OCCDisplayer;
+class Handle_HYDROData_LandCoverMap;
+
+class HYDROGUI_ShapeLandCoverMap : public HYDROGUI_Shape
+{
+public:
+  HYDROGUI_ShapeLandCoverMap( HYDROGUI_OCCDisplayer* theDisplayer,
+                              const Handle(AIS_InteractiveContext)& theContext,
+                              const Handle_HYDROData_LandCoverMap&  theLandCoverMap,
+                              const int                             theZLayer = -1,
+                              const bool                            theIsScalarMode = false );
+  virtual ~HYDROGUI_ShapeLandCoverMap();
+
+  virtual void              update( bool isUpdateViewer,
+                                    bool isDeactivateSelection );
+
+  virtual void display( const bool theIsUpdateViewer = true );
+  virtual void erase( const bool theIsUpdateViewer = true );
+
+  virtual void              setVisible( const bool theState,
+                                        const bool theIsUpdateViewer = true );
+
+  /**
+   * Enable/disable scalar map coloring mode.
+   * @param theIsToEnable if true - scalar map coloring mode willbe enbaled, if false - disabled
+   */
+  virtual void              setScalarMapModeEnabled( const bool theIsToEnable );
+
+protected:
+  virtual void              displayShape( const bool theIsUpdateViewer );
+  virtual Handle_AIS_InteractiveObject createShape() const;
+
+private:
+  HYDROGUI_OCCDisplayer* myDisplayer;
+  bool                   myIsScalarMapMode;
+};
+
+#endif
diff --git a/src/HYDROGUI/HYDROGUI_StricklerTypeComboBox.cxx b/src/HYDROGUI/HYDROGUI_StricklerTypeComboBox.cxx
new file mode 100644 (file)
index 0000000..8f592db
--- /dev/null
@@ -0,0 +1,104 @@
+// 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_StricklerTypeComboBox.h"
+
+#include "HYDROGUI_Module.h"
+
+#include <QLayout>
+#include <QLabel>
+#include <QComboBox>
+
+#include <HYDROData_Iterator.h>
+#include <HYDROData_Document.h>
+#include <HYDROData_StricklerTable.h>
+
+HYDROGUI_StricklerTypeComboBox::HYDROGUI_StricklerTypeComboBox( HYDROGUI_Module* theModule,
+                                                                const QString& theTitle,
+                                                                QWidget* theParent )
+: QWidget( theParent ),
+  myModule( theModule )
+{
+  QBoxLayout* base = new QHBoxLayout( this );
+  base->setMargin( 0 );
+
+  if ( !theTitle.isEmpty() )
+    base->addWidget( new QLabel( theTitle, this ) );    
+  myStricklerTypes = new QComboBox( this );  
+  myStricklerTypes->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  base->addWidget( myStricklerTypes );
+
+  if ( myModule )
+  {
+    // Construct a list of unique names of all Strickler types defined within the data model
+    Handle_HYDROData_Document aDoc = HYDROData_Document::Document( myModule->getStudyId() );
+    if ( aDoc )
+    {
+      QStringList aStricklerTypes;
+      HYDROData_Iterator anIterator( aDoc, KIND_STRICKLER_TABLE );
+      for( ; anIterator.More(); anIterator.Next() )
+      {
+        Handle(HYDROData_StricklerTable) aStricklerTableObj =
+          Handle(HYDROData_StricklerTable)::DownCast( anIterator.Current() );  
+        if ( !aStricklerTableObj.IsNull() )
+        {
+          // Get Strickler table data from the data model
+          QStringList aTypes = aStricklerTableObj->GetTypes();
+          for ( QStringList::iterator it = aTypes.begin(); it != aTypes.end(); ++it )
+          {
+            QString aType = *it;
+            if ( !aType.isEmpty() && !aStricklerTypes.contains( aType ) )
+              aStricklerTypes.append( aType );
+          }
+        }
+      }
+
+      aStricklerTypes.sort();
+      setStricklerTypes( aStricklerTypes );
+    }
+  }
+}
+
+HYDROGUI_StricklerTypeComboBox::~HYDROGUI_StricklerTypeComboBox()
+{
+}
+
+HYDROGUI_Module* HYDROGUI_StricklerTypeComboBox::module() const
+{
+  return myModule;
+}
+
+void HYDROGUI_StricklerTypeComboBox::setStricklerTypes( const QStringList& theTypes )
+{
+  bool isBlocked = blockSignals( true );
+
+  myStricklerTypes->clear();
+  myStricklerTypes->addItems( theTypes );
+
+  blockSignals( isBlocked );
+}
+
+void HYDROGUI_StricklerTypeComboBox::setSelectedStricklerTypeName( const QString& theName )
+{
+  myStricklerTypes->setCurrentIndex( myStricklerTypes->findText( theName ) );
+}
+
+QString HYDROGUI_StricklerTypeComboBox::getSelectedStricklerTypeName() const
+{
+  return myStricklerTypes->currentText();
+}
diff --git a/src/HYDROGUI/HYDROGUI_StricklerTypeComboBox.h b/src/HYDROGUI/HYDROGUI_StricklerTypeComboBox.h
new file mode 100644 (file)
index 0000000..5428039
--- /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 HYDROGUI_STRICKLERTYPECOMBOBOX_H
+#define HYDROGUI_STRICKLERTYPECOMBOBOX_H
+
+#include <QComboBox>
+
+class HYDROGUI_Module;
+
+class HYDROGUI_StricklerTypeComboBox : public QWidget
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_StricklerTypeComboBox( HYDROGUI_Module* theModule, const QString& theTitle, QWidget* theParent = 0 );
+  virtual ~HYDROGUI_StricklerTypeComboBox();
+
+  HYDROGUI_Module*       module() const;
+
+  void                   setStricklerTypes( const QStringList& theTypes );
+  void                   setSelectedStricklerTypeName( const QString& theName );
+  QString                getSelectedStricklerTypeName() const;
+
+private:
+  HYDROGUI_Module*       myModule;
+  QComboBox*             myStricklerTypes;
+};
+
+#endif
index e92266327e99d9f0d0429d78a30339e3ca50e936..7b62597c42e00923ac10713926179f8ec5942ddf 100644 (file)
@@ -48,8 +48,8 @@
       <translation>Strickler table</translation>
     </message>
     <message>
-      <source>DEFAULT_LAND_COVER_NAME</source>
-      <translation>Land cover</translation>
+      <source>DEFAULT_LAND_COVER_MAP_NAME</source>
+      <translation>Land cover map</translation>
     </message>
     <message>
       <source>IMAGES</source>
@@ -1074,7 +1074,7 @@ Would you like to remove all references from the image?</translation>
     </message>
     <message>
       <source>DSK_EXPORT_TO_SHAPE_FILE</source>
-      <translation>Export to Shape file</translation>
+      <translation>Export</translation>
     </message>
     <message>
       <source>DSK_POLYLINE_EXTRACTION</source>
@@ -1217,6 +1217,10 @@ Would you like to remove all references from the image?</translation>
       <source>MEN_DESK_POLYLINE</source>
       <translation>Polyline</translation>
     </message>
+    <message>
+      <source>MEN_DESK_LAND_COVER_MAP</source>
+      <translation>Land cover map</translation>
+    </message>
     <message>
       <source>MEN_EDIT_CALCULATION</source>
       <translation>Edit calculation case</translation>
@@ -1411,7 +1415,7 @@ Would you like to remove all references from the image?</translation>
     </message>
     <message>
       <source>MEN_EXPORT_TO_SHAPE_FILE</source>
-      <translation>Export to Shape file</translation>
+      <translation>Export</translation>
     </message>
     <message>
       <source>MEN_POLYLINE_EXTRACTION</source>
@@ -1725,7 +1729,7 @@ Would you like to remove all references from the image?</translation>
     </message>
     <message>
       <source>STB_EXPORT_TO_SHAPE_FILE</source>
-      <translation>Export to Shape file</translation>
+      <translation>Export</translation>
     </message>
 
 
@@ -2387,7 +2391,7 @@ file cannot be correctly imported for an Obstacle definition.</translation>
     <name>HYDROGUI_ExportFileOp</name>
     <message>
       <source>EXPORT_TO_SHAPE_FILE</source>
-      <translation>Export to Shape file</translation>
+      <translation>Export</translation>
     </message>
     <message>
       <source>SHP_FILTER</source>
@@ -2734,66 +2738,66 @@ Polyline should consist from one not closed curve.</translation>
   </context>
 
   <context>
-    <name>HYDROGUI_LandCoverDlg</name>
+    <name>HYDROGUI_LandCoverMapDlg</name>
     <message>
-      <source>DEFAULT_LAND_COVER_NAME</source>
-      <translation>Land cover</translation>
+      <source>DEFAULT_LAND_COVER_MAP_NAME</source>
+      <translation>Land cover map</translation>
     </message>
     <message>
-      <source>LAND_COVER_NAME</source>
-      <translation>Land cover name</translation>
+      <source>LAND_COVER_MAP_NAME</source>
+      <translation>Land cover map name</translation>
     </message>
     <message>
       <source>NAME</source>
       <translation>Name</translation>
     </message>
     <message>
-      <source>LAND_COVER_PARAMETERS</source>
+      <source>LAND_COVER_MAP_PARAMETERS</source>
       <translation>Parameters</translation>
     </message>
     <message>
-      <source>LAND_COVER_POLYLINES</source>
-      <translation>Polylines</translation>
+      <source>LAND_COVER_MAP_POLYLINE_FACE</source>
+      <translation>Polyline / Face</translation>
     </message>
     <message>
-      <source>LAND_COVER_STRICKLER_TYPE</source>
+      <source>LAND_COVER_MAP_STRICKLER_TYPE</source>
       <translation>Strickler type</translation>
     </message>
+  </context>
+
+  <context>
+    <name>HYDROGUI_LandCoverMapOp</name>
     <message>
-      <source>INCLUDE</source>
-      <translation>Include &gt;&gt;</translation>
+      <source>CREATE_LAND_COVER_MAP</source>
+      <translation>Create land cover map</translation>
     </message>
     <message>
-      <source>EXCLUDE</source>
-      <translation>Exclude &lt;&lt;</translation>
+      <source>ADD_LAND_COVER</source>
+      <translation>Add land cover to the land cover map</translation>
     </message>
-  </context>
-
-  <context>
-    <name>HYDROGUI_LandCoverOp</name>
     <message>
-      <source>CREATE_LAND_COVER</source>
-      <translation>Create land cover</translation>
+      <source>REMOVE_LAND_COVER</source>
+      <translation>Remove land cover from the land cover map</translation>
     </message>
     <message>
-      <source>EDIT_LAND_COVER</source>
-      <translation>Edit land cover</translation>
+      <source>SPLIT_LAND_COVER</source>
+      <translation>Split land cover(s) inside the land cover map</translation>
     </message>
     <message>
-      <source>SELECT_STRICKLER_TABLE_FILE</source>
-      <translation>The Strickler table file is not chosen</translation>
+      <source>MERGE_LAND_COVER</source>
+      <translation>Merge land covers inside the land cover map</translation>
     </message>
     <message>
-      <source>POLYLINES_CHANGED</source>
-      <translation>Polylines list modification</translation>
+      <source>POLYLINE_FACE_NOT_DEFINED</source>
+      <translation>Polyline / Face object should be defined.</translation>
     </message>
     <message>
-      <source>CONFIRM_LAND_COVER_RECALCULATION</source>
-      <translation>Land cover object already exists and will be recalculated after polylines list modification. Do you confirm the recalculation?</translation>
+      <source>STRICKLER_TYPE_NOT_DEFINED</source>
+      <translation>Strickler type should be defined.</translation>
     </message>
     <message>
-      <source>POLYLINES_NOT_DEFINED</source>
-      <translation>At least 1 polyline should be defined.</translation>
+      <source>LAND_COVER_NOT_ADDED</source>
+      <translation>Land cover can not be added.</translation>
     </message>
     <message>
       <source>LAND_COVER_OBJECT_CANNOT_BE_CREATED</source>