From: vsr Date: Thu, 18 Jun 2009 12:32:34 +0000 (+0000) Subject: Issue 0020385: EDF 1051 GUI : Windows of a desactivated module stay visible in the... X-Git-Tag: V5_1_2rc3~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e202aa0991dbc6c35c721a7493ee7b1d55a77cc6;p=modules%2Fvisu.git Issue 0020385: EDF 1051 GUI : Windows of a desactivated module stay visible in the View menu --- diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index af961943..11011105 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -2655,7 +2655,7 @@ VisuGUI tr("MEN_GAUSS_POINT_SELECTION"), "", 0, aParent, true, this, SLOT(OnSwitchSelectionMode())); - // Defenition of the actions for the "Navigation" tool bar + // Definition of the actions for the "Navigation" tool bar registerAction( VISU_SLIDER_PANEL, mySlider->toggleViewAction() ); registerAction( VISU_SWEEP_PANEL, mySweep->toggleViewAction() ); @@ -3171,18 +3171,14 @@ VisuGUI void VisuGUI::createPanels() { - myPanels.insert( SelectionPanelId, new VisuGUI_SelectionPanel( this ) ); - myPanels.insert( FeatureEdgesPanelId, new VisuGUI_FeatureEdgesPanel( this ) ); - myPanels.insert( ClippingPlanesPanelId, new VisuGUI_ClippingPanel( this ) ); - - QMap< PanelId, VisuGUI_Panel* >::iterator it = myPanels.begin(), itEnd = myPanels.end(); - for( ; it != itEnd; ++it ) - { - if( VisuGUI_Panel* aPanel = it.value() ) - { - aPanel->hide(); - GetDesktop(this)->addDockWidget( Qt::RightDockWidgetArea, aPanel ); - } + myPanels[SelectionPanelId] = new VisuGUI_SelectionPanel( this ); + myPanels[FeatureEdgesPanelId] = new VisuGUI_FeatureEdgesPanel( this ); + myPanels[ClippingPlanesPanelId] = new VisuGUI_ClippingPanel( this ); + + VisuGUI_Panel* aPanel; + foreach( aPanel, myPanels ) { + getApp()->desktop()->addDockWidget( Qt::RightDockWidgetArea, aPanel ); + aPanel->setVisible( false ); } } @@ -3414,13 +3410,6 @@ VisuGUI setMenuShown( false ); setToolShown( false ); - QMap< PanelId, VisuGUI_Panel* >::iterator it = myPanels.begin(), itEnd = myPanels.end(); - for( ; it != itEnd; ++it ) - { - if( VisuGUI_Panel* aPanel = it.value() ) - aPanel->hide(); - } - // Unset actions accelerator keys action(VISU_IMPORT_FROM_FILE)->setShortcuts(QKeySequence::UnknownKey); // Import: CTRL + Key_I diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index 3a955a50..58d8f2ce 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -218,12 +218,12 @@ private: int addVtkFontPref( const QString& label, const int pId, const QString& param, const bool useSize ); private: - QMap< PanelId, VisuGUI_Panel* > myPanels; - VisuGUI_Slider* mySlider; - VisuGUI_Sweep* mySweep; + QMap myPanels; + VisuGUI_Slider* mySlider; + VisuGUI_Sweep* mySweep; - LightApp_Displayer* myDisplayer; - VISU::TViewToPrs3d myScalarBarsMap; + LightApp_Displayer* myDisplayer; + VISU::TViewToPrs3d myScalarBarsMap; }; #endif diff --git a/src/VISUGUI/VisuGUI_ClippingPanel.cxx b/src/VISUGUI/VisuGUI_ClippingPanel.cxx index 3839330d..0b1252bd 100644 --- a/src/VISUGUI/VisuGUI_ClippingPanel.cxx +++ b/src/VISUGUI/VisuGUI_ClippingPanel.cxx @@ -208,13 +208,15 @@ CutPlaneFunction::~CutPlaneFunction() //**************************************************************** //**************************************************************** //**************************************************************** -VisuGUI_ClippingPanel::VisuGUI_ClippingPanel(VisuGUI* theModule) - : VisuGUI_Panel(tr("TITLE"), theModule, VISU::GetDesktop(theModule), ApplyBtn | HelpBtn ), - myModule(theModule), +VisuGUI_ClippingPanel::VisuGUI_ClippingPanel( VisuGUI* theModule, QWidget* theParent ) + : VisuGUI_Panel( tr( "TITLE" ), theModule, theParent, ApplyBtn | HelpBtn ), myPlaneDlg(0), myViewWindow(0), myIsApplied(true) { + setWindowTitle( tr( "TITLE" ) ); + setObjectName( tr( "TITLE" ) ); + QVBoxLayout* aMainLayout = new QVBoxLayout(mainFrame()); // List of presentations diff --git a/src/VISUGUI/VisuGUI_ClippingPanel.h b/src/VISUGUI/VisuGUI_ClippingPanel.h index 1e40755b..a3d6f004 100644 --- a/src/VISUGUI/VisuGUI_ClippingPanel.h +++ b/src/VISUGUI/VisuGUI_ClippingPanel.h @@ -115,7 +115,7 @@ class VisuGUI_ClippingPanel: public VisuGUI_Panel { Q_OBJECT public: - VisuGUI_ClippingPanel(VisuGUI* theModule); + VisuGUI_ClippingPanel(VisuGUI* theModule, QWidget* theParent = 0); ~VisuGUI_ClippingPanel(); void init(); @@ -169,8 +169,6 @@ private slots: QStringList getPrsList(_PTR(Study) theStudy, _PTR(SObject) theObject); VISU::Prs3d_i* getPrs(QString theEntry); - VisuGUI* myModule; - QListWidget* myPrsList; QTableWidget* myPlanesList; diff --git a/src/VISUGUI/VisuGUI_FeatureEdgesPanel.cxx b/src/VISUGUI/VisuGUI_FeatureEdgesPanel.cxx index fc7f1929..7162c691 100644 --- a/src/VISUGUI/VisuGUI_FeatureEdgesPanel.cxx +++ b/src/VISUGUI/VisuGUI_FeatureEdgesPanel.cxx @@ -47,10 +47,13 @@ #include -VisuGUI_FeatureEdgesPanel::VisuGUI_FeatureEdgesPanel( const VisuGUI* theModule, QWidget* theParent ) : +VisuGUI_FeatureEdgesPanel::VisuGUI_FeatureEdgesPanel( VisuGUI* theModule, QWidget* theParent ) : VisuGUI_Panel( tr( "WINDOW_TITLE" ), theModule, theParent, ApplyBtn | CloseBtn | HelpBtn ), myActor( 0 ) { + setWindowTitle( tr( "WINDOW_TITLE" ) ); + setObjectName( tr( "WINDOW_TITLE" ) ); + QVBoxLayout* aTopLayout = new QVBoxLayout( mainFrame() ); myGrp = new QGroupBox( tr( "FEATURE_EDGES_PROPERTIES" ), mainFrame() ); @@ -77,10 +80,8 @@ VisuGUI_FeatureEdgesPanel::VisuGUI_FeatureEdgesPanel( const VisuGUI* theModule, aTopLayout->addWidget( myGrp ); - SalomeApp_Application* anApp = - dynamic_cast( SUIT_Session::session()->activeApplication() ); - LightApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr(); - connect( aSelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionEvent() ) ); + connect( myModule->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), + this, SLOT( onSelectionEvent() ) ); } VisuGUI_FeatureEdgesPanel::~VisuGUI_FeatureEdgesPanel() @@ -148,7 +149,7 @@ void VisuGUI_FeatureEdgesPanel::onSelectionEvent() anIsManifoldEdges, anIsNonManifoldEdges ); - float aColoring = myActor->GetFeatureEdgesColoring(); + //float aColoring = myActor->GetFeatureEdgesColoring(); myAngleSpinBox->setValue( anAngle ); myFeatureEdgesCB->setChecked( anIsFeatureEdges ); @@ -176,7 +177,7 @@ void VisuGUI_FeatureEdgesPanel::onApply() void VisuGUI_FeatureEdgesPanel::onClose() { - close(); + // hide(); VisuGUI_Panel::onClose(); } @@ -213,3 +214,19 @@ void VisuGUI_FeatureEdgesPanel::keyPressEvent( QKeyEvent* e ) onHelp(); } } + +void VisuGUI_FeatureEdgesPanel::onModuleActivated() +{ + disconnect( myModule->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), + this, SLOT( onSelectionEvent() ) ); + connect( myModule->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), + this, SLOT( onSelectionEvent() ) ); + VisuGUI_Panel::onModuleActivated(); +} + +void VisuGUI_FeatureEdgesPanel::onModuleDeactivated() +{ + disconnect( myModule->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), + this, SLOT( onSelectionEvent() ) ); + VisuGUI_Panel::onModuleDeactivated(); +} diff --git a/src/VISUGUI/VisuGUI_FeatureEdgesPanel.h b/src/VISUGUI/VisuGUI_FeatureEdgesPanel.h index 6e36dd83..504d24eb 100644 --- a/src/VISUGUI/VisuGUI_FeatureEdgesPanel.h +++ b/src/VISUGUI/VisuGUI_FeatureEdgesPanel.h @@ -41,13 +41,17 @@ class VisuGUI_FeatureEdgesPanel: public VisuGUI_Panel Q_OBJECT public: - VisuGUI_FeatureEdgesPanel( const VisuGUI* theModule, QWidget* theParent = 0 ); + VisuGUI_FeatureEdgesPanel( VisuGUI* theModule, QWidget* theParent = 0 ); virtual ~VisuGUI_FeatureEdgesPanel (); protected: virtual void keyPressEvent( QKeyEvent* theEvent ); virtual void showEvent( QShowEvent* theEvent ); +protected slots: + virtual void onModuleActivated(); + virtual void onModuleDeactivated(); + private slots: virtual void onApply(); virtual void onClose(); diff --git a/src/VISUGUI/VisuGUI_Panel.cxx b/src/VISUGUI/VisuGUI_Panel.cxx index c1be4ea0..bf02fc76 100755 --- a/src/VISUGUI/VisuGUI_Panel.cxx +++ b/src/VISUGUI/VisuGUI_Panel.cxx @@ -43,7 +43,7 @@ \brief Frame inserted in viewport with redefined sizeHint method in order to avoid unreasonable increasing of viewport size */ -class VisuGUI_Panel::MainFrame : public QFrame +class VisuGUI_Panel::MainFrame : public QWidget { public: /*! @@ -51,7 +51,7 @@ public: \param theParent parent widget */ MainFrame( QWidget* theParent = 0 ) - : QFrame( theParent ) + : QWidget( theParent ) { } @@ -77,29 +77,33 @@ public: /*! \brief Constructor creates panels look and feel - \param theName name of the panel + \param theName panel title + \param theModule parent VISU GUI module \param theParent parent widget + \param theBtns panel buttons */ -VisuGUI_Panel::VisuGUI_Panel( const QString& theName, - const VisuGUI* theModule, - QWidget* theParent, - const int theBtns ) - : QtxDockWidget( theName, theParent ), +VisuGUI_Panel::VisuGUI_Panel( const QString& theName, + VisuGUI* theModule, + QWidget* theParent, + const int theBtns ) + : QtxDockWidget( true, theParent ), myModule( theModule ), myOK( 0 ), myApply( 0 ), myClose( 0 ), myHelp( 0 ) { + setObjectName( theName ); + QWidget* aGrp = new QWidget( this ); setWidget( aGrp ); // Create scroll view myView = new QScrollArea( aGrp ); + myView->setFrameStyle( QFrame::Plain | QFrame::NoFrame ); // Create main frame myMainFrame = new MainFrame( myView ); - myMainFrame->setFrameStyle( QFrame::Plain | QFrame::NoFrame ); myView->setWidget( myMainFrame ); myView->setAlignment( Qt::AlignCenter ); @@ -107,32 +111,32 @@ VisuGUI_Panel::VisuGUI_Panel( const QString& theName, myView->setMinimumWidth( myMainFrame->sizeHint().width() + 22 ); // Create buttons - QWidget* aBtnWg = new QWidget( aGrp ); - QHBoxLayout* aBtnWgLayout = new QHBoxLayout( aBtnWg ); + QHBoxLayout* aBtnWgLayout = new QHBoxLayout; + aBtnWgLayout->setMargin( 0 ); aBtnWgLayout->addStretch(); if( theBtns & OKBtn ) { - myOK = new QPushButton( tr( "BUT_OK" ), aBtnWg ); + myOK = new QPushButton( tr( "BUT_OK" ), aGrp ); aBtnWgLayout->addWidget( myOK ); connect( myOK, SIGNAL( clicked() ), SLOT( onOK() ) ); } if( theBtns & ApplyBtn ) { - myApply = new QPushButton( tr( "BUT_APPLY" ), aBtnWg ); + myApply = new QPushButton( tr( "BUT_APPLY" ), aGrp ); aBtnWgLayout->addWidget( myApply ); connect( myApply, SIGNAL( clicked() ), SLOT( onApply() ) ); } if( theBtns & CloseBtn ) { - myClose = new QPushButton( tr( "BUT_CLOSE" ), aBtnWg ); + myClose = new QPushButton( tr( "BUT_CLOSE" ), aGrp ); aBtnWgLayout->addWidget( myClose ); connect( myClose, SIGNAL( clicked() ), SLOT( onClose() ) ); } if( theBtns & HelpBtn ) { - myHelp = new QPushButton( tr( "BUT_HELP" ), aBtnWg ); + myHelp = new QPushButton( tr( "BUT_HELP" ), aGrp ); aBtnWgLayout->addWidget( myHelp ); connect( myHelp, SIGNAL( clicked() ), SLOT( onHelp() ) ); } @@ -141,9 +145,12 @@ VisuGUI_Panel::VisuGUI_Panel( const QString& theName, // fill layout QVBoxLayout* aLay = new QVBoxLayout( aGrp ); - aLay->setContentsMargins( 0, 0, 0, 0 ); + aLay->setMargin( 2 ); aLay->addWidget( myView, 1 ); - aLay->addWidget( aBtnWg ); + aLay->addLayout( aBtnWgLayout ); + + connect( theModule, SIGNAL( moduleDeactivated() ), SLOT( onModuleDeactivated() ) ); + connect( theModule, SIGNAL( moduleActivated() ), SLOT( onModuleActivated() ) ); } /*! @@ -218,6 +225,7 @@ void VisuGUI_Panel::onClose() { if ( myClose ) myClose->setFocus(); + hide(); } /*! @@ -235,7 +243,17 @@ void VisuGUI_Panel::onHelp() panels should use it as parent \return QFrame* object */ -QFrame* VisuGUI_Panel::mainFrame() +QWidget* VisuGUI_Panel::mainFrame() { return myMainFrame; } + +void VisuGUI_Panel::onModuleActivated() +{ + widget()->setHidden( false ); +} + +void VisuGUI_Panel::onModuleDeactivated() +{ + widget()->setHidden( true ); +} diff --git a/src/VISUGUI/VisuGUI_Panel.h b/src/VISUGUI/VisuGUI_Panel.h index a3336c9b..05f33c80 100755 --- a/src/VISUGUI/VisuGUI_Panel.h +++ b/src/VISUGUI/VisuGUI_Panel.h @@ -29,7 +29,6 @@ #include -class QFrame; class QScrollArea; class QPushButton; @@ -51,9 +50,9 @@ public: public: VisuGUI_Panel( const QString& theName, - const VisuGUI* theModule, - QWidget* theParent, - const int theBtns = AllBtn ); + VisuGUI* theModule, + QWidget* theParent = 0, + const int theBtns = AllBtn ); virtual ~VisuGUI_Panel(); virtual bool isValid( QString& theMessage ); @@ -65,19 +64,22 @@ protected slots: virtual void onClose(); virtual void onHelp(); + virtual void onModuleActivated(); + virtual void onModuleDeactivated(); + protected: - QFrame* mainFrame(); + QWidget* mainFrame(); protected: QScrollArea* myView; - QFrame* myMainFrame; + QWidget* myMainFrame; QPushButton* myOK; QPushButton* myApply; QPushButton* myClose; QPushButton* myHelp; - const VisuGUI* myModule; + VisuGUI* myModule; }; #endif diff --git a/src/VISUGUI/VisuGUI_SelectionPanel.cxx b/src/VISUGUI/VisuGUI_SelectionPanel.cxx index cb8531a3..f0dc15d2 100644 --- a/src/VISUGUI/VisuGUI_SelectionPanel.cxx +++ b/src/VISUGUI/VisuGUI_SelectionPanel.cxx @@ -122,10 +122,13 @@ public: } }; -VisuGUI_SelectionPanel::VisuGUI_SelectionPanel( const VisuGUI* theModule, QWidget* theParent ) : - VisuGUI_Panel( tr("WINDOW_TITLE" ), theModule, theParent, CloseBtn | HelpBtn ), +VisuGUI_SelectionPanel::VisuGUI_SelectionPanel( VisuGUI* theModule, QWidget* theParent ) : + VisuGUI_Panel( tr( "WINDOW_TITLE" ), theModule, theParent, CloseBtn | HelpBtn ), myPreferencesDlg( 0 ) { + setWindowTitle( tr( "WINDOW_TITLE" ) ); + setObjectName( tr( "WINDOW_TITLE" ) ); + QVBoxLayout* TopLayout = new QVBoxLayout ( mainFrame() ); QWidget* aNamePane = new QWidget (mainFrame()); @@ -335,10 +338,8 @@ VisuGUI_SelectionPanel::VisuGUI_SelectionPanel( const VisuGUI* theModule, QWidge TopLayout->addWidget( aPrefBtn ); - SalomeApp_Application* anApp = - dynamic_cast( SUIT_Session::session()->activeApplication() ); - LightApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr(); - connect( aSelectionMgr, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionEvent() ) ); + connect( myModule->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), + this, SLOT( onSelectionEvent() ) ); connect( this, SIGNAL( selectionModeChanged( int ) ), myModule, SLOT( OnSwitchSelectionMode( int ) ) ); @@ -450,7 +451,7 @@ void VisuGUI_SelectionPanel::showEvent( QShowEvent* theEvent ) void VisuGUI_SelectionPanel::closeEvent( QCloseEvent* theEvent ) { - onClose(); + //onClose(); VisuGUI_Panel::closeEvent(theEvent); } @@ -518,7 +519,7 @@ void VisuGUI_SelectionPanel::onSelectionEvent() { case GaussPointSelection: break; default: - close(); + hide(); return; } @@ -1091,7 +1092,7 @@ void VisuGUI_SelectionPanel::onApply() void VisuGUI_SelectionPanel::onClose() { - close(); + //hide(); VisuGUI_Panel::onClose(); } @@ -1128,3 +1129,19 @@ void VisuGUI_SelectionPanel::keyPressEvent( QKeyEvent* e ) onHelp(); } } + +void VisuGUI_SelectionPanel::onModuleActivated() +{ + disconnect( myModule->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), + this, SLOT( onSelectionEvent() ) ); + connect( myModule->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), + this, SLOT( onSelectionEvent() ) ); + VisuGUI_Panel::onModuleActivated(); +} + +void VisuGUI_SelectionPanel::onModuleDeactivated() +{ + disconnect( myModule->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), + this, SLOT( onSelectionEvent() ) ); + VisuGUI_Panel::onModuleDeactivated(); +} diff --git a/src/VISUGUI/VisuGUI_SelectionPanel.h b/src/VISUGUI/VisuGUI_SelectionPanel.h index c903e454..324ce098 100644 --- a/src/VISUGUI/VisuGUI_SelectionPanel.h +++ b/src/VISUGUI/VisuGUI_SelectionPanel.h @@ -92,12 +92,16 @@ class VisuGUI_SelectionPanel: public VisuGUI_Panel enum ColumnId { Cell = 0, Point, X, Y, Z, I, J, K, Scalar, Vector }; public: - VisuGUI_SelectionPanel( const VisuGUI* theModule, QWidget* theParent = 0 ); + VisuGUI_SelectionPanel( VisuGUI* theModule, QWidget* theParent = 0 ); virtual ~VisuGUI_SelectionPanel (); public: void setSelectionMode( int theId ); +protected slots: + virtual void onModuleActivated(); + virtual void onModuleDeactivated(); + protected: virtual void keyPressEvent( QKeyEvent* theEvent ); virtual void showEvent( QShowEvent* theEvent );