]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Improve loading of components GUI : load once and cash
authorsmh <smh@opencascade.com>
Wed, 31 Mar 2004 14:21:23 +0000 (14:21 +0000)
committersmh <smh@opencascade.com>
Wed, 31 Mar 2004 14:21:23 +0000 (14:21 +0000)
src/SALOMEGUI/QAD_Desktop.cxx
src/SALOMEGUI/QAD_Desktop.h
src/SALOMEGUI/SALOMEGUI.cxx
src/SALOMEGUI/SALOMEGUI.h
src/SALOMEGUI/SALOMEGUI_Application.cxx

index d2bd943893bc05f37d083aaa7eab1113c97737dc..3538e40a30136b79e61c9cb2a622b9321ad3a6d9 100644 (file)
@@ -55,6 +55,7 @@
 //NRI #include "QAD_HelpWindow.h"
 #include "QAD_DirListDlg.h"
 #include "QAD_WaitCursor.h"
+#include "SALOMEGUI.h"
 #include "SALOMEGUI_OpenWith.h"
 #include "SALOMEGUI_StudyPropertiesDlg.h"
 #include "SALOMEGUI_TrihedronSizeDlg.h"
@@ -2533,28 +2534,20 @@ void QAD_Desktop::onOpenWith()
   QApplication::restoreOverrideCursor();
 }
 
