From: ouv Date: Fri, 20 Sep 2013 15:27:31 +0000 (+0000) Subject: Few GUI modifications related to the Create Polyline functionality. X-Git-Tag: BR_hydro_v_0_1~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7ba9e0e34e3d326077ecb01fb6ce837cde1627bc;p=modules%2Fhydro.git Few GUI modifications related to the Create Polyline functionality. --- diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.cxx b/src/HYDROGUI/HYDROGUI_InputPanel.cxx index a20c755b..5b9fa21d 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.cxx +++ b/src/HYDROGUI/HYDROGUI_InputPanel.cxx @@ -28,7 +28,6 @@ #include #include -#include HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle ) : QDockWidget( theModule->application()->desktop() ), @@ -43,17 +42,14 @@ HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QStr QVBoxLayout* aLayout = new QVBoxLayout( aFrame ); myMainFrame = new QFrame( aFrame ); - QVBoxLayout* aMainLayout = new QVBoxLayout( myMainFrame ); + QBoxLayout* aMainLayout = new QVBoxLayout( myMainFrame ); aMainLayout->setMargin( 0 ); aMainLayout->setSpacing( 5 ); - myStackedLayout = new QStackedLayout(); - myBtnFrame = new QFrame( aFrame ); - activateWidget( myBtnFrame ); - aLayout->addWidget( myMainFrame, 3 ); - aLayout->addLayout( myStackedLayout, 1 ); + aLayout->addWidget( myMainFrame, 1 ); + aLayout->addWidget( myBtnFrame, 0 ); QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame ); aBtnsLayout->setMargin( 5 ); @@ -96,10 +92,10 @@ void HYDROGUI_InputPanel::onHelp() { } -void HYDROGUI_InputPanel::addWidget( QWidget* theWidget ) +void HYDROGUI_InputPanel::addWidget( QWidget* theWidget, int theStretch ) { QBoxLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); - aMainLayout->addWidget( theWidget ); + aMainLayout->addWidget( theWidget, theStretch ); } void HYDROGUI_InputPanel::addLayout( QLayout* theLayout ) @@ -118,15 +114,3 @@ QFrame* HYDROGUI_InputPanel::mainFrame() const { return myMainFrame; } - -void HYDROGUI_InputPanel::activateWidget( QWidget* theWidget ) -{ - if (theWidget == 0) { - myStackedLayout->setCurrentIndex( 0 ); - } - else { - if ( myStackedLayout->indexOf( theWidget ) == -1 ) - myStackedLayout->addWidget( theWidget ); - myStackedLayout->setCurrentWidget( theWidget ); - } -} diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.h b/src/HYDROGUI/HYDROGUI_InputPanel.h index 7c3c829b..9d16ad0f 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.h +++ b/src/HYDROGUI/HYDROGUI_InputPanel.h @@ -28,7 +28,6 @@ class QFrame; class QPushButton; class QLayout; -class QStackedLayout; class HYDROGUI_Module; @@ -43,12 +42,10 @@ public: HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle ); virtual ~HYDROGUI_InputPanel(); - void addWidget( QWidget* theWidget ); + void addWidget( QWidget* theWidget, int theStretch = 0 ); void addLayout( QLayout* theLayout ); void addStretch(); - void addToStackedLayout( QWidget* ); - void activateWidget( QWidget* ); HYDROGUI_Module* module() const; signals: @@ -70,7 +67,6 @@ private: QPushButton* myApply; QPushButton* myCancel; QPushButton* myHelp; - QStackedLayout* myStackedLayout; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx b/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx index 40a831d8..e68a8f67 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_PolylineDlg.cxx @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -41,14 +42,21 @@ HYDROGUI_PolylineDlg::HYDROGUI_PolylineDlg( HYDROGUI_Module* theModule, const QS addLayout(aNameLayout); - myEditorWidget = - new CurveCreator_Widget( this, NULL ); + myEditorWidget = new CurveCreator_Widget( this, NULL ); + addWidget( myEditorWidget, 3 ); - addWidget( myEditorWidget ); + myAddElementBox = new QGroupBox( tr( "ADD_ELEMENT" ), this ); + addWidget( myAddElementBox, 2 ); + + QBoxLayout* anAddElementLayout = new QVBoxLayout( myAddElementBox ); + anAddElementLayout->setMargin( 0 ); + anAddElementLayout->setSpacing( 5 ); connect( myEditorWidget, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); connect( myEditorWidget, SIGNAL( subOperationStarted(QWidget*) ), this, SLOT( processStartedSubOperation(QWidget*) ) ); connect( myEditorWidget, SIGNAL( subOperationFinished(QWidget*) ), this, SLOT( processFinishedSubOperation(QWidget*) ) ); + + myAddElementBox->hide(); } HYDROGUI_PolylineDlg::~HYDROGUI_PolylineDlg() @@ -58,13 +66,23 @@ HYDROGUI_PolylineDlg::~HYDROGUI_PolylineDlg() void HYDROGUI_PolylineDlg::processStartedSubOperation( QWidget* theWidget ) { myEditorWidget->setEnabled( false ); - activateWidget( theWidget ); + + QBoxLayout* anAddElementLayout = dynamic_cast( myAddElementBox->layout() ); + anAddElementLayout->addWidget( theWidget ); + + theWidget->show(); + myAddElementBox->show(); } void HYDROGUI_PolylineDlg::processFinishedSubOperation( QWidget* theWidget ) { myEditorWidget->setEnabled( true ); - activateWidget( 0 ); + + QBoxLayout* anAddElementLayout = dynamic_cast( myAddElementBox->layout() ); + anAddElementLayout->removeWidget( theWidget ); + + theWidget->hide(); + myAddElementBox->hide(); } void HYDROGUI_PolylineDlg::reset() diff --git a/src/HYDROGUI/HYDROGUI_PolylineDlg.h b/src/HYDROGUI/HYDROGUI_PolylineDlg.h index 4ca803fa..01d5a13c 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineDlg.h +++ b/src/HYDROGUI/HYDROGUI_PolylineDlg.h @@ -25,7 +25,7 @@ #include "HYDROGUI_InputPanel.h" - +class QGroupBox; class QLineEdit; class CurveCreator_Widget; class CurveCreator_Curve; @@ -60,6 +60,7 @@ signals: private: QLineEdit* myName; CurveCreator_Widget* myEditorWidget; + QGroupBox* myAddElementBox; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx index 2e3ad922..b8b19f76 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx +++ b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx @@ -52,6 +52,7 @@ HYDROGUI_PolylineOp::HYDROGUI_PolylineOp( HYDROGUI_Module* theModule, bool theIs HYDROGUI_PolylineOp::~HYDROGUI_PolylineOp() { + closePreview(); } HYDROGUI_InputPanel* HYDROGUI_PolylineOp::createInputPanel() const @@ -121,6 +122,9 @@ void HYDROGUI_PolylineOp::onCreatePreview() dynamic_cast( anApp->createViewManager( OCCViewer_Viewer::Type() ) ); if( myPreviewViewManager ) { + connect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ), + this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) ); + //anApp->selectionMgr()->setEnabled(false); // what the hell?! myPreviewViewManager->setTitle( tr( "CREATE_POLYLINE" ) ); OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer(); @@ -188,6 +192,20 @@ void HYDROGUI_PolylineOp::startOperation() onCreatePreview(); } +void HYDROGUI_PolylineOp::abortOperation() +{ + closePreview(); + + HYDROGUI_Operation::abortOperation(); +} + +void HYDROGUI_PolylineOp::commitOperation() +{ + closePreview(); + + HYDROGUI_Operation::commitOperation(); +} + void HYDROGUI_PolylineOp::onEditorSelectionChanged() { HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel(); @@ -205,3 +223,26 @@ void HYDROGUI_PolylineOp::onEditorSelectionChanged() } } } + +void HYDROGUI_PolylineOp::onLastViewClosed( SUIT_ViewManager* theViewManager ) +{ + closePreview(); +} + +void HYDROGUI_PolylineOp::closePreview() +{ + if( myPreviewViewManager ) + { + disconnect( myPreviewViewManager, SIGNAL( lastViewClosed( SUIT_ViewManager* ) ), + this, SLOT( onLastViewClosed( SUIT_ViewManager* ) ) ); + + module()->getApp()->removeViewManager( myPreviewViewManager ); // myPreviewViewManager is deleted here + myPreviewViewManager = 0; + } + + if( myActiveViewManager ) + { + HYDROGUI_Tool::SetActiveViewManager( module(), myActiveViewManager ); + myActiveViewManager = 0; + } +} diff --git a/src/HYDROGUI/HYDROGUI_PolylineOp.h b/src/HYDROGUI/HYDROGUI_PolylineOp.h index 2502c970..28667125 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineOp.h +++ b/src/HYDROGUI/HYDROGUI_PolylineOp.h @@ -27,9 +27,9 @@ #include -class CurveCreator_Curve; -class SUIT_ViewManager; class OCCViewer_ViewManager; +class SUIT_ViewManager; +class CurveCreator_Curve; class HYDROGUI_AISCurve; class HYDROGUI_PolylineOp : public HYDROGUI_Operation @@ -41,21 +41,28 @@ public: virtual ~HYDROGUI_PolylineOp(); protected: + virtual void startOperation(); + virtual void abortOperation(); + virtual void commitOperation(); + virtual HYDROGUI_InputPanel* createInputPanel() const; - virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); + virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg ); - virtual void startOperation(); - - void onCreatePreview(); + void onCreatePreview(); protected slots: - void onEditorSelectionChanged(); + void onEditorSelectionChanged(); + + void onLastViewClosed( SUIT_ViewManager* ); + +private: + void closePreview(); private: - SUIT_ViewManager* myActiveViewManager; + SUIT_ViewManager* myActiveViewManager; - OCCViewer_ViewManager* myPreviewViewManager; + OCCViewer_ViewManager* myPreviewViewManager; bool myIsEdit; Handle(HYDROData_Polyline) myEditedObject; diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 13f36555..9aee684a 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -711,6 +711,10 @@ file cannot be correctly imported for a Bathymetry definition. HYDROGUI_PolylineDlg + + ADD_ELEMENT + Add element + CURVE_NAME_TLT Name