From: asl Date: Wed, 27 Sep 2017 14:38:19 +0000 (+0300) Subject: refs #1332: implementation of the splitter X-Git-Tag: v2.1~66^2~12^2~3^2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=eee00c80cd11f796f34a49a60bec357374e92823;p=modules%2Fhydro.git refs #1332: implementation of the splitter --- diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.cxx b/src/HYDROGUI/HYDROGUI_InputPanel.cxx index 2c058db3..0049fac7 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.cxx +++ b/src/HYDROGUI/HYDROGUI_InputPanel.cxx @@ -27,8 +27,10 @@ #include #include #include +#include -HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle, bool doInitLayout ) +HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle, + bool doInitLayout, bool isSplitter ) #ifdef LIGHT_MODE : QDockWidget( 0 ), #else @@ -49,6 +51,14 @@ HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QStr QBoxLayout* aMainLayout = new QVBoxLayout( myMainFrame ); aMainLayout->setMargin( 0 ); aMainLayout->setSpacing( 5 ); + if( isSplitter ) + { + mySplitter = new QSplitter( myMainFrame ); + mySplitter->setOrientation( Qt::Vertical ); + aMainLayout->addWidget( mySplitter, 1 ); + } + else + mySplitter = 0; aLayout->addWidget( myMainFrame, 1 ); @@ -126,26 +136,55 @@ void HYDROGUI_InputPanel::closeEvent ( QCloseEvent * event ) void HYDROGUI_InputPanel::insertWidget( QWidget* theWidget, int theIndex, int theStretch ) { - QBoxLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); - aMainLayout->insertWidget( theIndex, theWidget, theStretch ); + if( mySplitter ) + { + mySplitter->insertWidget( theIndex, theWidget ); + mySplitter->setStretchFactor( theIndex, theStretch ); + } + else + { + QBoxLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); + aMainLayout->insertWidget( theIndex, theWidget, theStretch ); + } } void HYDROGUI_InputPanel::addWidget( QWidget* theWidget, int theStretch ) { - QBoxLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); - aMainLayout->addWidget( theWidget, theStretch ); + if( mySplitter ) + { + int s = mySplitter->count(); + mySplitter->addWidget( theWidget ); + mySplitter->setStretchFactor( s, theStretch ); + } + else + { + QBoxLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); + aMainLayout->addWidget( theWidget, theStretch ); + } } void HYDROGUI_InputPanel::addLayout( QLayout* theLayout, int theStretch ) { - QBoxLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); - aMainLayout->addLayout( theLayout, theStretch ); + if( mySplitter ) + { + } + else + { + QBoxLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); + aMainLayout->addLayout( theLayout, theStretch ); + } } void HYDROGUI_InputPanel::addStretch() { - QBoxLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); - aMainLayout->addStretch(); + if( mySplitter ) + { + } + else + { + QBoxLayout* aMainLayout = dynamic_cast( myMainFrame->layout() ); + aMainLayout->addStretch(); + } } QFrame* HYDROGUI_InputPanel::mainFrame() const @@ -157,3 +196,8 @@ QFrame* HYDROGUI_InputPanel::buttonFrame() const { return myBtnFrame; } + +QSplitter* HYDROGUI_InputPanel::splitter() const +{ + return mySplitter; +} diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.h b/src/HYDROGUI/HYDROGUI_InputPanel.h index 351b3cdc..e5093afa 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.h +++ b/src/HYDROGUI/HYDROGUI_InputPanel.h @@ -25,6 +25,7 @@ class QFrame; class QPushButton; class QLayout; class QCloseEvent; +class QSplitter; class HYDROGUI_Module; @@ -36,7 +37,7 @@ class HYDROGUI_InputPanel : public QDockWidget Q_OBJECT public: - HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle, bool doInitLayout = true ); + HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle, bool doInitLayout = true, bool isSplitter = false ); virtual ~HYDROGUI_InputPanel(); void addWidget( QWidget* theWidget, int theStretch = 0 ); @@ -66,6 +67,8 @@ protected: QFrame* buttonFrame() const; virtual void closeEvent ( QCloseEvent * event ); + QSplitter* splitter() const; + QPushButton* myCancel; QPushButton* myHelp; @@ -75,6 +78,7 @@ private: QFrame* myBtnFrame; QPushButton* myApplyAndClose; QPushButton* myApply; + QSplitter* mySplitter; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx index 98767efd..3f7c8b6c 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileDlg.cxx @@ -42,7 +42,7 @@ #include HYDROGUI_ProfileDlg::HYDROGUI_ProfileDlg( HYDROGUI_Module* theModule, const QString& theTitle ) -: HYDROGUI_ViewerDlg( theModule, theTitle ), +: HYDROGUI_ViewerDlg( theModule, theTitle, true ), myName( NULL ) { QFrame* name_frame = new QFrame( mainFrame() ); @@ -53,7 +53,7 @@ HYDROGUI_ProfileDlg::HYDROGUI_ProfileDlg( HYDROGUI_Module* theModule, const QStr myName = new QLineEdit(this); name_layout->addWidget(myName); - insertWidget( name_frame, 0, 0); + insertWidget( name_frame, 0, 0 ); int anActionFlags = CurveCreator_Widget::DisableNewSection | CurveCreator_Widget::DisableDetectionMode | diff --git a/src/HYDROGUI/HYDROGUI_ProfileInterpolateDlg.cxx b/src/HYDROGUI/HYDROGUI_ProfileInterpolateDlg.cxx index 70b3a7e2..fe3f1beb 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileInterpolateDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileInterpolateDlg.cxx @@ -45,7 +45,7 @@ #include HYDROGUI_ProfileInterpolateDlg::HYDROGUI_ProfileInterpolateDlg( HYDROGUI_Module* theModule, const QString& theTitle ) - : HYDROGUI_ViewerDlg( theModule, theTitle ) + : HYDROGUI_ViewerDlg( theModule, theTitle, false ) { QWidget* main = new QGroupBox( mainFrame() ); QGridLayout* base = new QGridLayout( main ); diff --git a/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx b/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx index 1a8a6c36..4465443d 100644 --- a/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ViewerDlg.cxx @@ -43,8 +43,8 @@ #include #include -HYDROGUI_ViewerDlg::HYDROGUI_ViewerDlg( HYDROGUI_Module* theModule, const QString& theTitle ) -: HYDROGUI_InputPanel( theModule, theTitle ) +HYDROGUI_ViewerDlg::HYDROGUI_ViewerDlg( HYDROGUI_Module* theModule, const QString& theTitle, bool isSplitter ) +: HYDROGUI_InputPanel( theModule, theTitle, true, isSplitter ) { SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); myViewManager = new OCCViewer_ViewManager( theModule->getApp()->activeStudy(), 0 ); @@ -109,7 +109,7 @@ bool HYDROGUI_ViewerDlg::event( QEvent* e ) { if ( e->type() == QEvent::Polish ) { - addWidget( myCoordLabel->parentWidget(), 4 ); + //addWidget( myCoordLabel->parentWidget(), 4 ); Handle(AIS_Trihedron) aTrihedron = trihedron(); Handle(AIS_InteractiveContext) anAISContext = getAISContext(); diff --git a/src/HYDROGUI/HYDROGUI_ViewerDlg.h b/src/HYDROGUI/HYDROGUI_ViewerDlg.h index a638b06b..0f5ed4b9 100644 --- a/src/HYDROGUI/HYDROGUI_ViewerDlg.h +++ b/src/HYDROGUI/HYDROGUI_ViewerDlg.h @@ -37,7 +37,7 @@ class HYDROGUI_ViewerDlg : public HYDROGUI_InputPanel Q_OBJECT public: - HYDROGUI_ViewerDlg( HYDROGUI_Module* theModule, const QString& theTitle ); + HYDROGUI_ViewerDlg( HYDROGUI_Module* theModule, const QString& theTitle, bool isSplitter ); virtual ~HYDROGUI_ViewerDlg(); Handle(AIS_InteractiveContext) getAISContext();