From: adv Date: Tue, 3 Dec 2013 07:11:09 +0000 (+0000) Subject: Chanel Create\Edit operation. X-Git-Tag: BR_hydro_v_0_4~93 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=06a6e19d03f1d202e3a58042fdf1abc1000b7c2c;p=modules%2Fhydro.git Chanel Create\Edit operation. --- diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 9d953b67..a7f6b516 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -6,6 +6,8 @@ set(PROJECT_HEADERS HYDROGUI_AbstractDisplayer.h HYDROGUI_CalculationDlg.h HYDROGUI_CalculationOp.h + HYDROGUI_ChannelDlg.h + HYDROGUI_ChannelOp.h HYDROGUI_ColorWidget.h HYDROGUI_CopyPasteOp.h HYDROGUI_DataBrowser.h @@ -81,6 +83,8 @@ set(PROJECT_SOURCES HYDROGUI_AbstractDisplayer.cxx HYDROGUI_CalculationDlg.cxx HYDROGUI_CalculationOp.cxx + HYDROGUI_ChannelDlg.cxx + HYDROGUI_ChannelOp.cxx HYDROGUI_ColorWidget.cxx HYDROGUI_CopyPasteOp.cxx HYDROGUI_DataBrowser.cxx diff --git a/src/HYDROGUI/HYDROGUI_ChannelDlg.cxx b/src/HYDROGUI/HYDROGUI_ChannelDlg.cxx new file mode 100644 index 00000000..3a761817 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ChannelDlg.cxx @@ -0,0 +1,167 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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. +// +// 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_ChannelDlg.h" + +#include "HYDROGUI_Tool.h" + +#include +#include +#include +#include +#include + +HYDROGUI_ChannelDlg::HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QString& theTitle ) +: HYDROGUI_InputPanel( theModule, theTitle ) +{ + // Channel name + myObjectNameGroup = new QGroupBox( tr( "CHANNEL_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 ); + + // Channel parameters + QGroupBox* aParamGroup = new QGroupBox( tr( "CHANNEL_PARAMETERS" ), mainFrame() ); + + //myGuideLines = new HYDROGUI_ObjComboSelector( theModule, KIND_POLYLINE, aParamGroup ); + myGuideLines = new QComboBox( aParamGroup ); + myGuideLines->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + //myProfiles = new HYDROGUI_ObjComboSelector( theModule, KIND_PROFILE, aParamGroup ); + myProfiles = new QComboBox( aParamGroup ); + myProfiles->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + QGridLayout* aParamsLayout = new QGridLayout( aParamGroup ); + aParamsLayout->setMargin( 5 ); + aParamsLayout->setSpacing( 5 ); + aParamsLayout->addWidget( new QLabel( tr( "CHANNEL_GUIDE_LINE" ), aParamGroup ), 0, 0 ); + aParamsLayout->addWidget( myGuideLines, 0, 1 ); + aParamsLayout->addWidget( new QLabel( tr( "CHANNEL_PROFILE" ), aParamGroup ), 1, 0 ); + aParamsLayout->addWidget( myProfiles, 1, 1 ); + + // Common + addWidget( myObjectNameGroup ); + addWidget( aParamGroup ); + + addStretch(); + + // Connect signals and slots + connect( myGuideLines, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onChannelDefChanged() ) ); + connect( myProfiles, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onChannelDefChanged() ) ); +} + +HYDROGUI_ChannelDlg::~HYDROGUI_ChannelDlg() +{ +} + +void HYDROGUI_ChannelDlg::reset() +{ + bool isBlocked = blockSignals( true ); + + myObjectName->clear(); + + myGuideLines->clear(); + myProfiles->clear(); + + blockSignals( isBlocked ); + + onChannelDefChanged(); +} + +void HYDROGUI_ChannelDlg::setObjectName( const QString& theName ) +{ + myObjectName->setText( theName ); +} + +QString HYDROGUI_ChannelDlg::getObjectName() const +{ + return myObjectName->text(); +} + +void HYDROGUI_ChannelDlg::setGuideLineNames( const QStringList& theGuideLines ) +{ + bool isBlocked = blockSignals( true ); + + myGuideLines->clear(); + myGuideLines->addItems( theGuideLines ); + + blockSignals( isBlocked ); +} + +void HYDROGUI_ChannelDlg::setGuideLineName( const QString& theGuideLine ) +{ + int aNewIdx = myGuideLines->findText( theGuideLine ); + if ( aNewIdx != myGuideLines->currentIndex() ) + { + myGuideLines->setCurrentIndex( aNewIdx ); + } + else + { + onChannelDefChanged(); + } +} + +QString HYDROGUI_ChannelDlg::getGuideLineName() const +{ + return myGuideLines->currentText(); +} + +void HYDROGUI_ChannelDlg::setProfileNames( const QStringList& theProfiles ) +{ + bool isBlocked = blockSignals( true ); + + myProfiles->clear(); + myProfiles->addItems( theProfiles ); + + blockSignals( isBlocked ); +} + +void HYDROGUI_ChannelDlg::setProfileName( const QString& theProfile ) +{ + int aNewIdx = myProfiles->findText( theProfile ); + if ( aNewIdx != myProfiles->currentIndex() ) + { + myProfiles->setCurrentIndex( aNewIdx ); + } + else + { + onChannelDefChanged(); + } +} + +QString HYDROGUI_ChannelDlg::getProfileName() const +{ + return myProfiles->currentText(); +} + +void HYDROGUI_ChannelDlg::onChannelDefChanged() +{ + if ( signalsBlocked() ) + return; + + emit CreatePreview(); +} diff --git a/src/HYDROGUI/HYDROGUI_ChannelDlg.h b/src/HYDROGUI/HYDROGUI_ChannelDlg.h new file mode 100644 index 00000000..3e947208 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ChannelDlg.h @@ -0,0 +1,68 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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. +// +// 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_ChannelDlg_H +#define HYDROGUI_ChannelDlg_H + +#include "HYDROGUI_InputPanel.h" + +class QComboBox; +class QGroupBox; +class QLineEdit; + +class HYDROGUI_ChannelDlg : public HYDROGUI_InputPanel +{ + Q_OBJECT + +public: + HYDROGUI_ChannelDlg( HYDROGUI_Module* theModule, const QString& theTitle ); + virtual ~HYDROGUI_ChannelDlg(); + + void reset(); + + void setObjectName( const QString& theName ); + QString getObjectName() const; + + void setGuideLineNames( const QStringList& theGuideLines ); + void setGuideLineName( const QString& theGuideLine ); + QString getGuideLineName() const; + + void setProfileNames( const QStringList& theProfiles ); + void setProfileName( const QString& theProfile ); + QString getProfileName() const; + +signals: + void CreatePreview(); + +private slots: + void onChannelDefChanged(); + +private: + + QGroupBox* myObjectNameGroup; + QLineEdit* myObjectName; + + QComboBox* myGuideLines; + QComboBox* myProfiles; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx new file mode 100644 index 00000000..720a3648 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx @@ -0,0 +1,241 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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. +// +// 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_ChannelOp.h" + +#include "HYDROGUI_DataModel.h" +#include "HYDROGUI_ChannelDlg.h" +#include "HYDROGUI_Module.h" +#include "HYDROGUI_Shape.h" +#include "HYDROGUI_Tool.h" +#include "HYDROGUI_UpdateFlags.h" + +#include +#include +#include + +#include +#include + +#include +#include + + +HYDROGUI_ChannelOp::HYDROGUI_ChannelOp( HYDROGUI_Module* theModule, + const bool theIsEdit ) +: HYDROGUI_Operation( theModule ), + myIsEdit( theIsEdit ), + myViewManager( 0 ), + myPreviewPrs( 0 ) +{ + setName( theIsEdit ? tr( "EDIT_CHANNEL" ) : tr( "CREATE_CHANNEL" ) ); +} + +HYDROGUI_ChannelOp::~HYDROGUI_ChannelOp() +{ + erasePreview(); +} + +void HYDROGUI_ChannelOp::startOperation() +{ + HYDROGUI_Operation::startOperation(); + + // We start operation in the document + startDocOperation(); + + HYDROGUI_ChannelDlg* aPanel = ::qobject_cast( inputPanel() ); + + aPanel->blockSignals( true ); + + aPanel->reset(); + + if( myIsEdit ) + myEditedObject = Handle(HYDROData_Channel)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + else + myEditedObject = Handle(HYDROData_Channel)::DownCast( doc()->CreateObject( KIND_CHANNEL ) ); + + QString aSelectedGuideLine, aSelectedProfile; + + QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_CHANNEL_NAME" ) ); + if ( myIsEdit && !myEditedObject.IsNull() ) + { + anObjectName = myEditedObject->GetName(); + + Handle(HYDROData_Polyline3D) aRefGuideLine = myEditedObject->GetGuideLine(); + if ( !aRefGuideLine.IsNull() ) + aSelectedGuideLine = aRefGuideLine->GetName(); + + Handle(HYDROData_Profile) aRefProfile = myEditedObject->GetProfile(); + if ( !aRefProfile.IsNull() ) + aSelectedProfile = aRefProfile->GetName(); + } + + // collect information about existing 3d polylines + QStringList aGuideLines = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_POLYLINE ); + + // collect information about existing profiles + QStringList aProfiles = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_PROFILE ); + + aPanel->setObjectName( anObjectName ); + + aPanel->setGuideLineNames( aGuideLines ); + aPanel->setProfileNames( aProfiles ); + + aPanel->setGuideLineName( aSelectedGuideLine ); + aPanel->setProfileName( aSelectedProfile ); + + aPanel->blockSignals( false ); + + onCreatePreview( true ); +} + +void HYDROGUI_ChannelOp::abortOperation() +{ + erasePreview(); + + HYDROGUI_Operation::abortOperation(); +} + +void HYDROGUI_ChannelOp::commitOperation() +{ + erasePreview(); + + HYDROGUI_Operation::commitOperation(); +} + +HYDROGUI_InputPanel* HYDROGUI_ChannelOp::createInputPanel() const +{ + HYDROGUI_ChannelDlg* aPanel = new HYDROGUI_ChannelDlg( module(), getName() ); + connect( aPanel, SIGNAL( CreatePreview() ), this, SLOT( onCreatePreview() ) ); + return aPanel; +} + +bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags, + QString& theErrorMsg ) +{ + HYDROGUI_ChannelDlg* 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; + } + } + + if ( myEditedObject.IsNull() ) + return false; + + myEditedObject->SetName( anObjectName ); + + if ( !myIsEdit ) { + myEditedObject->SetFillingColor( HYDROData_Channel::DefaultFillingColor() ); + myEditedObject->SetBorderColor( HYDROData_Channel::DefaultBorderColor() ); + } + + erasePreview(); + + if( !myIsEdit ) + module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), myEditedObject, true ); + + theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced; + + return true; +} + +void HYDROGUI_ChannelOp::onCreatePreview( const bool theIsInit ) +{ + HYDROGUI_ChannelDlg* aPanel = ::qobject_cast( inputPanel() ); + if ( !aPanel || myEditedObject.IsNull() ) + return; + + QString aGuideLineName = aPanel->getGuideLineName(); + QString aProfileName = aPanel->getProfileName(); + if ( aGuideLineName.isEmpty() || aProfileName.isEmpty() ) + { + if ( !theIsInit ) + { + myEditedObject->RemoveGuideLine(); + myEditedObject->RemoveProfile(); + myEditedObject->Update(); + } + + erasePreview(); + return; + } + + // Update channel data + if ( !theIsInit ) + { + Handle(HYDROData_Polyline3D) aGuideLine = Handle(HYDROData_Polyline3D)::DownCast( + HYDROGUI_Tool::FindObjectByName( module(), aGuideLineName, KIND_POLYLINE ) ); + myEditedObject->SetGuideLine( aGuideLine ); + + Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( + HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) ); + myEditedObject->SetProfile( aProfile ); + + if ( myEditedObject->IsMustBeUpdated() ) + myEditedObject->Update(); + } + + LightApp_Application* anApp = module()->getApp(); + if ( !myViewManager ) + myViewManager = ::qobject_cast( + anApp->getViewManager( OCCViewer_Viewer::Type(), true ) ); + + if ( myViewManager && !myPreviewPrs ) + { + if ( OCCViewer_Viewer* aViewer = myViewManager->getOCCViewer() ) + { + Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext(); + if ( !aCtx.IsNull() ) + myPreviewPrs = new HYDROGUI_Shape( aCtx, myEditedObject ); + } + } + + if ( !myViewManager || !myPreviewPrs ) + return; + + myPreviewPrs->update(); +} + +void HYDROGUI_ChannelOp::erasePreview() +{ + if( myPreviewPrs ) + { + delete myPreviewPrs; + myPreviewPrs = 0; + } +} diff --git a/src/HYDROGUI/HYDROGUI_ChannelOp.h b/src/HYDROGUI/HYDROGUI_ChannelOp.h new file mode 100644 index 00000000..f1456eeb --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ChannelOp.h @@ -0,0 +1,66 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// 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. +// +// 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_ChannelOp_H +#define HYDROGUI_ChannelOp_H + +#include "HYDROGUI_Operation.h" + +#include + +class OCCViewer_ViewManager; + +class HYDROGUI_Shape; + +class HYDROGUI_ChannelOp : public HYDROGUI_Operation +{ + Q_OBJECT + +public: + HYDROGUI_ChannelOp( HYDROGUI_Module* theModule, const bool theIsEdit ); + virtual ~HYDROGUI_ChannelOp(); + +protected: + virtual void startOperation(); + virtual void abortOperation(); + virtual void commitOperation(); + + virtual HYDROGUI_InputPanel* createInputPanel() const; + + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + +protected slots: + void onCreatePreview( const bool theIsInit = false ); + +private: + void erasePreview(); + +private: + bool myIsEdit; + Handle(HYDROData_Channel) myEditedObject; + + OCCViewer_ViewManager* myViewManager; + + HYDROGUI_Shape* myPreviewPrs; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index cad9dc66..8c8396d6 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -267,6 +267,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, bool anIsZone = false; bool anIsObstacle = false; bool anIsStream = false; + bool anIsChannel = false; bool anIsGeomObject = false; // check the selected GEOM objects @@ -348,6 +349,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, anIsObstacle = true; else if( anObjectKind == KIND_STREAM ) anIsStream = true; + else if( anObjectKind == KIND_CHANNEL ) + anIsChannel = true; } anIsGeomObject = HYDROData_Tool::IsGeometryObject( anObject ); @@ -372,6 +375,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, theMenu->addAction( action( ImportBathymetryId ) ); break; case KIND_ARTIFICIAL_OBJECT: + theMenu->addAction( action( CreateChannelId ) ); break; case KIND_NATURAL_OBJECT: theMenu->addAction( action( CreateImmersibleZoneId ) ); @@ -475,6 +479,11 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, theMenu->addAction( action( EditStreamId ) ); theMenu->addSeparator(); } + else if( anIsChannel ) + { + theMenu->addAction( action( EditChannelId ) ); + theMenu->addSeparator(); + } else if( anIsVisualState && anIsObjectBrowser ) { theMenu->addAction( action( SaveVisualStateId ) ); @@ -496,8 +505,10 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, theMenu->addAction( action( DeleteId ) ); theMenu->addSeparator(); - if( anIsImage || anIsPolyline || anIsPolyline3D || anIsImmersibleZone || anIsZone || - anIsRegion || anIsBathymetry || anIsObstacle || anIsStream || anIsValidProfile ) + if( anIsImage || anIsPolyline || anIsPolyline3D || + anIsImmersibleZone || anIsZone || anIsRegion || + anIsBathymetry || anIsObstacle || anIsStream || + anIsChannel || anIsValidProfile ) { if( anIsHiddenInSelection ) theMenu->addAction( action( ShowId ) ); diff --git a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx index f702ecbf..b9788afd 100644 --- a/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx +++ b/src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx @@ -107,7 +107,8 @@ HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const int anObjectKind != KIND_ZONE && anObjectKind != KIND_OBSTACLE && anObjectKind != KIND_PROFILE && - anObjectKind != KIND_STREAM ) + anObjectKind != KIND_STREAM && + anObjectKind != KIND_CHANNEL ) return aResShape; aResShape = new HYDROGUI_Shape( theContext, theObject ); diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index 6e1bc51c..79622a50 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -24,6 +24,7 @@ #include "HYDROGUI_CopyPasteOp.h" #include "HYDROGUI_CalculationOp.h" +#include "HYDROGUI_ChannelOp.h" #include "HYDROGUI_DataModel.h" #include "HYDROGUI_DeleteOp.h" #include "HYDROGUI_ExportImageOp.h" @@ -126,6 +127,9 @@ void HYDROGUI_Module::createActions() createAction( CreateStreamId, "CREATE_STREAM" ); createAction( EditStreamId, "EDIT_STREAM" ); + createAction( CreateChannelId, "CREATE_CHANNEL" ); + createAction( EditChannelId, "EDIT_CHANNEL" ); + createAction( ImportObstacleFromFileId, "IMPORT_OBSTACLE_FROM_FILE" ); createAction( ImportGeomObjectId, "IMPORT_GEOM_OBJECT" ); createAction( CreateBoxId, "CREATE_BOX" ); @@ -177,18 +181,22 @@ void HYDROGUI_Module::createMenus() createMenu( CreatePolylineId, aHydroId, -1, -1 ); createMenu( CreatePolyline3DId, aHydroId, -1, -1 ); - int aNewProfileId = createMenu( tr( "MEN_PROFILE" ), aHydroId, -1 ); + int aNewProfileId = createMenu( tr( "MEN_DESK_PROFILE" ), aHydroId, -1 ); createMenu( CreateProfileId, aNewProfileId, -1, -1 ); createMenu( ImportProfilesId, aNewProfileId, -1, -1 ); createMenu( AllGeoreferencementId, aNewProfileId, -1, -1 ); - createMenu( CreateImmersibleZoneId, aHydroId, -1, -1 ); - createMenu( CreateStreamId, aHydroId, -1, -1 ); + int anArtificialMenuId = createMenu( tr( "MEN_DESK_ARTIFICIAL" ), aHydroId, -1 ); + createMenu( CreateImmersibleZoneId, anArtificialMenuId, -1, -1 ); + createMenu( CreateStreamId, anArtificialMenuId, -1, -1 ); + + int aNaturalMenuId = createMenu( tr( "MEN_DESK_NATURAL" ), aHydroId, -1 ); + createMenu( CreateChannelId, aNaturalMenuId, -1, -1 ); - int aNewObstacleId = createMenu( tr( "MEN_OBSTACLE" ), aHydroId, -1 ); - createMenu( ImportObstacleFromFileId, aNewObstacleId, -1, -1 ); - createMenu( CreateBoxId, aNewObstacleId, -1, -1 ); - createMenu( CreateCylinderId, aNewObstacleId, -1, -1 ); + int anObstacleMenuId = createMenu( tr( "MEN_DESK_OBSTACLE" ), aHydroId, -1 ); + createMenu( ImportObstacleFromFileId, anObstacleMenuId, -1, -1 ); + createMenu( CreateBoxId, anObstacleMenuId, -1, -1 ); + createMenu( CreateCylinderId, anObstacleMenuId, -1, -1 ); createMenu( CreateCalculationId, aHydroId, -1, -1 ); createMenu( separator(), aHydroId ); @@ -374,6 +382,10 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const case EditStreamId: anOp = new HYDROGUI_StreamOp( aModule, theId == EditStreamId ); break; + case CreateChannelId: + case EditChannelId: + anOp = new HYDROGUI_ChannelOp( aModule, theId == EditChannelId ); + break; case CreateCalculationId: case EditCalculationId: anOp = new HYDROGUI_CalculationOp( aModule, theId == EditCalculationId ); diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index 534d56ca..d892d67f 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -64,6 +64,9 @@ enum OperationId CreateStreamId, EditStreamId, + CreateChannelId, + EditChannelId, + CreateCalculationId, EditCalculationId, ExportCalculationId, diff --git a/src/HYDROGUI/HYDROGUI_Shape.cxx b/src/HYDROGUI/HYDROGUI_Shape.cxx index adbed367..4ddd3b2d 100644 --- a/src/HYDROGUI/HYDROGUI_Shape.cxx +++ b/src/HYDROGUI/HYDROGUI_Shape.cxx @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -317,6 +318,21 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer ) QColor aFillingColor = aStream->GetFillingColor(); QColor aBorderColor = aStream->GetBorderColor(); + setFillingColor( aFillingColor, false, false ); + setBorderColor( aBorderColor, false, false ); + } + else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Channel) ) ) + { + Handle(HYDROData_Channel) aChannel = + Handle(HYDROData_Channel)::DownCast( myObject ); + + TopoDS_Face aChannelShape = TopoDS::Face( aChannel->GetTopShape() ); + + setShape( aChannelShape, false, false ); + + QColor aFillingColor = aChannel->GetFillingColor(); + QColor aBorderColor = aChannel->GetBorderColor(); + setFillingColor( aFillingColor, false, false ); setBorderColor( aBorderColor, false, false ); } diff --git a/src/HYDROGUI/HYDROGUI_Tool.cxx b/src/HYDROGUI/HYDROGUI_Tool.cxx index 2189ebd1..007e855f 100644 --- a/src/HYDROGUI/HYDROGUI_Tool.cxx +++ b/src/HYDROGUI/HYDROGUI_Tool.cxx @@ -223,7 +223,8 @@ void HYDROGUI_Tool::GetPrsSubObjects( HYDROGUI_Module* theModule, ( anObject->GetKind() == KIND_ZONE ) || ( anObject->GetKind() == KIND_OBSTACLE ) || ( anObject->GetKind() == KIND_PROFILE ) || - ( anObject->GetKind() == KIND_STREAM ) ) ) + ( anObject->GetKind() == KIND_STREAM ) || + ( anObject->GetKind() == KIND_CHANNEL ) ) ) { theSeq.Append( anObject ); } diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 7ffb7cde..b94d2147 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -512,6 +512,14 @@ file cannot be correctly imported for a Bathymetry definition. DSK_EDIT_STREAM Edit stream + + DSK_CREATE_CHANNEL + Create channel + + + DSK_EDIT_CHANNEL + Edit channel + DSK_COPY Copy @@ -692,6 +700,14 @@ file cannot be correctly imported for a Bathymetry definition. MEN_EDIT_STREAM Edit stream + + MEN_CREATE_CHANNEL + Create channel + + + MEN_EDIT_CHANNEL + Edit channel + MEN_CUT_IMAGES Cut images @@ -700,10 +716,26 @@ file cannot be correctly imported for a Bathymetry definition. MEN_DELETE Delete + + MEN_DESK_ARTIFICIAL + Artificial objects + MEN_DESK_HYDRO HYDRO + + MEN_DESK_NATURAL + Natural objects + + + MEN_DESK_OBSTACLE + Obstacle + + + MEN_DESK_PROFILE + Profile + MEN_EDIT_CALCULATION Edit calculation case @@ -812,14 +844,6 @@ file cannot be correctly imported for a Bathymetry definition. MEN_UPDATE_IMAGE Update image - - MEN_OBSTACLE - Obstacle - - - MEN_PROFILE - Profile - MEN_IMPORT_OBSTACLE_FROM_FILE Import obstacle @@ -880,6 +904,14 @@ file cannot be correctly imported for a Bathymetry definition. STB_EDIT_STREAM Edit stream + + STB_CREATE_CHANNEL + Create channel + + + STB_EDIT_CHANNEL + Edit channel + STB_COPY Copy @@ -1529,4 +1561,44 @@ file cannot be correctly imported for an Obstacle definition. + + HYDROGUI_ChannelDlg + + NAME + Name + + + CHANNEL_NAME + Channel name + + + CHANNEL_PARAMETERS + Parameters + + + CHANNEL_GUIDE_LINE + Guide line + + + CHANNEL_PROFILE + Profile + + + + + HYDROGUI_ChannelOp + + CREATE_CHANNEL + Create channel + + + EDIT_CHANNEL + Edit channel + + + DEFAULT_CHANNEL_NAME + Channel + + +