//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"
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() );
+ }
}
}
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 =
*/
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);
}
/*!
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*);
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;
}
*/
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());
}
/*!
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);
}
/*!
}
-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()
#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"
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;
}
}
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() );
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;
}
if (needRepaint)
viewFrame->Repaint();
- if (isForeignGUIUsed)
- ;//foreignGUI.DlClose(); // VSR: Fix crash on Display objects from non-parent components
myActiveStudy->updateObjBrowser(true);
}