2 #include "SalomeApp_Displayer.h"
3 #include "SalomeApp_Application.h"
5 #include <SALOME_InteractiveObject.hxx>
7 #include <SUIT_Session.h>
8 #include <SUIT_Desktop.h>
9 #include <SUIT_ViewManager.h>
10 #include <SUIT_ViewModel.h>
11 #include <SUIT_ViewWindow.h>
15 SalomeApp_Displayer::SalomeApp_Displayer()
19 SalomeApp_Displayer::~SalomeApp_Displayer()
23 void SalomeApp_Displayer::Display( const QString& entry, const bool updateViewer, SALOME_View* theViewFrame )
25 SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
28 SALOME_Prs* prs = buildPresentation( entry, vf );
32 vf->BeforeDisplay( this );
34 vf->AfterDisplay( this );
39 delete prs; // delete presentation because displayer is its owner
44 void SalomeApp_Displayer::Redisplay( const QString& entry, const bool updateViewer )
46 // Remove the object permanently (<forced> == true)
47 SUIT_Session* ses = SUIT_Session::session();
48 SUIT_Application* app = ses->activeApplication();
51 SUIT_Desktop* desk = app->desktop();
52 QPtrList<SUIT_ViewWindow> wnds = desk->windows();
54 for ( wnd = wnds.first(); wnd; wnd = wnds.next() )
56 SUIT_ViewManager* vman = wnd->getViewManager();
60 SUIT_ViewModel* vmodel = vman->getViewModel();
64 SALOME_View* view = dynamic_cast<SALOME_View*>(vmodel);
65 if( view && ( IsDisplayed( entry, view ) || view == GetActiveView() ) )
67 Erase( entry, true, false, view );
68 Display( entry, updateViewer, view );
74 void SalomeApp_Displayer::Erase( const QString& entry, const bool forced,
75 const bool updateViewer, SALOME_View* theViewFrame )
77 SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
80 SALOME_Prs* prs = vf->CreatePrs( entry.latin1() );
82 vf->Erase( prs, forced );
85 delete prs; // delete presentation because displayer is its owner
90 void SalomeApp_Displayer::EraseAll( const bool forced, const bool updateViewer, SALOME_View* theViewFrame ) const
92 SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
95 vf->EraseAll( forced );
101 bool SalomeApp_Displayer::IsDisplayed( const QString& entry, SALOME_View* theViewFrame ) const
103 SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
106 Handle( SALOME_InteractiveObject ) temp = new SALOME_InteractiveObject();
107 temp->setEntry( entry.latin1() );
108 return vf->isVisible( temp );
114 void SalomeApp_Displayer::UpdateViewer() const
116 SALOME_View* vf = GetActiveView();
121 SALOME_Prs* SalomeApp_Displayer::buildPresentation( const QString& entry, SALOME_View* theViewFrame )
125 SALOME_View* vf = theViewFrame ? theViewFrame : GetActiveView();
128 prs = vf->CreatePrs( entry.latin1() );
133 SALOME_View* SalomeApp_Displayer::GetActiveView()
135 SUIT_Session* session = SUIT_Session::session();
136 if ( SUIT_Application* app = session->activeApplication() ) {
137 if ( SalomeApp_Application* sApp = dynamic_cast<SalomeApp_Application*>( app ) ) {
138 if( SUIT_ViewManager* vman = sApp->activeViewManager() ) {
139 if ( SUIT_ViewModel* vmod = vman->getViewModel() )
140 return dynamic_cast<SALOME_View*>( vmod );