From 6186db7ca9c660da9abd2511402c3fb523964034 Mon Sep 17 00:00:00 2001 From: admin Date: Wed, 22 Dec 2004 11:19:47 +0000 Subject: [PATCH] Initial version of files for OCC developers --- bin/salome/runIDLparser.in | 4 +- idl/SALOME_ModuleCatalog.idl | 6 ++- src/Container/Container_i.cxx | 28 ++++++++++++-- src/Loader/SALOME_Session_Loader.cxx | 25 +++++++++++-- .../SALOME_ModuleCatalog_Handler.cxx | 14 +++++++ .../SALOME_ModuleCatalog_Handler.hxx | 2 + .../SALOME_ModuleCatalog_Parser.hxx | 2 + .../SALOME_ModuleCatalog_impl.cxx | 4 ++ src/Plot2d/Plot2d_ViewFrame.cxx | 15 ++++++++ src/SALOMEGUI/QAD_Desktop.cxx | 7 +++- src/SALOMEGUI/QAD_DirListDlg.cxx | 32 ++++++++++++++++ src/SALOMEGUI/QAD_PyEditor.cxx | 37 ++++++++++++++++++- src/SALOMEGUI/QAD_PyEditor.h | 3 +- src/SALOMEGUI/SALOMEGUI_TableDlg.cxx | 9 +++-- src/Session/SALOME_Session_Server.cxx | 30 ++++++++++++--- 15 files changed, 192 insertions(+), 26 deletions(-) diff --git a/bin/salome/runIDLparser.in b/bin/salome/runIDLparser.in index 085ac77d8..9f3afa861 100644 --- a/bin/salome/runIDLparser.in +++ b/bin/salome/runIDLparser.in @@ -36,10 +36,8 @@ fi @ENVSCRIPT@ cd $DIR - -PYTHONPATH=${PYTHONPATH}:${SALOME_HOME_DIR}/bin #============================================================ # omiidl ==================================================== -omniidl -bIDLparser -I ${SALOME_SRC_DIR}/idl $@ +omniidl -bIDLparser -I ${KERNEL_ROOT_DIR}/idl/salome $@ #============================================================ diff --git a/idl/SALOME_ModuleCatalog.idl b/idl/SALOME_ModuleCatalog.idl index 1bac5ce71..6ff889909 100644 --- a/idl/SALOME_ModuleCatalog.idl +++ b/idl/SALOME_ModuleCatalog.idl @@ -169,9 +169,11 @@ This struct contains GUI elements used for representation of the module in %IAPP */ struct IAPP_Affich { - string modulename; /*! orbmodule.py. + string tempfilename = "/tmp/logs/"; + tempfilename += getenv( "USER" ) ; + tempfilename += "/" ; + tempfilename += ContainerName ; + tempfilename += ".log" ; + FILE* f = fopen ( tempfilename.c_str(), "a" ); + if ( f ) { // check if file can be opened for writing + fclose( f ); + shstr += " > " ; + shstr += tempfilename; + shstr += " 2>&1 &" ; + } + else { // if file can't be opened - use a guaranteed temp file name + char* tmpFileName = tempnam( NULL, ContainerName ); + shstr += " > "; + shstr += tmpFileName; + shstr += " 2>&1 &"; + free( tmpFileName ); + } + MESSAGE("system(" << shstr << ")") ; int status = system( shstr.c_str() ) ; if (status == -1) { @@ -448,7 +468,7 @@ void SigIntHandler(int what , siginfo_t * siginfo , // Get the PID of the Container -CORBA::Long Engines_Container_i::getPID() { +long Engines_Container_i::getPID() { return (long)getpid(); } diff --git a/src/Loader/SALOME_Session_Loader.cxx b/src/Loader/SALOME_Session_Loader.cxx index 0db216d3c..9928b9360 100644 --- a/src/Loader/SALOME_Session_Loader.cxx +++ b/src/Loader/SALOME_Session_Loader.cxx @@ -29,10 +29,24 @@ #include "InquireServersQThread.h" using namespace std; +void MessageOutput( QtMsgType type, const char *msg ) +{ + switch ( type ) { + case QtDebugMsg: + MESSAGE( "Debug: " << msg ); + break; + case QtWarningMsg: + MESSAGE( "Warning: " << msg ); + break; + case QtFatalMsg: + MESSAGE( "Fatal: " << msg ); + break; + } +} + int main(int argc, char **argv) { - CORBA::ORB_ptr orb = CORBA::ORB_init(argc,argv) ; - LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb); + qInstallMsgHandler( MessageOutput ); //VRV: T2.4 - Trace management improvement QApplication myQApp(argc, argv) ; InquireServersGUI myIS; @@ -46,7 +60,9 @@ int main(int argc, char **argv) //VRV: T2.4 - Trace management improvement if (myIS.withGUI()) { try - { + { + CORBA::ORB_ptr orb = CORBA::ORB_init(argc,argv) ; + SALOME_NamingService &NS = *SINGLETON_::Instance() ; ASSERT(SINGLETON_::IsAlreadyExisting()) ; NS.init_orb( orb ) ; @@ -86,9 +102,10 @@ int main(int argc, char **argv) { INFOS("Caught unknown exception."); } + return 0 ; } INFOS("Normal Exit"); // without this trace, Splash remains on screen ! - delete myThreadTrace; +// delete myThreadTrace; return 0 ; } diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx index 0a8f27f4e..d698f6459 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx @@ -61,6 +61,8 @@ SALOME_ModuleCatalog_Handler::SALOME_ModuleCatalog_Handler() test_component_multistudy = "component-multistudy"; test_component_icon = "component-icone" ; test_component_impltype = "component-impltype"; + test_component_version = "component-version"; + test_component_comment = "component-comment"; test_interface_name = "component-interface-name" ; @@ -256,6 +258,18 @@ bool SALOME_ModuleCatalog_Handler::endElement(const QString&, return true; } + // tag test_component_version + if((qName.compare(test_component_version)==0)) { + _aModule.version = content ; + return true; + } + + // tag test_component_comment + if((qName.compare(test_component_comment)==0)) { + _aModule.comment = content ; + return true; + } + // interface identification // tag test_interface_name diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx index 775966ae7..43701c983 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx @@ -116,6 +116,8 @@ private: QString test_component_multistudy ; QString test_component_icon ; QString test_component_impltype; + QString test_component_version; + QString test_component_comment; QString test_interface_name; diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Parser.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Parser.hxx index 2fac49367..c23dde27e 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Parser.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Parser.hxx @@ -96,6 +96,8 @@ struct ParserComponent ParserInterfaces interfaces; ParserPathPrefixes prefixes; bool implementationType; + std::string version; + std::string comment; }; typedef std::vector ParserComponents ; diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx index 7018c1cac..845e341dc 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx @@ -301,6 +301,8 @@ SALOME_ModuleCatalogImpl::GetComponentIconeList() _list_components_icone[ind].modulename=(_personal_module_list[ind].name).c_str(); _list_components_icone[ind].moduleusername=(_personal_module_list[ind].username).c_str(); _list_components_icone[ind].moduleicone=(_personal_module_list[ind].icon).c_str(); + _list_components_icone[ind].moduleversion=(_personal_module_list[ind].version).c_str(); + _list_components_icone[ind].modulecomment=(_personal_module_list[ind].comment).c_str(); //if(MYDEBUG) SCRUTE(_list_components_icone[ind].modulename); //if(MYDEBUG) SCRUTE(_list_components_icone[ind].moduleicone); } @@ -325,6 +327,8 @@ SALOME_ModuleCatalogImpl::GetComponentIconeList() _list_components_icone[indice].modulename=_general_module_list[ind].name.c_str(); _list_components_icone[indice].moduleusername=_general_module_list[ind].username.c_str(); _list_components_icone[indice].moduleicone=_general_module_list[ind].icon.c_str(); + _list_components_icone[indice].moduleversion=_general_module_list[ind].version.c_str(); + _list_components_icone[indice].modulecomment=_general_module_list[ind].comment.c_str(); //if(MYDEBUG) SCRUTE(_list_components_icone[indice].modulename) ; //if(MYDEBUG) SCRUTE(_list_components_icone[indice].moduleicone); diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index 49f5cbdd3..ae6234cb8 100644 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -387,6 +387,21 @@ void Plot2d_ViewFrame::Erase( const Handle(SALOME_InteractiveObject)& IObject, b Plot2d_Curve* curve = getCurveByIO( IObject ); if ( curve ) eraseCurve( curve, update ); + // it can be table or container object selected + QAD_Study* activeStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOMEDS::SObject_var aSO = activeStudy->getStudyDocument()->FindObjectID(IObject->getEntry()); + if ( !aSO->_is_nil() ) { + SALOMEDS::ChildIterator_var aIter = activeStudy->getStudyDocument()->NewChildIterator( aSO ); + for ( ; aIter->More(); aIter->Next() ) { + SALOMEDS::SObject_var aChildSO = aIter->Value(); + SALOMEDS::SObject_var refSO; + if ( aChildSO->ReferencedObject( refSO ) && !refSO->_is_nil() ) + aChildSO = refSO; + curve = getCurveByIO( new SALOME_InteractiveObject( aChildSO->GetID(), "", "" ) ); + if ( curve ) + eraseCurve( curve, update ); + } + } } /*! Actually this method just re-displays all curves which are presented in the viewer diff --git a/src/SALOMEGUI/QAD_Desktop.cxx b/src/SALOMEGUI/QAD_Desktop.cxx index 69bde6093..49d457d63 100644 --- a/src/SALOMEGUI/QAD_Desktop.cxx +++ b/src/SALOMEGUI/QAD_Desktop.cxx @@ -97,7 +97,7 @@ #include #include #include - +#include #include #if QT_VERSION > 300 @@ -292,6 +292,8 @@ myAboutToClose( false ) QString iconfile = CORBA::string_dup(list_composants[ind].moduleicone) ; QString modulename = CORBA::string_dup(list_composants[ind].modulename) ; QString moduleusername = CORBA::string_dup(list_composants[ind].moduleusername) ; + QString moduleversion = CORBA::string_dup(list_composants[ind].moduleversion) ; + QString modulecomment = CORBA::string_dup(list_composants[ind].modulecomment) ; // MESSAGE ( " MODULE = " << modulename ) // MESSAGE ( " MODULE icon = " << iconfile ) @@ -313,7 +315,10 @@ myAboutToClose( false ) QToolButton * toolb = new QToolButton( QIconSet( Icone ), moduleusername, QString::null, this, SLOT( onButtonActiveComponent () ),tbComponent ); + QString ttip = QString("") + moduleusername + QString(""); + if ( !moduleversion.isEmpty() ) ttip += QString("
Version: ") + moduleversion; toolb->setToggleButton( true ); + QToolTip::add(toolb, ttip, this->toolTipGroup(), modulecomment); myComponentButton.append(toolb); } else diff --git a/src/SALOMEGUI/QAD_DirListDlg.cxx b/src/SALOMEGUI/QAD_DirListDlg.cxx index 542df51cf..a0479d944 100644 --- a/src/SALOMEGUI/QAD_DirListDlg.cxx +++ b/src/SALOMEGUI/QAD_DirListDlg.cxx @@ -142,9 +142,41 @@ void QAD_DirListDlg::setPathList(const QStringList& list) { /*! Validates entered path, returns true if OK */ +#ifndef WNT +#include +#endif bool QAD_DirListDlg::validate() { if (myEdited) { QString dirPath = myEdit->text().stripWhiteSpace(); +#ifndef WNT + if ( dirPath.startsWith( "~") ) { + dirPath = dirPath.remove(0,1); + QString user; + int slashPos = dirPath.find("/"); + if ( slashPos >= 0 ) { + user = dirPath.left(slashPos); + dirPath = dirPath.mid(slashPos); + } + else { + user = dirPath; + dirPath = ""; + } + if ( user.isEmpty() ) + user = getenv( "USER" ); + + struct passwd* user_data = getpwnam( user.latin1() ); + if ( user_data == NULL ) { + // unknown user or something another error + QAD_MessageBox::error1(this, + tr("ERR_ERROR"), + tr("Unknown user %1").arg(user), + tr("BUT_OK")); + myEdit->setFocus(); + return false; + } + dirPath = user_data->pw_dir + dirPath; + } +#endif QDir dir(dirPath); QListBoxItem* found = 0; for (unsigned i = 0; i < myDirList->count()-1; i++) { diff --git a/src/SALOMEGUI/QAD_PyEditor.cxx b/src/SALOMEGUI/QAD_PyEditor.cxx index f5258e1a0..ab17fc756 100644 --- a/src/SALOMEGUI/QAD_PyEditor.cxx +++ b/src/SALOMEGUI/QAD_PyEditor.cxx @@ -316,8 +316,42 @@ void QAD_PyEditor::mousePressEvent (QMouseEvent * event) } /*! - Called when a Mouse release event + Called when any event occures. The function is redefined to handle MousePress events + in order to provide the following behaviour: on middle mouse button press a previously + selected text (by mouse drag or left mouse button double click) is appended to the last + paragraph. This behaviour is similar to standard Unix terminal editor behaviour. */ +bool QAD_PyEditor::eventFilter( QObject *o, QEvent *e ) +{ + const int t = e->type(); + if ( t == QEvent::MouseButtonPress || t == QEvent::MouseButtonRelease ) { + QMouseEvent * event = (QMouseEvent*)e; + if ( event->button() == MidButton ) { + if ( t == QEvent::MouseButtonPress ) { + QString selection = selectedText(); + QClipboard *cb = QApplication::clipboard(); + if ( !selection.isNull() && !selection.isEmpty() ) + cb->setText( selection ); + const int endPara = paragraphs()-1; + insertAt( cb->text(), endPara, paragraphLength( endPara )-1 ); + return true; // don't allow futher event processing + } + // code from old mouseReleaseEvent() function. + else if ( t == QEvent::MouseButtonRelease ) { + int curPara, curCol; // for cursor position + int endPara, endCol; // for last edited line + getCursorPosition(&curPara, &curCol); + endPara = paragraphs() -1; + return ( curPara != endPara || curCol < SIZEPR ); + } + } + } + return QTextEdit::eventFilter( o, e ); +} + +/*! + Called when a Mouse release event + void QAD_PyEditor::mouseReleaseEvent ( QMouseEvent * e ) { // MESSAGE("mouseReleaseEvent"); @@ -330,6 +364,7 @@ void QAD_PyEditor::mouseReleaseEvent ( QMouseEvent * e ) else if ((curPara == endPara) && (curCol >= SIZEPR)) QTextEdit::mouseReleaseEvent(e); } +*/ /*! Called when a drop event (Drag & Drop) diff --git a/src/SALOMEGUI/QAD_PyEditor.h b/src/SALOMEGUI/QAD_PyEditor.h index fd7ff4955..5c1972909 100644 --- a/src/SALOMEGUI/QAD_PyEditor.h +++ b/src/SALOMEGUI/QAD_PyEditor.h @@ -61,9 +61,10 @@ public: protected: virtual void keyPressEvent (QKeyEvent * e); virtual void mousePressEvent (QMouseEvent * e); - virtual void mouseReleaseEvent (QMouseEvent * e); + //virtual void mouseReleaseEvent (QMouseEvent * e); virtual void dropEvent (QDropEvent *e); virtual void customEvent (QCustomEvent *e); + virtual bool eventFilter(QObject *o, QEvent *e); public slots: void handleReturn(); diff --git a/src/SALOMEGUI/SALOMEGUI_TableDlg.cxx b/src/SALOMEGUI/SALOMEGUI_TableDlg.cxx index a70b74df4..1b24930b3 100644 --- a/src/SALOMEGUI/SALOMEGUI_TableDlg.cxx +++ b/src/SALOMEGUI/SALOMEGUI_TableDlg.cxx @@ -579,9 +579,10 @@ void SALOMEGUI_TableWidget::setColTitles( QStringList& tlts ) // !!! first column contains units !!! for ( int i = 0; i < tlts.count(); i++ ) { myOrientation == Horizontal ? - myTable->horizontalHeader()->setLabel( i+1, tlts[i] ) : - myTable->verticalHeader()->setLabel( i+1, tlts[i] ); + myTable->horizontalHeader()->setLabel( i+1, tlts[i].isNull() ? "" : tlts[i] ) : + myTable->verticalHeader()->setLabel( i+1, tlts[i].isNull() ? "" : tlts[i] ); } + setUnitsTitle( tr( "UNITS_TLT" ) ); } /*! Sets columns titles @@ -606,7 +607,7 @@ void SALOMEGUI_TableWidget::getColTitles( QStringList& tlts ) */ void SALOMEGUI_TableWidget::setUnitsTitle( const QString& tlt ) { // !!! first column contains units !!! - myOrientation == Horizontal ? myTable->horizontalHeader()->setLabel( 0, tlt ) : myTable->verticalHeader()->setLabel( 0, tlt ); + myOrientation == Horizontal ? myTable->horizontalHeader()->setLabel( 0, tlt.isNull() ? "" : tlt ) : myTable->verticalHeader()->setLabel( 0, tlt.isNull() ? "" : tlt ); } /*! Sets units @@ -614,7 +615,7 @@ void SALOMEGUI_TableWidget::setUnitsTitle( const QString& tlt ) { void SALOMEGUI_TableWidget::setUnits( QStringList& units ) { for ( int i = 0; i < units.count(); i++ ) { - myOrientation == Horizontal ? myTable->setText( i, 0, units[i] ) : myTable->setText( 0, i, units[i] ); + myOrientation == Horizontal ? myTable->setText( i, 0, units[i].isNull() ? "" : units[i] ) : myTable->setText( 0, i, units[i].isNull() ? "" : units[i] ); } } /*! diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index 33d3440a3..39df11075 100644 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -90,15 +90,33 @@ static int MYDEBUG = 0; static int MYDEBUG = 0; #endif +void MessageOutput( QtMsgType type, const char *msg ) +{ + switch ( type ) { + case QtDebugMsg: + MESSAGE( "Debug: " << msg ); + break; + case QtWarningMsg: + MESSAGE( "Warning: " << msg ); + break; + case QtFatalMsg: + MESSAGE( "Fatal: " << msg ); + break; + } +} + int main(int argc, char **argv) { - SALOME_Event::GetSessionThread(); - ORB_INIT &init = *SINGLETON_::Instance() ; - int orbArgc = 1; - CORBA::ORB_var &orb = init( orbArgc , argv ) ; - LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb); + qInstallMsgHandler( MessageOutput ); try { + SALOME_Event::GetSessionThread(); + + ORB_INIT &init = *SINGLETON_::Instance() ; + ASSERT(SINGLETON_::IsAlreadyExisting()) ; + int orbArgc = 1; + CORBA::ORB_var &orb = init( orbArgc , argv ) ; + CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow(obj); @@ -254,6 +272,6 @@ int main(int argc, char **argv) INFOS("Caught unknown exception."); } MESSAGE("End of SALOME_Session_Server"); - delete myThreadTrace; +// delete myThreadTrace; return 0 ; } -- 2.39.2