#include "LightApp_Displayer.h"
#include "LightApp_Application.h"
+#include "LightApp_Module.h"
+
+#include <CAM_Study.h>
#include <SALOME_InteractiveObject.hxx>
}
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<LightApp_Application*>( 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<LightApp_Application*>( sapp );
+ if( !app )
+ return 0;
+
+ LightApp_Module* m = dynamic_cast<LightApp_Module*>( app ? app->module( mod_name ) : 0 );
+ if( !m && load )
+ {
+ m = dynamic_cast<LightApp_Module*>( app->loadModule( mod_name ) );
+ if( m )
+ app->addModule( m );
+ }
+
+ if( m )
+ {
+ m->connectToStudy( dynamic_cast<CAM_Study*>( app->activeStudy() ) );
+ if( m!=app->activeModule() && load )
+ {
+ m->setMenuShown( false );
+ m->setToolShown( false );
+ }
+ }
+ return m ? m->displayer() : 0;
+}
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 );
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 );
*/
QtxValue LightApp_Selection::param( const int ind, const QString& p ) const
{
- if( !( ind>=0 && ind<count() ) )
+ LightApp_Application* app = dynamic_cast<LightApp_Application*>( myStudy ? myStudy->application() : 0 );
+ if( !( ind>=0 && ind<count() ) || !app )
return QtxValue();
if( p=="isVisible" )
{
- LightApp_Displayer d;
- bool vis = d.IsDisplayed( myEntries[ ind ] );
+ 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
+
+ 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();
}
{
}
-LightApp_Displayer* LightApp_ShowHideOp::displayer( const QString& mod_name ) const
-{
- LightApp_Application* app = dynamic_cast<LightApp_Application*>( application() );
- LightApp_Module* m = dynamic_cast<LightApp_Module*>( app ? app->module( mod_name ) : 0 );
- if( !m )
- {
- m = dynamic_cast<LightApp_Module*>( app->loadModule( mod_name ) );
- if( m )
- app->addModule( m );
- }
-
- if( m )
- {
- m->connectToStudy( dynamic_cast<CAM_Study*>( 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<LightApp_Application*>( application() );
}
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();
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 );
}
protected:
virtual void startOperation();
- virtual LightApp_Displayer* displayer( const QString& ) const;
private:
ActionType myActionType;