From: mkr Date: Mon, 8 Jun 2015 09:13:47 +0000 (+0300) Subject: refs #568: Land Cover: a draft of data model and implementation of dialog box and... X-Git-Tag: v1.4.1~6^2~4^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5e9382826b48843ce2b958dc4d9a5e0b99f938c7;p=modules%2Fhydro.git refs #568: Land Cover: a draft of data model and implementation of dialog box and operation (GUI). --- diff --git a/src/HYDROData/CMakeLists.txt b/src/HYDROData/CMakeLists.txt index 5447d280..178f3200 100644 --- a/src/HYDROData/CMakeLists.txt +++ b/src/HYDROData/CMakeLists.txt @@ -42,6 +42,7 @@ set(PROJECT_HEADERS HYDROData_Stream.h HYDROData_StreamAltitude.h HYDROData_StricklerTable.h + HYDROData_LandCover.h HYDROData_Tool.h HYDROData_Transform.h HYDROData_VisualState.h @@ -94,6 +95,7 @@ set(PROJECT_SOURCES HYDROData_Stream.cxx HYDROData_StreamAltitude.cxx HYDROData_StricklerTable.cxx + HYDROData_LandCover.cxx HYDROData_Tool.cxx HYDROData_Transform.cxx HYDROData_VisualState.cxx diff --git a/src/HYDROData/HYDROData_Entity.cxx b/src/HYDROData/HYDROData_Entity.cxx index f51b2644..bd47a090 100644 --- a/src/HYDROData/HYDROData_Entity.cxx +++ b/src/HYDROData/HYDROData_Entity.cxx @@ -599,7 +599,8 @@ QString HYDROData_Entity::getPyTypeID() const case KIND_SPLITTED_GROUP: return "KIND_SPLITTED_GROUP"; case KIND_STREAM_ALTITUDE: return "KIND_STREAM_ALTITUDE"; case KIND_OBSTACLE_ALTITUDE: return "KIND_OBSTACLE_ALTITUDE"; - case KIND_STRICKLER_TABLE: return "KIND_STRICKLER_TABLE"; + case KIND_STRICKLER_TABLE: return "KIND_STRICKLER_TABLE"; + case KIND_LAND_COVER: return "KIND_LAND_COVER"; default: return "KIND_UNKNOWN"; ///! Unrecognized object } } diff --git a/src/HYDROData/HYDROData_Entity.h b/src/HYDROData/HYDROData_Entity.h index fd864063..8e493729 100644 --- a/src/HYDROData/HYDROData_Entity.h +++ b/src/HYDROData/HYDROData_Entity.h @@ -64,7 +64,8 @@ const ObjectKind KIND_SPLITTED_GROUP = 23; const ObjectKind KIND_STREAM_ALTITUDE = 24; const ObjectKind KIND_OBSTACLE_ALTITUDE = 25; const ObjectKind KIND_STRICKLER_TABLE = 26; -const ObjectKind KIND_LAST = KIND_STRICKLER_TABLE; +const ObjectKind KIND_LAND_COVER = 27; +const ObjectKind KIND_LAST = KIND_LAND_COVER; DEFINE_STANDARD_HANDLE(HYDROData_Entity, MMgt_TShared) diff --git a/src/HYDROData/HYDROData_Iterator.cxx b/src/HYDROData/HYDROData_Iterator.cxx index 18b3dffd..a52f9328 100644 --- a/src/HYDROData/HYDROData_Iterator.cxx +++ b/src/HYDROData/HYDROData_Iterator.cxx @@ -42,6 +42,7 @@ #include "HYDROData_StreamAltitude.h" #include "HYDROData_Zone.h" #include "HYDROData_StricklerTable.h" +#include "HYDROData_LandCover.h" #include #include @@ -150,7 +151,8 @@ Handle(HYDROData_Entity) HYDROData_Iterator::Object( const TDF_Label& theLabel ) case KIND_SPLITTED_GROUP: aResult = new HYDROData_SplittedShapesGroup(); break; case KIND_STREAM_ALTITUDE: aResult = new HYDROData_StreamAltitude(); break; case KIND_OBSTACLE_ALTITUDE: aResult = new HYDROData_ObstacleAltitude(); break; - case KIND_STRICKLER_TABLE: aResult = new HYDROData_StricklerTable(); break; + case KIND_STRICKLER_TABLE: aResult = new HYDROData_StricklerTable(); break; + case KIND_LAND_COVER: aResult = new HYDROData_LandCover(); break; default: break; } diff --git a/src/HYDROData/HYDROData_LandCover.cxx b/src/HYDROData/HYDROData_LandCover.cxx new file mode 100644 index 00000000..a6711927 --- /dev/null +++ b/src/HYDROData/HYDROData_LandCover.cxx @@ -0,0 +1,36 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "HYDROData_LandCover.h" + +IMPLEMENT_STANDARD_HANDLE( HYDROData_LandCover, HYDROData_Entity ) +IMPLEMENT_STANDARD_RTTIEXT( HYDROData_LandCover, HYDROData_Entity ) + +HYDROData_LandCover::HYDROData_LandCover() +{ +} + + +HYDROData_LandCover::~HYDROData_LandCover() +{ +} + +const ObjectKind HYDROData_LandCover::GetKind() const +{ + return KIND_LAND_COVER; +} diff --git a/src/HYDROData/HYDROData_LandCover.h b/src/HYDROData/HYDROData_LandCover.h new file mode 100644 index 00000000..246208e3 --- /dev/null +++ b/src/HYDROData/HYDROData_LandCover.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 HYDROData_LANDCOVER_HeaderFile +#define HYDROData_LANDCOVER_HeaderFile + +#include + +DEFINE_STANDARD_HANDLE( HYDROData_LandCover, HYDROData_Entity ) + +class HYDROData_LandCover : public HYDROData_Entity +{ +protected: + friend class HYDROData_Iterator; + + enum DataTag + { + DataTag_Table = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve + }; + + HYDRODATA_EXPORT HYDROData_LandCover(); + HYDRODATA_EXPORT ~HYDROData_LandCover(); + +public: + DEFINE_STANDARD_RTTI( HYDROData_LandCover ); + + HYDRODATA_EXPORT virtual const ObjectKind GetKind() const; +}; + +#endif diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index eeca42fc..b06c6908 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -27,6 +27,7 @@ set(PROJECT_HEADERS HYDROGUI_ExportImageOp.h HYDROGUI_GVSelector.h HYDROGUI_ImagePrs.h + HYDROGUI_BasicZoneDlg.h HYDROGUI_ImmersibleZoneDlg.h HYDROGUI_ImmersibleZoneOp.h HYDROGUI_ImportBathymetryDlg.h @@ -74,6 +75,8 @@ set(PROJECT_HEADERS HYDROGUI_LineEditDoubleValidator.h HYDROGUI_StricklerTableDlg.h HYDROGUI_StricklerTableOp.h + HYDROGUI_LandCoverDlg.h + HYDROGUI_LandCoverOp.h HYDROGUI_SubmersibleOp.h HYDROGUI_Tool.h HYDROGUI_TwoImagesDlg.h @@ -144,6 +147,7 @@ set(PROJECT_SOURCES HYDROGUI_ExportImageOp.cxx HYDROGUI_GVSelector.cxx HYDROGUI_ImagePrs.cxx + HYDROGUI_BasicZoneDlg.cxx HYDROGUI_ImmersibleZoneDlg.cxx HYDROGUI_ImmersibleZoneOp.cxx HYDROGUI_ImportBathymetryDlg.cxx @@ -191,6 +195,8 @@ set(PROJECT_SOURCES HYDROGUI_LineEditDoubleValidator.cxx HYDROGUI_StricklerTableDlg.cxx HYDROGUI_StricklerTableOp.cxx + HYDROGUI_LandCoverDlg.cxx + HYDROGUI_LandCoverOp.cxx HYDROGUI_SubmersibleOp.cxx HYDROGUI_Tool.cxx HYDROGUI_TwoImagesDlg.cxx diff --git a/src/HYDROGUI/HYDROGUI_BasicZoneDlg.cxx b/src/HYDROGUI/HYDROGUI_BasicZoneDlg.cxx new file mode 100644 index 00000000..31af61fd --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_BasicZoneDlg.cxx @@ -0,0 +1,106 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "HYDROGUI_BasicZoneDlg.h" + +#include +#include +#include +#include +#include + +HYDROGUI_BasicZoneDlg::HYDROGUI_BasicZoneDlg( HYDROGUI_Module* theModule, const QString& theTitle, + const QString& theLabel1, const QString& theLabel2, + const QString& theLabel3, const QString& theLabel4 ) +: HYDROGUI_InputPanel( theModule, theTitle ) +{ + // Zone name + myObjectNameGroup = new QGroupBox( theLabel1, mainFrame() ); + + myObjectName = new QLineEdit( myObjectNameGroup ); + + QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup ); + aNameLayout->setMargin( 5 ); + aNameLayout->setSpacing( 5 ); + aNameLayout->addWidget( new QLabel( theLabel2, myObjectNameGroup ) ); + aNameLayout->addWidget( myObjectName ); + + // Main parameters: group-box and frame + myParamGroup = new QGroupBox( theLabel3, mainFrame() ); + + myPolylineFrame = new QFrame( myParamGroup ); + + // Additional parameter defined with help of combo-box control + myAdditionalParamsGroup = new QGroupBox( theLabel4, mainFrame() ); + + myAdditionalParams = new QComboBox( myPolylineFrame ); + myAdditionalParams->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + QBoxLayout* aBathLayout = new QHBoxLayout( myAdditionalParamsGroup ); + aBathLayout->setMargin( 5 ); + aBathLayout->setSpacing( 5 ); + aBathLayout->addWidget( myAdditionalParams ); + + // Common + addWidget( myObjectNameGroup ); + addWidget( myParamGroup ); + addWidget( myAdditionalParamsGroup ); + + addStretch(); +} + +HYDROGUI_BasicZoneDlg::~HYDROGUI_BasicZoneDlg() +{ +} + +void HYDROGUI_BasicZoneDlg::reset() +{ + myObjectName->clear(); + myAdditionalParams->clear(); +} + +void HYDROGUI_BasicZoneDlg::setObjectName( const QString& theName ) +{ + myObjectName->setText( theName ); +} + +QString HYDROGUI_BasicZoneDlg::getObjectName() const +{ + return myObjectName->text(); +} + +void HYDROGUI_BasicZoneDlg::setAdditionalParams( const QStringList& thePrams ) +{ + bool isBlocked = blockSignals( true ); + + myAdditionalParams->clear(); + myAdditionalParams->addItems( thePrams ); + + blockSignals( isBlocked ); +} + +void HYDROGUI_BasicZoneDlg::setSelectedAdditionalParamName( const QString& theParam ) +{ + int aNewIdx = myAdditionalParams->findText( theParam ); + myAdditionalParams->setCurrentIndex( aNewIdx ); +} + +QString HYDROGUI_BasicZoneDlg::getSelectedAdditionalParamName() const +{ + return myAdditionalParams->currentText(); +} diff --git a/src/HYDROGUI/HYDROGUI_BasicZoneDlg.h b/src/HYDROGUI/HYDROGUI_BasicZoneDlg.h new file mode 100644 index 00000000..b89e1ca8 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_BasicZoneDlg.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_BASICZONEDLG_H +#define HYDROGUI_BASICZONEDLG_H + +#include "HYDROGUI_InputPanel.h" + +class QComboBox; +class QGroupBox; +class QLineEdit; +class QFrame; + +class HYDROGUI_BasicZoneDlg : public HYDROGUI_InputPanel +{ + Q_OBJECT + +public: + HYDROGUI_BasicZoneDlg( HYDROGUI_Module* theModule, const QString& theTitle, + const QString& theLabel1, const QString& theLabel2, + const QString& theLabel3, const QString& theLabel4 ); + virtual ~HYDROGUI_BasicZoneDlg(); + + virtual void reset(); + + void setObjectName( const QString& theName ); + QString getObjectName() const; + + void setAdditionalParams( const QStringList& thePrams ); + void setSelectedAdditionalParamName( const QString& theParam ); + QString getSelectedAdditionalParamName() const; + +protected: + QGroupBox* myObjectNameGroup; + QLineEdit* myObjectName; + + QGroupBox* myParamGroup; + QFrame* myPolylineFrame; + + QGroupBox* myAdditionalParamsGroup; + QComboBox* myAdditionalParams; // bathymetries or strickler types +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_DataModel.cxx b/src/HYDROGUI/HYDROGUI_DataModel.cxx index c3df102e..b6537bfe 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.cxx +++ b/src/HYDROGUI/HYDROGUI_DataModel.cxx @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -271,6 +272,9 @@ void HYDROGUI_DataModel::update( const int theStudyId ) // STRICKLER TABLES LightApp_DataObject* aStricklerTablesRootObj = createObject( aNewRootObj, tr( partitionName( KIND_STRICKLER_TABLE ).toAscii() ) ); + // LAND COVERS + LightApp_DataObject* aLandCoversRootObj = createObject( aNewRootObj, tr( partitionName( KIND_LAND_COVER ).toAscii() ) ); + // CALCULATION CASES LightApp_DataObject* aCalculRootObj = createObject( aNewRootObj, tr( partitionName( KIND_CALCULATION ).toAscii() ) ); @@ -375,14 +379,24 @@ void HYDROGUI_DataModel::update( const int theStudyId ) break; } - case KIND_STRICKLER_TABLE: + case KIND_STRICKLER_TABLE: { - Handle(HYDROData_StricklerTable) anStricklerTableObj = + Handle(HYDROData_StricklerTable) aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( anObj ); - if( !anStricklerTableObj.IsNull() ) { - obj = createObject( aStricklerTablesRootObj, anStricklerTableObj ); + if( !aStricklerTableObj.IsNull() ) { + obj = createObject( aStricklerTablesRootObj, aStricklerTableObj ); + } + aNoStricklerTableObj++; + + break; + } + case KIND_LAND_COVER: + { + Handle(HYDROData_LandCover) aLandCoverObj = + Handle(HYDROData_LandCover)::DownCast( anObj ); + if( !aLandCoverObj.IsNull() ) { + obj = createObject( aLandCoversRootObj, aLandCoverObj ); } - aNoStricklerTableObj++; break; } @@ -682,6 +696,7 @@ QString HYDROGUI_DataModel::partitionName( const ObjectKind theObjectKind ) case KIND_ARTIFICIAL_OBJECT: return "ARTIFICIAL_OBJECTS"; case KIND_NATURAL_OBJECT: return "NATURAL_OBJECTS"; case KIND_STRICKLER_TABLE: return "STRICKLER_TABLES"; + case KIND_LAND_COVER: return "LAND_COVERS"; default: break; } return QString(); @@ -779,25 +794,25 @@ void HYDROGUI_DataModel::createDefaultStricklerTable( const Handle(HYDROData_Doc LightApp_DataObject* theParent ) { // Create default Strickler table object - Handle(HYDROData_StricklerTable) anStricklerTableObj = + Handle(HYDROData_StricklerTable) aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( theDocument->CreateObject(KIND_STRICKLER_TABLE) ); - if ( !anStricklerTableObj.IsNull() ) + if ( !aStricklerTableObj.IsNull() ) { - anStricklerTableObj->Import( HYDROGUI_Tool::ToAsciiString( tr( "DEFAULT_STRICKLER_TABLE_FILE" ) ) ); - // Set name + aStricklerTableObj->Import( HYDROGUI_Tool::ToAsciiString( tr( "DEFAULT_STRICKLER_TABLE_FILE" ) ) ); + // Set name QString aStricklerTableName; - if ( anStricklerTableObj->GetName().isEmpty() ) + if ( aStricklerTableObj->GetName().isEmpty() ) { HYDROGUI_Module* aModule = dynamic_cast( module() ); if ( aModule ) aStricklerTableName = HYDROGUI_Tool::GenerateObjectName( aModule, tr( "DEFAULT_STRICKLER_TABLE_NAME" ) ); } - if ( anStricklerTableObj->GetName() != aStricklerTableName ) - anStricklerTableObj->SetName( aStricklerTableName ); + if ( aStricklerTableObj->GetName() != aStricklerTableName ) + aStricklerTableObj->SetName( aStricklerTableName ); - anStricklerTableObj->Update(); + aStricklerTableObj->Update(); - LightApp_DataObject* obj = createObject( theParent, anStricklerTableObj ); + LightApp_DataObject* obj = createObject( theParent, aStricklerTableObj ); } } diff --git a/src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.cxx b/src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.cxx index 000c4907..85130b2a 100644 --- a/src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.cxx @@ -24,59 +24,25 @@ #include #include #include -#include HYDROGUI_ImmersibleZoneDlg::HYDROGUI_ImmersibleZoneDlg( HYDROGUI_Module* theModule, const QString& theTitle ) -: HYDROGUI_InputPanel( theModule, theTitle ) +: HYDROGUI_BasicZoneDlg( theModule, theTitle, + tr( "ZONE_NAME" ), tr( "NAME" ), + tr( "ZONE_PARAMETERS" ), tr( "ZONE_BATHYMETRY" ) ) { - // Zone name - myObjectNameGroup = new QGroupBox( tr( "ZONE_NAME" ), mainFrame() ); - - myObjectName = new QLineEdit( myObjectNameGroup ); - - QBoxLayout* aNameLayout = new QHBoxLayout( myObjectNameGroup ); - aNameLayout->setMargin( 5 ); - aNameLayout->setSpacing( 5 ); - aNameLayout->addWidget( new QLabel( tr( "NAME" ), myObjectNameGroup ) ); - aNameLayout->addWidget( myObjectName ); - - - QGroupBox* aParamGroup = new QGroupBox( tr( "ZONE_PARAMETERS" ), mainFrame() ); - - QFrame* aPolylineFrame = new QFrame( aParamGroup ); - - myPolylines = new QComboBox( aPolylineFrame ); + myPolylines = new QComboBox( myPolylineFrame ); myPolylines->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - QBoxLayout* aPolyLayout = new QHBoxLayout( aPolylineFrame ); + QBoxLayout* aPolyLayout = new QHBoxLayout( myPolylineFrame ); aPolyLayout->setMargin( 0 ); aPolyLayout->setSpacing( 5 ); - aPolyLayout->addWidget( new QLabel( tr( "ZONE_POLYLINE" ), aPolylineFrame ) ); + aPolyLayout->addWidget( new QLabel( tr( "ZONE_POLYLINE" ), myPolylineFrame ) ); aPolyLayout->addWidget( myPolylines ); - QBoxLayout* aParamLayout = new QVBoxLayout( aParamGroup ); + QBoxLayout* aParamLayout = new QVBoxLayout( myParamGroup ); aParamLayout->setMargin( 5 ); aParamLayout->setSpacing( 5 ); - aParamLayout->addWidget( aPolylineFrame ); - - QGroupBox* aBathGroup = new QGroupBox( tr( "ZONE_BATHYMETRY" ), mainFrame() ); - - myBathymetries = new QComboBox( aPolylineFrame ); - myBathymetries->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - - QBoxLayout* aBathLayout = new QHBoxLayout( aBathGroup ); - aBathLayout->setMargin( 5 ); - aBathLayout->setSpacing( 5 ); - aBathLayout->addWidget( myBathymetries ); - - - // Common - addWidget( myObjectNameGroup ); - addWidget( aParamGroup ); - addWidget( aBathGroup ); - - addStretch(); - + aParamLayout->addWidget( myPolylineFrame ); // Connect signals and slots connect( myPolylines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onZoneDefChanged() ) ); @@ -90,26 +56,15 @@ void HYDROGUI_ImmersibleZoneDlg::reset() { bool isBlocked = blockSignals( true ); - myObjectName->clear(); + HYDROGUI_BasicZoneDlg::reset(); myPolylines->clear(); - myBathymetries->clear(); - + blockSignals( isBlocked ); onZoneDefChanged(); } -void HYDROGUI_ImmersibleZoneDlg::setObjectName( const QString& theName ) -{ - myObjectName->setText( theName ); -} - -QString HYDROGUI_ImmersibleZoneDlg::getObjectName() const -{ - return myObjectName->text(); -} - void HYDROGUI_ImmersibleZoneDlg::setPolylineNames( const QStringList& thePolylines ) { bool isBlocked = blockSignals( true ); @@ -138,27 +93,6 @@ QString HYDROGUI_ImmersibleZoneDlg::getPolylineName() const return myPolylines->currentText(); } -void HYDROGUI_ImmersibleZoneDlg::setBathymetryNames( const QStringList& theBathymetries ) -{ - bool isBlocked = blockSignals( true ); - - myBathymetries->clear(); - myBathymetries->addItems( theBathymetries ); - - blockSignals( isBlocked ); -} - -void HYDROGUI_ImmersibleZoneDlg::setBathymetryName( const QString& theName ) -{ - int aNewIdx = myBathymetries->findText( theName ); - myBathymetries->setCurrentIndex( aNewIdx ); -} - -QString HYDROGUI_ImmersibleZoneDlg::getBathymetryName() const -{ - return myBathymetries->currentText(); -} - void HYDROGUI_ImmersibleZoneDlg::onZoneDefChanged() { if ( signalsBlocked() ) diff --git a/src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.h b/src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.h index ea64b763..a7190f2c 100644 --- a/src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.h +++ b/src/HYDROGUI/HYDROGUI_ImmersibleZoneDlg.h @@ -19,13 +19,11 @@ #ifndef HYDROGUI_ImmersibleZoneDlg_H #define HYDROGUI_ImmersibleZoneDlg_H -#include "HYDROGUI_InputPanel.h" +#include "HYDROGUI_BasicZoneDlg.h" class QComboBox; -class QGroupBox; -class QLineEdit; -class HYDROGUI_ImmersibleZoneDlg : public HYDROGUI_InputPanel +class HYDROGUI_ImmersibleZoneDlg : public HYDROGUI_BasicZoneDlg { Q_OBJECT @@ -33,19 +31,12 @@ public: HYDROGUI_ImmersibleZoneDlg( HYDROGUI_Module* theModule, const QString& theTitle ); virtual ~HYDROGUI_ImmersibleZoneDlg(); - void reset(); - - void setObjectName( const QString& theName ); - QString getObjectName() const; + virtual void reset(); void setPolylineNames( const QStringList& thePolylines ); void setPolylineName( const QString& thePolyline ); QString getPolylineName() const; - void setBathymetryNames( const QStringList& theBathymetries ); - void setBathymetryName( const QString& theBathymetry ); - QString getBathymetryName() const; - signals: void CreatePreview( const QString& thePolylineName ); @@ -53,12 +44,7 @@ private slots: void onZoneDefChanged(); private: - - QGroupBox* myObjectNameGroup; - QLineEdit* myObjectName; - QComboBox* myPolylines; - QComboBox* myBathymetries; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx index dc674b74..678d8059 100644 --- a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx @@ -96,12 +96,12 @@ void HYDROGUI_ImmersibleZoneOp::startOperation() aPanel->setObjectName( anObjectName ); aPanel->setPolylineNames( HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_POLYLINEXY ) ); - aPanel->setBathymetryNames( HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_BATHYMETRY ) ); + aPanel->setAdditionalParams( HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_BATHYMETRY ) ); aPanel->blockSignals( false ); aPanel->setPolylineName( aSelectedPolyline ); - aPanel->setBathymetryName( aSelectedBathymetry ); + aPanel->setSelectedAdditionalParamName( aSelectedBathymetry ); } void HYDROGUI_ImmersibleZoneOp::abortOperation() @@ -162,7 +162,7 @@ bool HYDROGUI_ImmersibleZoneOp::processApply( int& theUpdateFlags, HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINEXY ) ); } - QString aBathymetryName = aPanel->getBathymetryName(); + QString aBathymetryName = aPanel->getSelectedAdditionalParamName(); if ( !aBathymetryName.isEmpty() ) { aZoneBathymetry = Handle(HYDROData_Bathymetry)::DownCast( diff --git a/src/HYDROGUI/HYDROGUI_LandCoverDlg.cxx b/src/HYDROGUI/HYDROGUI_LandCoverDlg.cxx new file mode 100644 index 00000000..fabcc568 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_LandCoverDlg.cxx @@ -0,0 +1,125 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "HYDROGUI_LandCoverDlg.h" + +#include +#include +#include +#include + +HYDROGUI_LandCoverDlg::HYDROGUI_LandCoverDlg( HYDROGUI_Module* theModule, const QString& theTitle ) +: HYDROGUI_BasicZoneDlg( theModule, theTitle, + tr( "LAND_COVER_NAME" ), tr( "NAME" ), + tr( "LAND_COVER_PARAMETERS" ), tr( "LAND_COVER_STRICKLER_TYPE" ) ) +{ + myPolylines = new QListWidget( myPolylineFrame ); + myPolylines->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + myPolylines->setSelectionMode( QAbstractItemView::ExtendedSelection ); + + QBoxLayout* aPolyLayout = new QVBoxLayout( myPolylineFrame ); + aPolyLayout->setMargin( 0 ); + aPolyLayout->setSpacing( 5 ); + aPolyLayout->addWidget( new QLabel( tr( "LAND_COVER_POLYLINES" ), myPolylineFrame ) ); + aPolyLayout->addWidget( myPolylines ); + + QBoxLayout* aParamLayout = new QVBoxLayout( myParamGroup ); + aParamLayout->setMargin( 5 ); + aParamLayout->setSpacing( 5 ); + aParamLayout->addWidget( myPolylineFrame ); + + // Connect signals and slots + connect( myPolylines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onZoneDefChanged() ) ); +} + +HYDROGUI_LandCoverDlg::~HYDROGUI_LandCoverDlg() +{ +} + +void HYDROGUI_LandCoverDlg::reset() +{ + bool isBlocked = blockSignals( true ); + + HYDROGUI_BasicZoneDlg::reset(); + + myPolylines->clear(); + + blockSignals( isBlocked ); + + onZoneDefChanged(); +} + +void HYDROGUI_LandCoverDlg::setPolylineNames( const QStringList& thePolylines ) +{ + bool isBlocked = blockSignals( true ); + + myPolylines->clear(); + myPolylines->addItems( thePolylines ); + + blockSignals( isBlocked ); +} + +void HYDROGUI_LandCoverDlg::setSelectedPolylineNames( const QStringList& theSelectedPolylines ) +{ + bool anUpdateNeeded = false; + for (int i =0; i< myPolylines->count(); i++) + { + QListWidgetItem* anItem = myPolylines->item( i ); + if ( anItem ) + { + bool aIsSelected = anItem->isSelected(); + if ( theSelectedPolylines.contains( anItem->text() ) ) + { + if ( !aIsSelected ) + { + anUpdateNeeded = true; + anItem->setSelected( true ); + } + } + else if ( aIsSelected ) + { + anUpdateNeeded = true; + anItem->setSelected( false ); + } + } + } + + if ( anUpdateNeeded ) + onZoneDefChanged(); +} + +QStringList HYDROGUI_LandCoverDlg::getSelectedPolylineNames() const +{ + QStringList aSelectedPolylines; + + QList aSelectedItems = myPolylines->selectedItems(); + QList::const_iterator anIt = aSelectedItems.begin(), aLast = aSelectedItems.end(); + for( ; anIt!=aLast; anIt++ ) + aSelectedPolylines.append( (*anIt)->text() ); + + return aSelectedPolylines; +} + +void HYDROGUI_LandCoverDlg::onZoneDefChanged() +{ + if ( signalsBlocked() ) + return; + + QStringList aPolylineNames = getSelectedPolylineNames(); + emit CreatePreview( aPolylineNames ); +} diff --git a/src/HYDROGUI/HYDROGUI_LandCoverDlg.h b/src/HYDROGUI/HYDROGUI_LandCoverDlg.h new file mode 100644 index 00000000..bb529fa0 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_LandCoverDlg.h @@ -0,0 +1,50 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HYDROGUI_LANDCOVERDLG_H +#define HYDROGUI_LANDCOVERDLG_H + +#include "HYDROGUI_BasicZoneDlg.h" + +class QListWidget; + +class HYDROGUI_LandCoverDlg : public HYDROGUI_BasicZoneDlg +{ + Q_OBJECT + +public: + HYDROGUI_LandCoverDlg( HYDROGUI_Module* theModule, const QString& theTitle ); + virtual ~HYDROGUI_LandCoverDlg(); + + virtual void reset(); + + void setPolylineNames( const QStringList& thePolylines ); + void setSelectedPolylineNames( const QStringList& theSelectedPolylines ); + QStringList getSelectedPolylineNames() const; + +signals: + void CreatePreview( const QStringList& thePolylineNames ); + +private slots: + void onZoneDefChanged(); + +private: + QListWidget* myPolylines; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx b/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx new file mode 100644 index 00000000..d8b4fdc3 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_LandCoverOp.cxx @@ -0,0 +1,321 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "HYDROGUI_LandCoverOp.h" + +#include "HYDROGUI_LandCoverDlg.h" +#include "HYDROGUI_Module.h" +#include "HYDROGUI_Shape.h" +#include "HYDROGUI_Tool.h" +#include "HYDROGUI_UpdateFlags.h" +#include "HYDROGUI_DataObject.h" + +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include + +#include + +HYDROGUI_LandCoverOp::HYDROGUI_LandCoverOp( HYDROGUI_Module* theModule, + const bool theIsEdit ) +: HYDROGUI_Operation( theModule ), + myIsEdit( theIsEdit ), + myPreviewPrs( 0 ) +{ + setName( theIsEdit ? tr( "EDIT_LAND_COVER" ) : tr( "CREATE_LAND_COVER" ) ); +} + +HYDROGUI_LandCoverOp::~HYDROGUI_LandCoverOp() +{ + closePreview(); +} + +void HYDROGUI_LandCoverOp::startOperation() +{ + HYDROGUI_Operation::startOperation(); + + HYDROGUI_LandCoverDlg* aPanel = ::qobject_cast( inputPanel() ); + if ( !aPanel ) + return; + + aPanel->blockSignals( true ); + + aPanel->reset(); + + QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_LAND_COVER_NAME" ) ); + + QStringList aSelectedPolylines; + QString aSelectedStricklerType; + + if ( myIsEdit ) + { + if ( isApplyAndClose() ) + myEditedObject = Handle(HYDROData_LandCover)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if ( !myEditedObject.IsNull() ) + { + anObjectName = myEditedObject->GetName(); + + // TODO: Temporary commented until getPolylinesCount, GetPolyline and GetStricklerType data model methods will be implemented + /* + int nNoPolylines = myEditedObject->getPolylinesCount(); + for (int i=0; iGetPolyline(i); + if ( !aRefPolyline.IsNull() ) + aSelectedPolylines.append( aRefPolyline->GetName() ); + } + + aSelectedStricklerType = myEditedObject->GetStricklerType(); + */ + + // The code below is a sample of data filling Land cover object + aSelectedPolylines.append( "Lake_1" ); + aSelectedPolylines.append( "Polyline_1" ); + aSelectedStricklerType = "Canaux naturels"; + } + } + + aPanel->setObjectName( anObjectName ); + aPanel->setPolylineNames( HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_POLYLINEXY ) ); + // Construct a list of unique names of all Strickler types defined within the data model + QStringList aStricklerTypes; + HYDROData_Iterator anIterator( doc(), KIND_STRICKLER_TABLE ); + for( ; anIterator.More(); anIterator.Next() ) + { + Handle(HYDROData_StricklerTable) aStricklerTableObj = + Handle(HYDROData_StricklerTable)::DownCast( anIterator.Current() ); + if ( !aStricklerTableObj.IsNull() ) + { + // TODO: implement GetTypes method in data model + //QStringList aTypes = aStricklerTableObj->GetTypes(); + // The code below is a sample of data filling list of Strickler types + QStringList aTypes; + aTypes.append("Zones de champs, prairies, sans cultures"); + aTypes.append("Canaux naturels"); + aTypes.append("Zones à faible urbanization (bourg)"); + QStringList::const_iterator anIt = aTypes.begin(), aLast = aTypes.end(); + for( ; anIt!=aLast; anIt++ ) + { + QString aType = *anIt; + if ( !aType.isEmpty() && !aStricklerTypes.contains( aType )) + aStricklerTypes.append( aType ); + } + } + } + aStricklerTypes.sort(); + aPanel->setAdditionalParams( aStricklerTypes ); + + aPanel->blockSignals( false ); + + aPanel->setSelectedPolylineNames( aSelectedPolylines ); + aPanel->setSelectedAdditionalParamName( aSelectedStricklerType ); +} + +void HYDROGUI_LandCoverOp::abortOperation() +{ + closePreview(); + + HYDROGUI_Operation::abortOperation(); +} + +void HYDROGUI_LandCoverOp::commitOperation() +{ + closePreview(); + + HYDROGUI_Operation::commitOperation(); +} + +HYDROGUI_InputPanel* HYDROGUI_LandCoverOp::createInputPanel() const +{ + HYDROGUI_LandCoverDlg* aPanel = new HYDROGUI_LandCoverDlg( module(), getName() ); + connect( aPanel, SIGNAL( CreatePreview( const QStringList& ) ), + this, SLOT( onCreatePreview( const QStringList& ) ) ); + return aPanel; +} + +bool HYDROGUI_LandCoverOp::processApply( int& theUpdateFlags, + QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ) +{ + HYDROGUI_LandCoverDlg* aPanel = ::qobject_cast( inputPanel() ); + if ( !aPanel ) + return false; + + QString anObjectName = aPanel->getObjectName().simplified(); + if ( anObjectName.isEmpty() ) + { + theErrorMsg = tr( "INCORRECT_OBJECT_NAME" ); + return false; + } + + if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anObjectName ) ) + { + // check that there are no other objects with the same name in the document + Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName ); + if( !anObject.IsNull() ) + { + theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName ); + return false; + } + } + + QList aZonePolylines; + QString aStricklerType; + + QStringList aSelectedPolylineNames = aPanel->getSelectedPolylineNames(); + QStringList::const_iterator anIt = aSelectedPolylineNames.begin(), aLast = aSelectedPolylineNames.end(); + for( ; anIt!=aLast; anIt++ ) + { + QString aPolylineName = *anIt; + if ( !aPolylineName.isEmpty() ) + { + aZonePolylines.append( Handle(HYDROData_PolylineXY)::DownCast( + HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINEXY ) ) ); + } + } + + QString aSelectedStricklerType = aPanel->getSelectedAdditionalParamName(); + + // TODO: Generate TopoDS_Shape based on the set of polylines, implement generateTopShape data model method + /* + if ( HYDROData_LandCover::generateTopShape( aZonePolylines ).IsNull() ) + { + theErrorMsg = tr( "ZONE_OBJECT_CANNOT_BE_CREATED" ); + return false; + } + */ + + Handle(HYDROData_LandCover) aZoneObj = myIsEdit ? myEditedObject : + Handle(HYDROData_LandCover)::DownCast( doc()->CreateObject( KIND_LAND_COVER ) ); + + aZoneObj->SetName( anObjectName ); + + // TODO: Temporary commented until SetFillingColor, DefaultFillingColor, + // SetBorderColor and DefaultBorderColor data model methods will be implemented + /* + if ( !myIsEdit ) + { + aZoneObj->SetFillingColor( HYDROData_LandCover::DefaultFillingColor() ); + aZoneObj->SetBorderColor( HYDROData_LandCover::DefaultBorderColor() ); + } + */ + + // TODO: Temporary commented until SetPolylines and SetStricklerType data model methods will be implemented + //aZoneObj->SetPolylines( aZonePolylines ); + //aZoneObj->SetStricklerType( aSelectedStricklerType ); + aZoneObj->Update(); + + closePreview(); + + if( !myIsEdit ) + { + module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aZoneObj, true ); + QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aZoneObj ); + theBrowseObjectsEntries.append( anEntry ); + } + + module()->setIsToUpdate( aZoneObj ); + + theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer; + + return true; +} + +void HYDROGUI_LandCoverOp::onCreatePreview( const QStringList& thePolylineNames ) +{ + HYDROGUI_LandCoverDlg* aPanel = ::qobject_cast( inputPanel() ); + if ( !aPanel ) + return; + + QApplication::setOverrideCursor( Qt::WaitCursor ); + + QList aZonePolylines; + QStringList::const_iterator anIt = thePolylineNames.begin(), aLast = thePolylineNames.end(); + for( ; anIt!=aLast; anIt++ ) + { + QString aPolylineName = *anIt; + Handle(HYDROData_PolylineXY) aPolyline = Handle(HYDROData_PolylineXY)::DownCast( + HYDROGUI_Tool::FindObjectByName( module(), aPolylineName, KIND_POLYLINEXY ) ); + if ( !aPolyline.IsNull() ) + aZonePolylines.append( aPolyline ); + } + + // TODO: Generate TopoDS_Shape based on the set of polylines, implement generateTopShape data model method + TopoDS_Shape aZoneShape;/* = HYDROData_LandCover::generateTopShape( aZonePolylines ); + if( aZoneShape.IsNull() ) + printErrorMessage( tr( "ZONE_OBJECT_CANNOT_BE_CREATED" ) ); + */ + + LightApp_Application* anApp = module()->getApp(); + if ( !getPreviewManager() ) + setPreviewManager( ::qobject_cast( + anApp->getViewManager( OCCViewer_Viewer::Type(), true ) ) ); + OCCViewer_ViewManager* aViewManager = getPreviewManager(); + if ( aViewManager && !myPreviewPrs ) + { + if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) + { + Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); + if ( !aCtx.IsNull() ) + myPreviewPrs = new HYDROGUI_Shape( aCtx, NULL, getPreviewZLayer() ); + } + } + + if ( aViewManager && myPreviewPrs ) + { + // TODO: Temporary commented until GetFillingColor, DefaultFillingColor, + // GetBorderColor and DefaultBorderColor data model methods will be implemented + /* + QColor aFillingColor = HYDROData_LandCover::DefaultFillingColor(); + QColor aBorderColor = HYDROData_LandCover::DefaultBorderColor(); + if ( !myEditedObject.IsNull() ) { + aFillingColor = myEditedObject->GetFillingColor(); + aBorderColor = myEditedObject->GetBorderColor(); + } + + myPreviewPrs->setFillingColor( aFillingColor, false, false ); + myPreviewPrs->setBorderColor( aBorderColor, false, false ); + */ + + TopoDS_Face aFace; + if( !aZoneShape.IsNull() ) + aFace = TopoDS::Face( aZoneShape ); + myPreviewPrs->setFace( aFace, true, true, "" ); + } + + QApplication::restoreOverrideCursor(); +} + +void HYDROGUI_LandCoverOp::closePreview() +{ + if( myPreviewPrs ) + { + delete myPreviewPrs; + myPreviewPrs = 0; + } +} diff --git a/src/HYDROGUI/HYDROGUI_LandCoverOp.h b/src/HYDROGUI/HYDROGUI_LandCoverOp.h new file mode 100644 index 00000000..a50feb05 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_LandCoverOp.h @@ -0,0 +1,61 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef HYDROGUI_LANDCOVEROP_H +#define HYDROGUI_LANDCOVEROP_H + +#include "HYDROGUI_Operation.h" + +#include + +class HYDROGUI_Shape; + +class HYDROGUI_LandCoverOp : public HYDROGUI_Operation +{ + Q_OBJECT + +public: + HYDROGUI_LandCoverOp( HYDROGUI_Module* theModule, const bool theIsEdit ); + virtual ~HYDROGUI_LandCoverOp(); + +protected: + virtual void startOperation(); + virtual void abortOperation(); + virtual void commitOperation(); + + virtual HYDROGUI_InputPanel* createInputPanel() const; + + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, + QStringList& theBrowseObjectsEntries ); + + virtual HYDROGUI_Shape* getPreviewShape() const { return myPreviewPrs; }; + +protected slots: + void onCreatePreview( const QStringList& thePolylineNames ); + +private: + void closePreview(); + +private: + bool myIsEdit; + Handle(HYDROData_LandCover) myEditedObject; + + HYDROGUI_Shape* myPreviewPrs; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 0403a311..3d5dc177 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -337,6 +337,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, bool anIsZone = false; bool anIsObstacle = false; bool anIsStricklerTable = false; + bool anIsLandCover = false; bool anIsStream = false; bool anIsChannel = false; bool anIsDigue = false; @@ -457,6 +458,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, anIsObstacle = true; else if( anObjectKind == KIND_STRICKLER_TABLE ) anIsStricklerTable = true; + else if( anObjectKind == KIND_LAND_COVER ) + anIsLandCover = true; else if( anObjectKind == KIND_STREAM ) { anIsStream = true; @@ -513,6 +516,9 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, case KIND_STRICKLER_TABLE: theMenu->addAction( action( ImportStricklerTableFromFileId ) ); break; + case KIND_LAND_COVER: + theMenu->addAction( action( CreateLandCoverId ) ); + break; case KIND_CALCULATION: theMenu->addAction( action( CreateCalculationId ) ); break; @@ -646,6 +652,11 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, theMenu->addAction( action( DuplicateStricklerTableId ) ); theMenu->addSeparator(); } + else if( anIsLandCover ) + { + theMenu->addAction( action( EditLandCoverId ) ); + theMenu->addSeparator(); + } else if( anIsVisualState && anIsObjectBrowser ) { theMenu->addAction( action( SaveVisualStateId ) ); diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index 3b4fedb1..6c291ed7 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -59,6 +59,7 @@ #include "HYDROGUI_SubmersibleOp.h" #include "HYDROGUI_StricklerTableOp.h" #include "HYDROGUI_DuplicateOp.h" +#include "HYDROGUI_LandCoverOp.h" #include #include @@ -155,6 +156,9 @@ void HYDROGUI_Module::createActions() createAction( EditStricklerTableId, "EDIT_STRICKLER_TABLE", "EDIT_STRICKLER_TABLE_ICO" ); createAction( DuplicateStricklerTableId, "DUPLICATE_STRICKLER_TABLE", "DUPLICATE_STRICKLER_TABLE_ICO" ); + createAction( CreateLandCoverId, "CREATE_LAND_COVER", "CREATE_LAND_COVER_ICO" ); + createAction( EditLandCoverId, "EDIT_LAND_COVER", "EDIT_LAND_COVER_ICO" ); + createAction( ImportObstacleFromFileId, "IMPORT_OBSTACLE_FROM_FILE", "IMPORT_OBSTACLE_FROM_FILE_ICO" ); createAction( ImportGeomObjectAsObstacleId, "IMPORT_GEOM_OBJECT_AS_OBSTACLE", "IMPORT_GEOM_OBJECT_ICO" ); createAction( ImportGeomObjectAsPolylineId, "IMPORT_GEOM_OBJECT_AS_POLYLINE", "IMPORT_GEOM_OBJECT_ICO" ); @@ -222,6 +226,7 @@ void HYDROGUI_Module::createMenus() createMenu( CreateImmersibleZoneId, aHydroId, -1, -1 ); createMenu( CreateChannelId, aHydroId, -1, -1 ); createMenu( CreateDigueId, aHydroId, -1, -1 ); + createMenu( CreateLandCoverId, aHydroId, -1, -1 ); int aNewProfileId = createMenu( tr( "MEN_DESK_PROFILE" ), aHydroId, -1 ); createMenu( CreateProfileId, aNewProfileId, -1, -1 ); @@ -284,7 +289,10 @@ void HYDROGUI_Module::createToolbars() createTool( CreateCylinderId, aToolBar ); createTool( separator(), aToolBar ); - createTool( ImportStricklerTableFromFileId, aToolBar ); + createTool( ImportStricklerTableFromFileId, aToolBar ); + + createTool( separator(), aToolBar ); + createTool( CreateLandCoverId, aToolBar ); createTool( separator(), aToolBar ); createTool( CreateCalculationId, aToolBar ); @@ -483,6 +491,10 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const case EditStricklerTableId: anOp = new HYDROGUI_StricklerTableOp( aModule, theId == EditStricklerTableId ); break; + case CreateLandCoverId: + case EditLandCoverId: + anOp = new HYDROGUI_LandCoverOp( aModule, theId == EditLandCoverId ); + break; case DuplicateStricklerTableId: anOp = new HYDROGUI_DuplicateOp( aModule ); break; diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index 504a9ef8..e9d10c02 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -114,8 +114,10 @@ enum OperationId ImportStricklerTableFromFileId, ExportStricklerTableFromFileId, EditStricklerTableId, - DuplicateStricklerTableId + DuplicateStricklerTableId, + CreateLandCoverId, + EditLandCoverId }; #endif diff --git a/src/HYDROGUI/resources/HYDROGUI_images.ts b/src/HYDROGUI/resources/HYDROGUI_images.ts index 9da19b5c..5a5540f3 100644 --- a/src/HYDROGUI/resources/HYDROGUI_images.ts +++ b/src/HYDROGUI/resources/HYDROGUI_images.ts @@ -141,6 +141,10 @@ HYDRO_TYPE26_ICO icon_strickler_table.png + + HYDRO_TYPE27_ICO + icon_land_cover.png + @@ -359,6 +363,15 @@ icon_edit_strickler_table.png + + CREATE_LAND_COVER_ICO + icon_create_land_cover.png + + + EDIT_LAND_COVER_ICO + icon_edit_land_cover.png + + IMPORT_OBSTACLE_FROM_FILE_ICO icon_import_obstacle.png diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index e07fd228..3c926868 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -47,6 +47,10 @@ DEFAULT_STRICKLER_TABLE_NAME Strickler table + + DEFAULT_LAND_COVER_NAME + Land cover + IMAGES IMAGES @@ -83,6 +87,10 @@ STRICKLER_TABLES STRICKLER TABLES + + LAND_COVERS + LAND COVERS + ARTIFICIAL_OBJECTS ARTIFICIAL OBJECTS @@ -786,6 +794,14 @@ Would you like to remove all references from the image? DSK_DUPLICATE_STRICKLER_TABLE Duplicate Strickler table + + DSK_CREATE_LAND_COVER + Create land cover + + + DSK_EDIT_LAND_COVER + Edit land cover + DSK_COPY Copy @@ -1038,6 +1054,14 @@ Would you like to remove all references from the image? MEN_DUPLICATE_STRICKLER_TABLE Duplicate Strickler table + + MEN_CREATE_LAND_COVER + Create land cover + + + MEN_EDIT_LAND_COVER + Edit land cover + MEN_CUT_IMAGES Cut images @@ -1314,6 +1338,14 @@ Would you like to remove all references from the image? STB_DUPLICATE_STRICKLER_TABLE Duplicate Strickler table + + STB_CREATE_LAND_COVER + Create land cover + + + STB_EDIT_LAND_COVER + Edit land cover + STB_COPY Copy @@ -2355,6 +2387,50 @@ Polyline should consist from one not closed curve. + + HYDROGUI_LandCoverDlg + + DEFAULT_LAND_COVER_NAME + Land cover + + + LAND_COVER_NAME + Land cover name + + + NAME + Name + + + LAND_COVER_PARAMETERS + Parameters + + + LAND_COVER_POLYLINES + Polylines + + + LAND_COVER_STRICKLER_TYPE + Strickler type + + + + + HYDROGUI_LandCoverOp + + CREATE_LAND_COVER + Create land cover + + + EDIT_LAND_COVER + Edit land cover + + + SELECT_STRICKLER_TABLE_FILE + The Strickler table file is not chosen + + + HYDROGUI_TranslateObstacleDlg diff --git a/src/HYDROGUI/resources/icon_create_land_cover.png b/src/HYDROGUI/resources/icon_create_land_cover.png new file mode 100644 index 00000000..63072e33 Binary files /dev/null and b/src/HYDROGUI/resources/icon_create_land_cover.png differ diff --git a/src/HYDROGUI/resources/icon_edit_land_cover.png b/src/HYDROGUI/resources/icon_edit_land_cover.png new file mode 100644 index 00000000..63072e33 Binary files /dev/null and b/src/HYDROGUI/resources/icon_edit_land_cover.png differ diff --git a/src/HYDROGUI/resources/icon_edit_strickler_table.png b/src/HYDROGUI/resources/icon_edit_strickler_table.png index 21dfce05..9b65769f 100644 Binary files a/src/HYDROGUI/resources/icon_edit_strickler_table.png and b/src/HYDROGUI/resources/icon_edit_strickler_table.png differ diff --git a/src/HYDROGUI/resources/icon_export_strickler_table.png b/src/HYDROGUI/resources/icon_export_strickler_table.png index 21dfce05..9b65769f 100644 Binary files a/src/HYDROGUI/resources/icon_export_strickler_table.png and b/src/HYDROGUI/resources/icon_export_strickler_table.png differ diff --git a/src/HYDROGUI/resources/icon_import_strickler_table.png b/src/HYDROGUI/resources/icon_import_strickler_table.png index 21dfce05..9b65769f 100644 Binary files a/src/HYDROGUI/resources/icon_import_strickler_table.png and b/src/HYDROGUI/resources/icon_import_strickler_table.png differ diff --git a/src/HYDROGUI/resources/icon_land_cover.png b/src/HYDROGUI/resources/icon_land_cover.png new file mode 100644 index 00000000..63072e33 Binary files /dev/null and b/src/HYDROGUI/resources/icon_land_cover.png differ diff --git a/src/HYDROGUI/resources/icon_strickler_table.png b/src/HYDROGUI/resources/icon_strickler_table.png index 21dfce05..9b65769f 100644 Binary files a/src/HYDROGUI/resources/icon_strickler_table.png and b/src/HYDROGUI/resources/icon_strickler_table.png differ