From 35284afc5a9d72627ca011ef09ff37d4e15437b9 Mon Sep 17 00:00:00 2001 From: mkr Date: Fri, 23 Oct 2015 11:21:13 +0300 Subject: [PATCH] refs #653, #665 - 669: start implementation of features. --- src/HYDROData/HYDROData_LandCoverMap.h | 12 +- src/HYDROGUI/CMakeLists.txt | 8 + src/HYDROGUI/HYDROGUI_LandCoverMapDlg.cxx | 193 +++++++++++ src/HYDROGUI/HYDROGUI_LandCoverMapDlg.h | 76 +++++ src/HYDROGUI/HYDROGUI_LandCoverMapOp.cxx | 310 ++++++++++++++++++ src/HYDROGUI/HYDROGUI_LandCoverMapOp.h | 59 ++++ src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx | 42 ++- src/HYDROGUI/HYDROGUI_Operations.cxx | 39 ++- src/HYDROGUI/HYDROGUI_ShapeLandCoverMap.cxx | 104 ++++++ src/HYDROGUI/HYDROGUI_ShapeLandCoverMap.h | 63 ++++ .../HYDROGUI_StricklerTypeComboBox.cxx | 104 ++++++ src/HYDROGUI/HYDROGUI_StricklerTypeComboBox.h | 45 +++ src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 74 +++-- 13 files changed, 1050 insertions(+), 79 deletions(-) create mode 100644 src/HYDROGUI/HYDROGUI_LandCoverMapDlg.cxx create mode 100644 src/HYDROGUI/HYDROGUI_LandCoverMapDlg.h create mode 100644 src/HYDROGUI/HYDROGUI_LandCoverMapOp.cxx create mode 100644 src/HYDROGUI/HYDROGUI_LandCoverMapOp.h create mode 100644 src/HYDROGUI/HYDROGUI_ShapeLandCoverMap.cxx create mode 100644 src/HYDROGUI/HYDROGUI_ShapeLandCoverMap.h create mode 100644 src/HYDROGUI/HYDROGUI_StricklerTypeComboBox.cxx create mode 100644 src/HYDROGUI/HYDROGUI_StricklerTypeComboBox.h diff --git a/src/HYDROData/HYDROData_LandCoverMap.h b/src/HYDROData/HYDROData_LandCoverMap.h index ed60ce28..2439c2de 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.h +++ b/src/HYDROData/HYDROData_LandCoverMap.h @@ -96,14 +96,14 @@ public: bool ExportTelemac( const QString& theFileName, double theDeflection ) const; - bool Add( const Handle( HYDROData_Object )&, const QString& theType ); - bool Add( const Handle( HYDROData_PolylineXY )&, const QString& theType ); + HYDRODATA_EXPORT bool Add( const Handle( HYDROData_Object )&, const QString& theType ); + HYDRODATA_EXPORT bool Add( const Handle( HYDROData_PolylineXY )&, const QString& theType ); - bool Remove( const TopoDS_Face& ); - bool Remove( const TopTools_ListOfShape& ); + HYDRODATA_EXPORT bool Remove( const TopoDS_Face& ); + HYDRODATA_EXPORT bool Remove( const TopTools_ListOfShape& ); - bool Split( const Handle( HYDROData_PolylineXY )& ); - bool Merge( const TopTools_ListOfShape&, const QString& theType ); + HYDRODATA_EXPORT bool Split( const Handle( HYDROData_PolylineXY )& ); + HYDRODATA_EXPORT bool Merge( const TopTools_ListOfShape&, const QString& theType ); TopoDS_Face FindByPoint( const gp_Pnt2d&, QString& theType ) const; diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 18e7950a..bbaf85f3 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -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 index 00000000..0c964637 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_LandCoverMapDlg.cxx @@ -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 +#include + +#include +#include +#include +#include +#include + +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 index 00000000..211740c8 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_LandCoverMapDlg.h @@ -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 index 00000000..96655be1 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_LandCoverMapOp.cxx @@ -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 +#include +#include +#include + +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( 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( 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( 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( + 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 index 00000000..092af90e --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_LandCoverMapOp.h @@ -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 + +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 diff --git a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx index a8e73707..aa5a6fe7 100644 --- a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx +++ b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx @@ -23,8 +23,7 @@ #include "HYDROGUI_Tool.h" #include #include -// TODO -//#include +#include #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 aLandCoverShapes = module()->getObjectShapes( aViewerId, KIND_LAND_COVER_MAP ); + QList aLandCoverMapShapes = module()->getObjectShapes( aViewerId, KIND_LAND_COVER_MAP ); QList 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( aShape ); + foreach( HYDROGUI_Shape* aShape, aLandCoverMapShapes ) { + HYDROGUI_ShapeLandCoverMap* aLandCoverMapShape = + dynamic_cast( 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; } diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index 5641a2c4..1715bc47 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -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 index 00000000..fddf6e70 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ShapeLandCoverMap.cxx @@ -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 + +#include + +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 index 00000000..025a0fcc --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ShapeLandCoverMap.h @@ -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 + +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 index 00000000..8f592db3 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_StricklerTypeComboBox.cxx @@ -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 +#include +#include + +#include +#include +#include + +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 index 00000000..5428039b --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_StricklerTypeComboBox.h @@ -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 + +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 diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index e9226632..7b62597c 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -48,8 +48,8 @@ Strickler table - DEFAULT_LAND_COVER_NAME - Land cover + DEFAULT_LAND_COVER_MAP_NAME + Land cover map IMAGES @@ -1074,7 +1074,7 @@ Would you like to remove all references from the image? DSK_EXPORT_TO_SHAPE_FILE - Export to Shape file + Export DSK_POLYLINE_EXTRACTION @@ -1217,6 +1217,10 @@ Would you like to remove all references from the image? MEN_DESK_POLYLINE Polyline + + MEN_DESK_LAND_COVER_MAP + Land cover map + MEN_EDIT_CALCULATION Edit calculation case @@ -1411,7 +1415,7 @@ Would you like to remove all references from the image? MEN_EXPORT_TO_SHAPE_FILE - Export to Shape file + Export MEN_POLYLINE_EXTRACTION @@ -1725,7 +1729,7 @@ Would you like to remove all references from the image? STB_EXPORT_TO_SHAPE_FILE - Export to Shape file + Export @@ -2387,7 +2391,7 @@ file cannot be correctly imported for an Obstacle definition. HYDROGUI_ExportFileOp EXPORT_TO_SHAPE_FILE - Export to Shape file + Export SHP_FILTER @@ -2734,66 +2738,66 @@ Polyline should consist from one not closed curve. - HYDROGUI_LandCoverDlg + HYDROGUI_LandCoverMapDlg - DEFAULT_LAND_COVER_NAME - Land cover + DEFAULT_LAND_COVER_MAP_NAME + Land cover map - LAND_COVER_NAME - Land cover name + LAND_COVER_MAP_NAME + Land cover map name NAME Name - LAND_COVER_PARAMETERS + LAND_COVER_MAP_PARAMETERS Parameters - LAND_COVER_POLYLINES - Polylines + LAND_COVER_MAP_POLYLINE_FACE + Polyline / Face - LAND_COVER_STRICKLER_TYPE + LAND_COVER_MAP_STRICKLER_TYPE Strickler type + + + + HYDROGUI_LandCoverMapOp - INCLUDE - Include >> + CREATE_LAND_COVER_MAP + Create land cover map - EXCLUDE - Exclude << + ADD_LAND_COVER + Add land cover to the land cover map - - - - HYDROGUI_LandCoverOp - CREATE_LAND_COVER - Create land cover + REMOVE_LAND_COVER + Remove land cover from the land cover map - EDIT_LAND_COVER - Edit land cover + SPLIT_LAND_COVER + Split land cover(s) inside the land cover map - SELECT_STRICKLER_TABLE_FILE - The Strickler table file is not chosen + MERGE_LAND_COVER + Merge land covers inside the land cover map - POLYLINES_CHANGED - Polylines list modification + POLYLINE_FACE_NOT_DEFINED + Polyline / Face object should be defined. - CONFIRM_LAND_COVER_RECALCULATION - Land cover object already exists and will be recalculated after polylines list modification. Do you confirm the recalculation? + STRICKLER_TYPE_NOT_DEFINED + Strickler type should be defined. - POLYLINES_NOT_DEFINED - At least 1 polyline should be defined. + LAND_COVER_NOT_ADDED + Land cover can not be added. LAND_COVER_OBJECT_CANNOT_BE_CREATED -- 2.39.2