From 161c2eaa4cad0e24cfaadf3d3060d825db82f6cd Mon Sep 17 00:00:00 2001 From: stv Date: Mon, 30 Mar 2015 13:12:08 +0300 Subject: [PATCH] Context menu item & river object filter were added. --- src/HYDROGUI/HYDROGUI_Module.cxx | 16 +++++++++++++++- src/HYDROGUI/HYDROGUI_RiverBottomDlg.cxx | 13 ++++++++++++- src/HYDROGUI/HYDROGUI_RiverBottomDlg.h | 11 +++++++---- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index d08d53b5..85ac5a68 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -44,10 +44,12 @@ #include "HYDROGUI_ImportGeomObjectOp.h" #include "HYDROGUI_ShowHideOp.h" +#include #include +#include #include #include -#include +#include #include @@ -339,6 +341,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, bool anIsGroup = false; bool anIsObjectCanBeColored = false; bool isRoot = false; + bool isStreamHasBottom = false; SUIT_SelectionMgr* aSelectionMgr = getApp()->selectionMgr(); SUIT_DataOwnerPtrList anOwners; @@ -450,7 +453,13 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, else if( anObjectKind == KIND_OBSTACLE ) anIsObstacle = true; else if( anObjectKind == KIND_STREAM ) + { anIsStream = true; + Handle(HYDROData_Stream) aStream = + Handle(HYDROData_Stream)::DownCast( anObject ); + if ( !aStream.IsNull() ) + isStreamHasBottom = !aStream->GetBottomPolyline().IsNull(); + } else if( anObjectKind == KIND_CHANNEL ) anIsChannel = true; else if( anObjectKind == KIND_DIGUE ) @@ -599,6 +608,11 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, else if( anIsStream ) { theMenu->addAction( action( EditStreamId ) ); + if ( action( RiverBottom ) ) + { + theMenu->addAction( action( RiverBottom ) ); + action( RiverBottom )->setEnabled( !isStreamHasBottom ); + } theMenu->addSeparator(); } else if( anIsChannel ) diff --git a/src/HYDROGUI/HYDROGUI_RiverBottomDlg.cxx b/src/HYDROGUI/HYDROGUI_RiverBottomDlg.cxx index 7e93c158..73192779 100644 --- a/src/HYDROGUI/HYDROGUI_RiverBottomDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_RiverBottomDlg.cxx @@ -25,19 +25,24 @@ #include "HYDROGUI_Tool.h" #include "HYDROGUI_ObjComboBox.h" +#include +#include + #include #include #include #include HYDROGUI_RiverBottomDlg::HYDROGUI_RiverBottomDlg( HYDROGUI_Module* theModule, const QString& theTitle ) - : HYDROGUI_InputPanel( theModule, theTitle ) + : HYDROGUI_InputPanel( theModule, theTitle ), + HYDROGUI_ObjComboBoxFilter() { // Channel name QGroupBox* group = new QGroupBox( mainFrame() ); QBoxLayout* base = new QVBoxLayout( group ); base->addWidget( myRivers = new HYDROGUI_ObjComboBox( theModule, tr( "RIVER_OBJECT" ), KIND_STREAM, group ) ); + myRivers->setObjectFilter( this ); addWidget( group ); @@ -73,6 +78,12 @@ void HYDROGUI_RiverBottomDlg::setRiverName( const QString& theName ) myRivers->setSectedObject( theName ); } +bool HYDROGUI_RiverBottomDlg::isOk( const Handle(HYDROData_Entity)& theEntity ) const +{ + Handle(HYDROData_Stream) aStream = Handle(HYDROData_Stream)::DownCast(theEntity); + return !aStream.IsNull() && aStream->GetBottomPolyline().IsNull(); +} + void HYDROGUI_RiverBottomDlg::onRiverChanged( const QString& ) { updateState(); diff --git a/src/HYDROGUI/HYDROGUI_RiverBottomDlg.h b/src/HYDROGUI/HYDROGUI_RiverBottomDlg.h index d0af4420..f958af96 100644 --- a/src/HYDROGUI/HYDROGUI_RiverBottomDlg.h +++ b/src/HYDROGUI/HYDROGUI_RiverBottomDlg.h @@ -20,15 +20,16 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef HYDROGUI_RIVERBOTTOMDlg_H -#define HYDROGUI_RIVERBOTTOMDlg_H +#ifndef HYDROGUI_RIVERBOTTOMDLG_H +#define HYDROGUI_RIVERBOTTOMDLG_H #include "HYDROGUI_InputPanel.h" +#include "HYDROGUI_ObjComboBox.h" + class QComboBox; -class HYDROGUI_ObjComboBox; -class HYDROGUI_RiverBottomDlg : public HYDROGUI_InputPanel +class HYDROGUI_RiverBottomDlg : public HYDROGUI_InputPanel, public HYDROGUI_ObjComboBoxFilter { Q_OBJECT @@ -41,6 +42,8 @@ public: QString getRiverName() const; void setRiverName( const QString& ); + virtual bool isOk( const Handle(HYDROData_Entity)& ) const; + private slots: void onRiverChanged( const QString& ); -- 2.39.2