Handle_SALOME_NumberFilter.hxx \
SALOME_DataMapOfIOMapOfInteger.hxx \
Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx \
+ SALOMEGUI.h \
SALOMEGUI_LoadStudiesDlg.h \
SALOMEGUI_TableDlg.h \
SALOMEGUI_NameDlg.h \
SALOMEGUI_SetupCurveDlg.h \
SALOMEGUI_CloseDlg.h
-
# .po files to transform in .qm
PO_FILES = \
QAD_icons.po \
QAD_StudyFrame.cxx \
QAD_Tools.cxx \
QAD_ViewFrame.cxx \
+ SALOMEGUI.cxx \
SALOMEGUI_Application.cxx \
SALOMEGUI_Desktop.cxx \
SALOMEGUI_ImportOperation.cxx \
SALOMEGUI_CloseDlg.cxx \
SALOMEGUI_ActivateComponentDlg.cxx
LIB_MOC = \
+ SALOMEGUI.h \
SALOMEGUI_Application.h \
SALOMEGUI_Desktop.h \
QAD_Application.h \
SALOME_Exception.idl
CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES)
-LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lqsplitterP -lSalomeLifeCycleCORBA -lOpUtil -lSalomeObject
+LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lqsplitterP -lSalomeLifeCycleCORBA -lOpUtil -lSalomeObject -lEvent
LIBS+= $(PYTHON_LIBS)
//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"
#include "SALOMEGUI_CloseDlg.h"
#include "SALOMEGUI_ActivateComponentDlg.h"
+#include "SALOME_Event.hxx"
+
// QT Includes
#include <qlabel.h>
#include <qlayout.h>
#endif
// Open CASCADE Includes
+#include <OSD_SharedLibrary.hxx>
#include <OSD_LoadMode.hxx>
#include <OSD_Function.hxx>
#include <TCollection_AsciiString.hxx>
}
}
}
+ else if ( e->type() == SALOME_EVENT ) {
+ SALOME_Event* aSE = (SALOME_Event*)((QCustomEvent*)e)->data();
+ MESSAGE( "QAD_Desktop::eventFilter - SALOME_Event handling - 1 : o = " << o << ", e = " << aSE);
+
+ processEvent( aSE );
+ MESSAGE( "QAD_Desktop::eventFilter - SALOME_Event handling - 2" );
+
+ // Signal the calling thread that the event has been processed
+ aSE->processed();
+ MESSAGE( "QAD_Desktop::eventFilter - SALOME_Event handling - 3" );
+
+ ((QCustomEvent*)e)->setData( 0 );
+ delete aSE;
+ return TRUE;
+ }
return QMainWindow::eventFilter( o, e );
}
+/*!
+ Dispatches <theEvent> to the target component GUI
+*/
+void QAD_Desktop::processEvent( SALOME_Event* theEvent )
+{
+ if ( !theEvent )
+ return;
+
+ if(theEvent->Execute())
+ return;
+
+ // san - temporary code - to be removed together with VISU_Event and test operations in VISU_I...
+ for ( ComponentMap::iterator it = myComponents.begin(); it != myComponents.end(); it++ ) {
+ if ( it.data()->CanProcessEvent( theEvent ) && it.data()->ProcessEvent( theEvent ) )
+ break;
+ }
+ // san - temporary code - to be removed together with VISU_Event and test operations in VISU_I...
+}
+
/*!
Creates and initializes the standard file operations
such as 'New/Open/Save/SaveAs/Close' and 'Help'.
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*);
-typedef void deactivate();
-
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);
}
void QAD_Desktop::deactivateComponent()
{
- if (!myActiveComp.isEmpty()) {
- OSD_Function osdF = mySharedLibrary.DlSymb("deactivate");
- if ( osdF != NULL ) {
- deactivate (*f1) = (void (*)()) osdF;
- (*f1)();
- }
- }
+ SALOMEGUI* anActiveGUI = getActiveGUI();
+ if ( anActiveGUI )
+ anActiveGUI->Deactivate();
}
-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 <qfiledialog.h>
#include <qtoolbutton.h>
-// Open CASCADE Includes
-#include <OSD_SharedLibrary.hxx>
-
class QAD_XmlHandler;
+class SALOMEGUI;
+class SALOME_Event;
class QAD_EXPORT QAD_Desktop : public QMainWindow
{
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,
QMap<QString,QString> mapComponentName;
+private:
+ void processEvent( SALOME_Event* );
+
+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;
QComboBox * myCombo;
bool myQueryClose;
bool _islibso;
+
+ ComponentMap myComponents;
};
/********************************************************************
// Module : SALOME
// $Header$
-using namespace std;
#include "QAD_PyEditor.h"
#include "QAD_PyInterp.h"
#include "QAD_Application.h"
#include "QAD_Tools.h"
#include "QAD_MessageBox.h"
//#include "QAD_RightFrame.h"
+using namespace std;
#include <qapplication.h>
#include <qmap.h>
#include <qclipboard.h>
+#include <qthread.h>
// NRI : Temporary added
// IDL Headers
#define SIZEPR 4
enum { IdCopy, IdPaste, IdClear, IdSelectAll };
+class PythonThread : public QThread
+{
+public:
+ PythonThread( PyInterp_base* interp, QAD_PyEditor* listener )
+ : QThread(), myInterp( interp ), myListener( listener ), myCommand( 0 )
+ {}
+
+ virtual ~PythonThread() {}
+
+ void exec( const char* command )
+ {
+ myCommand = (char*)command;
+ start();
+ }
+
+protected:
+ virtual void run()
+ {
+ if ( myInterp && myCommand && myListener ) {
+ myListener->viewport()->setCursor( waitCursor );
+ int ret = myInterp->run( myCommand );
+ QThread::postEvent( myListener,
+ new QCustomEvent( ret < 0 ? QAD_PyEditor::PYTHON_ERROR : ( ret ? QAD_PyEditor::PYTHON_INCOMPLETE : QAD_PyEditor::PYTHON_OK ) ) );
+ myListener->viewport()->unsetCursor();
+ }
+ }
+
+private:
+ PyInterp_base* myInterp;
+ QAD_PyEditor* myListener;
+ char* myCommand;
+};
+
/*!
Constructor
*/
QAD_PyEditor::QAD_PyEditor(QAD_PyInterp* interp,
QWidget *parent, const char *name)
- : QMultiLineEdit(parent,name)
+ : QTextEdit(parent,name)
{
QString fntSet = QAD_CONFIG->getSetting("Viewer:ConsoleFont");
QFont myFont = QAD_Tools::stringToFont( fntSet );
// QFont myFont("Courier",11);
setFont(myFont);
+ setTextFormat(QTextEdit::PlainText);
_interp = interp;
string banner = _interp->getbanner();
setText(banner.c_str());
setText(_currentPrompt);
setPalette( QAD_Application::getPalette(true) );
setWordWrap(NoWrap);
+
+ _thread = new PythonThread( interp, this );
+
connect(this,SIGNAL(returnPressed()),this,SLOT(handleReturn()) );
}
*/
QAD_PyEditor::~QAD_PyEditor()
{
+ if ( _thread->wait( 1000 ) )
+ delete _thread;
}
/*!
void QAD_PyEditor::setText(QString s)
{
// MESSAGE("setText");
- int line=numLines()-1;
- int col=lineLength(line);
- insertAt(s,line,col);
- int n = numLines()-1;
- setCursorPosition( n, textLine(n).length());
+ int para=paragraphs()-1;
+ int col=paragraphLength(para);
+ insertAt(s,para,col);
+ int n = paragraphs()-1;
+ setCursorPosition( n, paragraphLength(n));
}
/*!
*/
void QAD_PyEditor::handleReturn()
{
- QApplication::setOverrideCursor( Qt::waitCursor );
int ret;
- int line=numLines()-2;
+ int para=paragraphs()-2;
// NRI : Temporary added
SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
}
// NRI
- _buf.append(textLine(line).remove(0,SIZEPR));
- ret = _interp->run(_buf);
- if(ret <= 0)
- {
- _buf.truncate(0);
- setText(_interp->getvout());
- setText(_interp->getverr());
- _currentPrompt = ">>> ";
- setText(_currentPrompt);
- }
- if(ret == 1)
- {
- _buf.append("\n");
- _currentPrompt = "... ";
- setText(_currentPrompt);
- }
- _isInHistory = false;
- QApplication::restoreOverrideCursor();
+ _buf.append(text(para).remove(0,SIZEPR));
+ _buf.truncate( _buf.length() - 1 );
+ setReadOnly( true );
+ _thread->exec(_buf.latin1());
}
/*
QPopupMenu *popup = new QPopupMenu( this );
QMap<int, int> idMap;
- int line1, col1, line2, col2;
- getMarkedRegion(&line1, &col1, &line2, &col2);
- bool allSelected = getMarkedRegion(&line1, &col1, &line2, &col2) &&
- line1 == 0 && line2 == numLines()-1 && col1 == 0 && col2 == lineLength(line2);
+ int para1, col1, para2, col2;
+ getSelection(¶1, &col1, ¶2, &col2);
+ bool allSelected = hasSelectedText() &&
+ para1 == 0 && para2 == paragraphs()-1 && col1 == 0 && para2 == paragraphLength(para2);
int id;
id = popup->insertItem( tr( "EDIT_COPY_CMD" ) );
idMap.insert(IdCopy, id);
popup->insertSeparator();
id = popup->insertItem( tr( "EDIT_SELECTALL_CMD" ) );
idMap.insert(IdSelectAll, id);
- popup->setItemEnabled( idMap[ IdCopy ], hasMarkedText() );
+ popup->setItemEnabled( idMap[ IdCopy ], hasSelectedText() );
popup->setItemEnabled( idMap[ IdPaste ],
!isReadOnly() && (bool)QApplication::clipboard()->text().length() );
popup->setItemEnabled( idMap[ IdSelectAll ],
return;
}
else {
- QMultiLineEdit::mousePressEvent(event);
+ QTextEdit::mousePressEvent(event);
}
}
void QAD_PyEditor::mouseReleaseEvent ( QMouseEvent * e )
{
// MESSAGE("mouseReleaseEvent");
- int curLine, curCol; // for cursor position
- int endLine, endCol; // for last edited line
- getCursorPosition(&curLine, &curCol);
- endLine = numLines() -1;
+ int curPara, curCol; // for cursor position
+ int endPara, endCol; // for last edited line
+ getCursorPosition(&curPara, &curCol);
+ endPara = paragraphs() -1;
if (e->button() != MidButton)
- QMultiLineEdit::mouseReleaseEvent(e);
- else if ((curLine == endLine) && (curCol >= SIZEPR))
- QMultiLineEdit::mouseReleaseEvent(e);
+ QTextEdit::mouseReleaseEvent(e);
+ else if ((curPara == endPara) && (curCol >= SIZEPR))
+ QTextEdit::mouseReleaseEvent(e);
}
/*!
int curLine, curCol; // for cursor position
int endLine, endCol; // for last edited line
getCursorPosition(&curLine, &curCol);
- endLine = numLines() -1;
+ endLine = paragraphs() -1;
//MESSAGE("current position " << curLine << ", " << curCol);
//MESSAGE("last line " << endLine);
//MESSAGE(e->key());
{
case 0 :
{
- if (curLine <endLine)
- {
- setCursorPosition(endLine, SIZEPR);
- end();
- }
- QMultiLineEdit::keyPressEvent( e );
+ if (curLine <endLine || curCol < SIZEPR )
+ moveCursor(QTextEdit::MoveEnd, false);
+ QTextEdit::keyPressEvent( e );
break;
}
case Key_Return:
case Key_Enter:
{
if (curLine <endLine)
- {
- setCursorPosition(endLine, SIZEPR);
- }
- end();
- QMultiLineEdit::keyPressEvent( e );
+ moveCursor(QTextEdit::MoveEnd, false);
+ else
+ moveCursor(QTextEdit::MoveLineEnd, false);
+ QTextEdit::keyPressEvent( e );
break;
}
case Key_Up:
{
// if Cntr+Key_Up event then move cursor up
if (ctrlPressed) {
- QMultiLineEdit::cursorUp( );
+ moveCursor(QTextEdit::MoveUp, false);
}
// if Shift+Key_Up event then move cursor up and select the text
else if ( shftPressed && curLine > 0 ){
- setCursorPosition(curLine-1, curCol, true);
+ moveCursor(QTextEdit::MoveUp, true);
}
// scroll the commands stack up
else {
if (! _isInHistory)
{
_isInHistory = true;
- _currentCommand = textLine(endLine).remove(0,SIZEPR);
+ _currentCommand = text(endLine).remove(0,SIZEPR);
+ _currentCommand.truncate( _currentCommand.length() - 1 );
SCRUTE(_currentCommand);
}
QString previousCommand = _interp->getPrevious();
if (previousCommand.compare(BEGIN_HISTORY_PY) != 0)
{
- removeLine(endLine);
+ removeParagraph(endLine);
histLine.append(previousCommand);
- insertLine(histLine);
+ insertParagraph(histLine, -1);
}
- endLine = numLines() -1;
- setCursorPosition(endLine, lineLength(endLine));
+ moveCursor(QTextEdit::MoveEnd, false);
}
break;
}
{
// if Cntr+Key_Down event then move cursor down
if (ctrlPressed) {
- QMultiLineEdit::cursorDown( );
+ moveCursor(QTextEdit::MoveDown, false);
}
// if Shift+Key_Down event then move cursor down and select the text
else if ( shftPressed && curLine < endLine ) {
- setCursorPosition(curLine+1, curCol, true);
+ moveCursor(QTextEdit::MoveDown, true);
}
// scroll the commands stack down
else {
QString nextCommand = _interp->getNext();
if (nextCommand.compare(TOP_HISTORY_PY) != 0)
{
- removeLine(endLine);
+ removeParagraph(endLine);
histLine.append(nextCommand);
- insertLine(histLine);
+ insertParagraph(histLine, -1);
}
else
if (_isInHistory)
{
_isInHistory = false;
- removeLine(endLine);
+ removeParagraph(endLine);
histLine.append(_currentCommand);
- insertLine(histLine);
+ insertParagraph(histLine, -1);
}
- endLine = numLines() -1;
- setCursorPosition(endLine, lineLength(endLine));
+ moveCursor(QTextEdit::MoveEnd, false);
}
break;
}
case Key_Left:
{
- if (!shftPressed && isCommand(textLine(curLine)) && curCol <= SIZEPR )
+ if (!shftPressed && isCommand(text(curLine)) && curCol <= SIZEPR )
{
setCursorPosition((curLine -1), SIZEPR);
- end();
+ moveCursor(QTextEdit::MoveLineEnd, false);
}
- else QMultiLineEdit::keyPressEvent( e );
+ else QTextEdit::keyPressEvent( e );
break;
}
case Key_Right:
{
- if (!shftPressed && isCommand(textLine(curLine))
- && curCol < SIZEPR) setCursorPosition(curLine, SIZEPR-1);
- QMultiLineEdit::keyPressEvent( e );
+ if (!shftPressed && isCommand(text(curLine))
+ && curCol < SIZEPR) setCursorPosition(curLine, SIZEPR);
+ QTextEdit::keyPressEvent( e );
break;
}
case Key_Home:
{
- if (isCommand(textLine(curLine)) && curCol <= SIZEPR)
- setCursorPosition(curLine, SIZEPR, shftPressed);
- else setCursorPosition(curLine, 0, shftPressed);
+ horizontalScrollBar()->setValue( horizontalScrollBar()->minValue() );
+ if (isCommand(text(curLine))) {
+ setCursorPosition(curLine, SIZEPR);
+ if ( curCol > SIZEPR && shftPressed )
+ setSelection( curLine, SIZEPR, curLine, curCol );
+ else
+ selectAll( false );
+ }
+ else moveCursor(QTextEdit::MoveLineStart, shftPressed);
break;
}
case Key_End:
{
- setCursorPosition(curLine, textLine(curLine).length(), shftPressed);
+ moveCursor(QTextEdit::MoveLineEnd, shftPressed);
break;
}
case Key_Backspace :
{
if ((curLine == endLine) && (curCol > SIZEPR))
- QMultiLineEdit::keyPressEvent( e );
+ QTextEdit::keyPressEvent( e );
break;
}
case Key_Delete :
{
if ((curLine == endLine) && (curCol > SIZEPR-1))
- QMultiLineEdit::keyPressEvent( e );
+ QTextEdit::keyPressEvent( e );
+ break;
+ }
+ case Key_Insert :
+ {
+ if ( ctrlPressed )
+ copy();
+ else if ( shftPressed ) {
+ moveCursor(QTextEdit::MoveEnd, false);
+ paste();
+ }
+ else
+ QTextEdit::keyPressEvent( e );
break;
}
}
QAD_Application::getDesktop()->onKeyPress( e );
// NRI //
}
+
+void QAD_PyEditor::customEvent(QCustomEvent *e)
+{
+ switch( e->type() ) {
+ case PYTHON_OK:
+ case PYTHON_ERROR:
+ {
+ _buf.truncate(0);
+ setText(_interp->getvout());
+ setText(_interp->getverr());
+ _currentPrompt = ">>> ";
+ setText(_currentPrompt);
+ break;
+ }
+ case PYTHON_INCOMPLETE:
+ {
+ _buf.append("\n");
+ _currentPrompt = "... ";
+ setText(_currentPrompt);
+ break;
+ }
+ default:
+ QTextEdit::customEvent( e );
+ }
+
+ setReadOnly( false );
+ _isInHistory = false;
+}
#ifndef QAD_PyEditor_H
#define QAD_PyEditor_H
-#include <qmultilineedit.h>
+#include <qtextedit.h>
+#include <qevent.h>
class QAD_PyInterp;
+class PythonThread;
-class QAD_PyEditor : public QMultiLineEdit
+class QAD_PyEditor : public QTextEdit
{
Q_OBJECT
+public:
+ enum { PYTHON_OK = QEvent::User + 5000, PYTHON_ERROR, PYTHON_INCOMPLETE };
+
public:
QAD_PyEditor(QAD_PyInterp* interp, QWidget *parent=0, const char *name=0);
~QAD_PyEditor();
- void setText(QString s);
+ virtual void setText(QString s);
bool isCommand(const QString& str) const;
protected:
- void keyPressEvent (QKeyEvent * e);
- void mousePressEvent (QMouseEvent * e);
- void mouseReleaseEvent (QMouseEvent * e);
- void dropEvent (QDropEvent *e);
+ virtual void keyPressEvent (QKeyEvent * e);
+ virtual void mousePressEvent (QMouseEvent * e);
+ virtual void mouseReleaseEvent (QMouseEvent * e);
+ virtual void dropEvent (QDropEvent *e);
+ virtual void customEvent (QCustomEvent *e);
public slots:
void handleReturn();
QString _currentCommand;
QString _currentPrompt;
bool _isInHistory;
+
+ PythonThread* _thread;
};
#endif
//
//
// File : SALOMEGUI.cxx
-// Author : Nicolas REJNERI
+// Author : Sergey ANIKIN
// Module : SALOME
// $Header$
-using namespace std;
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SALOMEDS)
-
-#include "QAD.h"
-#include "QAD_MessageBox.h"
-#include "QAD_Application.h"
-#include "SALOMEGUI_Application.h"
-
-#include <qmainwindow.h>
-#include <qapplication.h>
-
-#include "SALOME_NamingService.hxx"
-
-int main(int argc, char* argv[])
-{
- QApplication a( argc, argv );
-
- // Setting up the CORBA environment
- // Initializing omniORB
- SALOME_NamingService * name_service;
- CORBA::ORB_var orb;
-
- // orb = CORBA::ORB_init(argc, argv, "omniORB4");
- orb = CORBA::ORB_init(argc, argv, "omniORB3");
-
- // Get the reference the server.
- name_service = new SALOME_NamingService(orb);
-
- QAD_ASSERT ( QObject::connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) ) );
-
- /* Initialize the desktop and 'SALOMEGUI' application */
- SALOMEGUI_Application* app =
- new SALOMEGUI_Application ( "MDTV-Standard", "HDF","hdf" );
-
- if ( !SALOMEGUI_Application::addToDesktop ( app, name_service ) )
- {
- QAD_MessageBox::error1 ( 0,
- QObject::tr("ERR_ERROR"),
- QObject::tr("ERR_APP_INITFAILED"),
- QObject::tr("BUT_OK") );
- return -1;
- }
-
- QPalette pal;
- QColorGroup cg;
- cg.setColor( QColorGroup::Foreground, Qt::black );
- cg.setColor( QColorGroup::Button, QColor( 192, 192, 192) );
- cg.setColor( QColorGroup::Light, Qt::white );
- cg.setColor( QColorGroup::Midlight, QColor( 223, 223, 223) );
- cg.setColor( QColorGroup::Dark, QColor( 96, 96, 96) );
- cg.setColor( QColorGroup::Mid, QColor( 128, 128, 128) );
- cg.setColor( QColorGroup::Text, Qt::black );
- cg.setColor( QColorGroup::BrightText, Qt::white );
- cg.setColor( QColorGroup::ButtonText, Qt::black );
- cg.setColor( QColorGroup::Base, Qt::white );
- cg.setColor( QColorGroup::Background, QColor( 192, 192, 192) );
- cg.setColor( QColorGroup::Shadow, Qt::black );
- cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) );
- cg.setColor( QColorGroup::HighlightedText, Qt::white );
- pal.setActive( cg );
- cg.setColor( QColorGroup::Foreground, Qt::black );
- cg.setColor( QColorGroup::Button, QColor( 192, 192, 192) );
- cg.setColor( QColorGroup::Light, Qt::white );
- cg.setColor( QColorGroup::Midlight, QColor( 220, 220, 220) );
- cg.setColor( QColorGroup::Dark, QColor( 96, 96, 96) );
- cg.setColor( QColorGroup::Mid, QColor( 128, 128, 128) );
- cg.setColor( QColorGroup::Text, Qt::black );
- cg.setColor( QColorGroup::BrightText, Qt::white );
- cg.setColor( QColorGroup::ButtonText, Qt::black );
- cg.setColor( QColorGroup::Base, Qt::white );
- cg.setColor( QColorGroup::Background, QColor( 192, 192, 192) );
- cg.setColor( QColorGroup::Shadow, Qt::black );
- cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) );
- cg.setColor( QColorGroup::HighlightedText, Qt::white );
- pal.setInactive( cg );
- cg.setColor( QColorGroup::Foreground, QColor( 128, 128, 128) );
- cg.setColor( QColorGroup::Button, QColor( 192, 192, 192) );
- cg.setColor( QColorGroup::Light, Qt::white );
- cg.setColor( QColorGroup::Midlight, QColor( 220, 220, 220) );
- cg.setColor( QColorGroup::Dark, QColor( 96, 96, 96) );
- cg.setColor( QColorGroup::Mid, QColor( 128, 128, 128) );
- cg.setColor( QColorGroup::Text, Qt::black );
- cg.setColor( QColorGroup::BrightText, Qt::white );
- cg.setColor( QColorGroup::ButtonText, QColor( 128, 128, 128) );
- cg.setColor( QColorGroup::Base, Qt::white );
- cg.setColor( QColorGroup::Background, QColor( 192, 192, 192) );
- cg.setColor( QColorGroup::Shadow, Qt::black );
- cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) );
- cg.setColor( QColorGroup::HighlightedText, Qt::white );
- pal.setDisabled( cg );
- qApp->setPalette( pal );
-
- /* Run 'SALOMEGUI' application */
- QAD_Application::run();
- a.exec();
-
- delete name_service;
- orb->destroy();
-
- return 0;
+#include "SALOMEGUI.h"
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+SALOMEGUI::SALOMEGUI( const QString& name, QObject* parent )
+: QObject( parent ),
+ myName( name )
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+SALOMEGUI::~SALOMEGUI()
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool SALOMEGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
+{
+ return true;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool SALOMEGUI::CanProcessEvent(SALOME_Event* se)
+{
+ return false;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool SALOMEGUI::ProcessEvent(SALOME_Event* se)
+{
+ return false;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool SALOMEGUI::OnKeyPress(QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
+{
+ return true;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool SALOMEGUI::OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
+{
+ return true;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool SALOMEGUI::OnMouseMove(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
+{
+ return true;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool SALOMEGUI::SetSettings( QAD_Desktop* parent )
+{
+ return true;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool SALOMEGUI::SetSettings( QAD_Desktop* parent, char* compName )
+{
+ return true;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool SALOMEGUI::CustomPopup( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext,
+ const QString & theParent, const QString & theObject )
+{
+ return true;
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void SALOMEGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+bool SALOMEGUI::ActiveStudyChanged( QAD_Desktop* parent )
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void SALOMEGUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& theIO )
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void SALOMEGUI::SupportedViewType(int* buffer, int bufferSize)
+{
+}
+
+//=============================================================================
+/*!
+ *
+ */
+//=============================================================================
+void SALOMEGUI::Deactivate()
+{
+ emit SignalCloseAllDialogs();
}
+
--- /dev/null
+// SALOME SALOMEGUI : implementation of desktop and GUI kernel
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : SALOMEGUI.hxx
+// Author : Sergey ANIKIN
+// Module : SALOME
+// $Header$
+
+#ifndef SALOMEGUI_HeaderFile
+#define SALOMEGUI_HeaderFile
+
+#include <Standard_Macro.hxx>
+
+#include <qobject.h>
+#include <qstring.h>
+
+class QAD_Desktop;
+class QAD_StudyFrame;
+class SALOME_Event;
+
+class Handle_SALOME_InteractiveObject;
+
+class QKeyEvent;
+class QMouseEvent;
+class QPopupMenu;
+class QString;
+
+
+class Standard_EXPORT SALOMEGUI : public QObject
+{
+ Q_OBJECT
+
+public:
+ SALOMEGUI( const QString& name, QObject* parent = 0 );
+ virtual ~SALOMEGUI();
+
+ virtual bool OnGUIEvent (int theCommandID, QAD_Desktop* parent);
+ virtual bool CanProcessEvent (SALOME_Event* se);
+ virtual bool ProcessEvent (SALOME_Event* se);
+ virtual bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame);
+ 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 );
+ virtual bool ActiveStudyChanged( QAD_Desktop* parent );
+ virtual void BuildPresentation ( const Handle(SALOME_InteractiveObject)& theIO );
+ virtual void SupportedViewType (int* buffer, int bufferSize);
+ virtual void Deactivate ();
+
+signals:
+ void SignalDeactivateActiveDialog();
+ void SignalCloseAllDialogs ();
+
+private:
+ QString myName;
+};
+
+#endif
// Module : SALOME
// $Header$
-using namespace std;
#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"
// Open CASCADE Include
#include <Standard_Failure.hxx>
#include <TCollection_AsciiString.hxx>
+using namespace std;
/*!
Constructor
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);
}