From: asl Date: Thu, 1 Dec 2005 10:04:49 +0000 (+0000) Subject: Improvement: now in rules you can use "canBeDisplayed" parameter. It is true, if... X-Git-Tag: BR_3_1_0_deb~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=14bb6518f00803b4505af74c42a65722cb6b1784;p=modules%2Fgui.git Improvement: now in rules you can use "canBeDisplayed" parameter. It is true, if current object can be displayed in active viewer. The result of this check is calculated by new virtual method LightApp_Displayer::canBeDisplayed. GEOM, SMESH, VISU overrides it in order to provide information, what object can be displayed in what viewer --- diff --git a/src/LightApp/LightApp_Displayer.cxx b/src/LightApp/LightApp_Displayer.cxx index f2952de04..17475e574 100644 --- a/src/LightApp/LightApp_Displayer.cxx +++ b/src/LightApp/LightApp_Displayer.cxx @@ -1,6 +1,9 @@ #include "LightApp_Displayer.h" #include "LightApp_Application.h" +#include "LightApp_Module.h" + +#include #include @@ -143,3 +146,48 @@ SALOME_View* LightApp_Displayer::GetActiveView() } return 0; } + +bool LightApp_Displayer::canBeDisplayed( const QString&, const QString& ) const +{ + return true; +} + +bool LightApp_Displayer::canBeDisplayed( const QString& entry ) const +{ + QString viewerType; + SUIT_Session* session = SUIT_Session::session(); + if( SUIT_Application* app = session->activeApplication() ) + if( LightApp_Application* sApp = dynamic_cast( app ) ) + if( SUIT_ViewManager* vman = sApp->activeViewManager() ) + if( SUIT_ViewModel* vmod = vman->getViewModel() ) + viewerType = vmod->getType(); + return !viewerType.isNull() && canBeDisplayed( entry, viewerType ); +} + +LightApp_Displayer* LightApp_Displayer::FindDisplayer( const QString& mod_name, const bool load ) +{ + SUIT_Session* session = SUIT_Session::session(); + SUIT_Application* sapp = session ? session->activeApplication() : 0; + LightApp_Application* app = dynamic_cast( sapp ); + if( !app ) + return 0; + + LightApp_Module* m = dynamic_cast( app ? app->module( mod_name ) : 0 ); + if( !m && load ) + { + m = dynamic_cast( app->loadModule( mod_name ) ); + if( m ) + app->addModule( m ); + } + + if( m ) + { + m->connectToStudy( dynamic_cast( app->activeStudy() ) ); + if( m!=app->activeModule() && load ) + { + m->setMenuShown( false ); + m->setToolShown( false ); + } + } + return m ? m->displayer() : 0; +} diff --git a/src/LightApp/LightApp_Displayer.h b/src/LightApp/LightApp_Displayer.h index 94ccd4f90..cafb3cd7f 100644 --- a/src/LightApp/LightApp_Displayer.h +++ b/src/LightApp/LightApp_Displayer.h @@ -19,7 +19,11 @@ public: bool IsDisplayed( const QString&, SALOME_View* = 0 ) const; void UpdateViewer() const; - static SALOME_View* GetActiveView(); + static SALOME_View* GetActiveView(); + static LightApp_Displayer* FindDisplayer( const QString&, const bool ); + + virtual bool canBeDisplayed( const QString& /*entry*/, const QString& /*viewer_type*/ ) const; + bool canBeDisplayed( const QString& /*entry*/ ) const; protected: virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 ); diff --git a/src/LightApp/LightApp_Module.cxx b/src/LightApp/LightApp_Module.cxx index b3f1428cb..46d3f82af 100644 --- a/src/LightApp/LightApp_Module.cxx +++ b/src/LightApp/LightApp_Module.cxx @@ -253,8 +253,9 @@ QtxPopupMgr* LightApp_Module::popupMgr() myPopupMgr->insert( eraseAll, -1, 0 ); myPopupMgr->insert( separator(), -1, 0 ); - QString uniform = "( count( $component ) = 1 ) and ( component != activeModule ) and ( activeModule = '%1' )"; - uniform = uniform.arg( name() ); + QString oneAndNotActive = "( count( $component ) = 1 ) and ( component != activeModule )"; + QString uniform = "true in $canBeDisplayed and %1 and ( activeModule = '%2' )"; + uniform = uniform.arg( oneAndNotActive ).arg( name() ); myPopupMgr->setRule( disp, /*QString( "( not isVisible ) and " ) + */ uniform, true ); myPopupMgr->setRule( erase, /*QString( "( isVisible ) and " ) + */ uniform, true ); myPopupMgr->setRule( dispOnly, uniform, true ); diff --git a/src/LightApp/LightApp_Selection.cxx b/src/LightApp/LightApp_Selection.cxx index 4c43e644d..0e3458f8f 100644 --- a/src/LightApp/LightApp_Selection.cxx +++ b/src/LightApp/LightApp_Selection.cxx @@ -85,21 +85,46 @@ int LightApp_Selection::count() const */ QtxValue LightApp_Selection::param( const int ind, const QString& p ) const { - if( !( ind>=0 && ind( myStudy ? myStudy->application() : 0 ); + if( !( ind>=0 && indmoduleTitle( param( ind, "component" ).toString() ); + LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( mod_name, false ); + // false in last parameter means that now we doesn't load module, if it isn't loaded + + bool vis = false; + if( d ) + vis = d->IsDisplayed( myEntries[ ind ] ); + else + { + LightApp_Displayer local_d; + vis = local_d.IsDisplayed( myEntries[ ind ] ); + } return QtxValue( vis, 0 ); } - else if( p=="component" ) { + + else if( p=="component" ) + { return myStudy->componentDataType( myEntries[ ind ] ); } + else if( p=="isReference" ) return QtxValue( isReference( ind ), false ); + else if( p=="canBeDisplayed" ) + { + QString mod_name = app->moduleTitle( param( ind, "component" ).toString() ); + LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( mod_name, false ); + // false in last parameter means that now we doesn't load module, if it isn't loaded + + return QtxValue( d ? d->canBeDisplayed( myEntries[ ind ] ) : true, 0 ); + //now if displayer is null, it means, that according module isn't loaded, so that we allow to all display/erase + //operations under object + } + return QtxValue(); } diff --git a/src/LightApp/LightApp_ShowHideOp.cxx b/src/LightApp/LightApp_ShowHideOp.cxx index c1a365b8e..525d9f842 100644 --- a/src/LightApp/LightApp_ShowHideOp.cxx +++ b/src/LightApp/LightApp_ShowHideOp.cxx @@ -23,29 +23,6 @@ LightApp_ShowHideOp::~LightApp_ShowHideOp() { } -LightApp_Displayer* LightApp_ShowHideOp::displayer( const QString& mod_name ) const -{ - LightApp_Application* app = dynamic_cast( application() ); - LightApp_Module* m = dynamic_cast( app ? app->module( mod_name ) : 0 ); - if( !m ) - { - m = dynamic_cast( app->loadModule( mod_name ) ); - if( m ) - app->addModule( m ); - } - - if( m ) - { - m->connectToStudy( dynamic_cast( app->activeStudy() ) ); - if( m!=app->activeModule() ) - { - m->setMenuShown( false ); - m->setToolShown( false ); - } - } - return m ? m->displayer() : 0; -} - void LightApp_ShowHideOp::startOperation() { LightApp_Application* app = dynamic_cast( application() ); @@ -65,7 +42,7 @@ void LightApp_ShowHideOp::startOperation() } QString aStr = sel.param( 0, "component" ).toString(); QString mod_name = app->moduleTitle( aStr );//sel.param( 0, "component" ).toString() ); - LightApp_Displayer* d = displayer( mod_name ); + LightApp_Displayer* d = LightApp_Displayer::FindDisplayer( mod_name, true ); if( !d ) { abort(); @@ -80,7 +57,7 @@ void LightApp_ShowHideOp::startOperation() QStringList::const_iterator anIt = comps.begin(), aLast = comps.end(); for( ; anIt!=aLast; anIt++ ) { - LightApp_Displayer* disp = displayer( app->moduleTitle( *anIt ) ); + LightApp_Displayer* disp = LightApp_Displayer::FindDisplayer( app->moduleTitle( *anIt ), true ); if( disp ) disp->EraseAll( false, false, 0 ); } diff --git a/src/LightApp/LightApp_ShowHideOp.h b/src/LightApp/LightApp_ShowHideOp.h index 7c322240c..fd234b58a 100644 --- a/src/LightApp/LightApp_ShowHideOp.h +++ b/src/LightApp/LightApp_ShowHideOp.h @@ -18,7 +18,6 @@ public: protected: virtual void startOperation(); - virtual LightApp_Displayer* displayer( const QString& ) const; private: ActionType myActionType;