-typedef bool OneDim1(QAD_Desktop*);
-typedef bool OneDim2(QAD_Desktop*, char*);
 
 /*!
   Called to define settings of component.
 */
 void QAD_Desktop::setSettings()
 {
-  if (!myActiveComp.isEmpty()) {
-    OSD_Function osdF = mySharedLibrary.DlSymb("SetSettings");
-    if ( osdF != NULL )
-      if (_islibso)
-       {
-         OneDim1 (*f1) = (bool (*) (QAD_Desktop*)) osdF;
-         (*f1)(this);
-       }
-      else
-       {
-         QString Component =mapComponentName[myActiveComp];
-         OneDim2 (*f1) = (bool (*) (QAD_Desktop*, char*)) osdF;
-         (*f1)(this, (char*)Component.latin1());
-       }
+  SALOMEGUI* anActiveGUI = getActiveGUI();
+  if ( anActiveGUI ) {
+    if (_islibso)
+      anActiveGUI->SetSettings( this );
+    else {
+      QString Component = mapComponentName[myActiveComp];
+      anActiveGUI->SetSettings( this, (char*)Component.latin1() );
+    }
   }
 }
 
@@ -2634,95 +2627,19 @@ bool QAD_Desktop::loadComponent(QString Component)
   int nbToolbars = 0;
   if (myActiveMenus)
     nbToolbars = myActiveMenus->getToolBarList().count();
-  /* Open Shared Library */
-  mySharedLibrary = OSD_SharedLibrary();
-  _islibso = false;
-
-  QString ComponentLib;
-  QCString libs;
-  QFileInfo fileInfo ;
-  QString fileString ;
-  QString dir;
-
-  if ( libs = getenv("LD_LIBRARY_PATH")) {
-    //    MESSAGE ( " LD_LIBRARY_PATH : " << libs );
-    QStringList dirList = QStringList::split( SEPARATOR, libs, false ); // skip empty entries
-    for ( int i = dirList.count()-1; i >= 0; i-- ) {
-      dir = dirList[ i ];
-#ifdef WNT
-      fileString = QAD_Tools::addSlash( dir ) + "lib" + Component + "GUI.dll" ;
-#else
-      fileString = QAD_Tools::addSlash( dir ) + "lib" + Component + "GUI.so" ;
-#endif
-    
-      fileInfo.setFile(fileString) ;
-      if (fileInfo.exists()) {
-       //      MESSAGE ( " GUI library = " << fileString );
-       ComponentLib = fileInfo.fileName() ;
-       _islibso = true;
-       break;
-      }
-    }
-  }
-
-  if (!_islibso) // component GUI could be in PyQt, use generic library
-    {
-      MESSAGE("GUI library not found, trying generic library for PyQt GUI");
-      bool found = false;
-      if (dir = getenv("KERNEL_ROOT_DIR"))
-       {
-         dir = QAD_Tools::addSlash(dir) ;
-         dir = dir + "lib" ;
-         dir = QAD_Tools::addSlash(dir) ;
-         dir = dir + "salome" ;
-         dir = QAD_Tools::addSlash(dir) ;
-#ifdef WNT
-         dir = dir + "libSalomePyQtcmodule.dll" ;
-#else
-         dir = dir + "libSalomePyQtcmodule.so" ;
-#endif
-         MESSAGE ( " GUI library = " << dir );
-         fileInfo.setFile(dir) ;
-         if (fileInfo.exists())
-           {
-             ComponentLib = fileInfo.fileName() ;
-             found = true;
-           }
-       }
-      if ( !found )
-       {
-         QMessageBox::critical( this,
-                                tr("ERR_ERROR"),
-                                tr("ERR_LIBGUI" ).arg(Component) );
-         return false;
-       }
-    }
 
-  mySharedLibrary.SetName(TCollection_AsciiString((char*)ComponentLib.latin1()).ToCString());
-  ok = mySharedLibrary.DlOpen(OSD_RTLD_LAZY);
-  if (!ok) {
-    wc.stop();
-    QMessageBox::critical( this,
-                          tr("ERR_ERROR"),
-                          tr( mySharedLibrary.DlError() ) );
+  // san - avoid loading component GUI library multiple times
+  QString aUserName( getComponentUserName( Component ) );
+  
+  SALOMEGUI* anActiveGUI = getComponentGUI(aUserName);
+  if ( !anActiveGUI )
     return false;
-  }
 
   /* SETTINGS */
-  OSD_Function osdF = mySharedLibrary.DlSymb("SetSettings");
-  if ( osdF != NULL )
-    if (_islibso)
-      {
-       OneDim1 (*f1) = (bool (*) (QAD_Desktop*)) osdF;
-       (*f1)(this);
-      }
-    else
-      {
-       OneDim2 (*f1) = (bool (*) (QAD_Desktop*, char*)) osdF;
-       (*f1)(this, (char*)Component.latin1());
-      }
-
-  
+  if (_islibso)
+    anActiveGUI->SetSettings( this );
+  else
+    anActiveGUI->SetSettings( this, (char*)Component.latin1() );
 
   /* COMPONENT INTERFACE */
   SALOME_ModuleCatalog::Acomponent_ptr aComponent =
@@ -3000,14 +2917,9 @@ void QAD_Desktop::onDispatchTools(int id)
  */
 void QAD_Desktop::onDispatch(int id)
 {
-  if (!myActiveComp.isEmpty()) {
-    OSD_Function osdF = mySharedLibrary.DlSymb("OnGUIEvent");
-    OneDim (*f1) = NULL;
-    if ( osdF != NULL ) {
-      f1 = (bool (*) (int, QAD_Desktop*)) osdF;
-      (*f1)(id,this);
-    }
-  }
+  SALOMEGUI* anActiveGUI = getActiveGUI();
+  if ( anActiveGUI ) 
+    anActiveGUI->OnGUIEvent(id,this);
 }
 
 /*!
@@ -3190,13 +3102,9 @@ typedef bool TwoDim1(QKeyEvent* pe, QAD_Desktop*, QAD_StudyFrame*);
 void QAD_Desktop::onKeyPress( QKeyEvent* pe )
 {
   //  MESSAGE ( "QAD_Desktop::onKeyPress" )
-  if (!myActiveComp.isEmpty()) {
-    OSD_Function osdF = mySharedLibrary.DlSymb("OnKeyPress");
-    if ( osdF != NULL ) {
-      TwoDim1 (*f1) = (bool (*) (QKeyEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF;
-      (*f1)(pe,this,myActiveStudy->getActiveStudyFrame());
-    }
-  }
+  SALOMEGUI* anActiveGUI = getActiveGUI();
+  if ( anActiveGUI ) 
+    anActiveGUI->OnKeyPress(pe,this,myActiveStudy->getActiveStudyFrame());
 }
 
 typedef bool TwoDim(QMouseEvent* pe, QAD_Desktop*, QAD_StudyFrame*);
@@ -3206,13 +3114,9 @@ typedef bool TwoDim(QMouseEvent* pe, QAD_Desktop*, QAD_StudyFrame*);
 bool QAD_Desktop::onMousePress( QMouseEvent* pe )
 {
   //  MESSAGE ( "QAD_Desktop::onMousePress" )
-  if (!myActiveComp.isEmpty()) {
-    OSD_Function osdF = mySharedLibrary.DlSymb("OnMousePress");
-    if ( osdF != NULL ) {
-      TwoDim (*f1) = (bool (*) (QMouseEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF;
-      return (*f1)(pe,this,myActiveStudy->getActiveStudyFrame());
-    }
-  }
+  SALOMEGUI* anActiveGUI = getActiveGUI();
+  if ( anActiveGUI ) 
+    return anActiveGUI->OnMousePress(pe,this,myActiveStudy->getActiveStudyFrame());
   return false;
 }
 
@@ -3221,13 +3125,9 @@ bool QAD_Desktop::onMousePress( QMouseEvent* pe )
  */
 void QAD_Desktop::onMouseMove( QMouseEvent* pe )
 {
-  if (!myActiveComp.isEmpty()) {
-    OSD_Function osdF = mySharedLibrary.DlSymb("OnMouseMove");
-    if ( osdF != NULL ) {
-      TwoDim (*f1) = (bool (*) (QMouseEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF;
-      (*f1)(pe,this,myActiveStudy->getActiveStudyFrame());
-    }
-  }
+  SALOMEGUI* anActiveGUI = getActiveGUI();
+  if ( anActiveGUI ) 
+    anActiveGUI->OnMouseMove(pe,this,myActiveStudy->getActiveStudyFrame());
 }
 
 /*!
@@ -3238,20 +3138,129 @@ const QString& QAD_Desktop::getActiveComponent() const
   return myActiveComp;
 }
 
+SALOMEGUI* QAD_Desktop::getActiveGUI()
+{
+  SALOMEGUI* anActiveGUI = 0;
+  if ( myComponents.find( myActiveComp ) != myComponents.end() )
+    anActiveGUI = myComponents[myActiveComp];
+  return anActiveGUI;
+}
 
-typedef bool defineP( QString & theContext, QString & theParent, QString & theObject);
+typedef SALOMEGUI* (*ComponentGUI)();
 
-void QAD_Desktop::definePopup(QString & theContext,
-                             QString & theParent, 
-                             QString & theObject ) 
+SALOMEGUI* QAD_Desktop::getComponentGUI( const QString& component )
 {
-  if (!myActiveComp.isEmpty()) {
-    OSD_Function osdF = mySharedLibrary.DlSymb("definePopup");
+  SALOMEGUI* aCompGUI = 0;
+  
+  // Load component GUI if requested for the first time
+  if ( myComponents.find( component ) == myComponents.end() ) {
+    OSD_SharedLibrary aSharedLibrary;
+    QString ComponentLib;
+    QCString libs;
+    QFileInfo fileInfo ;
+    QString fileString ;
+    QString dir;
+
+    QAD_WaitCursor wc;
+    
+    if ( libs = getenv("LD_LIBRARY_PATH")) {
+      //    MESSAGE ( " LD_LIBRARY_PATH : " << libs );
+      QStringList dirList = QStringList::split( SEPARATOR, libs, false ); // skip empty entries
+      for ( int i = dirList.count()-1; i >= 0; i-- ) {
+       dir = dirList[ i ];
+#ifdef WNT
+       fileString = QAD_Tools::addSlash( dir ) + "lib" + getComponentName( component ) + "GUI.dll" ;
+#else
+       fileString = QAD_Tools::addSlash( dir ) + "lib" + getComponentName( component ) + "GUI.so" ;
+#endif
+    
+       fileInfo.setFile(fileString) ;
+       if (fileInfo.exists()) {
+         //    MESSAGE ( " GUI library = " << fileString );
+         ComponentLib = fileInfo.fileName() ;
+         _islibso = true;
+         break;
+       }
+      }
+    }
+
+    if (!_islibso) // component GUI could be in PyQt, use generic library
+    {
+      MESSAGE("GUI library not found, trying generic library for PyQt GUI");
+      bool found = false;
+      if (dir = getenv("KERNEL_ROOT_DIR"))
+      {
+       dir = QAD_Tools::addSlash(dir) ;
+       dir = dir + "lib" ;
+       dir = QAD_Tools::addSlash(dir) ;
+       dir = dir + "salome" ;
+       dir = QAD_Tools::addSlash(dir) ;
+#ifdef WNT
+       dir = dir + "libSalomePyQtcmodule.dll" ;
+#else
+       dir = dir + "libSalomePyQtcmodule.so" ;
+#endif
+       MESSAGE ( " GUI library = " << dir );
+       fileInfo.setFile(dir) ;
+       if (fileInfo.exists())
+       {
+         ComponentLib = fileInfo.fileName() ;
+         found = true;
+       }
+      }
+      if ( !found )
+      {
+       QMessageBox::critical( this,
+                             tr("ERR_ERROR"),
+                             tr("ERR_LIBGUI" ).arg(component) );
+       return aCompGUI;
+      }
+    }
+
+    aSharedLibrary.SetName(TCollection_AsciiString((char*)ComponentLib.latin1()).ToCString());
+    bool ok = aSharedLibrary.DlOpen(OSD_RTLD_LAZY);
+    if (!ok) {
+      wc.stop();
+      QMessageBox::critical( this,
+                           tr("ERR_ERROR"),
+                           tr( aSharedLibrary.DlError() ) );
+      return aCompGUI;
+    }
+
+    OSD_Function osdF = aSharedLibrary.DlSymb("GetComponentGUI");
     if ( osdF != NULL ) {
-      defineP (*f1) = (bool (*) (QString &, QString &, QString &)) osdF;
-      (*f1)(theContext, theParent, theObject);
+      ComponentGUI f1 = (SALOMEGUI* (*) ()) osdF;
+      SALOMEGUI* aCompGUI = (*f1)();
+      if ( aCompGUI )
+       myComponents.insert( component, aCompGUI );
+      else {
+       wc.stop();
+       QMessageBox::critical( this,
+                             tr("ERR_ERROR"),
+                             tr("ERR_LIBGUI" ).arg(component) );
+       return aCompGUI;
+      }
+    }
+    else {
+      wc.stop();
+      QMessageBox::critical( this,
+                           tr("ERR_ERROR"),
+                           tr("ERR_LIBGUI" ).arg(component) );
+      return aCompGUI;
     }
   }
+  aCompGUI = myComponents[component];
+  return aCompGUI;
+}
+
+
+void QAD_Desktop::definePopup(QString & theContext,
+                             QString & theParent, 
+                             QString & theObject ) 
+{
+  SALOMEGUI* anActiveGUI = getActiveGUI();
+  if ( anActiveGUI ) 
+    anActiveGUI->DefinePopup(theContext, theParent, theObject);
 }
 
 /*!
@@ -3345,35 +3354,22 @@ void QAD_Desktop::createPopup(QPopupMenu* popup, const QString & theContext,
  
 }
 
-typedef bool activeStudyChanged(QAD_Desktop*);
-
 void QAD_Desktop::onActiveStudyChanged()
 {
-  if (!myActiveComp.isEmpty()) {
-    OSD_Function osdF = mySharedLibrary.DlSymb("activeStudyChanged");
-    if ( osdF != NULL ) {
-      activeStudyChanged (*f1) = (bool (*) (QAD_Desktop*)) osdF;
-      (*f1)(this);
-    }  
-  }
+  SALOMEGUI* anActiveGUI = getActiveGUI();
+  if ( anActiveGUI ) 
+    anActiveGUI->ActiveStudyChanged(this);
 }
 
-typedef bool customP(QAD_Desktop*, QPopupMenu*, const QString & theContext,
-                    const QString & theParent, const QString & theObject);
 /*!
   Custom popup ( GUI Library )
 */
 void QAD_Desktop::customPopup(QPopupMenu* popup, const QString & theContext,
                              const QString & theParent, const QString & theObject)
 {
-  if (!myActiveComp.isEmpty()) {
-    OSD_Function osdF = mySharedLibrary.DlSymb("customPopup");
-    if ( osdF != NULL ) {
-      customP (*f1) = (bool (*) (QAD_Desktop*, QPopupMenu*, const QString &,
-                                const QString &, const QString &)) osdF;
-      (*f1)(this, popup, theContext, theParent, theObject);
-    }
-  }
+  SALOMEGUI* anActiveGUI = getActiveGUI();
+  if ( anActiveGUI ) 
+    anActiveGUI->CustomPopup(this, popup, theContext, theParent, theObject);
 }
 
 void QAD_Desktop::onObjectBrowser()
index 56f8a79072ea4c9ed7a1cf66b606ee0c06853ce7..7cce46ea3bdf39613d9d64a9dc86039dc5cb1d6b 100644 (file)
@@ -63,6 +63,7 @@
 #include <OSD_SharedLibrary.hxx>
 
 class QAD_XmlHandler;
+class SALOMEGUI;
 
 class QAD_EXPORT QAD_Desktop : public QMainWindow
 {
@@ -163,8 +164,9 @@ public:
 
     QAD_Menus*           getActiveMenus()      {return myActiveMenus;}
     QAD_OperatorMenus*   getOperatorMenus()    {return myOperatorMenus;}
-    const OSD_SharedLibrary&  getHandle() const {return mySharedLibrary;}// never return sych objects "by value"
     const QString&       getActiveComponent() const;
+    SALOMEGUI*            getActiveGUI();
+    SALOMEGUI*            getComponentGUI( const QString& );  // accepts component`s user name
     SALOME_NamingService* getNameService()      {return myNameService;}
 
     Engines::Component_var getEngine(const char *containerName,
@@ -317,12 +319,14 @@ protected:
 
     QMap<QString,QString> mapComponentName;
 
+private:
+    typedef QMap<QString, SALOMEGUI*> ComponentMap;
+
 private:
     static QAD_ResourceMgr*                resourceMgr;
     static QPalette*                       palette;
     void                                   createActions();
     void                                   updateActions();
-    OSD_SharedLibrary                      mySharedLibrary;
     QAD_XmlHandler*                        myXmlHandler;
     QString                                myActiveComp;
     SALOME_NamingService*                  myNameService;
@@ -331,6 +335,8 @@ private:
     QComboBox *                                    myCombo;
     bool                                    myQueryClose;
     bool                                    _islibso;
+
+    ComponentMap                            myComponents;
 };
 
 /********************************************************************
index 7f6efa6a2a4503faefaabd6ce3942d6bc9d9838e..e3843bd2515c4826616d081a64650f7864c3226f 100644 (file)
@@ -118,6 +118,16 @@ bool SALOMEGUI::SetSettings( QAD_Desktop* parent )
   return true;
 }
 
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool SALOMEGUI::SetSettings( QAD_Desktop* parent, char* compName )
+{
+  return true;
+}
+
 //=============================================================================
 /*!
  *
index f23d5cd8ffb566d5dc9c83bc61fc803a08837461..0594487d424c48ecc8e8d85bfab6c3f6d49756f2 100644 (file)
@@ -61,6 +61,7 @@ public:
   virtual bool OnMousePress      (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame);
   virtual bool OnMouseMove       (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame);
   virtual bool SetSettings       ( QAD_Desktop* parent );
+  virtual bool SetSettings       ( QAD_Desktop* parent, char* compName );
   virtual bool CustomPopup       ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext,
                                    const QString & theParent, const QString & theObject );
   virtual void DefinePopup       ( QString & theContext, QString & theParent, QString & theObject );
index faa38b44dd75129db8bc1b33cb01cf8ac0f7f740..8d95761e962f82effbf2d125faf45098e52cac4b 100644 (file)
@@ -29,6 +29,7 @@
 #include "SALOMEGUI_Application.h"
 #include "SALOMEGUI_Desktop.h"
 #include "SALOMEGUI_ImportOperation.h"
+#include "SALOMEGUI.h"
 #include "SALOME_Selection.h"
 #include "SALOME_ListIO.hxx"
 #include "SALOME_ListIteratorOfListIO.hxx"
@@ -429,104 +430,26 @@ void SALOMEGUI_Application::onDisplay(int id)
     return;
   }
 
-  // Obtain the component's GUI library  
-  // Library cashing will be implemented soon in QAD_Desktop to increase performance
-  OSD_Function osdF, osdViewTypeFunc;
-  OSD_SharedLibrary foreignGUI;
-  void (*builder)(const Handle(SALOME_InteractiveObject)&); 
-  bool isForeignGUIUsed = false;
   bool isViewTypeOK     = true;
   int  viewTypes[VIEW_TYPE_MAX];
 
   for (int i = 0; i < VIEW_TYPE_MAX; i++)
     viewTypes[i] = -1;
 
-  if (parentComp.compare(desktop->getActiveComponent()) == 0) { // use active GUI library
-    const OSD_SharedLibrary& compGUI = desktop->getHandle();
-    osdF = compGUI.DlSymb("buildPresentation");
-    if ( osdF == NULL ) {
-      MESSAGE("BuildPresentation method not found in component's GUI")
-      return;
-    }
-    osdViewTypeFunc = compGUI.DlSymb("supportedViewType");
-    if ( osdViewTypeFunc == NULL ) {
-      MESSAGE("supportedViewType method not found in component's GUI")
-    }
-    MESSAGE("onDisplay(): using active GUI to build presentations")
-  } else { // use native GUI library
-    QString ComponentLib;
-    QCString dir;
-    QFileInfo fileInfo ;
-    bool found = false;
-    if ( getenv( QAD_Application::getDesktop()->getComponentName(parentComp) + "_ROOT_DIR")  ) {
-      dir.fill('\0');
-      dir.sprintf("%s", getenv( QAD_Application::getDesktop()->getComponentName(parentComp) + "_ROOT_DIR"));
-      dir = QAD_Tools::addSlash(dir) ;
-      dir = dir + "lib" ;
-      dir = QAD_Tools::addSlash(dir) ;
-      dir = dir + "salome" ;
-      dir = QAD_Tools::addSlash(dir) ;
-#ifdef WNT
-      dir = dir + "lib" + QAD_Application::getDesktop()->getComponentName(parentComp).latin1() + "GUI.dll" ;
-#else
-      dir = dir + "lib" + QAD_Application::getDesktop()->getComponentName(parentComp).latin1() + "GUI.so" ;
-#endif
-      MESSAGE ( " GUI library = " << dir )
-      fileInfo.setFile(dir) ;
-      if (fileInfo.exists()) {
-       ComponentLib = fileInfo.fileName() ;
-       found = true;
-       MESSAGE ( " found " )
-      } else {
-       MESSAGE ( " Not found " )
-      }
-    }
-    
-    if (ComponentLib.isEmpty()) {
-      waitCursor.stop();
-      QMessageBox::critical( desktop,
-                           tr("ERR_ERROR"),
-                           "Empty name of component "+ parentComp + " library");
-      return;
-    }
-
-    foreignGUI.SetName(TCollection_AsciiString((char*)ComponentLib.latin1()).ToCString());
-   
-    bool ok = foreignGUI.DlOpen(OSD_RTLD_LAZY);
-    if (!ok) {
-      waitCursor.stop();
-      QMessageBox::critical( desktop,
-                          tr("ERR_ERROR"),
-                          tr( foreignGUI.DlError() ) );
-      return;
-    }
-    
-    osdF = foreignGUI.DlSymb("buildPresentation");
-    if ( osdF == NULL ) {
-      MESSAGE("BuildPresentation method not found in component's GUI")
-      foreignGUI.DlClose();
-      return;
-    } 
-    osdViewTypeFunc = foreignGUI.DlSymb("supportedViewType");
-    if ( osdViewTypeFunc == NULL ) {
-      MESSAGE("supportedViewType method not found in component's GUI")
-    }
-    isForeignGUIUsed = true;
-    MESSAGE("onDisplay(): using parent component's GUI to build presentations")
-  }
+  // Obtain the component's GUI 
+  SALOMEGUI* aGUI = desktop->getComponentGUI( parentComp );
+  if ( !aGUI )
+    return;
 
   // Check if another view type is required (if viewToActivate < 0 then any type of view is acceptable)
-  if (osdViewTypeFunc) {
-    void (*viewTypeChecker)(int*, int) = (void (*)(int*, int)) osdViewTypeFunc; 
-    (*viewTypeChecker)(viewTypes, VIEW_TYPE_MAX);
-    if (viewTypes[0] >= 0) { // not all the view types are supported
-      for (int i = 0; i < VIEW_TYPE_MAX; i++) {
-       if (viewTypes[i] < 0) // no more types supported
-         break;
-       isViewTypeOK = ((int)myActiveStudy->getActiveStudyFrame()->getTypeView() == viewTypes[i]);
-       if (isViewTypeOK) // one of supported views is already active
-         break;
-      }
+  aGUI->SupportedViewType(viewTypes, VIEW_TYPE_MAX);
+  if (viewTypes[0] >= 0) { // not all the view types are supported
+    for (int i = 0; i < VIEW_TYPE_MAX; i++) {
+      if (viewTypes[i] < 0) // no more types supported
+       break;
+      isViewTypeOK = ((int)myActiveStudy->getActiveStudyFrame()->getTypeView() == viewTypes[i]);
+      if (isViewTypeOK) // one of supported views is already active
+       break;
     }
   }
 
@@ -557,7 +480,6 @@ void SALOMEGUI_Application::onDisplay(int id)
   QAD_ViewFrame* viewFrame = myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame();
 
   // Build the graphic presentation (it is stored in the corresponding viewer)
-  builder = (void (*) (const Handle(SALOME_InteractiveObject)&)) osdF;
 
   // Copy the selection
   SALOME_ListIteratorOfListIO itInit( Sel->StoredIObjects() );
@@ -598,13 +520,13 @@ void SALOMEGUI_Application::onDisplay(int id)
        childIObject->setEntry(child->GetID());
 
        // Ensure that proper 3D presentation exists for IObject
-       (*builder)(childIObject);
+       aGUI->BuildPresentation(childIObject);
        viewFrame->Display(childIObject, false);
        needRepaint = true;
       }
     } else { // for child object -> simply display it (no children are displayed)
       // Ensure that proper 3D presentation exists for IObject
-      (*builder)(IObject);
+      aGUI->BuildPresentation(IObject);
       viewFrame->Display(IObject, false);
       needRepaint = true;
     }
@@ -614,8 +536,6 @@ void SALOMEGUI_Application::onDisplay(int id)
   if (needRepaint)
     viewFrame->Repaint();
 
-  if (isForeignGUIUsed)
-    ;//foreignGUI.DlClose(); // VSR: Fix crash on Display objects from non-parent components
   myActiveStudy->updateObjBrowser(true);
 }